AP_Notify: Remove unneeded init guards
This commit is contained in:
parent
565a84efcb
commit
c5669a614e
@ -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)
|
||||
|
||||
void Display::update()
|
||||
{
|
||||
// return immediately if not enabled
|
||||
if (!_healthy) {
|
||||
return;
|
||||
}
|
||||
|
||||
// max update frequency 2Hz
|
||||
static uint8_t timer = 0;
|
||||
if (timer++ < 25) {
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
// 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)
|
||||
// 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);
|
||||
|
@ -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:
|
||||
// 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;
|
||||
|
@ -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)
|
||||
// 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;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
// 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;
|
||||
|
@ -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;
|
||||
|
@ -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…
Reference in New Issue
Block a user