Line data Source code
1 : #include "SIM_config.h" 2 : 3 : #if AP_SIM_BATT_MONITOR_SMBUS_ROTOYE_ENABLED 4 : 5 : #include "SIM_BattMonitor_SMBus_Rotoye.h" 6 : 7 : #include <AP_HAL/utility/sparse-endian.h> 8 : 9 2145 : SITL::Rotoye::Rotoye() : 10 2145 : SIM_BattMonitor_SMBus_Generic() 11 : { 12 2145 : add_register("External Temperature", SMBusBattRotoyeDevReg::TEMP_EXT, SITL::I2CRegisters::RegMode::RDONLY); 13 : 14 2145 : set_register(SMBusBattRotoyeDevReg::SERIAL, (uint16_t)39); 15 : 16 2145 : const char *manufacturer_name = "Rotoye"; 17 2145 : set_block(SMBusBattDevReg::MANUFACTURE_NAME, manufacturer_name); 18 : 19 2145 : const char *device_name = "SITL_BatMon v4.03"; 20 2145 : set_block(SMBusBattDevReg::DEVICE_NAME, device_name); 21 : 22 2145 : set_register(SMBusBattGenericDevReg::SERIAL, (uint16_t) 278); 23 2145 : } 24 : 25 178759942 : void SITL::Rotoye::update(const class Aircraft &aircraft) 26 : { 27 178759942 : SIM_BattMonitor_SMBus_Generic::update(aircraft); 28 : 29 178759942 : const uint32_t now = AP_HAL::millis(); 30 178759942 : if (now - last_temperature_update_ms > 1000) { 31 147797 : last_temperature_update_ms = now; 32 147797 : int16_t outside_temp = get_reg_value(SMBusBattRotoyeDevReg::TEMP); 33 147797 : set_register(SMBusBattRotoyeDevReg::TEMP_EXT, int16_t(outside_temp + 100)); // it's a little warmer inside.... (10 degrees here) 34 : } 35 178759942 : } 36 : 37 : #endif // AP_SIM_BATT_MONITOR_SMBUS_ROTOYE_ENABLED