2020-08-03 00:24:27 -03:00
|
|
|
#include "SIM_I2CDevice.h"
|
|
|
|
|
2021-10-11 02:06:06 -03:00
|
|
|
#include <AP_HAL/AP_HAL_Boards.h>
|
|
|
|
|
|
|
|
#ifndef AP_SIM_TOSHIBALED_ENABLED
|
|
|
|
#define AP_SIM_TOSHIBALED_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if AP_SIM_TOSHIBALED_ENABLED
|
|
|
|
|
2023-02-26 21:08:53 -04:00
|
|
|
#include "SIM_RGBLED.h"
|
|
|
|
|
2020-08-03 00:24:27 -03:00
|
|
|
namespace SITL {
|
|
|
|
|
2020-11-12 00:19:13 -04:00
|
|
|
class ToshibaLEDDevReg : public I2CRegEnum {
|
|
|
|
public:
|
|
|
|
static constexpr uint8_t PWM0 = 0x01;
|
|
|
|
static constexpr uint8_t PWM1 = 0x02;
|
|
|
|
static constexpr uint8_t PWM2 = 0x03;
|
|
|
|
static constexpr uint8_t ENABLE = 0x04;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ToshibaLED : public I2CDevice, protected I2CRegisters_8Bit
|
2020-08-03 00:24:27 -03:00
|
|
|
{
|
|
|
|
public:
|
2020-11-12 00:19:13 -04:00
|
|
|
void init() override {
|
2023-02-26 21:08:53 -04:00
|
|
|
rgbled.init();
|
|
|
|
|
2021-10-11 02:04:21 -03:00
|
|
|
add_register("PWM0", ToshibaLEDDevReg::PWM0, I2CRegisters::RegMode::WRONLY);
|
|
|
|
add_register("PWM1", ToshibaLEDDevReg::PWM1, I2CRegisters::RegMode::WRONLY);
|
|
|
|
add_register("PWM2", ToshibaLEDDevReg::PWM2, I2CRegisters::RegMode::WRONLY);
|
|
|
|
add_register("ENABLE", ToshibaLEDDevReg::ENABLE, I2CRegisters::RegMode::WRONLY);
|
2020-11-12 00:19:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void update(const class Aircraft &aircraft) override;
|
|
|
|
|
|
|
|
int rdwr(I2C::i2c_rdwr_ioctl_data *&data) override {
|
|
|
|
return I2CRegisters_8Bit::rdwr(data);
|
|
|
|
}
|
|
|
|
|
2020-08-03 00:24:27 -03:00
|
|
|
private:
|
2020-11-12 00:19:13 -04:00
|
|
|
uint8_t last_print_pwm0;
|
|
|
|
uint8_t last_print_pwm1;
|
|
|
|
uint8_t last_print_pwm2;
|
|
|
|
uint8_t last_print_enable;
|
2023-02-26 21:08:53 -04:00
|
|
|
|
|
|
|
SIM_RGBLED rgbled{"ToshibaLED"};
|
2020-08-03 00:24:27 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace SITL
|
2021-10-11 02:06:06 -03:00
|
|
|
|
|
|
|
#endif // AP_SIM_TOSHIBALED_ENABLED
|