diff --git a/Inc/config.h b/Inc/config.h index 0f738db..dd2c84e 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -8,7 +8,7 @@ #if !defined(PLATFORMIO) //#define VARIANT_ADC // Variant for control via ADC input //#define VARIANT_USART // Variant for Serial control via USART3 input - //#define VARIANT_ NUNCHUK // Variant for Nunchuk controlled vehicle build + //#define VARIANT_NUNCHUK // Variant for Nunchuk controlled vehicle build //#define VARIANT_PPM // Variant for RC-Remote with PPM-Sum Signal //#define VARIANT_IBUS // Variant for RC-Remotes with FLYSKY IBUS //#define VARIANT_HOVERCAR // Variant for HOVERCAR build @@ -197,7 +197,7 @@ #define ADC2_MAX 2200 // max ADC2-value while poti at maximum-position (0 - 4095) #endif -#ifdef VARIANT_ NUNCHUK +#ifdef VARIANT_NUNCHUK // ###### CONTROL VIA NINTENDO NUNCHUK ###### /* left sensor board cable. * keep cable short, use shielded cable, use ferrits, stabalize voltage in nunchuk, @@ -205,7 +205,7 @@ * use original nunchuk. most clones does not work very well. * Recommendation: Nunchuk Breakout Board https://github.com/Jan--Henrik/hoverboard-breakout */ - #define CONTROL_ NUNCHUK // use nunchuk as input. disable FEEDBACK_SERIAL_USART3, DEBUG_SERIAL_USART3! + #define CONTROL_NUNCHUK // use nunchuk as input. disable FEEDBACK_SERIAL_USART3, DEBUG_SERIAL_USART3! #endif // ############################### MOTOR CONTROL ######################### @@ -272,12 +272,12 @@ #define RATE 480 // 30.0f [-] lower value == slower rate [0, 32767] = [0.0, 2047.9375]. Do NOT make rate negative (>32767) // Value of FILTER is in fixdt(0,16,16): VAL_fixedPoint = VAL_floatingPoint * 2^16. In this case 6553 = 0.1 * 2^16 -#ifndef VARIANT_ NUNCHUK +#ifndef VARIANT_NUNCHUK #define FILTER 6553 // 0.1f [-] lower value == softer filter [0, 65535] = [0.0 - 1.0]. #endif // ################################# DEFAULT SETTINGS ############################ -#if !defined(VARIANT_HOVERCAR) && !defined(VARIANT_TRANSPOTTER) && !defined(VARIANT_ NUNCHUK) +#if !defined(VARIANT_HOVERCAR) && !defined(VARIANT_TRANSPOTTER) && !defined(VARIANT_NUNCHUK) // Value of COEFFICIENT is in fixdt(1,16,14) // If VAL_floatingPoint >= 0, VAL_fixedPoint = VAL_floatingPoint * 2^14 // If VAL_floatingPoint < 0, VAL_fixedPoint = 2^16 + floor(VAL_floatingPoint * 2^14). @@ -301,7 +301,7 @@ #ifdef VARIANT_TRANSPOTTER #define CONTROL_GAMETRAK #define SUPPORT_LCD - #define SUPPORT_ NUNCHUK + #define SUPPORT_NUNCHUK #define GAMETRAK_CONNECTION_NORMAL // for normal wiring according to the wiki instructions //#define GAMETRAK_CONNECTION_ALTERNATE // use this define instead if you messed up the gametrak ADC wiring (steering is speed, and length of the wire is steering) @@ -316,8 +316,8 @@ #define STEER_COEFFICIENT 8192 // 0.5f - higher value == stronger. if you do not want any steering, set it to 0.0; 0.0 to 1.0 #endif -// ################################# VARIANT_ NUNCHUK SETTINGS ############################ -#ifdef VARIANT_ NUNCHUK +// ################################# VARIANT_NUNCHUK SETTINGS ############################ +#ifdef VARIANT_NUNCHUK // # ARMCHAIR # #define FILTER 3276 // 0.05f #define SPEED_COEFFICIENT 8192 // 0.5f @@ -333,7 +333,7 @@ // ############################### VALIDATE SETTINGS ############################### -#if !defined(VARIANT_ADC) && !defined(VARIANT_USART) && !defined(VARIANT_HOVERCAR) && !defined(VARIANT_TRANSPOTTER) && !defined(VARIANT_ NUNCHUK) && !defined(VARIANT_PPM)&& !defined(VARIANT_IBUS) +#if !defined(VARIANT_ADC) && !defined(VARIANT_USART) && !defined(VARIANT_HOVERCAR) && !defined(VARIANT_TRANSPOTTER) && !defined(VARIANT_NUNCHUK) && !defined(VARIANT_PPM)&& !defined(VARIANT_IBUS) #error Variant not defined! Please check platformio.ini or Inc/config.h for available variants. #endif @@ -365,16 +365,16 @@ #error CONTROL_PPM and SERIAL_USART2 not allowed. It is on the same cable. #endif -#if (defined(DEBUG_SERIAL_USART3) || defined(CONTROL_SERIAL_USART3)) && defined(CONTROL_ NUNCHUK) - #error CONTROL_ NUNCHUK and SERIAL_USART3 not allowed. It is on the same cable. +#if (defined(DEBUG_SERIAL_USART3) || defined(CONTROL_SERIAL_USART3)) && defined(CONTROL_NUNCHUK) + #error CONTROL_NUNCHUK and SERIAL_USART3 not allowed. It is on the same cable. #endif #if (defined(DEBUG_SERIAL_USART3) || defined(CONTROL_SERIAL_USART3)) && defined(DEBUG_I2C_LCD) #error DEBUG_I2C_LCD and SERIAL_USART3 not allowed. It is on the same cable. #endif -#if defined(CONTROL_PPM) && defined(CONTROL_ADC) && defined(CONTROL_ NUNCHUK) || defined(CONTROL_PPM) && defined(CONTROL_ADC) || defined(CONTROL_ADC) && defined(CONTROL_ NUNCHUK) || defined(CONTROL_PPM) && defined(CONTROL_ NUNCHUK) - #error only 1 input method allowed. use CONTROL_PPM or CONTROL_ADC or CONTROL_ NUNCHUK. +#if defined(CONTROL_PPM) && defined(CONTROL_ADC) && defined(CONTROL_NUNCHUK) || defined(CONTROL_PPM) && defined(CONTROL_ADC) || defined(CONTROL_ADC) && defined(CONTROL_NUNCHUK) || defined(CONTROL_PPM) && defined(CONTROL_NUNCHUK) + #error only 1 input method allowed. use CONTROL_PPM or CONTROL_ADC or CONTROL_NUNCHUK. #endif #if defined(ADC_PROTECT_ENA) && ((ADC1_MIN - ADC_PROTECT_THRESH) <= 0 || (ADC1_MAX + ADC_PROTECT_THRESH) >= 4096) diff --git a/README.md b/README.md index 6c2eaa0..8debc84 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ Most robust way for input is to use the ADC and potis. It works well even on 1m This firmware offers currently these variants (selectable in [platformio.ini](/platformio.ini) and / or [/Inc/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 on USART3 right sensor cable (short wired). The commands can be sent from an Arduino. Check out the [hoverserial.ino](/02_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_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 a RC remote control with PPM Sum signal - **VARIANT_IBUS**: This is when you want to use a 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. diff --git a/Src/main.c b/Src/main.c index 27dda00..de6370e 100644 --- a/Src/main.c +++ b/Src/main.c @@ -146,7 +146,7 @@ typedef struct{ static SerialFeedback Feedback; #endif -#if defined(CONTROL_ NUNCHUK) || defined(SUPPORT_ NUNCHUK) || defined(CONTROL_PPM) || defined(CONTROL_ADC) +#if defined(CONTROL_NUNCHUK) || defined(SUPPORT_NUNCHUK) || defined(CONTROL_PPM) || defined(CONTROL_ADC) static uint8_t button1, button2; #endif @@ -304,7 +304,7 @@ int main(void) { PPM_Init(); #endif - #ifdef CONTROL_ NUNCHUK + #ifdef CONTROL_NUNCHUK I2C_Init(); Nunchuk_Init(); #endif @@ -453,7 +453,7 @@ int main(void) { } #endif - #if defined(CONTROL_ NUNCHUK) || defined(SUPPORT_ NUNCHUK) + #if defined(CONTROL_NUNCHUK) || defined(SUPPORT_NUNCHUK) if (nunchuk_connected != 0) { Nunchuk_Read(); cmd1 = CLAMP((nunchuk_data[0] - 127) * 8, INPUT_MIN, INPUT_MAX); // x - axis. Nunchuk joystick readings range 30 - 230 @@ -714,7 +714,7 @@ int main(void) { poweroff(); } - #ifdef SUPPORT_ NUNCHUK + #ifdef SUPPORT_NUNCHUK if (counter % 500 == 0) { if (nunchuk_connected == 0 && enable == 0) { if (Nunchuk_Ping()) { diff --git a/Src/stm32f1xx_it.c b/Src/stm32f1xx_it.c index 25dd6da..40fb78d 100644 --- a/Src/stm32f1xx_it.c +++ b/Src/stm32f1xx_it.c @@ -178,7 +178,7 @@ void SysTick_Handler(void) { /* USER CODE END SysTick_IRQn 1 */ } -#ifdef CONTROL_ NUNCHUK +#ifdef CONTROL_NUNCHUK extern I2C_HandleTypeDef hi2c2; void I2C1_EV_IRQHandler(void) { diff --git a/platformio.ini b/platformio.ini index ce6f229..a28c724 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ src_dir = Src ; ;default_envs = VARIANT_ADC ; Variant for control via ADC input ;default_envs = VARIANT_USART ; Variant for Serial control via USART3 input -;default_envs = VARIANT_ NUNCHUK ; Variant for Nunchuk controlled vehicle build +;default_envs = VARIANT_NUNCHUK ; Variant for Nunchuk controlled vehicle build ;default_envs = VARIANT_PPM ; Variant for RC-Remotes with PPM-Sum signal ;default_envs = VARIANT_IBUS ; Variant for RC-Remotes with FLYSKY IBUS ;default_envs = VARIANT_HOVERCAR ; Variant for HOVERCAR build @@ -70,7 +70,7 @@ build_flags = ;================================================================ -[env:VARIANT_ NUNCHUK] +[env:VARIANT_NUNCHUK] platform = ststm32 framework = stm32cube board = genericSTM32F103RC @@ -86,7 +86,7 @@ build_flags = -Wl,-lm -g -ggdb ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization # -Wl,-lnosys - -D VARIANT_ NUNCHUK + -D VARIANT_NUNCHUK -D PLATFORMIO ;================================================================