Skip to content

Add lock screen functionality and fix limit session issues #962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added gui-tft/lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/emonesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
#include "debug.h"
#include "profile.h"

// -------------------------------------------------------------------
// Lock Screen Configuration
// -------------------------------------------------------------------

// Uncomment to enable lock screen when EVSE is disabled
#define ENABLE_LOCK_SCREEN

// Default lock screen message displayed when EVSE is disabled
#ifndef LOCK_SCREEN_MESSAGE
#define LOCK_SCREEN_MESSAGE "STATION LOCKED"
#endif

#ifdef WIFI_LED
#ifndef WIFI_LED_ON_STATE
#define WIFI_LED_ON_STATE LOW
Expand Down
3 changes: 0 additions & 3 deletions src/lcd_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@
#define ARRAY_ITEMS(a) (sizeof(a) / sizeof(a[0]))
#endif

// Message line buffer - shared across screens
extern char _msg[LCD_MAX_LINES][LCD_MAX_LEN + 1];

#endif // __LCD_COMMON_H
68 changes: 68 additions & 0 deletions src/lcd_static/lcd_gui.lock_png.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
static const char CONTENT_LOCK_PNG[] PROGMEM = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x08, 0x06, 0x00, 0x00, 0x00, 0x57, 0x02, 0xf9,
0x87, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0e, 0xc3, 0x00, 0x00, 0x0e,
0xc3, 0x01, 0xc7, 0x6f, 0xa8, 0x64, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f,
0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00, 0x00, 0x03, 0xa9, 0x49,
0x44, 0x41, 0x54, 0x68, 0x81, 0xed, 0x5a, 0x5b, 0x6c, 0x0c, 0x51, 0x18, 0xfe, 0xce, 0x99, 0x99,
0xdd, 0x6e, 0xb7, 0x5a, 0x6d, 0xb7, 0x17, 0x45, 0x11, 0x34, 0x92, 0xd2, 0x20, 0x4a, 0x83, 0x20,
0xfa, 0x40, 0x25, 0xbc, 0x78, 0xa0, 0x5e, 0x78, 0x73, 0x49, 0xf0, 0xa4, 0x21, 0x22, 0x2e, 0x89,
0x88, 0x27, 0xe2, 0xd6, 0x78, 0xf3, 0x42, 0xf1, 0x20, 0x91, 0x10, 0x6d, 0x04, 0x91, 0xb8, 0xb4,
0x55, 0x89, 0x6c, 0xdd, 0xe2, 0x4e, 0xdc, 0x1a, 0xbd, 0x6e, 0x2f, 0x76, 0x76, 0x66, 0xe7, 0x78,
0x10, 0x95, 0xc9, 0x98, 0xdd, 0x9d, 0xb3, 0x67, 0xac, 0xca, 0x7e, 0x6f, 0x7b, 0xfe, 0xff, 0xfc,
0xdf, 0xf7, 0xed, 0xcc, 0x9c, 0xb3, 0xe7, 0x9f, 0x25, 0x8c, 0x31, 0x86, 0x11, 0x0c, 0x59, 0x64,
0x31, 0xd6, 0x13, 0x82, 0x76, 0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f6, 0x31, 0xbb, 0x80, 0xbc,
0x64, 0x8e, 0x2b, 0x62, 0x78, 0xa0, 0xc4, 0xd0, 0x62, 0x6b, 0xc0, 0xbb, 0xae, 0x06, 0xd2, 0xd4,
0x52, 0x57, 0x04, 0x39, 0x81, 0x54, 0x36, 0x01, 0x9e, 0xda, 0x1a, 0xdb, 0x78, 0xcc, 0xe6, 0x2e,
0x0b, 0xab, 0x88, 0x5c, 0x68, 0x82, 0x76, 0xab, 0x0d, 0x46, 0x47, 0x17, 0x60, 0x18, 0xae, 0x88,
0xb4, 0x80, 0x52, 0xd0, 0xa2, 0x7c, 0x28, 0x4b, 0x2b, 0xe1, 0x59, 0xb3, 0x0c, 0xc4, 0x6b, 0xff,
0x06, 0x48, 0xc8, 0x9f, 0x3d, 0x52, 0x89, 0x1f, 0x84, 0x04, 0x44, 0xbc, 0x01, 0xce, 0x27, 0xf2,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0x00 };
static const char CONTENT_LOCK_PNG_ETAG[] PROGMEM = "2adc4e2aa7d940943c70a2bcce2e17dd05b6156d7d8b5841a86a63d816ee5d9c";
2 changes: 2 additions & 0 deletions src/lcd_static/lcd_gui_static_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "lcd_gui.connected_png.h"
#include "lcd_gui.disabled_png.h"
#include "lcd_gui.error_png.h"
#include "lcd_gui.lock_png.h"
#include "lcd_gui.logo_png.h"
#include "lcd_gui.no_wifi_png.h"
#include "lcd_gui.not_connected_png.h"
Expand All @@ -23,6 +24,7 @@ StaticFile lcd_gui_static_files[] = {
{ "/connected.png", CONTENT_CONNECTED_PNG, sizeof(CONTENT_CONNECTED_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_CONNECTED_PNG_ETAG, false },
{ "/disabled.png", CONTENT_DISABLED_PNG, sizeof(CONTENT_DISABLED_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_DISABLED_PNG_ETAG, false },
{ "/error.png", CONTENT_ERROR_PNG, sizeof(CONTENT_ERROR_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_ERROR_PNG_ETAG, false },
{ "/lock.png", CONTENT_LOCK_PNG, sizeof(CONTENT_LOCK_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_LOCK_PNG_ETAG, false },
{ "/logo.png", CONTENT_LOGO_PNG, sizeof(CONTENT_LOGO_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_LOGO_PNG_ETAG, false },
{ "/no_wifi.png", CONTENT_NO_WIFI_PNG, sizeof(CONTENT_NO_WIFI_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_NO_WIFI_PNG_ETAG, false },
{ "/not_connected.png", CONTENT_NOT_CONNECTED_PNG, sizeof(CONTENT_NOT_CONNECTED_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_NOT_CONNECTED_PNG_ETAG, false },
Expand Down
34 changes: 4 additions & 30 deletions src/lcd_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "emonesp.h"
#include "lcd.h"
#include "lcd_common.h"
#include "screens/screen_renderer.h"
#include "RapiSender.h"
#include "openevse.h"
#include "input.h"
Expand All @@ -20,9 +21,6 @@

PNG png; // Global PNG decoder instance

// Global message buffer shared with renderers
char _msg[LCD_MAX_LINES][LCD_MAX_LEN + 1];

LcdTask::Message::Message(const __FlashStringHelper *msg, int x, int y, int time, uint32_t flags) :
_next(NULL),
_msg(""),
Expand Down Expand Up @@ -65,9 +63,8 @@ LcdTask::LcdTask() :
#endif
{
for(int i = 0; i < LCD_MAX_LINES; i++) {
clearLine(i);
clear_message_line(i);
}
_msg_cleared = true;
}

LcdTask::~LcdTask()
Expand Down Expand Up @@ -194,7 +191,7 @@ unsigned long LcdTask::loop(MicroTasks::WakeReason reason)
{
DBUGLN("Clearing message lines");
for(int i = 0; i < LCD_MAX_LINES; i++) {
clearLine(i);
clear_message_line(i);
}
_msg_cleared = true;
}
Expand Down Expand Up @@ -238,7 +235,7 @@ unsigned long LcdTask::displayNextMessage()
_screenManager->wakeBacklight();
}
#endif //TFT_BACKLIGHT_TIMEOUT_MS
showText(msg->getX(), msg->getY(), msg->getMsg(), msg->getClear());
set_message_line(msg->getX(), msg->getY(), msg->getMsg(), msg->getClear());

_nextMessageTime = millis() + msg->getTime();

Expand All @@ -251,29 +248,6 @@ unsigned long LcdTask::displayNextMessage()
return nextUpdate;
}

void LcdTask::showText(int x, int y, const char *msg, bool clear)
{
DBUGF("LCD: %d %d %s, clear=%s", x, y, msg, clear ? "true" : "false");

if(clear) {
clearLine(y);
}

strncpy(_msg[y], msg + x, LCD_MAX_LEN - x);
_msg[y][LCD_MAX_LEN] = '\0';
_msg_cleared = false;
}

void LcdTask::clearLine(int line)
{
if(line < 0 || line >= LCD_MAX_LINES) {
return;
}

memset(_msg[line], ' ', LCD_MAX_LEN);
_msg[line][LCD_MAX_LEN] = '\0';
}

LcdTask lcd;

#endif // ENABLE_SCREEN_LCD_TFT
5 changes: 0 additions & 5 deletions src/lcd_tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,8 @@ class LcdTask : public MicroTasks::Task
bool _previous_vehicle_state;
#endif //TFT_BACKLIGHT_TIMEOUT_MS

char _msg[LCD_MAX_LINES][LCD_MAX_LEN + 1];
bool _msg_cleared;

void display(Message *msg, uint32_t flags);
unsigned long displayNextMessage();
void clearLine(int line);
void showText(int x, int y, const char *msg, bool clear);

#ifdef TFT_BACKLIGHT_TIMEOUT_MS
void timeoutBacklight();
Expand Down
Loading
Loading