mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
commit
d9fa0d5d58
@ -26,6 +26,6 @@ When the `edit.htm.gz` file is present on Spiffs you will see an additional File
|
||||
Using that webpage, you can right-click and delete files:
|
||||

|
||||
|
||||
#### :question: Is there a file browser built-in?
|
||||
#### :question: How to delete files from flash?
|
||||
|
||||
*See: Is there a file browser built-in?*
|
@ -1,3 +1,7 @@
|
||||
There are 2 ways to create an object on the screen:
|
||||
- Uploading a pages.jsonl file onto the internal flash
|
||||
- Use the `jsonl` command, via MQTT, serial or telnet console
|
||||
|
||||
## Common Properties
|
||||
|
||||
These are the common properties shared among all objects:
|
||||
@ -46,6 +50,23 @@ You can still hide the object on select pages if needed. Objects on this page ap
|
||||
Each object type is an ID that indicates which object type that line represents.
|
||||
Besides the common properties listed above, each object type can have specific properties.
|
||||
|
||||
### Cheatsheet
|
||||
|
||||
| objid | Type |
|
||||
|:-----:|:-----------|
|
||||
| 10 | [Button](13-objects?id=button) |
|
||||
| 11 | [Checkbox](13-objects?id=checkbox) |
|
||||
| 12 | [Label](13-objects?id=text-label) |
|
||||
| 20 | [Colorpicker](13-objects?id=colorpicker) |
|
||||
| 21 | [Spinner](13-objects?id=spinner) |
|
||||
| 22 | [Arc](13-objects?id=arc) |
|
||||
| 30 | [Slider](13-objects?id=slider) |
|
||||
| 31 | [Gauge](13-objects?id=gauge) |
|
||||
| 32 | [Progressbar](13-objects?id=progressbar) |
|
||||
| 40 | [Switch](13-objects?id=switch) |
|
||||
| 41 | [LED](13-objects?id=led-indicator) |
|
||||
| 50 | [Dropdown List](13-objects?id=dropdown-list) |
|
||||
| 51 | [Roller](13-objects?id=roller) |
|
||||
|
||||
### Button
|
||||
**objid:10**
|
||||
@ -239,7 +260,7 @@ When the item is changed both `val` and `txt` of the newly selected item are sen
|
||||
| txt | string | no | "" | *Read-only* The text of the selected item
|
||||
| rows | int8 | no | 3 | The number ow rows that are visible
|
||||
|
||||
?> A roller does not use the `h` attribute to set its height, but uses the rows to set the visible number of rows instead.
|
||||
!> A roller does not use the `h` attribute to set its height but uses the `rows` attribute instead.
|
||||
|
||||
To change the currently selected item, use the `val` attribute.
|
||||
To change the items in the list, use the `options` attribute.
|
||||
|
@ -39,11 +39,16 @@
|
||||
- [STM32F4xx](./39-firmware-stm32.md)
|
||||
|
||||
- **Hardware**
|
||||
- Alternate Dev Boards
|
||||
|
||||
<!--
|
||||
- Devices to be tested
|
||||
- [Lanbon L8 Switch](displays/lanbon-l8.md)
|
||||
- [Wireless-Tag](displays/wt32-sc01.md)
|
||||
- [BTT TFT70 V3.0](displays/btt-tft70-v3.0.md)
|
||||
-->
|
||||
|
||||
- Tested Displays
|
||||
- [MHS4001](displays/MHS4001.md)
|
||||
- [WaveShare 4.0" RPi LCD (rev C)](displays/Waveshare_40RPi_LCD(C).md)
|
||||
- [MRB3511](displays/MRB3511.md)
|
||||
* [MHS4001](displays/MHS4001.md)
|
||||
* [MRB3511](displays/MRB3511.md)
|
||||
* [WaveShare 4.0" RPi LCD (rev C)](displays/Waveshare_40RPi_LCD(C).md)
|
||||
|
||||
- [**License**](21-license.md)
|
@ -1,21 +1,25 @@
|
||||
# Hasp-lvgl Documentation
|
||||
# Hasp-lvgl
|
||||
|
||||
## Purpose
|
||||
|
||||
Hasp-lvgl is a microcontroller firmware that can run on ESP and STM32F4 with an off-the-shelve touch display.
|
||||
Hasp-lvgl is a microcontroller firmware that runs on ESP and STM32F4 boards using an off-the-shelve touch display.
|
||||
You can use the hasp-lvgl firmware to create a custom touchscreen user interface.
|
||||
It can display information and you can create objects like touch buttons, switches and LEDs on the touchscreen to interact with your home automation system.
|
||||
|
||||
The communication is done over the network via MQTT.
|
||||
It can display information received over mqtt and you can create on-screen objects to interact with your home automation system,
|
||||
like touch buttons, switches, LEDs and more...
|
||||
|
||||
This project is a re-implementation of the popular HASwitchPlate sketch created by aderusha. The original HASwitchPlate project uses a Wemos D1 mini and requires a Nextion/TJC HMI display. This rewrite removes the Nextion/TJC requirement by using the Littlev Graphics Library on the MCU to drive a cheap commodity display.
|
||||
|
||||
This version also adds ESP32 and STM32F4 support to take advantage of the additional hardware capabilities.
|
||||
|
||||
## Requirements
|
||||
|
||||
To run the firmware, you only need a compatible microcontroller and touch display.
|
||||
To run the firmware, you only need a compatible [microcontroller](01-hardware?id=recommended-boards) and [touch display](01-hardware?id=recommended-display).
|
||||
|
||||
## Support
|
||||
|
||||
For support using hasp-lvgl, please join the Discord channel
|
||||

|
||||
|
||||
<!--
|
||||
**If you enjoy this software, please consider [supporting me](https://www.paypal.me/netwizeBE) for developing and maintaining it.**
|
||||
|
||||
[](https://www.paypal.me/netwizeBE)
|
||||
-->
|
@ -4,18 +4,18 @@
|
||||
#define HASP_USE_APP 1
|
||||
|
||||
/* Network Services */
|
||||
#define HASP_HAS_NETWORK (ARDUINO_ARCH_ESP32 > 0 || ARDUINO_ARCH_ESP8266 > 0)
|
||||
|
||||
#ifndef HASP_USE_OTA
|
||||
#define HASP_USE_OTA (HASP_HAS_NETWORK)
|
||||
#ifndef HASP_USE_ETHERNET
|
||||
#define HASP_USE_ETHERNET 0
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#ifndef HASP_USE_ETHERNET
|
||||
#define HASP_USE_ETHERNET 0
|
||||
#define HASP_HAS_NETWORK (ARDUINO_ARCH_ESP32 > 0 || ARDUINO_ARCH_ESP8266 > 0 || HASP_USE_ETHERNET > 0 || HASP_USE_WIFI > 0)
|
||||
|
||||
#ifndef HASP_USE_OTA
|
||||
#define HASP_USE_OTA (HASP_HAS_NETWORK)
|
||||
#endif
|
||||
|
||||
#ifndef HASP_USE_MQTT
|
||||
@ -124,7 +124,7 @@
|
||||
#endif
|
||||
|
||||
#if HASP_USE_WIFI > 0
|
||||
#include "hasp_wifi.h"
|
||||
#include "net/hasp_wifi.h"
|
||||
|
||||
#if defined(STM32F4xx)
|
||||
#include "WiFiSpi.h"
|
||||
@ -144,7 +144,7 @@ static WiFiSpiClass WiFi;
|
||||
#define ETH_TYPE ETH_PHY_LAN8720
|
||||
#define ETH_CLKMODE ETH_CLOCK_GPIO17_OUT
|
||||
|
||||
#include "hasp_ethernet_esp32.h"
|
||||
#include "net/hasp_ethernet_esp32.h"
|
||||
#warning Using ESP32 Ethernet LAN8720
|
||||
|
||||
#else
|
||||
@ -160,12 +160,12 @@ static WiFiSpiClass WiFi;
|
||||
#include "Ethernet.h"
|
||||
#warning Use W5x00 Ethernet shield
|
||||
#endif
|
||||
#include "hasp_ethernet_stm32.h"
|
||||
#include "net/hasp_ethernet_stm32.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HASP_USE_MQTT > 0
|
||||
#include "hasp_mqtt.h"
|
||||
#include "svc/hasp_mqtt.h"
|
||||
#endif
|
||||
|
||||
#if HASP_USE_GPIO > 0
|
||||
@ -173,23 +173,19 @@ static WiFiSpiClass WiFi;
|
||||
#endif
|
||||
|
||||
#if HASP_USE_HTTP > 0
|
||||
#include "hasp_http.h"
|
||||
#include "svc/hasp_http.h"
|
||||
#endif
|
||||
|
||||
#if HASP_USE_TELNET > 0
|
||||
#include "hasp_telnet.h"
|
||||
#include "svc/hasp_telnet.h"
|
||||
#endif
|
||||
|
||||
#if HASP_USE_MDNS > 0
|
||||
#include "hasp_mdns.h"
|
||||
#endif
|
||||
|
||||
#if HASP_USE_BUTTON > 0
|
||||
#include "hasp_button.h"
|
||||
#include "svc/hasp_mdns.h"
|
||||
#endif
|
||||
|
||||
#if HASP_USE_OTA > 0
|
||||
#include "hasp_ota.h"
|
||||
#include "svc/hasp_ota.h"
|
||||
#ifndef HASP_OTA_PORT
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#define HASP_OTA_PORT 3232
|
||||
@ -200,7 +196,7 @@ static WiFiSpiClass WiFi;
|
||||
#endif
|
||||
|
||||
#if HASP_USE_TASMOTA_SLAVE > 0
|
||||
#include "hasp_slave.h"
|
||||
#include "svc/hasp_slave.h"
|
||||
#endif
|
||||
|
||||
#ifndef FPSTR
|
||||
|
@ -109,7 +109,7 @@ void tft_espi_calibrate(uint16_t * calData)
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
tft.println(PSTR("Touch corners as indicated"));
|
||||
// tft.println(PSTR("Touch corners as indicated"));
|
||||
|
||||
tft.setTextFont(1);
|
||||
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.h" // for hasp_sleep_state
|
||||
extern uint8_t hasp_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 && hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_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_dispatch.h"
|
||||
//#include "hasp_filesystem.h" included in hasp_conf.h
|
||||
#include "hasp_wifi.h"
|
||||
#include "hasp_gui.h"
|
||||
|
||||
#include "hasp_attribute.h"
|
||||
@ -61,6 +60,9 @@ LV_IMG_DECLARE(img_bubble_pattern)
|
||||
void haspLoadPage(const char * pages);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
uint8_t hasp_sleep_state = HASP_SLEEP_OFF; // Used in hasp_drv_touch.cpp
|
||||
static uint16_t sleepTimeShort = 60; // 1 second resolution
|
||||
static uint16_t sleepTimeLong = 120; // 1 second resolution
|
||||
|
||||
uint8_t haspStartDim = 100;
|
||||
uint8_t haspStartPage = 0;
|
||||
@ -90,6 +92,49 @@ lv_font_t * hasp_get_font(uint8_t fontid)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WakeUp the display using a command instead of touch
|
||||
*/
|
||||
void hasp_wakeup()
|
||||
{
|
||||
lv_disp_trig_activity(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if sleep state needs to be updated
|
||||
*/
|
||||
bool IRAM_ATTR hasp_update_sleep_state()
|
||||
{
|
||||
uint32_t idle = lv_disp_get_inactive_time(NULL);
|
||||
|
||||
if(idle >= (sleepTimeShort + sleepTimeLong) * 1000U) {
|
||||
if(hasp_sleep_state != HASP_SLEEP_LONG) {
|
||||
dispatch_output_idle_state(HASP_SLEEP_LONG);
|
||||
hasp_sleep_state = HASP_SLEEP_LONG;
|
||||
}
|
||||
} else if(idle >= sleepTimeShort * 1000U) {
|
||||
if(hasp_sleep_state != HASP_SLEEP_SHORT) {
|
||||
dispatch_output_idle_state(HASP_SLEEP_SHORT);
|
||||
hasp_sleep_state = HASP_SLEEP_SHORT;
|
||||
}
|
||||
} else {
|
||||
if(hasp_sleep_state != HASP_SLEEP_OFF) {
|
||||
dispatch_output_idle_state(HASP_SLEEP_OFF);
|
||||
hasp_sleep_state = HASP_SLEEP_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
return (hasp_sleep_state != HASP_SLEEP_OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if we went to sleep, wake up is handled in the event handlers
|
||||
*/
|
||||
// void haspEverySecond()
|
||||
// {
|
||||
// hasp_update_sleep_state();
|
||||
// }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Get Page Object by PageID
|
||||
@ -235,7 +280,7 @@ static void custom_font_apply_cb(lv_theme_t * th, lv_obj_t * obj, lv_theme_style
|
||||
/**
|
||||
* Create a demo application
|
||||
*/
|
||||
void haspSetup()
|
||||
void haspSetup(void)
|
||||
{
|
||||
guiSetDim(haspStartDim);
|
||||
|
@ -7,7 +7,8 @@
|
||||
#include <Arduino.h>
|
||||
#include "lvgl.h"
|
||||
#include "hasp_conf.h"
|
||||
#include "hasp_debug.h"
|
||||
|
||||
#include "../hasp_debug.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -22,6 +23,9 @@ extern "C" {
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define HASP_SLEEP_OFF 0
|
||||
#define HASP_SLEEP_SHORT 1
|
||||
#define HASP_SLEEP_LONG 2
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -34,8 +38,10 @@ extern "C" {
|
||||
/**
|
||||
* Create a hasp application
|
||||
*/
|
||||
void haspSetup();
|
||||
void haspSetup(void);
|
||||
void IRAM_ATTR haspLoop(void);
|
||||
//void haspEverySecond(void); // See MACROS
|
||||
|
||||
void haspReconnect(void);
|
||||
void haspDisconnect(void);
|
||||
|
||||
@ -58,9 +64,13 @@ bool haspSetConfig(const JsonObject & settings);
|
||||
|
||||
lv_font_t * hasp_get_font(uint8_t fontid);
|
||||
|
||||
bool IRAM_ATTR hasp_update_sleep_state();
|
||||
void hasp_wakeup(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#define haspEverySecond hasp_update_sleep_state
|
||||
|
||||
#endif /*HASP_USE_APP*/
|
||||
|
@ -7,15 +7,18 @@
|
||||
#include "hasp_conf.h"
|
||||
|
||||
#include "hasp_dispatch.h"
|
||||
#include "hasp_network.h" // for network_get_status()
|
||||
#include "hasp_debug.h"
|
||||
#include "hasp_object.h"
|
||||
#include "hasp.h"
|
||||
|
||||
#include "hasp_debug.h"
|
||||
#include "hasp_gui.h"
|
||||
#include "hasp_oobe.h"
|
||||
#include "hasp_mqtt.h"
|
||||
#include "hasp_gpio.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
|
||||
#include "hasp_config.h"
|
||||
@ -472,9 +475,11 @@ void dispatch_parse_json(const char *, const char * payload)
|
||||
|
||||
} else if(json.is<JsonArray>()) { // handle json as an array of commands
|
||||
JsonArray arr = json.as<JsonArray>();
|
||||
guiStop();
|
||||
for(JsonVariant command : arr) {
|
||||
dispatch_text_line(command.as<String>().c_str());
|
||||
}
|
||||
guiStart();
|
||||
} else if(json.is<JsonObject>()) { // handle json as a jsonl
|
||||
uint8_t savedPage = haspGetPage();
|
||||
hasp_new_object(json.as<JsonObject>(), savedPage);
|
||||
@ -500,11 +505,13 @@ void dispatch_parse_jsonl(Stream & stream)
|
||||
DynamicJsonDocument jsonl(4 * 128u); // max ~256 characters per line
|
||||
DeserializationError err = deserializeJson(jsonl, stream);
|
||||
|
||||
guiStop();
|
||||
while(err == DeserializationError::Ok) {
|
||||
hasp_new_object(jsonl.as<JsonObject>(), savedPage);
|
||||
err = deserializeJson(jsonl, stream);
|
||||
line++;
|
||||
}
|
||||
guiStart();
|
||||
|
||||
/* For debugging pourposes */
|
||||
if(err == DeserializationError::EmptyInput) {
|
||||
@ -685,7 +692,7 @@ void dispatch_calibrate(const char *, const char *)
|
||||
|
||||
void dispatch_wakeup(const char *, const char *)
|
||||
{
|
||||
guiWakeUp();
|
||||
hasp_wakeup();
|
||||
}
|
||||
|
||||
void dispatch_reboot(const char *, const char *)
|
@ -21,7 +21,6 @@
|
||||
#endif
|
||||
|
||||
#include "hasp.h"
|
||||
#include "hasp_gui.h"
|
||||
#include "hasp_object.h"
|
||||
#include "hasp_dispatch.h"
|
||||
#include "hasp_attribute.h"
|
||||
@ -311,7 +310,7 @@ void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
return;
|
||||
}
|
||||
|
||||
guiCheckSleep(); // wakeup?
|
||||
hasp_update_sleep_state(); // wakeup?
|
||||
dispatch_object_event(obj, eventid); // send object event
|
||||
}
|
||||
|
||||
@ -323,7 +322,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)
|
||||
{
|
||||
if(obj == lv_disp_get_layer_sys(NULL)) {
|
||||
guiCheckSleep(); // wakeup?
|
||||
hasp_update_sleep_state(); // wakeup?
|
||||
lv_obj_set_click(obj, false); // disable fist click
|
||||
}
|
||||
}
|
||||
@ -336,7 +335,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)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
guiCheckSleep(); // wakeup?
|
||||
hasp_update_sleep_state(); // wakeup?
|
||||
hasp_send_obj_attribute_val(obj, lv_btnmatrix_get_active_btn(obj));
|
||||
}
|
||||
}
|
||||
@ -349,7 +348,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)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
guiCheckSleep(); // wakeup?
|
||||
hasp_update_sleep_state(); // wakeup?
|
||||
|
||||
uint16_t row;
|
||||
uint16_t col;
|
||||
@ -365,7 +364,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)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
guiCheckSleep(); // wakeup?
|
||||
hasp_update_sleep_state(); // wakeup?
|
||||
hasp_send_obj_attribute_val(obj, lv_checkbox_is_checked(obj));
|
||||
}
|
||||
}
|
||||
@ -378,7 +377,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)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
guiCheckSleep(); // wakeup?
|
||||
hasp_update_sleep_state(); // wakeup?
|
||||
hasp_send_obj_attribute_val(obj, lv_switch_get_state(obj));
|
||||
}
|
||||
}
|
@ -8,44 +8,41 @@
|
||||
#include "lvgl.h"
|
||||
|
||||
enum lv_hasp_obj_type_t {
|
||||
LV_HASP_BTNMATRIX = 1,
|
||||
LV_HASP_TABLE = 2,
|
||||
LV_HASP_CONTAINER = 90,
|
||||
LV_HASP_OBJECT = 91,
|
||||
LV_HASP_PAGE = 92,
|
||||
|
||||
LV_HASP_LABEL = 12,
|
||||
LV_HASP_DDLIST = 50,
|
||||
LV_HASP_ROLLER = 51,
|
||||
|
||||
LV_HASP_BUTTON = 10,
|
||||
LV_HASP_CHECKBOX = 11,
|
||||
LV_HASP_LABEL = 12,
|
||||
|
||||
LV_HASP_CPICKER = 20,
|
||||
LV_HASP_PRELOADER = 21,
|
||||
LV_HASP_ARC = 22,
|
||||
LV_HASP_SWITCH = 40,
|
||||
LV_HASP_LED = 41,
|
||||
|
||||
LV_HASP_SLIDER = 30,
|
||||
LV_HASP_GAUGE = 31,
|
||||
LV_HASP_BAR = 32,
|
||||
LV_HASP_LMETER = 33,
|
||||
|
||||
LV_HASP_SWITCH = 40,
|
||||
LV_HASP_LED = 41,
|
||||
|
||||
LV_HASP_DDLIST = 50,
|
||||
LV_HASP_ROLLER = 51,
|
||||
LV_HASP_ARC = 22,
|
||||
LV_HASP_PRELOADER = 21,
|
||||
LV_HASP_CPICKER = 20,
|
||||
|
||||
LV_HASP_IMAGE = 60,
|
||||
LV_HASP_IMGBTN = 61,
|
||||
LV_HASP_CANVAS = 62,
|
||||
|
||||
LV_HASP_BTNMATRIX = 1,
|
||||
LV_HASP_TABLE = 2,
|
||||
LV_HASP_CALENDER = 81,
|
||||
LV_HASP_CHART = 80,
|
||||
LV_HASP_TILEVIEW = 70,
|
||||
LV_HASP_TABVIEW = 71,
|
||||
LV_HASP_TAB = 72,
|
||||
|
||||
LV_HASP_CHART = 80,
|
||||
LV_HASP_CALENDER = 81,
|
||||
|
||||
LV_HASP_CONTAINER = 90,
|
||||
LV_HASP_OBJECT = 91,
|
||||
LV_HASP_PAGE = 92,
|
||||
LV_HASP_MSGBOX = 93,
|
||||
LV_HASP_WINDOW = 94,
|
||||
LV_HASP_MSGBOX = 93,
|
||||
};
|
||||
|
||||
void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id);
|
@ -18,7 +18,7 @@
|
||||
//#include "hasp_gpio.h" included in conf
|
||||
|
||||
//#include "hasp_eeprom.h"
|
||||
#include "hasp.h"
|
||||
#include "hasp/hasp.h"
|
||||
|
||||
#if HASP_USE_EEPROM > 0
|
||||
#include "EEPROM.h"
|
||||
|
@ -27,12 +27,14 @@
|
||||
#include <WiFiUdp.h>
|
||||
#endif
|
||||
|
||||
#include "hasp.h"
|
||||
#include "hasp_hal.h"
|
||||
#include "hasp_conf.h"
|
||||
|
||||
#include "hasp_hal.h"
|
||||
#include "hasp_debug.h"
|
||||
#include "hasp_config.h"
|
||||
#include "hasp_dispatch.h"
|
||||
|
||||
#include "hasp/hasp_dispatch.h"
|
||||
#include "hasp/hasp.h"
|
||||
|
||||
#ifdef USE_CONFIG_OVERRIDE
|
||||
#include "user_config_override.h"
|
||||
@ -426,6 +428,10 @@ static void debugPrintTag(uint8_t tag, Print * _logOutput)
|
||||
_logOutput->print(F("HASP"));
|
||||
break;
|
||||
|
||||
case TAG_DRVR:
|
||||
_logOutput->print(F("DRVR"));
|
||||
break;
|
||||
|
||||
case TAG_ATTR:
|
||||
_logOutput->print(F("ATTR"));
|
||||
break;
|
||||
@ -600,9 +606,6 @@ void debugPrintSuffix(uint8_t tag, int level, Print * _logOutput)
|
||||
|
||||
void debugPreSetup(JsonObject settings)
|
||||
{
|
||||
// Link stream to debugOutput
|
||||
// debugOutput.reserve(512);
|
||||
|
||||
Log.begin(LOG_LEVEL_WARNING, true);
|
||||
Log.setPrefix(debugPrintPrefix); // Uncomment to get timestamps as prefix
|
||||
Log.setSuffix(debugPrintSuffix); // Uncomment to get newline as suffix
|
||||
|
@ -40,6 +40,7 @@ enum {
|
||||
TAG_MSGR = 3,
|
||||
TAG_OOBE = 4,
|
||||
TAG_HAL = 5,
|
||||
TAG_DRVR = 6,
|
||||
|
||||
TAG_DEBG = 10,
|
||||
TAG_TELN = 11,
|
||||
|
@ -7,8 +7,9 @@
|
||||
#include "hasp_conf.h"
|
||||
#include "hasp_gpio.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;
|
||||
|
||||
|
343
src/hasp_gui.cpp
343
src/hasp_gui.cpp
@ -11,37 +11,24 @@
|
||||
#include "lv_misc/lv_fs.h"
|
||||
#include "lv_fs_if.h"
|
||||
|
||||
// Select Display Driver
|
||||
#if defined(USE_FSMC)
|
||||
#include "fsmc_ili9341.h"
|
||||
#else
|
||||
#include "tft_espi_drv.h"
|
||||
#endif
|
||||
|
||||
// Select Touch Driver
|
||||
//#include "indev/XPT2046_alt_drv.h"
|
||||
#include "indev/XPT2046.h"
|
||||
|
||||
//#include "lv_zifont.h"
|
||||
// Device Drivers
|
||||
#include "drv/hasp_drv_display.h"
|
||||
#include "drv/hasp_drv_touch.h"
|
||||
|
||||
#include "hasp_debug.h"
|
||||
#include "hasp_config.h"
|
||||
#include "hasp_dispatch.h"
|
||||
#include "hasp_gui.h"
|
||||
#include "hasp_oobe.h"
|
||||
#include "hasp.h"
|
||||
|
||||
//#include "lv_ex_conf.h"
|
||||
#include "hasp/hasp_dispatch.h"
|
||||
#include "hasp/hasp.h"
|
||||
|
||||
//#include "tpcal.h"
|
||||
|
||||
#include "Ticker.h"
|
||||
|
||||
#if HASP_USE_PNGDECODE > 0
|
||||
#include "png_decoder.h"
|
||||
#endif
|
||||
|
||||
#ifndef TOUCH_DRIVER
|
||||
#define TOUCH_DRIVER -1 // No Touch
|
||||
#include "png_decoder.h"
|
||||
#endif
|
||||
|
||||
#define BACKLIGHT_CHANNEL 15 // pwm channel 0-15
|
||||
@ -53,10 +40,10 @@ File pFileOut;
|
||||
#define LVGL_TICK_PERIOD 20
|
||||
|
||||
#ifndef TFT_BCKL
|
||||
#define TFT_BCKL -1 // No Backlight Control
|
||||
#define TFT_BCKL -1 // No Backlight Control
|
||||
#endif
|
||||
#ifndef TFT_ROTATION
|
||||
#define TFT_ROTATION 0
|
||||
#define TFT_ROTATION 0
|
||||
#endif
|
||||
|
||||
static void IRAM_ATTR lv_tick_handler(void);
|
||||
@ -67,11 +54,9 @@ static int8_t guiDimLevel = -1;
|
||||
static int8_t guiBacklightPin = TFT_BCKL;
|
||||
static uint16_t guiSleepTime1 = 60; // 1 second resolution
|
||||
static uint16_t guiSleepTime2 = 120; // 1 second resolution
|
||||
static uint8_t guiSleeping = HASP_SLEEP_OFF;
|
||||
static uint8_t guiTickPeriod = 20;
|
||||
static uint8_t guiRotation = TFT_ROTATION;
|
||||
// static TFT_eSPI tft; // = TFT_eSPI(); /* TFT instance */
|
||||
static uint16_t calData[5] = {0, 65535, 0, 65535, 0};
|
||||
static uint16_t calData[5] = {0, 65535, 0, 65535, 0};
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||
static Ticker tick; /* timer for interrupt handler */
|
||||
@ -79,67 +64,16 @@ static Ticker tick; /* timer for interrupt handler */
|
||||
static Ticker tick(lv_tick_handler, LVGL_TICK_PERIOD); // guiTickPeriod);
|
||||
#endif
|
||||
|
||||
/* **************************** SLEEP & WAKEUP ************************************** */
|
||||
bool IRAM_ATTR guiCheckSleep()
|
||||
/* **************************** FLUSH DATA TO TFT ******************************* */
|
||||
|
||||
/* Defines the actual driver callback to use */
|
||||
static void gui_flush_cb(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
uint32_t idle = lv_disp_get_inactive_time(NULL);
|
||||
|
||||
if(idle >= (guiSleepTime1 + guiSleepTime2) * 1000U) {
|
||||
if(guiSleeping != HASP_SLEEP_LONG) {
|
||||
dispatch_output_idle_state(HASP_SLEEP_LONG);
|
||||
guiSleeping = HASP_SLEEP_LONG;
|
||||
}
|
||||
} else if(idle >= guiSleepTime1 * 1000U) {
|
||||
if(guiSleeping != HASP_SLEEP_SHORT) {
|
||||
dispatch_output_idle_state(HASP_SLEEP_SHORT);
|
||||
guiSleeping = HASP_SLEEP_SHORT;
|
||||
}
|
||||
} else {
|
||||
if(guiSleeping != HASP_SLEEP_OFF) {
|
||||
dispatch_output_idle_state(HASP_SLEEP_OFF);
|
||||
guiSleeping = HASP_SLEEP_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
return (guiSleeping != HASP_SLEEP_OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* WakeUp the display using a command instead of touch
|
||||
*/
|
||||
void guiWakeUp()
|
||||
{
|
||||
lv_disp_trig_activity(NULL);
|
||||
}
|
||||
|
||||
/* **************************** SCREENSHOTS ************************************** */
|
||||
|
||||
/* After flusing to the file stream or web client, we also send the buffer to the tft */
|
||||
static void IRAM_ATTR printscreen_flush_cb(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
#if 0
|
||||
size_t len = (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1); /* Number of pixels */
|
||||
|
||||
/* Update TFT */
|
||||
tft.startWrite(); /* Start new TFT transaction */
|
||||
tft.setWindow(area->x1, area->y1, area->x2, area->y2); /* set the working window */
|
||||
tft.pushPixels((uint16_t *)color_p, len); /* Write words at once */
|
||||
tft.endWrite(); /* terminate TFT transaction */
|
||||
|
||||
/* Send Screenshot data */
|
||||
// if(guiSnapshot != 0) {
|
||||
// gui_take_screenshot(disp, area, color_p);
|
||||
//}
|
||||
#endif
|
||||
|
||||
#if defined(USE_FSMC)
|
||||
fsmc_ili9341_flush(disp, area, color_p);
|
||||
#else
|
||||
tft_espi_flush(disp, area, color_p);
|
||||
#endif
|
||||
|
||||
/* Tell lvgl that flushing is done */
|
||||
// lv_disp_flush_ready(disp); ===> moved into the drivers
|
||||
}
|
||||
|
||||
/* **************************** GUI TICKER ************************************** */
|
||||
@ -205,7 +139,7 @@ static void ICACHE_RAM_ATTR lv_tick_handler(void)
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// bool my_touchpad_read_raw(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
|
||||
// bool gui_touchpad_read_raw(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
|
||||
// {
|
||||
// #ifdef TOUCH_CS
|
||||
// uint16_t touchX, touchY;
|
||||
@ -227,7 +161,7 @@ static void ICACHE_RAM_ATTR lv_tick_handler(void)
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// if(guiSleeping > 0) guiCheckSleep(); // update Idle
|
||||
// if(sleep_state > 0) hasp_update_sleep_state(); // update Idle
|
||||
|
||||
// /*Save the state and save the pressed coordinate*/
|
||||
// // lv_disp_t * disp = lv_disp_get_default();
|
||||
@ -242,8 +176,8 @@ static void ICACHE_RAM_ATTR lv_tick_handler(void)
|
||||
// return false; /*Return `false` because we are not buffering and no more data to read*/
|
||||
// }
|
||||
|
||||
#if TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller
|
||||
#include "Touchscreen.h" // For Uno Shield or ADC based resistive touchscreens
|
||||
#if TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller
|
||||
#include "Touchscreen.h" // For Uno Shield or ADC based resistive touchscreens
|
||||
|
||||
boolean Touch_getXY(uint16_t * x, uint16_t * y, boolean showTouch)
|
||||
{
|
||||
@ -268,8 +202,8 @@ boolean Touch_getXY(uint16_t * x, uint16_t * y, boolean showTouch)
|
||||
digitalWrite(aYP, HIGH); // because TFT control pins
|
||||
digitalWrite(aXM, HIGH);
|
||||
// adjust pressure sensitivity - note works 'backwards'
|
||||
#define MINPRESSURE 200
|
||||
#define MAXPRESSURE 1000
|
||||
#define MINPRESSURE 200
|
||||
#define MAXPRESSURE 1000
|
||||
bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
|
||||
if(pressed) {
|
||||
|
||||
@ -297,143 +231,12 @@ boolean Touch_getXY(uint16_t * x, uint16_t * y, boolean showTouch)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TOUCH_DRIVER == 911
|
||||
|
||||
#include <Wire.h>
|
||||
#include "Goodix.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;
|
||||
|
||||
void handleTouch(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();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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_setup()
|
||||
{
|
||||
Wire.setClock(400000);
|
||||
Wire.begin();
|
||||
delay(300);
|
||||
|
||||
touch.setHandler(handleTouch);
|
||||
touchStart();
|
||||
Log.trace(TAG_GUI, F("Goodix GT911x touch driver started"));
|
||||
}
|
||||
#endif
|
||||
|
||||
bool IRAM_ATTR my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
|
||||
{
|
||||
#ifdef TOUCH_CS
|
||||
uint16_t touchX, touchY;
|
||||
bool touched;
|
||||
#if TOUCH_DRIVER == 2046 // XPT2046 Resistive touch panel driver
|
||||
touched = tft_espi_get_touch(&touchX, &touchY, 300);
|
||||
#elif TOUCH_DRIVER == 911
|
||||
// return false;
|
||||
touched = GT911_getXY(&touchX, &touchY, true);
|
||||
#elif TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller
|
||||
touched = Touch_getXY(&touchX, &touchY, false);
|
||||
#else
|
||||
// xpt2046_alt_drv_read(indev_driver, data);
|
||||
// xpt2046_read(indev_driver, data);
|
||||
// if(data->state && guiSleeping != HASP_SLEEP_OFF) guiCheckSleep();
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if(touched && guiSleeping != HASP_SLEEP_OFF) guiCheckSleep(); // 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; /*Return `false` because we are not buffering and no more data to read*/
|
||||
}
|
||||
|
||||
void guiCalibrate()
|
||||
{
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0
|
||||
#ifdef TOUCH_CS
|
||||
#ifdef TOUCH_CS
|
||||
tft_espi_calibrate(calData);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for(int i = 0; i < 5; i++) {
|
||||
Serial.print(calData[i]);
|
||||
@ -447,55 +250,45 @@ void guiCalibrate()
|
||||
|
||||
void guiSetup()
|
||||
{
|
||||
/* TFT init */
|
||||
#if defined(USE_FSMC)
|
||||
fsmc_ili9341_init(guiRotation);
|
||||
xpt2046_init(guiRotation);
|
||||
#else
|
||||
tft_espi_init(guiRotation);
|
||||
#endif
|
||||
|
||||
#if TOUCH_DRIVER == 911
|
||||
GT911_setup();
|
||||
#endif
|
||||
// Driver intializations:
|
||||
drv_display_init(guiRotation); // Display
|
||||
drv_touch_init(guiRotation); // Touch
|
||||
lv_init(); // GUI
|
||||
|
||||
#if 0
|
||||
tft.begin();
|
||||
tft.setSwapBytes(true); /* set endianess */
|
||||
|
||||
#ifdef USE_DMA_TO_TFT
|
||||
#ifdef USE_DMA_TO_TFT
|
||||
// DMA - should work with STM32F2xx/F4xx/F7xx processors
|
||||
// NOTE: >>>>>> DMA IS FOR SPI DISPLAYS ONLY <<<<<<
|
||||
tft.initDMA(); // Initialise the DMA engine (tested with STM32F446 and STM32F767)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
tft.setRotation(guiRotation); /* 1/3=Landscape or 0/2=Portrait orientation */
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0
|
||||
tft_espi_set_touch(calData);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Initialize the Virtual Device Buffers */
|
||||
size_t guiVDBsize = 0;
|
||||
lv_init();
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
/* allocate on iram (or psram ?) */
|
||||
static lv_disp_buf_t disp_buf;
|
||||
|
||||
#ifdef USE_DMA_TO_TFT
|
||||
#ifdef USE_DMA_TO_TFT
|
||||
static lv_color_t *guiVdbBuffer1, *guiVdbBuffer2 = NULL;
|
||||
guiVDBsize = 4 * 1024u; // 16 KBytes * 2
|
||||
guiVdbBuffer1 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_DMA);
|
||||
size_t guiVDBsize = 4 * 1024u; // 16 KBytes * 2
|
||||
guiVdbBuffer1 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_DMA);
|
||||
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
|
||||
//guiVdbBuffer2 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_DMA);
|
||||
//lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
|
||||
#else
|
||||
// guiVdbBuffer2 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_DMA);
|
||||
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
|
||||
#else
|
||||
static lv_color_t * guiVdbBuffer1;
|
||||
guiVDBsize = 16 * 1024u; // 32 KBytes * 2
|
||||
guiVdbBuffer1 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_8BIT);
|
||||
size_t guiVDBsize = 16 * 1024u; // 32 KBytes * 2
|
||||
guiVdbBuffer1 = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * guiVDBsize, MALLOC_CAP_8BIT);
|
||||
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// static lv_color_t * guiVdbBuffer2 = (lv_color_t *)malloc(sizeof(lv_color_t) * guiVDBsize);
|
||||
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
|
||||
@ -503,7 +296,7 @@ void guiSetup()
|
||||
/* allocate on heap */
|
||||
static lv_disp_buf_t disp_buf;
|
||||
static lv_color_t guiVdbBuffer1[4 * 512u]; // 4 KBytes
|
||||
guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
|
||||
size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
|
||||
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
|
||||
|
||||
// static lv_disp_buf_t disp_buf;
|
||||
@ -515,7 +308,7 @@ void guiSetup()
|
||||
static lv_disp_buf_t disp_buf;
|
||||
static lv_color_t guiVdbBuffer1[16 * 512u]; // 16 KBytes
|
||||
// static lv_color_t guiVdbBuffer2[16 * 512u]; // 16 KBytes
|
||||
guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
|
||||
size_t guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
|
||||
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, guiVdbBuffer2, guiVDBsize);
|
||||
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
|
||||
#endif
|
||||
@ -531,19 +324,15 @@ void guiSetup()
|
||||
lv_fs_if_init(); // auxilary file system drivers
|
||||
#endif
|
||||
|
||||
/* Dump TFT Configuration */
|
||||
// tftSetup(tft);
|
||||
#ifdef USE_DMA_TO_TFT
|
||||
Log.verbose(TAG_GUI, F("DMA : ENABLED"));
|
||||
#else
|
||||
Log.verbose(TAG_GUI, F("DMA : DISABLED"));
|
||||
#endif
|
||||
|
||||
/* Load User Settings */
|
||||
// guiSetConfig(settings);
|
||||
/* Setup Backlight Control Pin */
|
||||
if(guiBacklightPin >= 0) {
|
||||
Log.verbose(TAG_LVGL, F("Backlight: Pin %d"), guiBacklightPin);
|
||||
Log.verbose(TAG_GUI, F("Backlight: Pin %d"), guiBacklightPin);
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
// pinMode(guiBacklightPin, OUTPUT);
|
||||
@ -555,11 +344,11 @@ void guiSetup()
|
||||
pinMode(guiBacklightPin, OUTPUT);
|
||||
#endif
|
||||
}
|
||||
Log.verbose(TAG_GUI, F("Rotation : %d"), guiRotation);
|
||||
|
||||
Log.verbose(TAG_LVGL, F("Version : %u.%u.%u %s"), LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH,
|
||||
PSTR(LVGL_VERSION_INFO));
|
||||
|
||||
Log.verbose(TAG_LVGL, F("Rotation : %d"), guiRotation);
|
||||
#ifdef LV_MEM_SIZE
|
||||
Log.verbose(TAG_LVGL, F("MEM size : %d"), LV_MEM_SIZE);
|
||||
#endif
|
||||
@ -573,12 +362,15 @@ void guiSetup()
|
||||
/* Initialize the display driver */
|
||||
lv_disp_drv_t disp_drv;
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
#if defined(USE_FSMC)
|
||||
disp_drv.flush_cb = fsmc_ili9341_flush;
|
||||
#else
|
||||
disp_drv.flush_cb = tft_espi_flush;
|
||||
#endif
|
||||
disp_drv.buffer = &disp_buf;
|
||||
disp_drv.buffer = &disp_buf;
|
||||
disp_drv.flush_cb = gui_flush_cb; // static void that uses the appropriate driver
|
||||
|
||||
// #if defined(USE_FSMC)
|
||||
// disp_drv.flush_cb = fsmc_ili9341_flush;
|
||||
// #else
|
||||
// disp_drv.flush_cb = tft_espi_flush;
|
||||
// #endif
|
||||
|
||||
if(guiRotation == 0 || guiRotation == 2 || guiRotation == 4 || guiRotation == 6) {
|
||||
/* 1/3=Landscape or 0/2=Portrait orientation */
|
||||
// Normal width & height
|
||||
@ -590,7 +382,7 @@ void guiSetup()
|
||||
disp_drv.ver_res = TFT_WIDTH;
|
||||
}
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
guiStart();
|
||||
guiStart(); // Ticker
|
||||
|
||||
/* Initialize Global progress bar*/
|
||||
lv_obj_t * bar = lv_bar_create(lv_layer_sys(), NULL);
|
||||
@ -608,13 +400,11 @@ void guiSetup()
|
||||
lv_obj_set_style_local_bg_color(lv_layer_sys(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_obj_set_style_local_bg_opa(lv_layer_sys(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
||||
|
||||
/*Initialize the touch pad*/
|
||||
/* Initialize the touch pad */
|
||||
lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
// indev_drv.type = LV_INDEV_TYPE_ENCODER;
|
||||
// indev_drv.read_cb = read_encoder;
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = my_touchpad_read;
|
||||
indev_drv.read_cb = drv_touch_read;
|
||||
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
|
||||
mouse_indev->driver.type = LV_INDEV_TYPE_POINTER;
|
||||
|
||||
@ -650,16 +440,11 @@ void IRAM_ATTR guiLoop(void)
|
||||
#if defined(STM32F4xx)
|
||||
tick.update();
|
||||
#endif
|
||||
|
||||
#if TOUCH_DRIVER == 911
|
||||
touch.loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
void guiEverySecond(void)
|
||||
{
|
||||
// check if we went to sleep, wake up is handled in the event handlers
|
||||
guiCheckSleep();
|
||||
// nothing
|
||||
}
|
||||
|
||||
void guiStart()
|
||||
@ -764,9 +549,9 @@ bool guiGetConfig(const JsonObject & settings)
|
||||
} else {
|
||||
changed = true;
|
||||
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0 && defined(TOUCH_CS)
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0 && defined(TOUCH_CS)
|
||||
tft_espi_set_touch(calData);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@ -779,9 +564,9 @@ bool guiGetConfig(const JsonObject & settings)
|
||||
}
|
||||
changed = true;
|
||||
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0 && defined(TOUCH_CS)
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0 && defined(TOUCH_CS)
|
||||
tft_espi_set_touch(calData);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if(changed) configOutput(settings, TAG_GUI);
|
||||
@ -838,9 +623,9 @@ bool guiSetConfig(const JsonObject & settings)
|
||||
oobeSetAutoCalibrate(true);
|
||||
}
|
||||
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0 && defined(TOUCH_CS)
|
||||
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0 && defined(TOUCH_CS)
|
||||
if(status) tft_espi_set_touch(calData);
|
||||
#endif
|
||||
#endif
|
||||
changed |= status;
|
||||
}
|
||||
|
||||
@ -922,7 +707,7 @@ static void gui_screenshot_to_file(lv_disp_drv_t * disp, const lv_area_t * area,
|
||||
len *= sizeof(lv_color_t); /* Number of bytes */
|
||||
size_t res = pFileOut.write((uint8_t *)color_p, len);
|
||||
if(res != len) gui_flush_not_complete();
|
||||
printscreen_flush_cb(disp, area, color_p);
|
||||
gui_flush_cb(disp, area, color_p);
|
||||
}
|
||||
|
||||
/** Take Screenshot.
|
||||
@ -976,7 +761,7 @@ static void gui_screenshot_to_http(lv_disp_drv_t * disp, const lv_area_t * area,
|
||||
len *= sizeof(lv_color_t); /* Number of bytes */
|
||||
size_t res = httpClientWrite((uint8_t *)color_p, len);
|
||||
if(res != len) gui_flush_not_complete();
|
||||
printscreen_flush_cb(disp, area, color_p);
|
||||
gui_flush_cb(disp, area, color_p);
|
||||
}
|
||||
|
||||
/** Take Screenshot.
|
||||
|
@ -7,10 +7,6 @@
|
||||
#include "ArduinoJson.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
#define HASP_SLEEP_OFF 0
|
||||
#define HASP_SLEEP_SHORT 1
|
||||
#define HASP_SLEEP_LONG 2
|
||||
|
||||
/* ===== Default Event Processors ===== */
|
||||
void guiSetup();
|
||||
void IRAM_ATTR guiLoop(void);
|
||||
@ -24,12 +20,10 @@ void guiTakeScreenshot(const char * pFileName); // to file
|
||||
void guiTakeScreenshot(); // webclient
|
||||
|
||||
/* ===== Getter and Setter Functions ===== */
|
||||
void guiWakeUp(void);
|
||||
void guiSetDim(int8_t level);
|
||||
int8_t guiGetDim(void);
|
||||
void guiSetBacklight(bool lighton);
|
||||
bool guiGetBacklight();
|
||||
bool IRAM_ATTR guiCheckSleep();
|
||||
|
||||
/* ===== Read/Write Configuration ===== */
|
||||
#if HASP_USE_CONFIG > 0
|
||||
|
@ -10,11 +10,12 @@
|
||||
#include "../lv_components.h"
|
||||
#endif
|
||||
|
||||
#include "hasp_object.h"
|
||||
#include "hasp_gui.h"
|
||||
#include "hasp_wifi.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;
|
||||
|
||||
|
10
src/main.cpp
10
src/main.cpp
@ -8,9 +8,11 @@
|
||||
#include "hasp_config.h"
|
||||
#include "hasp_gui.h"
|
||||
#include "hasp_oobe.h"
|
||||
#include "hasp_dispatch.h"
|
||||
#include "hasp_network.h"
|
||||
#include "hasp.h"
|
||||
|
||||
#include "hasp/hasp_dispatch.h"
|
||||
#include "hasp/hasp.h"
|
||||
|
||||
#include "net/hasp_network.h"
|
||||
|
||||
bool isConnected;
|
||||
uint8_t mainLoopCounter = 0;
|
||||
@ -153,7 +155,7 @@ void loop()
|
||||
/* Timer Loop */
|
||||
if(millis() - mainLastLoopTime >= 1000) {
|
||||
/* Runs Every Second */
|
||||
guiEverySecond(); // sleep timer
|
||||
haspEverySecond();
|
||||
debugEverySecond(); // statusupdate
|
||||
#if HASP_USE_OTA > 0
|
||||
otaEverySecond(); // progressbar
|
||||
|
@ -7,8 +7,9 @@
|
||||
#include "hasp_conf.h"
|
||||
#include "hasp_hal.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
|
||||
|
@ -11,10 +11,11 @@
|
||||
|
||||
#include "hasp_debug.h"
|
||||
#include "hasp_config.h"
|
||||
#include "hasp_dispatch.h"
|
||||
#include "hasp_network.h"
|
||||
#include "hasp_gui.h"
|
||||
#include "hasp.h"
|
||||
|
||||
#include "hasp/hasp_dispatch.h"
|
||||
#include "hasp/hasp.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#include <WiFi.h>
|
@ -17,8 +17,9 @@
|
||||
#include "hasp_hal.h"
|
||||
#include "hasp_debug.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
|
||||
|
||||
@ -1620,9 +1621,9 @@ void webHandleFirmware()
|
||||
"name='filename' accept='.bin'>");
|
||||
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' "
|
||||
"name='filename' accept='.spiffs'>");
|
||||
httpMessage += F("<button type='submit'>Replace Filesystem Image</button></form></p>");
|
||||
// httpMessage += F("<p><form action='/update' method='post' enctype='multipart/form-data'><input type='file' "
|
||||
// "name='filename' accept='.spiffs'>");
|
||||
// httpMessage += F("<button type='submit'>Replace Filesystem Image</button></form></p>");
|
||||
|
||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||
|
@ -35,8 +35,9 @@ EthernetClient mqttNetworkClient;
|
||||
#include "hasp_hal.h"
|
||||
#include "hasp_debug.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
|
||||
#include "user_config_override.h"
|
@ -6,9 +6,10 @@
|
||||
#include "hasp_conf.h"
|
||||
|
||||
#include "hasp_debug.h"
|
||||
#include "hasp_dispatch.h"
|
||||
#include "hasp_ota.h"
|
||||
#include "hasp.h"
|
||||
|
||||
#include "../hasp/hasp_dispatch.h"
|
||||
#include "../hasp/hasp.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#include <ESP8266HTTPClient.h>
|
@ -9,9 +9,10 @@
|
||||
|
||||
#include "hasp_debug.h"
|
||||
#include "hasp_config.h"
|
||||
#include "hasp_dispatch.h"
|
||||
#include "hasp_telnet.h"
|
||||
|
||||
#include "../hasp/hasp_dispatch.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#include <WiFi.h>
|
||||
WiFiClient telnetClient;
|
@ -1,8 +1,8 @@
|
||||
;***************************************************;
|
||||
; Lanbon L8 Switch with ILI9341 TFT 2.4" ;
|
||||
; Lanbon L8 Switch with ST7789V TFT 2.4" ;
|
||||
; - Custom ESP32 pcb ;
|
||||
; - ili9341 TFT ;
|
||||
; - ? touch controller ;
|
||||
; - ST7789V TFT ;
|
||||
; - FT6336U touch controller ;
|
||||
;***************************************************;
|
||||
|
||||
[env:lanbon_l8]
|
||||
@ -22,21 +22,26 @@ build_flags =
|
||||
;region -- TFT_eSPI build options ------------------------
|
||||
${lcd.st7789v}
|
||||
-D TFT_RST=18 ; FCP pin2 RESET
|
||||
-D TFT_SCLK=19 ; FCP pin3 SCL
|
||||
-D TFT_SCLK=19 ; FCP pin3 SCL
|
||||
-D TFT_DC=21 ; FCP pin4 D/C
|
||||
-D TFT_CS=22 ; FCP pin5 CS
|
||||
-D TFT_MOSI=23 ; FCP pin6 SDA
|
||||
-D TFT_MISO=25 ; FCP pin7 SDO
|
||||
-D TFT_BCKL=5
|
||||
;CONFIG_LVGL_TOUCH_SCL_GPIO=0
|
||||
;CONFIG_LVGL_TOUCH_SDA_GPIO=4
|
||||
;-D TOUCH_CS=22
|
||||
-D TOUCH_DRIVER=6336
|
||||
-D TOUCH_SDA=4
|
||||
-D TOUCH_SCL=0
|
||||
-D TOUCH_IRQ=-1 ; use 34-39 as these are input only pins
|
||||
-D TOUCH_RST=-1 ; not used, connected to 3.3V
|
||||
-D USE_TFT_ESPI=1
|
||||
;endregion
|
||||
|
||||
;region -- Library options -------------------------------
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
${esp32.lib_deps}
|
||||
;git+https://github.com/lvgl/lvgl_esp32_drivers.git
|
||||
git+https://github.com/aselectroworks/Arduino-FT6336U.git
|
||||
|
||||
lib_ignore =
|
||||
${env.lib_ignore}
|
||||
|
@ -47,21 +47,25 @@ mrb3511 =
|
||||
-D USER_SETUP_LOADED=1
|
||||
-D TOUCH_DRIVER=911 ; GT911 Capacitive I2C touch panel driver
|
||||
-D SUPPORT_TRANSACTIONS
|
||||
-D I2C_TOUCH_FREQUENCY=400000
|
||||
|
||||
st7789v =
|
||||
-D ST7789_DRIVER=1
|
||||
;-D CGRAM_OFFSET=1 ; Library will add offsets required, only for 240x240
|
||||
-D TFT_SDA_READ ; Read from display, it only provides an SDA pin
|
||||
;-D CGRAM_OFFSET=1 ; Library will add offsets required
|
||||
-D TFT_SDA_READ ; Read from display, it only provides an SDA pin
|
||||
-D TFT_WIDTH=240
|
||||
-D TFT_HEIGHT=320
|
||||
-D TFT_ROTATION=2 ; see TFT_ROTATION values
|
||||
-D TFT_RGB_ORDER=TFT_RGB ; Colour order Red-Green-Blue
|
||||
-D TFT_ROTATION=2 ; see TFT_ROTATION values
|
||||
-D TFT_INVERSION_ON ; for inverted colors or OFF
|
||||
; -D TFT_INVERSION_OFF ; for normal colors
|
||||
-D TFT_RGB_ORDER=TFT_RGB ; Colour order Red-Green-Blue
|
||||
; -D TFT_RGB_ORDER=TFT_BGR ; Colour order Blue-Green-Red
|
||||
-D SPI_FREQUENCY=80000000
|
||||
-D SPI_READ_FREQUENCY=6000000
|
||||
-D USER_SETUP_LOADED=1
|
||||
-D TOUCH_DRIVER=6336 ; FT6336U Capacitive I2C touch panel driver
|
||||
-D TOUCH_DRIVER=6336 ; FT6336U Capacitive I2C touch panel driver
|
||||
-D SUPPORT_TRANSACTIONS
|
||||
-D I2C_TOUCH_FREQUENCY=400000
|
||||
|
||||
wireless-tag =
|
||||
-D ST7796_DRIVER=1
|
||||
@ -73,3 +77,4 @@ wireless-tag =
|
||||
-D USER_SETUP_LOADED=1
|
||||
-D TOUCH_DRIVER=6336 ; FT6336U Capacitive I2C touch panel driver
|
||||
-D SUPPORT_TRANSACTIONS
|
||||
-D I2C_TOUCH_FREQUENCY=400000
|
||||
|
@ -62,6 +62,7 @@ build_flags =
|
||||
-D HASP_USE_SPIFFS=0
|
||||
-D HASP_USE_EEPROM=1
|
||||
-D HASP_USE_GPIO=0
|
||||
-D HASP_USE_OTA=0
|
||||
-D HASP_USE_ETHERNET=0
|
||||
;endregion
|
||||
|
||||
|
@ -33,6 +33,7 @@ build_flags =
|
||||
-D HASP_OUTPUT_PIN=PE0 ; User LED D2 on DevEBox board
|
||||
-D HASP_INPUT_PIN=PD15 ; User Button K1 on DevEBox board
|
||||
-D HASP_USE_TASMOTA_SLAVE=1
|
||||
-D HASP_USE_OTA=0
|
||||
-D HASP_USE_ETHERNET=1
|
||||
;endregion
|
||||
|
||||
|
@ -48,6 +48,7 @@ build_flags =
|
||||
-D HASP_INPUT_PIN=PE4 ; User Button K0 on MCUDev Black board
|
||||
-D HASP_USE_HTTP=0
|
||||
-D HASP_USE_MQTT=1
|
||||
-D HASP_USE_OTA=0
|
||||
;endregion
|
||||
|
||||
;region -- Debugging options -----------------------------
|
||||
|
@ -45,6 +45,7 @@ build_flags =
|
||||
-D HASP_USE_EEPROM=1
|
||||
-D HASP_USE_GPIO=0
|
||||
-D HASP_USE_TASMOTA_SLAVE=0
|
||||
-D HASP_USE_OTA=0
|
||||
-D HASP_USE_ETHERNET=0
|
||||
;endregion
|
||||
|
||||
|
@ -53,6 +53,7 @@ build_flags =
|
||||
-D HASP_USE_EEPROM=1
|
||||
-D HASP_USE_GPIO=1
|
||||
-D HASP_USE_TASMOTA_SLAVE=0
|
||||
-D HASP_USE_OTA=0
|
||||
-D HASP_OUTPUT_PIN=PA1 ; User LED D2 on DevEBox board
|
||||
-D HASP_INPUT_PIN=PA0 ; User Button K1 on DevEBox board
|
||||
;endregion
|
||||
|
Loading…
x
Reference in New Issue
Block a user