From 994277affedfa1d331aedf7ea274f1fccf785efb Mon Sep 17 00:00:00 2001 From: EmanuelFeru Date: Sun, 6 Dec 2020 20:35:01 +0100 Subject: [PATCH] Fixed beep counter interraction - beep counter interraction fix - readme update --- README.md | 18 +++++++++--------- Src/util.c | 20 ++++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 8f5af8a..5c1de89 100644 --- a/README.md +++ b/README.md @@ -105,15 +105,15 @@ In all FOC control modes, the controller features maximum motor speed and maximu ## Example Variants This firmware offers currently these variants (selectable in [platformio.ini](/platformio.ini) or [config.h](/Inc/config.h)): -- **VARIANT_ADC**: In this variant the motors are controlled by two potentiometers connected to the Left sensor cable (long wired) -- **VARIANT_USART**: In this variant the motors are controlled via serial protocol (e.g. on USART3 right sensor cable, the short wired cable). The commands can be sent from an Arduino. Check out the [hoverserial.ino](/Arduino/hoverserial) as an example sketch. +- **VARIANT_ADC**: The motors are controlled by two potentiometers connected to the Left sensor cable (long wired) +- **VARIANT_USART**: The motors are controlled via serial protocol (e.g. on USART3 right sensor cable, the short wired cable). The commands can be sent from an Arduino. Check out the [hoverserial.ino](/Arduino/hoverserial) as an example sketch. - **VARIANT_NUNCHUK**: Wii Nunchuk offers one hand control for throttle, braking and steering. This was one of the first input device used for electric armchairs or bottle crates. -- **VARIANT_PPM**: This is when you want to use an RC remote control with PPM Sum signal. -- **VARIANT_PWM**: This is when you want to use an RC remote control with PWM signal. -- **VARIANT_IBUS**: This is when you want to use an RC remote control with Flysky IBUS protocol connected to the Left sensor cable. -- **VARIANT_HOVERCAR**: In this variant the motors are controlled by two pedals brake and throttle. Reverse is engaged by double tapping on the brake pedal at standstill. See [HOVERCAR video](https://www.youtube.com/watch?v=IgHCcj0NgWQ&t=). -- **VARIANT_HOVERBOARD**: In this variant the mainboard reads the sideboards data. The sideboards need to be flashed with the hacked version. Only balancing controller is still to be implemented. -- **VARIANT_TRANSPOTTER**: This build is for transpotter which is a hoverboard based transportation system. For more details on how to build it check [here](https://github.com/NiklasFauth/hoverboard-firmware-hack/wiki/Build-Instruction:-TranspOtter) and [here](https://hackaday.io/project/161891-transpotter-ng). +- **VARIANT_PPM**: RC remote control with PPM Sum signal. +- **VARIANT_PWM**: RC remote control with PWM signal. +- **VARIANT_IBUS**: RC remote control with Flysky iBUS protocol connected to the Left sensor cable. +- **VARIANT_HOVERCAR**: The motors are controlled by two pedals brake and throttle. Reverse is engaged by double tapping on the brake pedal at standstill. See [HOVERCAR video](https://www.youtube.com/watch?v=IgHCcj0NgWQ&t=). +- **VARIANT_HOVERBOARD**: The mainboard reads the two sideboards data. The sideboards need to be flashed with the hacked version. The balancing controller is **not** yet implemented. +- **VARIANT_TRANSPOTTER**: This is for transpotter build, which is a hoverboard based transportation system. For more details on how to build it check [here](https://github.com/NiklasFauth/hoverboard-firmware-hack/wiki/Build-Instruction:-TranspOtter) and [here](https://hackaday.io/project/161891-transpotter-ng). - **VARIANT_SKATEBOARD**: This is for skateboard build, controlled using an RC remote with PWM signal connected to the right sensor cable. Of course the firmware can be further customized for other needs or projects. @@ -209,8 +209,8 @@ The errors reported by the board are in the form of audible beeps: - **3 beeps (low pitch)**: Serial communication timeout - **4 beeps (low pitch)**: General timeout (PPM, PWM, Nunchuck) - **5 beeps (low pitch)**: Mainboard temperature warning -- **1 beep fast (medium pitch)**: Low battery voltage < 35V - **1 beep slow (medium pitch)**: Low battery voltage < 36V +- **1 beep fast (medium pitch)**: Low battery voltage < 35V - **1 beep fast (high pitch)**: Backward spinning motors diff --git a/Src/util.c b/Src/util.c index c9363c7..df2781c 100644 --- a/Src/util.c +++ b/Src/util.c @@ -370,26 +370,29 @@ void UART_DisableRxErrors(UART_HandleTypeDef *huart) /* =========================== General Functions =========================== */ void poweronMelody(void) { - for (int i = 8; i >= 0; i--) { - buzzerFreq = (uint8_t)i; - HAL_Delay(100); - } - buzzerFreq = 0; + buzzerCount = 0; // prevent interraction with beep counter + for (int i = 8; i >= 0; i--) { + buzzerFreq = (uint8_t)i; + HAL_Delay(100); + } + buzzerFreq = 0; } void beepCount(uint8_t cnt, uint8_t freq, uint8_t pattern) { - buzzerCount = cnt; - buzzerFreq = freq; - buzzerPattern = pattern; + buzzerCount = cnt; + buzzerFreq = freq; + buzzerPattern = pattern; } void beepLong(uint8_t freq) { + buzzerCount = 0; // prevent interraction with beep counter buzzerFreq = freq; HAL_Delay(500); buzzerFreq = 0; } void beepShort(uint8_t freq) { + buzzerCount = 0; // prevent interraction with beep counter buzzerFreq = freq; HAL_Delay(100); buzzerFreq = 0; @@ -758,6 +761,7 @@ void cruiseControl(uint8_t button) { void poweroff(void) { enable = 0; consoleLog("-- Motors disabled --\r\n"); + buzzerCount = 0; // prevent interraction with beep counter buzzerPattern = 0; for (int i = 0; i < 8; i++) { buzzerFreq = (uint8_t)i;