Browse Source

AP_Notify: grab initial flags state in init()

this prevents annoying tones on startup of APM:Plane
master
Andrew Tridgell 12 years ago
parent
commit
0d6b847966
  1. 7
      libraries/AP_Notify/ToneAlarm_PX4.cpp
  2. 6
      libraries/AP_Notify/ToneAlarm_PX4.h

7
libraries/AP_Notify/ToneAlarm_PX4.cpp

@ -41,6 +41,11 @@ bool ToneAlarm_PX4::init()
hal.console->printf("Unable to open " TONEALARM_DEVICE_PATH); hal.console->printf("Unable to open " TONEALARM_DEVICE_PATH);
return false; return false;
} }
// set initial boot states. This prevents us issueing a arming
// warning in plane and rover on every boot
flags.armed = AP_Notify::flags.armed;
flags.failsafe_battery = AP_Notify::flags.failsafe_battery;
return true; return true;
} }
@ -56,7 +61,7 @@ bool ToneAlarm_PX4::play_tune(const uint8_t tune_number)
void ToneAlarm_PX4::update() void ToneAlarm_PX4::update()
{ {
// exit immediately if we haven't initialised successfully // exit immediately if we haven't initialised successfully
if (_tonealarm_fd <= 0 ) { if (_tonealarm_fd == -1) {
return; return;
} }

6
libraries/AP_Notify/ToneAlarm_PX4.h

@ -26,13 +26,13 @@ public:
/// init - initialised the tone alarm /// init - initialised the tone alarm
bool init(void); bool init(void);
/// play_tune - play one of the pre-defined tunes
bool play_tune(const uint8_t tune_number);
/// update - updates led according to timed_updated. Should be called at 50Hz /// update - updates led according to timed_updated. Should be called at 50Hz
void update(); void update();
private: private:
/// play_tune - play one of the pre-defined tunes
bool play_tune(const uint8_t tune_number);
int _tonealarm_fd; // file descriptor for the tone alarm int _tonealarm_fd; // file descriptor for the tone alarm
/// tonealarm_type - bitmask of states we track /// tonealarm_type - bitmask of states we track

Loading…
Cancel
Save