UNTESTED interim commit with refactoring

This commit is contained in:
2020-11-13 14:19:30 +03:00
parent 544252fb14
commit 118fd25186
24 changed files with 1373 additions and 592 deletions

View File

@@ -20,10 +20,7 @@ e-mail anklimov@gmail.com
#pragma once
#include "options.h"
#include "abstractout.h"
#define POLLING_SLOW 1
#define POLLING_FAST 2
#define POLLING_INT 3
#include "itemCmd.h"
#define S_NOTFOUND 0
#define S_SETnCMD 0
@@ -35,6 +32,7 @@ e-mail anklimov@gmail.com
#define S_MODE 6
#define S_HUE 7
#define S_SAT 8
#define S_TEMP 9
#define S_ADDITIONAL 64
#define CH_DIMMER 0 //DMX 1 ch
@@ -58,64 +56,14 @@ e-mail anklimov@gmail.com
#define CH_WHITE 127//
#define CMD_NUM 0
#define CMD_UNKNOWN -1
#define CMD_JSON -2
//#define CMD_RGB -3
//#define CMD_HSV -4
typedef char cmdstr[9];
const cmdstr commands_P[] PROGMEM =
{
"","ON","OFF","REST","TOGGLE","HALT","XON","XOFF","INCREASE","DECREASE",
"HEAT","COOL","AUTO","FAN_ONLY","DRY","STOP","HIGH","MEDIUM","LOW",
"TRUE","FALSE","ENABLED","DISABLED","RGB","HSV"
};
#define commandsNum sizeof(commands_P)/sizeof(cmdstr)
#define CMD_ON 1
#define CMD_OFF 2
#define CMD_RESTORE 3 //on only if was turned off by CMD_HALT
#define CMD_TOGGLE 4
#define CMD_HALT 5 //just Off
#define CMD_XON 6 //just on
#define CMD_XOFF 7 //off only if was previously turned on by CMD_XON
#define CMD_UP 8 //increase
#define CMD_DN 9 //decrease
#define CMD_HEAT 0xa
#define CMD_COOL 0xb
#define CMD_AUTO 0xc
#define CMD_FAN 0xd
#define CMD_DRY 0xe
#define CMD_STOP 0xf
#define CMD_HIGH 0x10 //AC fan leve
#define CMD_MED 0x11
#define CMD_LOW 0x12
#define CMD_ENABLED 0x13
#define CMD_DISABLED 0x14
#define CMD_TRUE 0x15
#define CMD_FALSE 0x16
#define CMD_RGB 0x17
#define CMD_HSV 0x18
//#define CMD_CURTEMP 0xf
#define CMD_MASK 0xff
#define FLAG_MASK 0xff00
#define SEND_COMMAND 0x100
#define SEND_PARAMETERS 0x200
#define SEND_RETRY 0x400
#define SEND_DEFFERED 0x800
#define ACTION_NEEDED 0x1000
#define ACTION_IN_PROCESS 0x2000
#define POLLING_SLOW 1
#define POLLING_FAST 2
#define POLLING_INT 3
//#define CMD_REPORT 32
#define I_TYPE 0 //Type of item
#define I_ARG 1 //Chanel-type depended argument or array of arguments (pin, address etc)
#define I_VAL 2 //Latest preset (int or array of presets)
@@ -140,71 +88,6 @@ extern short thermoSetCurTemp(char *name, float t);
int txt2cmd (char * payload);
enum itemStoreType {
ST_VOID = 0,
ST_PERCENTS = 1,
ST_HS = 2,
ST_HSV = 3,
ST_FLOAT_CELSIUS= 4,
ST_FLOAT_FARENHEIT= 5,
ST_RGB = 6,
ST_RGBW = 7,
ST_PERCENTS255 = 8,
ST_HSV255 = 9,
ST_INT32 = 10,
ST_UINT32 = 11,
ST_STRING = 12,
ST_FLOAT = 13,
ST_COMMAND = 15
};
#pragma pack(push, 1)
typedef union
{
long int aslong;
int32_t asInt32;
uint32_t asUint32;
char* asString;
float asfloat;
struct
{
uint8_t cmd_code;
uint8_t cmd_flag;
uint8_t cmd_effect;
uint8_t cmd_effect_param;
};
struct
{ uint8_t v;
uint8_t s;
uint16_t h:15;
uint16_t hsv_flag:1;
};
struct
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t w;//:7;
// uint8_t rgb_flag:1;
};
} itemStore;
class itemCmd
{
public:
itemStoreType type;
itemStore param;
itemCmd Percents(int i);
itemCmd Int(int32_t i);
itemCmd Int(uint32_t i);
itemCmd Cmd(uint8_t i);
char * toString(char * Buffer, int bufLen);
short toCmd();
} ;
#pragma pack(pop)
class Item
{
public:
@@ -226,6 +109,7 @@ class Item
int getArg(short n=0);
//int getVal(short n); //From VAL array. Negative if no array
long int getVal(); //From int val OR array
uint8_t getSubtype();
uint8_t getCmd();
long int getExt(); //From int val OR array
void setExt(long int par);
@@ -236,6 +120,7 @@ class Item
void setFlag (short flag);
void clearFlag (short flag);
void setVal(long int par);
void setSubtype(uint8_t par);
int Poll(int cause);
int SendStatus(int sendFlags);
int isActive();