nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
utils.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0 */
2 /* Copyright 2018-2019 Peter A. Bigot */
3 
9 #ifndef NRFCXX_SENSOR_UTILS_HPP
10 #define NRFCXX_SENSOR_UTILS_HPP
11 
12 #include <array>
13 #include <cinttypes>
14 #include <type_traits>
15 
16 namespace nrfcxx {
17 namespace sensor {
18 
31 inline int temperature_cK_cCel (int t_cK)
32 {
33  return t_cK - 27315;
34 }
35 
43 {
45  uint16_t lvl_pptt;
46 
48  uint16_t lvl_mV;
49 };
50 
58 unsigned int battery_level_pptt (unsigned int batt_mV,
59  const battery_level_point_type* curve);
60 
61 } // ns sensor
62 } // ns nrfcxx
63 
64 #endif /* NRFCXX_SENSOR_UTILS_HPP */
nrfcxx::sensor::battery_level_point_type
A point in a battery discharge curve sequence.
Definition: utils.hpp:42
nrfcxx::sensor::battery_level_point_type::lvl_pptt
uint16_t lvl_pptt
Remaining life at lvl_mV.
Definition: utils.hpp:45
nrfcxx::sensor::temperature_cK_cCel
int temperature_cK_cCel(int t_cK)
Convert a temperature from cK to cCel.
Definition: utils.hpp:31
nrfcxx::sensor::battery_level_point_type::lvl_mV
uint16_t lvl_mV
Battery voltage at lvl_pptt remaining life.
Definition: utils.hpp:48
nrfcxx::sensor::battery_level_pptt
unsigned int battery_level_pptt(unsigned int batt_mV, const battery_level_point_type *curve)
Calculate the estimated battery level based on a measured voltage.
nrfcxx
Primary namespace for nrfcxx functionality.
Definition: clock.hpp:17