Add Icon Fonts and bugfixing
This commit is contained in:
Vendored
+2
-1
@@ -2,6 +2,7 @@
|
||||
"files.associations": {
|
||||
"styles.h": "c",
|
||||
"string.h": "c",
|
||||
"system_error": "cpp"
|
||||
"system_error": "cpp",
|
||||
"random": "c"
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,10 @@ void MQTT::serveOverride(void){
|
||||
}
|
||||
switch(glblData.override){
|
||||
case OVR_ALWAYSOFF:
|
||||
sending += "\"Override\": \"Always ON\"}";
|
||||
sending += "\"Override\": \"Always OFF\"}";
|
||||
break;
|
||||
case OVR_ALWAYSON:
|
||||
sending += "\"Override\": \"Always OFF\"}";
|
||||
sending += "\"Override\": \"Always ON\"}";
|
||||
break;
|
||||
case OVR_NONE:
|
||||
sending += "\"Override\": \"NONE\"}";
|
||||
|
||||
+49
-19
@@ -18,6 +18,9 @@
|
||||
#include "MQTT.h"
|
||||
|
||||
|
||||
#define MEASINT_S 1
|
||||
#define HISTINT_S (5*60) //make history point every 5 min.
|
||||
|
||||
// -- Initial password to connect to the Thing, when it creates an own Access Point.
|
||||
|
||||
MQTT mqtt;
|
||||
@@ -30,12 +33,12 @@ float barometerAltitude = 730.0; // meters ... map readings + barometer positio
|
||||
/*定义ESP32的SPI使用的引脚*/
|
||||
|
||||
BME280I2C::Settings settings(
|
||||
BME280::OSR_X1,
|
||||
BME280::OSR_X1,
|
||||
BME280::OSR_X4,
|
||||
BME280::OSR_X1,
|
||||
BME280::OSR_X1,
|
||||
BME280::Mode_Forced,
|
||||
BME280::Mode_Normal,
|
||||
BME280::StandbyTime_1000ms,
|
||||
BME280::Filter_2,
|
||||
BME280::Filter_Off,
|
||||
BME280::SpiEnable_False,
|
||||
BME280I2C::I2CAddr_0x76
|
||||
);
|
||||
@@ -46,21 +49,46 @@ BME280I2C bme(settings);
|
||||
uint32_t draw_buf[DRAW_BUF_SIZE / 4];
|
||||
bool newMeasurement=false,newHistory=false;
|
||||
float temp(NAN), hum(NAN), pres(NAN),seaLevelPress(NAN);
|
||||
bool presAlarm = false;
|
||||
bool mutex_locked = false;
|
||||
|
||||
void measure(void){ //update temp every 30secs
|
||||
static uint8_t counter=0;
|
||||
settings.mode = BME280::Mode_Forced;
|
||||
bme.setSettings(settings);
|
||||
static uint8_t dropCNT=0;
|
||||
static float old_pres=0;
|
||||
static uint32_t hist_update_cnt;
|
||||
static uint32_t screen_update_cnt;
|
||||
//settings.mode = BME280::Mode_Forced;
|
||||
//bme.setSettings(settings);
|
||||
++hist_update_cnt;
|
||||
++screen_update_cnt;
|
||||
if(newMeasurement){ //if flag was not yet handled completely, skip measurement but increase time counter for history timing
|
||||
return;
|
||||
}
|
||||
bme.read(pres, temp, hum, BME280::TempUnit_Celsius, BME280::PresUnit_hPa);
|
||||
settings.mode = BME280::Mode_Sleep;
|
||||
bme.setSettings(settings);
|
||||
//settings.mode = BME280::Mode_Sleep;
|
||||
//bme.setSettings(settings);
|
||||
temp = temp - 1.0; //adjust temp to compensate head dissipation of ESP
|
||||
seaLevelPress = EnvironmentCalculations::EquivalentSeaLevelPressure(barometerAltitude, temp, pres, EnvironmentCalculations::AltitudeUnit_Meters, EnvironmentCalculations::TempUnit_Celsius);
|
||||
newMeasurement = true;
|
||||
if(++counter > 10 || history_isInitialized() == false){ //add a point to history every 5 mins
|
||||
if(history_isInitialized() && old_pres - pres > 0.1){
|
||||
if(++dropCNT > 1){ //pressure drop at leaast 2 secs
|
||||
old_pres = pres;
|
||||
presAlarm = true;
|
||||
}
|
||||
}else{
|
||||
old_pres = pres;
|
||||
dropCNT = 0;
|
||||
presAlarm = false;
|
||||
}
|
||||
if(screen_update_cnt == 30 || presAlarm){ //update every 30 secs
|
||||
newMeasurement = true;
|
||||
screen_update_cnt = 0;
|
||||
}
|
||||
|
||||
if(hist_update_cnt == HISTINT_S/MEASINT_S || history_isInitialized() == false){ //add a point to history every 5 mins or init the hist, if no point present yet
|
||||
history_append(seaLevelPress,temp,hum);
|
||||
counter = 0;
|
||||
hist_update_cnt = 0;
|
||||
newHistory = true;
|
||||
newMeasurement = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +114,8 @@ void setup(void)
|
||||
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
|
||||
lv_indev_set_read_cb(indev, my_touch_read);
|
||||
ui_init();
|
||||
setBacklight(0x3FF);
|
||||
measurementTick.attach(30,measure);
|
||||
setBacklight(BL_BRIGHTNESS);
|
||||
measurementTick.attach(MEASINT_S,measure);
|
||||
mqtt.begin();
|
||||
|
||||
lv_label_set_text_fmt(objects.debugTxt, "IP:\n %s\n\nHostname:\n %s\n\nMqtt-Server:\n %s\n\nMqtt-Port:\n %d\n\nMqtt-Topic:\n %d\n\n",mqtt.getMyIP(),mqtt.getHostname(),mqtt.getMqttServer(),mqtt.getMqttPort(), mqtt.getMqttTopic());
|
||||
@@ -97,14 +125,14 @@ void setup(void)
|
||||
|
||||
unsigned long lastms = millis();
|
||||
unsigned long lastTick = 0;
|
||||
uint8_t statusCnt=0;
|
||||
uint16_t tickCounter = 0;
|
||||
void loop()
|
||||
{
|
||||
if(newMeasurement){
|
||||
update_sensorNstatus(temp, hum, seaLevelPress);
|
||||
mqtt.sendStatus();
|
||||
|
||||
update_sensorNstatus(temp, hum, seaLevelPress,presAlarm);
|
||||
newMeasurement = false;
|
||||
mqtt.sendStatus();
|
||||
}
|
||||
if(newHistory){
|
||||
newHistory=false;
|
||||
@@ -113,7 +141,9 @@ void loop()
|
||||
}
|
||||
mqtt.loop();
|
||||
ui_tick();
|
||||
lv_task_handler(); // let the GUI do its work
|
||||
lv_tick_inc(millis() - lastms); // tell LVGL how much time has passed
|
||||
if(!ui_isSleeping()){
|
||||
lv_task_handler(); // let the GUI do its work
|
||||
lv_tick_inc(millis() - lastms); // tell LVGL how much time has passed
|
||||
}
|
||||
lastms = millis();
|
||||
}
|
||||
|
||||
@@ -5,24 +5,42 @@
|
||||
|
||||
bool arc_pressed = false;
|
||||
bool animating = false;
|
||||
dataset_t glblData;
|
||||
dataset_t glblData = {.temp = NAN, .hum = NAN, .pres = NAN, .seaLevelPress = NAN, .settemp= NAN, .heating=false, .enBuff =false, .presAlarm=false, .override=OVR_NONE};
|
||||
float curr_temp = 0.0;
|
||||
int32_t scale_max = 0, scale_min = 0, lastSelChartValue = 0;
|
||||
lv_point_t lastChartPt;
|
||||
|
||||
void update_sensorNstatus(float temp, float hum, float seaLevelPress){
|
||||
void update_sensorNstatus(float temp, float hum, float seaLevelPress, bool presAlarm){
|
||||
glblData.temp = temp;
|
||||
glblData.hum = hum;
|
||||
glblData.seaLevelPress = seaLevelPress;
|
||||
glblData.presAlarm = presAlarm;
|
||||
update_status();
|
||||
}
|
||||
|
||||
static void alarm_ani_cb(void * var, int32_t v)
|
||||
{
|
||||
if(v > -1 && v < 256){
|
||||
lv_led_set_brightness(objects.alarmLED, v);
|
||||
//setBacklight((v<<4) | 0x00FF);
|
||||
ledcFade(GFX_BL,ledcRead(GFX_BL),(v<<4) | 0x00FF,100);
|
||||
}
|
||||
}
|
||||
|
||||
static void alarm_ani_end_cb(lv_anim_t *var)
|
||||
{
|
||||
lv_obj_add_flag(objects.alarmLED, LV_OBJ_FLAG_HIDDEN);
|
||||
setBacklight(BL_BRIGHTNESS);
|
||||
lv_led_set_brightness(objects.alarmLED, 0);
|
||||
|
||||
}
|
||||
|
||||
void ui_settemp(float tmp){
|
||||
lv_arc_set_value(objects.temp_arc, (int32_t) (tmp*2));
|
||||
}
|
||||
|
||||
void update_status(void){
|
||||
lv_label_set_text_fmt(objects.press_txt,"%4.0f hPa",glblData.seaLevelPress);
|
||||
lv_label_set_text_fmt(objects.press_txt,"%4.2f hPa",glblData.seaLevelPress);
|
||||
lv_label_set_text_fmt(objects.hum_txt,"%2.0f %%rH",glblData.hum);
|
||||
if(!arc_pressed && !animating){
|
||||
lv_label_set_text_fmt(objects.temp_txt,"%2.1f °C",glblData.temp);
|
||||
@@ -30,8 +48,14 @@ void update_status(void){
|
||||
glblData.settemp = lv_arc_get_value(objects.temp_arc)/2.0;
|
||||
lv_label_set_text_fmt(objects.temp_txt,"%2.1f °C",glblData.settemp);
|
||||
}
|
||||
if(glblData.enBuff){
|
||||
lv_obj_remove_flag(objects.bufferIcn, LV_OBJ_FLAG_HIDDEN);
|
||||
}else{
|
||||
lv_obj_add_flag(objects.bufferIcn, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
switch(glblData.override){
|
||||
case OVR_NONE:
|
||||
lv_obj_set_style_text_color(objects.bufferIcn,lv_color_hex(0xFFfafafa),LV_STATE_DEFAULT);
|
||||
if(glblData.temp < glblData.settemp-TMP_HYST){
|
||||
glblData.heating = true;
|
||||
}
|
||||
@@ -40,6 +64,7 @@ void update_status(void){
|
||||
}
|
||||
break;
|
||||
case OVR_ALWAYSON:
|
||||
lv_obj_set_style_text_color(objects.bufferIcn,lv_color_hex(0xFF00AA00),LV_STATE_DEFAULT);
|
||||
if(glblData.temp < glblData.settemp+3.0){ //allow for 3degC overheating
|
||||
glblData.heating = true;
|
||||
}
|
||||
@@ -48,6 +73,7 @@ void update_status(void){
|
||||
}
|
||||
break;
|
||||
case OVR_ALWAYSOFF:
|
||||
lv_obj_set_style_text_color(objects.bufferIcn,lv_color_hex(0xFFAA0000),LV_STATE_DEFAULT);
|
||||
if(glblData.temp < 12){ //ensure minimum of 12°C
|
||||
glblData.heating = true;
|
||||
}
|
||||
@@ -57,12 +83,28 @@ void update_status(void){
|
||||
break;
|
||||
}
|
||||
if(glblData.heating){
|
||||
digitalWrite(PIN_REL,LOW);
|
||||
lv_obj_add_flag(objects.heaterIcn, LV_OBJ_FLAG_HIDDEN);
|
||||
digitalWrite(PIN_REL,HIGH);
|
||||
lv_obj_remove_flag(objects.heaterIcn, LV_OBJ_FLAG_HIDDEN);
|
||||
}else{
|
||||
digitalWrite(PIN_REL,LOW);
|
||||
lv_obj_add_flag(objects.heaterIcn, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
if(glblData.presAlarm == true){
|
||||
lv_obj_remove_flag(objects.alarmLED, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_anim_t alarmAni;
|
||||
lv_anim_init(&alarmAni);
|
||||
lv_anim_set_values(&alarmAni, 0, 255);
|
||||
lv_anim_set_duration(&alarmAni, 600);
|
||||
lv_anim_set_playback_delay(&alarmAni, 0);
|
||||
lv_anim_set_playback_duration(&alarmAni, 600);
|
||||
lv_anim_set_repeat_delay(&alarmAni, 100);
|
||||
lv_anim_set_repeat_count(&alarmAni,7);
|
||||
lv_anim_set_exec_cb(&alarmAni, alarm_ani_cb);
|
||||
lv_anim_set_path_cb(&alarmAni, lv_anim_path_ease_in_out);
|
||||
lv_anim_set_completed_cb(&alarmAni,alarm_ani_end_cb);
|
||||
lv_anim_start(&alarmAni);
|
||||
ui_exitSleep();
|
||||
}
|
||||
}
|
||||
|
||||
void update_wifi_strength(wifi_strength_t strength){
|
||||
|
||||
@@ -22,11 +22,12 @@ typedef struct dataset_s{
|
||||
float seaLevelPress;
|
||||
float settemp;
|
||||
bool heating;
|
||||
bool buffRequest;
|
||||
bool enBuff;
|
||||
bool presAlarm;
|
||||
override_t override;
|
||||
}dataset_t;
|
||||
|
||||
|
||||
typedef enum wifi_strength_e{
|
||||
WIFI_STRENGTH_OFF,
|
||||
WIFI_STRENGTH_LOW,
|
||||
@@ -43,7 +44,7 @@ void showChartScreen(lv_event_t * e);
|
||||
void showMainScreen(lv_event_t * e);
|
||||
void action_show_cursors_cb(lv_event_t * e);
|
||||
void chartDrawingCB(lv_event_t * e);
|
||||
void update_sensorNstatus(float temp, float hum, float seaLevelPress);
|
||||
void update_sensorNstatus(float temp, float hum, float seaLevelPress, bool presAlarm);
|
||||
void update_status(void);
|
||||
void update_wifi_strength(wifi_strength_t strength);
|
||||
void chart_autoscale(void);
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
objects_t objects;
|
||||
lv_obj_t *tick_value_change_obj;
|
||||
|
||||
|
||||
|
||||
|
||||
void create_screen_main() {
|
||||
lv_obj_t *obj = lv_obj_create(0);
|
||||
objects.main = obj;
|
||||
@@ -20,6 +23,18 @@ void create_screen_main() {
|
||||
lv_obj_add_event_cb(obj, action_switch_screens, LV_EVENT_GESTURE, (void *)0);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_led_create(parent_obj);
|
||||
objects.alarmLED = obj;
|
||||
lv_obj_set_size(obj, 100, 100);
|
||||
lv_obj_center(obj);
|
||||
lv_led_set_color(obj, lv_color_hex(0xffff4411));
|
||||
lv_led_set_brightness(obj, 0);
|
||||
lv_obj_set_style_shadow_width(obj, 20, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_shadow_spread(obj, 16, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
{
|
||||
// tempArc
|
||||
lv_obj_t *obj = lv_arc_create(parent_obj);
|
||||
@@ -57,6 +72,7 @@ void create_screen_main() {
|
||||
objects.hum_txt = obj;
|
||||
lv_obj_set_pos(obj, 91, 141);
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_align(obj,LV_ALIGN_CENTER,0,25);
|
||||
lv_label_set_text(obj, "");
|
||||
lv_obj_set_style_text_font(obj, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
}
|
||||
@@ -66,6 +82,7 @@ void create_screen_main() {
|
||||
objects.press_txt = obj;
|
||||
lv_obj_set_pos(obj, 81, 78);
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_align(obj,LV_ALIGN_CENTER,0,-25);
|
||||
lv_label_set_text(obj, "");
|
||||
lv_obj_set_style_text_font(obj, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
}
|
||||
@@ -269,7 +286,6 @@ void create_screen_debug() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void create_screens() {
|
||||
lv_disp_t *dispp = lv_disp_get_default();
|
||||
lv_theme_t *theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_GREEN), lv_palette_main(LV_PALETTE_RED), true, LV_FONT_DEFAULT);
|
||||
|
||||
@@ -26,6 +26,7 @@ typedef struct _objects_t {
|
||||
lv_obj_t *heaterIcn;
|
||||
lv_obj_t *bufferIcn;
|
||||
lv_obj_t *wifiIcn;
|
||||
lv_obj_t *alarmLED;
|
||||
lv_chart_cursor_t *chart_cursor;
|
||||
lv_chart_series_t *chart_series;
|
||||
} objects_t;
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
/**
|
||||
* @file lv_symbol_def.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_SYMBOL_DEF_H
|
||||
#define LV_SYMBOL_DEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
LV_FONT_DECLARE(Bootstrap_Icons_16);
|
||||
|
||||
//included icons in bootstrap font
|
||||
//use this list for font generator:
|
||||
/*
|
||||
0xF619-0xF61C,0xF7F6,0xF4FF,0xF185-0xF188,0xF30B-0xF30D,0xF493,0xF4F7,0xF5CD-0xF5D20xF100,
|
||||
|
||||
*/
|
||||
#define ICON_WIFI_LOW "\xEF\x98\x99" //F619
|
||||
#define ICON_WIFI_MED "\xEF\x98\x9A" //F61A
|
||||
#define ICON_WIFI_HIGH "\xEF\x98\x9C" //F61C
|
||||
#define ICON_WIFI_OFF "\xEF\x98\x9B" //F61B
|
||||
#define ICON_FIRE "\xEF\x9F\xB6" //F7F6
|
||||
#define ICON_POWER "\xEF\x93\xBF" //F4FF
|
||||
#define ICON_BATT_CHARG "\xEF\x86\x85" //F185
|
||||
#define ICON_BATT_FULL "\xEF\x86\x86" //F186
|
||||
#define ICON_BATT_HALF "\xEF\x86\x87" //F187
|
||||
#define ICON_BATT "\xEF\x86\x88" //F188
|
||||
#define ICON_DROPLET_FULL "\xEF\x8C\x8B" //F30B
|
||||
#define ICON_DROPLET_HALF "\xEF\x8C\x8C" //F30C
|
||||
#define ICON_DROPLET "\xEF\x8C\x8D" //F30D
|
||||
#define ICON_MOISTURE "\xEF\x92\x93" //F493
|
||||
#define ICON_PLUG "\xEF\x93\xB7" //F4F7
|
||||
#define ICON_THERMOMETER_HALF "\xEF\x97\x8D" //F5CD
|
||||
#define ICON_THERMOMETER_HIGH "\xEF\x97\x8E" //F5CE
|
||||
#define ICON_THERMOMETER_LOW "\xEF\x97\x8F" //F5CF
|
||||
#define ICON_THERMOMETER_SNOW "\xEF\x97\x90" //F5D0
|
||||
#define ICON_THERMOMETER_SUN "\xEF\x97\x91" //F5D1
|
||||
#define ICON_THERMOMETER "\xEF\x97\x92" //F5D2
|
||||
#define ICON_SHUTTER "" //F100
|
||||
#define ICON_MENU_LINES "" //F479
|
||||
#define ICON_MENU_DOTS_H "" //F5D4
|
||||
#define ICON_MENU_DOTS_V "" //F5D3
|
||||
#define ICON_ROTATE_CW "" //F116
|
||||
#define ICON_ROTATE_CC "" //F117
|
||||
#define ICON_GRAPH "" //F3F2
|
||||
#define ICON_ARROW_DOWN_FILL "" //F229
|
||||
#define ICON_ARROW_DOWN "" //F22C
|
||||
#define ICON_ARROW_UP_FILL "" //F235
|
||||
#define ICON_ARROW_UP "" //F238
|
||||
#define ICON_ARROW_LEFT_FILL "" //F22D
|
||||
#define ICON_ARROW_LEFT "" //F230
|
||||
#define ICON_ARROW_RIGHT_FILL "" //F231
|
||||
#define ICON_ARROW_RIGHT "" //F234
|
||||
|
||||
|
||||
/*-------------------------------
|
||||
* Symbols from montserrat font
|
||||
*-----------------------------*/
|
||||
//use this list for font generator:
|
||||
/*
|
||||
0x20-0x7F,0x00B0-0xB4,0x2022,0xAB,0xBB-0xBE,0x3A9,0x3C0,0x2022
|
||||
µÄÖÜäöüß
|
||||
|
||||
*/
|
||||
|
||||
/*-------------------------------
|
||||
* Symbols from FontAwesome font
|
||||
*-----------------------------*/
|
||||
|
||||
/*In the font converter use this list as range:
|
||||
61441, 61448, 61451, 61452, 61453, 61457, 61459, 61461, 61465, 61468,
|
||||
61473, 61478, 61479, 61480, 61502, 61507, 61512, 61515, 61516, 61517,
|
||||
61521, 61522, 61523, 61524, 61543, 61544, 61550, 61552, 61553, 61556,
|
||||
61559, 61560, 61561, 61563, 61587, 61589, 61636, 61637, 61639, 61641,
|
||||
61664, 61671, 61674, 61683, 61724, 61732, 61787, 61931, 62016, 62017,
|
||||
62018, 62019, 62020, 62087, 62099, 62189, 62212, 62810, 63426, 63650
|
||||
*/
|
||||
|
||||
/* These symbols can be predefined in the lv_conf.h file.
|
||||
* If they are not predefined, they will use the following values
|
||||
*/
|
||||
|
||||
#if !defined LV_SYMBOL_AUDIO
|
||||
#define LV_SYMBOL_AUDIO "\xEF\x80\x81" /*61441, 0xF001*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_VIDEO
|
||||
#define LV_SYMBOL_VIDEO "\xEF\x80\x88" /*61448, 0xF008*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_LIST
|
||||
#define LV_SYMBOL_LIST "\xEF\x80\x8B" /*61451, 0xF00B*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_OK
|
||||
#define LV_SYMBOL_OK "\xEF\x80\x8C" /*61452, 0xF00C*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_CLOSE
|
||||
#define LV_SYMBOL_CLOSE "\xEF\x80\x8D" /*61453, 0xF00D*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_POWER
|
||||
#define LV_SYMBOL_POWER "\xEF\x80\x91" /*61457, 0xF011*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_SETTINGS
|
||||
#define LV_SYMBOL_SETTINGS "\xEF\x80\x93" /*61459, 0xF013*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_HOME
|
||||
#define LV_SYMBOL_HOME "\xEF\x80\x95" /*61461, 0xF015*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_DOWNLOAD
|
||||
#define LV_SYMBOL_DOWNLOAD "\xEF\x80\x99" /*61465, 0xF019*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_DRIVE
|
||||
#define LV_SYMBOL_DRIVE "\xEF\x80\x9C" /*61468, 0xF01C*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_REFRESH
|
||||
#define LV_SYMBOL_REFRESH "\xEF\x80\xA1" /*61473, 0xF021*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_MUTE
|
||||
#define LV_SYMBOL_MUTE "\xEF\x80\xA6" /*61478, 0xF026*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_VOLUME_MID
|
||||
#define LV_SYMBOL_VOLUME_MID "\xEF\x80\xA7" /*61479, 0xF027*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_VOLUME_MAX
|
||||
#define LV_SYMBOL_VOLUME_MAX "\xEF\x80\xA8" /*61480, 0xF028*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_IMAGE
|
||||
#define LV_SYMBOL_IMAGE "\xEF\x80\xBE" /*61502, 0xF03E*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_TINT
|
||||
#define LV_SYMBOL_TINT "\xEF\x81\x83" /*61507, 0xF043*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_PREV
|
||||
#define LV_SYMBOL_PREV "\xEF\x81\x88" /*61512, 0xF048*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_PLAY
|
||||
#define LV_SYMBOL_PLAY "\xEF\x81\x8B" /*61515, 0xF04B*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_PAUSE
|
||||
#define LV_SYMBOL_PAUSE "\xEF\x81\x8C" /*61516, 0xF04C*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_STOP
|
||||
#define LV_SYMBOL_STOP "\xEF\x81\x8D" /*61517, 0xF04D*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_NEXT
|
||||
#define LV_SYMBOL_NEXT "\xEF\x81\x91" /*61521, 0xF051*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_EJECT
|
||||
#define LV_SYMBOL_EJECT "\xEF\x81\x92" /*61522, 0xF052*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_LEFT
|
||||
#define LV_SYMBOL_LEFT "\xEF\x81\x93" /*61523, 0xF053*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_RIGHT
|
||||
#define LV_SYMBOL_RIGHT "\xEF\x81\x94" /*61524, 0xF054*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_PLUS
|
||||
#define LV_SYMBOL_PLUS "\xEF\x81\xA7" /*61543, 0xF067*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_MINUS
|
||||
#define LV_SYMBOL_MINUS "\xEF\x81\xA8" /*61544, 0xF068*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_EYE_OPEN
|
||||
#define LV_SYMBOL_EYE_OPEN "\xEF\x81\xAE" /*61550, 0xF06E*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_EYE_CLOSE
|
||||
#define LV_SYMBOL_EYE_CLOSE "\xEF\x81\xB0" /*61552, 0xF070*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_WARNING
|
||||
#define LV_SYMBOL_WARNING "\xEF\x81\xB1" /*61553, 0xF071*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_SHUFFLE
|
||||
#define LV_SYMBOL_SHUFFLE "\xEF\x81\xB4" /*61556, 0xF074*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_UP
|
||||
#define LV_SYMBOL_UP "\xEF\x81\xB7" /*61559, 0xF077*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_DOWN
|
||||
#define LV_SYMBOL_DOWN "\xEF\x81\xB8" /*61560, 0xF078*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_LOOP
|
||||
#define LV_SYMBOL_LOOP "\xEF\x81\xB9" /*61561, 0xF079*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_DIRECTORY
|
||||
#define LV_SYMBOL_DIRECTORY "\xEF\x81\xBB" /*61563, 0xF07B*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_UPLOAD
|
||||
#define LV_SYMBOL_UPLOAD "\xEF\x82\x93" /*61587, 0xF093*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_CALL
|
||||
#define LV_SYMBOL_CALL "\xEF\x82\x95" /*61589, 0xF095*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_CUT
|
||||
#define LV_SYMBOL_CUT "\xEF\x83\x84" /*61636, 0xF0C4*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_COPY
|
||||
#define LV_SYMBOL_COPY "\xEF\x83\x85" /*61637, 0xF0C5*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_SAVE
|
||||
#define LV_SYMBOL_SAVE "\xEF\x83\x87" /*61639, 0xF0C7*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BARS
|
||||
#define LV_SYMBOL_BARS "\xEF\x83\x89" /*61641, 0xF0C9*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_ENVELOPE
|
||||
#define LV_SYMBOL_ENVELOPE "\xEF\x83\xA0" /*61664, 0xF0E0*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_CHARGE
|
||||
#define LV_SYMBOL_CHARGE "\xEF\x83\xA7" /*61671, 0xF0E7*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_PASTE
|
||||
#define LV_SYMBOL_PASTE "\xEF\x83\xAA" /*61674, 0xF0EA*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BELL
|
||||
#define LV_SYMBOL_BELL "\xEF\x83\xB3" /*61683, 0xF0F3*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_KEYBOARD
|
||||
#define LV_SYMBOL_KEYBOARD "\xEF\x84\x9C" /*61724, 0xF11C*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_GPS
|
||||
#define LV_SYMBOL_GPS "\xEF\x84\xA4" /*61732, 0xF124*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_FILE
|
||||
#define LV_SYMBOL_FILE "\xEF\x85\x9B" /*61787, 0xF158*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_WIFI
|
||||
#define LV_SYMBOL_WIFI "\xEF\x87\xAB" /*61931, 0xF1EB*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BATTERY_FULL
|
||||
#define LV_SYMBOL_BATTERY_FULL "\xEF\x89\x80" /*62016, 0xF240*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BATTERY_3
|
||||
#define LV_SYMBOL_BATTERY_3 "\xEF\x89\x81" /*62017, 0xF241*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BATTERY_2
|
||||
#define LV_SYMBOL_BATTERY_2 "\xEF\x89\x82" /*62018, 0xF242*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BATTERY_1
|
||||
#define LV_SYMBOL_BATTERY_1 "\xEF\x89\x83" /*62019, 0xF243*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BATTERY_EMPTY
|
||||
#define LV_SYMBOL_BATTERY_EMPTY "\xEF\x89\x84" /*62020, 0xF244*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_USB
|
||||
#define LV_SYMBOL_USB "\xEF\x8a\x87" /*62087, 0xF287*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BLUETOOTH
|
||||
#define LV_SYMBOL_BLUETOOTH "\xEF\x8a\x93" /*62099, 0xF293*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_TRASH
|
||||
#define LV_SYMBOL_TRASH "\xEF\x8B\xAD" /*62189, 0xF2ED*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_EDIT
|
||||
#define LV_SYMBOL_EDIT "\xEF\x8C\x84" /*62212, 0xF304*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_BACKSPACE
|
||||
#define LV_SYMBOL_BACKSPACE "\xEF\x95\x9A" /*62810, 0xF55A*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_SD_CARD
|
||||
#define LV_SYMBOL_SD_CARD "\xEF\x9F\x82" /*63426, 0xF7C2*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_NEW_LINE
|
||||
#define LV_SYMBOL_NEW_LINE "\xEF\xA2\xA2" /*63650, 0xF8A2*/
|
||||
#endif
|
||||
|
||||
#if !defined LV_SYMBOL_DUMMY
|
||||
/** Invalid symbol at (U+F8FF). If written before a string then `lv_img` will show it as a label*/
|
||||
#define LV_SYMBOL_DUMMY "\xEF\xA3\xBF"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_SYMBOL_DEF_H*/
|
||||
|
||||
+30
-23
@@ -9,12 +9,10 @@
|
||||
#include <TouchDrvCSTXXX.hpp>
|
||||
#include <Ticker.h>
|
||||
|
||||
#define GFX_BL 1
|
||||
Arduino_DataBus *bus = new Arduino_ESP32SPI(3 /* DC */, 5 /* CS */, 2 /* SCK */, 4 /* MOSI */, -1 /* MISO */, FSPI /* spi_num */);
|
||||
Arduino_GC9A01 *gfx = new Arduino_GC9A01(bus, 0 /* RST */, 2 /* rotation */, true /* IPS */);
|
||||
uint16_t brightness = 0, brightness_new = 0;
|
||||
TouchDrvCSTXXX touch;
|
||||
int16_t x[5], y[5];
|
||||
bool isPressed = false,sleeping=false;
|
||||
unsigned long lastTouch;
|
||||
static int16_t currentScreen = -1;
|
||||
@@ -78,38 +76,47 @@ void ui_init() {
|
||||
loadScreen(SCREEN_ID_MAIN);
|
||||
}
|
||||
|
||||
bool ui_isSleeping(void){
|
||||
return sleeping;
|
||||
}
|
||||
|
||||
void ui_exitSleep(){
|
||||
if(sleeping){
|
||||
isPressed = true;
|
||||
}else{
|
||||
lastTouch = millis();
|
||||
}
|
||||
}
|
||||
|
||||
void ui_tick() {
|
||||
//tick_screen(currentScreen);
|
||||
if(millis() - lastTouch > 10000){
|
||||
if(millis() - lastTouch > SLEEP_TIMEOUT){
|
||||
if(!sleeping){
|
||||
displaySleep();
|
||||
sleeping = true;
|
||||
}
|
||||
unsigned long millisbefore = millis();
|
||||
/*
|
||||
gpio_wakeup_enable(GPIO_NUM_8,GPIO_INTR_HIGH_LEVEL);
|
||||
esp_sleep_enable_gpio_wakeup();
|
||||
esp_sleep_enable_timer_wakeup(500000);
|
||||
esp_light_sleep_start();
|
||||
gpio_wakeup_disable(GPIO_NUM_8);
|
||||
gpio_set_intr_type(GPIO_NUM_8,GPIO_INTR_NEGEDGE);*/
|
||||
while((millis()-millisbefore) < 10000 && (millis() - lastTouch) > 60000){
|
||||
//while((millis()-millisbefore) < 10000 && (millis() - lastTouch) > SLEEP_TIMEOUT){
|
||||
delay(200);
|
||||
if (isPressed){
|
||||
isPressed = false;
|
||||
lastTouch = millis();
|
||||
}else{
|
||||
lastTouch = millis()-SLEEP_TIMEOUT-1;
|
||||
}
|
||||
}
|
||||
//}
|
||||
}else if(sleeping){
|
||||
sleeping= false;
|
||||
Serial.print("WAKE!!");
|
||||
lastTouch = millis();
|
||||
displayWake();
|
||||
lv_obj_invalidate(objects.temp_arc);
|
||||
lv_task_handler(); // let the GUI do its work
|
||||
sleeping= false;
|
||||
isPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
void displaySleep(){
|
||||
gfx->displayOff();
|
||||
ledcFade(GFX_BL, 0x3FF, 0x000, 300);
|
||||
ledcFade(GFX_BL, BL_BRIGHTNESS, 0x000, 300);
|
||||
}
|
||||
|
||||
void displayWake(){
|
||||
@@ -118,7 +125,7 @@ void displayWake(){
|
||||
delay(10);
|
||||
lv_obj_invalidate(objects.temp_arc);
|
||||
lv_task_handler(); // let the GUI do its work
|
||||
ledcFade(GFX_BL, 0x000, 0x3FF, 300);
|
||||
ledcFade(GFX_BL, 0x000, BL_BRIGHTNESS, 300);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,15 +151,15 @@ void displayWake(){
|
||||
|
||||
void my_touch_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
lv_coord_t last_x = 0;
|
||||
lv_coord_t last_y = 0;
|
||||
if (isPressed) {
|
||||
int16_t x = 0;
|
||||
int16_t y = 0;
|
||||
if (isPressed && !sleeping) {
|
||||
lastTouch = millis();
|
||||
isPressed = false;
|
||||
uint8_t touched = touch.getPoint(x, y, touch.getSupportTouchPoint());
|
||||
uint8_t touched = touch.getPoint(&x, &y, 1);
|
||||
if (touched) {
|
||||
data->point.x = SCREEN_WIDTH - x[0];
|
||||
data->point.y = SCREEN_HEIGHT - y[0];
|
||||
data->point.x = SCREEN_WIDTH - x;
|
||||
data->point.y = SCREEN_HEIGHT - y;
|
||||
data->state = LV_INDEV_STATE_PRESSED;
|
||||
}else {
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
#define SLEEP_TIMEOUT 30000 //sleep display after 30 secs
|
||||
#define GFX_BL 1
|
||||
#define BL_BRIGHTNESS 0x3FF
|
||||
|
||||
#define TouchInt 8
|
||||
#define TouchRST 9
|
||||
#define SCL 7
|
||||
@@ -60,6 +64,8 @@ extern "C" {
|
||||
|
||||
void TouchHandleInterrupt(void);
|
||||
void ui_init();
|
||||
void ui_exitSleep();
|
||||
bool ui_isSleeping(void);
|
||||
void ui_tick();
|
||||
void DisplayInit(void);
|
||||
void log_print(lv_log_level_t level, const char * buf);
|
||||
|
||||
Reference in New Issue
Block a user