Skip to content

Commit 873ba4b

Browse files
committed
updated to work with separate buttons for pedals and steering
1 parent 575e5b0 commit 873ba4b

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

include/VCF_Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
namespace VCFInterfaceConstants {
88
/* Teensy 4.1 GPIO pins */
99

10-
constexpr int BTN_DIM_READ = 28; // Currently used for steering system recalibration TODO: change pin
1110
/* Not on Schematic
11+
// constexpr int BTN_DIM_READ = 28; // Currently used for steering system recalibration TODO: change pin
1212
// constexpr int BTN_PRESET_READ = 31;
1313
// constexpr int BTN_MODE_READ = 27; // USED TO BE 26.
1414
*/

lib/interfaces/src/NeopixelController.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void NeopixelController::set_neopixel(uint16_t id, uint32_t c) {
3030
void NeopixelController::refresh_neopixels(const PedalsSystemData_s &pedals_data, CANInterfaces &interfaces) {
3131

3232
// If we are in pedals recalibration state, LIGHT UP DASHBOARD ALL RED.
33-
if (interfaces.vcr_interface.is_in_pedals_calibration_state()) {
33+
if (interfaces.vcr_interface.is_in_pedals_calibration_state() || interfaces.vcr_interface.is_in_steering_calibration_state()) {
3434
set_neopixel_color(LED_ID_e::BRAKE, LED_color_e::RED);
3535
set_neopixel_color(LED_ID_e::TORQUE_MODE, LED_color_e::RED);
3636
set_neopixel_color(LED_ID_e::LATCH, LED_color_e::RED);

src/VCF_Tasks.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ HT_TASK::TaskResponse run_read_adc0_task(const unsigned long& sysMicros, const H
3030
{
3131
// Updates all eight channels.
3232
ADCInterfaceInstance::instance().adc0_tick();
33-
// OrbisBRInstance::instance().sample();
33+
OrbisBRInstance::instance().sample();
3434
PedalsSystemInstance::instance().set_pedals_sensor_data(PedalSensorData_s{
3535
.accel_1 = static_cast<uint32_t>(ADCInterfaceInstance::instance().acceleration_1().conversion),
3636
.accel_2 = static_cast<uint32_t>(ADCInterfaceInstance::instance().acceleration_2().conversion),
@@ -93,16 +93,14 @@ HT_TASK::TaskResponse update_pedals_calibration_task(const unsigned long& sysMic
9393
return HT_TASK::TaskResponse::YIELD;
9494
}
9595

96-
uint32_t last_steering_calibrate_time; // move this maybe
9796
HT_TASK::TaskResponse update_steering_calibration_task(const unsigned long& sysMicros, const HT_TASK::TaskInfo& taskInfo) {
9897
const uint32_t analog_raw = SteeringSystemInstance::instance().get_steering_system_data().analog_raw;
9998
const uint32_t digital_raw = SteeringSystemInstance::instance().get_steering_system_data().digital_raw;
10099

101100
SteeringSystemInstance::instance().update_observed_steering_limits(analog_raw, digital_raw);
102101

103102

104-
if (VCRInterfaceInstance::instance().is_in_steering_calibration_state() && sys_time::hal_millis() - last_steering_calibrate_time > 5000) {
105-
last_steering_calibrate_time = sys_time::hal_millis();
103+
if (VCRInterfaceInstance::instance().is_in_steering_calibration_state()) {
106104

107105
SteeringSystemInstance::instance().recalibrate_steering_digital();
108106
EEPROMUtilities::write_eeprom_32bit(VCFSystemConstants::MIN_STEERING_SIGNAL_ANALOG_ADDR, SteeringSystemInstance::instance().get_steering_params().min_steering_signal_analog);
@@ -326,10 +324,14 @@ HT_TASK::TaskResponse run_dash_GPIOs_task(const unsigned long& sys_micros, const
326324
bool was_dim_btn_pressed = DashboardInterfaceInstance::instance().get_dashboard_stored_state().brightness_ctrl_btn_is_pressed; //NOLINT (linter thinks variable uninitialized)
327325
DashInputState_s current_state = DashboardInterfaceInstance::instance().get_dashboard_outputs();
328326

329-
if (!current_state.preset_btn_is_pressed) //preset_btn_is_pressed doesnt exist anymore
327+
if (!current_state.preset_btn_is_pressed) //preset btn tied to brightness control on schematic
330328
{
331329
VCRInterfaceInstance::instance().disable_calibration_state();
332-
VCRInterfaceInstance::instance().disable_steering_calibration_state(); //link to new button eventually
330+
}
331+
332+
if (!current_state.data_btn_is_pressed)
333+
{
334+
VCRInterfaceInstance::instance().disable_steering_calibration_state();
333335
}
334336

335337
// Checks if dim btn has been clicked (falling edge)
@@ -580,7 +582,8 @@ HT_TASK::TaskResponse debug_print(const unsigned long& sysMicros, const HT_TASK:
580582

581583
Serial.println("Steering Sensor Data: ");
582584
Serial.print("analog adc: ");
583-
Serial.print(SteeringSystemInstance::instance().get_steering_system_data().analog_raw);
585+
Serial.print(SteeringSystemInstance::instance().get_steering_system_data().analog_raw); Serial.print(" ");
586+
Serial.print(ADCInterfaceInstance::instance().get_steering_degrees_cw().raw);
584587
Serial.print("|");
585588
Serial.println(SteeringSystemInstance::instance().get_steering_system_data().analog_steering_angle);
586589
Serial.print("digital adc: ");
@@ -771,7 +774,6 @@ void setup_all_interfaces() {
771774
steering_params.digital_midpoint = (steering_params.min_steering_signal_digital + steering_params.max_steering_signal_digital) / 2;
772775

773776
SteeringSystemInstance::create(steering_params);
774-
last_steering_calibrate_time = sys_time::hal_millis();
775777

776778
// Create Digital Steering Sensor singleton
777779
OrbisBRInstance::create(&Serial2);

0 commit comments

Comments
 (0)