AP_Notify: Remove unneeded init guards

This commit is contained in:
Michael du Breuil 2018-06-26 12:02:40 -07:00 committed by Andrew Tridgell
parent 565a84efcb
commit c5669a614e
9 changed files with 4 additions and 46 deletions

View File

@ -345,10 +345,8 @@ bool Display::init(void)
} }
if (_driver == nullptr) { if (_driver == nullptr) {
_healthy = false;
return false; return false;
} }
_healthy = true;
// update all on display // update all on display
update_all(); update_all();
@ -359,11 +357,6 @@ bool Display::init(void)
void Display::update() void Display::update()
{ {
// return immediately if not enabled
if (!_healthy) {
return;
}
// max update frequency 2Hz // max update frequency 2Hz
static uint8_t timer = 0; static uint8_t timer = 0;
if (timer++ < 25) { if (timer++ < 25) {

View File

@ -32,8 +32,6 @@ private:
Display_Backend *_driver; Display_Backend *_driver;
bool _healthy;
uint8_t _mstartpos; // ticker shift position uint8_t _mstartpos; // ticker shift position
uint8_t _movedelay; // ticker delay before shifting after new message displayed uint8_t _movedelay; // ticker delay before shifting after new message displayed
uint8_t _screenpage; uint8_t _screenpage;

View File

@ -34,8 +34,7 @@ RGBLed::RGBLed(uint8_t led_off, uint8_t led_bright, uint8_t led_medium, uint8_t
bool RGBLed::init() bool RGBLed::init()
{ {
_healthy = hw_init(); return hw_init();
return _healthy;
} }
// set_rgb - set color as a combination of red, green and blue values // set_rgb - set color as a combination of red, green and blue values
@ -56,10 +55,6 @@ void RGBLed::_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
// set_rgb - set color as a combination of red, green and blue values // set_rgb - set color as a combination of red, green and blue values
void RGBLed::set_rgb(uint8_t red, uint8_t green, uint8_t blue) void RGBLed::set_rgb(uint8_t red, uint8_t green, uint8_t blue)
{ {
// return immediately if not enabled
if (!_healthy) {
return;
}
if (pNotify->_rgb_led_override) { if (pNotify->_rgb_led_override) {
// don't set if in override mode // don't set if in override mode
return; return;
@ -329,10 +324,6 @@ void RGBLed::update_colours(void)
// at 50Hz // at 50Hz
void RGBLed::update() void RGBLed::update()
{ {
// return immediately if not enabled
if (!_healthy) {
return;
}
if (!pNotify->_rgb_led_override) { if (!pNotify->_rgb_led_override) {
update_colours(); update_colours();
set_rgb(_red_des, _green_des, _blue_des); set_rgb(_red_des, _green_des, _blue_des);

View File

@ -29,9 +29,6 @@ public:
// init - initialised the LED // init - initialised the LED
virtual bool init(void); virtual bool init(void);
// healthy - returns true if the LED is operating properly
virtual bool healthy() { return _healthy; }
// set_rgb - set color as a combination of red, green and blue levels from 0 ~ 15 // set_rgb - set color as a combination of red, green and blue levels from 0 ~ 15
virtual void set_rgb(uint8_t red, uint8_t green, uint8_t blue); virtual void set_rgb(uint8_t red, uint8_t green, uint8_t blue);
@ -55,7 +52,6 @@ protected:
// meta-data common to all hw devices // meta-data common to all hw devices
uint8_t counter; uint8_t counter;
uint8_t step; uint8_t step;
bool _healthy; // true if the LED is operating properly
uint8_t _red_des, _green_des, _blue_des; // color requested by timed update uint8_t _red_des, _green_des, _blue_des; // color requested by timed update
uint8_t _red_curr, _green_curr, _blue_curr; // current colours displayed by the led uint8_t _red_curr, _green_curr, _blue_curr; // current colours displayed by the led
uint8_t _led_off; uint8_t _led_off;

View File

@ -28,7 +28,7 @@ extern const AP_HAL::HAL& hal;
bool ToneAlarm_ChibiOS::init() bool ToneAlarm_ChibiOS::init()
{ {
// open the tone alarm device // open the tone alarm device
_initialized = hal.util->toneAlarm_init(); bool _initialized = hal.util->toneAlarm_init();
if (!_initialized) { if (!_initialized) {
hal.console->printf("AP_Notify: Failed to initialise ToneAlarm"); hal.console->printf("AP_Notify: Failed to initialise ToneAlarm");
return false; return false;
@ -52,11 +52,6 @@ bool ToneAlarm_ChibiOS::play_tune(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 ToneAlarm_ChibiOS::update() void ToneAlarm_ChibiOS::update()
{ {
// exit immediately if we haven't initialised successfully
if (!_initialized) {
return;
}
// exit if buzzer is not enabled // exit if buzzer is not enabled
if (pNotify->buzzer_enabled() == false) { if (pNotify->buzzer_enabled() == false) {
return; return;

View File

@ -32,8 +32,6 @@ private:
/// play_tune - play one of the pre-defined tunes /// play_tune - play one of the pre-defined tunes
bool play_tune(uint8_t tune_number); bool play_tune(uint8_t tune_number);
bool _initialized = false;
/// tonealarm_type - bitmask of states we track /// tonealarm_type - bitmask of states we track
struct tonealarm_type { struct tonealarm_type {
bool armed : 1; // false = disarmed, true = armed bool armed : 1; // false = disarmed, true = armed

View File

@ -37,7 +37,7 @@ extern const AP_HAL::HAL& hal;
bool ToneAlarm_Linux::init() bool ToneAlarm_Linux::init()
{ {
// open the tone alarm device // open the tone alarm device
_initialized = hal.util->toneAlarm_init(); bool _initialized = hal.util->toneAlarm_init();
if (!_initialized) { if (!_initialized) {
hal.console->printf("AP_Notify: Failed to initialise ToneAlarm"); hal.console->printf("AP_Notify: Failed to initialise ToneAlarm");
return false; return false;
@ -61,11 +61,6 @@ bool ToneAlarm_Linux::play_tune(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 ToneAlarm_Linux::update() void ToneAlarm_Linux::update()
{ {
// exit immediately if we haven't initialised successfully
if (!_initialized) {
return;
}
// exit if buzzer is not enabled // exit if buzzer is not enabled
if (pNotify->buzzer_enabled() == false) { if (pNotify->buzzer_enabled() == false) {
return; return;

View File

@ -155,11 +155,6 @@ void ToneAlarm_PX4::check_cont_tone() {
// 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 ToneAlarm_PX4::update() void ToneAlarm_PX4::update()
{ {
// exit immediately if we haven't initialised successfully
if (_tonealarm_fd == -1) {
return;
}
// exit if buzzer is not enabled // exit if buzzer is not enabled
if (pNotify->buzzer_enabled() == false) { if (pNotify->buzzer_enabled() == false) {
return; return;

View File

@ -17,10 +17,7 @@ void setup(void)
hal.console->printf("Toshiba LED test ver 0.1\n"); hal.console->printf("Toshiba LED test ver 0.1\n");
// initialise LED // initialise LED
toshiba_led.init(); if (toshiba_led.init()) {
// check if healthy
if (!toshiba_led.healthy()) {
hal.console->printf("Failed to initialise Toshiba LED\n"); hal.console->printf("Failed to initialise Toshiba LED\n");
} }