M5Unit-THERMO 0.4.0 git rev:7cce598
Loading...
Searching...
No Matches
unit_NCIR2_data.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
13#ifndef M5_UNIT_THERMO_UNIT_NCIR2_DATA_HPP
14#define M5_UNIT_THERMO_UNIT_NCIR2_DATA_HPP
15
16#include <array>
17#include <cstdint>
18
19#include <m5_utility/types.hpp>
20
21namespace m5 {
22namespace unit {
23
28namespace ncir2 {
34struct Data {
35 std::array<uint8_t, 2> raw{0x00, 0x80};
37 inline int16_t value() const
38 {
39 return m5::types::little_int16_t{raw[0], raw[1]}.get();
40 }
42 inline float temperature() const
43 {
44 return value() * 0.01f;
45 }
47 inline float celsius() const
48 {
49 return temperature();
50 }
52 inline float fahrenheit() const
53 {
54 return celsius() * 9.0f / 5.0f + 32.f;
55 }
56};
57} // namespace ncir2
58
59} // namespace unit
60} // namespace m5
61#endif
Top level namespace of M5stack.
For UnitNCIR2.
Unit-related namespace.
Measurement data group.
Definition unit_NCIR2_data.hpp:34
float fahrenheit() const
Fahrenheit.
Definition unit_NCIR2_data.hpp:52
float celsius() const
Celsius.
Definition unit_NCIR2_data.hpp:47
std::array< uint8_t, 2 > raw
Definition unit_NCIR2_data.hpp:35
float temperature() const
Temperature(Celsius)
Definition unit_NCIR2_data.hpp:42
int16_t value() const
Raw int16.
Definition unit_NCIR2_data.hpp:37