Browse Source

add usb state class

master
Schoenberger, Philipp 6 years ago
parent
commit
75e5543ecf
No known key found for this signature in database GPG Key ID: 77E9DF7A0452BF64
  1. 11
      remote/include/state.h
  2. 3
      remote/src/FrSkyD_cc2500.cpp
  3. 2
      remote/src/state.cpp
  4. 52
      remote/src/state_joy_usb.cpp
  5. 1
      remote/src/state_menu.cpp

11
remote/include/state.h

@ -93,6 +93,16 @@ public:
void update(void); void update(void);
void leave(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 *curr_state;
extern State *new_state; extern State *new_state;
@ -100,5 +110,6 @@ extern State *s_init;
extern State *s_bind; extern State *s_bind;
extern State *s_fly; extern State *s_fly;
extern State *s_joy; extern State *s_joy;
extern State *s_usb;
extern State *s_menu; extern State *s_menu;
#endif /*_STATE_H_*/ #endif /*_STATE_H_*/

3
remote/src/FrSkyD_cc2500.cpp

@ -245,13 +245,16 @@ uint16_t ReadFrSky_2way()
//debugln("%d len",len); //debugln("%d len",len);
if (len && len<=(0x11+3)) { // 20bytes if (len && len<=(0x11+3)) { // 20bytes
debug("rx tel\n");
CC2500_ReadData(pkt, len); //received telemetry packets CC2500_ReadData(pkt, len); //received telemetry packets
#if defined(TELEMETRY) #if defined(TELEMETRY)
if(pkt[len-1] & 0x80) if(pkt[len-1] & 0x80)
{//with valid crc {//with valid crc
debug("rx invalid crc\n");
packet_count=0; packet_count=0;
frsky_check_telemetry(pkt,len); //check if valid telemetry packets and buffer them. frsky_check_telemetry(pkt,len); //check if valid telemetry packets and buffer them.
} }
debug("rx end crc\n");
#endif #endif
} else { } else {
packet_count++; packet_count++;

2
remote/src/state.cpp

@ -17,6 +17,7 @@ State *s_init = NULL;
State *s_bind = NULL; State *s_bind = NULL;
State *s_fly = NULL; State *s_fly = NULL;
State *s_joy = NULL; State *s_joy = NULL;
State *s_usb = NULL;
State *s_menu = NULL; State *s_menu = NULL;
@ -32,6 +33,7 @@ void init_state(void) {
s_bind = new LCD_state_bind(); s_bind = new LCD_state_bind();
s_fly = new LCD_state_fly(); s_fly = new LCD_state_fly();
s_joy = new LCD_state_joy_calibration(); s_joy = new LCD_state_joy_calibration();
s_usb = new LCD_state_joy_usb();
s_menu = new LCD_state_menu(); s_menu = new LCD_state_menu();
lcd.backlight(); lcd.backlight();
curr_state = NULL; curr_state = NULL;

52
remote/src/state_joy_usb.cpp

@ -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 ");
}

1
remote/src/state_menu.cpp

@ -26,6 +26,7 @@ void LCD_state_menu::update(void)
} menus[] = { } menus[] = {
{ "Flight ", s_fly }, { "Flight ", s_fly },
{ "Bind ", s_bind }, { "Bind ", s_bind },
{ "Joy usb ", s_usb},
{ "Joy calib ", s_joy }, { "Joy calib ", s_joy },
{ "HF calib ", NULL }, { "HF calib ", NULL },
{ " ", NULL }, { " ", NULL },

Loading…
Cancel
Save