From 5d122bd9ee116338469b54fa4761e33ccefe3d46 Mon Sep 17 00:00:00 2001 From: "Schoenberger, Philipp" Date: Thu, 11 Apr 2019 03:34:53 +0200 Subject: [PATCH] add debug only in case of non joystick usb and vice versa --- remote/include/Multiprotocol.h | 2 -- remote/include/config.h | 4 ++-- remote/src/Multiprotocol.cpp | 24 +++++++----------------- remote/src/input.cpp | 9 ++++++--- remote/src/state_init.cpp | 2 +- remote/src/state_joy_usb.cpp | 4 ++++ 6 files changed, 20 insertions(+), 25 deletions(-) diff --git a/remote/include/Multiprotocol.h b/remote/include/Multiprotocol.h index aef0d0e..5f8758d 100644 --- a/remote/include/Multiprotocol.h +++ b/remote/include/Multiprotocol.h @@ -28,11 +28,9 @@ extern uint8_t protocol_flags; extern uint8_t protocol_flags2; extern uint8_t crc8; extern uint8_t packet_count; -extern uint8_t binding_idx; extern uint8_t packet[40]; extern uint8_t option; extern uint16_t state; -extern uint8_t phase; extern uint8_t len; // Telemetry diff --git a/remote/include/config.h b/remote/include/config.h index 2843941..dc779c3 100644 --- a/remote/include/config.h +++ b/remote/include/config.h @@ -16,7 +16,7 @@ #define _CONFIG_H_ #include -#define REMOE_OWNER "Sina" +#define REMOE_OWNER "phschoen" #define DEFAULT_BIND_TIME 13 /*seconds*/ @@ -123,7 +123,7 @@ //In this section you can configure the telemetry. //If you do not plan using the telemetry comment this global setting using "//" and skip to the next section. -//#define TELEMETRY +#define TELEMETRY //Comment to invert the polarity of the output telemetry serial signal. //This function takes quite some flash space and processor power on an atmega. diff --git a/remote/src/Multiprotocol.cpp b/remote/src/Multiprotocol.cpp index c7df700..28e0834 100644 --- a/remote/src/Multiprotocol.cpp +++ b/remote/src/Multiprotocol.cpp @@ -21,9 +21,6 @@ along with Multiprotocol. If not, see . */ - -#define DEBUG_SERIAL // Only for STM32_BOARD compiled with Upload method "Serial"->usart1, "STM32duino bootloader"->USB serial - #include //adds types like unit_16_t #include "config.h" @@ -42,47 +39,40 @@ #include "FrSkyD_cc2500.h" //Global constants/variables -uint32_t blink=0,last_signal=0; uint8_t protocol_flags=0,protocol_flags2=0; // uint8_t channel; uint8_t packet[40]; // Protocol variables -uint8_t cyrfmfg_id[6];//for dsm2 and devo uint8_t rx_id[4]; -uint8_t phase; -uint16_t bind_counter; -uint8_t bind_phase; -uint8_t binding_idx; uint16_t packet_period; uint8_t packet_count; -uint8_t packet_sent; -uint8_t packet_length; uint8_t *hopping_frequency_ptr; -uint8_t rf_ch_num; uint16_t crc; uint8_t crc8; uint16_t failsafe_count; uint8_t len; - +#ifndef ENABLE_DBEUG #include USBHID HID; HIDJoystick Joystick(HID); +#endif // Telemetry void setup() { // Setup diagnostic uart before anything else #ifdef ENABLE_DBEUG - Serial.begin(115200,SERIAL_8N1); - delay(1000); - while (!Serial); // Wait for ever for the serial port to connect... + Serial.begin(9600,SERIAL_8N1); delay(1000); debugln("Multiprotocol startup"); + delay(1000); debugln("time %s ", __TIME__); + delay(1000); + #else + HID.begin(HID_JOYSTICK); #endif - HID.begin(HID_JOYSTICK); // all inputs // outputs diff --git a/remote/src/input.cpp b/remote/src/input.cpp index d1c70ba..4cd9746 100644 --- a/remote/src/input.cpp +++ b/remote/src/input.cpp @@ -239,13 +239,16 @@ void Input::update(void) { this->curr->menu = digitalRead(Menu_pin) == HIGH; -#define CHANNEL_DEAD 60 + for (uint8_t ch = 0; ch < CH_COUNT; ++ch) { + this->channel_data[ch] = map(this->curr->ch_data[ch], this->ch_config[ch].min, this->ch_config[ch].max, CHANNEL_MIN_100, CHANNEL_MAX_100); + } + + #define CHANNEL_DEAD 70 uint8_t mid = (CHANNEL_MAX_100 - CHANNEL_MIN_100)/2 + CHANNEL_MIN_100; uint8_t min_dead = mid - CHANNEL_DEAD; uint8_t max_dead = mid + CHANNEL_DEAD; for (uint8_t ch = 0; ch < CH_COUNT; ++ch) { - this->channel_data[ch] = map(this->curr->ch_data[ch], this->ch_config[ch].min, this->ch_config[ch].max, CHANNEL_MIN_100, CHANNEL_MAX_100); - if (min_dead <= this->channel_data[ch] || + if (min_dead <= this->channel_data[ch] && this->channel_data[ch] <= max_dead) { this->channel_data[ch] = mid; } diff --git a/remote/src/state_init.cpp b/remote/src/state_init.cpp index 7a6a380..a92350c 100644 --- a/remote/src/state_init.cpp +++ b/remote/src/state_init.cpp @@ -9,7 +9,7 @@ #include "config.h" #include "pins.h" #include "tx_def.h" -void centerText(char *text, int fieldWidth) +void centerText(const char *text, int fieldWidth) { int padlen = 0; padlen = (fieldWidth - strlen(text)) / 2 ; diff --git a/remote/src/state_joy_usb.cpp b/remote/src/state_joy_usb.cpp index 2a10187..21cbb8e 100644 --- a/remote/src/state_joy_usb.cpp +++ b/remote/src/state_joy_usb.cpp @@ -5,7 +5,10 @@ #include "input.h" #include "debug.h" +#ifndef ENABLE_DBEUG int16_t map16b( int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max); + + #include extern HIDJoystick Joystick; LCD_state_joy_usb::LCD_state_joy_usb(void) { @@ -62,3 +65,4 @@ void LCD_state_joy_usb::leave(void) { lcd.setCursor(0,1); lcd.print("usb mode "); } +#endif