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 "SerialLED.h" 17 : 18 : #if AP_NOTIFY_SERIALLED_ENABLED 19 : 20 : extern const AP_HAL::HAL& hal; 21 : 22 0 : SerialLED::SerialLED(uint8_t led_off, uint8_t led_bright, uint8_t led_medium, uint8_t led_dim) : 23 0 : RGBLed(led_off, led_bright, led_medium, led_dim) 24 : { 25 0 : } 26 : 27 0 : bool SerialLED::init() 28 : { 29 0 : enable_mask = init_ports(); 30 0 : return true; 31 : } 32 : 33 0 : bool SerialLED::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue) 34 : { 35 0 : if (enable_mask == 0) { 36 : // nothing is enabled, no pins set as LED output 37 0 : return true; 38 : } 39 : 40 0 : AP_SerialLED *led = AP_SerialLED::get_singleton(); 41 0 : if (led == nullptr) { 42 0 : return false; 43 : } 44 : 45 0 : for (uint16_t chan=0; chan<16; chan++) { 46 0 : if ((1U<<chan) & enable_mask) { 47 0 : led->set_RGB(chan+1, -1, red, green, blue); 48 : } 49 : } 50 : 51 0 : for (uint16_t chan=0; chan<16; chan++) { 52 0 : if ((1U<<chan) & enable_mask) { 53 0 : led->send(chan+1); 54 : } 55 : } 56 : 57 0 : return true; 58 : } 59 : 60 : #endif // AP_NOTIFY_SERIALLED_ENABLED