diff --git a/selfdrive/pandad/pandad.cc b/selfdrive/pandad/pandad.cc index dd970dd16ce09d..bf2a465d78127a 100644 --- a/selfdrive/pandad/pandad.cc +++ b/selfdrive/pandad/pandad.cc @@ -416,6 +416,7 @@ void process_peripheral_state(Panda *panda, PubMaster *pm, bool no_fan_control) if (ir_pwr != prev_ir_pwr || sm.frame % 100 == 0 || ir_pwr >= 50.0) { panda->set_ir_pwr(ir_pwr); + Hardware::set_ir_power(ir_pwr); prev_ir_pwr = ir_pwr; } } diff --git a/system/hardware/base.h b/system/hardware/base.h index ca24633a182a91..732f0f99e0acd0 100644 --- a/system/hardware/base.h +++ b/system/hardware/base.h @@ -28,6 +28,7 @@ class HardwareNone { static void reboot() {} static void poweroff() {} static void set_brightness(int percent) {} + static void set_ir_power(int percentage) {} static void set_display_power(bool on) {} static bool get_ssh_enabled() { return false; } diff --git a/system/hardware/tici/hardware.h b/system/hardware/tici/hardware.h index f1d1f1e717ed88..702785c9d9ee26 100644 --- a/system/hardware/tici/hardware.h +++ b/system/hardware/tici/hardware.h @@ -4,6 +4,7 @@ #include #include #include +#include // for std::clamp #include "common/params.h" #include "common/util.h" @@ -68,6 +69,28 @@ class HardwareTici : public HardwareNone { } } + static void set_ir_power(int percent) { + auto device = get_device_type(); + if (device == cereal::InitData::DeviceType::TICI || + device == cereal::InitData::DeviceType::TIZI) { + return; + } + + percent = std::clamp(percent, 0, 100); + + std::ofstream torch_brightness("/sys/class/leds/led:torch_2/brightness"); + if (torch_brightness.is_open()) { + torch_brightness << percent << "\n"; + torch_brightness.close(); + } + + std::ofstream switch_brightness("/sys/class/leds/led:switch_2/brightness"); + if (switch_brightness.is_open()) { + switch_brightness << percent << "\n"; + switch_brightness.close(); + } + } + static std::map get_init_logs() { std::map ret = { {"/BUILD", util::read_file("/BUILD")},