pull/360/head^2
sfeakes 2024-09-07 09:53:13 -05:00
parent eee110b043
commit 375f66437e
8 changed files with 47 additions and 11 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -157,6 +157,10 @@ void setColorLightsPanelVersion(uint8_t supported)
const char *light_mode_name(clight_type type, int index, emulation_type protocol)
{
if (index <= 0 || index > LIGHT_COLOR_OPTIONS ){
return "";
}
// Rename any modes depending on emulation type
if (protocol == ALLBUTTON) {
if (strcmp(_color_light_options[type][index],"Afternoon Skies") == 0) {
@ -192,6 +196,15 @@ bool isShowMode(const char *mode)
return false;
}
void set_currentlight_value(clight_detail *light, int index)
{
// We want to leave the last color, so if 0 don't do anything, but set to 0 if bad value
if (index < 0 || index > LIGHT_COLOR_OPTIONS)
light->currentValue = 0;
else if (index > 0 && index < LIGHT_COLOR_OPTIONS)
light->currentValue = index;
}
int build_color_lights_js(struct aqualinkdata *aqdata, char* buffer, int size)
{
memset(&buffer[0], 0, size);

View File

@ -27,7 +27,7 @@ typedef enum clight_type {
//const char *light_mode_name(clight_type type, int index);
const char *light_mode_name(clight_type type, int index, emulation_type protocol);
int build_color_lights_js(struct aqualinkdata *aqdata, char* buffer, int size);
void set_currentlight_value(clight_detail *light, int index);
//char *_color_light_options_[LIGHT_COLOR_TYPES][LIGHT_COLOR_OPTIONS][LIGHT_COLOR_NAME];

View File

@ -33,6 +33,7 @@
#include "aq_timer.h"
#include "aq_programmer.h"
#include "rs_msg_utils.h"
#include "color_lights.h"
//#define test_message "{\"type\": \"status\",\"version\": \"8157 REV MMM\",\"date\": \"09/01/16 THU\",\"time\": \"1:16 PM\",\"temp_units\": \"F\",\"air_temp\": \"96\",\"pool_temp\": \"86\",\"spa_temp\": \" \",\"battery\": \"ok\",\"pool_htr_set_pnt\": \"85\",\"spa_htr_set_pnt\": \"99\",\"freeze_protection\": \"off\",\"frz_protect_set_pnt\": \"0\",\"leds\": {\"pump\": \"on\",\"spa\": \"off\",\"aux1\": \"off\",\"aux2\": \"off\",\"aux3\": \"off\",\"aux4\": \"off\",\"aux5\": \"off\",\"aux6\": \"off\",\"aux7\": \"off\",\"pool_heater\": \"off\",\"spa_heater\": \"off\",\"solar_heater\": \"off\"}}"
//#define test_labels "{\"type\": \"aux_labels\",\"aux1_label\": \"Cleaner\",\"aux2_label\": \"Waterfall\",\"aux3_label\": \"Spa Blower\",\"aux4_label\": \"Pool Light\",\"aux5_label\": \"Spa Light\",\"aux6_label\": \"Unassigned\",\"aux7_label\": \"Unassigned\"}"
@ -706,7 +707,31 @@ printf("Pump Type %d\n",aqdata->pumps[i].pumpType);
length--;
length += sprintf(buffer+length, "}");
length += sprintf(buffer+length, ",\"light_program\":{" );
for (i=0; i < aqdata->num_lights; i++)
{
length += sprintf(buffer+length, "\"%s\": \"%s\",", aqdata->lights[i].button->name, light_mode_name(aqdata->lights[i].lightType, aqdata->lights[i].currentValue, RSSADAPTER) );
}
if (buffer[length-1] == ',')
length--;
length += sprintf(buffer+length, "}");
/*
for (i=0; i < aqdata->num_lights; i++)
{
length += sprintf(buffer+length, ",\"Plight_%d\":{\"name\":\"%s\",\"id\":\"%s\", \"type\":\"%d\", \"value\":\"%d\", \"state\":\"%s\"}",
i+1,
aqdata->lights[i].button->label,
aqdata->lights[i].button->name,
aqdata->lights[i].lightType,
aqdata->lights[i].currentValue,
LED2text(aqdata->lights[i].RSSDstate)
);
}
*/
//if (buffer[length-1] == ',')
// length--;
//length += sprintf(buffer+length, "}");
length += sprintf(buffer+length, "}" );

View File

@ -364,17 +364,9 @@ bool process_rssadapter_packet(unsigned char *packet, int length, struct aqualin
#endif
// Set the color index. (packet[6] - RSSD_COLOR_LIGHT_OFFSET)-1
if (aq_data->lights[i].lightType != LC_DIMMER) {
int color_index = (packet[6] - RSSD_COLOR_LIGHT_OFFSET);
if (color_index <= 0 || color_index > LIGHT_COLOR_OPTIONS)
color_index = 0;
//LOG(RSSA_LOG,LOG_DEBUG,"Color index %d\n",color_index);
aq_data->lights[i].currentValue = color_index;
set_currentlight_value(&aq_data->lights[i], (packet[6] - RSSD_COLOR_LIGHT_OFFSET));
} else if (aq_data->lights[i].lightType == LC_DIMMER) {
int dimmer_index = (packet[6] - RSSD_DIMMER_LIGHT_OFFSET) / 25;
if (dimmer_index < 0 || dimmer_index > 4)
dimmer_index = 0;
//LOG(RSSA_LOG,LOG_DEBUG,"Dimmer index %d\n",dimmer_index);
aq_data->lights[i].currentValue = dimmer_index;
set_currentlight_value(&aq_data->lights[i], (packet[6] - RSSD_DIMMER_LIGHT_OFFSET) / 25);
}
}
}

View File

@ -2166,6 +2166,12 @@
for (var obj in data.timer_durations) {
setTileOnText(obj.toString(),"Timer "+toHoursAndMinutes(data.timer_durations[obj]));
}
for (var obj in data.light_program) {
if (data.light_program[obj] != "") {
setTileOnText(obj.toString(),data.light_program[obj]);
}
}
if (data.swg_boost_msg != null ) {