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

Update upstream #3

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
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
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
54e002e
fixed the spelling error in M5.TP.available(), otherwise the error wo…
HonestQiao Oct 2, 2023
6d44c01
When the language is set to zh, ntp.aliyun.com is used as the ntp ser…
HonestQiao Oct 2, 2023
6aa7ad3
M Fix typo
icyqwq Oct 25, 2023
d031740
Fix spi confliction issue at startup.
icyqwq Oct 26, 2023
ba03364
Merge branch 'm5stack:main' into main
HonestQiao Oct 26, 2023
a8d1808
Fix not being able to select the first item in the list without a crash.
hexmaster111 Jun 9, 2024
8699920
Error fixes and ntp synchronization time optimization
Tinyu-Zhao Jun 11, 2024
aadeebe
Fix not being able to select the first item in the Wifi list without …
Tinyu-Zhao Jun 18, 2024
7e1650f
Fix system crash when connecting to NTP
Tinyu-Zhao Jun 20, 2024
277b398
Merge branch 'main' of github.com:m5stack/M5Paper_FactoryTest
Tinyu-Zhao Jun 20, 2024
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
9 changes: 5 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
; https://docs.platformio.org/page/projectconf.html

[env:m5stack-fire]
platform = espressif32
platform = espressif32@^5.1.0
board = m5stack-fire
framework = arduino
upload_speed = 2000000
platform_packages = platformio/framework-arduinoespressif32@3.20004.0
upload_speed = 1500000
monitor_speed = 115200
board_build.partitions = default_16MB.csv
build_flags =
-DCORE_DEBUG_LEVEL=4
build_flags =
-DCORE_DEBUG_LEVEL=5
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
lib_deps =
Expand Down
166 changes: 72 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.available()) {
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,76 +125,67 @@ 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;
frame->init(frame_map[frame->GetFrameName()].args);
EPDGUI_Run(frame);
}
vTaskDelay(1);
}

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));
vTaskDelay(1);
}

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