Skip to content

Commit 0ceb60b

Browse files
committed
Adding a way to disable ON/OFF beeps, change wheels size
1 parent 5d29637 commit 0ceb60b

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ build/*
22
!build/hover.hex
33
.pioenvs
44
.piolibdeps
5+
.pio
56
.vscode/*
67
lib/readme.txt
78
_autosave*

inc/config.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@
260260
#define TEMP_POWEROFF 65 // overheat poweroff. (while not driving) [°C]
261261
#endif
262262

263+
#ifndef ENABLE_INACTIVITY_TIMEOUT
264+
#define ENABLE_INACTIVITY_TIMEOUT 1
265+
#endif
266+
263267
#ifndef INACTIVITY_TIMEOUT
264268
#define INACTIVITY_TIMEOUT 8 // minutes of not driving until poweroff. it is not very precise.
265269
#endif
@@ -354,8 +358,9 @@
354358
// left sensor board cable. keep cable short, use shielded cable, use ferrits, stabalize voltage in nunchuck, use the right one of the 2 types of nunchucks, add i2c pullups. use original nunchuck. most clones does not work very well.
355359
//#define CONTROL_NUNCHUCK // use nunchuck as input. disable DEBUG_SERIAL_USART3!
356360

357-
358-
//#define WHEEL_SIZE_INCHES 8.5 - set to your wheelsize to override the default 6.5
361+
#ifndef WHEEL_SIZE_INCHES
362+
#define WHEEL_SIZE_INCHES 6.5 //set to your wheelsize to override the default 6.5
363+
#endif
359364

360365

361366
// ############################### SOFTWARE SERIAL ###############################
@@ -403,7 +408,10 @@
403408
#define SWITCH_WHEELS 0 // switch right and left wheel. Watch out, you probably also need to invert directions.
404409
#endif
405410
#ifndef BEEPS_BACKWARD
406-
#define BEEPS_BACKWARD 0 // 0 or 1
411+
#define BEEPS_BACKWARD 0 // 0 or 1
412+
#endif
413+
#ifndef BEEPS_ON_OFF
414+
#define BEEPS_ON_OFF 1 // Beeps on starting/stopping hoverboard
407415
#endif
408416

409417

inc/hallinterrupts.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ extern TIME_STATS timeStats;
7171
#define HALL_INTERRUPT_TIMER_FREQ 100000
7272

7373
#define HALL_POSN_PER_REV 90
74-
#define DEFAULT_WHEEL_SIZE_INCHES 6.5
7574

7675
//////////////////////////////////////////////////////////////
7776
// this is the Hall data we gather, and can be read elsewhere

src/hallinterrupts.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ volatile HALL_PARAMS local_hall_params[2];
8080

8181
volatile long long timerwraps = 0;
8282

83-
static float WheelSize_mm = (DEFAULT_WHEEL_SIZE_INCHES * 25.4);
83+
static float WheelSize_mm = (WHEEL_SIZE_INCHES * 25.4);
8484

8585

8686

@@ -92,11 +92,6 @@ void HallInterruptinit(void){
9292
local_hall_params[0].direction = -1;
9393
local_hall_params[1].direction = 1;
9494

95-
// overrides local fle default
96-
#ifdef WHEEL_SIZE_INCHES
97-
WheelSize_mm = (WHEEL_SIZE_INCHES * 25.4);
98-
#endif
99-
10095
HallData[0].HallPosnMultiplier = (float)((WheelSize_mm*3.14159265359)/(float)HALL_POSN_PER_REV);
10196
HallData[1].HallPosnMultiplier = (float)((WheelSize_mm*3.14159265359)/(float)HALL_POSN_PER_REV);
10297

src/main.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ void poweroff() {
122122
if (ABS(speed) < 20) {
123123
buzzerPattern = 0;
124124
enable = 0;
125+
#if BEEPS_ON_OFF
125126
for (int i = 0; i < 8; i++) {
126127
buzzerFreq = i;
127128
HAL_Delay(100);
128129
}
130+
#endif
129131
HAL_GPIO_WritePin(OFF_PORT, OFF_PIN, 0);
130132

131133
// if we are powered from sTLink, this bit allows the system to be started again with the button.
@@ -260,7 +262,7 @@ int main(void) {
260262
& HallData[0].HallPosn,
261263
& HallData[1].HallPosn,
262264
HALL_POSN_PER_REV,
263-
(DEFAULT_WHEEL_SIZE_INCHES*25.4),
265+
(WHEEL_SIZE_INCHES*25.4),
264266
WHEELBASE_MM, 1);
265267
#endif
266268

@@ -319,12 +321,13 @@ int main(void) {
319321
electrical_measurements.dcCurLim = MIN(DC_CUR_LIMIT*100, FlashContent.MaxCurrLim);
320322

321323

322-
324+
#if BEEPS_ON_OFF
323325
for (int i = 8; i >= 0; i--) {
324326
buzzerFreq = i;
325327
HAL_Delay(100);
326328
}
327329
buzzerFreq = 0;
330+
#endif
328331

329332
HAL_GPIO_WritePin(LED_PORT, LED_PIN, 1);
330333

@@ -807,31 +810,39 @@ int main(void) {
807810

808811
// if we plug in the charger, keep us alive
809812
// also if we have deliberately turned off poweroff over serial
813+
#if ENABLE_INACTIVITY_TIMEOUT
810814
if (electrical_measurements.charging || disablepoweroff){
811815
inactivity_timeout_counter = 0;
812816
}
817+
#endif
813818

814819
// ####### BEEP AND EMERGENCY POWEROFF #######
815-
if (TEMP_POWEROFF_ENABLE && board_temp_deg_c >= TEMP_POWEROFF && ABS(speed) < 20){ // poweroff before mainboard burns OR low bat 3
820+
#if TEMP_POWEROFF_ENABLE
821+
if (board_temp_deg_c >= TEMP_POWEROFF && ABS(speed) < 20){ // poweroff before mainboard burns OR low bat 3
816822
consoleLog("power off by temp\r\n");
817823
poweroff();
818824
}
825+
#endif
819826

820827
if (batteryVoltage < ((float)BAT_LOW_DEAD * (float)BAT_NUMBER_OF_CELLS) && ABS(speed) < 20) { // poweroff before mainboard burns OR low bat 3
821828
consoleLog("power off by low voltage\r\n");
822829
poweroff();
823-
} else if (TEMP_WARNING_ENABLE && board_temp_deg_c >= TEMP_WARNING) { // beep if mainboard gets hot
830+
#if TEMP_WARNING_ENABLE
831+
} else if (board_temp_deg_c >= TEMP_WARNING) { // beep if mainboard gets hot
824832
buzzerFreq = 4;
825833
buzzerPattern = 1;
834+
#endif
826835
} else if (batteryVoltage < ((float)BAT_LOW_LVL1 * (float)BAT_NUMBER_OF_CELLS) && batteryVoltage > ((float)BAT_LOW_LVL2 * (float)BAT_NUMBER_OF_CELLS) && BAT_LOW_LVL1_ENABLE) { // low bat 1: slow beep
827836
buzzerFreq = 5;
828837
buzzerPattern = 42;
829838
} else if (batteryVoltage < ((float)BAT_LOW_LVL2 * (float)BAT_NUMBER_OF_CELLS) && batteryVoltage > ((float)BAT_LOW_DEAD * (float)BAT_NUMBER_OF_CELLS) && BAT_LOW_LVL2_ENABLE) { // low bat 2: fast beep
830839
buzzerFreq = 5;
831840
buzzerPattern = 6;
832-
} else if (BEEPS_BACKWARD && speed < -50) { // backward beep
841+
#if BEEPS_BACKWARD
842+
} else if (speed < -50) { // backward beep
833843
buzzerFreq = 5;
834844
buzzerPattern = 1;
845+
#endif
835846
} else { // do not beep
836847
if (buzzerLen > 0){
837848
buzzerLen--;
@@ -843,6 +854,7 @@ int main(void) {
843854

844855

845856
// ####### INACTIVITY TIMEOUT #######
857+
#if ENABLE_INACTIVITY_TIMEOUT
846858
if (ABS(pwms[0]) > 50 || ABS(pwms[1]) > 50) {
847859
inactivity_timeout_counter = 0;
848860
} else {
@@ -871,6 +883,7 @@ int main(void) {
871883
consoleLog("power off by 60s inactivity\r\n");
872884
poweroff();
873885
}
886+
#endif
874887

875888

876889
if (powerofftimer > 0){

0 commit comments

Comments
 (0)