GPS - Add satellite strength bargraphs to OLED display.

This commit is contained in:
Dominic Clifton 2014-12-13 21:58:54 +00:00
parent e8dbb77db5
commit d8b5f6c60c
6 changed files with 38 additions and 12 deletions

View File

@ -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

View File

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

View File

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

View File

@ -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();

View File

@ -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

View File

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