PX4 Firmware
PX4 Autopilot Software http://px4.io
ToneAlarm Class Reference

#include <ToneAlarm.h>

Inheritance diagram for ToneAlarm:
Collaboration diagram for ToneAlarm:

Public Member Functions

 ToneAlarm ()
 
 ~ToneAlarm ()
 
int init () override
 Initializes the character device and hardware registers. More...
 
void status ()
 Prints the driver status to the console. More...
 
- Public Member Functions inherited from cdev::CDev
 CDev (const char *devname)
 Constructor. More...
 
 CDev (const CDev &)=delete
 
CDevoperator= (const CDev &)=delete
 
 CDev (CDev &&)=delete
 
CDevoperator= (CDev &&)=delete
 
virtual ~CDev ()
 
virtual int open (file_t *filep)
 Handle an open of the device. More...
 
virtual int close (file_t *filep)
 Handle a close of the device. More...
 
virtual ssize_t read (file_t *filep, char *buffer, size_t buflen)
 Perform a read from the device. More...
 
virtual ssize_t write (file_t *filep, const char *buffer, size_t buflen)
 Perform a write to the device. More...
 
virtual off_t seek (file_t *filep, off_t offset, int whence)
 Perform a logical seek operation on the device. More...
 
virtual int ioctl (file_t *filep, int cmd, unsigned long arg)
 Perform an ioctl operation on the device. More...
 
virtual int poll (file_t *filep, px4_pollfd_struct_t *fds, bool setup)
 Perform a poll setup/teardown operation. More...
 
const char * get_devname () const
 Get the device name. More...
 

Protected Member Functions

void next_note ()
 Parses the next note out of the string and plays it. More...
 
void Run () override
 Trampoline for the work queue. More...
 
void orb_update ()
 Updates the uORB topics for local subscribers. More...
 
void start_note (unsigned frequency)
 Starts playing the note. More...
 
void stop_note ()
 Stops playing the current note and makes the player 'safe'. More...
 
- Protected Member Functions inherited from cdev::CDev
virtual pollevent_t poll_state (file_t *filep)
 Check the current state of the device for poll events from the perspective of the file. More...
 
virtual void poll_notify (pollevent_t events)
 Report new poll events. More...
 
virtual void poll_notify_one (px4_pollfd_struct_t *fds, pollevent_t events)
 Internal implementation of poll_notify. More...
 
virtual int open_first (file_t *filep)
 Notification of the first open. More...
 
virtual int close_last (file_t *filep)
 Notification of the last close. More...
 
virtual int register_class_devname (const char *class_devname)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
virtual int unregister_class_devname (const char *class_devname, unsigned class_instance)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
void lock ()
 Take the driver lock. More...
 
void unlock ()
 Release the driver lock. More...
 
int unregister_driver_and_memory ()
 First, unregisters the driver. More...
 

Protected Attributes

volatile bool _running {false}
 Flag to indicate the current driver status. More...
 
int _cbrk {CBRK_UNINIT}
 If true, no audio output. More...
 
- Protected Attributes inherited from cdev::CDev
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes) More...
 

Private Attributes

volatile bool _should_run {true}
 
bool _play_tone {false}
 
unsigned int _silence_length {0}
 If nonzero, silence before next note. More...
 
uORB::Subscription _tune_control_sub {ORB_ID(tune_control)}
 
tune_control_s _tune {}
 
Tunes _tunes = Tunes()
 

Additional Inherited Members

- Static Protected Attributes inherited from cdev::CDev
static const px4_file_operations_t fops = {}
 Pointer to the default cdev file operations table; useful for registering clone devices etc. More...
 

Detailed Description

Definition at line 58 of file ToneAlarm.h.

Constructor & Destructor Documentation

◆ ToneAlarm()

ToneAlarm::ToneAlarm ( )

Definition at line 42 of file ToneAlarm.cpp.

Referenced by tone_alarm_main().

Here is the caller graph for this function:

◆ ~ToneAlarm()

ToneAlarm::~ToneAlarm ( )

Definition at line 48 of file ToneAlarm.cpp.

References _running, _should_run, and counter.

Member Function Documentation

◆ init()

int ToneAlarm::init ( )
overridevirtual

Initializes the character device and hardware registers.

Reimplemented from cdev::CDev.

Definition at line 59 of file ToneAlarm.cpp.

References _running, ToneAlarmInterface::init(), and OK.

Here is the call graph for this function:

◆ next_note()

void ToneAlarm::next_note ( )
protected

Parses the next note out of the string and plays it.

Definition at line 75 of file ToneAlarm.cpp.

References _play_tone, _running, _should_run, _silence_length, _tunes, Tunes::get_maximum_update_interval(), Tunes::get_next_note(), orb_update(), start_note(), and stop_note().

Referenced by Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ orb_update()

void ToneAlarm::orb_update ( )
protected

Updates the uORB topics for local subscribers.

Definition at line 127 of file ToneAlarm.cpp.

References _play_tone, _tune, _tune_control_sub, _tunes, uORB::Subscription::copy(), Tunes::set_control(), tune_control_s::timestamp, and uORB::Subscription::updated().

Referenced by next_note().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Run()

void ToneAlarm::Run ( )
overrideprotected

Trampoline for the work queue.

Definition at line 122 of file ToneAlarm.cpp.

References next_note().

Here is the call graph for this function:

◆ start_note()

void ToneAlarm::start_note ( unsigned  frequency)
protected

Starts playing the note.

Definition at line 149 of file ToneAlarm.cpp.

References _cbrk, CBRK_BUZZER_KEY, CBRK_OFF, CBRK_UNINIT, circuit_breaker_enabled(), and ToneAlarmInterface::start_note().

Referenced by next_note().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ status()

void ToneAlarm::status ( )

Prints the driver status to the console.

Definition at line 139 of file ToneAlarm.cpp.

References _running.

◆ stop_note()

void ToneAlarm::stop_note ( )
protected

Stops playing the current note and makes the player 'safe'.

Definition at line 164 of file ToneAlarm.cpp.

References ets_airspeed::g_dev, and ToneAlarmInterface::stop_note().

Referenced by next_note().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _cbrk

int ToneAlarm::_cbrk {CBRK_UNINIT}
protected

If true, no audio output.

Definition at line 103 of file ToneAlarm.h.

Referenced by start_note().

◆ _play_tone

bool ToneAlarm::_play_tone {false}
private

Definition at line 109 of file ToneAlarm.h.

Referenced by next_note(), and orb_update().

◆ _running

volatile bool ToneAlarm::_running {false}
protected

Flag to indicate the current driver status.

Definition at line 101 of file ToneAlarm.h.

Referenced by init(), next_note(), status(), and ~ToneAlarm().

◆ _should_run

volatile bool ToneAlarm::_should_run {true}
private

Definition at line 107 of file ToneAlarm.h.

Referenced by next_note(), and ~ToneAlarm().

◆ _silence_length

unsigned int ToneAlarm::_silence_length {0}
private

If nonzero, silence before next note.

Definition at line 111 of file ToneAlarm.h.

Referenced by next_note().

◆ _tune

tune_control_s ToneAlarm::_tune {}
private

Definition at line 115 of file ToneAlarm.h.

Referenced by orb_update().

◆ _tune_control_sub

uORB::Subscription ToneAlarm::_tune_control_sub {ORB_ID(tune_control)}
private

Definition at line 113 of file ToneAlarm.h.

Referenced by orb_update().

◆ _tunes

Tunes ToneAlarm::_tunes = Tunes()
private

Definition at line 117 of file ToneAlarm.h.

Referenced by next_note(), and orb_update().


The documentation for this class was generated from the following files: