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/AP_Notify.h" 17 : #include <AP_HAL/RCOutput.h> 18 : #include "DShotLED.h" 19 : #include "SRV_Channel/SRV_Channel.h" 20 : 21 : extern const AP_HAL::HAL& hal; 22 : 23 0 : bool DShotLED::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue) 24 : { 25 : // don't play the motor LEDs while flying 26 0 : if (hal.util->get_soft_armed() || (hal.rcout->get_dshot_esc_type() != AP_HAL::RCOutput::DSHOT_ESC_BLHELI 27 0 : && hal.rcout->get_dshot_esc_type() != AP_HAL::RCOutput::DSHOT_ESC_BLHELI_EDT)) { 28 0 : return false; 29 : } 30 : 31 0 : hal.rcout->send_dshot_command(red ? AP_HAL::RCOutput::DSHOT_LED1_ON : AP_HAL::RCOutput::DSHOT_LED1_OFF); 32 0 : hal.rcout->send_dshot_command(green ? AP_HAL::RCOutput::DSHOT_LED2_ON : AP_HAL::RCOutput::DSHOT_LED2_OFF); 33 0 : hal.rcout->send_dshot_command(blue ? AP_HAL::RCOutput::DSHOT_LED0_ON : AP_HAL::RCOutput::DSHOT_LED0_OFF); 34 : 35 0 : return true; 36 : }