mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' of github.com:arendst/Tasmota into pr_tm1638
This commit is contained in:
commit
5aeb4c0475
|
@ -14,7 +14,7 @@
|
|||
#define CONFIG_HAP_HTTP_STACK_SIZE 12288
|
||||
#define CONFIG_HAP_HTTP_SERVER_PORT 5556 // 80 for normal webserver
|
||||
#define CONFIG_HAP_HTTP_CONTROL_PORT 32859
|
||||
#define CONFIG_HAP_HTTP_MAX_OPEN_SOCKETS 6
|
||||
#define CONFIG_HAP_HTTP_MAX_OPEN_SOCKETS 5 // 6
|
||||
#define CONFIG_HAP_HTTP_MAX_URI_HANDLERS 16
|
||||
|
||||
#endif /* ESP_HAP_CONFIG_H_ */
|
||||
|
|
|
@ -39,6 +39,21 @@ hap_char_t *hap_char_brightness_create(int brightness)
|
|||
return hc;
|
||||
}
|
||||
|
||||
/* Char: Brightness */
|
||||
hap_char_t *hap_char_wattage_create(float watts)
|
||||
{
|
||||
hap_char_t *hc = hap_char_float_create(HAP_CHAR_UUID_CURRENT_AMBIENT_LIGHT_LEVEL,
|
||||
HAP_CHAR_PERM_PR | HAP_CHAR_PERM_PW | HAP_CHAR_PERM_EV, watts);
|
||||
if (!hc) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hap_char_float_set_constraints(hc, -10000.0, 10000.0, 1);
|
||||
hap_char_add_unit(hc, HAP_CHAR_UNIT_LUX);
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
||||
/* Char: Cooling Threshold Temperature */
|
||||
hap_char_t *hap_char_cooling_threshold_temperature_create(float cooling_threshold_temp)
|
||||
{
|
||||
|
@ -1284,7 +1299,7 @@ hap_char_t *hap_char_relative_humidity_humidifier_threshold_create(float rel_hum
|
|||
}
|
||||
|
||||
hap_char_float_set_constraints(hc, 0.0, 100.0, 1.0);
|
||||
hap_char_add_unit(hc, HAP_CHAR_UNIT_PERCENTAGE);
|
||||
hap_char_add_unit(hc, HAP_CHAR_UNIT_LUX);
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
|
|
@ -142,6 +142,7 @@ extern "C" {
|
|||
#define HAP_CHAR_UUID_REMAINING_DURATION "D4"
|
||||
#define HAP_CHAR_UUID_VALVE_TYPE "D5"
|
||||
#define HAP_CHAR_UUID_IS_CONFIGURED "D6"
|
||||
#define HAP_CHAR_UUID_WATTAGE "DC"
|
||||
#define HAP_CHAR_UUID_PRODUCT_DATA "220"
|
||||
|
||||
/** Create Brightness Characteristic
|
||||
|
@ -1415,6 +1416,8 @@ hap_char_t *hap_char_air_particulate_density_create(float air_particulate_densit
|
|||
*/
|
||||
hap_char_t *hap_char_air_particulate_size_create(uint8_t air_particulate_size);
|
||||
|
||||
hap_char_t *hap_char_wattage_create(float watts);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -419,6 +419,22 @@ err:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
hap_serv_t *hap_serv_wattage_create(float curr_watts)
|
||||
{
|
||||
hap_serv_t *hs = hap_serv_create(HAP_SERV_UUID_LIGHT_SENSOR);
|
||||
if (!hs) {
|
||||
return NULL;
|
||||
}
|
||||
if (hap_serv_add_char(hs, hap_char_wattage_create(curr_watts)) != HAP_SUCCESS) {
|
||||
goto err;
|
||||
}
|
||||
return hs;
|
||||
err:
|
||||
hap_serv_delete(hs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
hap_serv_t *hap_serv_temperature_sensor_create(float curr_temp)
|
||||
{
|
||||
hap_serv_t *hs = hap_serv_create(HAP_SERV_UUID_TEMPERATURE_SENSOR);
|
||||
|
@ -703,4 +719,3 @@ err:
|
|||
hap_serv_delete(hs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ extern "C" {
|
|||
#define HAP_SERV_UUID_VALVE "D0"
|
||||
#define HAP_SERV_UUID_FAUCET "D7"
|
||||
|
||||
|
||||
/** Create Accessory Information Service
|
||||
*
|
||||
* This API will create the Accessory Information Service with the mandatory
|
||||
|
@ -553,6 +554,9 @@ hap_serv_t *hap_serv_valve_create(uint8_t active, uint8_t in_use, uint8_t valve_
|
|||
*/
|
||||
hap_serv_t *hap_serv_faucet_create(uint8_t active);
|
||||
|
||||
|
||||
hap_serv_t *hap_serv_wattage_create(float curr_watts);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -144,12 +144,10 @@ int hap_platform_keystore_delete_namespace(const char *part_name, const char *na
|
|||
while (true) {
|
||||
File entry = fp.openNextFile();
|
||||
if (!entry) break;
|
||||
char fp[48];
|
||||
strcpy(fp,path);
|
||||
strcat(fp, "/");
|
||||
strcat(fp, entry.name());
|
||||
ffsp->remove(fp);
|
||||
char p[48];
|
||||
strcpy(p,entry.name());
|
||||
entry.close();
|
||||
ffsp->remove(p);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -157,7 +155,6 @@ int hap_platform_keystore_delete_namespace(const char *part_name, const char *na
|
|||
|
||||
// last resort only
|
||||
int hap_platfrom_keystore_erase_partition(const char *part_name) {
|
||||
// LITTLEFS.format();
|
||||
char path[48];
|
||||
strcpy(path, "/");
|
||||
strcat(path, part_name);
|
||||
|
@ -166,17 +163,23 @@ if (fp.isDirectory()) {
|
|||
while (true) {
|
||||
File entry = fp.openNextFile();
|
||||
if (!entry) break;
|
||||
char fp[48];
|
||||
strcpy(fp,path);
|
||||
strcat(fp, "/");
|
||||
strcat(fp, entry.name());
|
||||
if (entry.isDirectory()) {
|
||||
hap_platform_keystore_delete_namespace(part_name, entry.name());
|
||||
ffsp->rmdir(fp);
|
||||
} else {
|
||||
ffsp->remove(fp);
|
||||
const char *ep = entry.name();
|
||||
if (*ep=='/') ep++;
|
||||
char *lcp = strrchr(ep,'/');
|
||||
if (lcp) {
|
||||
ep = lcp + 1;
|
||||
}
|
||||
entry.close();
|
||||
char p[48];
|
||||
strcpy(p,entry.name());
|
||||
if (entry.isDirectory()) {
|
||||
hap_platform_keystore_delete_namespace(part_name, ep);
|
||||
entry.close();
|
||||
ffsp->rmdir(p);
|
||||
} else {
|
||||
entry.close();
|
||||
ffsp->remove(p);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -59,11 +59,11 @@ extern uint32_t Ext_UpdVar(char *vname, float *fvar, uint32_t mode);
|
|||
|
||||
#define MAX_HAP_DEFS 16
|
||||
struct HAP_DESC {
|
||||
char hap_name[16];
|
||||
char var_name[16];
|
||||
char var2_name[16];
|
||||
char var3_name[16];
|
||||
char var4_name[16];
|
||||
char hap_name[24];
|
||||
char var_name[12];
|
||||
char var2_name[12];
|
||||
char var3_name[12];
|
||||
char var4_name[12];
|
||||
uint8_t hap_cid;
|
||||
uint8_t type;
|
||||
hap_acc_t *accessory;
|
||||
|
@ -148,45 +148,66 @@ static int accessory_identify(hap_acc_t *ha)
|
|||
return HAP_SUCCESS;
|
||||
}
|
||||
|
||||
const struct HAP_CHAR_TABLE {
|
||||
char stype[4];
|
||||
char ntype;
|
||||
int8_t index;
|
||||
} hap_rtab[] = {
|
||||
{HAP_CHAR_UUID_CURRENT_TEMPERATURE,'f',0},
|
||||
{HAP_CHAR_UUID_CURRENT_RELATIVE_HUMIDITY,'f',0},
|
||||
{HAP_CHAR_UUID_CURRENT_AMBIENT_LIGHT_LEVEL,'f',0},
|
||||
{HAP_CHAR_UUID_BATTERY_LEVEL,'u',0},
|
||||
{HAP_CHAR_UUID_STATUS_LOW_BATTERY,'b',1},
|
||||
{HAP_CHAR_UUID_CHARGING_STATE,'b',2},
|
||||
{HAP_CHAR_UUID_ON,'b',0},
|
||||
{HAP_CHAR_UUID_HUE,'f',1},
|
||||
{HAP_CHAR_UUID_SATURATION,'f',2},
|
||||
{HAP_CHAR_UUID_BRIGHTNESS,'u',3},
|
||||
{HAP_CHAR_UUID_COLOR_TEMPERATURE,'u',0},
|
||||
{HAP_CHAR_UUID_CONTACT_SENSOR_STATE,'u',0},
|
||||
{HAP_CHAR_UUID_WATTAGE,'f',0}
|
||||
};
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/* A dummy callback for handling a write on the "On" characteristic of Outlet.
|
||||
* In an actual accessory, this should control the hardware
|
||||
*/
|
||||
static int sensor_write(hap_write_data_t write_data[], int count, void *serv_priv, void *write_priv, uint32_t index) {
|
||||
int i, ret = HAP_SUCCESS;
|
||||
float fvar;
|
||||
hap_write_data_t *write;
|
||||
for (i = 0; i < count; i++) {
|
||||
write = &write_data[i];
|
||||
bool found = false;
|
||||
const char *hcp = hap_char_get_type_uuid(write->hc);
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_ON)) {
|
||||
//ESP_LOGI(TAG, "Received Write. Outlet %s", write->val.b ? "On" : "Off");
|
||||
ESP_LOG_LEVEL(ESP_LOG_INFO, TAG, "Received Write. Outlet %s", write->val.b ? "On" : "Off");
|
||||
hap_char_update_val(write->hc, &(write->val));
|
||||
float fvar = write->val.b;
|
||||
Ext_UpdVar(hap_devs[index].var_name, &fvar, 1);
|
||||
*(write->status) = HAP_STATUS_SUCCESS;
|
||||
} else if (!strcmp(hcp, HAP_CHAR_UUID_HUE)) {
|
||||
hap_char_update_val(write->hc, &(write->val));
|
||||
float fvar = write->val.f;
|
||||
Ext_UpdVar(hap_devs[index].var2_name, &fvar, 1);
|
||||
*(write->status) = HAP_STATUS_SUCCESS;
|
||||
} else if (!strcmp(hcp, HAP_CHAR_UUID_SATURATION)) {
|
||||
hap_char_update_val(write->hc, &(write->val));
|
||||
float fvar = write->val.f;
|
||||
Ext_UpdVar(hap_devs[index].var3_name, &fvar, 1);
|
||||
*(write->status) = HAP_STATUS_SUCCESS;
|
||||
} else if (!strcmp(hcp, HAP_CHAR_UUID_BRIGHTNESS)) {
|
||||
hap_char_update_val(write->hc, &(write->val));
|
||||
float fvar = write->val.u;
|
||||
Ext_UpdVar(hap_devs[index].var4_name, &fvar, 1);
|
||||
*(write->status) = HAP_STATUS_SUCCESS;
|
||||
} else {
|
||||
for (uint32_t cnt = 0; cnt < ARRAY_SIZE(hap_rtab); cnt++ ) {
|
||||
if (!strcmp(hcp, hap_rtab[cnt].stype)) {
|
||||
hap_char_update_val(write->hc, &(write->val));
|
||||
switch (hap_rtab[cnt].ntype) {
|
||||
case 'f': fvar = write->val.f; break;
|
||||
case 'u': fvar = write->val.u; break;
|
||||
case 'b': fvar = write->val.b; break;
|
||||
}
|
||||
switch (hap_rtab[cnt].index) {
|
||||
case 0: Ext_UpdVar(hap_devs[index].var_name, &fvar, 1);break;
|
||||
case 1: Ext_UpdVar(hap_devs[index].var2_name, &fvar, 1);break;
|
||||
case 2: Ext_UpdVar(hap_devs[index].var3_name, &fvar, 1);break;
|
||||
case 3: Ext_UpdVar(hap_devs[index].var4_name, &fvar, 1);break;
|
||||
}
|
||||
*(write->status) = HAP_STATUS_SUCCESS;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
*(write->status) = HAP_STATUS_RES_ABSENT;
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// common read routine
|
||||
static int sensor_read(hap_char_t *hc, hap_status_t *status_code, void *serv_priv, void *read_priv, uint32_t index) {
|
||||
hap_val_t new_val;
|
||||
|
@ -200,61 +221,123 @@ static int sensor_read(hap_char_t *hc, hap_status_t *status_code, void *serv_pri
|
|||
|
||||
printf("read values %s\n", hcp );
|
||||
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_CURRENT_TEMPERATURE)
|
||||
|| !strcmp(hcp, HAP_CHAR_UUID_CURRENT_RELATIVE_HUMIDITY)
|
||||
|| !strcmp(hcp, HAP_CHAR_UUID_CURRENT_AMBIENT_LIGHT_LEVEL)
|
||||
) {
|
||||
|
||||
Ext_UpdVar(hap_devs[index].var_name, &fvar, 0);
|
||||
new_val.f = fvar;
|
||||
for (uint32_t cnt = 0; cnt < ARRAY_SIZE(hap_rtab); cnt++ ) {
|
||||
if (!strcmp(hcp, hap_rtab[cnt].stype)) {
|
||||
switch (hap_rtab[cnt].index) {
|
||||
case 0: Ext_UpdVar(hap_devs[index].var_name, &fvar, 0);break;
|
||||
case 1: Ext_UpdVar(hap_devs[index].var2_name, &fvar, 0);break;
|
||||
case 2: Ext_UpdVar(hap_devs[index].var3_name, &fvar, 0);break;
|
||||
case 3: Ext_UpdVar(hap_devs[index].var4_name, &fvar, 0);break;
|
||||
}
|
||||
switch (hap_rtab[cnt].ntype) {
|
||||
case 'f': new_val.f = fvar; break;
|
||||
case 'u': new_val.u = fvar; break;
|
||||
case 'b': new_val.b = fvar; break;
|
||||
}
|
||||
hap_char_update_val(hc, &new_val);
|
||||
*status_code = HAP_STATUS_SUCCESS;
|
||||
}
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_ON)) {
|
||||
Ext_UpdVar(hap_devs[index].var_name, &fvar, 0);
|
||||
new_val.b = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
*status_code = HAP_STATUS_SUCCESS;
|
||||
}
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_HUE)) {
|
||||
Ext_UpdVar(hap_devs[index].var2_name, &fvar, 0);
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
*status_code = HAP_STATUS_SUCCESS;
|
||||
}
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_SATURATION)) {
|
||||
Ext_UpdVar(hap_devs[index].var3_name, &fvar, 0);
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
*status_code = HAP_STATUS_SUCCESS;
|
||||
}
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_BRIGHTNESS)) {
|
||||
Ext_UpdVar(hap_devs[index].var4_name, &fvar, 0);
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
*status_code = HAP_STATUS_SUCCESS;
|
||||
}
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_BATTERY_LEVEL)) {
|
||||
Ext_UpdVar(hap_devs[index].var_name, &fvar, 0);
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
*status_code = HAP_STATUS_SUCCESS;
|
||||
}
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_STATUS_LOW_BATTERY)) {
|
||||
Ext_UpdVar(hap_devs[index].var2_name, &fvar, 0);
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
*status_code = HAP_STATUS_SUCCESS;
|
||||
}
|
||||
if (!strcmp(hcp, HAP_CHAR_UUID_CHARGING_STATE)) {
|
||||
Ext_UpdVar(hap_devs[index].var3_name, &fvar, 0);
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
*status_code = HAP_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
return HAP_SUCCESS;
|
||||
}
|
||||
|
||||
// update values every 500 ms
|
||||
void hap_update_from_vars(void) {
|
||||
float fvar;
|
||||
hap_char_t *hc;
|
||||
hap_val_t new_val;
|
||||
for (uint32_t cnt = 0; cnt < hk_services; cnt++) {
|
||||
switch (hap_devs[cnt].hap_cid) {
|
||||
case HAP_CID_SENSOR:
|
||||
switch (hap_devs[cnt].type) {
|
||||
case 0:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_CURRENT_TEMPERATURE);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_CURRENT_RELATIVE_HUMIDITY);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_CURRENT_AMBIENT_LIGHT_LEVEL);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_BATTERY_LEVEL);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_STATUS_LOW_BATTERY);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var2_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_STATUS_LOW_BATTERY);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var3_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_CURRENT_AMBIENT_LIGHT_LEVEL);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_CONTACT_SENSOR_STATE);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HAP_CID_OUTLET:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_ON);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.b = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case HAP_CID_LIGHTING:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_ON);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.b = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_HUE);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var2_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_SATURATION);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var3_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_BRIGHTNESS);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var4_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#define HAP_READ hap_char_t *hc, hap_status_t *status_code, void *serv_priv, void *read_priv) { return sensor_read(hc, status_code, serv_priv, read_priv
|
||||
|
||||
static int sensor_read1(HAP_READ, 0);}
|
||||
|
@ -377,6 +460,8 @@ uint32_t str2c(char **sp, char *vp, uint32_t len) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
extern char *GetFName();
|
||||
|
||||
/*The main thread for handling the Smart Outlet Accessory */
|
||||
static void smart_outlet_thread_entry(void *p) {
|
||||
/* Initialize the HAP core */
|
||||
|
@ -385,7 +470,8 @@ static void smart_outlet_thread_entry(void *p) {
|
|||
hap_acc_t *accessory;
|
||||
|
||||
hap_acc_cfg_t cfg = {
|
||||
.name = "Tasmota-Bridge",
|
||||
//.name = "Tasmota-Bridge",
|
||||
.name = GetFName(),
|
||||
.manufacturer = "Tasmota",
|
||||
.model = "Bridge",
|
||||
.serial_num = "001122334455",
|
||||
|
@ -462,7 +548,6 @@ static void smart_outlet_thread_entry(void *p) {
|
|||
/* Create accessory object */
|
||||
hap_devs[index].accessory = hap_acc_create(&hap_cfg);
|
||||
/* Add a dummy Product Data */
|
||||
uint8_t product_data[] = {'E','S','P','3','2','H','A','P'};
|
||||
hap_acc_add_product_data(hap_devs[index].accessory, product_data, sizeof(product_data));
|
||||
|
||||
int ret;
|
||||
|
@ -500,6 +585,8 @@ static void smart_outlet_thread_entry(void *p) {
|
|||
hap_devs[index].service = hap_serv_battery_service_create(fvar, fvar1, fvar2);
|
||||
}
|
||||
break;
|
||||
case 4: hap_devs[index].service = hap_serv_wattage_create(fvar); break;
|
||||
case 5: hap_devs[index].service = hap_serv_contact_sensor_create(fvar); break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -513,7 +600,7 @@ static void smart_outlet_thread_entry(void *p) {
|
|||
hap_set_write(hap_devs[index].service, index);
|
||||
|
||||
/* Get pointer to the outlet in use characteristic which we need to monitor for state changes */
|
||||
hap_char_t *outlet_in_use = hap_serv_get_char_by_uuid(hap_devs[index].service, HAP_CHAR_UUID_OUTLET_IN_USE);
|
||||
outlet_in_use = hap_serv_get_char_by_uuid(hap_devs[index].service, HAP_CHAR_UUID_OUTLET_IN_USE);
|
||||
|
||||
/* Add the Outlet Service to the Accessory Object */
|
||||
hap_acc_add_serv(hap_devs[index].accessory, hap_devs[index].service);
|
||||
|
@ -565,13 +652,8 @@ nextline:
|
|||
/* Enable Hardware MFi authentication (applicable only for MFi variant of SDK) */
|
||||
hap_enable_mfi_auth(HAP_MFI_AUTH_HW);
|
||||
|
||||
/* Initialize Wi-Fi */
|
||||
//app_wifi_init();
|
||||
|
||||
/* After all the initializations are done, start the HAP core */
|
||||
hap_start();
|
||||
/* Start Wi-Fi */
|
||||
//app_wifi_start(portMAX_DELAY);
|
||||
|
||||
int32_t io_num = OUTLET_IN_USE_GPIO;
|
||||
if (io_num >= 0) {
|
||||
|
@ -597,93 +679,16 @@ nextline:
|
|||
}
|
||||
} else {
|
||||
// vTaskDelete(NULL);
|
||||
// update values every 100 ms
|
||||
while (1) {
|
||||
delay(100);
|
||||
float fvar;
|
||||
hap_char_t *hc;
|
||||
hap_val_t new_val;
|
||||
for (uint32_t cnt = 0; cnt < hk_services; cnt++) {
|
||||
switch (hap_devs[cnt].hap_cid) {
|
||||
case HAP_CID_SENSOR:
|
||||
switch (hap_devs[cnt].type) {
|
||||
case 0:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_CURRENT_TEMPERATURE);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_CURRENT_RELATIVE_HUMIDITY);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_CURRENT_AMBIENT_LIGHT_LEVEL);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_BATTERY_LEVEL);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_STATUS_LOW_BATTERY);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var2_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_STATUS_LOW_BATTERY);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var3_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HAP_CID_OUTLET:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_ON);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.b = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
case HAP_CID_LIGHTING:
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_ON);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var_name, &fvar, 0)) {
|
||||
new_val.b = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_HUE);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var2_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_SATURATION);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var3_name, &fvar, 0)) {
|
||||
new_val.f = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
hc = hap_serv_get_char_by_uuid(hap_devs[cnt].service, HAP_CHAR_UUID_BRIGHTNESS);
|
||||
if (Ext_UpdVar(hap_devs[cnt].var4_name, &fvar, 0)) {
|
||||
new_val.u = fvar;
|
||||
hap_char_update_val(hc, &new_val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
delay(500);
|
||||
// hap_update_from_vars();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define HK_PASSCODE "111-11-111"
|
||||
int hap_loop_stop(void);
|
||||
extern void Ext_toLog(char *str);
|
||||
|
||||
void homekit_main(char *desc, uint32_t flag ) {
|
||||
if (desc) {
|
||||
|
@ -710,10 +715,14 @@ void homekit_main(char *desc, uint32_t flag ) {
|
|||
hk_desc = cp;
|
||||
} else {
|
||||
if (flag == 99) {
|
||||
hap_loop_stop();
|
||||
hap_reset_to_factory();
|
||||
} else if (flag == 98) {
|
||||
hap_loop_stop();
|
||||
// is just the folder in wrapper
|
||||
hap_platfrom_keystore_erase_partition(hap_platform_keystore_get_nvs_partition_name());
|
||||
} else {
|
||||
// not yet implemented
|
||||
hap_stop();
|
||||
hap_loop_stop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
* Use online command StateText to translate ON, OFF, HOLD and TOGGLE.
|
||||
* Use online command Prefix to translate cmnd, stat and tele.
|
||||
*
|
||||
* Updated until v9.3.1.1
|
||||
* Last update - 9.3.1.1 (17.03.2021)
|
||||
\*********************************************************************/
|
||||
|
||||
#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English)
|
||||
|
||||
// https://www.science.co.il/language/Locale-codes.php
|
||||
#define LANGUAGE_LCID 1040
|
||||
// HTML (ISO 639-1) Language Code
|
||||
#define D_HTML_LANGUAGE "it"
|
||||
|
@ -798,8 +798,8 @@
|
|||
#define D_SENSOR_NEOPOOL_TX "NeoPool - TX"
|
||||
#define D_SENSOR_NEOPOOL_RX "NeoPool - RX"
|
||||
#define D_SENSOR_VL53L0X_XSHUT "VL53L0X XSHUT"
|
||||
#define D_NEW_ADDRESS "Cambio di indirizzo a"
|
||||
#define D_OUT_OF_RANGE "Fuori dal limite"
|
||||
#define D_NEW_ADDRESS "Imposta indirizzo a"
|
||||
#define D_OUT_OF_RANGE "Fuori limite"
|
||||
#define D_SENSOR_DETECTED "rilevato"
|
||||
|
||||
// Units
|
||||
|
|
|
@ -410,11 +410,13 @@ const uint16_t kGpioNiceList[] PROGMEM = {
|
|||
AGPIO(GPIO_SDCARD_CS),
|
||||
#endif // USE_SDCARD
|
||||
#endif // USE_SPI
|
||||
|
||||
AGPIO(GPIO_SSPI_MISO), // Software SPI Master Input Client Output
|
||||
AGPIO(GPIO_SSPI_MOSI), // Software SPI Master Output Client Input
|
||||
AGPIO(GPIO_SSPI_SCLK), // Software SPI Serial Clock
|
||||
AGPIO(GPIO_SSPI_CS), // Software SPI Chip Select
|
||||
AGPIO(GPIO_SSPI_DC), // Software SPI Data or Command
|
||||
|
||||
#ifdef USE_DISPLAY
|
||||
#ifdef USE_DISPLAY_ILI9341
|
||||
AGPIO(GPIO_ILI9341_CS),
|
||||
|
@ -422,7 +424,6 @@ const uint16_t kGpioNiceList[] PROGMEM = {
|
|||
#ifdef USE_XPT2046
|
||||
AGPIO(GPIO_XPT2046_CS), // XPT2046 SPI Chip Select
|
||||
#endif
|
||||
|
||||
#endif // USE_DISPLAY_ILI9341
|
||||
#ifdef USE_DISPLAY_ILI9488
|
||||
AGPIO(GPIO_ILI9488_CS),
|
||||
|
|
|
@ -2515,9 +2515,12 @@ chknext:
|
|||
if (!TasmotaGlobal.global_state.wifi_down) {
|
||||
// erase nvs
|
||||
lp = GetNumericArgument(lp + 4, OPER_EQU, &fvar, gv);
|
||||
|
||||
homekit_main(0, fvar);
|
||||
// restart homekit
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
if (fvar >= 98) {
|
||||
glob_script_mem.homekit_running == false;
|
||||
}
|
||||
|
||||
}
|
||||
lp++;
|
||||
len = 0;
|
||||
|
@ -3589,13 +3592,51 @@ extern "C" {
|
|||
uint32_t Ext_UpdVar(char *vname, float *fvar, uint32_t mode) {
|
||||
return UpdVar(vname, fvar, mode);
|
||||
}
|
||||
void Ext_toLog(char *str) {
|
||||
toLog(str);
|
||||
}
|
||||
|
||||
char *GetFName(void) {
|
||||
return SettingsText(SET_FRIENDLYNAME1);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t UpdVar(char *vname, float *fvar, uint32_t mode) {
|
||||
uint8_t type;
|
||||
uint8_t index;
|
||||
if (*vname == '@') {
|
||||
vname++;
|
||||
type = *vname;
|
||||
vname++;
|
||||
index = (*vname & 0x0f);
|
||||
if (index < 1) index = 1;
|
||||
if (index > 9) index = 9;
|
||||
switch (type) {
|
||||
case 'p':
|
||||
if (mode) {
|
||||
// set power
|
||||
ExecuteCommandPower(index, *fvar, SRC_BUTTON);
|
||||
return 0;
|
||||
} else {
|
||||
// read power
|
||||
*fvar = bitRead(TasmotaGlobal.power, index - 1);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
*fvar = SwitchLastState(index - 1);
|
||||
return 1;
|
||||
break;
|
||||
case 'b':
|
||||
*fvar = Button.last_state[index - 1];
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
struct T_INDEX ind;
|
||||
uint8_t vtype;
|
||||
float res = *fvar;
|
||||
uint8_t index;
|
||||
isvar(vname, &vtype, &ind, fvar, 0, 0);
|
||||
if (vtype != VAR_NV) {
|
||||
// found variable as result
|
||||
|
@ -3604,7 +3645,7 @@ int32_t UpdVar(char *vname, float *fvar, uint32_t mode) {
|
|||
// set var
|
||||
index = glob_script_mem.type[ind.index].index;
|
||||
glob_script_mem.fvars[index] = res;
|
||||
SetChanged(ind.index);
|
||||
glob_script_mem.type[ind.index].bits.changed = 1;
|
||||
return 0;
|
||||
} else {
|
||||
// get var
|
||||
|
@ -3724,13 +3765,11 @@ void Replace_Cmd_Vars(char *srcbuf, uint32_t srcsize, char *dstbuf, uint32_t dst
|
|||
dstbuf[count] = 0;
|
||||
}
|
||||
|
||||
|
||||
void toLog(const char *str) {
|
||||
if (!str) return;
|
||||
AddLog(LOG_LEVEL_INFO, str);
|
||||
}
|
||||
|
||||
|
||||
void toLogN(const char *cp, uint8_t len) {
|
||||
if (!cp) return;
|
||||
char str[32];
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(USE_I2C) || defined(USE_SPI)
|
||||
#ifdef USE_DISPLAY
|
||||
|
||||
#define XDRV_13 13
|
||||
|
@ -1601,7 +1600,9 @@ void DisplayInitDriver(void)
|
|||
Display_Text_From_File("/display.ini");
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_GRAPH
|
||||
for (uint8_t count = 0; count < NUM_GRAPHS; count++) { graph[count] = 0; }
|
||||
#endif
|
||||
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
|
||||
|
||||
|
@ -1945,7 +1946,7 @@ void CmndDisplayFont(void)
|
|||
|
||||
void CmndDisplayILIMOde(void)
|
||||
{
|
||||
if ((XdrvMailbox.payload >= 1) && (XdrvMailbox.payload < 16)) {
|
||||
if ((XdrvMailbox.payload >= 1) && (XdrvMailbox.payload <= 7)) {
|
||||
Settings.display_options.ilimode = XdrvMailbox.payload;
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
}
|
||||
|
@ -2051,8 +2052,9 @@ void CmndDisplayRows(void)
|
|||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* optional drivers
|
||||
* Optional drivers
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef USE_TOUCH_BUTTONS
|
||||
// very limited path size, so, add .jpg
|
||||
void draw_picture(char *path, uint32_t xp, uint32_t yp, uint32_t xs, uint32_t ys, uint32_t ocol, bool inverted) {
|
||||
|
@ -2073,7 +2075,7 @@ char ppath[16];
|
|||
}
|
||||
Draw_RGB_Bitmap(ppath, xp, yp, inverted);
|
||||
}
|
||||
#endif
|
||||
#endif // USE_TOUCH_BUTTONS
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
|
@ -2187,6 +2189,10 @@ void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) {
|
|||
}
|
||||
#endif // USE_UFILESYS
|
||||
|
||||
/*********************************************************************************************\
|
||||
* AWatch
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef USE_AWATCH
|
||||
#define MINUTE_REDUCT 4
|
||||
|
||||
|
@ -2224,6 +2230,9 @@ void DrawAClock(uint16_t rad) {
|
|||
}
|
||||
#endif // USE_AWATCH
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Graphics
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef USE_GRAPH
|
||||
|
||||
|
@ -2264,7 +2273,6 @@ struct GRAPH {
|
|||
GFLAGS flags;
|
||||
};
|
||||
|
||||
|
||||
struct GRAPH *graph[NUM_GRAPHS];
|
||||
|
||||
#define TICKLEN 4
|
||||
|
@ -2461,6 +2469,7 @@ void Save_graph(uint8_t num, char *path) {
|
|||
fp.print("\n");
|
||||
fp.close();
|
||||
}
|
||||
|
||||
void Restore_graph(uint8_t num, char *path) {
|
||||
if (!renderer) return;
|
||||
uint16_t index=num%NUM_GRAPHS;
|
||||
|
@ -2572,7 +2581,6 @@ void AddGraph(uint8_t num,uint8_t val) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// add next value
|
||||
void AddValue(uint8_t num,float fval) {
|
||||
// not yet defined ???
|
||||
|
@ -2607,7 +2615,12 @@ void AddValue(uint8_t num,float fval) {
|
|||
}
|
||||
#endif // USE_GRAPH
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Touch panel control
|
||||
\*********************************************************************************************/
|
||||
|
||||
#if defined(USE_FT5206) || defined(USE_XPT2046)
|
||||
|
||||
#ifdef USE_FT5206
|
||||
|
||||
#include <FT5206.h>
|
||||
|
@ -2644,7 +2657,7 @@ uint32_t Touch_Status(uint32_t sel) {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // USE_FT5206
|
||||
|
||||
#if defined(USE_XPT2046) && defined(USE_DISPLAY_ILI9341)
|
||||
#include <XPT2046_Touchscreen.h>
|
||||
|
@ -2678,7 +2691,7 @@ uint32_t Touch_Status(uint32_t sel) {
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USE_XPT2046 && USE_DISPLAY_ILI9341
|
||||
|
||||
#ifdef USE_TOUCH_BUTTONS
|
||||
void Touch_MQTT(uint8_t index, const char *cp, uint32_t val) {
|
||||
|
@ -2686,7 +2699,7 @@ void Touch_MQTT(uint8_t index, const char *cp, uint32_t val) {
|
|||
ResponseTime_P(PSTR(",\"FT5206\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
|
||||
#elif defined(USE_XPT2046)
|
||||
ResponseTime_P(PSTR(",\"XPT2046\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
|
||||
#endif
|
||||
#endif // USE_XPT2046
|
||||
MqttPublishTeleSensor();
|
||||
}
|
||||
|
||||
|
@ -2702,18 +2715,17 @@ uint8_t tbstate[3];
|
|||
|
||||
// check digitizer hit
|
||||
void Touch_Check(void(*rotconvert)(int16_t *x, int16_t *y)) {
|
||||
uint16_t temp;
|
||||
uint8_t rbutt=0;
|
||||
uint8_t vbutt=0;
|
||||
uint16_t temp;
|
||||
uint8_t rbutt=0;
|
||||
uint8_t vbutt=0;
|
||||
|
||||
|
||||
if (touchp->touched()) {
|
||||
if (touchp->touched()) {
|
||||
// did find a hit
|
||||
#if defined(USE_FT5206)
|
||||
pLoc = touchp->getPoint(0);
|
||||
#elif defined(USE_XPT2046)
|
||||
pLoc = touchp->getPoint();
|
||||
#endif
|
||||
#endif // USE_XPT2046
|
||||
if (renderer) {
|
||||
|
||||
#ifdef USE_M5STACK_CORE2
|
||||
|
@ -2734,7 +2746,7 @@ uint8_t vbutt=0;
|
|||
}
|
||||
xcenter += 100;
|
||||
}
|
||||
#endif
|
||||
#endif // USE_M5STACK_CORE2
|
||||
|
||||
rotconvert(&pLoc.x, &pLoc.y);
|
||||
|
||||
|
@ -2798,7 +2810,7 @@ uint8_t vbutt=0;
|
|||
//AddLog(LOG_LEVEL_INFO, PSTR("tbut: %d released"), tbut);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // USE_M5STACK_CORE2
|
||||
for (uint8_t count = 0; count < MAX_TOUCH_BUTTONS; count++) {
|
||||
if (buttons[count]) {
|
||||
if (!buttons[count]->vpower.slider) {
|
||||
|
@ -2831,7 +2843,7 @@ uint8_t vbutt=0;
|
|||
}
|
||||
|
||||
#endif // USE_TOUCH_BUTTONS
|
||||
#endif // USE_FT5206
|
||||
#endif // USE_FT5206 || USE_XPT2046
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
|
@ -2841,13 +2853,10 @@ bool Xdrv13(uint8_t function)
|
|||
{
|
||||
bool result = false;
|
||||
|
||||
if ((TasmotaGlobal.i2c_enabled || TasmotaGlobal.spi_enabled || TasmotaGlobal.soft_spi_enabled) && XdspPresent()) {
|
||||
if (XdspPresent()) {
|
||||
switch (function) {
|
||||
case FUNC_PRE_INIT:
|
||||
DisplayInitDriver();
|
||||
#ifdef USE_GRAPH
|
||||
for (uint8_t count = 0; count < NUM_GRAPHS; count++) { graph[count] = 0; }
|
||||
#endif
|
||||
break;
|
||||
case FUNC_EVERY_50_MSECOND:
|
||||
if (Settings.display_model) { XdspCall(FUNC_DISPLAY_EVERY_50_MSECOND); }
|
||||
|
@ -2889,4 +2898,3 @@ bool Xdrv13(uint8_t function)
|
|||
}
|
||||
|
||||
#endif // USE_DISPLAY
|
||||
#endif // USE_I2C or USE_SPI
|
||||
|
|
|
@ -55,8 +55,9 @@ void LcdInit(uint8_t mode)
|
|||
}
|
||||
}
|
||||
|
||||
void LcdInitDriver(void)
|
||||
{
|
||||
void LcdInitDriver(void) {
|
||||
if (!TasmotaGlobal.i2c_enabled) { return; }
|
||||
|
||||
if (!Settings.display_model) {
|
||||
if (I2cSetDevice(LCD_ADDRESS1)) {
|
||||
Settings.display_address[0] = LCD_ADDRESS1;
|
||||
|
|
|
@ -47,8 +47,9 @@ extern uint8_t *buffer;
|
|||
|
||||
/*********************************************************************************************/
|
||||
|
||||
void SSD1306InitDriver(void)
|
||||
{
|
||||
void SSD1306InitDriver(void) {
|
||||
if (!TasmotaGlobal.i2c_enabled) { return; }
|
||||
|
||||
if (!Settings.display_model) {
|
||||
if (I2cSetDevice(OLED_ADDRESS1)) {
|
||||
Settings.display_address[0] = OLED_ADDRESS1;
|
||||
|
|
|
@ -194,8 +194,9 @@ void MatrixInit(uint8_t mode)
|
|||
}
|
||||
}
|
||||
|
||||
void MatrixInitDriver(void)
|
||||
{
|
||||
void MatrixInitDriver(void) {
|
||||
if (!TasmotaGlobal.i2c_enabled) { return; }
|
||||
|
||||
mtx_buffer = (char*)(malloc(MTX_MAX_SCREEN_BUFFER));
|
||||
if (mtx_buffer != nullptr) {
|
||||
if (!Settings.display_model) {
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#define XDSP_04 4
|
||||
|
||||
enum IliModes { ILIMODE_9341 = 1, ILIMODE_9342, ILIMODE_MAX };
|
||||
|
||||
#include <ILI9341_2.h>
|
||||
|
||||
extern uint8_t *buffer;
|
||||
|
@ -37,13 +39,10 @@ uint8_t ili9342_ctouch_counter = 0;
|
|||
uint8_t ili9342_ctouch_counter = 0;
|
||||
#endif // USE_FT5206
|
||||
|
||||
|
||||
bool tft_init_done = false;
|
||||
|
||||
#define ILI9341_ID 1
|
||||
#define ILI9342_ID 2
|
||||
|
||||
//Settings.display_options.ilimode = ILI9341_ID;
|
||||
//Settings.display_options.ilimode = ILIMODE_9341;
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
|
@ -66,8 +65,8 @@ void ILI9341_InitDriver()
|
|||
// disable screen buffer
|
||||
buffer = NULL;
|
||||
|
||||
if (!Settings.display_options.ilimode) {
|
||||
Settings.display_options.ilimode = ILI9341_ID;
|
||||
if (!Settings.display_options.ilimode || (Settings.display_options.ilimode >= ILIMODE_MAX)) {
|
||||
Settings.display_options.ilimode = ILIMODE_9341;
|
||||
}
|
||||
|
||||
// default colors
|
||||
|
@ -102,7 +101,7 @@ void ILI9341_InitDriver()
|
|||
renderer->setTextFont(2);
|
||||
renderer->setTextSize(1);
|
||||
renderer->setTextColor(ILI9341_WHITE, ILI9341_BLACK);
|
||||
renderer->DrawStringAt(50, (Settings.display_height/2)-12, (Settings.display_options.ilimode & 3)==ILI9341_ID?"ILI9341 TFT!":"ILI9342 TFT!", ILI9341_WHITE, 0);
|
||||
renderer->DrawStringAt(50, (Settings.display_height/2)-12, (Settings.display_options.ilimode & 3)==ILIMODE_9341?"ILI9341 TFT!":"ILI9342 TFT!", ILI9341_WHITE, 0);
|
||||
delay(1000);
|
||||
#endif // SHOW_SPLASH
|
||||
|
||||
|
|
|
@ -48,8 +48,9 @@ Adafruit_SH1106 *oled1106;
|
|||
/*********************************************************************************************/
|
||||
|
||||
|
||||
void SH1106InitDriver()
|
||||
{
|
||||
void SH1106InitDriver() {
|
||||
if (!TasmotaGlobal.i2c_enabled) { return; }
|
||||
|
||||
if (!Settings.display_model) {
|
||||
if (I2cSetDevice(OLED_ADDRESS1)) {
|
||||
Settings.display_address[0] = OLED_ADDRESS1;
|
||||
|
|
|
@ -147,8 +147,9 @@ void SevensegInit(uint8_t mode)
|
|||
}
|
||||
}
|
||||
|
||||
void SevensegInitDriver(void)
|
||||
{
|
||||
void SevensegInitDriver(void) {
|
||||
if (!TasmotaGlobal.i2c_enabled) { return; }
|
||||
|
||||
if (!Settings.display_model) {
|
||||
if (I2cSetDevice(Settings.display_address[0])) {
|
||||
Settings.display_model = XDSP_11;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(USE_I2C) || defined(USE_SPI)
|
||||
#ifdef USE_DISPLAY
|
||||
|
||||
#ifdef XFUNC_PTR_IN_ROM
|
||||
|
@ -201,4 +200,3 @@ bool XdspCall(uint8_t Function)
|
|||
}
|
||||
|
||||
#endif // USE_DISPLAY
|
||||
#endif // USE_I2C or USE_SPI
|
||||
|
|
Loading…
Reference in New Issue