38 #ifndef LIGHT_CTL_UTILS_H__ 39 #define LIGHT_CTL_UTILS_H__ 42 #include "nordic_common.h" 85 #define T32_SCALE_FACTOR (65535LL) 88 #define SCALE_DOWN(_input, _scale_factor) ((_input)/(_scale_factor)) 91 #define SCALE_UP(_input, _scale_factor) ((_input)*(_scale_factor)) 144 if (t32_max == t32_min)
165 uint16_t t_min, uint16_t t_max)
167 return (generic_level_delta * ((int32_t)t_max - (int32_t)t_min))/65535L;
179 uint32_t t32_min, uint32_t t32_max)
182 return MAX(t32_min, MIN(t32_max, temperature32));
static int16_t light_ctl_utils_temperature32_to_level(uint32_t temperature32, uint32_t t32_min, uint32_t t32_max)
Converts internal, scaled up, temperature32 value to Generic Level state.
#define SCALE_UP(_input, _scale_factor)
Macro for performing scaling up.
static uint32_t light_ctl_utils_temperature_to_temperature32(uint16_t temperature)
Converts netural temperature value to internal, scaled up, temperature32 value.
static uint32_t light_ctl_utils_temperature32_range_restrict(uint32_t temperature32, uint32_t t32_min, uint32_t t32_max)
Restricts the given temperature32 value to given minimum and maximum (scaled up) range values...
#define SCALE_DOWN(_input, _scale_factor)
Macro for performing scaling down.
static int32_t light_ctl_utils_level_delta_to_temperature_delta(int32_t generic_level_delta, uint16_t t_min, uint16_t t_max)
Converts Generic Level Delta value to internal temperature value.
static uint16_t light_ctl_utils_temperature32_to_temperature(uint32_t temperature32)
Converts the scaled up temperature32 value back to neutral value.
static uint32_t light_ctl_utils_level_to_temperature32(int16_t level, uint32_t t32_min, uint32_t t32_max)
Converts Generic Level state to internal, scaled up, temperature32 value.
#define T32_SCALE_FACTOR
Scaling factor used by this module to scale given temperature value so as not to loose precision...