@@ -70,7 +70,8 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
7070 file.read ((uint8_t *)&_prefs->gps_interval , sizeof (_prefs->gps_interval )); // 157
7171 file.read ((uint8_t *)&_prefs->advert_loc_policy , sizeof (_prefs->advert_loc_policy )); // 161
7272 file.read ((uint8_t *)&_prefs->discovery_mod_timestamp , sizeof (_prefs->discovery_mod_timestamp )); // 162
73- // 166
73+ file.read ((uint8_t *)&_prefs->adc_multiplier , sizeof (_prefs->adc_multiplier )); // 166
74+ // 170
7475
7576 // sanitise bad pref values
7677 _prefs->rx_delay_base = constrain (_prefs->rx_delay_base , 0 , 20 .0f );
@@ -83,6 +84,7 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
8384 _prefs->cr = constrain (_prefs->cr , 5 , 8 );
8485 _prefs->tx_power_dbm = constrain (_prefs->tx_power_dbm , 1 , 30 );
8586 _prefs->multi_acks = constrain (_prefs->multi_acks , 0 , 1 );
87+ _prefs->adc_multiplier = constrain (_prefs->adc_multiplier , 0 .0f , 10 .0f );
8688
8789 // sanitise bad bridge pref values
8890 _prefs->bridge_enabled = constrain (_prefs->bridge_enabled , 0 , 1 );
@@ -148,7 +150,8 @@ void CommonCLI::savePrefs(FILESYSTEM* fs) {
148150 file.write ((uint8_t *)&_prefs->gps_interval , sizeof (_prefs->gps_interval )); // 157
149151 file.write ((uint8_t *)&_prefs->advert_loc_policy , sizeof (_prefs->advert_loc_policy )); // 161
150152 file.write ((uint8_t *)&_prefs->discovery_mod_timestamp , sizeof (_prefs->discovery_mod_timestamp )); // 162
151- // 166
153+ file.write ((uint8_t *)&_prefs->adc_multiplier , sizeof (_prefs->adc_multiplier )); // 166
154+ // 170
152155
153156 file.close ();
154157 }
@@ -233,7 +236,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
233236 uint8_t sf = num > 2 ? atoi (parts[2 ]) : 0 ;
234237 uint8_t cr = num > 3 ? atoi (parts[3 ]) : 0 ;
235238 int temp_timeout_mins = num > 4 ? atoi (parts[4 ]) : 0 ;
236- if (freq >= 300 .0f && freq <= 2500 .0f && sf >= 7 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7 .0f && bw <= 500 .0f && temp_timeout_mins > 0 ) {
239+ if (freq >= 300 .0f && freq <= 2500 .0f && sf >= 5 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7 .0f && bw <= 500 .0f && temp_timeout_mins > 0 ) {
237240 _callbacks->applyTempRadioParams (freq, bw, sf, cr, temp_timeout_mins);
238241 sprintf (reply, " OK - temp params for %d mins" , temp_timeout_mins);
239242 } else {
@@ -331,6 +334,13 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
331334 } else if (memcmp (config, " bridge.secret" , 13 ) == 0 ) {
332335 sprintf (reply, " > %s" , _prefs->bridge_secret );
333336#endif
337+ } else if (memcmp (config, " adc.multiplier" , 14 ) == 0 ) {
338+ float adc_mult = _board->getAdcMultiplier ();
339+ if (adc_mult == 0 .0f ) {
340+ strcpy (reply, " Error: unsupported by this board" );
341+ } else {
342+ sprintf (reply, " > %.3f" , adc_mult);
343+ }
334344 } else {
335345 sprintf (reply, " ??: %s" , config);
336346 }
@@ -411,7 +421,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
411421 float bw = num > 1 ? atof (parts[1 ]) : 0 .0f ;
412422 uint8_t sf = num > 2 ? atoi (parts[2 ]) : 0 ;
413423 uint8_t cr = num > 3 ? atoi (parts[3 ]) : 0 ;
414- if (freq >= 300 .0f && freq <= 2500 .0f && sf >= 7 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7 .0f && bw <= 500 .0f ) {
424+ if (freq >= 300 .0f && freq <= 2500 .0f && sf >= 5 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7 .0f && bw <= 500 .0f ) {
415425 _prefs->sf = sf;
416426 _prefs->cr = cr;
417427 _prefs->freq = freq;
@@ -523,6 +533,19 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
523533 savePrefs ();
524534 strcpy (reply, " OK" );
525535#endif
536+ } else if (memcmp (config, " adc.multiplier " , 15 ) == 0 ) {
537+ _prefs->adc_multiplier = atof (&config[15 ]);
538+ if (_board->setAdcMultiplier (_prefs->adc_multiplier )) {
539+ savePrefs ();
540+ if (_prefs->adc_multiplier == 0 .0f ) {
541+ strcpy (reply, " OK - using default board multiplier" );
542+ } else {
543+ sprintf (reply, " OK - multiplier set to %.3f" , _prefs->adc_multiplier );
544+ }
545+ } else {
546+ _prefs->adc_multiplier = 0 .0f ;
547+ strcpy (reply, " Error: unsupported by this board" );
548+ };
526549 } else {
527550 sprintf (reply, " unknown config: %s" , config);
528551 }
0 commit comments