Skip to content
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

Upstream merge #1

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fb93bca
Add M5EPD as a platformio dependency
fcapano Jan 2, 2021
99bceaf
Merge pull request #4 from fcapano/patch-1
Gitshaoxiang May 26, 2021
739b1e1
Support TXT when filesystem reports uppercase
eggfly Sep 20, 2021
c0a9780
Auto shutdown for power saving
eggfly Sep 19, 2021
4a403f2
Merge pull request #6 from eggfly/main
Gitshaoxiang Sep 23, 2021
588d8f2
update sleep logo and change page refresh mode
Gitshaoxiang Nov 12, 2021
860c8f0
Update platformio.ini to resolve upload failure
TRex22 Mar 31, 2022
485d7fc
Compatible with CH9102 chip
Tinyu-Zhao Jul 19, 2022
c6cdcb5
Fixed problem of compile error in new environment
Tinyu-Zhao Jul 19, 2022
4fe44ad
Merge remote-tracking branch 'zenreader/master' into test_zenreader_main
hpsaturn Jul 19, 2022
82d7694
fixed some merge issues and remove usb ports for OS compatibility
hpsaturn Jul 19, 2022
2d2b5b6
added build flags for remove/add widgets (i.e keyboard for WiFi config)
hpsaturn Jul 19, 2022
4537be0
fix bug where 5th file item and later on a folder are not displayed o…
cat-in-136 Oct 23, 2022
a059c2d
Update frame_fileindex.cpp
Tinyu-Zhao Oct 24, 2022
f3eb8fa
Fix bug where 5th file item and later on a folder are not displayed o…
Tinyu-Zhao Oct 24, 2022
85ce8c4
Create M5Paper_FactoryTest.ino
tobozo Nov 21, 2022
64db8c6
Merge pull request #13 from tobozo/main
Nov 23, 2022
3f75bd5
Update: Update platformio.ini for limit some pacs
Nov 23, 2022
e8cd6f4
Merge pull request #14 from IcingTomato/main
Nov 23, 2022
8fbfa02
Use latest working platform package version
SomeoneToIgnore Nov 24, 2022
e375ac6
Use latest working platform package version
Tinyu-Zhao Nov 26, 2022
67e2346
Update platformio.ini
Dec 12, 2022
7d22adb
Merge pull request #17 from IcingTomato/main
Dec 12, 2022
b9b8d55
Update: Update framework in platformio.ini
Dec 12, 2022
5247147
Update platformio.ini
Dec 30, 2022
7ad43f1
Merge pull request #19 from IcingTomato/main
Dec 30, 2022
d1d809a
Merge remote-tracking branch 'upstream/main' into upstream_merge
hpsaturn Jun 13, 2023
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
5 changes: 5 additions & 0 deletions M5Paper_FactoryTest.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Satisfy Arduino IDE (needs a .ino file, even if it's empty)

#if !defined ARDUINO_M5STACK_FIRE
#error "Please Select M5Fire from the board menu"
#endif
16 changes: 8 additions & 8 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
; https://docs.platformio.org/page/projectconf.html

[env:m5stack-fire]
platform = espressif32
platform = espressif32@^3.2.0
board = m5stack-fire
framework = arduino
lib_deps =
m5stack/M5EPD @ ^0.1.1
bblanchon/ArduinoJson@^6.17.3
upload_port = /dev/ttyUSB*
monitor_port = /dev/ttyUSB*
upload_speed = 2000000
m5stack/M5EPD
bblanchon/ArduinoJson@ 6.17.3
upload_speed = 1500000
monitor_speed = 115200
board_build.partitions = default_16MB.csv
build_flags =
-DCORE_DEBUG_LEVEL=4
build_flags =
-DCORE_DEBUG_LEVEL=0
-DINCLUDE_FACTORYTESTS=1
-DINCLUDE_HOMESAMPLE=1
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
164 changes: 70 additions & 94 deletions src/epdgui/epdgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,133 +3,120 @@
#include <list>
#include "epdgui.h"

typedef struct
{
typedef struct {
Frame_Base* frame;
epdgui_args_vector_t args;
}frame_struct_t;
} frame_struct_t;

std::list<EPDGUI_Base*> epdgui_object_list;
uint32_t obj_id = 1;
uint32_t obj_id = 1;
Frame_Base* wait_for_delete = NULL;
std::stack <Frame_Base*> frame_stack;
std::stack<Frame_Base*> frame_stack;
std::map<String, frame_struct_t> frame_map;
uint8_t frame_switch_count = 0;
bool _is_auto_update = true;
bool _is_auto_update = true;

uint16_t _is_last_finger_up = 0xFFFF;
uint16_t _last_pos_x = 0xFFFF, _last_pos_y = 0xFFFF;

void EPDGUI_AddObject(EPDGUI_Base* object)
{
uint32_t g_last_active_time_millis = 0;

void EPDGUI_AddObject(EPDGUI_Base* object) {
object->SetID(obj_id);
obj_id++;
epdgui_object_list.push_back(object);
}

void EPDGUI_Draw(m5epd_update_mode_t mode)
{
for(std::list<EPDGUI_Base*>::iterator p = epdgui_object_list.begin(); p != epdgui_object_list.end(); p++)
{
void EPDGUI_Draw(m5epd_update_mode_t mode) {
for (std::list<EPDGUI_Base*>::iterator p = epdgui_object_list.begin();
p != epdgui_object_list.end(); p++) {
(*p)->Draw(mode);
}
}

void EPDGUI_Process(void)
{
for(std::list<EPDGUI_Base*>::iterator p = epdgui_object_list.begin(); p != epdgui_object_list.end(); p++)
{
void EPDGUI_Process(void) {
for (std::list<EPDGUI_Base*>::iterator p = epdgui_object_list.begin();
p != epdgui_object_list.end(); p++) {
(*p)->UpdateState(-1, -1);
}
}

void EPDGUI_Process(int16_t x, int16_t y)
{
for(std::list<EPDGUI_Base*>::iterator p = epdgui_object_list.begin(); p != epdgui_object_list.end(); p++)
{
// log_d("%d, %d -> %d, %d, %d, %d", x, y, (*p)->getX(), (*p)->getY(), (*p)->getRX(), (*p)->getBY());
void EPDGUI_Process(int16_t x, int16_t y) {
for (std::list<EPDGUI_Base*>::iterator p = epdgui_object_list.begin();
p != epdgui_object_list.end(); p++) {
// log_d("%d, %d -> %d, %d, %d, %d", x, y, (*p)->getX(), (*p)->getY(),
// (*p)->getRX(), (*p)->getBY());
(*p)->UpdateState(x, y);
}
}

void EPDGUI_Clear(void)
{
void EPDGUI_Clear(void) {
epdgui_object_list.clear();
}

void EPDGUI_Run(Frame_Base* frame)
{
void EPDGUI_Run(Frame_Base* frame) {
uint32_t last_active_time = 0;

if(frame->isRun() == 0)
{
if (frame->isRun() == 0) {
frame->exit();
log_d("Exit %s", frame->GetFrameName().c_str());
if(wait_for_delete != NULL)
{
if (wait_for_delete != NULL) {
delete wait_for_delete;
wait_for_delete = NULL;
}
return;
}

EPDGUI_Draw(UPDATE_MODE_NONE);
if((frame->GetFrameID() == 1) || (frame_switch_count > 3))
{
if ((frame->GetFrameID() == 1) || (frame_switch_count > 3)) {
frame_switch_count = 0;
M5.EPD.UpdateFull(UPDATE_MODE_GC16);
}
else
{
} else {
M5.EPD.UpdateFull(UPDATE_MODE_GL16);
frame_switch_count++;
}

while (1)
{
if((frame->isRun() == 0) || (frame->run() == 0))
{
while (1) {
if ((frame->isRun() == 0) || (frame->run() == 0)) {
frame->exit();
// M5.EPD.Clear();
M5.EPD.Clear(true);
log_d("Exit %s", frame->GetFrameName().c_str());
if(wait_for_delete != NULL)
{
if (wait_for_delete != NULL) {
log_d("delete %s", wait_for_delete->GetFrameName().c_str());
delete wait_for_delete;
wait_for_delete = NULL;
}
return;
}

if (M5.TP.avaliable())
{
if (M5.TP.avaliable()) {
M5.TP.update();
bool is_finger_up = M5.TP.isFingerUp();
if(is_finger_up || (_last_pos_x != M5.TP.readFingerX(0)) || (_last_pos_y != M5.TP.readFingerY(0)))
{
_last_pos_x = M5.TP.readFingerX(0);
_last_pos_y = M5.TP.readFingerY(0);
if(is_finger_up)
{
uint16_t is_finger_up = M5.TP.isFingerUp() ? 1 : 0;
uint16_t pos_x = M5.TP.readFingerX(0);
uint16_t pos_y = M5.TP.readFingerY(0);
// Avoid duplicate events
if (_is_last_finger_up != is_finger_up || _last_pos_x != pos_x ||
_last_pos_y != pos_y) {
EPDGUI_UpdateGlobalLastActiveTime();
_last_pos_x = pos_x;
_last_pos_y = pos_y;
_is_last_finger_up = is_finger_up;
if (is_finger_up) {
EPDGUI_Process();
last_active_time = millis();
}
else
{
EPDGUI_Process(M5.TP.readFingerX(0), M5.TP.readFingerY(0));
} else {
EPDGUI_Process(pos_x, pos_y);
last_active_time = 0;
}
}



M5.TP.flush();
}

if((last_active_time != 0) && (millis() - last_active_time > 2000))
{
if(M5.EPD.UpdateCount() > 4)
{
if ((last_active_time != 0) && (millis() - last_active_time > 2000)) {
if (M5.EPD.UpdateCount() > 4) {
M5.EPD.ResetUpdateCount();
if(_is_auto_update)
{
if (_is_auto_update) {
M5.EPD.UpdateFull(UPDATE_MODE_GL16);
}
}
Expand All @@ -138,11 +125,9 @@ void EPDGUI_Run(Frame_Base* frame)
}
}

void EPDGUI_MainLoop(void)
{
if((!frame_stack.empty()) && (frame_stack.top() != NULL))
{
Frame_Base *frame = frame_stack.top();
void EPDGUI_MainLoop(void) {
if ((!frame_stack.empty()) && (frame_stack.top() != NULL)) {
Frame_Base* frame = frame_stack.top();
log_d("Run %s", frame->GetFrameName().c_str());
EPDGUI_Clear();
_is_auto_update = true;
Expand All @@ -151,63 +136,54 @@ void EPDGUI_MainLoop(void)
}
}

void EPDGUI_AddFrame(String name, Frame_Base* frame)
{
void EPDGUI_AddFrame(String name, Frame_Base* frame) {
frame_struct_t f;
f.frame = frame;
frame_map.insert(std::pair<String, frame_struct_t>(name, f));
}

void EPDGUI_AddFrameArg(String name, int n, void* arg)
{
if(frame_map.count(name) == 0)
{
void EPDGUI_AddFrameArg(String name, int n, void* arg) {
if (frame_map.count(name) == 0) {
return;
}
if(frame_map[name].args.size() > n)
{
if (frame_map[name].args.size() > n) {
frame_map[name].args[n] = arg;
}
else
{
} else {
frame_map[name].args.push_back(arg);
}
log_d("%d", frame_map[name].args.size());
}

Frame_Base* EPDGUI_GetFrame(String name)
{
if(frame_map.count(name) > 0)
{
Frame_Base* EPDGUI_GetFrame(String name) {
if (frame_map.count(name) > 0) {
return frame_map[name].frame;
}
return NULL;
}

void EPDGUI_PushFrame(Frame_Base* frame)
{
void EPDGUI_PushFrame(Frame_Base* frame) {
frame_stack.push(frame);
}

void EPDGUI_PopFrame(bool isDelete)
{
if(isDelete)
{
void EPDGUI_PopFrame(bool isDelete) {
if (isDelete) {
wait_for_delete = frame_stack.top();
}
frame_stack.pop();
}

void EPDGUI_OverwriteFrame(Frame_Base* frame)
{
while(!frame_stack.empty())
{
void EPDGUI_OverwriteFrame(Frame_Base* frame) {
while (!frame_stack.empty()) {
frame_stack.pop();
}
frame_stack.push(frame);
}

void EPDGUI_SetAutoUpdate(bool isAuto)
{
void EPDGUI_SetAutoUpdate(bool isAuto) {
_is_auto_update = isAuto;
}

/// Update active time to avoid power saving
void EPDGUI_UpdateGlobalLastActiveTime() {
g_last_active_time_millis = millis();
}
6 changes: 5 additions & 1 deletion src/epdgui/epdgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ void EPDGUI_AddFrameArg(String name, int n, void* arg);
Frame_Base* EPDGUI_GetFrame(String name);
void EPDGUI_SetAutoUpdate(bool isAuto);

#endif //__EPDGUI_H
extern uint32_t g_last_active_time_millis;

void EPDGUI_UpdateGlobalLastActiveTime();

#endif //__EPDGUI_H
Loading