Skip to content

Commit ea9789a

Browse files
committed
Bluetooth: Mesh: Calculate Light temp time to edge in lvl space
Changes the calculation of time to edge in the lvl_move set implementation of the Light Temperature Server to the level space. Previously, the time to edge was calculated with a mix of light temperature and generic level, which caused longer transition times than expected. Signed-off-by: Trond Einar Snekvik <[email protected]>
1 parent 260beb6 commit ea9789a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/bluetooth/mesh/light_temp_srv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ static void lvl_move_set(struct bt_mesh_lvl_srv *lvl_srv,
271271
}
272272

273273
if (move_set->delta != 0 && move_set->transition) {
274-
uint64_t distance = abs(set.params.temp - status.current.temp);
275-
uint32_t time_to_edge =
276-
(distance * (uint64_t)move_set->transition->time) /
277-
abs(move_set->delta);
274+
/* Calculate the transition time to edge in the Generic Level space: */
275+
int32_t lvl_target = (move_set->delta > 0 ? INT16_MAX : INT16_MIN);
276+
int32_t lvl_delta = lvl_target - temp_to_lvl(srv, status.current.temp);
277+
uint32_t time_to_edge = (move_set->transition->time * lvl_delta) / move_set->delta;
278278

279279
if (time_to_edge > 0) {
280280
transition.time = time_to_edge;

0 commit comments

Comments
 (0)