Fixed RC switch reading from Sideboard data
- updated figures - renamed RC switched to match transmitter convention
This commit is contained in:
parent
ce03d4c816
commit
31c321c83a
|
@ -222,11 +222,11 @@ void PWM_ISR_CH2_Callback(void);
|
|||
#define SENSOR2_SET (0x02)
|
||||
#define SENSOR_MPU (0x04)
|
||||
|
||||
// RC iBUS switch definitions. Flysky FS-i6S has [SW1, SW2, SW3, SW4] = [2, 3, 3, 2] positions switch
|
||||
#define SW1_SET (0x0100) // 0000 0001 0000 0000
|
||||
#define SW2_SET (0x0600) // 0000 0110 0000 0000
|
||||
#define SW3_SET (0x1800) // 0001 1000 0000 0000
|
||||
#define SW4_SET (0x2000) // 0010 0000 0000 0000
|
||||
// RC iBUS switch definitions. Flysky FS-i6S has [SWA, SWB, SWC, SWD] = [2, 3, 3, 2] positions switch
|
||||
#define SWA_SET (0x0100) // 0000 0001 0000 0000
|
||||
#define SWB_SET (0x0600) // 0000 0110 0000 0000
|
||||
#define SWC_SET (0x1800) // 0001 1000 0000 0000
|
||||
#define SWD_SET (0x2000) // 0010 0000 0000 0000
|
||||
|
||||
|
||||
#endif // DEFINES_H
|
||||
|
|
|
@ -110,7 +110,7 @@ This firmware offers currently these variants (selectable in [platformio.ini](/p
|
|||
- **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_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 wiki](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/wiki/Variant-HOVERCAR).
|
||||
- **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.
|
||||
|
@ -257,7 +257,7 @@ For a more detailed troubleshooting connect an [FTDI Serial adapter](https://s.c
|
|||
## Projects and Links
|
||||
|
||||
- **Original firmware:** [https://github.com/NiklasFauth/hoverboard-firmware-hack](https://github.com/NiklasFauth/hoverboard-firmware-hack)
|
||||
- **[Candas](https://github.com/Candas1/) Hoverboard Web Serial Control:** [https://candas1.github.io/Hoverboard-Web-Serial-Control/](https://candas1.github.io/Hoverboard-Web-Serial-Control/)
|
||||
- **[Candas](https://github.com/Candas1/) Hoverboard Web Serial Control:** [https://github.com/Candas1/Hoverboard-Web-Serial-Control](https://github.com/Candas1/Hoverboard-Web-Serial-Control)
|
||||
- **[RoboDurden's](https://github.com/RoboDurden) online compiler:** [https://pionierland.de/hoverhack/](https://pionierland.de/hoverhack/)
|
||||
- **Hoverboard hack for AT32F403RCT6 mainboards:** [https://github.com/cloidnerux/hoverboard-firmware-hack](https://github.com/cloidnerux/hoverboard-firmware-hack)
|
||||
- **Hoverboard hack for split mainboards:** [https://github.com/flo199213/Hoverboard-Firmware-Hack-Gen2](https://github.com/flo199213/Hoverboard-Firmware-Hack-Gen2)
|
||||
|
|
54
Src/util.c
54
Src/util.c
|
@ -931,7 +931,7 @@ void handleTimeout(void) {
|
|||
#endif
|
||||
} else { // No Timeout
|
||||
#if defined(DUAL_INPUTS) && defined(SIDEBOARD_SERIAL_USART2)
|
||||
if (Sideboard_L.sensors & SW1_SET) { // If SW1 is set, switch to Sideboard control
|
||||
if (Sideboard_L.sensors & SWA_SET) { // If SWA is set, switch to Sideboard control
|
||||
inIdx = SIDEBOARD_SERIAL_USART2;
|
||||
} else {
|
||||
inIdx = !SIDEBOARD_SERIAL_USART2;
|
||||
|
@ -954,7 +954,7 @@ void handleTimeout(void) {
|
|||
#endif
|
||||
} else { // No Timeout
|
||||
#if defined(DUAL_INPUTS) && defined(SIDEBOARD_SERIAL_USART3)
|
||||
if (Sideboard_R.sensors & SW1_SET) { // If SW1 is set, switch to Sideboard control
|
||||
if (Sideboard_R.sensors & SWA_SET) { // If SWA is set, switch to Sideboard control
|
||||
inIdx = SIDEBOARD_SERIAL_USART3;
|
||||
} else {
|
||||
inIdx = !SIDEBOARD_SERIAL_USART3;
|
||||
|
@ -1360,32 +1360,27 @@ void sideboardSensors(uint8_t sensors) {
|
|||
static uint8_t sensor1_prev, sensor2_prev;
|
||||
static uint8_t sensor1_index; // holds the press index number for sensor1, when used as a button
|
||||
uint8_t sensor1_trig, sensor2_trig;
|
||||
sensor1_trig = (sensors & SENSOR1_SET) && !sensor1_prev; // rising edge detection
|
||||
sensor2_trig = (sensors & SENSOR2_SET) && !sensor2_prev; // rising edge detection
|
||||
sensor1_prev = sensors & SENSOR1_SET;
|
||||
sensor2_prev = sensors & SENSOR2_SET;
|
||||
#if defined(SIDEBOARD_SERIAL_USART2)
|
||||
uint8_t sideboardIdx = SIDEBOARD_SERIAL_USART2;
|
||||
uint16_t sideboardSns = Sideboard_L.sensors;
|
||||
#else
|
||||
uint8_t sideboardIdx = SIDEBOARD_SERIAL_USART3;
|
||||
uint16_t sideboardSns = Sideboard_R.sensors;
|
||||
#endif
|
||||
|
||||
// Override in case the Sideboard control is Active
|
||||
#if defined(DUAL_INPUTS) && defined(SIDEBOARD_SERIAL_USART2)
|
||||
if (inIdx == SIDEBOARD_SERIAL_USART2) {
|
||||
sensor1_index = 3 + ((Sideboard_L.sensors & SW2_SET) >> 9); // SW2 on RC transmitter is used to change Control Type
|
||||
if (sensor1_index == 3) { // FOC control Type
|
||||
sensor1_index = (Sideboard_L.sensors & SW3_SET) >> 11; // SW3 on RC transmitter is used to change Control Mode
|
||||
if (inIdx == sideboardIdx) { // Use Sideboard data
|
||||
sensor1_index = 2 + ((sideboardSns & SWB_SET) >> 9); // SWB on RC transmitter is used to change Control Type
|
||||
if (sensor1_index == 2) { // FOC control Type
|
||||
sensor1_index = (sideboardSns & SWC_SET) >> 11; // SWC on RC transmitter is used to change Control Mode
|
||||
}
|
||||
sensor1_trig = sensor1_index != sensor1_prev; // rising or falling edge change detection
|
||||
sensor1_prev = sensor1_index;
|
||||
} else { // Use Optical switches
|
||||
sensor1_trig = (sensors & SENSOR1_SET) && !sensor1_prev; // rising edge detection
|
||||
sensor2_trig = (sensors & SENSOR2_SET) && !sensor2_prev; // rising edge detection
|
||||
sensor1_prev = sensors & SENSOR1_SET;
|
||||
sensor2_prev = sensors & SENSOR2_SET;
|
||||
}
|
||||
#endif
|
||||
#if defined(DUAL_INPUTS) && defined(SIDEBOARD_SERIAL_USART3)
|
||||
if (inIdx == SIDEBOARD_SERIAL_USART3) {
|
||||
sensor1_index = 3 + ((Sideboard_R.sensors & SW2_SET) >> 9); // SW2 on RC transmitter is used to change Control Type
|
||||
if (sensor1_index == 3) { // FOC control Type
|
||||
sensor1_index = (Sideboard_R.sensors & SW3_SET) >> 11; // SW3 on RC transmitter is used to change Control Mode
|
||||
}
|
||||
sensor1_trig = sensor1_index != sensor1_prev; // rising or falling edge change detection
|
||||
sensor1_prev = sensor1_index;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Control MODE and Control Type Handling
|
||||
if (sensor1_trig) {
|
||||
|
@ -1422,20 +1417,11 @@ void sideboardSensors(uint8_t sensors) {
|
|||
static uint8_t sensor2_index = 1; // holds the press index number for sensor2, when used as a button
|
||||
|
||||
// Override in case the Sideboard control is Active
|
||||
#if defined(DUAL_INPUTS) && defined(SIDEBOARD_SERIAL_USART2)
|
||||
if (inIdx == SIDEBOARD_SERIAL_USART2) {
|
||||
sensor2_index = (Sideboard_L.sensors & SW4_SET) >> 13; // SW4 on RC transmitter is used to Activate/Deactivate Field Weakening
|
||||
if (inIdx == sideboardIdx) { // Use Sideboard data
|
||||
sensor2_index = (sideboardSns & SWD_SET) >> 13; // SWD on RC transmitter is used to Activate/Deactivate Field Weakening
|
||||
sensor2_trig = sensor2_index != sensor2_prev; // rising or falling edge change detection
|
||||
sensor2_prev = sensor2_index;
|
||||
}
|
||||
#endif
|
||||
#if defined(DUAL_INPUTS) && defined(SIDEBOARD_SERIAL_USART3)
|
||||
if (inIdx == SIDEBOARD_SERIAL_USART3) {
|
||||
sensor2_index = (Sideboard_R.sensors & SW4_SET) >> 13; // SW4 on RC transmitter is used to Activate/Deactivate Field Weakening
|
||||
sensor2_trig = sensor2_index != sensor2_prev; // rising or falling edge change detection
|
||||
sensor2_prev = sensor2_index;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sensor2_trig) {
|
||||
switch (sensor2_index) {
|
||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 236 KiB After Width: | Height: | Size: 234 KiB |
Binary file not shown.
Before Width: | Height: | Size: 566 KiB After Width: | Height: | Size: 574 KiB |
Loading…
Reference in New Issue