Fixed implicit conversion from float to double in lighting output and color.
This commit is contained in:
+2
-1
@@ -3254,7 +3254,8 @@ int bacapp_snprintf_value(
|
||||
case BACNET_APPLICATION_TAG_SCALE:
|
||||
if (value->type.Scale.float_scale) {
|
||||
ret_val = bacapp_snprintf(
|
||||
str, str_len, "%f", value->type.Scale.type.real_scale);
|
||||
str, str_len, "%f",
|
||||
(double)value->type.Scale.type.real_scale);
|
||||
} else {
|
||||
ret_val = bacapp_snprintf(
|
||||
str, str_len, "%ld",
|
||||
|
||||
@@ -1384,7 +1384,8 @@ bool Lighting_Output_Default_Ramp_Rate_Set(
|
||||
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
if ((percent_per_second >= 0.1) && (percent_per_second <= 100.0)) {
|
||||
if (isgreaterequal(percent_per_second, 0.1f) &&
|
||||
islessequal(percent_per_second, 100.0f)) {
|
||||
pObject->Default_Ramp_Rate = percent_per_second;
|
||||
status = true;
|
||||
}
|
||||
@@ -1417,7 +1418,8 @@ static bool Lighting_Output_Default_Ramp_Rate_Write(
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
(void)priority;
|
||||
if ((percent_per_second >= 0.1) && (percent_per_second <= 100.0)) {
|
||||
if (isgreaterequal(percent_per_second, 0.1f) &&
|
||||
islessequal(percent_per_second, 100.0f)) {
|
||||
pObject->Default_Ramp_Rate = percent_per_second;
|
||||
status = true;
|
||||
} else {
|
||||
@@ -1470,7 +1472,8 @@ bool Lighting_Output_Default_Step_Increment_Set(
|
||||
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
if ((step_increment >= 0.1) && (step_increment <= 100.0)) {
|
||||
if (isgreaterequal(step_increment, 0.1f) &&
|
||||
islessequal(step_increment, 100.0f)) {
|
||||
pObject->Default_Step_Increment = step_increment;
|
||||
status = true;
|
||||
}
|
||||
@@ -1503,7 +1506,8 @@ static bool Lighting_Output_Default_Step_Increment_Write(
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
(void)priority;
|
||||
if ((value >= 0.1) && (value <= 100.0)) {
|
||||
if (isgreaterequal(value, 0.1f) &&
|
||||
islessequal(value, 100.0f)) {
|
||||
pObject->Default_Step_Increment = value;
|
||||
status = true;
|
||||
} else {
|
||||
@@ -2515,7 +2519,7 @@ static void Lighting_Output_Step_Off_Handler(uint32_t object_instance)
|
||||
if (isgreaterequal(target_value, step_value)) {
|
||||
target_value -= step_value;
|
||||
} else {
|
||||
target_value = 0;
|
||||
target_value = 0.0f;
|
||||
}
|
||||
/* clamp target within max */
|
||||
if (isgreater(target_value, max_value)) {
|
||||
@@ -2523,7 +2527,7 @@ static void Lighting_Output_Step_Off_Handler(uint32_t object_instance)
|
||||
}
|
||||
/* jump target to OFF if below min */
|
||||
if (isless(target_value, min_value)) {
|
||||
target_value = 0.0;
|
||||
target_value = 0.0f;
|
||||
}
|
||||
pObject->Present_Value = target_value;
|
||||
pObject->Tracking_Value = target_value;
|
||||
@@ -2623,9 +2627,9 @@ uint32_t Lighting_Output_Create(uint32_t object_instance)
|
||||
}
|
||||
pObject->Object_Name = NULL;
|
||||
pObject->Description = NULL;
|
||||
pObject->Present_Value = 0.0;
|
||||
pObject->Tracking_Value = 0.0;
|
||||
pObject->Physical_Value = 0.0;
|
||||
pObject->Present_Value = 0.0f;
|
||||
pObject->Tracking_Value = 0.0f;
|
||||
pObject->Physical_Value = 0.0f;
|
||||
pObject->Lighting_Command.operation = BACNET_LIGHTS_NONE;
|
||||
pObject->Lighting_Command.use_target_level = false;
|
||||
pObject->Lighting_Command.use_ramp_rate = false;
|
||||
@@ -2639,18 +2643,18 @@ uint32_t Lighting_Output_Create(uint32_t object_instance)
|
||||
pObject->Egress_Time = 0;
|
||||
pObject->Default_Fade_Time = 100;
|
||||
pObject->Default_Ramp_Rate = 100.0;
|
||||
pObject->Default_Step_Increment = 1.0;
|
||||
pObject->Default_Step_Increment = 1.0f;
|
||||
pObject->Transition = BACNET_LIGHTING_TRANSITION_FADE;
|
||||
pObject->Feedback_Value = 0.0;
|
||||
for (p = 0; p < BACNET_MAX_PRIORITY; p++) {
|
||||
pObject->Priority_Array[p] = 0.0;
|
||||
pObject->Priority_Array[p] = 0.0f;
|
||||
BIT_CLEAR(pObject->Priority_Active_Bits, p);
|
||||
}
|
||||
pObject->Relinquish_Default = 0.0;
|
||||
pObject->Power = 0.0;
|
||||
pObject->Instantaneous_Power = 0.0;
|
||||
pObject->Min_Actual_Value = 0.0;
|
||||
pObject->Max_Actual_Value = 100.0;
|
||||
pObject->Relinquish_Default = 0.0f;
|
||||
pObject->Power = 0.0f;
|
||||
pObject->Instantaneous_Power = 0.0f;
|
||||
pObject->Min_Actual_Value = 0.0f;
|
||||
pObject->Max_Actual_Value = 100.0f;
|
||||
pObject->Lighting_Command_Default_Priority = 16;
|
||||
pObject->Color_Override = false;
|
||||
pObject->Color_Reference.type = OBJECT_COLOR;
|
||||
|
||||
@@ -69,12 +69,15 @@ static void color_rgb_to_xy_gamma_correction(uint8_t r,
|
||||
This gamma correction is also applied to the screen
|
||||
of your computer or phone, thus we need this to create
|
||||
the same color on the light as on screen. */
|
||||
red = (red > 0.04045f) ? pow((red + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (red / 12.92f);
|
||||
green = (green > 0.04045f) ? pow((green + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (green / 12.92f);
|
||||
blue = (blue > 0.04045f) ? pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (blue / 12.92f);
|
||||
red = (red > 0.04045f)
|
||||
? (float)pow(((double)red + 0.055) / (1.0 + 0.055), 2.4)
|
||||
: (red / 12.92f);
|
||||
green = (green > 0.04045f)
|
||||
? (float)pow(((double)green + 0.055) / (1.0 + 0.055), 2.4)
|
||||
: (green / 12.92f);
|
||||
blue = (blue > 0.04045f)
|
||||
? (float)pow(((double)blue + 0.055) / (1.0 + 0.055), 2.4)
|
||||
: (blue / 12.92f);
|
||||
}
|
||||
|
||||
/* Convert the RGB values to XYZ using the
|
||||
@@ -189,12 +192,15 @@ static void color_rgb_from_xy_gamma_correction(uint8_t *red,
|
||||
|
||||
if (gamma_correction) {
|
||||
/* Apply reverse gamma correction */
|
||||
r = r <= 0.0031308f ? 12.92f * r
|
||||
: (1.0f + 0.055f) * pow(r, (1.0f / 2.4f)) - 0.055f;
|
||||
g = g <= 0.0031308f ? 12.92f * g
|
||||
: (1.0f + 0.055f) * pow(g, (1.0f / 2.4f)) - 0.055f;
|
||||
b = b <= 0.0031308f ? 12.92f * b
|
||||
: (1.0f + 0.055f) * pow(b, (1.0f / 2.4f)) - 0.055f;
|
||||
r = r <= 0.0031308f
|
||||
? 12.92f * r
|
||||
: (1.0f + 0.055f) * (float)pow((double)r, (1.0 / 2.4)) - 0.055f;
|
||||
g = g <= 0.0031308f
|
||||
? 12.92f * g
|
||||
: (1.0f + 0.055f) * (float)pow((double)g, (1.0 / 2.4)) - 0.055f;
|
||||
b = b <= 0.0031308f
|
||||
? 12.92f * b
|
||||
: (1.0f + 0.055f) * (float)pow((double)b, (1.0 / 2.4)) - 0.055f;
|
||||
}
|
||||
|
||||
/* Convert the RGB values to your color object
|
||||
|
||||
@@ -386,7 +386,8 @@ static void testLoadControlStateMachine(void)
|
||||
} else {
|
||||
zassert_true(false, NULL);
|
||||
}
|
||||
zassert_false(islessgreater(90.0f, level), "AO Present Value = %f", level);
|
||||
zassert_false(islessgreater(90.0f, level), "AO Present Value = %f",
|
||||
(double)level);
|
||||
/* FinishedSuccessfulShed */
|
||||
datetime_set_values(&bdatetime, 2007, 2, 27, 23, 0, 0, 0);
|
||||
Load_Control_State_Machine(0, &bdatetime);
|
||||
@@ -399,7 +400,8 @@ static void testLoadControlStateMachine(void)
|
||||
} else {
|
||||
zassert_true(false, NULL);
|
||||
}
|
||||
zassert_false(islessgreater(100.0f, level), "AO Present Value = %f", level);
|
||||
zassert_false(islessgreater(100.0f, level), "AO Present Value = %f",
|
||||
(double)level);
|
||||
}
|
||||
|
||||
#ifndef MAX_LOAD_CONTROLS
|
||||
|
||||
@@ -42,7 +42,7 @@ static void test_color_rgb_xy_gamma_unit(
|
||||
float y_coordinate,
|
||||
uint8_t brightness)
|
||||
{
|
||||
float test_x_coordinate = 0.0, test_y_coordinate = 0.0;
|
||||
float test_x_coordinate = 0.0f, test_y_coordinate = 0.0f;
|
||||
uint8_t test_brightness = 0;
|
||||
uint8_t test_red = 0, test_green = 0, test_blue = 0;
|
||||
|
||||
@@ -55,10 +55,10 @@ static void test_color_rgb_xy_gamma_unit(
|
||||
brightness);
|
||||
zassert_true(
|
||||
is_float_equal(x_coordinate, test_x_coordinate), "(x=%.3f,test_x=%.3f)",
|
||||
x_coordinate, test_x_coordinate);
|
||||
(double)x_coordinate, (double)test_x_coordinate);
|
||||
zassert_true(
|
||||
is_float_equal(y_coordinate, test_y_coordinate), "(y=%.3f,test_y=%.3f)",
|
||||
y_coordinate, test_y_coordinate);
|
||||
(double)y_coordinate, (double)test_y_coordinate);
|
||||
zassert_equal(
|
||||
brightness, test_brightness, "b=%u, test_b=%u", brightness,
|
||||
test_brightness);
|
||||
@@ -75,7 +75,7 @@ static void test_color_rgb_xy_unit(
|
||||
float y_coordinate,
|
||||
uint8_t brightness)
|
||||
{
|
||||
float test_x_coordinate = 0.0, test_y_coordinate = 0.0;
|
||||
float test_x_coordinate = 0.0f, test_y_coordinate = 0.0f;
|
||||
uint8_t test_brightness = 0;
|
||||
uint8_t test_red = 0, test_green = 0, test_blue = 0;
|
||||
|
||||
@@ -87,10 +87,10 @@ static void test_color_rgb_xy_unit(
|
||||
brightness);
|
||||
zassert_true(
|
||||
is_float_equal(x_coordinate, test_x_coordinate), "(x=%.3f,test_x=%.3f)",
|
||||
x_coordinate, test_x_coordinate);
|
||||
(double)x_coordinate, (double)test_x_coordinate);
|
||||
zassert_true(
|
||||
is_float_equal(y_coordinate, test_y_coordinate), "(y=%.3f,test_y=%.3f)",
|
||||
y_coordinate, test_y_coordinate);
|
||||
(double)y_coordinate, (double)test_y_coordinate);
|
||||
zassert_equal(
|
||||
brightness, test_brightness, "b=%u, test_b=%u", brightness,
|
||||
test_brightness);
|
||||
|
||||
Reference in New Issue
Block a user