Browse Source

AP_Notify: Remove unneeded init guards

master
Michael du Breuil 7 years ago committed by Andrew Tridgell
parent
commit
c5669a614e
  1. 7
      libraries/AP_Notify/Display.cpp
  2. 2
      libraries/AP_Notify/Display.h
  3. 11
      libraries/AP_Notify/RGBLed.cpp
  4. 4
      libraries/AP_Notify/RGBLed.h
  5. 7
      libraries/AP_Notify/ToneAlarm_ChibiOS.cpp
  6. 2
      libraries/AP_Notify/ToneAlarm_ChibiOS.h
  7. 7
      libraries/AP_Notify/ToneAlarm_Linux.cpp
  8. 5
      libraries/AP_Notify/ToneAlarm_PX4.cpp
  9. 5
      libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.cpp

7
libraries/AP_Notify/Display.cpp

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

2
libraries/AP_Notify/Display.h

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

11
libraries/AP_Notify/RGBLed.cpp

@ -34,8 +34,7 @@ RGBLed::RGBLed(uint8_t led_off, uint8_t led_bright, uint8_t led_medium, uint8_t @@ -34,8 +34,7 @@ RGBLed::RGBLed(uint8_t led_off, uint8_t led_bright, uint8_t led_medium, uint8_t
bool RGBLed::init()
{
_healthy = hw_init();
return _healthy;
return hw_init();
}
// 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) @@ -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
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) {
// don't set if in override mode
return;
@ -329,10 +324,6 @@ void RGBLed::update_colours(void) @@ -329,10 +324,6 @@ void RGBLed::update_colours(void)
// at 50Hz
void RGBLed::update()
{
// return immediately if not enabled
if (!_healthy) {
return;
}
if (!pNotify->_rgb_led_override) {
update_colours();
set_rgb(_red_des, _green_des, _blue_des);

4
libraries/AP_Notify/RGBLed.h

@ -29,9 +29,6 @@ public: @@ -29,9 +29,6 @@ public:
// init - initialised the LED
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
virtual void set_rgb(uint8_t red, uint8_t green, uint8_t blue);
@ -55,7 +52,6 @@ protected: @@ -55,7 +52,6 @@ protected:
// meta-data common to all hw devices
uint8_t counter;
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_curr, _green_curr, _blue_curr; // current colours displayed by the led
uint8_t _led_off;

7
libraries/AP_Notify/ToneAlarm_ChibiOS.cpp

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

2
libraries/AP_Notify/ToneAlarm_ChibiOS.h

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

7
libraries/AP_Notify/ToneAlarm_Linux.cpp

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

5
libraries/AP_Notify/ToneAlarm_PX4.cpp

@ -155,11 +155,6 @@ void ToneAlarm_PX4::check_cont_tone() { @@ -155,11 +155,6 @@ void ToneAlarm_PX4::check_cont_tone() {
// update - updates led according to timed_updated. Should be called at 50Hz
void ToneAlarm_PX4::update()
{
// exit immediately if we haven't initialised successfully
if (_tonealarm_fd == -1) {
return;
}
// exit if buzzer is not enabled
if (pNotify->buzzer_enabled() == false) {
return;

5
libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.cpp

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

Loading…
Cancel
Save