From baa8c58813de2f609f25f7883be872dd9c740cac Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 20 Sep 2011 18:56:53 +0000 Subject: [PATCH] Commit before revert to a previous version. The async eeprom write doesn't work any more. --- src/Makefile | 2 +- src/drivers.cpp | 3 +- src/frsky.cpp | 240 ++++++++++++++++++++++----------------- src/frsky.h | 45 +++++++- src/gruvin9x.cpp | 44 ++++--- src/gtests.cpp | 42 +++++++ src/lcd.h | 2 +- src/main_views.cpp | 117 ++++++++++++++++++- src/statistics_views.cpp | 2 +- 9 files changed, 369 insertions(+), 128 deletions(-) diff --git a/src/Makefile b/src/Makefile index b568ff966..2d8b61d9b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -60,7 +60,7 @@ USART1 = FREED # Values = STD, MOD1 PPMIN = STD -BATT voltage algorithm. Values = BANDGAP, UNSTABLE_BANDGAP +# BATT voltage algorithm. Values = BANDGAP, UNSTABLE_BANDGAP BATT = BANDGAP # Decimals display in the main view (PPM calibration, diff --git a/src/drivers.cpp b/src/drivers.cpp index 1638f40eb..baf255c5c 100644 --- a/src/drivers.cpp +++ b/src/drivers.cpp @@ -320,7 +320,7 @@ void per10ms() g_tmr10ms++; g_blinkTmr10ms++; -#if defined (PCBV3) && !defined (PCBV4) +#if defined (PCBV3) /* Update gloabal Date/Time every 100 per10ms cycles */ if (++g_ms100 == 100) { @@ -470,7 +470,6 @@ void per10ms() #if defined (FRSKY) - // TODO why sending only every 50ms // Attempt to transmit any waiting Fr-Sky alarm set packets every 50ms (subject to packet buffer availability) static uint8_t FrskyDelay = 5; if (FrskyAlarmSendState && (--FrskyDelay == 0)) diff --git a/src/frsky.cpp b/src/frsky.cpp index fec5f7e72..332d350da 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -36,12 +36,14 @@ #define BYTESTUFF 0x7d #define STUFF_MASK 0x20 -uint8_t frskyRxBuffer[19]; // Receive buffer. 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1) -uint8_t frskyTxBuffer[19]; // Ditto for transmit buffer +#define FRSKY_RX_PACKET_SIZE 19 +#define FRSKY_TX_PACKET_SIZE 12 + +uint8_t frskyRxBuffer[FRSKY_RX_PACKET_SIZE]; // Receive buffer. 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1) +uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE]; // Ditto for transmit buffer uint8_t frskyTxBufferCount = 0; uint8_t FrskyRxBufferReady = 0; uint8_t frskyStreaming = 0; -uint8_t frskyTxISRIndex = 0; FrskyData frskyTelemetry[2]; FrskyData frskyRSSI[2]; @@ -51,25 +53,99 @@ struct FrskyAlarm { uint8_t greater; // 1 = 'if greater than'. 0 = 'if less than' uint8_t value; // The threshold above or below which the alarm will sound }; + struct FrskyAlarm frskyAlarms[4]; -void frskyPushValue(uint8_t & i, uint8_t value); +#ifdef FRSKY_HUB +struct FrskyHubData frskyHubData; +#endif + +void frskyPushValue(uint8_t *&ptr, uint8_t value) +{ + // byte stuff the only byte than might need it + if (value == START_STOP) { + *ptr++ = 0x5e; + *ptr++ = BYTESTUFF; + } + else if (value == BYTESTUFF) { + *ptr++ = 0x5d; + *ptr++ = BYTESTUFF; + } + else { + *ptr++ = value; + } +} + +#ifdef FRSKY_HUB +int8_t parseTelemHubIndex(uint8_t index) +{ + if (index > 0x26) + index = 0; // invalid index + if (index > 0x21) + index -= 5; + if (index > 0x0f) + index -= 6; + if (index > 0x08) + index -= 2; + return 2*(index-1); +} + +typedef enum { + TS_IDLE = 0, // waiting for 0x5e frame marker + TS_DATA_ID, // waiting for dataID + TS_DATA_LOW, // waiting for data low byte + TS_DATA_HIGH, // waiting for data high byte + TS_XOR = 0x80 // decode stuffed byte +} TS_STATE; + +void parseTelemHubByte(uint8_t byte) +{ + static int8_t structPos; + static TS_STATE state = TS_IDLE; + + if (byte == 0x5e) { + state = TS_DATA_ID; + return; + } + if (state == TS_IDLE) { + return; + } + if (state & TS_XOR) { + byte = byte ^ 0x60; + state = (TS_STATE)(state - TS_XOR); + } + if (byte == 0x5d) { + state = (TS_STATE)(state | TS_XOR); + return; + } + if (state == TS_DATA_ID) { + structPos = parseTelemHubIndex(byte); + state = TS_DATA_LOW; + if (structPos < 0) + state = TS_IDLE; + return; + } + if (state == TS_DATA_LOW) { + ((uint8_t*)&frskyHubData)[structPos] = byte; + state = TS_DATA_HIGH; + return; + } + ((uint8_t*)&frskyHubData)[structPos+1] = byte; + state = TS_IDLE; +} +#endif /* - Called from somewhere in the main loop or a low prioirty interrupt - routine perhaps. This funtcion processes Fr-Sky telemetry data packets - assembled byt he USART0_RX_vect) ISR function (below) and stores + Called from somewhere in the main loop or a low priority interrupt + routine perhaps. This function processes FrSky telemetry data packets + assembled by he USART0_RX_vect) ISR function (below) and stores extracted data in global variables for use by other parts of the program. Packets can be any of the following: - - A1/A2/RSSI telemtry data + - A1/A2/RSSI telemetry data - Alarm level/mode/threshold settings for Ch1A, Ch1B, Ch2A, Ch2B - User Data packets - - User Data packets are not yet implementedi (they are simply ignored), - but will likely one day contain the likes of GPS long/lat/alt/speed, - AoA, airspeed, etc. */ void processFrskyPacket(uint8_t *packet) @@ -96,7 +172,14 @@ void processFrskyPacket(uint8_t *packet) frskyRSSI[1].set(packet[4] / 2); break; - case USRPKT: // User Data packet -- not yet implemented + case USRPKT: // User Data packet +#ifdef FRSKY_HUB + uint8_t numBytes = 3 + (packet[1] & 0x07); // sanitize in case of data corruption leading to buffer overflow + for (uint8_t i=3; i 0) { - UDR0 = frskyTxBuffer[frskyTxISRIndex++]; - frskyTxBufferCount--; + UDR0 = frskyTxBuffer[--frskyTxBufferCount]; } else { UCSR0B &= ~(1 << UDRIE0); // disable UDRE0 interrupt @@ -243,85 +327,47 @@ ISR(USART0_UDRE_vect) void frskyTransmitBuffer() { - frskyTxISRIndex = 0; UCSR0B |= (1 << UDRIE0); // enable UDRE0 interrupt } - uint8_t FrskyAlarmSendState = 0 ; -uint8_t FrskyDelay = 0 ; - - void FRSKY10mspoll(void) { - if (FrskyDelay) - { - FrskyDelay -= 1 ; - return ; - } - if (frskyTxBufferCount) - { return; // we only have one buffer. If it's in use, then we can't send yet. - } + + uint8_t *ptr = &frskyTxBuffer[0]; + + *ptr++ = START_STOP; // End of packet + *ptr++ = 0x00; + *ptr++ = 0x00; + *ptr++ = 0x00; + *ptr++ = 0x00; + *ptr++ = 0x00; // Now send a packet - { - FrskyAlarmSendState -= 1 ; + FrskyAlarmSendState -= 1 ; + uint8_t alarm = 1 - (FrskyAlarmSendState % 2); + if (FrskyAlarmSendState < SEND_MODEL_ALARMS) { uint8_t channel = 1 - (FrskyAlarmSendState / 2); - uint8_t alarm = 1 - (FrskyAlarmSendState % 2); - - uint8_t i = 0; - frskyTxBuffer[i++] = START_STOP; // Start of packet - frskyTxBuffer[i++] = (A22PKT + FrskyAlarmSendState); // fc - fb - fa - f9 - frskyPushValue(i, g_model.frsky.channels[channel].alarms_value[alarm]); - { - uint8_t *ptr ; - ptr = &frskyTxBuffer[i] ; - *ptr++ = ALARM_GREATER(channel, alarm); - *ptr++ = ALARM_LEVEL(channel, alarm); - *ptr++ = 0x00 ; - *ptr++ = 0x00 ; - *ptr++ = 0x00 ; - *ptr++ = 0x00 ; - *ptr++ = 0x00 ; - *ptr++ = START_STOP; // End of packet - i += 8 ; - } - FrskyDelay = 5 ; // 50mS - frskyTxBufferCount = i; - frskyTransmitBuffer(); + *ptr++ = ALARM_LEVEL(channel, alarm); + *ptr++ = ALARM_GREATER(channel, alarm); + frskyPushValue(ptr, g_model.frsky.channels[channel].alarms_value[alarm]); + *ptr++ = (A22PKT + FrskyAlarmSendState); // fc - fb - fa - f9 } -} - -// Send packet requesting all alarm settings be sent back to us -void FRSKY_setRSSIAlarms(void) -{ - if (frskyTxBufferCount) return; // we only have one buffer. If it's in use, then we can't send. Sorry. - - uint8_t i = 0; - - for (int alarm=0; alarm<2; alarm++) { - frskyTxBuffer[i++] = START_STOP; // Start of packet - frskyTxBuffer[i++] = (RSSI1PKT-alarm); // f7 - f6 - frskyPushValue(i, g_eeGeneral.frskyRssiAlarms[alarm].value+50-(10*i)); - { - uint8_t *ptr ; - ptr = &frskyTxBuffer[i] ; - *ptr++ = 0x00 ; - *ptr++ = g_eeGeneral.frskyRssiAlarms[alarm].level; - *ptr++ = 0x00 ; - *ptr++ = 0x00 ; - *ptr++ = 0x00 ; - *ptr++ = 0x00 ; - *ptr++ = 0x00 ; - *ptr++ = START_STOP; // End of packet - i += 8 ; - } + else { + if (FrskyAlarmSendState == SEND_MODEL_ALARMS) + FrskyAlarmSendState = 0; + *ptr++ = g_eeGeneral.frskyRssiAlarms[alarm].level; + *ptr++ = 0x00 ; + frskyPushValue(ptr, g_eeGeneral.frskyRssiAlarms[alarm].value+50-(10*alarm)); + *ptr++ = (RSSI1PKT-alarm); // f7 - f6 } - frskyTxBufferCount = i; - frskyTransmitBuffer(); + *ptr++ = START_STOP; // Start of packet + + frskyTxBufferCount = ptr - &frskyTxBuffer[0]; + frskyTransmitBuffer(); } bool FRSKY_alarmRaised(uint8_t idx) @@ -344,7 +390,7 @@ bool FRSKY_alarmRaised(uint8_t idx) inline void FRSKY_EnableTXD(void) { frskyTxBufferCount = 0; - UCSR0B |= (1 << TXEN0) | (1 << UDRIE0); // enable TX and TX interrupt + UCSR0B |= (1 << TXEN0); // enable TX } inline void FRSKY_EnableRXD(void) @@ -427,22 +473,6 @@ void frskyAlarmsRefresh() } #endif -void frskyPushValue(uint8_t & i, uint8_t value) -{ - // byte stuff the only byte than might need it - if (value == START_STOP) { - frskyTxBuffer[i++] = BYTESTUFF; - frskyTxBuffer[i++] = 0x5e; - } - else if (value == BYTESTUFF) { - frskyTxBuffer[i++] = BYTESTUFF; - frskyTxBuffer[i++] = 0x5d; - } - else { - frskyTxBuffer[i++] = value; - } -} - void FrskyData::set(uint8_t value) { this->value = value; diff --git a/src/frsky.h b/src/frsky.h index 9a400a068..35ea32546 100644 --- a/src/frsky.h +++ b/src/frsky.h @@ -40,9 +40,47 @@ struct FrskyData { void set(uint8_t value); }; +#ifdef FRSKY_HUB +struct FrskyHubData { + int16_t gpsAltitude_bp; // before punct + int16_t temperature1; // -20 .. 250 deg. celcius + uint16_t rpm; // 0..60,000 revs. per minute + uint16_t fuelLevel; // 0, 25, 50, 75, 100 percent + int16_t temperature2; // -20 .. 250 deg. celcius + uint16_t volts; // 1/500V increments (0..4.2V) + int16_t gpsAltitude_ap; // after punct + uint16_t baroAltitude; // 0..9,999 meters + uint16_t gpsSpeed_bp; // before punct + uint16_t gpsLongitude_bp; // before punct + uint16_t gpsLatitude_bp; // before punct + uint16_t gpsCourse_bp; // before punct (0..359.99 deg. -- seemingly 2-decimal precision) + uint8_t day; + uint8_t month; + uint16_t year; + uint8_t hour; + uint8_t min; + uint16_t sec; + uint16_t gpsSpeed_ap; + uint16_t gpsLongitude_ap; + uint16_t gpsLatitude_ap; + uint16_t gpsCourse_ap; + uint16_t gpsLongitudeEW; // East/West + uint16_t gpsLatitudeNS; // North/South + int16_t accelX; // 1/256th gram (-8g ~ +8g) + int16_t accelY; // 1/256th gram (-8g ~ +8g) + int16_t accelZ; // 1/256th gram (-8g ~ +8g) +}; + +extern struct FrskyHubData frskyHubData; +#endif + // Global Fr-Sky telemetry data variables extern uint8_t frskyStreaming; // >0 (true) == data is streaming in. 0 = nodata detected for some time + +#define SEND_MODEL_ALARMS 4 +#define SEND_RSSI_ALARMS (SEND_MODEL_ALARMS + 2) extern uint8_t FrskyAlarmSendState; + extern FrskyData frskyTelemetry[2]; extern FrskyData frskyRSSI[2]; @@ -51,7 +89,12 @@ void FRSKY10mspoll(void); inline void FRSKY_setModelAlarms(void) { - FrskyAlarmSendState = 4 ; + FrskyAlarmSendState = SEND_MODEL_ALARMS; +} + +inline void FRSKY_setRSSIAlarms(void) +{ + FrskyAlarmSendState = SEND_RSSI_ALARMS; } bool FRSKY_alarmRaised(uint8_t idx); diff --git a/src/gruvin9x.cpp b/src/gruvin9x.cpp index 936853c0a..95c1defdb 100644 --- a/src/gruvin9x.cpp +++ b/src/gruvin9x.cpp @@ -2009,20 +2009,6 @@ uint16_t DEBUG1 = 0; uint16_t DEBUG2 = 0; #endif -extern unsigned char __bss_end ; - -unsigned int stack_free() -{ - unsigned char *p ; - - p = &__bss_end + 1 ; - while ( *p == 0x55 ) - { - p+= 1 ; - } - return p - &__bss_end ; -} - #endif @@ -2078,6 +2064,21 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim } #ifndef SIMU + +extern unsigned char __bss_end ; + +uint16_t stack_free() +{ + unsigned char *p ; + + p = &__bss_end + 1 ; + while ( *p == 0x55 ) + { + p+= 1 ; + } + return p - &__bss_end ; +} + int main(void) { // Set up I/O port data directions and initial states @@ -2174,6 +2175,21 @@ int main(void) ETIMSK |= (1< q ) + { + *p-- = 0x55 ; + } + } + sei(); // interrupts needed for eeReadAll function (soon). g_menuStack[0] = menuMainView; diff --git a/src/gtests.cpp b/src/gtests.cpp index a229ef600..ac6427b32 100644 --- a/src/gtests.cpp +++ b/src/gtests.cpp @@ -192,6 +192,48 @@ TEST(EEPROM, rm) { EXPECT_EQ(sz, 0); } +extern void processFrskyPacket(uint8_t *packet); + +TEST(FrSky, gpsNfuel) { + uint8_t pkt1[] = { 0xfd, 0x07, 0x00, 0x5e, 0x14, 0x2c, 0x00, 0x5e, 0x1c, 0x03 }; + uint8_t pkt2[] = { 0xfd, 0x07, 0x00, 0x00, 0x5e, 0x13, 0x38, 0x0c, 0x5e, 0x1b }; + uint8_t pkt3[] = { 0xfd, 0x07, 0x00, 0xc9, 0x06, 0x5e, 0x23, 0x4e, 0x00, 0x5e }; + uint8_t pkt4[] = { 0xfd, 0x07, 0x00, 0x12, 0xef, 0x2e, 0x5e, 0x1a, 0x98, 0x26 }; + uint8_t pkt5[] = { 0xfd, 0x07, 0x00, 0x5e, 0x22, 0x45, 0x00, 0x5e, 0x11, 0x02 }; + uint8_t pkt6[] = { 0xfd, 0x07, 0x00, 0x00, 0x5e, 0x19, 0x93, 0x00, 0x5e, 0x04 }; + uint8_t pkt7[] = { 0xfd, 0x03, 0x00, 0x64, 0x00, 0x5e }; + processFrskyPacket(pkt1); + processFrskyPacket(pkt2); + processFrskyPacket(pkt3); + processFrskyPacket(pkt4); + processFrskyPacket(pkt5); + processFrskyPacket(pkt6); + processFrskyPacket(pkt7); + EXPECT_EQ(frskyHubData.gpsCourse_bp, 44); + EXPECT_EQ(frskyHubData.gpsCourse_ap, 03); + EXPECT_EQ(frskyHubData.gpsLongitude_bp / 100, 120); + EXPECT_EQ(frskyHubData.gpsLongitude_bp % 100, 15); + EXPECT_EQ(frskyHubData.gpsLongitude_ap, 0x2698); + EXPECT_EQ(frskyHubData.gpsLatitudeNS, 'N'); + EXPECT_EQ(frskyHubData.gpsLongitudeEW, 'E'); + EXPECT_EQ(frskyHubData.fuelLevel, 100); +} + +TEST(FrSky, dateNtime) { + uint8_t pkt1[] = { 0xfd, 0x07, 0x00, 0x5e, 0x15, 0x0f, 0x07, 0x5e, 0x16, 0x0b }; + uint8_t pkt2[] = { 0xfd, 0x07, 0x00, 0x00, 0x5e, 0x17, 0x06, 0x12, 0x5e, 0x18 }; + uint8_t pkt3[] = { 0xfd, 0x03, 0x00, 0x32, 0x00, 0x5e }; + processFrskyPacket(pkt1); + processFrskyPacket(pkt2); + processFrskyPacket(pkt3); + EXPECT_EQ(frskyHubData.day, 15); + EXPECT_EQ(frskyHubData.month, 07); + EXPECT_EQ(frskyHubData.year, 11); + EXPECT_EQ(frskyHubData.hour, 06); + EXPECT_EQ(frskyHubData.min, 18); + EXPECT_EQ(frskyHubData.sec, 50); +} + int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/lcd.h b/src/lcd.h index 93794a240..253665624 100644 --- a/src/lcd.h +++ b/src/lcd.h @@ -62,7 +62,7 @@ /* other flags */ #define NO_UNIT UNSIGN -#define SHRT_TM_MODE 0x10 +#define SHRT_TM_MODE LEFT extern uint8_t displayBuf[DISPLAY_W*DISPLAY_H/8]; diff --git a/src/main_views.cpp b/src/main_views.cpp index 96e3cebbb..11a02badb 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -40,7 +40,7 @@ uint8_t tabViews[] = { 3, /*e_inputs*/ 1, /*e_timer2*/ #ifdef FRSKY - 2, /*e_telemetry*/ + 4, /*e_telemetry*/ #endif }; @@ -152,7 +152,7 @@ void menuMainView(uint8_t event) if (!instantTrimSwLock && trimSw) instantTrim(); instantTrimSwLock = trimSw; - if (view == e_telemetry+ALTERNATE) { + if (view_base == e_telemetry && view > ALTERNATE) { putsModelName(0, 0, g_model.name, g_eeGeneral.currModel, 0); uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0); putsVBat(14*FW,0,att); @@ -276,7 +276,7 @@ void menuMainView(uint8_t event) } } displayCount = (displayCount+1) % 50; - if (view & ALTERNATE) { + if (view == e_telemetry+ALTERNATE) { if (g_model.frsky.channels[0].ratio || g_model.frsky.channels[1].ratio) { x0 = 0; for (int i=0; i<2; i++) { @@ -340,6 +340,117 @@ void menuMainView(uint8_t event) lcd_outdezAtt(15 * FW - 2, 7*FH, frskyRSSI[1].min, 0); lcd_outdezAtt(17 * FW - 2, 7*FH, frskyRSSI[1].max, LEFT); } +#ifdef FRSKY_HUB + else if (g_eeGeneral.view == e_telemetry+2*ALTERNATE) { // if on second alternate telemetry view + // date + lcd_outdezNAtt(1*FW, 1*FH, frskyHubData.year+2000, LEFT, 4); + lcd_putc(lcd_lastPos, 1*FH, '-'); + lcd_outdezNAtt(lcd_lastPos+FW, 1*FH, frskyHubData.month, LEFT|LEADING0, 2); + lcd_putc(lcd_lastPos, 1*FH, '-'); + lcd_outdezNAtt(lcd_lastPos+FW, 1*FH, frskyHubData.day, LEFT|LEADING0, 2); + + // time + lcd_outdezNAtt(FW*10+8, 1*FH, frskyHubData.hour, LEFT|LEADING0, 2); + lcd_putc(lcd_lastPos, 1*FH, ':'); + lcd_outdezNAtt(lcd_lastPos+FW, 1*FH, frskyHubData.min, LEFT|LEADING0, 2); + lcd_putc(lcd_lastPos, 1*FH, ':'); + lcd_outdezNAtt(lcd_lastPos+FW, 1*FH, frskyHubData.sec, LEFT|LEADING0, 2); + + // Longitude + lcd_outdezAtt(FW*3-2, 3*FH, frskyHubData.gpsLongitude_bp / 100, 0); // ddd before '.' + lcd_putc(lcd_lastPos, 3*FH, '@'); + uint8_t mn = frskyHubData.gpsLongitude_bp % 100; + lcd_outdezNAtt(lcd_lastPos+FW, 3*FH, mn, LEFT|LEADING0, 2); // mm before '.' + lcd_plot(lcd_lastPos, 4*FH-2, 0); // small decimal point + lcd_outdezNAtt(lcd_lastPos+2, 3*FH, frskyHubData.gpsLongitude_ap, LEFT|UNSIGN|LEADING0, 4); // after '.' + lcd_putc(lcd_lastPos+1, 3*FH, frskyHubData.gpsLongitudeEW ? frskyHubData.gpsLongitudeEW : '-'); + + // Latitude + lcd_outdezAtt(lcd_lastPos+3*FW+3, 3*FH, frskyHubData.gpsLatitude_bp / 100, 0); // ddd before '.' + lcd_putc(lcd_lastPos, 3*FH, '@'); + mn = frskyHubData.gpsLatitude_bp % 100; + lcd_outdezNAtt(lcd_lastPos+FW, 3*FH, mn, LEFT|LEADING0, 2); // mm before '.' + lcd_plot(lcd_lastPos, 4*FH-2, 0); // small decimal point + lcd_outdezNAtt(lcd_lastPos+2, 3*FH, frskyHubData.gpsLatitude_ap, LEFT|UNSIGN|LEADING0, 4); // after '.' + lcd_putc(lcd_lastPos+1, 3*FH, frskyHubData.gpsLatitudeNS ? frskyHubData.gpsLatitudeNS : '-'); + + // Course / Heading + lcd_puts_P(5, 5*FH, PSTR("Hdg:")); + lcd_outdezNAtt(lcd_lastPos, 5*FH, frskyHubData.gpsCourse_bp, LEFT|LEADING0, 3); // before '.' + lcd_plot(lcd_lastPos, 6*FH-2, 0); // small decimal point + lcd_outdezAtt(lcd_lastPos+2, 5*FH, frskyHubData.gpsCourse_ap, LEFT); // after '.' + lcd_putc(lcd_lastPos, 5*FH, '@'); + + // Speed + lcd_puts_P(76, 5*FH, PSTR("Spd:")); + lcd_outdezAtt(lcd_lastPos, 5*FH, frskyHubData.gpsSpeed_bp, LEFT); // before '.' + lcd_plot(lcd_lastPos, 6*FH-2, 0); // small decimal point + lcd_outdezAtt(lcd_lastPos+2, 5*FH, frskyHubData.gpsSpeed_ap, LEFT|UNSIGN); // after '.' + + // Altitude + lcd_puts_P(7*FW, 7*FH, PSTR("Alt:")); + lcd_outdezNAtt(lcd_lastPos, 7*FH, frskyHubData.gpsAltitude_bp, LEFT|LEADING0, 3); // before '.' + lcd_plot(lcd_lastPos, 8*FH-2, 0); // small decimal point + lcd_outdezAtt(lcd_lastPos+2, 7*FH, frskyHubData.gpsAltitude_ap, LEFT|UNSIGN); // after '.' + lcd_putc(lcd_lastPos, 7*FH, 'm'); + } + else if (g_eeGeneral.view == e_telemetry+3*ALTERNATE) { // if on second alternate telemetry view + + uint8_t y = 2*FH; + + // Temperature 1 + lcd_puts_P(0, y, PSTR("Temp1:")); + lcd_outdezNAtt(lcd_lastPos, y, frskyHubData.temperature1, LEFT); + lcd_puts_P(lcd_lastPos, y, PSTR("@C")); + y += FH; + + // Temperature 2 + lcd_puts_P(0, y, PSTR("Temp2:")); + lcd_outdezNAtt(lcd_lastPos, y, frskyHubData.temperature2, LEFT); + lcd_puts_P(lcd_lastPos, y, PSTR("@C")); + + y += 2*FH; + + // RPM + lcd_puts_P(0, y, PSTR("RPM:")); + lcd_outdezNAtt(lcd_lastPos, y, frskyHubData.rpm, LEFT); + y += FH; + + // Fuel + lcd_puts_P(0, y, PSTR("Fuel:")); + lcd_outdezNAtt(lcd_lastPos, y, frskyHubData.fuelLevel, LEFT); + lcd_putc(lcd_lastPos, y, '%'); + y += FH; + + // Volts + lcd_puts_P(0, y, PSTR("Volts:")); + lcd_outdezNAtt(lcd_lastPos, y, frskyHubData.volts, LEFT); + lcd_putc(lcd_lastPos, y, 'V'); + + y = 2*FH; + // Altitude (barometric) + lcd_puts_P(12*FW, y, PSTR("Alt:")); + lcd_outdezNAtt(lcd_lastPos, y, frskyHubData.baroAltitude, LEFT|UNSIGN); + lcd_putc(lcd_lastPos, y, 'm'); + + y += 2*FH; + + // Acceleromter + lcd_puts_P(11*FW, y, PSTR("Accel")); + y += FH; + lcd_puts_P(11*FW, y, PSTR("x=")); + lcd_outdezNAtt(FW*17, y, (int32_t)frskyHubData.accelX * 100 / 256, PREC2); + lcd_putc(lcd_lastPos, y, 'g'); + y += FH; + lcd_puts_P(11*FW, y, PSTR("y=")); + lcd_outdezNAtt(FW*17, y, (int32_t)frskyHubData.accelY * 100 / 256, PREC2); + lcd_putc(lcd_lastPos, y, 'g'); + y += FH; + lcd_puts_P(11*FW, y, PSTR("z=")); + lcd_outdezNAtt(FW*17, y, (int32_t)frskyHubData.accelZ * 100 / 256, PREC2); + lcd_putc(lcd_lastPos, y, 'g'); + } +#endif else { y0 = 5*FH; //lcd_puts_P(2*FW-3, y0, PSTR("Tele:")); diff --git a/src/statistics_views.cpp b/src/statistics_views.cpp index 92725f2ee..b1303bcfe 100644 --- a/src/statistics_views.cpp +++ b/src/statistics_views.cpp @@ -99,7 +99,7 @@ void menuProcStatistic2(uint8_t event) lcd_outdez8(15*FW , 5*FH, g_time_per10/2 ); #ifndef SIMU lcd_puts_P( 0*FW, 6*FH, PSTR("Free Stack min b")); - lcd_outdezAtt(18*FW-1, 6*FH, stack_free() ) ; + lcd_outdezAtt(18*FW-1, 6*FH, stack_free(), UNSIGN) ; #endif lcd_puts_P( 3*FW, 7*FH, PSTR("[MENU] to reset")); }