Line data Source code
1 : /*
2 : This program is free software: you can redistribute it and/or modify
3 : it under the terms of the GNU General Public License as published by
4 : the Free Software Foundation, either version 3 of the License, or
5 : (at your option) any later version.
6 :
7 : This program is distributed in the hope that it will be useful,
8 : but WITHOUT ANY WARRANTY; without even the implied warranty of
9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 : GNU General Public License for more details.
11 :
12 : You should have received a copy of the GNU General Public License
13 : along with this program. If not, see <http://www.gnu.org/licenses/>.
14 : */
15 :
16 : #include "AP_Notify.h"
17 :
18 : #include "AP_BoardLED.h"
19 : #include "PixRacerLED.h"
20 : #include "Buzzer.h"
21 : #include "Display.h"
22 : #include "ExternalLED.h"
23 : #include "GPIO_LED_1.h"
24 : #include "IS31FL3195.h"
25 : #include "PCA9685LED_I2C.h"
26 : #include "NavigatorLED.h"
27 : #include "NeoPixel.h"
28 : #include "NCP5623.h"
29 : #include "OreoLED_I2C.h"
30 : #include "RCOutputRGBLed.h"
31 : #include "ToneAlarm.h"
32 : #include "ToshibaLED_I2C.h"
33 : #include "LP5562.h"
34 : #include "VRBoard_LED.h"
35 : #include "DiscreteRGBLed.h"
36 : #include "DiscoLED.h"
37 : #include "Led_Sysfs.h"
38 : #include "DroneCAN_RGB_LED.h"
39 : #include "SITL_SFML_LED.h"
40 : #include <stdio.h>
41 : #include "AP_BoardLED2.h"
42 : #include "ProfiLED.h"
43 : #include "ScriptingLED.h"
44 : #include "DShotLED.h"
45 : #include "ProfiLED_IOMCU.h"
46 :
47 : extern const AP_HAL::HAL& hal;
48 :
49 : AP_Notify *AP_Notify::_singleton;
50 :
51 : #if CONFIG_HAL_BOARD == HAL_BOARD_SITL
52 : #define CONFIG_NOTIFY_DEVICES_MAX 12
53 : #else
54 : #define CONFIG_NOTIFY_DEVICES_MAX 6
55 : #endif
56 :
57 : #if AP_NOTIFY_TOSHIBALED_ENABLED
58 : #define TOSHIBA_LED_I2C_BUS_INTERNAL 0
59 : #define TOSHIBA_LED_I2C_BUS_EXTERNAL 1
60 : #define ALL_TOSHIBALED_I2C (Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External)
61 : #else
62 : #define ALL_TOSHIBALED_I2C 0
63 : #endif
64 :
65 : #if AP_NOTIFY_NCP5623_ENABLED
66 : #define ALL_NCP5623_I2C (Notify_LED_NCP5623_I2C_Internal | Notify_LED_NCP5623_I2C_External)
67 : #else
68 : #define ALL_NCP5623_I2C 0
69 : #endif
70 :
71 : #if AP_NOTIFY_LP5562_ENABLED
72 : #define ALL_LP5562_I2C (Notify_LED_LP5562_I2C_Internal | Notify_LED_LP5562_I2C_External)
73 : #else
74 : #define ALL_LP5562_I2C 0
75 : #endif
76 :
77 : #if AP_NOTIFY_IS31FL3195_ENABLED
78 : #define ALL_IS31FL3195_I2C (Notify_LED_IS31FL3195_I2C_Internal | Notify_LED_IS31FL3195_I2C_External)
79 : #else
80 : #define ALL_IS31FL3195_I2C 0
81 : #endif
82 :
83 : // all I2C_LEDS
84 : #define I2C_LEDS (ALL_TOSHIBALED_I2C | ALL_NCP5623_I2C | ALL_LP5562_I2C | ALL_IS31FL3195_I2C)
85 :
86 : #if AP_NOTIFY_DRONECAN_LED_ENABLED
87 : #define DRONECAN_LEDS Notify_LED_DroneCAN
88 : #else
89 : #define DRONECAN_LEDS 0
90 : #endif
91 :
92 : #ifndef DEFAULT_NTF_LED_TYPES
93 : #if HAL_WITH_IO_MCU && AP_IOMCU_PROFILED_SUPPORT_ENABLED
94 : #define DEFAULT_NTF_LED_TYPES (Notify_LED_Board | Notify_LED_ProfiLED_IOMCU | I2C_LEDS)
95 : #else
96 : #define DEFAULT_NTF_LED_TYPES (Notify_LED_Board | I2C_LEDS)
97 : #endif
98 : #endif // DEFAULT_NTF_LED_TYPES
99 :
100 : #ifndef BUZZER_ENABLE_DEFAULT
101 : #if HAL_CANMANAGER_ENABLED
102 : // Enable Buzzer messages over UAVCAN
103 : #define BUZZER_ENABLE_DEFAULT (uint8_t(BuzzerType::BUILTIN) | uint8_t(BuzzerType::UAVCAN))
104 : #else
105 : #define BUZZER_ENABLE_DEFAULT uint8_t(BuzzerType::BUILTIN)
106 : #endif
107 : #endif
108 :
109 : #ifndef BUILD_DEFAULT_BUZZER_TYPE
110 : #define BUILD_DEFAULT_BUZZER_TYPE BUZZER_ENABLE_DEFAULT
111 : #endif
112 :
113 : #ifndef NOTIFY_LED_BRIGHT_DEFAULT
114 : #define NOTIFY_LED_BRIGHT_DEFAULT RGB_LED_HIGH
115 : #endif
116 :
117 : #ifndef NOTIFY_LED_OVERRIDE_DEFAULT
118 : #define NOTIFY_LED_OVERRIDE_DEFAULT 0 // rgb_source_t::standard
119 : #endif
120 :
121 : #ifndef NOTIFY_LED_LEN_DEFAULT
122 : #define NOTIFY_LED_LEN_DEFAULT 1
123 : #endif
124 :
125 : #ifndef HAL_BUZZER_PIN
126 : #define HAL_BUZZER_PIN -1
127 : #endif
128 :
129 : #ifndef DEFAULT_BUZZ_ON_LVL
130 : #define DEFAULT_BUZZ_ON_LVL 1
131 : #endif
132 :
133 : // table of user settable parameters
134 : const AP_Param::GroupInfo AP_Notify::var_info[] = {
135 :
136 : // @Param: LED_BRIGHT
137 : // @DisplayName: LED Brightness
138 : // @Description: Select the RGB LED brightness level. When USB is connected brightness will never be higher than low regardless of the setting.
139 : // @Values: 0:Off,1:Low,2:Medium,3:High
140 : // @User: Advanced
141 : AP_GROUPINFO("LED_BRIGHT", 0, AP_Notify, _rgb_led_brightness, NOTIFY_LED_BRIGHT_DEFAULT),
142 :
143 : // @Param: BUZZ_TYPES
144 : // @DisplayName: Buzzer Driver Types
145 : // @Description: Controls what types of Buzzer will be enabled
146 : // @Bitmask: 0:Built-in buzzer, 1:DShot, 2:DroneCAN
147 : // @User: Advanced
148 : AP_GROUPINFO("BUZZ_TYPES", 1, AP_Notify, _buzzer_type, BUILD_DEFAULT_BUZZER_TYPE),
149 :
150 : // @Param: LED_OVERRIDE
151 : // @DisplayName: Specifies colour source for the RGBLed
152 : // @Description: Specifies the source for the colours and brightness for the LED. OutbackChallenge conforms to the MedicalExpress (https://uavchallenge.org/medical-express/) rules, essentially "Green" is disarmed (safe-to-approach), "Red" is armed (not safe-to-approach). Traffic light is a simplified color set, red when armed, yellow when the safety switch is not surpressing outputs (but disarmed), and green when outputs are surpressed and disarmed, the LED will blink faster if disarmed and failing arming checks.
153 : // @Values: 0:Standard,1:MAVLink/Scripting/AP_Periph,2:OutbackChallenge,3:TrafficLight
154 : // @User: Advanced
155 : AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, NOTIFY_LED_OVERRIDE_DEFAULT),
156 :
157 : #if HAL_DISPLAY_ENABLED
158 : // @Param: DISPLAY_TYPE
159 : // @DisplayName: Type of on-board I2C display
160 : // @Description: This sets up the type of on-board I2C display. Disabled by default.
161 : // @Values: 0:Disable,1:ssd1306,2:sh1106,10:SITL
162 : // @User: Advanced
163 : AP_GROUPINFO("DISPLAY_TYPE", 3, AP_Notify, _display_type, 0),
164 : #endif
165 :
166 : #if AP_NOTIFY_OREOLED_ENABLED
167 : // @Param: OREO_THEME
168 : // @DisplayName: OreoLED Theme
169 : // @Description: Enable/Disable Solo Oreo LED driver, 0 to disable, 1 for Aircraft theme, 2 for Rover theme
170 : // @Values: 0:Disabled,1:Aircraft,2:Rover
171 : // @User: Advanced
172 : AP_GROUPINFO("OREO_THEME", 4, AP_Notify, _oreo_theme, 0),
173 : #endif
174 :
175 : // @Param: BUZZ_PIN
176 : // @DisplayName: Buzzer pin
177 : // @Description: Enables to connect active buzzer to arbitrary pin. Requires 3-pin buzzer or additional MOSFET! Some the Wiki's "GPIOs" page for how to determine the pin number for a given autopilot.
178 : // @Values: -1:Disabled
179 : // @User: Advanced
180 : AP_GROUPINFO("BUZZ_PIN", 5, AP_Notify, _buzzer_pin, HAL_BUZZER_PIN),
181 :
182 : // @Param: LED_TYPES
183 : // @DisplayName: LED Driver Types
184 : // @Description: Controls what types of LEDs will be enabled
185 : // @Bitmask: 0:Built-in LED, 1:Internal ToshibaLED, 2:External ToshibaLED, 3:External PCA9685, 4:Oreo LED, 5:DroneCAN, 6:NCP5623 External, 7:NCP5623 Internal, 8:NeoPixel, 9:ProfiLED, 10:Scripting, 11:DShot, 12:ProfiLED_SPI, 13:LP5562 External, 14: LP5562 Internal, 15:IS31FL3195 External, 16: IS31FL3195 Internal, 17: DiscreteRGB, 18: NeoPixelRGB, 19:ProfiLED_IOMCU
186 : // @User: Advanced
187 : AP_GROUPINFO("LED_TYPES", 6, AP_Notify, _led_type, DEFAULT_NTF_LED_TYPES),
188 :
189 : // @Param: BUZZ_ON_LVL
190 : // @DisplayName: Buzzer-on pin logic level
191 : // @Description: Specifies pin level that indicates buzzer should play
192 : // @Values: 0:LowIsOn,1:HighIsOn
193 : // @User: Advanced
194 : AP_GROUPINFO("BUZZ_ON_LVL", 7, AP_Notify, _buzzer_level, DEFAULT_BUZZ_ON_LVL),
195 :
196 : // @Param: BUZZ_VOLUME
197 : // @DisplayName: Buzzer volume
198 : // @Description: Control the volume of the buzzer
199 : // @Range: 0 100
200 : // @Units: %
201 : AP_GROUPINFO("BUZZ_VOLUME", 8, AP_Notify, _buzzer_volume, 100),
202 :
203 : // @Param: LED_LEN
204 : // @DisplayName: Serial LED String Length
205 : // @Description: The number of Serial LED's to use for notifications (NeoPixel's and ProfiLED)
206 : // @Range: 1 32
207 : // @User: Advanced
208 : // @RebootRequired: True
209 : AP_GROUPINFO("LED_LEN", 9, AP_Notify, _led_len, NOTIFY_LED_LEN_DEFAULT),
210 :
211 : AP_GROUPEND
212 : };
213 :
214 : // Default constructor
215 2098 : AP_Notify::AP_Notify()
216 : {
217 2098 : AP_Param::setup_object_defaults(this, var_info);
218 2098 : if (_singleton != nullptr) {
219 0 : AP_HAL::panic("AP_Notify must be singleton");
220 : }
221 2098 : _singleton = this;
222 2098 : }
223 :
224 : // static flags, to allow for direct class update from device drivers
225 : struct AP_Notify::notify_flags_and_values_type AP_Notify::flags;
226 : struct AP_Notify::notify_events_type AP_Notify::events;
227 :
228 : NotifyDevice *AP_Notify::_devices[CONFIG_NOTIFY_DEVICES_MAX];
229 : uint8_t AP_Notify::_num_devices;
230 :
231 41880 : void AP_Notify::add_backend_helper(NotifyDevice *backend)
232 : {
233 41880 : _devices[_num_devices] = backend;
234 41880 : _devices[_num_devices]->pNotify = this;
235 41880 : if(!_devices[_num_devices]->init()) {
236 35598 : delete _devices[_num_devices];
237 35598 : _devices[_num_devices] = nullptr;
238 : } else {
239 6282 : _num_devices++;
240 : }
241 41880 : }
242 :
243 : #define ADD_BACKEND(backend) do { add_backend_helper(backend); if (_num_devices >= CONFIG_NOTIFY_DEVICES_MAX) return;} while(0)
244 :
245 : // add notify backends to _devices array
246 2094 : void AP_Notify::add_backends(void)
247 : {
248 2094 : if (_num_devices != 0) {
249 0 : return;
250 : }
251 :
252 41880 : for (uint32_t i = 1; i < Notify_LED_MAX; i = i << 1) {
253 39786 : switch(_led_type & i) {
254 20940 : case Notify_LED_None:
255 20940 : break;
256 2094 : case Notify_LED_Board:
257 : // select the most appropriate built in LED driver type
258 : #if AP_NOTIFY_SYSFS_LED_ENABLED
259 : ADD_BACKEND(NEW_NOTHROW Led_Sysfs("rgb_led0", "rgb_led2", "rgb_led1"));
260 : #elif AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED
261 : ADD_BACKEND(NEW_NOTHROW RCOutputRGBLedInverted(12, 13, 14));
262 : #elif AP_NOTIFY_RCOUTPUTRGBLED_LED_ENABLED
263 : ADD_BACKEND(NEW_NOTHROW RCOutputRGBLed(HAL_RCOUT_RGBLED_RED, HAL_RCOUT_RGBLED_GREEN, HAL_RCOUT_RGBLED_BLUE));
264 : #elif AP_NOTIFY_DISCO_LED_ENABLED
265 : ADD_BACKEND(NEW_NOTHROW DiscoLED());
266 : #elif AP_NOTIFY_NAVIGATOR_LED_ENABLED
267 : ADD_BACKEND(NEW_NOTHROW NavigatorLED());
268 : #endif
269 :
270 : #if AP_NOTIFY_EXTERNALLED_ENABLED
271 : ADD_BACKEND(NEW_NOTHROW ExternalLED()); // despite the name this is a built in set of onboard LED's
272 : #endif
273 :
274 : #if AP_NOTIFY_GPIO_LED_RGB_ENABLED
275 : ADD_BACKEND(NEW_NOTHROW PixRacerLED());
276 : #elif AP_NOTIFY_VRBOARD_LED_ENABLED
277 : ADD_BACKEND(NEW_NOTHROW VRBoard_LED());
278 : #elif AP_NOTIFY_GPIO_LED_3_ENABLED
279 : ADD_BACKEND(NEW_NOTHROW AP_BoardLED());
280 : #elif AP_NOTIFY_GPIO_LED_2_ENABLED
281 : ADD_BACKEND(NEW_NOTHROW AP_BoardLED2());
282 : #endif
283 : #if AP_NOTIFY_GPIO_LED_1_ENABLED
284 : ADD_BACKEND(NEW_NOTHROW GPIO_LED_1());
285 : #endif
286 2094 : break;
287 : #if AP_NOTIFY_TOSHIBALED_ENABLED
288 2094 : case Notify_LED_ToshibaLED_I2C_Internal:
289 2094 : ADD_BACKEND(NEW_NOTHROW ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
290 2094 : break;
291 2094 : case Notify_LED_ToshibaLED_I2C_External:
292 2094 : ADD_BACKEND(NEW_NOTHROW ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
293 2094 : break;
294 : #endif
295 : #if AP_NOTIFY_NCP5623_ENABLED
296 2094 : case Notify_LED_NCP5623_I2C_External:
297 69102 : FOREACH_I2C_EXTERNAL(b) {
298 8376 : ADD_BACKEND(NEW_NOTHROW NCP5623(b));
299 : }
300 2094 : break;
301 2094 : case Notify_LED_NCP5623_I2C_Internal:
302 69102 : FOREACH_I2C_INTERNAL(b) {
303 2094 : ADD_BACKEND(NEW_NOTHROW NCP5623(b));
304 : }
305 2094 : break;
306 : #endif
307 : #if AP_NOTIFY_PCA9685_ENABLED
308 0 : case Notify_LED_PCA9685LED_I2C_External:
309 0 : ADD_BACKEND(NEW_NOTHROW PCA9685LED_I2C());
310 0 : break;
311 : #endif
312 : #if AP_NOTIFY_NEOPIXEL_ENABLED
313 0 : case Notify_LED_NeoPixel:
314 : case Notify_LED_NeoPixelRGB:
315 0 : ADD_BACKEND(NEW_NOTHROW NeoPixel());
316 0 : break;
317 : #endif
318 : #if AP_NOTIFY_PROFILED_ENABLED
319 0 : case Notify_LED_ProfiLED:
320 0 : ADD_BACKEND(NEW_NOTHROW ProfiLED());
321 0 : break;
322 : #endif
323 : #if AP_NOTIFY_PROFILED_SPI_ENABLED
324 : case Notify_LED_ProfiLED_SPI:
325 : ADD_BACKEND(NEW_NOTHROW ProfiLED_SPI());
326 : break;
327 : #endif
328 : #if AP_NOTIFY_OREOLED_ENABLED
329 : case Notify_LED_OreoLED:
330 : if (_oreo_theme) {
331 : ADD_BACKEND(NEW_NOTHROW OreoLED_I2C(0, _oreo_theme));
332 : }
333 : break;
334 : #endif
335 : #if AP_NOTIFY_DRONECAN_LED_ENABLED
336 0 : case Notify_LED_DroneCAN:
337 0 : ADD_BACKEND(NEW_NOTHROW DroneCAN_RGB_LED());
338 0 : break;
339 : #endif // AP_NOTIFY_DRONECAN_LED_ENABLED
340 : #if AP_NOTIFY_SCRIPTING_LED_ENABLED
341 0 : case Notify_LED_Scripting:
342 0 : ADD_BACKEND(NEW_NOTHROW ScriptingLED());
343 0 : break;
344 : #endif
345 : #if AP_NOTIFY_DSHOT_LED_ENABLED
346 0 : case Notify_LED_DShot:
347 0 : ADD_BACKEND(NEW_NOTHROW DShotLED());
348 0 : break;
349 : #endif
350 : #if HAL_WITH_IO_MCU && AP_IOMCU_PROFILED_SUPPORT_ENABLED
351 : case Notify_LED_ProfiLED_IOMCU:
352 : ADD_BACKEND(NEW_NOTHROW ProfiLED_IOMCU());
353 : break;
354 : #endif
355 : #if AP_NOTIFY_LP5562_ENABLED
356 2094 : case Notify_LED_LP5562_I2C_External:
357 69102 : FOREACH_I2C_EXTERNAL(b) {
358 8376 : ADD_BACKEND(NEW_NOTHROW LP5562(b, 0x30));
359 : }
360 2094 : break;
361 2094 : case Notify_LED_LP5562_I2C_Internal:
362 69102 : FOREACH_I2C_INTERNAL(b) {
363 2094 : ADD_BACKEND(NEW_NOTHROW LP5562(b, 0x30));
364 : }
365 2094 : break;
366 : #endif
367 : #if AP_NOTIFY_IS31FL3195_ENABLED
368 2094 : case Notify_LED_IS31FL3195_I2C_External:
369 69102 : FOREACH_I2C_EXTERNAL(b) {
370 8376 : ADD_BACKEND(NEW_NOTHROW IS31FL3195(b, 0x54));
371 : }
372 2094 : break;
373 2094 : case Notify_LED_IS31FL3195_I2C_Internal:
374 69102 : FOREACH_I2C_INTERNAL(b) {
375 2094 : ADD_BACKEND(NEW_NOTHROW IS31FL3195(b, 0x54));
376 : }
377 2094 : break;
378 : #endif
379 : #if AP_NOTIFY_DISCRETE_RGB_ENABLED
380 : case Notify_LED_DiscreteRGB:
381 : ADD_BACKEND(NEW_NOTHROW DiscreteRGBLed(DISCRETE_RGB_RED_PIN,
382 : DISCRETE_RGB_GREEN_PIN,
383 : DISCRETE_RGB_BLUE_PIN,
384 : DISCRETE_RGB_POLARITY));
385 : break;
386 : #endif
387 : }
388 : }
389 :
390 : #if HAL_DISPLAY_ENABLED
391 : // Always try and add a display backend
392 2094 : ADD_BACKEND(NEW_NOTHROW Display());
393 : #endif
394 :
395 : // Noise makers:
396 : #if AP_NOTIFY_BUZZER_ENABLED
397 2094 : ADD_BACKEND(NEW_NOTHROW Buzzer());
398 : #endif
399 :
400 : #if AP_NOTIFY_TONEALARM_ENABLED
401 2094 : ADD_BACKEND(NEW_NOTHROW AP_ToneAlarm());
402 : #endif
403 :
404 :
405 : #ifdef WITH_SITL_RGBLED
406 : ADD_BACKEND(NEW_NOTHROW SITL_SFML_LED());
407 : #endif
408 : }
409 :
410 : // initialisation
411 2094 : void AP_Notify::init(void)
412 : {
413 : // add all the backends
414 2094 : add_backends();
415 2094 : }
416 :
417 : // main update function, called at 50Hz
418 7754223 : void AP_Notify::update(void)
419 : {
420 30999567 : for (uint8_t i = 0; i < _num_devices; i++) {
421 23245344 : if (_devices[i] != nullptr) {
422 23245344 : _devices[i]->update();
423 : }
424 : }
425 :
426 : //reset the events
427 7754223 : memset(&AP_Notify::events, 0, sizeof(AP_Notify::events));
428 7754223 : }
429 :
430 : #if AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
431 : // handle a LED_CONTROL message
432 0 : void AP_Notify::handle_led_control(const mavlink_message_t &msg)
433 : {
434 0 : for (uint8_t i = 0; i < _num_devices; i++) {
435 0 : if (_devices[i] != nullptr) {
436 0 : _devices[i]->handle_led_control(msg);
437 : }
438 : }
439 0 : }
440 : #endif
441 :
442 : // handle RGB from Scripting or AP_Periph
443 0 : void AP_Notify::handle_rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz)
444 : {
445 0 : for (uint8_t i = 0; i < _num_devices; i++) {
446 0 : if (_devices[i] != nullptr) {
447 0 : _devices[i]->rgb_control(r, g, b, rate_hz);
448 : }
449 : }
450 0 : }
451 :
452 : // handle RGB Per led from Scripting
453 0 : void AP_Notify::handle_rgb_id(uint8_t r, uint8_t g, uint8_t b, uint8_t id)
454 : {
455 0 : for (uint8_t i = 0; i < _num_devices; i++) {
456 0 : if (_devices[i] != nullptr) {
457 0 : _devices[i]->rgb_set_id(r, g, b, id);
458 : }
459 : }
460 0 : }
461 :
462 4 : void AP_Notify::play_tune(const char *tune)
463 : {
464 16 : for (uint8_t i = 0; i < _num_devices; i++) {
465 12 : if (_devices[i] != nullptr) {
466 12 : _devices[i]->play_tune(tune);
467 : }
468 : }
469 4 : }
470 :
471 : // set flight mode string
472 5858 : void AP_Notify::set_flight_mode_str(const char *str)
473 : {
474 5858 : strncpy(_flight_mode_str, str, sizeof(_flight_mode_str));
475 5858 : _flight_mode_str[sizeof(_flight_mode_str)-1] = 0;
476 5858 : }
477 :
478 262928 : void AP_Notify::send_text(const char *str)
479 : {
480 262928 : strncpy(_send_text, str, sizeof(_send_text));
481 262928 : _send_text[sizeof(_send_text)-1] = 0;
482 262928 : _send_text_updated_millis = AP_HAL::millis();
483 262928 : }
484 :
485 : #if AP_SCRIPTING_ENABLED
486 0 : void AP_Notify::send_text_scripting(const char *str, uint8_t r)
487 : {
488 0 : for (uint8_t i = 0; i < _num_devices; i++) {
489 0 : if (_devices[i] != nullptr) {
490 0 : _devices[i]->send_text_blocking(str, r);
491 : }
492 : }
493 0 : }
494 :
495 0 : void AP_Notify::release_text_scripting(uint8_t r)
496 : {
497 0 : for (uint8_t i = 0; i < _num_devices; i++) {
498 0 : if (_devices[i] != nullptr) {
499 0 : _devices[i]->release_text(r);
500 : }
501 : }
502 0 : }
503 : #endif
504 :
505 :
506 : // convert 0-3 to 0-100
507 0 : int8_t AP_Notify::get_rgb_led_brightness_percent() const
508 : {
509 0 : switch (_rgb_led_brightness) {
510 0 : default:
511 : case RGB_LED_OFF:
512 0 : return 0;
513 0 : case RGB_LED_LOW:
514 0 : return 33;
515 0 : case RGB_LED_MEDIUM:
516 0 : return 66;
517 0 : case RGB_LED_HIGH:
518 0 : return 100;
519 : }
520 : }
521 :
522 : namespace AP {
523 :
524 25937 : AP_Notify ¬ify()
525 : {
526 25937 : return *AP_Notify::get_singleton();
527 : }
528 :
529 : };
|