Schoenberger, Philipp
6 years ago
No known key found for this signature in database
GPG Key ID: 77E9DF7A0452BF64
5 changed files with
69 additions and
0 deletions
-
remote/include/state.h
-
remote/src/FrSkyD_cc2500.cpp
-
remote/src/state.cpp
-
remote/src/state_joy_usb.cpp
-
remote/src/state_menu.cpp
|
|
@ -93,6 +93,16 @@ public: |
|
|
|
void update(void); |
|
|
|
void leave(void); |
|
|
|
}; |
|
|
|
|
|
|
|
class LCD_state_joy_usb: public State { |
|
|
|
private: |
|
|
|
unsigned long time_enter; |
|
|
|
public: |
|
|
|
LCD_state_joy_usb(void); |
|
|
|
void enter(void); |
|
|
|
void update(void); |
|
|
|
void leave(void); |
|
|
|
}; |
|
|
|
extern State *curr_state; |
|
|
|
extern State *new_state; |
|
|
|
|
|
|
@ -100,5 +110,6 @@ extern State *s_init; |
|
|
|
extern State *s_bind; |
|
|
|
extern State *s_fly; |
|
|
|
extern State *s_joy; |
|
|
|
extern State *s_usb; |
|
|
|
extern State *s_menu; |
|
|
|
#endif /*_STATE_H_*/ |
|
|
@ -245,13 +245,16 @@ uint16_t ReadFrSky_2way() |
|
|
|
|
|
|
|
//debugln("%d len",len);
|
|
|
|
if (len && len<=(0x11+3)) { // 20bytes
|
|
|
|
debug("rx tel\n"); |
|
|
|
CC2500_ReadData(pkt, len); //received telemetry packets
|
|
|
|
#if defined(TELEMETRY)
|
|
|
|
if(pkt[len-1] & 0x80) |
|
|
|
{//with valid crc
|
|
|
|
debug("rx invalid crc\n"); |
|
|
|
packet_count=0; |
|
|
|
frsky_check_telemetry(pkt,len); //check if valid telemetry packets and buffer them.
|
|
|
|
} |
|
|
|
debug("rx end crc\n"); |
|
|
|
#endif
|
|
|
|
} else { |
|
|
|
packet_count++; |
|
|
|
|
|
@ -17,6 +17,7 @@ State *s_init = NULL; |
|
|
|
State *s_bind = NULL; |
|
|
|
State *s_fly = NULL; |
|
|
|
State *s_joy = NULL; |
|
|
|
State *s_usb = NULL; |
|
|
|
State *s_menu = NULL; |
|
|
|
|
|
|
|
|
|
|
@ -32,6 +33,7 @@ void init_state(void) { |
|
|
|
s_bind = new LCD_state_bind(); |
|
|
|
s_fly = new LCD_state_fly(); |
|
|
|
s_joy = new LCD_state_joy_calibration(); |
|
|
|
s_usb = new LCD_state_joy_usb(); |
|
|
|
s_menu = new LCD_state_menu(); |
|
|
|
lcd.backlight(); |
|
|
|
curr_state = NULL; |
|
|
|
|
|
@ -0,0 +1,52 @@ |
|
|
|
#include <LiquidCrystal_I2C.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "Arduino.h"
|
|
|
|
#include "state.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
//#include <USBComposite.h>
|
|
|
|
|
|
|
|
/* USBHID* HID; */ |
|
|
|
/* HIDJoystick* Joystick; */ |
|
|
|
|
|
|
|
LCD_state_joy_usb::LCD_state_joy_usb(void) { |
|
|
|
|
|
|
|
} |
|
|
|
void LCD_state_joy_usb::enter(void) { |
|
|
|
lcd.setCursor(0,0); |
|
|
|
lcd.print("joystick mode "); |
|
|
|
lcd.setCursor(0,1); |
|
|
|
lcd.print(" "); |
|
|
|
delay(500); |
|
|
|
|
|
|
|
/* HID = new USBHID(); */ |
|
|
|
/* Joystick = new HIDJoystick(*HID); */ |
|
|
|
/* HID->begin(HID_JOYSTICK); */ |
|
|
|
} |
|
|
|
void LCD_state_joy_usb::update(void) { |
|
|
|
|
|
|
|
input.update(); |
|
|
|
input.print(); |
|
|
|
while(1) { |
|
|
|
/* Joystick->X(0); */ |
|
|
|
/* delay(500); */ |
|
|
|
/* Joystick->X(1023); */ |
|
|
|
/* delay(500); */ |
|
|
|
|
|
|
|
input.update(); |
|
|
|
|
|
|
|
if (input.is_menu_triggered()) { |
|
|
|
debug("%lu menu button trigger\n", millis()); |
|
|
|
input.print(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
new_state = s_menu; |
|
|
|
} |
|
|
|
void LCD_state_joy_usb::leave(void) { |
|
|
|
lcd.setCursor(0,0); |
|
|
|
lcd.print("finished "); |
|
|
|
lcd.setCursor(0,1); |
|
|
|
lcd.print("usb mode "); |
|
|
|
} |
|
|
@ -26,6 +26,7 @@ void LCD_state_menu::update(void) |
|
|
|
} menus[] = { |
|
|
|
{ "Flight ", s_fly }, |
|
|
|
{ "Bind ", s_bind }, |
|
|
|
{ "Joy usb ", s_usb}, |
|
|
|
{ "Joy calib ", s_joy }, |
|
|
|
{ "HF calib ", NULL }, |
|
|
|
{ " ", NULL }, |
|
|
|