mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-03-07 15:57:51 +01:00
add ability to change mired range
This commit is contained in:
@@ -70,8 +70,8 @@ float rgb_used_corr[3]; // RGB correction currently used
|
||||
int g_lightEnableAll = 0;
|
||||
|
||||
// the slider control in the UI emits values
|
||||
//in the range from 154-500 (defined
|
||||
//in homeassistant/util/color.py as HASS_COLOR_MIN and HASS_COLOR_MAX).
|
||||
// in the range from 154-500 (defined
|
||||
// in homeassistant/util/color.py as HASS_COLOR_MIN and HASS_COLOR_MAX).
|
||||
float led_temperature_min = HASS_TEMPERATURE_MIN;
|
||||
float led_temperature_max = HASS_TEMPERATURE_MAX;
|
||||
float led_temperature_current = HASS_TEMPERATURE_MIN;
|
||||
@@ -1311,6 +1311,15 @@ static commandResult_t lerpSpeed(const void *context, const char *cmd, const cha
|
||||
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
static commandResult_t ledRange(const void *context, const char *cmd, const char *args, int cmdFlags) {
|
||||
// Use tokenizer, so we can use variables (eg. $CH11 as variable)
|
||||
Tokenizer_TokenizeString(args, 0);
|
||||
|
||||
led_temperature_min = Tokenizer_GetArgFloat(0);
|
||||
led_temperature_max = Tokenizer_GetArgFloat(1);
|
||||
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
static commandResult_t setBrightness(const void *context, const char *cmd, const char *args, int cmdFlags) {
|
||||
float f;
|
||||
|
||||
@@ -1494,6 +1503,7 @@ void NewLED_InitCommands(){
|
||||
//cmddetail:"fn":"rgb_gamma_control","file":"cmnds/cmd_rgbGamma.c","requires":"",
|
||||
//cmddetail:"examples":"led_gammaCtrl on"}
|
||||
CMD_RegisterCommand("led_gammaCtrl", led_gamma_control, NULL);
|
||||
CMD_RegisterCommand("LEDRange", ledRange, NULL);
|
||||
}
|
||||
|
||||
void NewLED_RestoreSavedStateIfNeeded() {
|
||||
|
||||
@@ -124,8 +124,7 @@ enum EventCode {
|
||||
#define HASS_TEMPERATURE_MIN 154
|
||||
#define HASS_TEMPERATURE_MAX 500
|
||||
#define HASS_TEMPERATURE_CENTER ((HASS_TEMPERATURE_MAX+HASS_TEMPERATURE_MIN)/2)
|
||||
#define KELVIN_TEMPERATURE_MIN 2000
|
||||
#define KELVIN_TEMPERATURE_MAX 6500
|
||||
#define HASS_TO_KELVIN(x) (1000000 / (x))
|
||||
|
||||
// In general, LED can be in two modes:
|
||||
// - Temperature (Cool and Warm LEDs are on)
|
||||
@@ -222,6 +221,8 @@ OBK_Publish_Result LED_SendDimmerChange();
|
||||
OBK_Publish_Result sendTemperatureChange();
|
||||
OBK_Publish_Result LED_SendCurrentLightMode();
|
||||
void LED_ResetGlobalVariablesToDefaults();
|
||||
extern float led_temperature_min;
|
||||
extern float led_temperature_max;
|
||||
// cmd_test.c
|
||||
int CMD_InitTestCommands();
|
||||
// cmd_channels.c
|
||||
|
||||
@@ -769,14 +769,16 @@ int http_fn_index(http_request_t* request) {
|
||||
inputName = "pwm";
|
||||
|
||||
pwmValue = LED_GetTemperature();
|
||||
long pwmKelvin = 1000000 / pwmValue;
|
||||
long pwmKelvin = HASS_TO_KELVIN(pwmValue);
|
||||
long pwmKelvinMax = HASS_TO_KELVIN(led_temperature_min);
|
||||
long pwmKelvinMin = HASS_TO_KELVIN(led_temperature_max);
|
||||
|
||||
poststr(request, "<tr><td>");
|
||||
hprintf255(request, "<h5>LED Temperature Slider %s (%ld K) (Warm <--- ---> Cool)</h5>", activeStr, pwmKelvin);
|
||||
hprintf255(request, "<form class='r' action=\"index\" id=\"form%i\">", SPECIAL_CHANNEL_TEMPERATURE);
|
||||
|
||||
//(KELVIN_TEMPERATURE_MAX - KELVIN_TEMPERATURE_MIN) / (HASS_TEMPERATURE_MAX - HASS_TEMPERATURE_MIN) = 13
|
||||
hprintf255(request, "<input type=\"range\" step='13' min=\"%ld\" max=\"%ld\" ", KELVIN_TEMPERATURE_MIN, KELVIN_TEMPERATURE_MAX);
|
||||
hprintf255(request, "<input type=\"range\" step='13' min=\"%ld\" max=\"%ld\" ", pwmKelvinMin, pwmKelvinMax);
|
||||
hprintf255(request, "value=\"%ld\" onchange=\"submitTemperature(this);\"/>", pwmKelvin);
|
||||
|
||||
hprintf255(request, "<input type=\"hidden\" name=\"%sIndex\" value=\"%i\"/>", inputName, SPECIAL_CHANNEL_TEMPERATURE);
|
||||
|
||||
Reference in New Issue
Block a user