Skip to content

Commit 53bd5f5

Browse files
author
Bjoern Schmidt
committed
fugbixes
1 parent 609247b commit 53bd5f5

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

ACAcommons.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,23 @@ void updatePasStatus(void) {
259259
void updateSlowLoopStates(void) {
260260

261261
if (ui16_motor_speed_erps == 0) {
262-
ui16_idle_counter++;
262+
if (ui16_idle_counter < 64000){
263+
ui16_idle_counter++;
264+
}
263265
} else {
264266
ui16_idle_counter = 0;
265267
}
266268

269+
// debug only
270+
ui8_variableDebugA = ui16_passcode;
271+
ui8_variableDebugB = ui16_passcode >>8;
272+
267273
//disable lock if passcode is not at least 4 digits
268-
if (ui16_passcode < 1000){
269-
ui8_lockstatus = 0;
274+
if (ui16_passcode < 1001){
275+
ui8_lockstatus = 16;
270276
}else if (((ui16_aca_flags & IDLE_LOCKS_CONTROLLER) == IDLE_LOCKS_CONTROLLER) && (ui16_idle_counter > 3000)) {
271277
//lock after 60 seconds idle
272-
ui8_lockstatus = 1;
278+
ui8_lockstatus = 255;
273279
}
274280

275281
if (((ui16_aca_flags & IDLE_DISABLES_OFFROAD) == IDLE_DISABLES_OFFROAD) && (ui8_offroad_state > 4) && (ui16_idle_counter > 3000)) {

ACAcontrollerState.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ uint8_t ui8_SPEED_Flag = 0; //flag for SPEED interrupt
110110
uint8_t ui8_offroad_counter = 0; //counter for offroad switching procedure
111111
uint16_t ui16_idle_counter = 0;
112112
uint16_t ui16_passcode = 0;
113-
uint8_t ui8_lockstatus = 1;
113+
uint8_t ui8_lockstatus = 255;
114114

115115
uint16_t ui16_aca_flags = 0;
116116
uint16_t ui16_aca_experimental_flags = 0;

BOdisplay.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void addDetailStateInfos(void) {
214214
addPayload(CODE_VER_SPEED_HIGH_BYTE, ui16_virtual_erps_speed >> 8);
215215
addPayload(CODE_VER_SPEED, ui16_virtual_erps_speed);
216216
addPayload(CODE_LOCKSTATUS, ui8_lockstatus);
217-
// 9 more elements left/avail (max30)
217+
// 8 more elements left/avail (max30)
218218
}
219219

220220
void addBasicStateInfos(void) {
@@ -280,18 +280,18 @@ void digestConfigRequest(uint8_t configAddress, uint8_t requestedCodeLowByte, ui
280280
addPayload(requestedCodeLowByte, ui8_offroad_state);
281281
break;
282282
case CODE_PASSCODE:
283-
if ((ui8_lockstatus == 0) && (configAddress == EEPROM_ADDRESS)){
283+
if ((ui8_lockstatus == 16) && (configAddress == EEPROM_ADDRESS)){
284284
// write new passcode only if unlocked
285-
ui16_passcode == ((uint16_t) requestedValueHighByte << 8)+(uint16_t) requestedValue;
285+
ui16_passcode = ((uint16_t) requestedValueHighByte << 8)+(uint16_t) requestedValue;
286286
eeprom_write(OFFSET_PASSCODE_HIGH_BYTE, requestedValueHighByte);
287287
eeprom_write(OFFSET_PASSCODE, requestedValue);
288-
addPayload(CODE_PASSCODE_HIGH_BYTE, ui16_aca_flags >> 8);
289-
addPayload(requestedCodeLowByte, ui16_aca_flags);
288+
addPayload(CODE_PASSCODE_HIGH_BYTE, ui16_passcode >> 8);
289+
addPayload(requestedCodeLowByte, ui16_passcode);
290290
}else if ((configAddress != EEPROM_ADDRESS) && (ui16_passcode == (((uint16_t) requestedValueHighByte << 8)+(uint16_t) requestedValue))){
291291
// unlock if correct code was sent
292-
ui8_lockstatus = 0;
293-
addPayload(CODE_PASSCODE_HIGH_BYTE, ui16_aca_flags >> 8);
294-
addPayload(requestedCodeLowByte, ui16_aca_flags);
292+
ui8_lockstatus = 16;
293+
addPayload(CODE_PASSCODE_HIGH_BYTE, ui16_passcode >> 8);
294+
addPayload(requestedCodeLowByte, ui16_passcode);
295295
}else{
296296
addPayload(CODE_ERROR, CODE_ERROR);
297297
}

config.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define CONFIG_H_
1010

1111
#define NUMBER_OF_PAS_MAGS 12
12-
#define limit 25
12+
#define limit 28
1313
#define timeout 3125
1414
#define wheel_circumference 2230L
1515
#define limit_without_pas 6
@@ -19,7 +19,7 @@
1919
#define BATTERY_CURRENT_MAX_VALUE 150L
2020
#define PHASE_CURRENT_MAX_VALUE 300L
2121
#define REGEN_CURRENT_MAX_VALUE 50L
22-
#define MOTOR_ROTOR_DELTA_PHASE_ANGLE_RIGHT 0
22+
#define MOTOR_ROTOR_DELTA_PHASE_ANGLE_RIGHT 238
2323
#define current_cal_a 46
2424
#define TEMP_CAL_A 1.6
2525
#define TEMP_CAL_B -110.4
@@ -38,22 +38,22 @@
3838
#define BATTERY_LI_ION_CELLS_NUMBER 13
3939
#define PAS_THRESHOLD 1.9
4040
#define RAMP_START 64000
41-
#define limit_with_throttle_override 25
41+
#define limit_with_throttle_override 35
4242
#define CORRECTION_AT_ANGLE 127
4343
#define PWM_CYCLES_SECOND 15625L
44-
#define BLUOSEC
4544
#define SPEEDSENSOR_INTERNAL
4645
#define ANGLE_4_0 1
47-
#define ANGLE_6_60 43
48-
#define ANGLE_2_120 86
46+
#define ANGLE_6_60 38
47+
#define ANGLE_2_120 82
4948
#define ANGLE_3_180 128
50-
#define ANGLE_1_240 171
51-
#define ANGLE_5_300 213
49+
#define BLUOSEC
50+
#define ANGLE_1_240 166
51+
#define ANGLE_5_300 210
5252
#define TQS_CALIB 0.0
53-
#define ACA 4766
53+
#define ACA 4764
5454
#define EEPROM_NOINIT // eeprom will not be cleared
55-
#define EEPROM_INIT_MAGIC_BYTE 193 // makes sure (chance of fail 1/255) eeprom is invalidated after flashing new config
56-
#define ADC_BATTERY_VOLTAGE_K 70
55+
#define EEPROM_INIT_MAGIC_BYTE 85 // makes sure (chance of fail 1/255) eeprom is invalidated after flashing new config
56+
#define ADC_BATTERY_VOLTAGE_K 68
5757
#define ACA_EXPERIMENTAL 128
5858
#define BATTERY_VOLTAGE_MAX_VALUE 200
5959

0 commit comments

Comments
 (0)