Skip to content

Commit ee5ca71

Browse files
committed
fix speed, hopefully brake bars
1 parent 85565ea commit ee5ca71

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

Telemetry-Main/BT817Q/layouts.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void Layouts::drawStandardLayout(
4141
Faults faults, const uint8_t speed, const uint8_t soc, uint8_t acc_temp,
4242
uint8_t ctrl_tmp, uint8_t mtr_tmp, float mtr_volt, float glv,
4343
float steering_angle, float brake_balance, float brake_f, float brake_r,
44-
float throttle_demand, float brake_demand, std::chrono::milliseconds time,
44+
float throttle_demand, float brake_val, float brake_psi, std::chrono::milliseconds time,
4545
double delta_time_seconds) {
4646
if (failure == startFrame()) {
4747
return;
@@ -126,7 +126,7 @@ void Layouts::drawStandardLayout(
126126
// red,
127127
// mid_gray); // brake demand bar
128128
drawRect(Point{750, 300}, Point{782, 480}, mid_gray);
129-
const uint16_t brake_bar_h = (480 - floor(160 * brake_demand));
129+
const uint16_t brake_bar_h = (480 - floor(160 * brake_val));
130130
drawRect(Point{750, brake_bar_h}, Point{782, 480}, red);
131131
endFrame();
132132
}
@@ -135,7 +135,7 @@ void Layouts::drawStandardLayout2(
135135
Faults faults, uint8_t speed, uint8_t soc, uint8_t acc_temp,
136136
uint8_t ctrl_tmp, uint8_t mtr_tmp, float mtr_volt, float glv,
137137
float steering_angle, float brake_balance, float brake_f, float brake_r,
138-
float throttle_demand, float brake_demand, std::chrono::milliseconds time,
138+
float throttle_demand, float brake_val, float brake_psi, std::chrono::milliseconds time,
139139
double delta_time_seconds, bool rtds, uint16_t rpm) {
140140
if (failure == startFrame()) {
141141
return;
@@ -199,20 +199,21 @@ void Layouts::drawStandardLayout2(
199199
drawFormattedText(70, 210, "ACC %03dC", 24, OPT_CENTER, acc_temp);
200200
drawFormattedText(70, 240, "CTRL %03dC", 24, OPT_CENTER, ctrl_tmp);
201201
drawFormattedText(70, 270, "MTR %03dC", 24, OPT_CENTER, mtr_tmp);
202-
drawFormattedText(70, 300, "MC %03.1fV ", 24, OPT_CENTER,
202+
drawFormattedText(70, 300, "MC %03.1fV ", 24, OPT_CENTER,
203203
mtr_volt); // voltages
204204
drawFormattedText(70, 330, "GLV %03.1fV ", 24, OPT_CENTER, glv);
205-
drawFormattedText(70, 390, "BRF %03.2f ", 24, OPT_CENTER, brake_f);
206-
drawFormattedText(70, 420, "BRR %03.2f ", 24, OPT_CENTER, brake_r);
205+
drawFormattedText(70, 360, "BRF %03.2fmV ", 24, OPT_CENTER, brake_f);
206+
drawFormattedText(70, 390, "BRR %03.2fmV ", 24, OPT_CENTER, brake_r);
207+
drawFormattedText(70, 420, "BR %03.2fpsi ", 24, OPT_CENTER, brake_psi);
207208
drawFormattedText(70, 450, "STEER %03.2f ", 24, OPT_CENTER, steering_angle);
208209

209210
drawRect(Point{614, 127}, Point{637, 310}, mid_gray);
210-
uint16_t throttle_bar_h = 127 + 183*throttle_demand;
211-
drawRect(Point{614, throttle_bar_h}, Point{637, 310}, green);
211+
uint16_t throttle_bar_h = 310 - 183*throttle_demand;
212+
drawRect(Point{614, 127}, Point{637, throttle_bar_h}, green);
212213

213214
drawRect(Point{643, 127}, Point{666, 310}, mid_gray);
214-
uint16_t brake_bar_h = 127 + 183*brake_demand;
215-
drawRect(Point{643, brake_bar_h}, Point{666, 310}, red);
215+
uint16_t brake_bar_h = 310 - 183*(brake_val);
216+
drawRect(Point{643, 310}, Point{666, brake_bar_h}, red);
216217
// drawRect(Point{643, static_cast<uint16_t>(brake_demand)}, Point{666, 310},
217218
// red);
218219
endFrame();

Telemetry-Main/BT817Q/layouts.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class Layouts : public BT817Q {
3737
float brake_f;
3838
float brake_r;
3939
float throttle_demand;
40-
float brake_demand;
40+
float brake_val;
41+
float brake_psi;
4142
std::chrono::milliseconds time;
4243
double delta_time_seconds;
4344
bool rtds;
@@ -57,7 +58,8 @@ class Layouts : public BT817Q {
5758
float brake_f,
5859
float brake_r,
5960
float throttle_demand,
60-
float brake_demand,
61+
float brake_val,
62+
float brake_psi,
6163
std::chrono::milliseconds time,
6264
double delta_time_seconds
6365
);
@@ -76,7 +78,8 @@ class Layouts : public BT817Q {
7678
params.brake_f,
7779
params.brake_r,
7880
params.throttle_demand,
79-
params.brake_demand,
81+
params.brake_val,
82+
params.brake_psi,
8083
params.time,
8184
params.delta_time_seconds);
8285
}
@@ -93,7 +96,8 @@ class Layouts : public BT817Q {
9396
float brake_f,
9497
float brake_r,
9598
float throttle_demand,
96-
float brake_demand,
99+
float brake_val,
100+
float brake_psi,
97101
std::chrono::milliseconds time,
98102
double delta_time_seconds,
99103
bool rtds,
@@ -114,7 +118,8 @@ class Layouts : public BT817Q {
114118
params.brake_f,
115119
params.brake_r,
116120
params.throttle_demand,
117-
params.brake_demand,
121+
params.brake_val,
122+
params.brake_psi,
118123
params.time,
119124
params.delta_time_seconds,
120125
params.rtds,

Telemetry-Main/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void update_dash() {
108108
}
109109
params = {
110110
.faults =
111-
Faults{false, static_cast<bool>(vsm_state.accStatus.PRECHARGE_DONE),
111+
Faults{false, static_cast<bool>(!vsm_state.accStatus.PRECHARGE_DONE),
112112
static_cast<bool>(!vsm_state.accStatus.SHUTDOWN_STATE)},
113113
.speed = static_cast<uint8_t>(vsm_state.smeTrqSpd.SPEED * 112 / 7500),
114114
.soc = vsm_state.accPower.SOC,
@@ -121,9 +121,11 @@ void update_dash() {
121121
.brake_balance = vsm_state.brake_sensor_f / (vsm_state.brake_sensor_f + vsm_state.brake_sensor_r),
122122
.brake_f = vsm_state.brake_sensor_f,
123123
.brake_r = vsm_state.brake_sensor_r,
124-
.throttle_demand = static_cast<float>(vsm_state.smeThrottleDemand.TORQUE_DEMAND / 32768.0), // 0-1
125-
// 0.33 - 1.65
126-
.brake_demand = static_cast<float>(((vsm_state.etcStatus.BRAKE_SENSE_VOLTAGE / 32768.0)*3.3 - 0.33) / (1.65 - 0.33)),
124+
.throttle_demand = vsm_state.smeThrottleDemand.TORQUE_DEMAND / 32768.0f, // 0-1
125+
// 0 - 1
126+
.brake_val = static_cast<float>(((vsm_state.etcStatus.BRAKE_SENSE_VOLTAGE / 32768.0)*3.3 - 0.33) / (1.65 - 0.33)),
127+
// psi
128+
.brake_psi = static_cast<float>((vsm_state.etcStatus.BRAKE_SENSE_VOLTAGE / 32768.0) - 0.1) * 2500,
127129
.time = chrono::milliseconds(0),
128130
.delta_time_seconds = 0.01,
129131
.rtds = static_cast<bool>(vsm_state.etcStatus.RTD),

0 commit comments

Comments
 (0)