Browse Source

add debug only in case of non joystick usb and vice versa

master
Schoenberger, Philipp 6 years ago
parent
commit
5d122bd9ee
  1. 2
      remote/include/Multiprotocol.h
  2. 4
      remote/include/config.h
  3. 24
      remote/src/Multiprotocol.cpp
  4. 9
      remote/src/input.cpp
  5. 2
      remote/src/state_init.cpp
  6. 4
      remote/src/state_joy_usb.cpp

2
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

4
remote/include/config.h

@ -16,7 +16,7 @@
#define _CONFIG_H_
#include <stdint.h>
#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.

24
remote/src/Multiprotocol.cpp

@ -21,9 +21,6 @@
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
*/
#define DEBUG_SERIAL // Only for STM32_BOARD compiled with Upload method "Serial"->usart1, "STM32duino bootloader"->USB serial
#include <cstdint> //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 <USBComposite.h>
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

9
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;
}

2
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 ;

4
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 <USBComposite.h>
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
Loading…
Cancel
Save