mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 22:22:05 +00:00
Switch EnvironmentTelemetry to use UnitConversions (#4972)
We already have a central class for unit conversions, switch EnvironmentTelemetry to that in preparation for HealthTelemetry.
This commit is contained in:
parent
001a845ac3
commit
bb9f003c24
@ -10,6 +10,7 @@
|
|||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
|
#include "UnitConversions.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
@ -182,11 +183,6 @@ bool EnvironmentTelemetryModule::wantUIFrame()
|
|||||||
return moduleConfig.telemetry.environment_screen_enabled;
|
return moduleConfig.telemetry.environment_screen_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
float EnvironmentTelemetryModule::CelsiusToFahrenheit(float c)
|
|
||||||
{
|
|
||||||
return (c * 9) / 5 + 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
@ -216,7 +212,8 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt
|
|||||||
|
|
||||||
String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C";
|
String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C";
|
||||||
if (moduleConfig.telemetry.environment_display_fahrenheit) {
|
if (moduleConfig.telemetry.environment_display_fahrenheit) {
|
||||||
last_temp = String(CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F";
|
last_temp =
|
||||||
|
String(UnitConversions::CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue with the remaining details
|
// Continue with the remaining details
|
||||||
|
@ -52,7 +52,6 @@ class EnvironmentTelemetryModule : private concurrency::OSThread, public Protobu
|
|||||||
meshtastic_AdminMessage *response) override;
|
meshtastic_AdminMessage *response) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float CelsiusToFahrenheit(float c);
|
|
||||||
bool firstTime = 1;
|
bool firstTime = 1;
|
||||||
meshtastic_MeshPacket *lastMeasurementPacket;
|
meshtastic_MeshPacket *lastMeasurementPacket;
|
||||||
uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute
|
uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute
|
||||||
|
Loading…
Reference in New Issue
Block a user