Improve sensor printing format

This commit is contained in:
BlackMark 2020-07-03 18:58:54 +02:00
parent 608f29e81b
commit 7363926f64
2 changed files with 11 additions and 5 deletions

View File

@ -9,6 +9,8 @@
class LightSensors { class LightSensors {
public: public:
static constexpr auto MAX_VALUE = uint16_t{4095};
static inline const std::array<uint16_t, 3>& getValues() static inline const std::array<uint16_t, 3>& getValues()
{ {
sampleLightSensors(); sampleLightSensors();

View File

@ -144,12 +144,16 @@ class Terminal {
static void readSensors() static void readSensors()
{ {
const auto sensorValues = m_lightSensors.getValues(); const auto sensorValues = m_lightSensors.getValues();
m_serial << "Sensor values: "; m_serial << "Sensor values: " << detail::ENDL;
for(const auto& ldrValue: sensorValues) { for(size_t i = 0; i < sensorValues.size(); ++i) {
m_serial.txNumber(ldrValue); m_serial << "LDR";
m_serial << ", "; m_serial.txNumber(i + 1);
m_serial << ": ";
m_serial.template txNumber<uint16_t, 10, 4, ' '>(sensorValues[i]);
m_serial << " - ";
m_serial.template txNumber<uint8_t, 10, 3, ' '>(sensorValues[i] * 100 / m_lightSensors.MAX_VALUE);
m_serial << "%" << detail::ENDL;
} }
m_serial << detail::ENDL;
} }
static void printVersion() { m_serial << "AdaptiveBrightness v" << detail::VERSION << detail::ENDL; } static void printVersion() { m_serial << "AdaptiveBrightness v" << detail::VERSION << detail::ENDL; }