Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read aircraft voltage from telemetry (CRSF), fixtype and voltage on OLED #97

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/io/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extern int16_t telemetry_sats;
extern uint8_t telemetry_failed_cs;
extern uint8_t telemetry_fixtype;
extern uint8_t telemetry_frequency;
extern int16_t telemetry_voltage;
extern positionVector_t targetPosition;
extern positionVector_t trackerPosition;
extern bool gotFix;
Expand Down Expand Up @@ -660,7 +661,8 @@ void showTelemetryPage(void){
if(telemetry_sats>99)
telemetry_sats = 99;

tfp_sprintf(lineBuffer, "Hz : %d",telemetry_frequency);
tfp_sprintf(lineBuffer, "Hz : %d V:%d.%d",telemetry_frequency, telemetry_voltage/100, telemetry_voltage%100);
// tfp_sprintf(lineBuffer, "Hz : %d",telemetry_frequency);
padLineBuffer();
i2c_OLED_set_line(rowIndex++);
i2c_OLED_send_string(lineBuffer);
Expand Down
22 changes: 21 additions & 1 deletion src/main/tracker/crossfire.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file is part of u360gts, aka amv-open360tracker 32bits:
* https://github.com/raul-ortega/amv-open360tracker-32bits
*
* The code below is an adaptation by Ral Ortega of the original code of OpenTX
* The code below is an adaptation by Ra˙l Ortega of the original code of OpenTX
* https://github.com/opentx/opentx
*
* u360gts is free software: you can redistribute it and/or modify
Expand All @@ -26,14 +26,20 @@
#define BROADCAST_ADDRESS 0x00
#define RADIO_ADDRESS 0xEA
#define GPS_ID 0x02
#define BAT_ID 0x08
#define TELEMETRY_RX_PACKET_SIZE 128



uint8_t crc8(const uint8_t * ptr, uint32_t len);

uint8_t telemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE]; // Receive buffer. 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1)
uint8_t telemetryRxBufferCount = 0;
uint8_t posCount = 0;

//VFAS sensor = voltage
int16_t telemetry_voltage;

bool checkCrossfireTelemetryFrameCRC()
{
uint8_t len = telemetryRxBuffer[1];
Expand Down Expand Up @@ -63,6 +69,16 @@ void processCrossfireTelemetryFrame()
return;
}

if (telemetry_sats == 0) {
telemetry_fixtype = 0;
}
else if (telemetry_sats < 5 && telemetry_sats > 0) {
telemetry_fixtype = 2;
}
else {
telemetry_fixtype = 3;
}

uint8_t id = telemetryRxBuffer[2];
int32_t value;
switch(id) {
Expand All @@ -86,6 +102,10 @@ void processCrossfireTelemetryFrame()
if (getCrossfireTelemetryValue(1, 17, &value))
telemetry_sats = (uint16_t) value;
break;
case BAT_ID:
if (getCrossfireTelemetryValue(2, 3, &value))
telemetry_voltage = (uint16_t) (value * 10);
break;
}
if(posCount == 2 ) {
posCount = 0;
Expand Down