@@ -10,16 +10,20 @@ APB::History::History() {
1010}
1111
1212
13+ #if APB_HEATERS_SIZE > 0
1314void APB::History::Entry::Heater::set (const APB::Heater &heater) {
1415 temperatureHundredth = static_cast <int16_t >(heater.temperature ().value_or (-100.0 ) * 100.0 );
1516 duty = heater.active () ? heater.duty () : 0 ;
1617}
18+ #endif
1719
20+ #ifndef APB_AMBIENT_TEMPERATURE_SENSOR_NONE
1821void APB::History::Entry::setAmbient (const std::optional<Ambient::Reading> &reading) {
1922 const auto readingValue = reading.value_or (Ambient::Reading{-100.0 , -100.0 });
2023 ambientTemperatureHundredth = static_cast <uint16_t >(readingValue.temperature * 100.0 );
2124 ambientHumidityHundredth = static_cast <uint16_t >(readingValue.humidity * 100.0 );
2225}
26+ #endif
2327
2428void APB::History::Entry::setPower (const PowerMonitor::Status & powerStatus) {
2529 busVoltageHundreth = static_cast <uint16_t >(powerStatus.busVoltage * 100.0 );
@@ -28,14 +32,26 @@ void APB::History::Entry::setPower(const PowerMonitor::Status & powerStatus) {
2832
2933void APB::History::Entry::populate (JsonObject object) {
3034 object[" uptime" ] = secondsFromBoot;
35+
36+ #ifndef APB_AMBIENT_TEMPERATURE_SENSOR_NONE
3137 setNullableFloat (object, " ambientTemperature" , getAmbientTemperature ());
3238 setNullableFloat (object, " ambientHumidity" , getAmbientHumidity ());
3339 object[" ambientDewpoint" ] = getDewpoint ();
40+ #else
41+ object[" ambientTemperature" ] = static_cast <char *>(0 );
42+ object[" ambientHumidity" ] = static_cast <char *>(0 );
43+ object[" ambientDewpoint" ] = static_cast <char *>(0 );
44+ #endif
45+
46+ #if APB_HEATERS_SIZE > 0
3447 for (uint8_t i=0 ; i<heaters.size (); i++) {
3548 JsonObject heaterObject = object[" heaters" ][i].to <JsonObject>();;
3649 heaterObject[" duty" ] = heaters[i].getDuty ();
3750 setNullableFloat (heaterObject, " temperature" , heaters[i].getTemperature ());
3851 }
52+ #else
53+ object[" heaters" ].to <JsonArray>();
54+ #endif
3955 object[" busVoltage" ] = getBusVoltage ();
4056 object[" power" ] = getPower ();
4157 object[" current" ] = getCurrent ();
0 commit comments