lib/led: move drivers/lights/rgbled LED_RGB_MAXBRT -> SYS_RGB_MAXBRT

This commit is contained in:
Daniel Agar
2021-09-28 10:09:55 -04:00
parent b24e5fc0af
commit 03bd5e0f48
7 changed files with 75 additions and 169 deletions
+13
View File
@@ -38,6 +38,7 @@
#include <lib/drivers/device/Device.hpp>
#include <drivers/drv_sensor.h>
#include <lib/parameters/param.h>
#include <lib/mathlib/mathlib.h>
bool param_modify_on_import(bson_node_t node)
{
@@ -91,6 +92,18 @@ bool param_modify_on_import(bson_node_t node)
}
}
// 2021-08-27: translate LED_RGB_MAXBRT (0-15) to SYS_RGB_MAXBRT(0.f-1.f)
if (node->type == BSON_INT32) {
if (strcmp("LED_RGB_MAXBRT", node->name) == 0) {
// convert integer (0-15) to float percentage
node->d = math::constrain(static_cast<double>(node->i) / 15., 0., 1.);
node->type = BSON_DOUBLE;
strcpy(node->name, "SYS_RGB_MAXBRT");
PX4_INFO("param migrating LED_RGB_MAXBRT (removed) -> SYS_RGB_MAXBRT: value=%.3f", node->d);
return true;
}
}
// 2020-06-29 (v1.11 beta): translate CAL_ACCx_EN/CAL_GYROx_EN/CAL_MAGx_EN -> CAL_ACCx_PRIO/CAL_GYROx_PRIO/CAL_MAGx_PRIO
if (node->type == BSON_INT32) {