mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-25 17:42:48 +00:00
support independently enabling/disabling the on-device screen and actual measurement
This commit is contained in:
parent
0c9df6ccbd
commit
3f1ada29ac
2
proto
2
proto
@ -1 +1 @@
|
|||||||
Subproject commit 040f6298976839120b07ee8a34e11494a370d401
|
Subproject commit d70f6f6f669df79c9423795caf34adbd28967e19
|
@ -80,7 +80,7 @@ extern const pb_msgdesc_t DeviceState_msg;
|
|||||||
#define DeviceState_fields &DeviceState_msg
|
#define DeviceState_fields &DeviceState_msg
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define DeviceState_size 6290
|
#define DeviceState_size 6293
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -208,7 +208,8 @@ typedef struct _RadioConfig_UserPreferences {
|
|||||||
bool range_test_plugin_save;
|
bool range_test_plugin_save;
|
||||||
bool store_forward_plugin_enabled;
|
bool store_forward_plugin_enabled;
|
||||||
uint32_t store_forward_plugin_records;
|
uint32_t store_forward_plugin_records;
|
||||||
bool environmental_measurement_plugin_enabled;
|
bool environmental_measurement_plugin_measurement_enabled;
|
||||||
|
bool environmental_measurement_plugin_screen_enabled;
|
||||||
uint32_t environmental_measurement_plugin_read_error_count_threshold;
|
uint32_t environmental_measurement_plugin_read_error_count_threshold;
|
||||||
uint32_t environmental_measurement_plugin_update_interval;
|
uint32_t environmental_measurement_plugin_update_interval;
|
||||||
uint32_t environmental_measurement_plugin_recovery_interval;
|
uint32_t environmental_measurement_plugin_recovery_interval;
|
||||||
@ -364,7 +365,7 @@ extern "C" {
|
|||||||
#define MeshPacket_init_default {0, 0, 0, {SubPacket_init_default}, 0, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN}
|
#define MeshPacket_init_default {0, 0, 0, {SubPacket_init_default}, 0, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN}
|
||||||
#define ChannelSettings_init_default {0, _ChannelSettings_ModemConfig_MIN, {0, {0}}, "", 0, 0, 0, 0, 0, 0, 0}
|
#define ChannelSettings_init_default {0, _ChannelSettings_ModemConfig_MIN, {0, {0}}, "", 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default, false, ChannelSettings_init_default}
|
#define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default, false, ChannelSettings_init_default}
|
||||||
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0}
|
#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0}
|
||||||
#define MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0}
|
#define MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN}
|
#define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN}
|
||||||
@ -378,7 +379,7 @@ extern "C" {
|
|||||||
#define MeshPacket_init_zero {0, 0, 0, {SubPacket_init_zero}, 0, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN}
|
#define MeshPacket_init_zero {0, 0, 0, {SubPacket_init_zero}, 0, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN}
|
||||||
#define ChannelSettings_init_zero {0, _ChannelSettings_ModemConfig_MIN, {0, {0}}, "", 0, 0, 0, 0, 0, 0, 0}
|
#define ChannelSettings_init_zero {0, _ChannelSettings_ModemConfig_MIN, {0, {0}}, "", 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero, false, ChannelSettings_init_zero}
|
#define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero, false, ChannelSettings_init_zero}
|
||||||
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0}
|
#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0}
|
||||||
#define MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0}
|
#define MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN}
|
#define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN}
|
||||||
@ -464,10 +465,11 @@ extern "C" {
|
|||||||
#define RadioConfig_UserPreferences_range_test_plugin_save_tag 134
|
#define RadioConfig_UserPreferences_range_test_plugin_save_tag 134
|
||||||
#define RadioConfig_UserPreferences_store_forward_plugin_enabled_tag 136
|
#define RadioConfig_UserPreferences_store_forward_plugin_enabled_tag 136
|
||||||
#define RadioConfig_UserPreferences_store_forward_plugin_records_tag 137
|
#define RadioConfig_UserPreferences_store_forward_plugin_records_tag 137
|
||||||
#define RadioConfig_UserPreferences_environmental_measurement_plugin_enabled_tag 140
|
#define RadioConfig_UserPreferences_environmental_measurement_plugin_measurement_enabled_tag 140
|
||||||
#define RadioConfig_UserPreferences_environmental_measurement_plugin_read_error_count_threshold_tag 141
|
#define RadioConfig_UserPreferences_environmental_measurement_plugin_screen_enabled_tag 141
|
||||||
#define RadioConfig_UserPreferences_environmental_measurement_plugin_update_interval_tag 142
|
#define RadioConfig_UserPreferences_environmental_measurement_plugin_read_error_count_threshold_tag 142
|
||||||
#define RadioConfig_UserPreferences_environmental_measurement_plugin_recovery_interval_tag 143
|
#define RadioConfig_UserPreferences_environmental_measurement_plugin_update_interval_tag 143
|
||||||
|
#define RadioConfig_UserPreferences_environmental_measurement_plugin_recovery_interval_tag 144
|
||||||
#define RouteDiscovery_route_tag 2
|
#define RouteDiscovery_route_tag 2
|
||||||
#define User_id_tag 1
|
#define User_id_tag 1
|
||||||
#define User_long_name_tag 2
|
#define User_long_name_tag 2
|
||||||
@ -650,10 +652,11 @@ X(a, STATIC, SINGULAR, UINT32, range_test_plugin_sender, 133) \
|
|||||||
X(a, STATIC, SINGULAR, BOOL, range_test_plugin_save, 134) \
|
X(a, STATIC, SINGULAR, BOOL, range_test_plugin_save, 134) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_enabled, 136) \
|
X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_enabled, 136) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, store_forward_plugin_records, 137) \
|
X(a, STATIC, SINGULAR, UINT32, store_forward_plugin_records, 137) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, environmental_measurement_plugin_enabled, 140) \
|
X(a, STATIC, SINGULAR, BOOL, environmental_measurement_plugin_measurement_enabled, 140) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_read_error_count_threshold, 141) \
|
X(a, STATIC, SINGULAR, BOOL, environmental_measurement_plugin_screen_enabled, 141) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_update_interval, 142) \
|
X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_read_error_count_threshold, 142) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_recovery_interval, 143)
|
X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_update_interval, 143) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_recovery_interval, 144)
|
||||||
#define RadioConfig_UserPreferences_CALLBACK NULL
|
#define RadioConfig_UserPreferences_CALLBACK NULL
|
||||||
#define RadioConfig_UserPreferences_DEFAULT NULL
|
#define RadioConfig_UserPreferences_DEFAULT NULL
|
||||||
|
|
||||||
@ -765,13 +768,13 @@ extern const pb_msgdesc_t ToRadio_msg;
|
|||||||
#define SubPacket_size 275
|
#define SubPacket_size 275
|
||||||
#define MeshPacket_size 322
|
#define MeshPacket_size 322
|
||||||
#define ChannelSettings_size 95
|
#define ChannelSettings_size 95
|
||||||
#define RadioConfig_size 429
|
#define RadioConfig_size 432
|
||||||
#define RadioConfig_UserPreferences_size 329
|
#define RadioConfig_UserPreferences_size 332
|
||||||
#define NodeInfo_size 132
|
#define NodeInfo_size 132
|
||||||
#define MyNodeInfo_size 106
|
#define MyNodeInfo_size 106
|
||||||
#define LogRecord_size 81
|
#define LogRecord_size 81
|
||||||
#define FromRadio_size 438
|
#define FromRadio_size 441
|
||||||
#define ToRadio_size 433
|
#define ToRadio_size 436
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -49,19 +49,20 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() {
|
|||||||
Uncomment the preferences below if you want to use the plugin
|
Uncomment the preferences below if you want to use the plugin
|
||||||
without having to configure it from the PythonAPI or WebUI.
|
without having to configure it from the PythonAPI or WebUI.
|
||||||
*/
|
*/
|
||||||
/*radioConfig.preferences.environmental_measurement_plugin_enabled = 1;
|
/*radioConfig.preferences.environmental_measurement_plugin_measurement_enabled = 1;
|
||||||
|
radioConfig.preferences.environmental_measurement_plugin_screen_enabled = 1;
|
||||||
radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold = 5;
|
radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold = 5;
|
||||||
radioConfig.preferences.environmental_measurement_plugin_update_interval = 30;
|
radioConfig.preferences.environmental_measurement_plugin_update_interval = 30;
|
||||||
radioConfig.preferences.environmental_measurement_plugin_recovery_interval = 600;*/
|
radioConfig.preferences.environmental_measurement_plugin_recovery_interval = 600;*/
|
||||||
|
|
||||||
if (!radioConfig.preferences.environmental_measurement_plugin_enabled){
|
if (! (radioConfig.preferences.environmental_measurement_plugin_measurement_enabled || radioConfig.preferences.environmental_measurement_plugin_screen_enabled)){
|
||||||
// If this plugin is not enabled, don't waste any OSThread time on it
|
// If this plugin is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it
|
||||||
return (INT32_MAX);
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
// This is the first time the OSThread library has called this function, so do some setup
|
// This is the first time the OSThread library has called this function, so do some setup
|
||||||
DEBUG_MSG("EnvironmentalMeasurement: Initializing as sender\n");
|
DEBUG_MSG("EnvironmentalMeasurement: Initializing\n");
|
||||||
environmentalMeasurementPluginRadio = new EnvironmentalMeasurementPluginRadio();
|
environmentalMeasurementPluginRadio = new EnvironmentalMeasurementPluginRadio();
|
||||||
firstTime = 0;
|
firstTime = 0;
|
||||||
// begin reading measurements from the sensor
|
// begin reading measurements from the sensor
|
||||||
@ -70,10 +71,22 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() {
|
|||||||
// returning the interval here means that the next time OSThread
|
// returning the interval here means that the next time OSThread
|
||||||
// calls our plugin, we'll run the other branch of this if statement
|
// calls our plugin, we'll run the other branch of this if statement
|
||||||
// and actually do a "sendOurEnvironmentalMeasurement()"
|
// and actually do a "sendOurEnvironmentalMeasurement()"
|
||||||
dht.begin();
|
if (radioConfig.preferences.environmental_measurement_plugin_measurement_enabled)
|
||||||
return(DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
{
|
||||||
|
// it's possible to have this plugin enabled, only for displaying values on the screen.
|
||||||
|
// therefore, we should only enable the sensor loop if measurement is also enabled
|
||||||
|
dht.begin();
|
||||||
|
return(DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||||
|
}
|
||||||
|
return (INT32_MAX);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (!radioConfig.preferences.environmental_measurement_plugin_measurement_enabled)
|
||||||
|
{
|
||||||
|
// if we somehow got to a second run of this plugin with measurement disabled, then just wait forever
|
||||||
|
// I can't imagine we'd ever get here though.
|
||||||
|
return (INT32_MAX);
|
||||||
|
}
|
||||||
// this is not the first time OSThread library has called this function
|
// this is not the first time OSThread library has called this function
|
||||||
// so just do what we intend to do on the interval
|
// so just do what we intend to do on the interval
|
||||||
if(sensor_read_error_count > radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold)
|
if(sensor_read_error_count > radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold)
|
||||||
@ -110,6 +123,10 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EnvironmentalMeasurementPluginRadio::wantUIFrame() {
|
||||||
|
return radioConfig.preferences.environmental_measurement_plugin_screen_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void EnvironmentalMeasurementPluginRadio::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void EnvironmentalMeasurementPluginRadio::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
@ -134,8 +151,8 @@ String GetSenderName(const MeshPacket &mp) {
|
|||||||
|
|
||||||
bool EnvironmentalMeasurementPluginRadio::handleReceivedProtobuf(const MeshPacket &mp, const EnvironmentalMeasurement &p)
|
bool EnvironmentalMeasurementPluginRadio::handleReceivedProtobuf(const MeshPacket &mp, const EnvironmentalMeasurement &p)
|
||||||
{
|
{
|
||||||
if (!radioConfig.preferences.environmental_measurement_plugin_enabled){
|
if (!(radioConfig.preferences.environmental_measurement_plugin_measurement_enabled || radioConfig.preferences.environmental_measurement_plugin_screen_enabled)){
|
||||||
// If this plugin is not enabled, don't handle the packet, and allow other plugins to consume
|
// If this plugin is not enabled in any capacity, don't handle the packet, and allow other plugins to consume
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool wasBroadcast = mp.to == NODENUM_BROADCAST;
|
bool wasBroadcast = mp.to == NODENUM_BROADCAST;
|
||||||
|
@ -44,9 +44,7 @@ class EnvironmentalMeasurementPluginRadio : public ProtobufPlugin<EnvironmentalM
|
|||||||
*/
|
*/
|
||||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, const EnvironmentalMeasurement &p);
|
virtual bool handleReceivedProtobuf(const MeshPacket &mp, const EnvironmentalMeasurement &p);
|
||||||
|
|
||||||
virtual bool wantUIFrame() {
|
virtual bool wantUIFrame();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user