PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <ToneAlarm.h>
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 | |
CDev & | operator= (const CDev &)=delete |
CDev (CDev &&)=delete | |
CDev & | operator= (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... | |
Definition at line 58 of file ToneAlarm.h.
ToneAlarm::ToneAlarm | ( | ) |
Definition at line 42 of file ToneAlarm.cpp.
Referenced by tone_alarm_main().
ToneAlarm::~ToneAlarm | ( | ) |
Definition at line 48 of file ToneAlarm.cpp.
References _running, _should_run, and counter.
|
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.
|
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().
|
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().
|
overrideprotected |
Trampoline for the work queue.
Definition at line 122 of file ToneAlarm.cpp.
References next_note().
|
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().
void ToneAlarm::status | ( | ) |
Prints the driver status to the console.
Definition at line 139 of file ToneAlarm.cpp.
References _running.
|
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().
|
protected |
|
private |
Definition at line 109 of file ToneAlarm.h.
Referenced by next_note(), and orb_update().
|
protected |
Flag to indicate the current driver status.
Definition at line 101 of file ToneAlarm.h.
Referenced by init(), next_note(), status(), and ~ToneAlarm().
|
private |
Definition at line 107 of file ToneAlarm.h.
Referenced by next_note(), and ~ToneAlarm().
|
private |
If nonzero, silence before next note.
Definition at line 111 of file ToneAlarm.h.
Referenced by next_note().
|
private |
Definition at line 115 of file ToneAlarm.h.
Referenced by orb_update().
|
private |
Definition at line 113 of file ToneAlarm.h.
Referenced by orb_update().
Definition at line 117 of file ToneAlarm.h.
Referenced by next_note(), and orb_update().