#ifndef THER_NTC_HPP #define THER_NTC_HPP #include #include #include #include namespace ther { template class Ntc { public: /// Read all NTC sensors, return the maximum temperature value. /// Returns error if every sensor read fails. static auto GetSensorValue() -> zpp::result> { bool found = false; zpp::value max_val; for (const auto *dev : s_devices) { if (0 != sensor_sample_fetch(dev)) continue; zpp::value val; if (0 != sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &val)) continue; if (!found || val.to_double() > max_val.to_double()) { max_val = val; found = true; } } if (found) return max_val; return zpp::error_code::k_io; } private: static constexpr device *s_devices[] = {kNtcDev...}; }; } // namespace ther #endif // THER_NTC_HPP