From cad6db7175e164fd68e33849f16e8a930b372bf6 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 24 Feb 2019 10:53:00 +0100 Subject: [PATCH 1/7] Make M5SAM_LIST_MAX_COUNT overridable --- src/M5StackSAM.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/M5StackSAM.h b/src/M5StackSAM.h index ec28567..88a6902 100644 --- a/src/M5StackSAM.h +++ b/src/M5StackSAM.h @@ -15,7 +15,9 @@ #define M5SAM_BTN_TITLE_MAX_SIZE 6 #define M5SAM_MAX_SUBMENUS 8 +#ifnded M5SAM_LIST_MAX_COUNT #define M5SAM_LIST_MAX_COUNT 32 +#endif #define M5SAM_LIST_MAX_LABEL_SIZE 36 #define M5SAM_LIST_PAGE_LABELS 6 From 17639b1e992d5877fb3218f2b6d248f8f25be433 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 24 Feb 2019 11:08:59 +0100 Subject: [PATCH 2/7] whoops --- src/M5StackSAM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/M5StackSAM.h b/src/M5StackSAM.h index 88a6902..289502a 100644 --- a/src/M5StackSAM.h +++ b/src/M5StackSAM.h @@ -15,7 +15,7 @@ #define M5SAM_BTN_TITLE_MAX_SIZE 6 #define M5SAM_MAX_SUBMENUS 8 -#ifnded M5SAM_LIST_MAX_COUNT +#ifndef M5SAM_LIST_MAX_COUNT #define M5SAM_LIST_MAX_COUNT 32 #endif #define M5SAM_LIST_MAX_LABEL_SIZE 36 From fabc232cbebf5d782a8e788239b9a2f8ff88ec0d Mon Sep 17 00:00:00 2001 From: tobozo Date: Fri, 22 Mar 2019 16:44:21 +0100 Subject: [PATCH 3/7] Make rendering optional when walking list --- src/M5StackSAM.cpp | 4 ++-- src/M5StackSAM.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/M5StackSAM.cpp b/src/M5StackSAM.cpp index 22adbbc..a3cb4c0 100644 --- a/src/M5StackSAM.cpp +++ b/src/M5StackSAM.cpp @@ -68,7 +68,7 @@ String M5SAM::getListString(){ return list_labels[list_idx]; } -void M5SAM::nextList(){ +void M5SAM::nextList( bool renderAfter ){ if(list_idx< list_page * M5SAM_LIST_PAGE_LABELS + list_lines - 1){ list_idx++; }else{ @@ -79,7 +79,7 @@ void M5SAM::nextList(){ } list_idx = list_page * M5SAM_LIST_PAGE_LABELS; } - showList(); + if( renderAfter ) showList(); } void M5SAM::drawListItem(byte inIDX, byte postIDX){ diff --git a/src/M5StackSAM.h b/src/M5StackSAM.h index 289502a..52a254d 100644 --- a/src/M5StackSAM.h +++ b/src/M5StackSAM.h @@ -43,7 +43,7 @@ class M5SAM { byte getListID(); void setListID(byte idx); String getListString(); - void nextList(); + void nextList( bool renderAfter = true ); void addList(String inLabel); void setListCaption(String inCaption); String keyboardGetString(); From d671cbcf51e2c7fb8572fa631ea05660fe2653e6 Mon Sep 17 00:00:00 2001 From: tobozo Date: Mon, 25 Mar 2019 20:31:26 +0100 Subject: [PATCH 4/7] raise max count --- src/M5StackSAM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/M5StackSAM.h b/src/M5StackSAM.h index 52a254d..e0bbb46 100644 --- a/src/M5StackSAM.h +++ b/src/M5StackSAM.h @@ -16,7 +16,7 @@ #define M5SAM_MAX_SUBMENUS 8 #ifndef M5SAM_LIST_MAX_COUNT -#define M5SAM_LIST_MAX_COUNT 32 +#define M5SAM_LIST_MAX_COUNT 128 #endif #define M5SAM_LIST_MAX_LABEL_SIZE 36 #define M5SAM_LIST_PAGE_LABELS 6 From 860abb83a2db62faebfeb59d2312b148f1112040 Mon Sep 17 00:00:00 2001 From: tobozo Date: Wed, 6 Nov 2019 13:46:58 +0100 Subject: [PATCH 5/7] Better control on MenuList --- src/M5StackSAM.cpp | 53 ++++++++++++++++++++++++---------------------- src/M5StackSAM.h | 14 +++++++----- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/M5StackSAM.cpp b/src/M5StackSAM.cpp index a3cb4c0..8915ef8 100644 --- a/src/M5StackSAM.cpp +++ b/src/M5StackSAM.cpp @@ -35,18 +35,18 @@ void M5SAM::clearList(){ } void M5SAM::addList(String inStr){ - if(inStr.length()<=M5SAM_LIST_MAX_LABEL_SIZE and inStr.length()>0 and list_count < M5SAM_LIST_MAX_COUNT){ + if(inStr.length()<=listMaxLabelSize and inStr.length()>0 and list_count < M5SAM_LIST_MAX_COUNT){ list_labels[list_count] = inStr; list_count++; } if(list_count>0){ - if(list_count > M5SAM_LIST_PAGE_LABELS){ - list_lastpagelines = list_count % M5SAM_LIST_PAGE_LABELS; + if(list_count > listPagination){ + list_lastpagelines = list_count % listPagination; if(list_lastpagelines>0){ - list_pages = (list_count - list_lastpagelines) / M5SAM_LIST_PAGE_LABELS; + list_pages = (list_count - list_lastpagelines) / listPagination; list_pages++; }else{ - list_pages = list_count / M5SAM_LIST_PAGE_LABELS; + list_pages = list_count / listPagination; } }else{ list_pages = 1; @@ -58,10 +58,10 @@ byte M5SAM::getListID(){ return list_idx; } void M5SAM::setListID(byte idx) { - if(idx< list_page * M5SAM_LIST_PAGE_LABELS + list_lines){ + if(idx< list_page * listPagination + list_lines){ list_idx = idx; } - list_page = list_idx / M5SAM_LIST_PAGE_LABELS; + list_page = list_idx / listPagination; } String M5SAM::getListString(){ @@ -69,7 +69,7 @@ String M5SAM::getListString(){ } void M5SAM::nextList( bool renderAfter ){ - if(list_idx< list_page * M5SAM_LIST_PAGE_LABELS + list_lines - 1){ + if(list_idx< list_page * listPagination + list_lines - 1){ list_idx++; }else{ if(list_page",3,80+(postIDX*20),2); + M5.Lcd.drawString(list_labels[inIDX],15,listPageLabelsOffset+(postIDX*20),2); + M5.Lcd.drawString(">",3,listPageLabelsOffset+(postIDX*20),2); }else{ - M5.Lcd.drawString(list_labels[inIDX],15,80+(postIDX*20),2); + M5.Lcd.drawString(list_labels[inIDX],15,listPageLabelsOffset+(postIDX*20),2); } } void M5SAM::showList(){ windowClr(); byte labelid = 0; - M5.Lcd.drawCentreString(listCaption,M5.Lcd.width()/2,45,2); + M5.Lcd.setTextDatum( listCaptionDatum ); + //M5.Lcd.drawCentreString(listCaption,M5.Lcd.width()/2,45,2); + M5.Lcd.drawString(listCaption, listCaptionXPos, listCaptionYPos, 2); + M5.Lcd.setTextDatum( TL_DATUM ); if((list_page + 1) == list_pages){ - if(list_lastpagelines == 0 and list_count >= M5SAM_LIST_PAGE_LABELS){ - list_lines = M5SAM_LIST_PAGE_LABELS; - for(byte i = 0;i= listPagination){ + list_lines = listPagination; + for(byte i = 0;i1){ list_lines = list_lastpagelines; for(byte i = 0;i - +/* +// why was it even here ? #if defined(WIRING) && WIRING >= 100 #include #elif defined(ARDUINO) && ARDUINO >= 100 @@ -7,7 +8,7 @@ #else #include #endif - +*/ #ifndef M5StackSAM_h #define M5StackSAM_h @@ -18,8 +19,6 @@ #ifndef M5SAM_LIST_MAX_COUNT #define M5SAM_LIST_MAX_COUNT 128 #endif -#define M5SAM_LIST_MAX_LABEL_SIZE 36 -#define M5SAM_LIST_PAGE_LABELS 6 volatile static uint8_t _keyboardIRQRcvd; volatile static uint8_t _keyboardChar; @@ -48,6 +47,12 @@ class M5SAM { void setListCaption(String inCaption); String keyboardGetString(); String lastBtnTittle[3]; + uint8_t listMaxLabelSize = 36; // list labels will be trimmed + uint8_t listPagination = 6; + uint8_t listPageLabelsOffset = 80; // initially 80, pixels offset from top screen for list items + uint8_t listCaptionDatum = TC_DATUM; // initially TC_DATUM=top centered, TL_DATUM=top left (default), top/right/bottom/left + uint16_t listCaptionXPos = 160; // initially M5.Lcd.width()/2, text cursor position-x for list caption + uint16_t listCaptionYPos = 45; // initially 45, text cursor position-x for list caption private: String listCaption; @@ -66,7 +71,6 @@ class M5SAM { char btnCtitle[M5SAM_BTN_TITLE_MAX_SIZE + 1]; signed char gotoLevel; void (*function)(); - }; String list_labels[M5SAM_LIST_MAX_COUNT]; byte list_lastpagelines; From 4c89bd9f3b0f8b7aa0b88dd998ff911590809696 Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 7 Nov 2019 17:14:12 +0100 Subject: [PATCH 6/7] Fixing backwards compat --- src/M5StackSAM.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/M5StackSAM.h b/src/M5StackSAM.h index 342d358..c972b0e 100644 --- a/src/M5StackSAM.h +++ b/src/M5StackSAM.h @@ -20,6 +20,9 @@ #define M5SAM_LIST_MAX_COUNT 128 #endif +#define M5SAM_LIST_MAX_LABEL_SIZE 36 // list labels will be trimmed +#define M5SAM_LIST_PAGE_LABELS 6 + volatile static uint8_t _keyboardIRQRcvd; volatile static uint8_t _keyboardChar; @@ -47,8 +50,8 @@ class M5SAM { void setListCaption(String inCaption); String keyboardGetString(); String lastBtnTittle[3]; - uint8_t listMaxLabelSize = 36; // list labels will be trimmed - uint8_t listPagination = 6; + uint8_t listMaxLabelSize = M5SAM_LIST_MAX_LABEL_SIZE; // list labels will be trimmed + uint8_t listPagination = M5SAM_LIST_PAGE_LABELS; uint8_t listPageLabelsOffset = 80; // initially 80, pixels offset from top screen for list items uint8_t listCaptionDatum = TC_DATUM; // initially TC_DATUM=top centered, TL_DATUM=top left (default), top/right/bottom/left uint16_t listCaptionXPos = 160; // initially M5.Lcd.width()/2, text cursor position-x for list caption From e5f5a2f69ab6fc21dbe9ebec773beec4c04926cd Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 14 Nov 2019 21:53:44 +0100 Subject: [PATCH 7/7] Enabled Odroid-Go 4 buttons mode --- src/M5StackSAM.cpp | 86 +++++++++++++++++++++++++++++++++------------- src/M5StackSAM.h | 14 ++++++-- 2 files changed, 75 insertions(+), 25 deletions(-) diff --git a/src/M5StackSAM.cpp b/src/M5StackSAM.cpp index 8915ef8..347f2d3 100644 --- a/src/M5StackSAM.cpp +++ b/src/M5StackSAM.cpp @@ -221,17 +221,7 @@ String M5SAM::keyboardGetString(){ return tmp_str; } -void M5SAM::btnRestore(){ - M5.Lcd.setTextColor(menutextcolor); - M5.Lcd.fillRoundRect(0,M5.Lcd.height()-28,M5.Lcd.width(),28,3,0x00); - M5.Lcd.fillRoundRect(31,M5.Lcd.height()-28,60,28,3,menucolor); - M5.Lcd.fillRoundRect(126,M5.Lcd.height()-28,60,28,3,menucolor); - M5.Lcd.fillRoundRect(221,M5.Lcd.height()-28,60,28,3,menucolor); - M5.Lcd.drawCentreString(lastBtnTittle[0],31+30,M5.Lcd.height()-28+6,2); - M5.Lcd.drawCentreString(lastBtnTittle[1],126+30,M5.Lcd.height()-28+6,2); - M5.Lcd.drawCentreString(lastBtnTittle[2],221+30,M5.Lcd.height()-28+6,2); - M5.Lcd.setTextColor(menutextcolor,windowcolor); -} + /* void M5SAM::keyboardEnable(){ pinMode(5, INPUT); @@ -254,21 +244,71 @@ void M5SAM::keyboardIRQ(){ _keyboardIRQRcvd = HIGH; } */ -void M5SAM::drawMenu(String inmenuttl, String inbtnAttl, String inbtnBttl, String inbtnCttl, unsigned int inmenucolor, unsigned int inwindowcolor, unsigned int intxtcolor){ - lastBtnTittle[0] = inbtnAttl; - lastBtnTittle[1] = inbtnBttl; - lastBtnTittle[2] = inbtnCttl; - M5.Lcd.fillRoundRect(31,M5.Lcd.height()-28,60,28,3,inmenucolor); - M5.Lcd.fillRoundRect(126,M5.Lcd.height()-28,60,28,3,inmenucolor); - M5.Lcd.fillRoundRect(221,M5.Lcd.height()-28,60,28,3,inmenucolor); - M5.Lcd.fillRoundRect(0,0,M5.Lcd.width(),28,3,inmenucolor); + +#ifdef ARDUINO_ODROID_ESP32 + + #define BUTTON_WIDTH 60 + #define BUTTON_HWIDTH BUTTON_WIDTH/2 // 30 + #define BUTTON_HEIGHT 28 + uint16_t buttonsXOffset[4] = { + 1, 72, 188, 260 + }; + + void M5SAM::drawMenu(String inmenuttl, String inbtnAttl, String intSpeakerttl, String inbtnBttl, String inbtnCttl, unsigned int inmenucolor, unsigned int inwindowcolor, unsigned int intxtcolor) { + lastBtnTittle[1] = intSpeakerttl; + drawMenu(inmenuttl, inbtnAttl, inbtnBttl, inbtnCttl, inmenucolor, inwindowcolor, intxtcolor); + } + void M5SAM::drawAppMenu(String inmenuttl, String inbtnAttl, String intSpeakerttl, String inbtnBttl, String inbtnCttl){ + drawMenu(inmenuttl, inbtnAttl, intSpeakerttl, inbtnBttl, inbtnCttl, menucolor, windowcolor, menutextcolor); + M5.Lcd.setTextColor(menutextcolor,windowcolor); + } + +#else + + #define BUTTON_WIDTH 60 + #define BUTTON_HWIDTH BUTTON_WIDTH/2 // 30 + #define BUTTON_HEIGHT 28 + uint16_t buttonsXOffset[3] = { + 31, 126, 221 + }; + +#endif + +void M5SAM::btnRestore(){ + M5.Lcd.setTextColor(menutextcolor); + M5.Lcd.fillRoundRect(0,M5.Lcd.height()-BUTTON_HEIGHT,M5.Lcd.width(),BUTTON_HEIGHT,3,0x00); + for( byte i=0; i