diff --git a/src/icons.lbm b/src/icons.lbm index 6f2afd395..f6b18fdce 100644 --- a/src/icons.lbm +++ b/src/icons.lbm @@ -1,2 +1,2 @@ -102,8, -0x1d,0xe3,0xe3,0x1c,0x1c,0xdd,0xdd,0x3e,0xea,0x23,0x6b,0xb6,0xa1,0x9f,0xbf,0xc0,0xf9,0xef,0xff,0xe8,0xa1,0x9f,0xbf,0xc0,0xea,0x23,0x6b,0xb6,0x1c,0xdd,0xdd,0x3e,0x1d,0xe3,0xe3,0x1c,0x38,0xff,0xff,0x38,0x7c,0xbb,0xbb,0x7c,0xfe,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x00,0xff,0xff,0x00,0x50,0xff,0xff,0x50,0x20,0xff,0xff,0x20,0x50,0xff,0xff,0x50,0x38,0xff,0xff,0x38,0x7c,0xbb,0xbb,0x7c,0xfe,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x00,0xff,0xff,0x00,0x40,0xff,0xff,0x40,0x40,0xff,0xff,0x40,0x40,0xff,0xff,0x40,0x38,0xff,0xff,0x38,0x7c,0xbb,0xbb,0x7c,0xfe,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x00,0xff,0xff,0x00,0x50,0xff,0xff,0x50,0x50,0xff,0xff,0x50,0x50,0xff,0xff,0x50,0x38,0xff,0xff,0x38,0x7c,0xbb,0xbb,0x7c,0xfe,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x00,0xff,0xff,0x00,0x54,0xff,0xff,0x54,0x54,0xff,0xff,0x54,0x54,0xff,0xff,0x54,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xc1,0x41,0x41,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xfd,0xfb,0x7b,0x79,0xfb,0xc7,0x47,0x43,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xe3,0xff,0x77,0x63,0xdd,0xff,0x63,0x41,0xdd,0xff,0x41,0x41,0xdd,0xff,0x63,0x41,0xe3,0xff,0x77,0x63,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff,0xfd,0xff,0x43,0x41,0xff,0xff,0x7d,0x7d,0xff,0xff,0x73,0x73,0xff,0xff,0x7d,0x7d,0xdd,0xff,0x63,0x41,0xff,0xff,0x5f,0x5f,0xff,0xff,0x59,0x59,0xdd,0xff,0x63,0x41,0xff,0xff,0x79,0x79,0xff,0xff,0xff,0xff,0xff,0xff,0x79,0x79,0xdd,0xff,0x63,0x41,0xff,0xff,0x59,0x59,0xff,0xff,0x5f,0x5f,0xf5,0xff,0x5b,0x51,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xd7,0xff,0x6d,0x45,0xff,0xff,0xff,0xff,0xff,0xff,0x63,0x63,0xff,0xff,0x63,0x63,0xff,0xff,0x77,0x77,0xff,0xff,0x73,0x73,0xff,0xff,0x65,0x65,0xfd,0xff,0x57,0x55,0xff,0xff,0x77,0x77,0xff,0xff,0x63,0x63,0xeb,0xff,0x77,0x63,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x51,0x51,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff, +102,8, +0xff,0xff,0x00,0x00,0xff,0xff,0x1c,0x1c,0x6b,0xff,0xb6,0x22,0xbf,0xff,0xc0,0x80,0xff,0xff,0xe8,0xe8,0xbf,0xff,0xc0,0x80,0x6b,0xff,0xb6,0x22,0xff,0xff,0x1c,0x1c,0xff,0xff,0x00,0x00,0xff,0xff,0x38,0x38,0xbb,0xff,0x7c,0x38,0x7d,0xff,0xfe,0x7c,0xff,0xff,0xfe,0xfe,0xff,0xff,0x00,0x00,0xff,0xff,0x50,0x50,0xff,0xff,0x20,0x20,0xff,0xff,0x50,0x50,0xff,0xff,0x38,0x38,0xbb,0xff,0x7c,0x38,0x7d,0xff,0xfe,0x7c,0xff,0xff,0xfe,0xfe,0xff,0xff,0x00,0x00,0xff,0xff,0x40,0x40,0xff,0xff,0x40,0x40,0xff,0xff,0x40,0x40,0xff,0xff,0x38,0x38,0xbb,0xff,0x7c,0x38,0x7d,0xff,0xfe,0x7c,0xff,0xff,0xfe,0xfe,0xff,0xff,0x00,0x00,0xff,0xff,0x50,0x50,0xff,0xff,0x50,0x50,0xff,0xff,0x50,0x50,0xff,0xff,0x38,0x38,0xbb,0xff,0x7c,0x38,0x7d,0xff,0xfe,0x7c,0xff,0xff,0xfe,0xfe,0xff,0xff,0x00,0x00,0xff,0xff,0x54,0x54,0xff,0xff,0x54,0x54,0xff,0xff,0x54,0x54,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xc1,0x41,0x41,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xfd,0xfb,0x7b,0x79,0xfb,0xc7,0x47,0x43,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xe3,0xff,0x77,0x63,0xdd,0xff,0x63,0x41,0xdd,0xff,0x41,0x41,0xdd,0xff,0x63,0x41,0xe3,0xff,0x77,0x63,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff,0xfd,0xff,0x43,0x41,0xff,0xff,0x7d,0x7d,0xff,0xff,0x73,0x73,0xff,0xff,0x7d,0x7d,0xdd,0xff,0x63,0x41,0xff,0xff,0x5f,0x5f,0xff,0xff,0x59,0x59,0xdd,0xff,0x63,0x41,0xff,0xff,0x79,0x79,0xff,0xff,0xff,0xff,0xff,0xff,0x79,0x79,0xdd,0xff,0x63,0x41,0xff,0xff,0x59,0x59,0xff,0xff,0x5f,0x5f,0xf5,0xff,0x5b,0x51,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xd7,0xff,0x6d,0x45,0xff,0xff,0xff,0xff,0xff,0xff,0x63,0x63,0xff,0xff,0x63,0x63,0xff,0xff,0x77,0x77,0xff,0xff,0x73,0x73,0xff,0xff,0x65,0x65,0xfd,0xff,0x57,0x55,0xff,0xff,0x77,0x77,0xff,0xff,0x63,0x63,0xeb,0xff,0x77,0x63,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x51,0x51,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff, diff --git a/src/icons.png b/src/icons.png index 1a225a37e..8b08f8a69 100644 Binary files a/src/icons.png and b/src/icons.png differ diff --git a/src/lcd.h b/src/lcd.h index bd837c0a6..aab315602 100644 --- a/src/lcd.h +++ b/src/lcd.h @@ -129,7 +129,7 @@ #if defined(PCBX9D) #define GREY(x) ((x) * 0x1000) -#define GREY_DEFAULT GREY(8) +#define GREY_DEFAULT GREY(11) #define GREY_MASK(x) ((x) & 0xF000) #endif diff --git a/src/main_views.cpp b/src/main_views.cpp index 0c65cb6b1..29cd2d54f 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -247,7 +247,7 @@ void displayTopBar() x -= 12; } - if (1) { + if (usbPlugged()) { LCD_NOTIF_ICON(x, ICON_USB); x -= 12; } diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 98529cf6c..39afd5e84 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -3493,7 +3493,7 @@ void menuModelCustomFunctions(uint8_t event) #if defined(GVARS) else if (CFN_FUNC(sd) >= FUNC_ADJUST_GV1 #if defined(DEBUG) - && CFN_FUNC(sd) <= FUNC_ADJUST_GV5 + && CFN_FUNC(sd) <= FUNC_ADJUST_GVLAST #endif ) { switch (CFN_GVAR_MODE(sd)) { diff --git a/src/x9d/board_x9d.cpp b/src/x9d/board_x9d.cpp index 38a119b65..09958bba9 100644 --- a/src/x9d/board_x9d.cpp +++ b/src/x9d/board_x9d.cpp @@ -43,6 +43,7 @@ extern "C" { uint8_t temperature = 0; // Raw temp reading uint8_t maxTemperature = 0 ; // Raw temp reading volatile uint32_t Tenms ; // TODO to remove everywhere / use a #define +uint8_t usb_connected = 0; #define PIN_MODE_MASK 0x0003 #define PIN_INPUT 0x0000 @@ -106,6 +107,11 @@ void configure_pins( uint32_t pins, uint16_t config ) } #endif +uint8_t usbPlugged(void) +{ + return usb_connected; +} + #if defined(DEBUG) void debugPutc(const char c) { diff --git a/src/x9d/board_x9d.h b/src/x9d/board_x9d.h index 37221facc..647549915 100644 --- a/src/x9d/board_x9d.h +++ b/src/x9d/board_x9d.h @@ -80,6 +80,7 @@ uint8_t getTemperature(); extern uint16_t sessionTimer; +uint8_t usbPlugged(void); #define BOOTLOADER_REQUEST() (0/*usbPlugged()*/) #define SLAVE_MODE() (0/*pwrCheck() == e_power_trainer*/) diff --git a/src/x9d/hal.h b/src/x9d/hal.h index 1c4a98545..3c6a823d5 100644 --- a/src/x9d/hal.h +++ b/src/x9d/hal.h @@ -156,6 +156,8 @@ #define RCC_AHB1Periph_GPIOPWR RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD #define GPIOPWRLED GPIOC #define GPIOPWR GPIOD +#define GPIOTRNDET GPIOA +#define PIN_TRNDET GPIO_Pin_8 // Trainer Port #define PIN_TR_PPM_IN GPIO_Pin_8 //PC.08 @@ -255,6 +257,11 @@ #define I2C_EE_SDA GPIO_Pin_0 //PE0 #define I2C_EE_WP GPIO_Pin_9 //PB9 #else +#define RCC_APBPeriph_I2C_EE RCC_APB1Periph_I2C1 +#define I2C_EE I2C1 +#define GPIO_AF_I2C_EE GPIO_AF_I2C1 +#define GPIO_PinSource_I2C_EE_SCL GPIO_PinSource6 +#define GPIO_PinSource_I2C_EE_SDA GPIO_PinSource7 #define I2C_EE_GPIO GPIOB #define I2C_EE_WP_GPIO GPIOB #define I2C_EE_GPIO_CLK RCC_AHB1Periph_GPIOB diff --git a/src/x9d/pwr_driver.cpp b/src/x9d/pwr_driver.cpp index 09400c4d0..614a99a9e 100644 --- a/src/x9d/pwr_driver.cpp +++ b/src/x9d/pwr_driver.cpp @@ -48,6 +48,12 @@ uint32_t pwrCheck() #else if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET) return e_power_on; +#if !defined(REV3) + else if (GPIO_ReadInputDataBit(GPIOTRNDET, PIN_TRNDET) == Bit_RESET) + return e_power_trainer; +#endif + else if (usbPlugged()) + return e_power_usb; else return e_power_off; #endif diff --git a/src/x9d/usbd_usr.c b/src/x9d/usbd_usr.c index 5df034e7d..9af985ab9 100644 --- a/src/x9d/usbd_usr.c +++ b/src/x9d/usbd_usr.c @@ -28,6 +28,8 @@ /* Includes ------------------------------------------------------------------*/ #include "usbd_usr.h" +extern uint8_t usb_connected; + /* Points to the DEVICE_PROP structure of current device */ /* The purpose of this register is to speed up the execution */ @@ -102,7 +104,7 @@ void USBD_USR_DeviceResumed(void) */ void USBD_USR_DeviceConnected (void) { - + usb_connected = 1; } @@ -114,7 +116,7 @@ void USBD_USR_DeviceConnected (void) */ void USBD_USR_DeviceDisconnected (void) { - + usb_connected = 0; }