mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-23 11:16:45 +00:00
tasmotaslave impovements
This commit is contained in:
parent
554849714d
commit
2785880a09
@ -8,7 +8,7 @@ lolin24 =
|
|||||||
-D ILI9341_DRIVER=1
|
-D ILI9341_DRIVER=1
|
||||||
-D TFT_WIDTH=240
|
-D TFT_WIDTH=240
|
||||||
-D TFT_HEIGHT=320
|
-D TFT_HEIGHT=320
|
||||||
-D TFT_ROTATION=0 ; 0=0, 1=90, 2=180 or 3=270 degree
|
-D TFT_ROTATION=2 ; 0=0, 1=90, 2=180 or 3=270 degree
|
||||||
-D SPI_FREQUENCY=40000000
|
-D SPI_FREQUENCY=40000000
|
||||||
-D SPI_TOUCH_FREQUENCY=2500000
|
-D SPI_TOUCH_FREQUENCY=2500000
|
||||||
-D SPI_READ_FREQUENCY=20000000
|
-D SPI_READ_FREQUENCY=20000000
|
||||||
|
@ -665,7 +665,7 @@ void haspClearPage(uint16_t pageid)
|
|||||||
Log.warning(F("HASP: Cannot clear a layer"));
|
Log.warning(F("HASP: Cannot clear a layer"));
|
||||||
} else {
|
} else {
|
||||||
Log.notice(F("HASP: Clearing page %u"), pageid);
|
Log.notice(F("HASP: Clearing page %u"), pageid);
|
||||||
lv_page_clean(pages[pageid]);
|
lv_obj_clean(pages[pageid]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ static void button_event_cb(AceButton * button, uint8_t eventType, uint8_t butto
|
|||||||
|
|
||||||
void buttonSetup(void)
|
void buttonSetup(void)
|
||||||
{
|
{
|
||||||
// button[0] = new Button(2);
|
button[0] = new AceButton(HASP_INPUT_PIN, LOW, 0);
|
||||||
button[1] = new AceButton(3, HIGH, 1);
|
button[1] = new AceButton(3, HIGH, 1);
|
||||||
button[2] = new AceButton(4, HIGH, 2);
|
button[2] = new AceButton(4, HIGH, 2);
|
||||||
|
|
||||||
|
@ -9,6 +9,6 @@ void gpioSetup()
|
|||||||
#endif
|
#endif
|
||||||
#if defined(STM32_CORE_VERSION)
|
#if defined(STM32_CORE_VERSION)
|
||||||
pinMode(HASP_OUTPUT_PIN, OUTPUT);
|
pinMode(HASP_OUTPUT_PIN, OUTPUT);
|
||||||
pinMode(HASP_INPUT_PIN, INPUT_PULLUP);
|
pinMode(HASP_INPUT_PIN, INPUT_PULLDOWN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -7,6 +7,10 @@
|
|||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
#include "hasp_dispatch.h"
|
#include "hasp_dispatch.h"
|
||||||
#include "hasp_gui.h"
|
#include "hasp_gui.h"
|
||||||
|
#include "hasp_hal.h"
|
||||||
|
#include "hasp_tft.h"
|
||||||
|
#include "hasp_config.h"
|
||||||
|
#include "hasp.h"
|
||||||
#include "tasmotaSlave.h"
|
#include "tasmotaSlave.h"
|
||||||
|
|
||||||
// set RX and TX pins
|
// set RX and TX pins
|
||||||
@ -62,54 +66,63 @@ void slave_send_input(uint8_t id, const char * payload)
|
|||||||
Log.notice(F("TAS PUB: %sstate/input%u = %s"), slaveNodeTopic, id, payload);
|
Log.notice(F("TAS PUB: %sstate/input%u = %s"), slaveNodeTopic, id, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void slave_send_statusupdate()
|
void TASMO_TELE_JSON()
|
||||||
// { // Periodically publish a JSON string indicating system status
|
{ // Periodically publish a JSON string indicating system status
|
||||||
// char data[3 * 128];
|
char data[3 * 128];
|
||||||
// {
|
{
|
||||||
// char buffer[128];
|
char buffer[128];
|
||||||
// snprintf_P(data, sizeof(data), PSTR("{\"status\":\"available\",\"version\":\"%s\",\"uptime\":%lu,"),
|
snprintf_P(data, sizeof(data), PSTR("{\"status\":\"available\",\"version\":\"%s\",\"uptime\":%lu,"),
|
||||||
// haspGetVersion().c_str(), long(millis() / 1000));
|
haspGetVersion().c_str(), long(millis() / 1000));
|
||||||
// strcat(buffer, data);
|
strcat(buffer, data);
|
||||||
// snprintf_P(buffer, sizeof(buffer), PSTR("\"heapFree\":%u,\"heapFrag\":%u,\"espCore\":\"%s\","),
|
snprintf_P(buffer, sizeof(buffer), PSTR("\"espCanUpdate\":\"false\",\"page\":%u,\"numPages\":%u,"),
|
||||||
// ESP.getFreeHeap(), halGetHeapFragmentation(), halGetCoreVersion().c_str());
|
haspGetPage(), (HASP_NUM_PAGES));
|
||||||
// strcat(data, buffer);
|
strcat(data, buffer);
|
||||||
// snprintf_P(buffer, sizeof(buffer), PSTR("\"espCanUpdate\":\"false\",\"page\":%u,\"numPages\":%u}"),
|
snprintf_P(buffer, sizeof(buffer), PSTR("\"tftDriver\":\"%s\",\"tftWidth\":%u,\"tftHeight\":%u}"),
|
||||||
// haspGetPage(), (HASP_NUM_PAGES));
|
tftDriverName().c_str(), (TFT_WIDTH), (TFT_HEIGHT));
|
||||||
// strcat(data, buffer);
|
strcat(data, buffer);
|
||||||
// snprintf_P(buffer, sizeof(buffer), PSTR("\"tftDriver\":\"%s\",\"tftWidth\":%u,\"tftHeight\":%u}"),
|
}
|
||||||
// tftDriverName().c_str(), (TFT_WIDTH), (TFT_HEIGHT));
|
slave.sendJSON((char*)data);
|
||||||
// strcat(data, buffer);
|
// slave_send_state(F("statusupdate"), data);
|
||||||
// }
|
// debugLastMillis = millis();
|
||||||
// slave_send_state(F("statusupdate"), data);
|
}
|
||||||
// debugLastMillis = millis();
|
|
||||||
// }
|
|
||||||
|
|
||||||
void TASMO_DATA_RECEIVE(char *data)
|
void TASMO_DATA_RECEIVE(char *data)
|
||||||
{
|
{
|
||||||
Log.verbose(F("TAS: Slave IN [%s]"), data);
|
Log.verbose(F("TAS: Slave IN [%s]"), data);
|
||||||
|
|
||||||
char slvCmd[20],slvVal[60];
|
char dataType[3];
|
||||||
memset(slvCmd, 0 ,sizeof(slvCmd));
|
memset(dataType, 0 ,sizeof(dataType));
|
||||||
memset(slvVal, 0 ,sizeof(slvVal));
|
snprintf_P(dataType, sizeof(dataType), data);
|
||||||
sscanf(data,"%s %s", slvCmd, slvVal);
|
Log.verbose(F("TAS: dataType [%s]"), dataType);
|
||||||
|
|
||||||
Log.verbose(F("TAS: Cmd[%s] Val[%s]"), slvCmd, slvVal);
|
if (!strcmp(dataType, "p[")){ //
|
||||||
|
dispatchCommand(data);
|
||||||
if (!strcmp(slvCmd, "calData")){
|
} else if (!strcmp(dataType, "[\"")) {
|
||||||
if (strlen(slvVal) != 0) {
|
dispatchJson(data);
|
||||||
char cBuffer[strlen(slvVal) + 24];
|
|
||||||
memset(cBuffer, 0 ,sizeof(cBuffer));
|
|
||||||
snprintf_P(cBuffer, sizeof(cBuffer), PSTR("{'calibration':[%s]}"), slvVal);
|
|
||||||
dispatchConfig("gui",cBuffer);
|
|
||||||
} else {
|
|
||||||
dispatchConfig("gui","");
|
|
||||||
}
|
|
||||||
} else if (!strcmp(slvCmd, "jsonl")) {
|
|
||||||
dispatchJsonl(slvVal);
|
|
||||||
} else {
|
} else {
|
||||||
char cBuffer[strlen(data)+1];
|
char slvCmd[20],slvVal[60];
|
||||||
snprintf_P(cBuffer, sizeof(cBuffer), PSTR("%s=%s"), slvCmd, slvVal);
|
memset(slvCmd, 0 ,sizeof(slvCmd));
|
||||||
dispatchCommand(cBuffer);
|
memset(slvVal, 0 ,sizeof(slvVal));
|
||||||
|
sscanf(data,"%[^=] =%s", slvCmd, slvVal);
|
||||||
|
|
||||||
|
Log.verbose(F("TAS: Cmd[%s] Val[%s]"), slvCmd, slvVal);
|
||||||
|
|
||||||
|
if (!strcmp(slvCmd, "calData")){
|
||||||
|
if (strlen(slvVal) != 0) {
|
||||||
|
char cBuffer[strlen(slvVal) + 24];
|
||||||
|
memset(cBuffer, 0 ,sizeof(cBuffer));
|
||||||
|
snprintf_P(cBuffer, sizeof(cBuffer), PSTR("{'calibration':[%s]}"), slvVal);
|
||||||
|
dispatchConfig("gui",cBuffer);
|
||||||
|
} else {
|
||||||
|
dispatchConfig("gui","");
|
||||||
|
}
|
||||||
|
} else if (!strcmp(slvCmd, "jsonl")) {
|
||||||
|
dispatchJsonl(slvVal);
|
||||||
|
} else if (!strcmp(slvCmd, "clearpage")) {
|
||||||
|
dispatchClearPage(slvVal);
|
||||||
|
} else {
|
||||||
|
dispatchCommand(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +143,7 @@ void slaveSetup()
|
|||||||
{
|
{
|
||||||
Serial2.begin(HASP_SLAVE_SPEED);
|
Serial2.begin(HASP_SLAVE_SPEED);
|
||||||
// slave.attach_FUNC_EVERY_SECOND(TASMO_EVERY_SECOND);
|
// slave.attach_FUNC_EVERY_SECOND(TASMO_EVERY_SECOND);
|
||||||
|
slave.attach_FUNC_JSON(TASMO_TELE_JSON);
|
||||||
slave.attach_FUNC_COMMAND_SEND(TASMO_DATA_RECEIVE);
|
slave.attach_FUNC_COMMAND_SEND(TASMO_DATA_RECEIVE);
|
||||||
|
|
||||||
Log.notice(F("TAS: HASP SLAVE LOADED"));
|
Log.notice(F("TAS: HASP SLAVE LOADED"));
|
||||||
|
@ -103,10 +103,13 @@ void loop()
|
|||||||
/* Graphics Loops */
|
/* Graphics Loops */
|
||||||
// tftLoop();
|
// tftLoop();
|
||||||
guiLoop();
|
guiLoop();
|
||||||
|
|
||||||
/* Application Loops */
|
/* Application Loops */
|
||||||
// haspLoop();
|
// haspLoop();
|
||||||
|
|
||||||
|
#if HASP_USE_BUTTON
|
||||||
|
buttonLoop();
|
||||||
|
#endif // BUTTON
|
||||||
|
|
||||||
/* Network Services Loops */
|
/* Network Services Loops */
|
||||||
#if HASP_USE_WIFI
|
#if HASP_USE_WIFI
|
||||||
|
|
||||||
@ -126,10 +129,6 @@ void loop()
|
|||||||
mdnsLoop();
|
mdnsLoop();
|
||||||
#endif // MDNS
|
#endif // MDNS
|
||||||
|
|
||||||
#if HASP_USE_BUTTON
|
|
||||||
buttonLoop();
|
|
||||||
#endif // BUTTON
|
|
||||||
|
|
||||||
#if HASP_USE_OTA
|
#if HASP_USE_OTA
|
||||||
otaLoop();
|
otaLoop();
|
||||||
#endif // OTA
|
#endif // OTA
|
||||||
|
Loading…
x
Reference in New Issue
Block a user