Skip to content

Commit a8f989e

Browse files
committed
er updates
1 parent b302c1a commit a8f989e

File tree

4 files changed

+325
-273
lines changed

4 files changed

+325
-273
lines changed

applications/er/ErConfig.qml

+28-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Item {
2727
er_msg.ER_MSG_GET_IO = 2
2828
er_msg.ER_MSG_RESTORE_SETTINGS = 3
2929
er_msg.ER_MSG_SET_MOTORS_ENABLED = 4
30+
er_msg.ER_MSG_SET_PEDAL_TEST_MODE = 5
3031

3132
er_set.p_throttle_hyst = 0.04
3233
er_set.p_pedal_current = 20.0
@@ -98,6 +99,12 @@ Item {
9899
} else {
99100
VescIf.emitStatusMessage("ER Motors Disabled", true)
100101
}
102+
} else if (cmd == er_msg.ER_MSG_SET_PEDAL_TEST_MODE) {
103+
if (dv.getUint8(ind++)) {
104+
VescIf.emitStatusMessage("Pedal Test Enabled", true)
105+
} else {
106+
VescIf.emitStatusMessage("Pedal Test Disabled", true)
107+
}
101108
}
102109
}
103110
}
@@ -156,6 +163,15 @@ Item {
156163
mCommands.sendCustomAppData(buffer)
157164
}
158165

166+
function setPedalTestMode(enabled) {
167+
var buffer = new ArrayBuffer(2)
168+
var dv = new DataView(buffer)
169+
var ind = 0
170+
dv.setUint8(ind++, er_msg.ER_MSG_SET_PEDAL_TEST_MODE)
171+
dv.setUint8(ind++, enabled)
172+
mCommands.sendCustomAppData(buffer)
173+
}
174+
159175
function updateSliders() {
160176
repSliders.itemAt(0).value = er_set.p_pedal_current
161177
repSliders.itemAt(1).value = er_set.p_start_gain
@@ -305,6 +321,17 @@ Item {
305321
readSettings()
306322
}
307323
}
324+
325+
CheckBox {
326+
Layout.fillWidth: true
327+
Layout.preferredWidth: 500
328+
Layout.preferredHeight: 80
329+
text: "Pedal Test"
330+
331+
onToggled: {
332+
setPedalTestMode(checked)
333+
}
334+
}
308335
}
309336
}
310337

@@ -487,7 +514,7 @@ Item {
487514
return
488515
}
489516

490-
mMcConf.updateParamDouble("si_gear_ratio", 5.6, null)
517+
mMcConf.updateParamDouble("si_gear_ratio", 112 / 18, null)
491518
mMcConf.updateParamInt("si_motor_poles", 8, null)
492519
mMcConf.updateParamDouble("si_wheel_diameter", 0.58, null)
493520

applications/er/app_erockit_v2.c

+21-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ typedef enum {
8787
ER_MSG_GET_MODE_PARAMS,
8888
ER_MSG_GET_IO,
8989
ER_MSG_RESTORE_SETTINGS,
90-
ER_MSG_SET_MOTORS_ENABLED
90+
ER_MSG_SET_MOTORS_ENABLED,
91+
ER_MSG_SET_PEDAL_TEST_MODE
9192
} ER_MSG;
9293

9394
typedef struct {
@@ -108,6 +109,7 @@ static volatile SETTINGS_T m_set_sport;
108109
static volatile SETTINGS_T *m_set_now = &m_set_normal;
109110
static volatile int m_set_now_offset = 0;
110111
static volatile bool m_motors_enabled = true;
112+
static volatile bool m_pedal_test_mode = false;
111113

112114
// Private functions
113115
static void process_custom_app_data(unsigned char *data, unsigned int len);
@@ -406,6 +408,10 @@ static THD_FUNCTION(my_thread, arg) {
406408
pedal_current_target = utils_map(erpm_motor, 0.0, erpm_ramp_in, 0.0, pedal_current_target);
407409
}
408410

411+
if ((!m_kill_sw || m_brake_front || m_brake_rear) && !m_pedal_test_mode) {
412+
running = false;
413+
}
414+
409415
if (running) {
410416
mc_interface_set_pid_speed(erpm_now);
411417

@@ -547,7 +553,9 @@ static THD_FUNCTION(my_thread, arg) {
547553
}
548554
}
549555

550-
if (!m_kill_sw || brake > 0.0001) {
556+
if (!m_kill_sw || m_pedal_test_mode) {
557+
comm_can_set_current_brake_rel(255, 0.0);
558+
} else if (brake > 0.0001) {
551559
comm_can_set_current_brake_rel(255, brake);
552560
} else {
553561
comm_can_set_current_rel(255, pwr_out * m_set_now->p_output_power);
@@ -662,6 +670,17 @@ static void process_custom_app_data(unsigned char *data, unsigned int len) {
662670
commands_send_app_data(dataTx, ind);
663671
} break;
664672

673+
case ER_MSG_SET_PEDAL_TEST_MODE: {
674+
m_pedal_test_mode = data[ind++];
675+
676+
// Send ack
677+
uint8_t dataTx[50];
678+
ind = 0;
679+
dataTx[ind++] = msg;
680+
dataTx[ind++] = m_pedal_test_mode;
681+
commands_send_app_data(dataTx, ind);
682+
} break;
683+
665684
default:
666685
break;
667686
}

0 commit comments

Comments
 (0)