Skip to content

Commit

Permalink
allow special indices for flash memory channel access; fix obk disabl…
Browse files Browse the repository at this point in the history
…e drivers
  • Loading branch information
openshwprojects committed Feb 25, 2023
1 parent dbdd209 commit caa8357
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/httpserver/hass.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ HassDeviceInfo* hass_init_device_info(ENTITY_TYPE type, int index, char* payload
bool flagavty = false;
flagavty = CFG_HasFlag(OBK_FLAG_NOT_PUBLISH_AVAILABILITY_SENSOR);
// if door sensor is running, then deep sleep will be invoked mostly, then we dont want availability
if (DRV_IsRunning("DoorSensor") == false) {
#ifndef OBK_DISABLE_ALL_DRIVERS
if (DRV_IsRunning("DoorSensor") == false)
#endif
{
if (!isSensor || !flagavty) {
cJSON_AddStringToObject(info->root, "avty_t", "~/connected"); //availability_topic, `online` value is broadcasted
}
Expand Down
20 changes: 20 additions & 0 deletions src/new_pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,22 @@ float CHANNEL_GetFloat(int ch) {
return g_channelValuesFloats[ch];
}
int CHANNEL_Get(int ch) {
// special channels
if (ch == SPECIAL_CHANNEL_LEDPOWER) {
return LED_GetEnableAll();
}
if (ch == SPECIAL_CHANNEL_BRIGHTNESS) {
return LED_GetDimmer();
}
if (ch == SPECIAL_CHANNEL_TEMPERATURE) {
return LED_GetTemperature();
}
if (ch >= SPECIAL_CHANNEL_BASECOLOR_FIRST && ch <= SPECIAL_CHANNEL_BASECOLOR_LAST) {
return 0; // TODO
}
if (ch >= SPECIAL_CHANNEL_FLASHVARS_FIRST && ch <= SPECIAL_CHANNEL_FLASHVARS_LAST) {
return HAL_FlashVars_GetChannelValue(ch - SPECIAL_CHANNEL_FLASHVARS_FIRST);
}
if (ch < 0 || ch >= CHANNEL_MAX) {
addLogAdv(LOG_ERROR, LOG_FEATURE_GENERAL, "CHANNEL_Get: Channel index %i is out of range <0,%i)\n\r", ch, CHANNEL_MAX);
return 0;
Expand Down Expand Up @@ -1014,6 +1030,10 @@ void CHANNEL_Set(int ch, int iVal, int iFlags) {
LED_SetBaseColorByIndex(ch - SPECIAL_CHANNEL_BASECOLOR_FIRST, iVal, 1);
return;
}
if (ch >= SPECIAL_CHANNEL_FLASHVARS_FIRST && ch <= SPECIAL_CHANNEL_FLASHVARS_LAST) {
HAL_FlashVars_SaveChannel(ch - SPECIAL_CHANNEL_FLASHVARS_FIRST, iVal);
return;
}
if (ch < 0 || ch >= CHANNEL_MAX) {
//if(bMustBeSilent==0) {
addLogAdv(LOG_ERROR, LOG_FEATURE_GENERAL, "CHANNEL_Set: Channel index %i is out of range <0,%i)\n\r", ch, CHANNEL_MAX);
Expand Down
5 changes: 5 additions & 0 deletions src/new_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ typedef enum {
#define SPECIAL_CHANNEL_BASECOLOR_WARM 137
#define SPECIAL_CHANNEL_BASECOLOR_LAST 137

// note: real limit here is MAX_RETAIN_CHANNELS
#define SPECIAL_CHANNEL_FLASHVARS_FIRST 200
#define SPECIAL_CHANNEL_FLASHVARS_LAST 264


#if PLATFORM_W800

typedef struct pinsState_s {
Expand Down

0 comments on commit caa8357

Please sign in to comment.