2020-08-03 00:24:27 -03:00
|
|
|
#include "SIM_ToshibaLED.h"
|
|
|
|
|
2021-10-11 02:06:06 -03:00
|
|
|
#if AP_SIM_TOSHIBALED_ENABLED
|
|
|
|
|
2020-08-03 00:24:27 -03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2020-11-12 00:19:13 -04:00
|
|
|
void SITL::ToshibaLED::update(const class Aircraft &aircraft)
|
2020-08-03 00:24:27 -03:00
|
|
|
{
|
2020-11-12 00:19:13 -04:00
|
|
|
if (last_print_pwm0 == get_register(ToshibaLEDDevReg::PWM0) &&
|
|
|
|
last_print_pwm1 == get_register(ToshibaLEDDevReg::PWM1) &&
|
|
|
|
last_print_pwm2 == get_register(ToshibaLEDDevReg::PWM2) &&
|
|
|
|
last_print_enable == get_register(ToshibaLEDDevReg::ENABLE)) {
|
|
|
|
return;
|
2020-08-03 00:24:27 -03:00
|
|
|
}
|
2020-11-12 00:19:13 -04:00
|
|
|
|
|
|
|
last_print_pwm0 = get_register(ToshibaLEDDevReg::PWM0);
|
|
|
|
last_print_pwm1 = get_register(ToshibaLEDDevReg::PWM1);
|
|
|
|
last_print_pwm2 = get_register(ToshibaLEDDevReg::PWM2);
|
|
|
|
last_print_enable = get_register(ToshibaLEDDevReg::ENABLE);
|
2024-08-07 00:17:22 -03:00
|
|
|
// GCS_SEND_TEXT(MAV_SEVERITY_INFO, "SIM_ToshibaLED: PWM0=%u PWM1=%u PWM2=%u ENABLE=%u", last_print_pwm0, last_print_pwm1, last_print_pwm2, last_print_enable);
|
2023-02-26 21:08:53 -04:00
|
|
|
|
|
|
|
if (get_register(ToshibaLEDDevReg::ENABLE)) {
|
|
|
|
// here we convert from 0-15 BGR (the PWM values from the i2c bus)
|
|
|
|
// to 0-255 RGB (what SIM_RGBLED wants):
|
|
|
|
rgbled.set_colours(
|
|
|
|
get_register(ToshibaLEDDevReg::PWM2) * 17,
|
|
|
|
get_register(ToshibaLEDDevReg::PWM1) * 17,
|
|
|
|
get_register(ToshibaLEDDevReg::PWM0) * 17
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
rgbled.set_colours(0, 0, 0);
|
|
|
|
}
|
2020-08-03 00:24:27 -03:00
|
|
|
}
|
2021-10-11 02:06:06 -03:00
|
|
|
|
|
|
|
#endif
|