diff --git a/src/main/drivers/display_ug2864hsweg01.c b/src/main/drivers/display_ug2864hsweg01.c index 3016bb530f..055defc095 100644 --- a/src/main/drivers/display_ug2864hsweg01.c +++ b/src/main/drivers/display_ug2864hsweg01.c @@ -153,12 +153,19 @@ static const uint8_t const multiWiiFont[][5] = { // Refer to "Times New Roman" F { 0x17, 0x08, 0x34, 0x2A, 0x7D }, // (119) /4 - 0x00BC Vulgar Fraction One Quarter { 0x17, 0x08, 0x04, 0x6A, 0x59 }, // (120) /2 - 0x00BD Vulgar Fraction One Half { 0x30, 0x48, 0x45, 0x40, 0x20 }, // (121) ? - 0x00BE Inverted Question Mark - { 0x42, 0x00, 0x42, 0x00, 0x42 }, // (122) - 0x00BF Bargraph - 0 - { 0x7E, 0x42, 0x00, 0x42, 0x00 }, // (123) - 0x00BF Bargraph - 1 - { 0x7E, 0x7E, 0x00, 0x42, 0x00 }, // (124) - 0x00BF Bargraph - 2 - { 0x7E, 0x7E, 0x7E, 0x42, 0x00 }, // (125) - 0x00BF Bargraph - 3 - { 0x7E, 0x7E, 0x7E, 0x7E, 0x00 }, // (126) - 0x00BF Bargraph - 4 - { 0x7E, 0x7E, 0x7E, 0x7E, 0x7E }, // (127) - 0x00BF Bargraph - 5 + { 0x42, 0x00, 0x42, 0x00, 0x42 }, // (122) - 0x00BF Horizontal Bargraph - 0 (empty) + { 0x7E, 0x42, 0x00, 0x42, 0x00 }, // (123) - 0x00C0 Horizontal Bargraph - 1 + { 0x7E, 0x7E, 0x00, 0x42, 0x00 }, // (124) - 0x00C1 Horizontal Bargraph - 2 + { 0x7E, 0x7E, 0x7E, 0x42, 0x00 }, // (125) - 0x00C2 Horizontal Bargraph - 3 + { 0x7E, 0x7E, 0x7E, 0x7E, 0x00 }, // (126) - 0x00C3 Horizontal Bargraph - 4 + { 0x7E, 0x7E, 0x7E, 0x7E, 0x7E }, // (127) - 0x00C4 Horizontal Bargraph - 5 (full) + { 0x5A, 0x00, 0x00, 0x00, 0x5A }, // (128) - 0x00C5 Vertical Bargraph - 0 (empty) + { 0x5A, 0x40, 0x40, 0x40, 0x5A }, // (129) - 0x00C6 Vertical Bargraph - 1 + { 0x7A, 0x60, 0x60, 0x60, 0x7A }, // (130) - 0x00C7 Vertical Bargraph - 2 + { 0x7A, 0x70, 0x70, 0x70, 0x7A }, // (131) - 0x00C8 Vertical Bargraph - 3 + { 0x7A, 0x78, 0x78, 0x78, 0x7A }, // (131) - 0x00C8 Vertical Bargraph - 4 + { 0x7A, 0x7C, 0x7C, 0x7C, 0x7A }, // (131) - 0x00C8 Vertical Bargraph - 5 + { 0x7A, 0x7E, 0x7E, 0x7E, 0x7A }, // (131) - 0x00C8 Vertical Bargraph - 6 (full) }; #define OLED_address 0x3C // OLED at address 0x3C in 7bit diff --git a/src/main/drivers/display_ug2864hsweg01.h b/src/main/drivers/display_ug2864hsweg01.h index 38b8a88eda..b6be41c28a 100644 --- a/src/main/drivers/display_ug2864hsweg01.h +++ b/src/main/drivers/display_ug2864hsweg01.h @@ -31,6 +31,9 @@ #define SCREEN_CHARACTER_COLUMN_COUNT (SCREEN_WIDTH / CHARACTER_WIDTH_TOTAL) #define SCREEN_CHARACTER_ROW_COUNT (SCREEN_HEIGHT / CHARACTER_HEIGHT_TOTAL) +#define VERTICAL_BARGRAPH_ZERO_CHARACTER (128 + 32) +#define VERTICAL_BARGRAPH_CHARACTER_COUNT 7 + void ug2864hsweg01InitI2C(void); void i2c_OLED_set_xy(uint8_t col, uint8_t row); diff --git a/src/main/drivers/serial_uart.h b/src/main/drivers/serial_uart.h index 8bfd756a95..817929f288 100644 --- a/src/main/drivers/serial_uart.h +++ b/src/main/drivers/serial_uart.h @@ -17,13 +17,14 @@ #pragma once -// Since serial ports can be used for any function these buffer sizes probably need normalising. +// Since serial ports can be used for any function these buffer sizes should be equal +// The two largest things that need to be sent are: 1, MSP responses, 2, UBLOX SVINFO packet. #define UART1_RX_BUFFER_SIZE 256 -#define UART1_TX_BUFFER_SIZE 192 +#define UART1_TX_BUFFER_SIZE 256 #define UART2_RX_BUFFER_SIZE 256 -#define UART2_TX_BUFFER_SIZE 192 +#define UART2_TX_BUFFER_SIZE 256 #define UART3_RX_BUFFER_SIZE 256 -#define UART3_TX_BUFFER_SIZE 192 +#define UART3_TX_BUFFER_SIZE 256 typedef struct { serialPort_t port; diff --git a/src/main/io/display.c b/src/main/io/display.c index 417c39a714..bfca1934d8 100644 --- a/src/main/io/display.c +++ b/src/main/io/display.c @@ -282,11 +282,22 @@ void showProfilePage(void) i2c_OLED_send_string(lineBuffer); } +#define SATELLITE_COUNT (sizeof(GPS_svinfo_cno) / sizeof(GPS_svinfo_cno[0])) +#define SATELLITE_GRAPH_LEFT_OFFSET ((SCREEN_CHARACTER_COLUMN_COUNT - SATELLITE_COUNT) / 2) #ifdef GPS void showGpsPage() { uint8_t rowIndex = PAGE_TITLE_LINE_COUNT; + i2c_OLED_set_xy(max(0, SATELLITE_GRAPH_LEFT_OFFSET), rowIndex++); + + uint32_t index; + for (index = 0; index < SATELLITE_COUNT && index < SCREEN_CHARACTER_COLUMN_COUNT; index++) { + uint8_t bargraphValue = ((uint16_t) GPS_svinfo_cno[index] * VERTICAL_BARGRAPH_CHARACTER_COUNT) / (GPS_DBHZ_MAX - 1); + bargraphValue = min(bargraphValue, VERTICAL_BARGRAPH_CHARACTER_COUNT - 1); + i2c_OLED_send_char(VERTICAL_BARGRAPH_ZERO_CHARACTER + bargraphValue); + } + char fixChar = STATE(GPS_FIX) ? 'Y' : 'N'; tfp_sprintf(lineBuffer, "Satellites: %d Fix: %c", GPS_numSat, fixChar); padLineBuffer(); diff --git a/src/main/io/gps.c b/src/main/io/gps.c index d3eb8af058..db742a7953 100644 --- a/src/main/io/gps.c +++ b/src/main/io/gps.c @@ -709,7 +709,7 @@ typedef struct { uint8_t svid; // Satellite ID uint8_t flags; // Bitmask uint8_t quality; // Bitfield - uint8_t cno; // Carrier to Noise Ratio (Signal Strength) + uint8_t cno; // Carrier to Noise Ratio (Signal Strength) // dbHz, 0-55. uint8_t elev; // Elevation in integer degrees int16_t azim; // Azimuth in integer degrees int32_t prRes; // Pseudo range residual in centimetres diff --git a/src/main/io/gps.h b/src/main/io/gps.h index 855492ec84..18063ae314 100644 --- a/src/main/io/gps.h +++ b/src/main/io/gps.h @@ -89,7 +89,7 @@ typedef enum { typedef struct gpsData_t { uint8_t state; // GPS thread state. Used for detecting cable disconnects and configuring attached devices uint8_t baudrateIndex; // index into auto-detecting or current baudrate - uint32_t errors; // gps error counter - crc error/lost of data/sync etc.. + uint32_t errors; // gps error counter - crc error/lost of data/sync etc.. uint32_t timeouts; uint32_t lastMessage; // last time valid GPS data was received (millis) uint32_t lastLastMessage; // last-last valid GPS message. Used to calculate delta. @@ -118,6 +118,10 @@ extern uint8_t GPS_svinfo_svid[16]; // Satellite ID extern uint8_t GPS_svinfo_quality[16]; // Bitfield Qualtity extern uint8_t GPS_svinfo_cno[16]; // Carrier to Noise Ratio (Signal Strength) +#define GPS_DBHZ_MIN 0 +#define GPS_DBHZ_MAX 55 + + void gpsThread(void); bool gpsNewFrame(uint8_t c); gpsEnablePassthroughResult_e gpsEnablePassthrough(void);