mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-04-07 23:45:11 +00:00
primera mejora Telemetria
This commit is contained in:
parent
dd12330e85
commit
0e46c64880
12 changed files with 186 additions and 27 deletions
|
|
@ -17,6 +17,8 @@ float multiplyCorrection = 0.035;
|
|||
|
||||
float voltageDividerTransformation = 0.0;
|
||||
|
||||
int telemetryCounter = random(1,999);
|
||||
|
||||
|
||||
#ifdef HAS_ADC_CALIBRATION
|
||||
#include <esp_adc_cal.h>
|
||||
|
|
@ -220,4 +222,47 @@ namespace BATTERY_Utils {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
String generateEncodedTelemetryBytes(float value, bool firstBytes, byte voltageType) { // 0 = internal battery(0-4,2V) , 1 = external battery(0-15V)
|
||||
String encodedBytes;
|
||||
int tempValue;
|
||||
|
||||
if (firstBytes) {
|
||||
tempValue = value;
|
||||
} else {
|
||||
switch (voltageType) {
|
||||
case 0:
|
||||
tempValue = value * 100; // Internal voltage calculation
|
||||
break;
|
||||
case 1:
|
||||
tempValue = (value * 100) / 2; // External voltage calculation
|
||||
break;
|
||||
default:
|
||||
tempValue = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int firstByte = tempValue / 91;
|
||||
tempValue -= firstByte * 91;
|
||||
|
||||
encodedBytes = char(firstByte + 33);
|
||||
encodedBytes += char(tempValue + 33);
|
||||
return encodedBytes;
|
||||
}
|
||||
|
||||
|
||||
String generateEncodedTelemetry() {
|
||||
String telemetry = "|";
|
||||
telemetry += generateEncodedTelemetryBytes(telemetryCounter, true, 0);
|
||||
telemetryCounter++;
|
||||
if (telemetryCounter == 1000) {
|
||||
telemetryCounter = 0;
|
||||
}
|
||||
if (Config.battery.sendInternalVoltage) telemetry += generateEncodedTelemetryBytes(3.987/*checkInternalVoltage()*/, false, 0);
|
||||
if (Config.battery.sendExternalVoltage) telemetry += generateEncodedTelemetryBytes(12.123/*checkExternalVoltage()*/, false, 1);
|
||||
telemetry += "|";
|
||||
return telemetry;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue