Browse Source

AP_Notify: add singleton

master
Peter Barker 8 years ago committed by Tom Pittenger
parent
commit
eb1f22fc67
  1. 6
      libraries/AP_Notify/AP_Notify.cpp
  2. 7
      libraries/AP_Notify/AP_Notify.h

6
libraries/AP_Notify/AP_Notify.cpp

@ -32,6 +32,8 @@ @@ -32,6 +32,8 @@
#include "DiscoLED.h"
#include <stdio.h>
AP_Notify *AP_Notify::_instance;
#define CONFIG_NOTIFY_DEVICES_COUNT 5
// table of user settable parameters
@ -79,6 +81,10 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = { @@ -79,6 +81,10 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = {
AP_Notify::AP_Notify()
{
AP_Param::setup_object_defaults(this, var_info);
if (_instance != nullptr) {
AP_HAL::panic("AP_Notify must be singleton");
}
_instance = this;
}
// static flags, to allow for direct class update from device drivers

7
libraries/AP_Notify/AP_Notify.h

@ -43,6 +43,11 @@ public: @@ -43,6 +43,11 @@ public:
// Constructor
AP_Notify();
// get singleton instance
static AP_Notify *instance(void) {
return _instance;
}
// Oreo LED Themes
enum Oreo_LED_Theme {
OreoLED_Disabled = 0, // Disabled the OLED driver entirely
@ -132,6 +137,8 @@ public: @@ -132,6 +137,8 @@ public:
private:
static AP_Notify *_instance;
// parameters
AP_Int8 _rgb_led_brightness;
AP_Int8 _rgb_led_override;

Loading…
Cancel
Save