123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- #pragma once
- #include <AP_Common/AP_Common.h>
- #include <AP_Param/AP_Param.h>
- #include <GCS_MAVLink/GCS_MAVLink.h>
- #include "NotifyDevice.h"
- #define RGB_LED_OFF 0
- #define RGB_LED_LOW 1
- #define RGB_LED_MEDIUM 2
- #define RGB_LED_HIGH 3
- #define BUZZER_ON 1
- #define BUZZER_OFF 0
- #define NOTIFY_TEXT_BUFFER_SIZE 51
- #define DISPLAY_OFF 0
- #define DISPLAY_SSD1306 1
- #define DISPLAY_SH1106 2
- #define DISPLAY_SITL 10
- class AP_Notify
- {
- friend class RGBLed;
- friend class Display;
- public:
- AP_Notify();
-
- AP_Notify(const AP_Notify &other) = delete;
- AP_Notify &operator=(const AP_Notify&) = delete;
-
- static AP_Notify *get_singleton(void) {
- return _singleton;
- }
-
-
- enum Oreo_LED_Theme {
- OreoLED_Disabled = 0,
- OreoLED_Aircraft = 1,
- OreoLED_Automobile = 2,
- };
- enum Notify_LED_Type {
- Notify_LED_None = 0,
- Notify_LED_Board = (1 << 0),
- Notify_LED_ToshibaLED_I2C_Internal = (1 << 1),
- Notify_LED_ToshibaLED_I2C_External = (1 << 2),
- Notify_LED_PCA9685LED_I2C_External = (1 << 3),
- Notify_LED_OreoLED = (1 << 4),
- Notify_LED_UAVCAN = (1 << 5),
- Notify_LED_NCP5623_I2C_External = (1 << 6),
- Notify_LED_NCP5623_I2C_Internal = (1 << 7),
- Notify_LED_NeoPixel = (1 << 8),
- Notify_LED_MAX
- };
-
- struct notify_flags_and_values_type {
- bool initialising;
- uint8_t gps_status;
- uint8_t gps_num_sats;
- uint8_t flight_mode;
- bool armed;
- bool flying;
- bool pre_arm_check;
- bool pre_arm_gps_check;
- bool save_trim;
- bool esc_calibration;
- bool failsafe_radio;
- bool failsafe_battery;
- bool parachute_release;
- bool ekf_bad;
- bool autopilot_mode;
- bool firmware_update;
- bool compass_cal_running;
- bool leak_detected;
- bool gps_fusion;
- bool gps_glitching;
- bool have_pos_abs;
- bool vehicle_lost;
- bool waiting_for_throw;
- bool powering_off;
- bool video_recording;
- };
-
-
- struct notify_events_type {
- uint32_t arming_failed : 1;
- uint32_t user_mode_change : 1;
- uint32_t user_mode_change_failed: 1;
- uint32_t failsafe_mode_change : 1;
- uint32_t autotune_complete : 1;
- uint32_t autotune_failed : 1;
- uint32_t autotune_next_axis : 1;
- uint32_t mission_complete : 1;
- uint32_t waypoint_complete : 1;
- uint32_t initiated_compass_cal : 1;
- uint32_t compass_cal_saved : 1;
- uint32_t compass_cal_failed : 1;
- uint32_t compass_cal_canceled : 1;
- uint32_t tune_started : 1;
- uint32_t tune_next : 3;
- uint32_t tune_save : 1;
- uint32_t tune_error : 1;
- };
-
-
- static struct notify_flags_and_values_type flags;
- static struct notify_events_type events;
-
- void init(void);
-
- void update(void);
-
- static void handle_led_control(const mavlink_message_t &msg);
-
- static void handle_play_tune(const mavlink_message_t &msg);
-
- static void play_tune(const char *tune);
- bool buzzer_enabled() const { return _buzzer_enable; }
-
- void set_flight_mode_str(const char *str);
- const char* get_flight_mode_str() const { return _flight_mode_str; }
-
- void send_text(const char *str);
- const char* get_text() const { return _send_text; }
- uint32_t get_text_updated_millis() const {return _send_text_updated_millis; }
- static const struct AP_Param::GroupInfo var_info[];
- uint8_t get_buzz_pin() const { return _buzzer_pin; }
- uint8_t get_buzz_level() const { return _buzzer_level; }
- uint8_t get_buzz_volume() const { return _buzzer_volume; }
- #if CONFIG_HAL_BOARD == HAL_BOARD_SITL
- HAL_Semaphore sf_window_mutex;
- #endif
- private:
- static AP_Notify *_singleton;
- void add_backend_helper(NotifyDevice *backend);
-
- void add_backends(void);
-
- AP_Int8 _rgb_led_brightness;
- AP_Int8 _rgb_led_override;
- AP_Int8 _buzzer_enable;
- AP_Int8 _display_type;
- AP_Int8 _oreo_theme;
- AP_Int8 _buzzer_pin;
- AP_Int32 _led_type;
- AP_Int8 _buzzer_level;
- AP_Int8 _buzzer_volume;
- char _send_text[NOTIFY_TEXT_BUFFER_SIZE];
- uint32_t _send_text_updated_millis;
- char _flight_mode_str[5];
- static NotifyDevice* _devices[];
- static uint8_t _num_devices;
- };
- namespace AP {
- AP_Notify ¬ify();
- };
|