@@ -276,28 +276,6 @@ static float getDistanceConversionFactor(const char* unit) {
276276 return 1 .0f ; // Default: assume inches
277277}
278278
279- // Helper function: Get tank height/capacity based on sensor configuration
280- static float getMonitorHeight (const MonitorConfig &cfg) {
281- if (cfg.sensorInterface == SENSOR_CURRENT_LOOP) {
282- if (cfg.currentLoopType == CURRENT_LOOP_ULTRASONIC) {
283- // For ultrasonic sensors, mount height IS the tank height (distance to bottom)
284- return cfg.sensorMountHeight ;
285- } else {
286- // For pressure sensors, max range + mount height approximates full tank height
287- float rangeInches = cfg.sensorRangeMax * getPressureConversionFactor (cfg.sensorRangeUnit );
288- return rangeInches + cfg.sensorMountHeight ;
289- }
290- } else if (cfg.sensorInterface == SENSOR_ANALOG) {
291- // For analog sensors, max range + mount height approximates full tank height
292- float rangeInches = cfg.sensorRangeMax * getPressureConversionFactor (cfg.sensorRangeUnit );
293- return rangeInches + cfg.sensorMountHeight ;
294- } else if (cfg.sensorInterface == SENSOR_DIGITAL) {
295- // Digital sensors are binary, treat 1.0 as full
296- return 1 .0f ;
297- }
298- return 0 .0f ;
299- }
300-
301279static const uint8_t NOTECARD_I2C_ADDRESS = 0x17 ;
302280static const uint32_t NOTECARD_I2C_FREQUENCY = 400000UL ;
303281
@@ -450,6 +428,28 @@ struct MonitorRuntime {
450428 unsigned long lastSensorFaultMillis;
451429};
452430
431+ // Helper function: Get tank height/capacity based on sensor configuration
432+ static float getMonitorHeight (const MonitorConfig &cfg) {
433+ if (cfg.sensorInterface == SENSOR_CURRENT_LOOP) {
434+ if (cfg.currentLoopType == CURRENT_LOOP_ULTRASONIC) {
435+ // For ultrasonic sensors, mount height IS the tank height (distance to bottom)
436+ return cfg.sensorMountHeight ;
437+ } else {
438+ // For pressure sensors, max range + mount height approximates full tank height
439+ float rangeInches = cfg.sensorRangeMax * getPressureConversionFactor (cfg.sensorRangeUnit );
440+ return rangeInches + cfg.sensorMountHeight ;
441+ }
442+ } else if (cfg.sensorInterface == SENSOR_ANALOG) {
443+ // For analog sensors, max range + mount height approximates full tank height
444+ float rangeInches = cfg.sensorRangeMax * getPressureConversionFactor (cfg.sensorRangeUnit );
445+ return rangeInches + cfg.sensorMountHeight ;
446+ } else if (cfg.sensorInterface == SENSOR_DIGITAL) {
447+ // Digital sensors are binary, treat 1.0 as full
448+ return 1 .0f ;
449+ }
450+ return 0 .0f ;
451+ }
452+
453453static ClientConfig gConfig ;
454454static MonitorRuntime gMonitorState [MAX_TANKS];
455455
0 commit comments