mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-11-21 22:47:05 +00:00
Merge pull request #3785 from AlexandrTyshchenko/feature/companion-adc-multiplier
Companion: set/get adc.multiplier CLI command
This commit is contained in:
3 files changed
+45
No files matched your search
@@ -66,6 +66,20 @@ Since version 1.18 meshcore companion radio firmware has a CLI interface, which
|
||||
|
||||
---
|
||||
|
||||
#### Fine-tune the battery reading
|
||||
**Usage:**
|
||||
- `get adc.multiplier`
|
||||
- `set adc.multiplier <value>`
|
||||
|
||||
**Parameters:**
|
||||
- `value`: ADC multiplier (0.0-10.0)
|
||||
|
||||
**Default:** `0.0` (value defined by board)
|
||||
|
||||
**Note:** Returns "Error: unsupported" if the board doesn't support it. Same command as on repeaters, for boards whose battery divider resistors vary (e.g. DIY ProMicro / Faketec).
|
||||
|
||||
---
|
||||
|
||||
### Radio
|
||||
|
||||
Radio parameters are common to all roles and handled by `CommonRadioPrefs`.
|
||||
|
||||
@@ -993,6 +993,8 @@ void MyMesh::begin() {
|
||||
_prefs.tx_power_dbm = constrain(_prefs.tx_power_dbm, -9, MAX_LORA_TX_POWER);
|
||||
_prefs.gps_enabled = constrain(_prefs.gps_enabled, 0, 1); // Ensure boolean 0 or 1
|
||||
_prefs.gps_interval = constrain(_prefs.gps_interval, 0, 86400); // Max 24 hours
|
||||
_prefs.adc_multiplier = constrain(_prefs.adc_multiplier, 0.0f, 10.0f);
|
||||
if (!board.setAdcMultiplier(_prefs.adc_multiplier)) _prefs.adc_multiplier = 0.0f;
|
||||
|
||||
_active_ble_pin = _prefs.ble_pin;
|
||||
|
||||
@@ -2215,6 +2217,33 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
||||
return true;
|
||||
}
|
||||
|
||||
if (memcmp(command, "set adc.multiplier ", 19) == 0) { // same as CommonCLI
|
||||
float mult = atof(&command[19]);
|
||||
if (mult < 0.0f || mult > 10.0f) {
|
||||
strcpy(reply, "Error, must be from 0 to 10");
|
||||
} else if (board.setAdcMultiplier(mult)) {
|
||||
_prefs.adc_multiplier = mult;
|
||||
savePrefs();
|
||||
if (mult == 0.0f) {
|
||||
strcpy(reply, "OK - using default board multiplier");
|
||||
} else {
|
||||
sprintf(reply, "OK - multiplier set to %.3f", mult);
|
||||
}
|
||||
} else {
|
||||
strcpy(reply, "Error: unsupported");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (strcmp(command, "get adc.multiplier") == 0) {
|
||||
float mult = board.getAdcMultiplier();
|
||||
if (mult == 0.0f) {
|
||||
strcpy(reply, "Error: unsupported");
|
||||
} else {
|
||||
sprintf(reply, "> %.3f", mult);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcmp(command, "get tz.offset") == 0) {
|
||||
float q = _prefs.tz_offset * 4;
|
||||
sprintf(reply, (q == (int)q && ((int)q & 1)) ? "> %.2f" : "> %.1f", _prefs.tz_offset);
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
char default_scope_name[31];
|
||||
uint8_t default_scope_key[16];
|
||||
float tz_offset = 0;
|
||||
float adc_multiplier = 0; // battery ADC multiplier, 0 = board default
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
#ifndef WIFI_SSID
|
||||
#define WIFI_SSID ""
|
||||
@@ -223,6 +224,7 @@ private:
|
||||
def("tel_loc", _parent->telemetry_mode_loc);
|
||||
def("tel_env", _parent->telemetry_mode_env);
|
||||
def("tz_offset", _parent->tz_offset);
|
||||
def("adc_mult", _parent->adc_multiplier);
|
||||
}
|
||||
public:
|
||||
CompanionPrefs(NodePrefs* parent) : _parent(parent) { }
|
||||
|
||||
Reference in new issue
Block a user