Add RGB pixel and brightness APIs, update Blinkt example (#1210)
* Added API to get the RGB pixel and brightness values from the blinkt interface. * Fixed Channel object for Color object present-value which does not use coercion. * Added API to the color-RGB library to convert from ASCII CSS color name to X,Y and brightness. * Converted the Blinkt example app to use the basic-server. Added a default color name command line option --color that accepts CSS color names. Set the color and brightness at startup. * Added vacancy timer for lights using timer object defaulted to 30m and started at startup.
This commit is contained in:
@@ -662,18 +662,6 @@ bool Channel_Write_Member_Value(
|
||||
wp_data->application_data_len = apdu_len;
|
||||
status = true;
|
||||
}
|
||||
} else if (
|
||||
(wp_data->object_type == OBJECT_COLOR) &&
|
||||
((wp_data->object_property == PROP_PRESENT_VALUE) ||
|
||||
(wp_data->object_property == PROP_DEFAULT_COLOR)) &&
|
||||
(wp_data->array_index == BACNET_ARRAY_ALL)) {
|
||||
apdu_len = bacnet_channel_value_coerce_data_encode(
|
||||
wp_data->application_data, wp_data->application_data_len, value,
|
||||
BACNET_APPLICATION_TAG_XY_COLOR);
|
||||
if (apdu_len != BACNET_STATUS_ERROR) {
|
||||
wp_data->application_data_len = apdu_len;
|
||||
status = true;
|
||||
}
|
||||
} else if (
|
||||
(wp_data->object_type == OBJECT_COLOR_TEMPERATURE) &&
|
||||
((wp_data->object_property == PROP_PRESENT_VALUE) ||
|
||||
@@ -761,8 +749,11 @@ static bool Channel_Write_Members(
|
||||
}
|
||||
debug_printf(
|
||||
"channel[%lu].Channel_Write_Member[%u] "
|
||||
"%s\n",
|
||||
"%s-%u %s %s\n",
|
||||
(unsigned long)object_instance, m,
|
||||
bactext_object_type_name(wp_data.object_type),
|
||||
wp_data.object_instance,
|
||||
bactext_property_name(wp_data.object_property),
|
||||
bactext_error_code_name(wp_data.error_code));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -490,6 +490,33 @@ unsigned color_rgb_from_ascii(
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert CSS color name to CIE xy coordinates and brightness
|
||||
* @param x_coordinate - return x of CIE xy 0.0..1.0
|
||||
* @param y_coordinate - return y of CIE xy 0.0..1.0
|
||||
* @param brightness - return brightness of the CIE xy color 0..255
|
||||
* @param name - CSS color name from W3C
|
||||
* @return true if color name was found, false if not found
|
||||
*/
|
||||
bool color_rgb_xy_from_ascii(
|
||||
float *x_coordinate,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness,
|
||||
const char *name)
|
||||
{
|
||||
bool status = false;
|
||||
uint8_t r = 0, g = 0, b = 0;
|
||||
unsigned index;
|
||||
|
||||
index = color_rgb_from_ascii(&r, &g, &b, name);
|
||||
if (index < color_rgb_count()) {
|
||||
color_rgb_to_xy(r, g, b, x_coordinate, y_coordinate, brightness);
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert sRGB from CIE xy and brightness
|
||||
* @param red - return R value of sRGB
|
||||
|
||||
@@ -59,6 +59,13 @@ BACNET_STACK_EXPORT
|
||||
unsigned color_rgb_from_ascii(
|
||||
uint8_t *red, uint8_t *green, uint8_t *blue, const char *name);
|
||||
BACNET_STACK_EXPORT
|
||||
bool color_rgb_xy_from_ascii(
|
||||
float *x_coordinate,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness,
|
||||
const char *name);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
const char *color_rgb_from_index(
|
||||
unsigned target_index, uint8_t *red, uint8_t *green, uint8_t *blue);
|
||||
BACNET_STACK_EXPORT
|
||||
|
||||
Reference in New Issue
Block a user