mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
hardware: add helper for setting IR power (#34245)
* hardware: add helper for setting IR power * fix
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
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; }
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <algorithm> // for std::clamp
|
||||
|
||||
#include "common/params.h"
|
||||
#include "common/util.h"
|
||||
@@ -68,6 +69,28 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
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<std::string, std::string> get_init_logs() {
|
||||
std::map<std::string, std::string> ret = {
|
||||
{"/BUILD", util::read_file("/BUILD")},
|
||||
|
||||
Reference in New Issue
Block a user