mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-07-26 03:42:05 +08:00
rescale ir power (#35858)
* rescale ir value pandad sends to Hardware and changed max ir value in Hardware * changed ir_percentage type * refactored pandad.cc ir_pwr setting * cleaned up ir update condition --------- Co-authored-by: kostas pats <kostas@comma.ai>
This commit is contained in:
+10
-10
@@ -36,8 +36,7 @@
|
||||
// Ignition:
|
||||
// - If any of the ignition sources in any panda is high, ignition is high
|
||||
|
||||
#define MAX_IR_POWER 0.5f
|
||||
#define MIN_IR_POWER 0.0f
|
||||
#define MAX_IR_PANDA_VAL 50
|
||||
#define CUTOFF_IL 400
|
||||
#define SATURATE_IL 1000
|
||||
|
||||
@@ -371,8 +370,8 @@ void process_peripheral_state(Panda *panda, PubMaster *pm, bool no_fan_control)
|
||||
|
||||
static uint64_t last_driver_camera_t = 0;
|
||||
static uint16_t prev_fan_speed = 999;
|
||||
static uint16_t ir_pwr = 0;
|
||||
static uint16_t prev_ir_pwr = 999;
|
||||
static int ir_pwr = 0;
|
||||
static int prev_ir_pwr = 999;
|
||||
|
||||
static FirstOrderFilter integ_lines_filter(0, 30.0, 0.05);
|
||||
|
||||
@@ -395,11 +394,11 @@ void process_peripheral_state(Panda *panda, PubMaster *pm, bool no_fan_control)
|
||||
last_driver_camera_t = event.getLogMonoTime();
|
||||
|
||||
if (cur_integ_lines <= CUTOFF_IL) {
|
||||
ir_pwr = 100.0 * MIN_IR_POWER;
|
||||
ir_pwr = 0;
|
||||
} else if (cur_integ_lines > SATURATE_IL) {
|
||||
ir_pwr = 100.0 * MAX_IR_POWER;
|
||||
ir_pwr = 100;
|
||||
} else {
|
||||
ir_pwr = 100.0 * (MIN_IR_POWER + ((cur_integ_lines - CUTOFF_IL) * (MAX_IR_POWER - MIN_IR_POWER) / (SATURATE_IL - CUTOFF_IL)));
|
||||
ir_pwr = 100 * (cur_integ_lines - CUTOFF_IL) / (SATURATE_IL - CUTOFF_IL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,9 +407,10 @@ void process_peripheral_state(Panda *panda, PubMaster *pm, bool no_fan_control)
|
||||
ir_pwr = 0;
|
||||
}
|
||||
|
||||
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);
|
||||
if (ir_pwr != prev_ir_pwr || sm.frame % 100 == 0) {
|
||||
int16_t ir_panda = util::map_val(ir_pwr, 0, 100, 0, MAX_IR_PANDA_VAL);
|
||||
panda->set_ir_pwr(ir_panda);
|
||||
Hardware::set_ir_power(ir_pwr);
|
||||
prev_ir_pwr = ir_pwr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int value = util::map_val(std::clamp(percent, 0, 100), 0, 100, 0, 255);
|
||||
int value = util::map_val(std::clamp(percent, 0, 100), 0, 100, 0, 300);
|
||||
std::ofstream("/sys/class/leds/led:switch_2/brightness") << 0 << "\n";
|
||||
std::ofstream("/sys/class/leds/led:torch_2/brightness") << value << "\n";
|
||||
std::ofstream("/sys/class/leds/led:switch_2/brightness") << value << "\n";
|
||||
|
||||
Reference in New Issue
Block a user