mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 20:56:37 +00:00
Reorganize folder structure
This commit is contained in:
parent
b7bb58c960
commit
f9a67dbedc
@ -4,18 +4,18 @@
|
|||||||
#define HASP_USE_APP 1
|
#define HASP_USE_APP 1
|
||||||
|
|
||||||
/* Network Services */
|
/* Network Services */
|
||||||
#define HASP_HAS_NETWORK (ARDUINO_ARCH_ESP32 > 0 || ARDUINO_ARCH_ESP8266 > 0)
|
#ifndef HASP_USE_ETHERNET
|
||||||
|
#define HASP_USE_ETHERNET 0
|
||||||
#ifndef HASP_USE_OTA
|
|
||||||
#define HASP_USE_OTA (HASP_HAS_NETWORK)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HASP_USE_WIFI
|
#ifndef HASP_USE_WIFI
|
||||||
#define HASP_USE_WIFI (HASP_HAS_NETWORK)
|
#define HASP_USE_WIFI (ARDUINO_ARCH_ESP32 > 0 || ARDUINO_ARCH_ESP8266 > 0 || HASP_USE_WIFI > 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HASP_USE_ETHERNET
|
#define HASP_HAS_NETWORK (ARDUINO_ARCH_ESP32 > 0 || ARDUINO_ARCH_ESP8266 > 0 || HASP_USE_ETHERNET > 0 || HASP_USE_WIFI > 0)
|
||||||
#define HASP_USE_ETHERNET 0
|
|
||||||
|
#ifndef HASP_USE_OTA
|
||||||
|
#define HASP_USE_OTA (HASP_HAS_NETWORK)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HASP_USE_MQTT
|
#ifndef HASP_USE_MQTT
|
||||||
@ -124,7 +124,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_WIFI > 0
|
#if HASP_USE_WIFI > 0
|
||||||
#include "hasp_wifi.h"
|
#include "net/hasp_wifi.h"
|
||||||
|
|
||||||
#if defined(STM32F4xx)
|
#if defined(STM32F4xx)
|
||||||
#include "WiFiSpi.h"
|
#include "WiFiSpi.h"
|
||||||
@ -144,7 +144,7 @@ static WiFiSpiClass WiFi;
|
|||||||
#define ETH_TYPE ETH_PHY_LAN8720
|
#define ETH_TYPE ETH_PHY_LAN8720
|
||||||
#define ETH_CLKMODE ETH_CLOCK_GPIO17_OUT
|
#define ETH_CLKMODE ETH_CLOCK_GPIO17_OUT
|
||||||
|
|
||||||
#include "hasp_ethernet_esp32.h"
|
#include "net/hasp_ethernet_esp32.h"
|
||||||
#warning Using ESP32 Ethernet LAN8720
|
#warning Using ESP32 Ethernet LAN8720
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -160,12 +160,12 @@ static WiFiSpiClass WiFi;
|
|||||||
#include "Ethernet.h"
|
#include "Ethernet.h"
|
||||||
#warning Use W5x00 Ethernet shield
|
#warning Use W5x00 Ethernet shield
|
||||||
#endif
|
#endif
|
||||||
#include "hasp_ethernet_stm32.h"
|
#include "net/hasp_ethernet_stm32.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
#include "hasp_mqtt.h"
|
#include "svc/hasp_mqtt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_GPIO > 0
|
#if HASP_USE_GPIO > 0
|
||||||
@ -173,23 +173,19 @@ static WiFiSpiClass WiFi;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_HTTP > 0
|
#if HASP_USE_HTTP > 0
|
||||||
#include "hasp_http.h"
|
#include "svc/hasp_http.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_TELNET > 0
|
#if HASP_USE_TELNET > 0
|
||||||
#include "hasp_telnet.h"
|
#include "svc/hasp_telnet.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_MDNS > 0
|
#if HASP_USE_MDNS > 0
|
||||||
#include "hasp_mdns.h"
|
#include "svc/hasp_mdns.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_BUTTON > 0
|
|
||||||
#include "hasp_button.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_OTA > 0
|
#if HASP_USE_OTA > 0
|
||||||
#include "hasp_ota.h"
|
#include "svc/hasp_ota.h"
|
||||||
#ifndef HASP_OTA_PORT
|
#ifndef HASP_OTA_PORT
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
#define HASP_OTA_PORT 3232
|
#define HASP_OTA_PORT 3232
|
||||||
@ -200,7 +196,7 @@ static WiFiSpiClass WiFi;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_TASMOTA_SLAVE > 0
|
#if HASP_USE_TASMOTA_SLAVE > 0
|
||||||
#include "hasp_slave.h"
|
#include "svc/hasp_slave.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FPSTR
|
#ifndef FPSTR
|
||||||
|
@ -109,7 +109,7 @@ void tft_espi_calibrate(uint16_t * calData)
|
|||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
|
||||||
tft.println(PSTR("Touch corners as indicated"));
|
// tft.println(PSTR("Touch corners as indicated"));
|
||||||
|
|
||||||
tft.setTextFont(1);
|
tft.setTextFont(1);
|
||||||
delay(500);
|
delay(500);
|
||||||
|
108
src/drv/hasp_drv_911.cpp
Normal file
108
src/drv/hasp_drv_911.cpp
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#if TOUCH_DRIVER == 911
|
||||||
|
|
||||||
|
#include <Wire.h>
|
||||||
|
#include "Goodix.h"
|
||||||
|
#include "ArduinoLog.h"
|
||||||
|
|
||||||
|
#include "hasp_drv_911.h"
|
||||||
|
|
||||||
|
#define INT_PIN (TOUCH_IRQ)
|
||||||
|
#define RST_PIN (TOUCH_RST) // -1 if pin is connected to VCC else set pin number
|
||||||
|
|
||||||
|
static Goodix touch = Goodix();
|
||||||
|
static int8_t GT911_num_touches;
|
||||||
|
static GTPoint * GT911_points;
|
||||||
|
|
||||||
|
// Store touch points into global variable
|
||||||
|
void IRAM_ATTR GT911_setXY(int8_t contacts, GTPoint * points)
|
||||||
|
{
|
||||||
|
GT911_num_touches = contacts;
|
||||||
|
GT911_points = points;
|
||||||
|
|
||||||
|
Log.verbose(TAG_GUI, "Contacts: %d", contacts);
|
||||||
|
for(int i = 0; i < contacts; i++) {
|
||||||
|
Log.verbose(TAG_GUI, "C%d: #%d %d,%d s:%d", i, points[i].trackId, points[i].x, points[i].y, points[i].area);
|
||||||
|
yield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read touch points from global variable
|
||||||
|
bool IRAM_ATTR GT911_getXY(uint16_t * touchX, uint16_t * touchY, bool debug)
|
||||||
|
{
|
||||||
|
static GTPoint points[5];
|
||||||
|
int16_t contacts = touch.readInput((uint8_t *)&points);
|
||||||
|
if(contacts <= 0) return false;
|
||||||
|
|
||||||
|
if(debug) {
|
||||||
|
Serial.print(contacts);
|
||||||
|
Serial.print(" : ");
|
||||||
|
Serial.print(points[0].x);
|
||||||
|
Serial.print(" x ");
|
||||||
|
Serial.println(points[0].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
*touchX = points[0].x;
|
||||||
|
*touchY = points[0].y;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// ALTERNATE REGISTER READ METHOD
|
||||||
|
// static uint8_t touchBuffer[6];
|
||||||
|
|
||||||
|
// uint16_t first = 0x814E; // 8150
|
||||||
|
// uint16_t last = 0x8153;
|
||||||
|
// uint16_t len = first - last + 1;
|
||||||
|
// uint8_t res = touch.read(first, touchBuffer, len);
|
||||||
|
|
||||||
|
// if(res != GOODIX_OK || touchBuffer[0] - 128 == 0) return false;
|
||||||
|
|
||||||
|
// *touchX = touchBuffer[2] + touchBuffer[3] * 256;
|
||||||
|
// *touchY = touchBuffer[4] + touchBuffer[5] * 256;
|
||||||
|
|
||||||
|
// if (debug) {
|
||||||
|
// Serial.print(touchBuffer[0] - 128);
|
||||||
|
// Serial.print(" : ");
|
||||||
|
// Serial.print(*touchX);
|
||||||
|
// Serial.print(" x ");
|
||||||
|
// Serial.println(*touchY);
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void touchStart()
|
||||||
|
{
|
||||||
|
if(touch.begin(INT_PIN, RST_PIN) != true) {
|
||||||
|
Serial.println("! Module reset failed");
|
||||||
|
} else {
|
||||||
|
Serial.println("Module reset OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.print("Check ACK on addr request on 0x");
|
||||||
|
Serial.print(touch.i2cAddr, HEX);
|
||||||
|
|
||||||
|
Wire.beginTransmission(touch.i2cAddr);
|
||||||
|
int error = Wire.endTransmission();
|
||||||
|
if(error == 0) {
|
||||||
|
Serial.println(": SUCCESS");
|
||||||
|
} else {
|
||||||
|
Serial.print(": ERROR #");
|
||||||
|
Serial.println(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GT911_init()
|
||||||
|
{
|
||||||
|
// Wire.setClock(400000);
|
||||||
|
// Wire.begin();
|
||||||
|
Wire.begin(TOUCH_SDA, TOUCH_SCL, I2C_TOUCH_FREQUENCY);
|
||||||
|
delay(300);
|
||||||
|
|
||||||
|
touch.setHandler(GT911_setXY);
|
||||||
|
touchStart();
|
||||||
|
Log.trace(TAG_DRVR, F("Goodix GT911x touch driver started"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR GT911_loop()
|
||||||
|
{
|
||||||
|
touch.loop();
|
||||||
|
}
|
||||||
|
#endif
|
16
src/drv/hasp_drv_911.h
Normal file
16
src/drv/hasp_drv_911.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/* MIT License - Copyright (c) 2020 Francis Van Roie
|
||||||
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
|
#if TOUCH_DRIVER == 911
|
||||||
|
|
||||||
|
#include "hasp_debug.h" // for TAG_DRVR
|
||||||
|
|
||||||
|
#ifndef HASP_DRV_911_H
|
||||||
|
#define HASP_DRV_911_H
|
||||||
|
|
||||||
|
bool IRAM_ATTR GT911_getXY(uint16_t * touchX, uint16_t * touchY, bool debug);
|
||||||
|
void GT911_init();
|
||||||
|
void IRAM_ATTR GT911_loop();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
12
src/drv/hasp_drv_display.cpp
Normal file
12
src/drv/hasp_drv_display.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "hasp_drv_display.h"
|
||||||
|
|
||||||
|
void drv_display_init(uint8_t rotation)
|
||||||
|
{
|
||||||
|
/* TFT init */
|
||||||
|
#if defined(USE_FSMC)
|
||||||
|
fsmc_ili9341_init(rotation);
|
||||||
|
// xpt2046_init(rotation);
|
||||||
|
#else
|
||||||
|
tft_espi_init(rotation);
|
||||||
|
#endif
|
||||||
|
}
|
16
src/drv/hasp_drv_display.h
Normal file
16
src/drv/hasp_drv_display.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/* MIT License - Copyright (c) 2020 Francis Van Roie
|
||||||
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
|
#ifndef HASP_DRV_DISPLAY_H
|
||||||
|
#define HASP_DRV_DISPLAY_H
|
||||||
|
|
||||||
|
// Select Display Driver
|
||||||
|
#if defined(USE_FSMC)
|
||||||
|
#include "fsmc_ili9341.h"
|
||||||
|
#else
|
||||||
|
#include "tft_espi_drv.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void drv_display_init(uint8_t rotation);
|
||||||
|
|
||||||
|
#endif
|
39
src/drv/hasp_drv_ft6336u.cpp
Normal file
39
src/drv/hasp_drv_ft6336u.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#if TOUCH_DRIVER == 6336
|
||||||
|
|
||||||
|
#include <Wire.h>
|
||||||
|
#include "FT6336U.h"
|
||||||
|
#include "ArduinoLog.h"
|
||||||
|
|
||||||
|
#include "hasp_drv_ft6336u.h"
|
||||||
|
|
||||||
|
#define RST_PIN (TOUCH_RST) // -1 if pin is connected to VCC else set pin number
|
||||||
|
|
||||||
|
static FT6336U ft6336u(TOUCH_SDA, TOUCH_SCL, TOUCH_RST, TOUCH_IRQ);
|
||||||
|
|
||||||
|
// Read touch points
|
||||||
|
bool IRAM_ATTR FT6336U_getXY(uint16_t * touchX, uint16_t * touchY, bool debug)
|
||||||
|
{
|
||||||
|
FT6336U_TouchPointType tp = ft6336u.scan();
|
||||||
|
|
||||||
|
if(debug) {
|
||||||
|
char tempString[128];
|
||||||
|
sprintf(tempString, "FT6336U TD Count %d / TD1 (%d, %4d, %4d) / TD2 (%d, %4d, %4d)\r", tp.touch_count,
|
||||||
|
tp.tp[0].status, tp.tp[0].x, tp.tp[0].y, tp.tp[1].status, tp.tp[1].x, tp.tp[1].y);
|
||||||
|
Serial.print(tempString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tp.touch_count != 1) return false;
|
||||||
|
|
||||||
|
int i = tp.tp[0].status == TouchStatusEnum::touch ? 0 : 1;
|
||||||
|
|
||||||
|
*touchX = tp.tp[i].x;
|
||||||
|
*touchY = tp.tp[i].y;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FT6336U_init()
|
||||||
|
{
|
||||||
|
ft6336u.begin();
|
||||||
|
Log.trace(TAG_DRVR, F("FT6336U touch driver started"));
|
||||||
|
}
|
||||||
|
#endif
|
15
src/drv/hasp_drv_ft6336u.h
Normal file
15
src/drv/hasp_drv_ft6336u.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/* MIT License - Copyright (c) 2020 Francis Van Roie
|
||||||
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
|
#if TOUCH_DRIVER == 6336
|
||||||
|
|
||||||
|
#include "hasp_debug.h" // for TAG_DRVR
|
||||||
|
|
||||||
|
#ifndef HASP_DRV_FT6336U_H
|
||||||
|
#define HASP_DRV_FT6336U_H
|
||||||
|
|
||||||
|
bool IRAM_ATTR FT6336U_getXY(uint16_t * touchX, uint16_t * touchY, bool debug);
|
||||||
|
void FT6336U_init();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
100
src/drv/hasp_drv_touch.cpp
Normal file
100
src/drv/hasp_drv_touch.cpp
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#include "hasp_drv_touch.h"
|
||||||
|
#include "lvgl.h"
|
||||||
|
|
||||||
|
#if TOUCH_DRIVER == 2046
|
||||||
|
#if defined(USE_FSMC)
|
||||||
|
#else
|
||||||
|
#include "tft_espi_drv.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif TOUCH_DRIVER == 2046
|
||||||
|
#include "indev/XPT2046.h"
|
||||||
|
#elif TOUCH_DRIVER == 911
|
||||||
|
#include "hasp_drv_911.h"
|
||||||
|
#elif TOUCH_DRIVER == 0xADC
|
||||||
|
#include "hasp_drv_ft6336u.h"
|
||||||
|
#elif TOUCH_DRIVER == 6336
|
||||||
|
#include "hasp_drv_ft6336u.h"
|
||||||
|
#else
|
||||||
|
//#include "tp_i2c.h"
|
||||||
|
//#include "ft6x36.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../hasp/hasp_sleep.h"
|
||||||
|
extern uint8_t sleep_state;
|
||||||
|
|
||||||
|
void drv_touch_init(uint8_t rotation)
|
||||||
|
{
|
||||||
|
#if TOUCH_DRIVER == 2046 // XPT2046 Resistive touch panel driver
|
||||||
|
#if defined(USE_FSMC)
|
||||||
|
xpt2046_init(rotation);
|
||||||
|
#else
|
||||||
|
// The display driver takes care of all initializations
|
||||||
|
// tft_espi_init(rotation);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif TOUCH_DRIVER == 911
|
||||||
|
GT911_init();
|
||||||
|
|
||||||
|
#elif TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller
|
||||||
|
// Touch_init();
|
||||||
|
|
||||||
|
#elif TOUCH_DRIVER == 6336
|
||||||
|
FT6336U_init();
|
||||||
|
|
||||||
|
#else
|
||||||
|
// xpt2046_alt_drv_read(indev_driver, data);
|
||||||
|
// xpt2046_read(indev_driver, data);
|
||||||
|
// if(data->state && guiSleeping != HASP_SLEEP_OFF) guiCheckSleep();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool drv_touchpad_getXY(uint16_t * touchX, uint16_t * touchY)
|
||||||
|
{
|
||||||
|
#if TOUCH_DRIVER == 2046 // XPT2046 Resistive touch panel driver
|
||||||
|
return tft_espi_get_touch(touchX, touchY, 300);
|
||||||
|
|
||||||
|
#elif TOUCH_DRIVER == 911
|
||||||
|
return GT911_getXY(touchX, touchY, true);
|
||||||
|
|
||||||
|
#elif TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller
|
||||||
|
return Touch_getXY(touchX, touchY, false);
|
||||||
|
|
||||||
|
#elif TOUCH_DRIVER == 6336
|
||||||
|
return FT6336U_getXY(touchX, touchY, true);
|
||||||
|
|
||||||
|
#else
|
||||||
|
// xpt2046_alt_drv_read(indev_driver, data);
|
||||||
|
// xpt2046_read(indev_driver, data);
|
||||||
|
// if(data->state && guiSleeping != HASP_SLEEP_OFF) guiCheckSleep();
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool drv_touch_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
|
||||||
|
{
|
||||||
|
#ifdef TOUCH_CS
|
||||||
|
uint16_t touchX, touchY;
|
||||||
|
bool touched = drv_touchpad_getXY(&touchX, &touchY);
|
||||||
|
if(touched && sleep_state != HASP_SLEEP_OFF) sleep_check_state(); // update Idle
|
||||||
|
|
||||||
|
// Ignore first press?
|
||||||
|
|
||||||
|
/*Save the state and save the pressed coordinate for cursor position */
|
||||||
|
data->state = touched ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
|
||||||
|
if(touched) {
|
||||||
|
data->point.x = touchX;
|
||||||
|
data->point.y = touchY;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Return `false` because we are not buffering and no more data to read*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR drv_touch_loop()
|
||||||
|
{
|
||||||
|
#if TOUCH_DRIVER == 911
|
||||||
|
GT911_loop();
|
||||||
|
#endif
|
||||||
|
}
|
17
src/drv/hasp_drv_touch.h
Normal file
17
src/drv/hasp_drv_touch.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/* MIT License - Copyright (c) 2020 Francis Van Roie
|
||||||
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
|
#ifndef HASP_DRV_TOUCH_H
|
||||||
|
#define HASP_DRV_TOUCH_H
|
||||||
|
|
||||||
|
#include "lvgl.h"
|
||||||
|
|
||||||
|
#ifndef TOUCH_DRIVER
|
||||||
|
#define TOUCH_DRIVER -1 // No Touch
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void drv_touch_init(uint8_t rotation);
|
||||||
|
bool drv_touch_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
|
||||||
|
void drv_touch_loop();
|
||||||
|
|
||||||
|
#endif
|
@ -16,7 +16,6 @@
|
|||||||
#include "hasp_object.h"
|
#include "hasp_object.h"
|
||||||
#include "hasp_dispatch.h"
|
#include "hasp_dispatch.h"
|
||||||
//#include "hasp_filesystem.h" included in hasp_conf.h
|
//#include "hasp_filesystem.h" included in hasp_conf.h
|
||||||
#include "hasp_wifi.h"
|
|
||||||
#include "hasp_gui.h"
|
#include "hasp_gui.h"
|
||||||
|
|
||||||
#include "hasp_attribute.h"
|
#include "hasp_attribute.h"
|
@ -7,7 +7,8 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
#include "hasp_debug.h"
|
|
||||||
|
#include "../hasp_debug.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
@ -7,15 +7,19 @@
|
|||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
|
|
||||||
#include "hasp_dispatch.h"
|
#include "hasp_dispatch.h"
|
||||||
#include "hasp_network.h" // for network_get_status()
|
|
||||||
#include "hasp_debug.h"
|
|
||||||
#include "hasp_object.h"
|
#include "hasp_object.h"
|
||||||
|
#include "hasp_sleep.h"
|
||||||
|
#include "hasp.h"
|
||||||
|
|
||||||
|
#include "hasp_debug.h"
|
||||||
#include "hasp_gui.h"
|
#include "hasp_gui.h"
|
||||||
#include "hasp_oobe.h"
|
#include "hasp_oobe.h"
|
||||||
#include "hasp_mqtt.h"
|
|
||||||
#include "hasp_gpio.h"
|
#include "hasp_gpio.h"
|
||||||
#include "hasp_hal.h"
|
#include "hasp_hal.h"
|
||||||
#include "hasp.h"
|
|
||||||
|
#include "svc/hasp_ota.h"
|
||||||
|
#include "svc/hasp_mqtt.h"
|
||||||
|
#include "net/hasp_network.h" // for network_get_status()
|
||||||
|
|
||||||
#if HASP_USE_CONFIG > 0
|
#if HASP_USE_CONFIG > 0
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
@ -472,9 +476,11 @@ void dispatch_parse_json(const char *, const char * payload)
|
|||||||
|
|
||||||
} else if(json.is<JsonArray>()) { // handle json as an array of commands
|
} else if(json.is<JsonArray>()) { // handle json as an array of commands
|
||||||
JsonArray arr = json.as<JsonArray>();
|
JsonArray arr = json.as<JsonArray>();
|
||||||
|
guiStop();
|
||||||
for(JsonVariant command : arr) {
|
for(JsonVariant command : arr) {
|
||||||
dispatch_text_line(command.as<String>().c_str());
|
dispatch_text_line(command.as<String>().c_str());
|
||||||
}
|
}
|
||||||
|
guiStart();
|
||||||
} else if(json.is<JsonObject>()) { // handle json as a jsonl
|
} else if(json.is<JsonObject>()) { // handle json as a jsonl
|
||||||
uint8_t savedPage = haspGetPage();
|
uint8_t savedPage = haspGetPage();
|
||||||
hasp_new_object(json.as<JsonObject>(), savedPage);
|
hasp_new_object(json.as<JsonObject>(), savedPage);
|
||||||
@ -500,11 +506,13 @@ void dispatch_parse_jsonl(Stream & stream)
|
|||||||
DynamicJsonDocument jsonl(4 * 128u); // max ~256 characters per line
|
DynamicJsonDocument jsonl(4 * 128u); // max ~256 characters per line
|
||||||
DeserializationError err = deserializeJson(jsonl, stream);
|
DeserializationError err = deserializeJson(jsonl, stream);
|
||||||
|
|
||||||
|
guiStop();
|
||||||
while(err == DeserializationError::Ok) {
|
while(err == DeserializationError::Ok) {
|
||||||
hasp_new_object(jsonl.as<JsonObject>(), savedPage);
|
hasp_new_object(jsonl.as<JsonObject>(), savedPage);
|
||||||
err = deserializeJson(jsonl, stream);
|
err = deserializeJson(jsonl, stream);
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
|
guiStart();
|
||||||
|
|
||||||
/* For debugging pourposes */
|
/* For debugging pourposes */
|
||||||
if(err == DeserializationError::EmptyInput) {
|
if(err == DeserializationError::EmptyInput) {
|
||||||
@ -685,7 +693,7 @@ void dispatch_calibrate(const char *, const char *)
|
|||||||
|
|
||||||
void dispatch_wakeup(const char *, const char *)
|
void dispatch_wakeup(const char *, const char *)
|
||||||
{
|
{
|
||||||
guiWakeUp();
|
sleep_wakeup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatch_reboot(const char *, const char *)
|
void dispatch_reboot(const char *, const char *)
|
@ -21,10 +21,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hasp.h"
|
#include "hasp.h"
|
||||||
#include "hasp_gui.h"
|
|
||||||
#include "hasp_object.h"
|
#include "hasp_object.h"
|
||||||
#include "hasp_dispatch.h"
|
#include "hasp_dispatch.h"
|
||||||
#include "hasp_attribute.h"
|
#include "hasp_attribute.h"
|
||||||
|
#include "hasp_sleep.h"
|
||||||
|
|
||||||
// ##################### Object Finders ########################################################
|
// ##################### Object Finders ########################################################
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
guiCheckSleep(); // wakeup?
|
sleep_check_state(); // wakeup?
|
||||||
dispatch_object_event(obj, eventid); // send object event
|
dispatch_object_event(obj, eventid); // send object event
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
void wakeup_event_handler(lv_obj_t * obj, lv_event_t event)
|
void wakeup_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(obj == lv_disp_get_layer_sys(NULL)) {
|
if(obj == lv_disp_get_layer_sys(NULL)) {
|
||||||
guiCheckSleep(); // wakeup?
|
sleep_check_state(); // wakeup?
|
||||||
lv_obj_set_click(obj, false); // disable fist click
|
lv_obj_set_click(obj, false); // disable fist click
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ void wakeup_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
static void btnmap_event_handler(lv_obj_t * obj, lv_event_t event)
|
static void btnmap_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
guiCheckSleep(); // wakeup?
|
sleep_check_state(); // wakeup?
|
||||||
hasp_send_obj_attribute_val(obj, lv_btnmatrix_get_active_btn(obj));
|
hasp_send_obj_attribute_val(obj, lv_btnmatrix_get_active_btn(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ static void btnmap_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
static void table_event_handler(lv_obj_t * obj, lv_event_t event)
|
static void table_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
guiCheckSleep(); // wakeup?
|
sleep_check_state(); // wakeup?
|
||||||
|
|
||||||
uint16_t row;
|
uint16_t row;
|
||||||
uint16_t col;
|
uint16_t col;
|
||||||
@ -365,7 +365,7 @@ static void table_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
void IRAM_ATTR toggle_event_handler(lv_obj_t * obj, lv_event_t event)
|
void IRAM_ATTR toggle_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
guiCheckSleep(); // wakeup?
|
sleep_check_state(); // wakeup?
|
||||||
hasp_send_obj_attribute_val(obj, lv_checkbox_is_checked(obj));
|
hasp_send_obj_attribute_val(obj, lv_checkbox_is_checked(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ void IRAM_ATTR toggle_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
static void switch_event_handler(lv_obj_t * obj, lv_event_t event)
|
static void switch_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
guiCheckSleep(); // wakeup?
|
sleep_check_state(); // wakeup?
|
||||||
hasp_send_obj_attribute_val(obj, lv_switch_get_state(obj));
|
hasp_send_obj_attribute_val(obj, lv_switch_get_state(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,7 +18,7 @@
|
|||||||
//#include "hasp_gpio.h" included in conf
|
//#include "hasp_gpio.h" included in conf
|
||||||
|
|
||||||
//#include "hasp_eeprom.h"
|
//#include "hasp_eeprom.h"
|
||||||
#include "hasp.h"
|
#include "hasp/hasp.h"
|
||||||
|
|
||||||
#if HASP_USE_EEPROM > 0
|
#if HASP_USE_EEPROM > 0
|
||||||
#include "EEPROM.h"
|
#include "EEPROM.h"
|
||||||
|
@ -27,12 +27,14 @@
|
|||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hasp.h"
|
|
||||||
#include "hasp_hal.h"
|
|
||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
|
|
||||||
|
#include "hasp_hal.h"
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
|
#include "hasp/hasp_dispatch.h"
|
||||||
|
#include "hasp/hasp.h"
|
||||||
|
|
||||||
#ifdef USE_CONFIG_OVERRIDE
|
#ifdef USE_CONFIG_OVERRIDE
|
||||||
#include "user_config_override.h"
|
#include "user_config_override.h"
|
||||||
@ -426,6 +428,10 @@ static void debugPrintTag(uint8_t tag, Print * _logOutput)
|
|||||||
_logOutput->print(F("HASP"));
|
_logOutput->print(F("HASP"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TAG_DRVR:
|
||||||
|
_logOutput->print(F("DRVR"));
|
||||||
|
break;
|
||||||
|
|
||||||
case TAG_ATTR:
|
case TAG_ATTR:
|
||||||
_logOutput->print(F("ATTR"));
|
_logOutput->print(F("ATTR"));
|
||||||
break;
|
break;
|
||||||
|
@ -40,6 +40,7 @@ enum {
|
|||||||
TAG_MSGR = 3,
|
TAG_MSGR = 3,
|
||||||
TAG_OOBE = 4,
|
TAG_OOBE = 4,
|
||||||
TAG_HAL = 5,
|
TAG_HAL = 5,
|
||||||
|
TAG_DRVR = 6,
|
||||||
|
|
||||||
TAG_DEBG = 10,
|
TAG_DEBG = 10,
|
||||||
TAG_TELN = 11,
|
TAG_TELN = 11,
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
#include "hasp_gpio.h"
|
#include "hasp_gpio.h"
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
#include "hasp.h"
|
#include "hasp/hasp_dispatch.h"
|
||||||
|
#include "hasp/hasp.h"
|
||||||
|
|
||||||
uint8_t gpioUsedInputCount = 0;
|
uint8_t gpioUsedInputCount = 0;
|
||||||
|
|
||||||
|
@ -10,11 +10,12 @@
|
|||||||
#include "../lv_components.h"
|
#include "../lv_components.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hasp_object.h"
|
|
||||||
#include "hasp_gui.h"
|
#include "hasp_gui.h"
|
||||||
#include "hasp_wifi.h"
|
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
|
#include "net/hasp_wifi.h"
|
||||||
|
#include "hasp/hasp_dispatch.h"
|
||||||
|
#include "hasp/hasp_object.h"
|
||||||
|
|
||||||
static bool oobeAutoCalibrate = true;
|
static bool oobeAutoCalibrate = true;
|
||||||
|
|
||||||
|
11
src/main.cpp
11
src/main.cpp
@ -8,9 +8,12 @@
|
|||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_gui.h"
|
#include "hasp_gui.h"
|
||||||
#include "hasp_oobe.h"
|
#include "hasp_oobe.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
#include "hasp_network.h"
|
#include "hasp/hasp_dispatch.h"
|
||||||
#include "hasp.h"
|
#include "hasp/hasp_sleep.h"
|
||||||
|
#include "hasp/hasp.h"
|
||||||
|
|
||||||
|
#include "net/hasp_network.h"
|
||||||
|
|
||||||
bool isConnected;
|
bool isConnected;
|
||||||
uint8_t mainLoopCounter = 0;
|
uint8_t mainLoopCounter = 0;
|
||||||
@ -153,7 +156,7 @@ void loop()
|
|||||||
/* Timer Loop */
|
/* Timer Loop */
|
||||||
if(millis() - mainLastLoopTime >= 1000) {
|
if(millis() - mainLastLoopTime >= 1000) {
|
||||||
/* Runs Every Second */
|
/* Runs Every Second */
|
||||||
guiEverySecond(); // sleep timer
|
sleepEverySecond();
|
||||||
debugEverySecond(); // statusupdate
|
debugEverySecond(); // statusupdate
|
||||||
#if HASP_USE_OTA > 0
|
#if HASP_USE_OTA > 0
|
||||||
otaEverySecond(); // progressbar
|
otaEverySecond(); // progressbar
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
#include "hasp_hal.h"
|
#include "hasp_hal.h"
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_mdns.h"
|
|
||||||
#include "hasp.h"
|
#include "../hasp/hasp.h"
|
||||||
|
#include "../svc/hasp_mdns.h"
|
||||||
|
|
||||||
#if HASP_USE_ETHERNET > 0 || HASP_USE_WIFI > 0
|
#if HASP_USE_ETHERNET > 0 || HASP_USE_WIFI > 0
|
||||||
|
|
@ -11,10 +11,11 @@
|
|||||||
|
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
#include "hasp_network.h"
|
#include "hasp_network.h"
|
||||||
#include "hasp_gui.h"
|
#include "hasp_gui.h"
|
||||||
#include "hasp.h"
|
|
||||||
|
#include "hasp/hasp_dispatch.h"
|
||||||
|
#include "hasp/hasp.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
@ -17,8 +17,9 @@
|
|||||||
#include "hasp_hal.h"
|
#include "hasp_hal.h"
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
#include "hasp.h"
|
#include "hasp/hasp_dispatch.h"
|
||||||
|
#include "hasp/hasp.h"
|
||||||
|
|
||||||
#if HASP_USE_HTTP > 0
|
#if HASP_USE_HTTP > 0
|
||||||
|
|
||||||
@ -1620,9 +1621,9 @@ void webHandleFirmware()
|
|||||||
"name='filename' accept='.bin'>");
|
"name='filename' accept='.bin'>");
|
||||||
httpMessage += F("<button type='submit'>Update Firmware</button></form></p>");
|
httpMessage += F("<button type='submit'>Update Firmware</button></form></p>");
|
||||||
|
|
||||||
httpMessage += F("<p><form action='/update' method='post' enctype='multipart/form-data'><input type='file' "
|
// httpMessage += F("<p><form action='/update' method='post' enctype='multipart/form-data'><input type='file' "
|
||||||
"name='filename' accept='.spiffs'>");
|
// "name='filename' accept='.spiffs'>");
|
||||||
httpMessage += F("<button type='submit'>Replace Filesystem Image</button></form></p>");
|
// httpMessage += F("<button type='submit'>Replace Filesystem Image</button></form></p>");
|
||||||
|
|
||||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||||
|
|
@ -35,8 +35,9 @@ EthernetClient mqttNetworkClient;
|
|||||||
#include "hasp_hal.h"
|
#include "hasp_hal.h"
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
#include "hasp.h"
|
#include "../hasp/hasp_dispatch.h"
|
||||||
|
#include "../hasp/hasp.h"
|
||||||
|
|
||||||
#ifdef USE_CONFIG_OVERRIDE
|
#ifdef USE_CONFIG_OVERRIDE
|
||||||
#include "user_config_override.h"
|
#include "user_config_override.h"
|
@ -6,9 +6,10 @@
|
|||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
|
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
#include "hasp_ota.h"
|
#include "hasp_ota.h"
|
||||||
#include "hasp.h"
|
|
||||||
|
#include "../hasp/hasp_dispatch.h"
|
||||||
|
#include "../hasp/hasp.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
@ -9,9 +9,10 @@
|
|||||||
|
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
|
||||||
#include "hasp_telnet.h"
|
#include "hasp_telnet.h"
|
||||||
|
|
||||||
|
#include "../hasp/hasp_dispatch.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
WiFiClient telnetClient;
|
WiFiClient telnetClient;
|
Loading…
x
Reference in New Issue
Block a user