From 473df7d81b487b35af2da60f1eb1bef16afae745 Mon Sep 17 00:00:00 2001 From: lunokIoT <797792+lunokjod@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:23:01 +0100 Subject: [PATCH] begin support for M5 (work in progress) --- platformio.ini | 29 +- src/UI/Animation.cpp | 7 + src/UI/Animation.hpp | 6 +- src/UI/AppTemplate.cpp | 1 - src/UI/BootSplash.cpp | 51 +++- src/UI/UI.cpp | 50 +++- src/UI/UI.hpp | 20 +- src/UI/base/Widget.hpp | 7 +- src/UI/controls/Buffer.hpp | 6 + src/UI/controls/Button.cpp | 8 +- src/UI/controls/Check.hpp | 2 +- src/UI/controls/Draw.hpp | 4 + src/UI/controls/IconMenu.hpp | 6 + src/UI/controls/Image.hpp | 4 + src/UI/controls/Paginator.hpp | 2 +- src/UI/controls/Text.hpp | 5 + src/UI/controls/View3D/Common.hpp | 4 + src/UI/controls/View3D/View3D.cpp | 4 +- src/UI/controls/View3D/View3D.hpp | 2 +- src/UI/controls/XBM.hpp | 1 - src/UI/controls/base/Control.cpp | 7 +- src/UI/controls/base/Control.hpp | 13 +- src/UI/transition/Displace.hpp | 4 + src/UI/transition/Fade.hpp | 4 + src/UI/transition/Flip.hpp | 5 + src/UI/transition/Stripes.hpp | 5 + src/UI/transition/UpDown.hpp | 5 + src/UI/transition/ZoomOut.hpp | 5 + src/UI/widgets/ButtonImageXBMWidget.cpp | 6 +- src/UI/widgets/ButtonTextWidget.cpp | 2 +- src/UI/widgets/ButtonWidget.cpp | 4 +- src/UI/widgets/CanvasWidget.cpp | 10 +- src/UI/widgets/CanvasWidget.hpp | 3 + src/UI/widgets/CanvasZWidget.cpp | 6 +- src/UI/widgets/CanvasZWidget.hpp | 6 +- src/UI/widgets/EntryTextWidget.cpp | 2 +- src/UI/widgets/GraphWidget.cpp | 2 +- src/UI/widgets/NotificationWidget.cpp | 2 +- src/UI/widgets/NotificationWidget.hpp | 4 +- src/UI/widgets/ScrollViewWidget.cpp | 4 +- src/UI/widgets/ScrollViewWidget.hpp | 2 +- src/UI/widgets/SwitchWidget.cpp | 2 +- src/UI/widgets/ValueSelector.cpp | 2 +- src/UI/widgets/ValueSelector.hpp | 2 +- src/app/About.cpp | 35 ++- src/app/About.hpp | 2 +- src/app/Activities.cpp | 1 - src/app/ActivityRecorder.cpp | 352 ----------------------- src/app/ActivityRecorder.hpp | 87 ------ src/app/Advanced.cpp | 2 +- src/app/Advanced.hpp | 2 +- src/app/AppPartitionBrowser.cpp | 4 +- src/app/BLEDevice.cpp | 2 +- src/app/BLEDevice.hpp | 2 +- src/app/BLEMonitor.cpp | 14 +- src/app/BLEMonitor.hpp | 2 +- src/app/Battery.cpp | 9 + src/app/Battery.hpp | 2 +- src/app/Bluetooth.cpp | 2 +- src/app/Bluetooth.hpp | 2 +- src/app/Brightness.cpp | 21 +- src/app/Calculator.cpp | 2 +- src/app/Calculator.hpp | 2 +- src/app/Calendar.cpp | 4 +- src/app/CalendarLogDetail.cpp | 2 +- src/app/Dungeon/Dungeon.cpp | 6 +- src/app/Dungeon/MapGenerator.cpp | 2 +- src/app/FileBrowser.cpp | 4 +- src/app/FreehandKeyboardLetterChoice.cpp | 4 +- src/app/FreehandKeyboardLetterChoice.hpp | 2 +- src/app/FreehandKeyboardQuery.cpp | 4 +- src/app/FreehandKeyboardQuery.hpp | 2 +- src/app/FreehandKeyboardSetup.cpp | 2 +- src/app/FreehandKeyboardTraining.cpp | 4 +- src/app/FreehandKeyboardTraining.hpp | 2 +- src/app/GestureSettings.cpp | 6 + src/app/IATest.cpp | 54 ++-- src/app/KnowLocations.cpp | 8 +- src/app/Lamp.cpp | 6 + src/app/LockPicking.cpp | 115 -------- src/app/LockPicking.hpp | 45 --- src/app/LogView.cpp | 2 +- src/app/LogView.hpp | 3 +- src/app/LuIBufferTest.cpp | 2 +- src/app/LuIButtonsTest.cpp | 14 +- src/app/LuIDemoMask.cpp | 6 +- src/app/LuIDemoMask.hpp | 2 +- src/app/LuIDemoPlanet.cpp | 22 +- src/app/LuIDemoRubiks.cpp | 304 -------------------- src/app/LuIDemoRubiks.hpp | 35 --- src/app/LuIGameOfLife.cpp | 13 +- src/app/LuIMainMenu.cpp | 15 +- src/app/LuIRotation.cpp | 17 +- src/app/LuISettingsMenu.cpp | 2 +- src/app/LuITest.cpp | 8 +- src/app/LuITest.hpp | 2 +- src/app/LuiChess.cpp | 192 ------------- src/app/LuiChess.hpp | 55 ---- src/app/LuiExperiment.cpp | 4 +- src/app/LuiGamesMenu.cpp | 2 +- src/app/LunoNoid.cpp | 19 +- src/app/Provisioning2.cpp | 6 +- src/app/Provisioning2.hpp | 2 +- src/app/SetDate.cpp | 8 +- src/app/SetTime.cpp | 8 +- src/app/SetTime.hpp | 2 +- src/app/SetTimeZone.cpp | 10 +- src/app/SetTimeZone.hpp | 2 +- src/app/Steps.hpp | 2 +- src/app/Stopwatch.hpp | 2 +- src/app/Theme.cpp | 4 +- src/app/Watchface2.cpp | 22 +- src/app/Watchface2.hpp | 12 +- src/app/WatchfaceBasic.hpp | 4 +- src/main.cpp | 2 +- src/system/Application.hpp | 8 + src/system/Network/Tasks/GeoIP.hpp | 7 +- src/system/Network/Tasks/NTP.hpp | 9 +- src/system/Network/Tasks/Weather.hpp | 2 +- src/system/SystemEvents.cpp | 2 +- src/system/lunokIoT.cpp | 36 ++- 121 files changed, 590 insertions(+), 1422 deletions(-) delete mode 100644 src/app/ActivityRecorder.cpp delete mode 100644 src/app/ActivityRecorder.hpp delete mode 100644 src/app/LockPicking.cpp delete mode 100644 src/app/LockPicking.hpp delete mode 100644 src/app/LuIDemoRubiks.cpp delete mode 100644 src/app/LuIDemoRubiks.hpp delete mode 100644 src/app/LuiChess.cpp delete mode 100644 src/app/LuiChess.hpp diff --git a/platformio.ini b/platformio.ini index 9265d50..5718f5f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,8 +14,6 @@ board = ttgo-t-watch framework = arduino lib_deps = https://github.com/siara-cc/esp32_arduino_sqlite3_lib.git - ;../TTGO_TWatch_Library_alt/ - https://github.com/lunokjod/TTGO_TWatch_Library_alt.git rpolitex/ArduinoNvs@^2.5 ricmoo/QRCode@^0.0.1 arduino-libraries/Arduino_JSON@^0.1.0 @@ -50,24 +48,47 @@ build_flags = -DLUNOKIOT_WIFI_ENABLED ;-fno-sanitize=shift-base ; -Wl,--wrap=ps_malloc -extra_scripts = - pre:./tool/generateConfig.py +;extra_scripts = +; pre:./tool/generateConfig.py + +[env:m5stack-core2] +board = m5stack-core2 +lib_deps = ${env.lib_deps} + m5stack/M5Core2 +monitor_speed = 115200 +upload_speed = 115200 +build_flags = + -DM5_DEV [BaseTwatchV1] lib_deps = ${env.lib_deps} earlephilhower/ESP8266Audio@^1.9.7 + ;Xinyuan-LilyGO/TTGO_TWatch_Library + https://github.com/Xinyuan-LilyGO/TTGO_TWatch_Library.git + ;../TTGO_TWatch_Library_alt/ + ;https://github.com/lunokjod/TTGO_TWatch_Library_alt.git build_flags = + -DLILYGO_DEV -DLILYGO_WATCH_2020_V1 [BaseTwatchV2] lib_deps = ${env.lib_deps} + ;../TTGO_TWatch_Library_alt/ + ;https://github.com/lunokjod/TTGO_TWatch_Library_alt.git + https://github.com/Xinyuan-LilyGO/TTGO_TWatch_Library.git build_flags = + -DLILYGO_DEV -DLILYGO_WATCH_2020_V2 [BaseTwatchV3] lib_deps = ${env.lib_deps} earlephilhower/ESP8266Audio@^1.9.7 + https://github.com/Xinyuan-LilyGO/TTGO_TWatch_Library.git + ;Xinyuan-LilyGO/TTGO_TWatch_Library + ;../TTGO_TWatch_Library_alt/ + ;https://github.com/lunokjod/TTGO_TWatch_Library_alt.git build_flags = + -DLILYGO_DEV -DLILYGO_WATCH_2020_V3 -DLUNOKIOT_BATTERY_CHECK diff --git a/src/UI/Animation.cpp b/src/UI/Animation.cpp index 84d283a..3fc2460 100644 --- a/src/UI/Animation.cpp +++ b/src/UI/Animation.cpp @@ -18,8 +18,12 @@ // #include "Animation.hpp" +#include "../app/LogView.hpp" + +#ifdef LILYGO_DEV #include extern TTGOClass *ttgo; +#endif AnimationDescriptor::AnimationDescriptor(int32_t fromX,int32_t fromY,int32_t toX, int32_t toY, int32_t stepSize) : fromX(fromX), fromY(fromY),toX(toX),toY(toY),stepSize(stepSize) { @@ -53,5 +57,8 @@ void AnimationDescriptor::Step() { } void AnimationDescriptor::Draw() { + #ifdef LILYGO_DEV tft->fillRoundRect(currentX,currentY,35,35,5,0x5DFC); + #endif + lLog("WARNING: AnimationDescriptor::Draw() only TFT_eSPI support\n"); } diff --git a/src/UI/Animation.hpp b/src/UI/Animation.hpp index d105214..4b03d2f 100644 --- a/src/UI/Animation.hpp +++ b/src/UI/Animation.hpp @@ -27,9 +27,13 @@ * https://www.geeksforgeeks.org/mid-point-circle-drawing-algorithm/?ref=lbp */ #include + +#ifdef LILYGO_DEV #include +#endif +//M5_DEV -#include "lunokiot_config.hpp" +#include "../lunokiot_config.hpp" class AnimationDescriptor { public: diff --git a/src/UI/AppTemplate.cpp b/src/UI/AppTemplate.cpp index 6ddac72..d43d0ab 100644 --- a/src/UI/AppTemplate.cpp +++ b/src/UI/AppTemplate.cpp @@ -23,7 +23,6 @@ //#include #include "../lunokiot_config.hpp" -#include "../app/LogView.hpp" // for lLog functions #include "../resources.hpp" TemplateApplication::~TemplateApplication() { delete btnBack; } diff --git a/src/UI/BootSplash.cpp b/src/UI/BootSplash.cpp index a2d5e0a..f7c9c9a 100644 --- a/src/UI/BootSplash.cpp +++ b/src/UI/BootSplash.cpp @@ -18,7 +18,15 @@ // #include +#ifdef LILYGO_DEV #include +#endif + +#ifdef M5_DEV +#include +#endif + + #include // used for reset task watchdog @@ -38,7 +46,9 @@ #include "../app/LogView.hpp" // lLog shit #include "../resources.hpp" +#ifdef LILYGO_DEV extern TTGOClass *ttgo; // ttgo lib +#endif bool bootLoop = true; // this stops the animation loop bool bootLoopEnds = false; // this is used by the splash to know bootLoop is ended @@ -148,7 +158,7 @@ void SleepFanfare() { //lLog("FANFARE TIME: %d\n",millis()-begin); } #endif - +/* void SplashMeanWhile(void *data) { // task to do boot animation bootLoop=true; lUILog("Splash loop begin\n"); @@ -189,7 +199,7 @@ void SplashMeanWhile(void *data) { // task to do boot animation bootLoopEnds=true; vTaskDelete(NULL); } - +*/ void SplashBootMode(const char *what) { tft->setTextColor(ThCol(boot_splash_foreground),ThCol(boot_splash_background)); tft->setTextDatum(TL_DATUM); @@ -204,8 +214,12 @@ void SplashAnnounce(const char * what) { void SplashAnnounce() { bootLoop=true; - - ttgo->setBrightness(0); // low brightness + #ifdef LILYGO_DEV + ttgo->setBrightness(0); // low brightness + #elif M5_DEV + tft->setBrightness(0); + #endif + tft->fillScreen(ThCol(boot_splash_background)); // coords from gimp :) manual stetic-centered same as the group logo on telegram https://t.me/lunowatch!!! come with us if you read this!!! :) tft->drawXBitmap(52,73,img_lunokiot_logo_bits, img_lunokiot_logo_width,img_lunokiot_logo_height, ThCol(boot_splash_foreground)); @@ -227,13 +241,22 @@ void SplashAnnounce() { tft->drawString(buildNumberAsString, posX, posY); #endif - ttgo->setBrightness(0); - ttgo->openBL(); // turn on the lights! - for(int i=0;i<255;i++) { - ttgo->setBrightness(i); - delay(5); - } - ttgo->setBrightness(BaseBackLightBrightness); // default brightness + #ifdef LILYGO_DEV + ttgo->setBrightness(0); + ttgo->openBL(); // turn on the lights! + for(int i=0;i<255;i++) { + ttgo->setBrightness(i); + delay(5); + } + ttgo->setBrightness(BaseBackLightBrightness); // default brightness + #elif M5_DEV + tft->setBrightness(0); + for(int i=0;i<255;i++) { + tft->setBrightness(i); + delay(5); + } + tft->setBrightness(BaseBackLightBrightness); // default brightness + #endif } @@ -255,6 +278,10 @@ void SplashAnnounceBegin() { // user eyecandy bright++; delay(1000/255); if ( bright > 255 ) { break; } - ttgo->setBrightness(bright); + #ifdef LILYGO_DEV + ttgo->setBrightness(bright); // low brightness + #elif M5_DEV + tft->setBrightness(bright); + #endif } } diff --git a/src/UI/UI.cpp b/src/UI/UI.cpp index 27bc57f..8795e82 100644 --- a/src/UI/UI.cpp +++ b/src/UI/UI.cpp @@ -17,8 +17,13 @@ // LunokWatch. If not, see . // - +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif + +//#include #include #include #include @@ -52,8 +57,14 @@ extern SoftwareKeyboard *keyboardInstance; +#ifdef LILYGO_DEV extern TTGOClass *ttgo; // ttgo library shit ;) extern TFT_eSPI * tft; +#elif defined(M5_DEV) +//extern TTGOClass *ttgo; // ttgo library shit ;) +extern M5Display * tft; +#endif + bool UIlongTap=false; // used to trigger only once the long tap event bool UILongTapOverride=false; // disable long tap to task switcher feature extern const PROGMEM uint8_t screenshoot_sound_start[] asm("_binary_asset_screenshoot_sound_mp3_start"); @@ -108,7 +119,11 @@ void SetUserBrightness() { userBright=BaseBackLightBrightness; NVS.setInt("lBright",userBright,false); } +#ifdef LILYGO_DEV if ( ttgo->bl->isOn() ) { ttgo->setBrightness(userBright); } +#elif defined(M5_DEV) + tft->setBrightness(userBright); +#endif } void ScreenWake() { @@ -118,6 +133,7 @@ void ScreenWake() { lEvLog("Unable to obtain the Screen Lock!\n"); return; } + #ifdef LILYGO_DEV if ( false == ttgo->bl->isOn() ) { LoT().CpuSpeed(240); if ( ttgo->rtc->isValid() ) { ttgo->rtc->syncToSystem(); } @@ -130,9 +146,10 @@ void ScreenWake() { //SystemEventBootEnd(); // perform a ready (and if all is ok, launch watchface) ttgo->bl->on(); //tft->fillScreen(TFT_BLACK); // cleanup, better than show old watchface time! (missinformation) - esp_event_post_to(uiEventloopHandle, UI_EVENTS, UI_EVENT_CONTINUE,nullptr, 0, LUNOKIOT_EVENT_IMPORTANT_TIME_TICKS); - FPS = MAXFPS; } + #endif + esp_event_post_to(uiEventloopHandle, UI_EVENTS, UI_EVENT_CONTINUE,nullptr, 0, LUNOKIOT_EVENT_IMPORTANT_TIME_TICKS); + FPS = MAXFPS; xSemaphoreGive(UISemaphore); } @@ -142,15 +159,19 @@ void ScreenSleep() { lEvLog("Unable to obtain the Screen Lock!\n"); return; } + #ifdef LILYGO_DEV if ( true == ttgo->bl->isOn() ) { ttgo->bl->off(); lUILog("Put screen to sleep now\n"); ttgo->displaySleep(); delay(1); ttgo->touchToSleep(); + #endif esp_event_post_to(uiEventloopHandle, UI_EVENTS, UI_EVENT_STOP,nullptr, 0, LUNOKIOT_EVENT_MANDATORY_TIME_TICKS); LoT().CpuSpeed(80); + #ifdef LILYGO_DEV } + #endif xSemaphoreGive(UISemaphore); } @@ -355,6 +376,14 @@ TFT_eSprite * ScaleSprite(TFT_eSprite *view, float divisor) { return canvas; } +uint16_t Get16BitFromRGB(uint32_t color888) { + uint16_t r = (color888 >> 8) & 0xF800; + uint16_t g = (color888 >> 5) & 0x07E0; + uint16_t b = (color888 >> 3) & 0x001F; + + return (r | g | b); +} + void GetRGBFrom16Bit(const uint16_t color, uint8_t &r, uint8_t &g, uint8_t &b) { double pr = ((color >> 11) & 0x1F) / 31.0; // red 0.0 .. 1.0 double pg = ((color >> 5) & 0x3F) / 63.0; // green 0.0 .. 1.0 @@ -563,7 +592,14 @@ static void UIEventScreenRefresh(void* handler_args, esp_event_base_t base, int3 int16_t newTouchX,newTouchY; bool newTouch=false; if( xSemaphoreTake( I2cMutex, LUNOKIOT_UI_SHORT_WAIT) == pdFALSE ) { return; } - newTouch = ttgo->getTouch(newTouchX,newTouchY); + #ifdef LILYGO_DEV + newTouch = ttgo->getTouch(newTouchX,newTouchY); + #elif defined(M5_DEV) + Point currPt = M5.Touch.getPressPoint(); + newTouch = currPt.valid(); + newTouchX = currPt.x; + newTouchY = currPt.y; + #endif xSemaphoreGive( I2cMutex ); bool updateCoords=true; if ( ( !oldTouchState ) && ( newTouch ) ) { // thumb in @@ -707,11 +743,15 @@ static void UIEventScreenTimeout(void* handler_args, esp_event_base_t base, int3 if ( UINextTimeout > millis() ) { return; } // get a nap! +#ifdef LILYGO_DEV if ( ttgo->bl->isOn() ) { +#endif ScreenSleep(); esp_event_post_to(systemEventloopHandler, SYSTEM_EVENTS, SYSTEM_EVENT_STOP, nullptr, 0, LUNOKIOT_EVENT_MANDATORY_TIME_TICKS); DoSleep(); +#ifdef LILYGO_DEV } +#endif } static void UIReadyEvent(void* handler_args, esp_event_base_t base, int32_t id, void* event_data) { @@ -728,7 +768,9 @@ static void UITickTask(void* args) { if ( false == UIRunning ) { continue; } if ( systemSleep ) { continue; } +#ifdef LILYGO_DEV if ( false == ttgo->bl->isOn() ) { continue; } // do not send UI tick when screen is off +#endif esp_err_t what = esp_event_post_to(uiEventloopHandle, UI_EVENTS, UI_EVENT_TICK, nullptr, 0, LUNOKIOT_EVENT_DONTCARE_TIME_TICKS); // Dynamic FPS... the apps receives less events per second if (( ESP_OK != what )||( isDelayed )) { diff --git a/src/UI/UI.hpp b/src/UI/UI.hpp index 3af358e..ccb92af 100644 --- a/src/UI/UI.hpp +++ b/src/UI/UI.hpp @@ -21,7 +21,18 @@ #define __LUNOKIOT__UI__DEFINE__ #include + +#ifdef LILYGO_DEV #include +extern TFT_eSPI * tft; +#endif + +#ifdef M5_DEV +#include +extern M5Display * tft; +#endif + + #include #include // callbacks @@ -33,7 +44,6 @@ typedef std::function UICallback; // repeated declaration typedef std::function UICallback2; typedef std::function UICallback3; -extern TFT_eSPI * tft; //extern TTGOClass *ttgo; // ttgo lib //#include "../system/Application.hpp" // caller contains the object (must be converted) @@ -95,11 +105,17 @@ extern const TemplateColorPalette * currentColorPalette; extern const TemplateThemeScheme * currentThemeScheme; // color utilities +uint16_t Get16BitFromRGB(uint32_t color888); void GetRGBFrom16Bit(const uint16_t color, uint8_t &r, uint8_t &g, uint8_t &b); uint16_t ColorSwap(uint16_t colorToSwap); uint16_t ByteSwap(uint16_t colorToSwap); -#define ThCol(WHAT) tft->color24to16(currentThemeScheme->WHAT) +#ifdef LILYGO_DEV +#define ThCol(WHAT) Get16BitFromRGB(currentThemeScheme->WHAT) +#else +#define ThCol(WHAT) currentThemeScheme->WHAT +#endif + extern uint8_t pendingNotifications; diff --git a/src/UI/base/Widget.hpp b/src/UI/base/Widget.hpp index c46c2c7..60cab74 100644 --- a/src/UI/base/Widget.hpp +++ b/src/UI/base/Widget.hpp @@ -20,8 +20,13 @@ #ifndef __LUNOKIOT__WIDGET__BASE__ #define __LUNOKIOT__WIDGET__BASE__ -#include +#include +#ifdef LILYGO_DEV +#include +#elif defined(M5_DEV) +#include +#endif // https://github.com/Bodmer/TFT_eSPI/blob/master/examples/Sprite/Orrery/Orrery.ino class Drawable { public: diff --git a/src/UI/controls/Buffer.hpp b/src/UI/controls/Buffer.hpp index eec045b..a69b6a0 100644 --- a/src/UI/controls/Buffer.hpp +++ b/src/UI/controls/Buffer.hpp @@ -22,7 +22,13 @@ #include "../../lunokIoT.hpp" #include "base/Control.hpp" + +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif + #include "base/Control.hpp" #include "base/Container.hpp" diff --git a/src/UI/controls/Button.cpp b/src/UI/controls/Button.cpp index 2fe0cb6..de14b96 100644 --- a/src/UI/controls/Button.cpp +++ b/src/UI/controls/Button.cpp @@ -24,9 +24,9 @@ #include "Button.hpp" #include "../../app/LogView.hpp" #include "../UI.hpp" -using namespace LuI; +//using namespace LuI; -void Button::Refresh(bool direct) { +void LuI::Button::Refresh(bool direct) { lLog("Button %p refresh canvas dirty: %s direct: %s\n",this,(dirty?"true":"false"),(direct?"true":"false")); // I'm not dirty, but called refresh, send the refresh to children trying to resolve if ( false == dirty ) { @@ -76,12 +76,12 @@ void Button::Refresh(bool direct) { Container::Refresh(direct); } -Button::Button(LuI_Layout layout, size_t childs,bool decorations,uint16_t color): Container(layout,childs),decorations(decorations),color(color) { +LuI::Button::Button(LuI_Layout layout, size_t childs,bool decorations,uint16_t color): Container(layout,childs),decorations(decorations),color(color) { // a little stylished borders if decorations are enabled if ( decorations ) { border=5; } } -void Button::EventHandler() { +void LuI::Button::EventHandler() { // I'm a button, react about events (tapCallback mostly) Control::EventHandler(); // Butt... I'm also a container, 'share the word' x'D with children :) diff --git a/src/UI/controls/Check.hpp b/src/UI/controls/Check.hpp index ce7b203..1f5a4d8 100644 --- a/src/UI/controls/Check.hpp +++ b/src/UI/controls/Check.hpp @@ -22,7 +22,7 @@ #include "../../lunokIoT.hpp" #include "base/Control.hpp" -#include +//#include namespace LuI { class Check: public Control { diff --git a/src/UI/controls/Draw.hpp b/src/UI/controls/Draw.hpp index 6e6780e..1fb9d26 100644 --- a/src/UI/controls/Draw.hpp +++ b/src/UI/controls/Draw.hpp @@ -22,7 +22,11 @@ #include "../../lunokIoT.hpp" #include "base/Control.hpp" +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif #include "base/Control.hpp" namespace LuI { diff --git a/src/UI/controls/IconMenu.hpp b/src/UI/controls/IconMenu.hpp index a1b611a..f695a53 100644 --- a/src/UI/controls/IconMenu.hpp +++ b/src/UI/controls/IconMenu.hpp @@ -22,7 +22,13 @@ #include "../../lunokIoT.hpp" #include "base/Control.hpp" + +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif + #include "base/Control.hpp" #include "base/Container.hpp" diff --git a/src/UI/controls/Image.hpp b/src/UI/controls/Image.hpp index a224316..a8e21f0 100644 --- a/src/UI/controls/Image.hpp +++ b/src/UI/controls/Image.hpp @@ -22,7 +22,11 @@ #include "../../lunokIoT.hpp" #include "base/Control.hpp" +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif #include "base/Container.hpp" namespace LuI { diff --git a/src/UI/controls/Paginator.hpp b/src/UI/controls/Paginator.hpp index bc00c5e..576e228 100644 --- a/src/UI/controls/Paginator.hpp +++ b/src/UI/controls/Paginator.hpp @@ -22,7 +22,7 @@ #include "../../lunokIoT.hpp" #include "base/Control.hpp" -#include + #include "../../app/LogView.hpp" namespace LuI { diff --git a/src/UI/controls/Text.hpp b/src/UI/controls/Text.hpp index cbb6cf4..06759ca 100644 --- a/src/UI/controls/Text.hpp +++ b/src/UI/controls/Text.hpp @@ -22,7 +22,12 @@ #include "../../lunokIoT.hpp" #include "base/Control.hpp" +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif + namespace LuI { diff --git a/src/UI/controls/View3D/Common.hpp b/src/UI/controls/View3D/Common.hpp index 2600ef0..777d659 100644 --- a/src/UI/controls/View3D/Common.hpp +++ b/src/UI/controls/View3D/Common.hpp @@ -20,7 +20,11 @@ #ifndef __LUNOKIOT__MESH_DEFINES___ #define __LUNOKIOT__MESH_DEFINES___ #include +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif namespace LuI { #define ENGINE_INVALID_VALUE -666 diff --git a/src/UI/controls/View3D/View3D.cpp b/src/UI/controls/View3D/View3D.cpp index 8e131bc..99f1823 100644 --- a/src/UI/controls/View3D/View3D.cpp +++ b/src/UI/controls/View3D/View3D.cpp @@ -420,7 +420,7 @@ void View3D::Render() { for(int i=0;ibilboard ) { continue; } - if ( RENDER::NODRAW == RenderMode ) { continue; } + if ( RENDER::nodraw == RenderMode ) { continue; } int32_t tp0x = meshOrderedFaces[i].p0x; int32_t tp0y = meshOrderedFaces[i].p0y; @@ -455,7 +455,7 @@ void View3D::Render() { canvas->drawTriangle(tp0x,tp0y,tp1x,tp1y,tp2x,tp2y,MaskColor); } else if ( RENDER::MASK == RenderMode ) { canvas->fillTriangle(tp0x,tp0y,tp1x,tp1y,tp2x,tp2y,MaskColor); - } // else NODRAW + } // else nodraw if ( nullptr != polygonCallback ) { (polygonCallback)(polygonCallbackParam,canvas,&meshOrderedFaces[i]); } } DrawBilboards(); diff --git a/src/UI/controls/View3D/View3D.hpp b/src/UI/controls/View3D/View3D.hpp index 3d0a2a7..f3bf1a5 100644 --- a/src/UI/controls/View3D/View3D.hpp +++ b/src/UI/controls/View3D/View3D.hpp @@ -42,7 +42,7 @@ namespace LuI { //void ThreadedRender(); //bool renderLoop=true; uint16_t MaskColor=TFT_WHITE; - typedef enum { FULL = 0, FLAT, WIREFRAME, FLATWIREFRAME, MASK, NODRAW} RENDER; + typedef enum { FULL = 0, FLAT, WIREFRAME, FLATWIREFRAME, MASK, nodraw } RENDER; RENDER RenderMode = FULL; void SetBackgroundColor(uint16_t color) { viewBackgroundColor=color; } OrderedFace3D * meshOrderedFaces= { nullptr }; diff --git a/src/UI/controls/XBM.hpp b/src/UI/controls/XBM.hpp index 116c581..3a17639 100644 --- a/src/UI/controls/XBM.hpp +++ b/src/UI/controls/XBM.hpp @@ -22,7 +22,6 @@ #include "../../lunokIoT.hpp" #include "base/Control.hpp" -#include namespace LuI { diff --git a/src/UI/controls/base/Control.cpp b/src/UI/controls/base/Control.cpp index bb80fa6..b666e39 100644 --- a/src/UI/controls/base/Control.cpp +++ b/src/UI/controls/base/Control.cpp @@ -35,7 +35,8 @@ bool Control::Attach(INOUT Control *control) { Control::~Control() { lUILog("Control %p destroyed!\n",this); if ( nullptr != canvas ) { - if ( canvas->created() ) { canvas->deleteSprite(); } + //if ( canvas->created() ) { canvas->deleteSprite(); } + canvas->deleteSprite(); delete canvas; canvas=nullptr; } @@ -134,7 +135,9 @@ void Control::EventHandler() { void Control::Rebuild() { lUILog("Control %p Rebuild (w:%u h:%u)\n",this,width,height); if ( nullptr != canvas ) { - if ( canvas->created() ) { canvas->deleteSprite(); } + //@TODO M5 TFT_eSPI don't have ->created() + //if ( canvas->created() ) { canvas->deleteSprite(); } + canvas->deleteSprite(); delete canvas; } // create new with current size diff --git a/src/UI/controls/base/Control.hpp b/src/UI/controls/base/Control.hpp index fe8111c..6f2f4fd 100644 --- a/src/UI/controls/base/Control.hpp +++ b/src/UI/controls/base/Control.hpp @@ -21,10 +21,17 @@ #define __LUNOKIOT__CONTROL_BASE_CLASS__ #include "../../../lunokIoT.hpp" -#include -//#include -#include "../../UI.hpp" + +#ifdef LILYGO_DEV +#include extern TFT_eSPI * tft; +#elif defined(M5_DEV) +#include +extern M5Display * tft; +#endif + +#include "../../UI.hpp" + namespace LuI { // defines root of any screen element diff --git a/src/UI/transition/Displace.hpp b/src/UI/transition/Displace.hpp index cc06db1..cf4b53b 100644 --- a/src/UI/transition/Displace.hpp +++ b/src/UI/transition/Displace.hpp @@ -19,7 +19,11 @@ #ifndef __LUNOKIOT__ANIMATION__DISPLACE__ #define __LUNOKIOT__ANIMATION__DISPLACE__ +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif void DisplaceTransition(TFT_eSprite * curentView, TFT_eSprite * nextView); diff --git a/src/UI/transition/Fade.hpp b/src/UI/transition/Fade.hpp index f960521..9a9df0d 100644 --- a/src/UI/transition/Fade.hpp +++ b/src/UI/transition/Fade.hpp @@ -19,7 +19,11 @@ #ifndef __LUNOKIOT__ANIMATION__FADE__ #define __LUNOKIOT__ANIMATION__FADE__ +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif void FadeTransition(TFT_eSprite * curentView, TFT_eSprite * nextView); diff --git a/src/UI/transition/Flip.hpp b/src/UI/transition/Flip.hpp index 6d682d2..f3fb546 100644 --- a/src/UI/transition/Flip.hpp +++ b/src/UI/transition/Flip.hpp @@ -19,7 +19,12 @@ #ifndef __LUNOKIOT__ANIMATION__FLIP__ #define __LUNOKIOT__ANIMATION__FLIP__ + +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif void FlipTransition(TFT_eSprite * curentView, TFT_eSprite * nextView); diff --git a/src/UI/transition/Stripes.hpp b/src/UI/transition/Stripes.hpp index 3ead183..e703271 100644 --- a/src/UI/transition/Stripes.hpp +++ b/src/UI/transition/Stripes.hpp @@ -19,7 +19,12 @@ #ifndef __LUNOKIOT__ANIMATION__STRIPE__ #define __LUNOKIOT__ANIMATION__STRIPE__ + +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif void StripeTransition(TFT_eSprite * curentView, TFT_eSprite * nextView); diff --git a/src/UI/transition/UpDown.hpp b/src/UI/transition/UpDown.hpp index 159425b..85bb970 100644 --- a/src/UI/transition/UpDown.hpp +++ b/src/UI/transition/UpDown.hpp @@ -19,7 +19,12 @@ #ifndef __LUNOKIOT__ANIMATION__UPDOWN__ #define __LUNOKIOT__ANIMATION__UPDOWN__ + +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif void UpDownTransition(TFT_eSprite * curentView, TFT_eSprite * nextView); diff --git a/src/UI/transition/ZoomOut.hpp b/src/UI/transition/ZoomOut.hpp index 77fca66..7bd4c50 100644 --- a/src/UI/transition/ZoomOut.hpp +++ b/src/UI/transition/ZoomOut.hpp @@ -19,7 +19,12 @@ #ifndef __LUNOKIOT__ANIMATION__ZOOMOUT__ #define __LUNOKIOT__ANIMATION__ZOOMOUT__ + +#ifdef LILYGO_DEV #include +#elif defined(M5_DEV) +#include +#endif void ZoomOutTransition(TFT_eSprite * curentView, TFT_eSprite * nextView); diff --git a/src/UI/widgets/ButtonImageXBMWidget.cpp b/src/UI/widgets/ButtonImageXBMWidget.cpp index 3be3f44..8cbaaea 100644 --- a/src/UI/widgets/ButtonImageXBMWidget.cpp +++ b/src/UI/widgets/ButtonImageXBMWidget.cpp @@ -18,8 +18,12 @@ // #include + +#ifdef LILYGO_DEV #include -#include +#elif defined(M5_DEV) +#include +#endif //#include //extern TFT_eSPI *tft; diff --git a/src/UI/widgets/ButtonTextWidget.cpp b/src/UI/widgets/ButtonTextWidget.cpp index 87da4b1..f7b1158 100644 --- a/src/UI/widgets/ButtonTextWidget.cpp +++ b/src/UI/widgets/ButtonTextWidget.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "lunokiot_config.hpp" #include "ButtonTextWidget.hpp" #include "../../app/LogView.hpp" diff --git a/src/UI/widgets/ButtonWidget.cpp b/src/UI/widgets/ButtonWidget.cpp index 9e349b8..4a565a1 100644 --- a/src/UI/widgets/ButtonWidget.cpp +++ b/src/UI/widgets/ButtonWidget.cpp @@ -18,8 +18,8 @@ // #include -#include -#include +//#include +//#include //#include #include diff --git a/src/UI/widgets/CanvasWidget.cpp b/src/UI/widgets/CanvasWidget.cpp index 13e6d05..f6d67df 100644 --- a/src/UI/widgets/CanvasWidget.cpp +++ b/src/UI/widgets/CanvasWidget.cpp @@ -18,14 +18,14 @@ // //#include -#include +//#include #include "CanvasWidget.hpp" -#include +//#include //#include #include "../../app/LogView.hpp" -extern TTGOClass *ttgo; // ttgo lib +//extern TTGOClass *ttgo; // ttgo lib CanvasWidget::CanvasWidget(int16_t h, int16_t w,int8_t colorDepth) { lUIDeepLog("%s new %p\n",__PRETTY_FUNCTION__,this); @@ -44,10 +44,12 @@ bool CanvasWidget::RebuildCanvas(int16_t h, int16_t w, int8_t colorDepth) { canvas->setColorDepth(colorDepth); this->colorDepth = colorDepth; if ( nullptr == canvas->createSprite(w,h) ) { return false; } - + + #ifdef LILYGO_DEV if ( 4 == colorDepth ) { canvas->createPalette(default_4bit_palette); } + #endif canvas->fillSprite(MASK_COLOR); // by default use transparent return true; } diff --git a/src/UI/widgets/CanvasWidget.hpp b/src/UI/widgets/CanvasWidget.hpp index 06e1f5f..1e84a4b 100644 --- a/src/UI/widgets/CanvasWidget.hpp +++ b/src/UI/widgets/CanvasWidget.hpp @@ -21,7 +21,10 @@ #define __LUNOKIOT__CANVAS__WIDGET___HEADER__ //#include //#include +#ifdef LILYGO_DEV #include +#endif + //#include #include "../base/Widget.hpp" diff --git a/src/UI/widgets/CanvasZWidget.cpp b/src/UI/widgets/CanvasZWidget.cpp index 8bf2e69..bf9965a 100644 --- a/src/UI/widgets/CanvasZWidget.cpp +++ b/src/UI/widgets/CanvasZWidget.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "CanvasZWidget.hpp" #include "../UI.hpp" #include "../../app/LogView.hpp" @@ -56,9 +56,9 @@ bool CanvasZWidget::SetScale(float z) { if ( this->z != z ) { this->z=z; if ( ( nullptr != canvas ) && ( NULL != canvas ) ) { - if ( true == canvas->created() ) { + //if ( true == canvas->created() ) { return CanvasWidget::RebuildCanvas(canvas->height(),canvas->width(), colorDepth); - } + //} } } return false; diff --git a/src/UI/widgets/CanvasZWidget.hpp b/src/UI/widgets/CanvasZWidget.hpp index 59eee95..e601aaf 100644 --- a/src/UI/widgets/CanvasZWidget.hpp +++ b/src/UI/widgets/CanvasZWidget.hpp @@ -20,10 +20,12 @@ #ifndef __LUNOKIOT__CANVAS__Z_WIDGET___HEADER__ #define __LUNOKIOT__CANVAS__Z_WIDGET___HEADER__ #include -#include +#ifdef LILYGO_DEV #include -//#include +#elif defined(M5_DEV) +#include +#endif #include "lunokiot_config.hpp" #include "CanvasWidget.hpp" diff --git a/src/UI/widgets/EntryTextWidget.cpp b/src/UI/widgets/EntryTextWidget.cpp index 0c63cf6..69bd811 100644 --- a/src/UI/widgets/EntryTextWidget.cpp +++ b/src/UI/widgets/EntryTextWidget.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "lunokiot_config.hpp" #include "EntryTextWidget.hpp" #include "ButtonTextWidget.hpp" diff --git a/src/UI/widgets/GraphWidget.cpp b/src/UI/widgets/GraphWidget.cpp index 05400ed..cb65e63 100644 --- a/src/UI/widgets/GraphWidget.cpp +++ b/src/UI/widgets/GraphWidget.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "GraphWidget.hpp" #include "../../app/LogView.hpp" diff --git a/src/UI/widgets/NotificationWidget.cpp b/src/UI/widgets/NotificationWidget.cpp index ffca2f1..e14ffd7 100644 --- a/src/UI/widgets/NotificationWidget.cpp +++ b/src/UI/widgets/NotificationWidget.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "lunokiot_config.hpp" #include "../../app/LogView.hpp" diff --git a/src/UI/widgets/NotificationWidget.hpp b/src/UI/widgets/NotificationWidget.hpp index 503fad7..b951721 100644 --- a/src/UI/widgets/NotificationWidget.hpp +++ b/src/UI/widgets/NotificationWidget.hpp @@ -21,7 +21,7 @@ #define __LUNOKIOT__UI__NOTIFICATION___ #include #include -#include +//#include #include "lunokiot_config.hpp" @@ -41,7 +41,7 @@ class NotificationWidget: public ButtonWidget { char * message=nullptr; uint32_t color=0x0; bool Interact(bool touch, int16_t tx,int16_t ty); - NotificationWidget(UICallback notifyTo, char *message, uint32_t color=tft->color24to16(0x353e45)); + NotificationWidget(UICallback notifyTo, char *message, uint32_t color=TFT_DARKGREY); //Get16BitFromRGB(0x353e45)); void DrawTo(TFT_eSprite * endCanvas); bool isRead = false; ~NotificationWidget(); diff --git a/src/UI/widgets/ScrollViewWidget.cpp b/src/UI/widgets/ScrollViewWidget.cpp index b0cc1ed..81297e2 100644 --- a/src/UI/widgets/ScrollViewWidget.cpp +++ b/src/UI/widgets/ScrollViewWidget.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "lunokiot_config.hpp" #include "ScrollViewWidget.hpp" @@ -59,7 +59,7 @@ void ScrollViewWidget::DrawTo(TFT_eSprite * endCanvas) { //uint16_t lightColor = canvas->alphaBlend(128,btnBackgroundColor,TFT_WHITE); //canvas->fillSprite(lightColor); - canvas->fillSprite(canvas->color24to16(0x555f68)); + canvas->fillSprite(TFT_DARKGREY); //Get16BitFromRGB(0x555f68)); backroundView->DrawTo(canvas,offsetX,offsetY); /* if ( borders ) { diff --git a/src/UI/widgets/ScrollViewWidget.hpp b/src/UI/widgets/ScrollViewWidget.hpp index 3ea2e2a..c512c95 100644 --- a/src/UI/widgets/ScrollViewWidget.hpp +++ b/src/UI/widgets/ScrollViewWidget.hpp @@ -21,7 +21,7 @@ #define __LUNOKIOT__UI__SCROLLVIEW___ //ScrollViewWidget.hpp #include -#include +//#include #include "lunokiot_config.hpp" #include "../activator/ActiveRect.hpp" diff --git a/src/UI/widgets/SwitchWidget.cpp b/src/UI/widgets/SwitchWidget.cpp index b5bf23e..c7e0648 100644 --- a/src/UI/widgets/SwitchWidget.cpp +++ b/src/UI/widgets/SwitchWidget.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "lunokiot_config.hpp" #include "SwitchWidget.hpp" diff --git a/src/UI/widgets/ValueSelector.cpp b/src/UI/widgets/ValueSelector.cpp index 57148e7..71247d5 100644 --- a/src/UI/widgets/ValueSelector.cpp +++ b/src/UI/widgets/ValueSelector.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "ValueSelector.hpp" #include "../../app/LogView.hpp" diff --git a/src/UI/widgets/ValueSelector.hpp b/src/UI/widgets/ValueSelector.hpp index 60368eb..2aae651 100644 --- a/src/UI/widgets/ValueSelector.hpp +++ b/src/UI/widgets/ValueSelector.hpp @@ -21,7 +21,7 @@ #define __LUNOKIOT__UI__VALUE_SELECTOR___ #include -#include +//#include #include "lunokiot_config.hpp" #include "../activator/ActiveRect.hpp" diff --git a/src/app/About.cpp b/src/app/About.cpp index dce04cd..edfa3c8 100644 --- a/src/app/About.cpp +++ b/src/app/About.cpp @@ -18,16 +18,15 @@ // #include -#include -//#include +#include "lunokIoT.hpp" #include "Settings.hpp" #include "../lunokiot_config.hpp" #include "About.hpp" #include "LogView.hpp" -extern TTGOClass *ttgo; // ttgo lib +//extern TTGOClass *ttgo; // ttgo lib const unsigned long AboutBoxTextScrollDelay = 1000/12; const unsigned long AboutBoxTextScrollDelayScroll = 1000/24; //const unsigned long @@ -365,6 +364,36 @@ bool AboutApplication::Tick() { TemplateApplication::btnBack->DirectDraw(); // Direct draw xD + // draw batt if needed (only when external supply) + //if ( false == vbusPresent ) { + if ( -1 != batteryPercent ) { + const int battWidth=25; + const int BattHeight=10; + const int BORDER=5; + #ifdef LILYGO_DEV + const uint16_t BattColor = TFT_WHITE; + const int startX=(TFT_WIDTH-BORDER)-battWidth; + tft->drawRect(startX,BORDER,battWidth,BattHeight,BattColor); // batt + tft->fillRect(startX+battWidth,BattHeight-2,3,BORDER-1,BattColor); // batt cap + //else if..... + #else + lAppLog("WARNING: DRAWRECT NOT IMPLEMENTED ON THIS ARCHITECTURE 1\n"); + // @TODO must define: + //const uint16_t BattColor = TFT_WHITE; + //const int startX=(TFT_WIDTH-BORDER)-battWidth; + #endif + int pixelBat = (batteryPercent/100.0)*battWidth; + if ( pixelBat > 0 ) { + #ifdef LILYGO_DEV + tft->fillRect(startX,5,pixelBat,10,BattColor); + tft->fillRect(startX+pixelBat+1,BORDER+1,battWidth-pixelBat,BattHeight-2,TFT_BLACK); + #else + lAppLog("@TODO WARNING: DRAWRECT NOT IMPLEMENTED ON THIS ARCHITECTURE 2\n"); + #endif + } + } + //} + //TransformationMatrix imgTransf = { 0.46, 0.18, 0.06, 0.95 }; //TFT_eSprite * transformedCopy = ShearSprite(perspectiveTextBuffer->canvas,imgTransf); perspectiveTextBuffer->canvas->pushSprite( diff --git a/src/app/About.hpp b/src/app/About.hpp index f23db29..2d1442d 100644 --- a/src/app/About.hpp +++ b/src/app/About.hpp @@ -21,7 +21,7 @@ #define __LUNOKIOT__ABOUT_APP__ #include -//#include + #include "../UI/AppTemplate.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/Activities.cpp b/src/app/Activities.cpp index 352aec1..43c9eb2 100644 --- a/src/app/Activities.cpp +++ b/src/app/Activities.cpp @@ -20,7 +20,6 @@ //#include #include -#include #include "../lunokiot_config.hpp" #include "Activities.hpp" diff --git a/src/app/ActivityRecorder.cpp b/src/app/ActivityRecorder.cpp deleted file mode 100644 index 8a2e348..0000000 --- a/src/app/ActivityRecorder.cpp +++ /dev/null @@ -1,352 +0,0 @@ -// -// LunokWatch, a open source smartwatch software -// Copyright (C) 2022,2023 Jordi Rubió -// This file is part of LunokWatch. -// -// LunokWatch is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// LunokWatch is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// LunokWatch. If not, see . -// - -#include -#include -#include "lunokiot_config.hpp" -#include "ActivityRecorder.hpp" - -#include "../static/img_record_48.xbm" -#include "../static/img_stop_48.xbm" -#include "../static/img_save_48.xbm" -#include "../static/img_search_48.xbm" - -ActivityRecorderApplication::ActivityRecorderApplication() : LunokIoTApplication() { - uint32_t wcolor = canvas->color24to16(0x27273d); - uint32_t mcolor = canvas->color24to16(0x3b3b5b); - - accXGraph = new GraphWidget(24,79,0,360,TFT_RED,mcolor); - accYGraph = new GraphWidget(24,79,0,360,TFT_GREEN,mcolor); - accZGraph = new GraphWidget(24,79,0,360,TFT_BLUE,mcolor); - - playbackGraph = new GraphWidget(62,180,0,36,canvas->color24to16(0x4c70a4)); - - btnStop = new ButtonImageXBMWidget(5,240-73,68,68,[&, this](void *bah) { - Serial.println("ActivityRecorder: Event: User wants stop!"); - recordOffset = recordEntries-1; // this cause end of recording - },img_stop_48_bits,img_stop_48_width,img_stop_48_height,TFT_WHITE,wcolor); - btnStop->enabled = false; - - btnRecord = new ButtonImageXBMWidget(5,240-73,68,68,[&, this](void *bah) { - Serial.println("ActivityRecorder: Begin activity recording..."); - this->btnRecord->enabled = false; - this->btnStop->enabled = true; - this->btnSave->enabled = false; - this->btnMatch->enabled = false; - - countdownOffset=0; - //playbackGraph->graph->canvas->fillSprite(CanvasWidget::MASK_COLOR); - - if ( nullptr != recordX ) { - free(recordX); - recordX = nullptr; - } - if ( nullptr != recordY ) { - free(recordY); - recordY = nullptr; - } - if ( nullptr != recordZ ) { - free(recordZ); - recordZ = nullptr; - } - Serial.printf("Allocating: %d bytes\n",(sizeof(float)*recordEntries)*3); - recordX = (float*)ps_calloc(recordEntries,sizeof(float)); - recordY = (float*)ps_calloc(recordEntries,sizeof(float)); - recordZ = (float*)ps_calloc(recordEntries,sizeof(float)); - recordData->canvas->fillSprite(TFT_BLACK); - - recordingTime = millis(); - this->recording = true; - this->recordOffset=0; - },img_record_48_bits,img_record_48_width,img_record_48_height,TFT_WHITE, TFT_RED); - - btnSave = new ButtonImageXBMWidget(78,240-73,68,68,[&, this](void *bah) { - this->btnSave->enabled = false; - - if ( ( nullptr == recordX ) || ( nullptr == recordY ) || ( nullptr == recordZ ) ) { - Serial.println("ActivityRecorder: Nothing to save! abort"); - return; - } - Serial.println("ActivityRecorder: Save wave"); - if ( nullptr != recordX ) { - if ( nullptr != historyRecordsX[historyRecordsOffset] ) { - free(historyRecordsX[historyRecordsOffset]); - Serial.printf("ActivityRecorder: Freed old slot X at %d\n",historyRecordsOffset); - historyRecordsX[historyRecordsOffset] = nullptr; - } - historyRecordsX[historyRecordsOffset] = recordX; - recordX = nullptr; - } - if ( nullptr != recordY ) { - if ( nullptr != historyRecordsY[historyRecordsOffset] ) { - free(historyRecordsY[historyRecordsOffset]); - Serial.printf("ActivityRecorder: Freed old slot Y at %d\n",historyRecordsOffset); - historyRecordsY[historyRecordsOffset] = nullptr; - } - historyRecordsY[historyRecordsOffset] = recordY; - recordY = nullptr; - } - if ( nullptr != recordZ ) { - if ( nullptr != historyRecordsZ[historyRecordsOffset] ) { - free(historyRecordsZ[historyRecordsOffset]); - Serial.printf("ActivityRecorder: Freed old slot Z at %d\n",historyRecordsOffset); - historyRecordsZ[historyRecordsOffset] = nullptr; - } - historyRecordsZ[historyRecordsOffset] = recordZ; - recordZ = nullptr; - } - historyRecordsLenght[historyRecordsOffset] = lastRecordOffset; - Serial.printf("ActivityRecorder: Saved at slot %d (lenght %d)\n",historyRecordsOffset, lastRecordOffset-1); - historyRecordsOffset++; - if (historyRecordsOffset > (historyRecordMAX-1) ) { historyRecordsOffset = 0; } - this->btnMatch->enabled = true; - - },img_save_48_bits,img_save_48_width,img_save_48_height,TFT_WHITE, canvas->color24to16(0x2e2e48)); - btnSave->enabled = false; - - btnMatch = new ButtonImageXBMWidget(78+68+5,240-73,68,68,[&, this](void *bah) { - Serial.println("Building match stream..."); - // * iterate last record - size_t lasthistoryRecordsOffset=historyRecordsOffset-1; - if ( -1 == lasthistoryRecordsOffset ) { lasthistoryRecordsOffset = historyRecordMAX-1; } - Serial.printf("lasthistoryRecordsOffset: %d\n", lasthistoryRecordsOffset); - // * use threshold to simplify the data - int32_t lrX=0; - int32_t lrY=0; - int32_t lrZ=0; - size_t validEntries=0; - - if ( nullptr != matchX[currentMatchOffset] ) { - free(matchX[currentMatchOffset]); - matchX[currentMatchOffset] = nullptr; - Serial.println("Freed X"); - } - matchX[currentMatchOffset] = (int8_t*)ps_calloc(recordEntries,sizeof(uint8_t)); - if ( nullptr != matchY[currentMatchOffset] ) { - free(matchY[currentMatchOffset]); - matchY[currentMatchOffset] = nullptr; - Serial.println("Freed Y"); - } - matchY[currentMatchOffset] = (int8_t*)ps_calloc(recordEntries,sizeof(uint8_t)); - if ( nullptr != matchZ[currentMatchOffset] ) { - free(matchZ[currentMatchOffset]); - matchZ[currentMatchOffset] = nullptr; - Serial.println("Freed Z"); - } - matchZ[currentMatchOffset] = (int8_t*)ps_calloc(recordEntries,sizeof(uint8_t)); - - for (size_t offset = 0; offset < historyRecordsLenght[lasthistoryRecordsOffset]; offset++) { - int32_t rX = historyRecordsX[lasthistoryRecordsOffset][offset]; - int32_t rY = historyRecordsY[lasthistoryRecordsOffset][offset]; - int32_t rZ = historyRecordsZ[lasthistoryRecordsOffset][offset]; - rX /=threshold; - rY /=threshold; - rZ /=threshold; - // discard repeated values - if ( ( rX != lrX ) || ( rY != lrY ) || ( rZ != lrZ ) ) { - if ( offset > 0 ) { // the first value raise from 0, isn't valid - int8_t rfX = lrX-rX; - int8_t rfY = lrY-rY; - int8_t rfZ = lrZ-rZ; - Serial.printf("OFFSET: %d:%d X: %d Y: %d Z: %d\n", currentMatchOffset, offset, rfX, rfY, rfZ); - playbackGraph->PushValue((rX+rY+rZ)/3); - matchX[currentMatchOffset][validEntries] = rfX; - matchY[currentMatchOffset][validEntries] = rfY; - matchZ[currentMatchOffset][validEntries] = rfZ; - validEntries++; - } - } - lrX=rX; - lrY=rY; - lrZ=rZ; - //playbackGraph->PushValue(((lrX+lrY+lrZ)/3)*10); - } - matchLenght[currentMatchOffset] = validEntries; - Serial.printf("Entries from this match: %d\n", validEntries); - currentMatchOffset++; - if ( currentMatchOffset > historyRecordMAX-1) { - currentMatchOffset = 0; - } - btnMatch->enabled=false; - //historyRecordsLenght[lasthistoryRecordsOffset] - // playbackGraph - - - },img_search_48_bits,img_search_48_width,img_search_48_height,TFT_WHITE, canvas->color24to16(0x2e2e48)); - btnMatch->enabled = false; - - progressBar = new CanvasWidget(14,200); - recordData = new CanvasWidget(64,64); - recordData->canvas->fillSprite(TFT_BLACK); -} - -bool ActivityRecorderApplication::Tick() { - - accXGraph->PushValue(degX); - accYGraph->PushValue(degY); - accZGraph->PushValue(degZ); - - btnRecord->Interact(touched, touchX, touchY); - btnStop->Interact(touched, touchX, touchY); - btnSave->Interact(touched, touchX, touchY); - btnMatch->Interact(touched, touchX, touchY); - - - int8_t simplifiedX = degX/threshold; - int8_t simplifiedY = degY/threshold; - int8_t simplifiedZ = degZ/threshold; - static int8_t lastSimplifiedX = simplifiedX; - static int8_t lastSimplifiedY = simplifiedY; - static int8_t lastSimplifiedZ = simplifiedZ; - - if ( ( lastSimplifiedX != simplifiedX ) || ( lastSimplifiedY != simplifiedY ) || ( lastSimplifiedZ != simplifiedZ ) ) { - int8_t cmatchX = lastSimplifiedX-simplifiedX; - int8_t cmatchY = lastSimplifiedY-simplifiedY; - int8_t cmatchZ = lastSimplifiedZ-simplifiedZ; - //Serial.printf("Movement detected X: %d Y: %d Z: %d\n", cmatchX, cmatchY, cmatchZ); - static unsigned long sampleTime = 0; - if ( sampleTime < millis() ) { - Serial.printf("Resample, last activity: %d\n", visualPatternOffset); - for ( size_t off=0;off 0 ) { - for (size_t pos=0;pos 0 ) { - Serial.printf("%d(%d), ", off, matchPoints[off]); - if ( matchPoints[off] > mostPoints ) { - mostPoints = matchPoints[off]; - moreMatched = off; - } - } - } - Serial.println(""); - - visualPatternPos = 0; - visualPatternOffset = moreMatched; - - //Serial.println(""); - lastSimplifiedX = simplifiedX; - lastSimplifiedY = simplifiedY; - lastSimplifiedZ = simplifiedZ; - } - - - static unsigned long nextFullRedraw = 0; - if ( millis() > nextFullRedraw ) { - - canvas->fillSprite(canvas->color24to16(0x191927)); - - accXGraph->DrawTo(canvas,0,0); - accYGraph->DrawTo(canvas,80,0); - accZGraph->DrawTo(canvas,160,0); - - playbackGraph->DrawTo(canvas); - - progressBar->canvas->fillSprite(CanvasWidget::MASK_COLOR); - int32_t calcFull = (recordOffset * progressBar->canvas->width()) /recordEntries; - progressBar->canvas->fillRoundRect(0,0,progressBar->canvas->width(),progressBar->canvas->height(),6,TFT_BLACK); - progressBar->canvas->fillRoundRect(0,0,calcFull,progressBar->canvas->height(),6,TFT_ORANGE); - progressBar->DrawTo(canvas,20,142); - - if ( recording ) { - btnStop->DrawTo(canvas); - } else { - btnRecord->DrawTo(canvas); - } - btnSave->DrawTo(canvas); - btnMatch->DrawTo(canvas); - - canvas->setFreeFont(&FreeMonoBold18pt7b); - canvas->setTextSize(1); - canvas->setTextDatum(TL_DATUM); - canvas->setTextWrap(false,false); - canvas->setTextColor(TFT_WHITE); - char textBuff[64] = { 0 }; - //sprintf(textBuff,"Match: %d:%d", visualPatternOffset, visualPatternPos ); - sprintf(textBuff,"Match: %d", visualPatternOffset ); - canvas->drawString(textBuff, 0,100); - - - nextFullRedraw = millis()+(1000/4); - return true; - } - - if ( recording ) { - UINextTimeout = millis()+UITimeout; // disable screen timeout during recording - - recordX[recordOffset] = degX; - recordY[recordOffset] = degY; - recordZ[recordOffset] = degZ; - /* - float med = (recordX[recordOffset]+recordY[recordOffset]+recordZ[recordOffset])/3; - playbackGraph->PushValue(med); - */ - recordOffset++; - //Serial.printf("Offset: %lu\n",recordOffset); - if ( recordOffset >= recordEntries ) { - Serial.printf("Recorded time: %lu secs\n", (millis()-recordingTime)/1000); - this->recording = false; - this->btnRecord->enabled = true; - this->btnStop->enabled = false; - this->btnSave->enabled = true; - //this->accXGraph->graph->canvas->fillSprite(this->accXGraph->backgroundColor); - //this->accYGraph->graph->canvas->fillSprite(this->accYGraph->backgroundColor); - //this->accZGraph->graph->canvas->fillSprite(this->accZGraph->backgroundColor); - recordOffset = 0; - Serial.println("ActivityRecorder: End activity recording."); - //commented by new graphwidget playbackGraph->graph->canvas->fillSprite(CanvasWidget::MASK_COLOR); - //playbackGraphMed->graph->canvas->fillSprite(CanvasWidget::MASK_COLOR); - //countdownOffset = lastRecordOffset; - } else { - lastRecordOffset = recordOffset; - } - return true; - } - /* DataImage - if ( recording ) { - int16_t mapY = recordOffset / recordData->canvas->width(); - int16_t mapX = recordOffset % recordData->canvas->width(); - //Serial.printf("mapX: %d mapY: %d\n",mapX,mapY); - uint32_t dataPacked = canvas->color565(recordX[recordOffset],recordY[recordOffset],recordZ[recordOffset]); - recordData->canvas->drawPixel(mapX,mapY,dataPacked); - } - */ - return false; -} diff --git a/src/app/ActivityRecorder.hpp b/src/app/ActivityRecorder.hpp deleted file mode 100644 index eb57c31..0000000 --- a/src/app/ActivityRecorder.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// -// LunokWatch, a open source smartwatch software -// Copyright (C) 2022,2023 Jordi Rubió -// This file is part of LunokWatch. -// -// LunokWatch is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// LunokWatch is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// LunokWatch. If not, see . -// - -#ifndef __LUNOKIOT__ACTIVITY_RECORDER_APP__ -#define __LUNOKIOT__ACTIVITY_RECORDER_APP__ -#include -#include -#include "lunokiot_config.hpp" -#include "../system/Application.hpp" -#include "../UI/widgets/CanvasWidget.hpp" -#include "../UI/widgets/ButtonWidget.hpp" -#include "../UI/widgets/ButtonImageXBMWidget.hpp" -#include "../UI/widgets/NotificationWidget.hpp" -#include "../UI/widgets/SwitchWidget.hpp" -//#include "../UI/representation/Point2D.hpp" -#include "../UI/widgets/GraphWidget.hpp" -#include "../UI/widgets/GaugeWidget.hpp" - -class ActivityRecorderApplication: public LunokIoTApplication { - public: - const char *AppName() override { return "Activity recorder"; }; - GraphWidget * accXGraph = nullptr; - GraphWidget * accYGraph = nullptr; - GraphWidget * accZGraph = nullptr; - - GraphWidget * playbackGraph = nullptr; - //GraphWidget * playbackGraphMed = nullptr; - - ButtonImageXBMWidget * btnRecord = nullptr; - ButtonImageXBMWidget * btnStop = nullptr; - - ButtonImageXBMWidget * btnSave = nullptr; - ButtonImageXBMWidget * btnMatch = nullptr; - - CanvasWidget * progressBar = nullptr; - CanvasWidget * recordData = nullptr; - bool recording = false; - unsigned long recordingTime = 0; - size_t recordOffset = 0; - size_t lastRecordOffset =0; - size_t countdownOffset = 0; - //const unsigned long maxRecordingTime = 60*1000; - const static size_t recordEntries = (60/8)*110; // DEBUG *4 - - ActivityRecorderApplication(); - bool Tick(); - float *recordX = nullptr; - float *recordY = nullptr; - float *recordZ = nullptr; - size_t historyRecordsOffset = 0; - const float threshold = 40; - static const unsigned long ResampleMS = 2000; - static const size_t historyRecordMAX = 32; - size_t historyRecordsLenght[historyRecordMAX] = { 0 }; - float *historyRecordsX[historyRecordMAX] = { nullptr }; - float *historyRecordsY[historyRecordMAX] = { nullptr }; - float *historyRecordsZ[historyRecordMAX] = { nullptr }; - - size_t currentMatchOffset = 0; - size_t matchLenght[historyRecordMAX] = { 0 }; - int8_t *matchX[historyRecordMAX] = { nullptr }; - int8_t *matchY[historyRecordMAX] = { nullptr }; - int8_t *matchZ[historyRecordMAX] = { nullptr }; - - size_t matchPoints[historyRecordMAX] = { 0 }; - - size_t visualPatternPos = 0; - size_t visualPatternOffset = -1; -}; - -#endif diff --git a/src/app/Advanced.cpp b/src/app/Advanced.cpp index 0c2b388..c3beb90 100644 --- a/src/app/Advanced.cpp +++ b/src/app/Advanced.cpp @@ -19,7 +19,7 @@ #include #include -#include +//#include #include "Advanced.hpp" #include "LogView.hpp" #include "../resources.hpp" diff --git a/src/app/Advanced.hpp b/src/app/Advanced.hpp index 2bf1753..317b41e 100644 --- a/src/app/Advanced.hpp +++ b/src/app/Advanced.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__ADVANCED_SETTINGS_APP__ #define __LUNOKIOT__ADVANCED_SETTINGS_APP__ #include -#include +//#include #include "../system/Application.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/AppPartitionBrowser.cpp b/src/app/AppPartitionBrowser.cpp index 3652c56..c016d7d 100644 --- a/src/app/AppPartitionBrowser.cpp +++ b/src/app/AppPartitionBrowser.cpp @@ -33,7 +33,7 @@ #include #include "PartitionBrowser.hpp" #include "../UI/UI.hpp" -#include +//#include using namespace LuI; #include "../resources.hpp" //#include "../system/Datasources/database.hpp" @@ -58,7 +58,7 @@ AppPartitionApplication::AppPartitionApplication(const esp_partition_t *part) { Container * viewContainer = new Container(LuI_Horizontal_Layout,2); viewContainer->border=5; // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + LuI::Button *backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=0; backButton->tapCallback=[](void * obj){ LaunchApplication(new PartitionExplorerApplication()); diff --git a/src/app/BLEDevice.cpp b/src/app/BLEDevice.cpp index 845d40f..08e86bb 100644 --- a/src/app/BLEDevice.cpp +++ b/src/app/BLEDevice.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "BLEDevice.hpp" #include "BLEMonitor.hpp" #include "../system/Network/BLE.hpp" diff --git a/src/app/BLEDevice.hpp b/src/app/BLEDevice.hpp index 4ec77ec..6040420 100644 --- a/src/app/BLEDevice.hpp +++ b/src/app/BLEDevice.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__BLEMONITORDEVICE_APP__ #define __LUNOKIOT__BLEMONITORDEVICE_APP__ #include -#include +//#include #include "../system/Network.hpp" #include "../UI/AppTemplate.hpp" diff --git a/src/app/BLEMonitor.cpp b/src/app/BLEMonitor.cpp index eeb2174..c3b4fc7 100644 --- a/src/app/BLEMonitor.cpp +++ b/src/app/BLEMonitor.cpp @@ -19,7 +19,7 @@ #include #include -#include +//#include #include "BLEMonitor.hpp" #include "../static/img_back_32.xbm" #include "../static/img_bluetooth_32.xbm" @@ -120,7 +120,7 @@ bool BLEMonitorApplication::Tick() { UINextTimeout = millis() + UITimeout; // no sleep here if (millis() > nextRedraw) { rotateVal += 1; - canvas->fillSprite(canvas->color24to16(0x212121)); + canvas->fillSprite(TFT_DARKGREY); canvas->fillCircle(120, 120, 30, TFT_BLACK); canvas->fillCircle(120, 120, 28, TFT_WHITE); canvas->fillCircle(120, 120, 24, TFT_BLUE); @@ -156,11 +156,11 @@ bool BLEMonitorApplication::Tick() { //lLog("DEV RSSI: %d\n",dev->rssi); if ( seconds < 3) { // draw signal radius+=2; - canvas->fillCircle(x,y,radius,canvas->color24to16(0x1825a9)); - canvas->fillCircle(x,y,radius-4,canvas->color24to16(0x212121)); + canvas->fillCircle(x,y,radius,TFT_YELLOW); + canvas->fillCircle(x,y,radius-4,TFT_DARKGREY); - canvas->fillCircle(x,y,radius-8,canvas->color24to16(0x1825a9)); - canvas->fillCircle(x,y,radius-12,canvas->color24to16(0x212121)); + canvas->fillCircle(x,y,radius-8,TFT_YELLOW); + canvas->fillCircle(x,y,radius-12,TFT_DARKGREY); } else if ( seconds > 77 ) { radius-=12; } else if ( seconds > 69 ) { radius-=10; } else if ( seconds > 62 ) { radius-=8; @@ -168,7 +168,7 @@ bool BLEMonitorApplication::Tick() { } else if ( seconds > 40 ) { radius-=3; } canvas->fillCircle(x,y,radius-14,TFT_BLACK); canvas->fillCircle(x,y,radius-16,TFT_WHITE); - uint16_t finalColor = canvas->alphaBlend(alpha,canvas->color24to16(0x212121),TFT_BLUE); + uint16_t finalColor = canvas->alphaBlend(alpha,TFT_DARKGREY,TFT_BLUE); canvas->fillCircle(x,y,radius-18,finalColor); if ( seconds < 5) { // draw signal canvas->setTextColor(TFT_BLACK); diff --git a/src/app/BLEMonitor.hpp b/src/app/BLEMonitor.hpp index 30cdd11..ec6e7f1 100644 --- a/src/app/BLEMonitor.hpp +++ b/src/app/BLEMonitor.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__BLEMONITOR_APP__ #define __LUNOKIOT__BLEMONITOR_APP__ #include -#include +//#include #include "../UI/AppTemplate.hpp" //#include "../system/Network.hpp" //#include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/Battery.cpp b/src/app/Battery.cpp index 91a172e..61542e5 100644 --- a/src/app/Battery.cpp +++ b/src/app/Battery.cpp @@ -23,8 +23,11 @@ #include "../UI/widgets/ButtonImageXBMWidget.hpp" #include "../UI/widgets/GraphWidget.hpp" #include "../resources.hpp" + +#ifdef LILYGO_DEV #include extern TTGOClass *ttgo; // ttgo lib +#endif extern float PMUBattDischarge; extern float batteryRemainingTimeHours; @@ -52,7 +55,11 @@ BatteryApplication::BatteryApplication() { //LaunchWatchface(); // battery full, return to watchface },PMU_EVENT_BATT_FULL); + #ifdef LILYGO_DEV charging = ttgo->power->isChargeing(); + #else + charging = false; + #endif int64_t tmin = int64_t(axpTemp*10)-SCALE; int64_t tmax = int64_t(axpTemp*10)+SCALE; batteryTempMonitor = new GraphWidget(35,100,tmin,tmax); @@ -89,7 +96,9 @@ bool BatteryApplication::Tick() { return false; } if (millis() > nextRedraw ) { + #ifdef LILYGO_DEV charging = ttgo->power->isChargeing(); + #endif //if ( this->dirtyFrame ) { // only refresh when dirty canvas->fillSprite(TFT_BLACK); canvas->pushImage(TFT_WIDTH-90,40,img_battery_empty_160.width,img_battery_empty_160.height, (uint16_t *)img_battery_empty_160.pixel_data); diff --git a/src/app/Battery.hpp b/src/app/Battery.hpp index e08ec14..96377c4 100644 --- a/src/app/Battery.hpp +++ b/src/app/Battery.hpp @@ -24,7 +24,7 @@ */ #include -#include +//#include #include "../UI/AppTemplate.hpp" #include "../system/Datasources/kvo.hpp" diff --git a/src/app/Bluetooth.cpp b/src/app/Bluetooth.cpp index 2dd24ab..df832f1 100644 --- a/src/app/Bluetooth.cpp +++ b/src/app/Bluetooth.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "Bluetooth.hpp" #include #include "../resources.hpp" diff --git a/src/app/Bluetooth.hpp b/src/app/Bluetooth.hpp index 0d78148..05b39b7 100644 --- a/src/app/Bluetooth.hpp +++ b/src/app/Bluetooth.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__BLUETOOTH_APP__ #define __LUNOKIOT__BLUETOOTH_APP__ #include -#include +//#include #include "../UI/AppTemplate.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/Brightness.cpp b/src/app/Brightness.cpp index 0d35b16..5bc9d45 100644 --- a/src/app/Brightness.cpp +++ b/src/app/Brightness.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include #include "Brightness.hpp" @@ -28,13 +28,21 @@ #include "LogView.hpp" +#ifdef LILYGO_DEV #include extern TTGOClass *ttgo; // ttgo lib +#elif defined(M5_DEV) +#include +#endif BrightnessApplication::~BrightnessApplication() { uint16_t currentValue = ((255/360.0)*brightGauge->selectedAngle); if (currentValue != 0) { - ttgo->setBrightness(currentValue); + #ifdef LILYGO_DEV + ttgo->setBrightness(currentValue); + #elif defined(M5_DEV) + tft->setBrightness(currentValue); + #endif NVS.setInt("lBright",currentValue,false); }; delete brightGauge; @@ -42,17 +50,22 @@ BrightnessApplication::~BrightnessApplication() { BrightnessApplication::BrightnessApplication() { brightGauge = new GaugeWidget(10,10,220); - +#ifdef LILYGO_DEV uint8_t userBright = ttgo->bl->getLevel(); int16_t currentValue = userBright*(360.0/255); brightGauge->selectedAngle = currentValue; +#endif Tick(); } bool BrightnessApplication::Tick() { if ( brightGauge->Interact(touched,touchX, touchY) ) { uint16_t currentValue = ((255/360.0)*brightGauge->selectedAngle); - ttgo->setBrightness(currentValue); + #ifdef LILYGO_DEV + ttgo->setBrightness(currentValue); + #elif defined(M5_DEV) + tft->setBrightness(currentValue); + #endif brightGauge->DirectDraw(); return false; } diff --git a/src/app/Calculator.cpp b/src/app/Calculator.cpp index 0e20a71..0393eda 100644 --- a/src/app/Calculator.cpp +++ b/src/app/Calculator.cpp @@ -19,7 +19,7 @@ #include "Calculator.hpp" #include -#include +//#include #include "../UI/UI.hpp" #include "../static/img_happy_48.xbm" // center smiley to see the orientation diff --git a/src/app/Calculator.hpp b/src/app/Calculator.hpp index e16b3c7..611a990 100644 --- a/src/app/Calculator.hpp +++ b/src/app/Calculator.hpp @@ -21,7 +21,7 @@ #define __LUNOKIOT__CALCULATOR_APP__ #include -#include +//#include #include "../system/Application.hpp" #include "../UI/widgets/ButtonTextWidget.hpp" diff --git a/src/app/Calendar.cpp b/src/app/Calendar.cpp index 5582965..09cae99 100644 --- a/src/app/Calendar.cpp +++ b/src/app/Calendar.cpp @@ -21,7 +21,7 @@ #include "../lunokIoT.hpp" #include "LogView.hpp" // log capabilities #include "../UI/AppTemplate.hpp" -#include +//#include #include "Calendar.hpp" #include "../UI/widgets/ButtonTextWidget.hpp" #include @@ -105,7 +105,7 @@ CalendarApplication::CalendarApplication() { //lAppLog("Time: %02d:%02d:%02d %02d-%02d-%04d\n", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec, timeinfo.tm_mday, timeinfo.tm_mon, 1900 + timeinfo.tm_year); year = 1900 + timeinfo.tm_year; lAppLog("Current year: %d\n", year); - if((year% 4) == FALSE && (year%100) != FALSE || (year%400) == FALSE) { + if((year% 4) == 0 && (year%100) != 0 || (year%400) == 0) { // It is a leap year and February has 29 days. days_in_month[1] = 29; lAppLog("Is a leap year\n"); diff --git a/src/app/CalendarLogDetail.cpp b/src/app/CalendarLogDetail.cpp index ebc1c2a..f074a1d 100644 --- a/src/app/CalendarLogDetail.cpp +++ b/src/app/CalendarLogDetail.cpp @@ -98,7 +98,7 @@ CalendarLogDetailApplication::CalendarLogDetailApplication(int year, int month, screen->AddChild(bottomButtonContainer,0.4); // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + LuI::Button *backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=0; backButton->tapCallback=[](void * obj){ LaunchApplication(new CalendarApplication()); }; // callback when tap // load icon in XBM format diff --git a/src/app/Dungeon/Dungeon.cpp b/src/app/Dungeon/Dungeon.cpp index 6862465..eeaa380 100644 --- a/src/app/Dungeon/Dungeon.cpp +++ b/src/app/Dungeon/Dungeon.cpp @@ -17,9 +17,7 @@ // LunokWatch. If not, see . // #include "Dungeon.hpp" -#include -//#include #include "../LogView.hpp" // for lLog functions #include @@ -108,7 +106,7 @@ DungeonGameApplication::DungeonGameApplication() { - tft->setTextColor(TFT_WHITE,tft->color24to16(0x191919)); + tft->setTextColor(TFT_WHITE,Get16BitFromRGB(0x191919)); tft->setTextDatum(BC_DATUM); tft->setFreeFont(&FreeSerif12pt7b); tft->setTextSize(1); @@ -509,7 +507,7 @@ void DungeonGameApplication::Redraw() { void DungeonGameApplication::NoticesBanner(const char *what) { if ( false == currentLevel.running ) { - tft->fillRect(0,TFT_HEIGHT-40,TFT_WIDTH,40,tft->color24to16(0x191919)); + tft->fillRect(0,TFT_HEIGHT-40,TFT_WIDTH,40,Get16BitFromRGB(0x191919)); tft->drawString(what, TFT_WIDTH/2,TFT_HEIGHT-10); } } diff --git a/src/app/Dungeon/MapGenerator.cpp b/src/app/Dungeon/MapGenerator.cpp index 7094e27..ac252fd 100644 --- a/src/app/Dungeon/MapGenerator.cpp +++ b/src/app/Dungeon/MapGenerator.cpp @@ -21,7 +21,7 @@ #include "Dungeon.hpp" #include "../LogView.hpp" -extern TFT_eSPI * tft; +//extern TFT_eSPI * tft; /* void DrawLevelGeneratorMap(levelDescriptor * currentLevel) { delay(10); diff --git a/src/app/FileBrowser.cpp b/src/app/FileBrowser.cpp index a11a97a..16b2da1 100644 --- a/src/app/FileBrowser.cpp +++ b/src/app/FileBrowser.cpp @@ -33,7 +33,7 @@ #include #include "../UI/UI.hpp" -#include +//#include using namespace LuI; #include "../resources.hpp" //#include "../system/Datasources/database.hpp" @@ -55,7 +55,7 @@ FileExplorerApplication::FileExplorerApplication(const char *path) { Container * viewContainer = new Container(LuI_Horizontal_Layout,2); viewContainer->border=5; // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + LuI::Button *backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=0; backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap // load icon in XBM format diff --git a/src/app/FreehandKeyboardLetterChoice.cpp b/src/app/FreehandKeyboardLetterChoice.cpp index e09baea..416f3eb 100644 --- a/src/app/FreehandKeyboardLetterChoice.cpp +++ b/src/app/FreehandKeyboardLetterChoice.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "LogView.hpp" // log capabilities #include "../UI/AppTemplate.hpp" #include "FreehandKeyboardLetterChoice.hpp" @@ -27,7 +27,7 @@ #include "../UI/widgets/ButtonImageXBMWidget.hpp" #include -extern TTGOClass *ttgo; +//extern TTGOClass *ttgo; #include "../static/img_trash_32.xbm" extern bool UILongTapOverride; diff --git a/src/app/FreehandKeyboardLetterChoice.hpp b/src/app/FreehandKeyboardLetterChoice.hpp index 2137f8b..b9567d6 100644 --- a/src/app/FreehandKeyboardLetterChoice.hpp +++ b/src/app/FreehandKeyboardLetterChoice.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__APPLICATION__FreehandKeyboardLetterChoiceApplication__ #define __LUNOKIOT__APPLICATION__FreehandKeyboardLetterChoiceApplication__ #include -#include +//#include #include "../UI/AppTemplate.hpp" #include "../system/Datasources/perceptron.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/FreehandKeyboardQuery.cpp b/src/app/FreehandKeyboardQuery.cpp index 5958dea..3fde7d8 100644 --- a/src/app/FreehandKeyboardQuery.cpp +++ b/src/app/FreehandKeyboardQuery.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "LogView.hpp" // log capabilities #include "../UI/AppTemplate.hpp" #include "FreehandKeyboardQuery.hpp" @@ -27,7 +27,7 @@ #include "../UI/widgets/ButtonImageXBMWidget.hpp" #include -extern TTGOClass *ttgo; +//extern TTGOClass *ttgo; #include "../static/img_trash_32.xbm" extern bool UILongTapOverride; diff --git a/src/app/FreehandKeyboardQuery.hpp b/src/app/FreehandKeyboardQuery.hpp index 1693a78..e965306 100644 --- a/src/app/FreehandKeyboardQuery.hpp +++ b/src/app/FreehandKeyboardQuery.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__APPLICATION__FreehandKeyboardQUERY___ #define __LUNOKIOT__APPLICATION__FreehandKeyboardQUERY___ #include -#include +//#include #include "../UI/AppTemplate.hpp" #include "../system/Datasources/perceptron.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/FreehandKeyboardSetup.cpp b/src/app/FreehandKeyboardSetup.cpp index ce4ad3c..d3709b8 100644 --- a/src/app/FreehandKeyboardSetup.cpp +++ b/src/app/FreehandKeyboardSetup.cpp @@ -29,7 +29,7 @@ #include "FreehandKeyboardTraining.hpp" #include "FreehandKeyboardQuery.hpp" #include -#include +//#include #include "../system/Datasources/perceptron.hpp" #include "../../static/freeHandKeyboardPreTrained.h" diff --git a/src/app/FreehandKeyboardTraining.cpp b/src/app/FreehandKeyboardTraining.cpp index c6fa8f6..2871b91 100644 --- a/src/app/FreehandKeyboardTraining.cpp +++ b/src/app/FreehandKeyboardTraining.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "LogView.hpp" // log capabilities #include "../UI/AppTemplate.hpp" #include "FreehandKeyboardTraining.hpp" @@ -28,7 +28,7 @@ #include //#include -extern TTGOClass *ttgo; +//extern TTGOClass *ttgo; #include "../resources.hpp" //#include "../static/img_trash_32.xbm" extern bool UILongTapOverride; diff --git a/src/app/FreehandKeyboardTraining.hpp b/src/app/FreehandKeyboardTraining.hpp index 19f62e8..8fdc9d9 100644 --- a/src/app/FreehandKeyboardTraining.hpp +++ b/src/app/FreehandKeyboardTraining.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__APPLICATION__FreehandKeyboardTRAINING__ #define __LUNOKIOT__APPLICATION__FreehandKeyboardTRAINING__ #include -#include +//#include #include "../UI/AppTemplate.hpp" #include "../system/Datasources/perceptron.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/GestureSettings.cpp b/src/app/GestureSettings.cpp index 261d9cf..ce453a4 100644 --- a/src/app/GestureSettings.cpp +++ b/src/app/GestureSettings.cpp @@ -24,8 +24,10 @@ #include "../lunokIoT.hpp" #include +#ifdef LILYGO_DEV #include extern TTGOClass *ttgo; +#endif extern SemaphoreHandle_t I2cMutex; GestureSettings::GestureSettings() { @@ -48,11 +50,15 @@ GestureSettings::~GestureSettings() { delete UseDoubleTapSwitch; BaseType_t done = xSemaphoreTake(I2cMutex, LUNOKIOT_EVENT_MANDATORY_TIME_TICKS); if ( doubleTapSetting ) { + #ifdef LILYGO_DEV bool featureOK = ttgo->bma->enableWakeupInterrupt(); if ( false == featureOK ) { lEvLog("BMA: Unable to Enable interrupt 'double tap'\n"); } + #endif } else { + #ifdef LILYGO_DEV bool featureOK = ttgo->bma->enableWakeupInterrupt(false); if ( false == featureOK ) { lEvLog("BMA: Unable to Disable interrupt 'double tap'\n"); } + #endif } xSemaphoreGive(I2cMutex); } diff --git a/src/app/IATest.cpp b/src/app/IATest.cpp index 1a52d47..7792177 100644 --- a/src/app/IATest.cpp +++ b/src/app/IATest.cpp @@ -18,7 +18,7 @@ // #include -#include +//#include #include "../lunokiot_config.hpp" #include "../UI/widgets/CanvasWidget.hpp" // for color mask @@ -37,7 +37,7 @@ IATestApplication::IATestApplication() { accelSphere = new CanvasWidget(150, 150); // BMP info on a spin compositeBuffer150 = new CanvasWidget(150,150); // dirty buffer to do things with accelSphere - eyeLensBuffer->canvas->fillCircle(eyeLensBuffer->canvas->height()/2, eyeLensBuffer->canvas->width()/2,98,canvas->color24to16(0x2a040c));//0x686890)); + eyeLensBuffer->canvas->fillCircle(eyeLensBuffer->canvas->height()/2, eyeLensBuffer->canvas->width()/2,98,Get16BitFromRGB(0x2a040c));//0x686890)); eyeLensBuffer->canvas->fillCircle(eyeLensBuffer->canvas->height()/2, eyeLensBuffer->canvas->width()/2,87,CanvasWidget::MASK_COLOR); eyeLensBuffer->canvas->fillRect(0,0,100,200,CanvasWidget::MASK_COLOR); @@ -48,7 +48,7 @@ IATestApplication::IATestApplication() { compositeBuffer->canvas->fillCircle(TFT_HEIGHT/2, TFT_WIDTH/2,80,CanvasWidget::MASK_COLOR); // outher circle decoration - compositeBuffer->canvas->fillCircle(TFT_HEIGHT/2, TFT_WIDTH/2,120,canvas->color24to16(0x383838)); + compositeBuffer->canvas->fillCircle(TFT_HEIGHT/2, TFT_WIDTH/2,120,Get16BitFromRGB(0x383838)); compositeBuffer->canvas->fillCircle(TFT_HEIGHT/2, TFT_WIDTH/2,116,CanvasWidget::MASK_COLOR); // eraser ;-P compositeBuffer->canvas->fillRect(0,0,118,TFT_HEIGHT,CanvasWidget::MASK_COLOR); @@ -62,10 +62,10 @@ IATestApplication::IATestApplication() { } // upper single border circle - compositeBuffer->canvas->drawCircle(TFT_HEIGHT/2, TFT_WIDTH/2,150, canvas->color24to16(0x383838)); + compositeBuffer->canvas->drawCircle(TFT_HEIGHT/2, TFT_WIDTH/2,150, Get16BitFromRGB(0x383838)); // inner circle - compositeBuffer->canvas->fillCircle(TFT_HEIGHT/2, TFT_WIDTH/2,80, canvas->color24to16(0x383838)); + compositeBuffer->canvas->fillCircle(TFT_HEIGHT/2, TFT_WIDTH/2,80, Get16BitFromRGB(0x383838)); compositeBuffer->canvas->fillCircle(TFT_HEIGHT/2, TFT_WIDTH/2,75,CanvasWidget::MASK_COLOR); // right side circle cut compositeBuffer->canvas->fillRect(180,84,120,74, TFT_BLACK); @@ -73,8 +73,8 @@ IATestApplication::IATestApplication() { // compositeBuffer->canvas->fillRect(120,80,120,80, TFT_BLACK); // right side circle cut lines - compositeBuffer->canvas->fillRect(185,80,55,5, compositeBuffer->canvas->color24to16(0x383838)); - compositeBuffer->canvas->fillRect(185,160,55,5, compositeBuffer->canvas->color24to16(0x383838)); + compositeBuffer->canvas->fillRect(185,80,55,5, Get16BitFromRGB(0x383838)); + compositeBuffer->canvas->fillRect(185,160,55,5, Get16BitFromRGB(0x383838)); // Dump to buffer compositeBuffer->canvas->pushRotated(watchFacebackground->canvas,0,CanvasWidget::MASK_COLOR); @@ -89,9 +89,9 @@ IATestApplication::IATestApplication() { // notification pane draw // notif 1 test - circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,20,canvas->color24to16(0x0)); - circleNotifications->canvas->drawCircle(TFT_WIDTH/2,38,18,canvas->color24to16(0xffffff)); - circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,16,canvas->color24to16(0x00ff00)); + circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,20,Get16BitFromRGB(0x0)); + circleNotifications->canvas->drawCircle(TFT_WIDTH/2,38,18,Get16BitFromRGB(0xffffff)); + circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,16,Get16BitFromRGB(0x00ff00)); compositeBuffer->canvas->fillSprite(CanvasWidget::MASK_COLOR); @@ -99,9 +99,9 @@ IATestApplication::IATestApplication() { circleNotifications->canvas->fillSprite(CanvasWidget::MASK_COLOR); compositeBuffer->canvas->pushRotated(circleNotifications->canvas,0,CanvasWidget::MASK_COLOR); // notif 2 test - circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,20,canvas->color24to16(0x0)); - circleNotifications->canvas->drawCircle(TFT_WIDTH/2,38,18,canvas->color24to16(0xffffff)); - circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,16,canvas->color24to16(0x0000ff)); + circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,20,Get16BitFromRGB(0x0)); + circleNotifications->canvas->drawCircle(TFT_WIDTH/2,38,18,Get16BitFromRGB(0xffffff)); + circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,16,Get16BitFromRGB(0x0000ff)); compositeBuffer->canvas->fillSprite(CanvasWidget::MASK_COLOR); circleNotifications->canvas->pushRotated(compositeBuffer->canvas,notificationRouletteAngle,CanvasWidget::MASK_COLOR); @@ -109,9 +109,9 @@ IATestApplication::IATestApplication() { compositeBuffer->canvas->pushRotated(circleNotifications->canvas,0,CanvasWidget::MASK_COLOR); // notif 3 test - circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,20,canvas->color24to16(0x0)); - circleNotifications->canvas->drawCircle(TFT_WIDTH/2,38,18,canvas->color24to16(0xffffff)); - circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,16,canvas->color24to16(0xff00ff)); + circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,20,Get16BitFromRGB(0x0)); + circleNotifications->canvas->drawCircle(TFT_WIDTH/2,38,18,Get16BitFromRGB(0xffffff)); + circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,16,Get16BitFromRGB(0xff00ff)); compositeBuffer->canvas->fillSprite(CanvasWidget::MASK_COLOR); circleNotifications->canvas->pushRotated(compositeBuffer->canvas,notificationRouletteAngle,CanvasWidget::MASK_COLOR); @@ -119,9 +119,9 @@ IATestApplication::IATestApplication() { compositeBuffer->canvas->pushRotated(circleNotifications->canvas,0,CanvasWidget::MASK_COLOR); // notif 4 test - circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,20,canvas->color24to16(0x0)); - circleNotifications->canvas->drawCircle(TFT_WIDTH/2,38,18,canvas->color24to16(0xffffff)); - circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,16,canvas->color24to16(0xff0ffa)); + circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,20,Get16BitFromRGB(0x0)); + circleNotifications->canvas->drawCircle(TFT_WIDTH/2,38,18,Get16BitFromRGB(0xffffff)); + circleNotifications->canvas->fillCircle(TFT_WIDTH/2,38,16,Get16BitFromRGB(0xff0ffa)); } @@ -164,13 +164,13 @@ bool IATestApplication::Tick() { uint16_t pcYinByte = pcY*2.55; uint16_t pcZinByte = pcZ*2.55; - uint16_t colorX = canvas->alphaBlend(pcXinByte,TFT_WHITE, canvas->color24to16(0xbfbf40))+randX; - //uint16_t colorX = canvas->alphaBlend(pcX,TFT_WHITE, canvas->color24to16(0x1c02a2))+randX; - uint16_t colorY = canvas->alphaBlend(pcYinByte,TFT_WHITE, canvas->color24to16(0xff1649))+randY; + uint16_t colorX = canvas->alphaBlend(pcXinByte,TFT_WHITE, Get16BitFromRGB(0xbfbf40))+randX; + //uint16_t colorX = canvas->alphaBlend(pcX,TFT_WHITE, Get16BitFromRGB(0x1c02a2))+randX; + uint16_t colorY = canvas->alphaBlend(pcYinByte,TFT_WHITE, Get16BitFromRGB(0xff1649))+randY; - //uint16_t colorY = canvas->alphaBlend(pcY,TFT_WHITE, canvas->color24to16(0x4266f6))+randY; - //uint16_t colorZ = canvas->alphaBlend(pcZ,TFT_WHITE, canvas->color24to16(0xff1ecf))+randZ; - uint16_t colorZ = canvas->alphaBlend(pcZinByte,TFT_WHITE, canvas->color24to16(0x1c72c5))+randZ; + //uint16_t colorY = canvas->alphaBlend(pcY,TFT_WHITE, Get16BitFromRGB(0x4266f6))+randY; + //uint16_t colorZ = canvas->alphaBlend(pcZ,TFT_WHITE, Get16BitFromRGB(0xff1ecf))+randZ; + uint16_t colorZ = canvas->alphaBlend(pcZinByte,TFT_WHITE, Get16BitFromRGB(0x1c72c5))+randZ; int32_t sizeX = (pcX*0.12); if ( sizeX < 2 ) { sizeX =1; } int32_t sizeY = (pcY*0.12); if ( sizeY < 2 ) { sizeY =1; } @@ -186,14 +186,14 @@ bool IATestApplication::Tick() { int32_t fakeHeight = random(0, 100); //int32_t dcolor = random(0, 16536); int32_t dsize = random(1, 4); - compositeBuffer150->canvas->fillCircle(75,fakeHeight,dsize,canvas->color24to16(0x8840bf)+randZ); + compositeBuffer150->canvas->fillCircle(75,fakeHeight,dsize,Get16BitFromRGB(0x8840bf)+randZ); /* int32_t drandX = random(0, 100); int32_t drandY = random(0, 100); int32_t dsize = random(1, 4); int32_t dcolor = random(0, 16536); - compositeBuffer150->canvas->fillCircle(drandX,drandY,dsize,canvas->color24to16(0x8840bf)+randZ); + compositeBuffer150->canvas->fillCircle(drandX,drandY,dsize,Get16BitFromRGB(0x8840bf)+randZ); */ // cleanup final buffer diff --git a/src/app/KnowLocations.cpp b/src/app/KnowLocations.cpp index a67de4a..afd348f 100644 --- a/src/app/KnowLocations.cpp +++ b/src/app/KnowLocations.cpp @@ -31,12 +31,12 @@ #include "LogView.hpp" #include "../UI/UI.hpp" -#include +//#include using namespace LuI; #include "../resources.hpp" #include "../system/Datasources/database.hpp" #include "../system/Network/BLE.hpp" -extern TFT_eSPI * tft; +//extern TFT_eSPI * tft; static int totalKnowBLEDEvices = 0; @@ -104,7 +104,7 @@ KnowLocationApplication::KnowLocationApplication() { screen->AddChild(bottomButtonContainer,0.35); // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + LuI::Button *backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=0; backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap // load icon in XBM format @@ -115,7 +115,7 @@ KnowLocationApplication::KnowLocationApplication() { // shrink button to left and empty control oversized (want button on left bottom) bottomButtonContainer->AddChild(backButton,0.45); - Button * setButton = new Button(LuI_Vertical_Layout,1); + LuI::Button * setButton = new LuI::Button(LuI_Vertical_Layout,1); setButton->AddChild(new Text("Set zone")); setButton->tapCallbackParam=this; diff --git a/src/app/Lamp.cpp b/src/app/Lamp.cpp index 0de8366..93a3e08 100644 --- a/src/app/Lamp.cpp +++ b/src/app/Lamp.cpp @@ -18,17 +18,23 @@ // #include +#ifdef LILYGO_DEV #include extern TTGOClass *ttgo; // ttgo lib +#elif defined(M5_DEV) +#include +#endif #include "LogView.hpp" // log capabilities #include "Lamp.hpp" LampApplication::LampApplication() { canvas->fillSprite(TFT_WHITE); } bool LampApplication::Tick() { + #ifdef LILYGO_DEV if ( ttgo->bl->isOn() ) { // is the screen ON? if ( 255 > ttgo->bl->getLevel() ) { ttgo->setBrightness(ttgo->bl->getLevel()+1); } } + #endif if ( touched ) { LaunchWatchface(); } return false; } diff --git a/src/app/LockPicking.cpp b/src/app/LockPicking.cpp deleted file mode 100644 index c2cebfb..0000000 --- a/src/app/LockPicking.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// -// LunokWatch, a open source smartwatch software -// Copyright (C) 2022,2023 Jordi Rubió -// This file is part of LunokWatch. -// -// LunokWatch is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// LunokWatch is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// LunokWatch. If not, see . -// - -#include -#include -#include "LockPicking.hpp" -#include "../UI/UI.hpp" -#include "LogView.hpp" // log capabilities -#include "../UI/AppTemplate.hpp" -#include "ApplicationBase.hpp" -#include "../UI/widgets/EntryTextWidget.hpp" -#include "../lunokiot_config.hpp" -extern TTGOClass *ttgo; // ttgo lib - -extern void TakeBMPSample(); - -LockPickingGameApplication::~LockPickingGameApplication() { - delete wristGauge; -} - -LockPickingGameApplication::LockPickingGameApplication() { - wristGauge = new GaugeWidget(10,10,220); - levelCorrectAngle=random(aMIN,aMAX); - lAppLog("Selected angle: %d\n",levelCorrectAngle); - Tick(); -} - -bool LockPickingGameApplication::Tick() { - UINextTimeout = millis()+UITimeout; // disable screen timeout - TemplateApplication::Tick(); - if ( lastAngle != wristGauge->selectedAngle ) { - wristGauge->dirty=true; // force redraw - lastAngle=wristGauge->selectedAngle; - //lAppLog("degX: %.2f wristGauge: %d\n",degX,wristGauge->selectedAngle); - lAppLog("levelCorrectAngle: %d wristGauge: %d\n",levelCorrectAngle,wristGauge->selectedAngle); - if ( (levelCorrectAngle-levelDriftAngle <= wristGauge->selectedAngle ) - && (levelCorrectAngle+levelDriftAngle >= wristGauge->selectedAngle ) ) { - tft->fillScreen(TFT_GREEN); - ttgo->motor->onec(); - currentLevel++; - levelCorrectAngle=random(aMIN,aMAX); - lAppLog("Selected angle: %d\n",levelCorrectAngle); - levelDriftAngle--; - if (levelDriftAngle < 0 ) { - levelDriftAngle=0; - playerWin=true; // YOU WIN!!! - LaunchWatchface(); - } - delay(200); - } - int16_t difference=abs(levelCorrectAngle-wristGauge->selectedAngle); - uint16_t currentValue = ((255/360.0)*difference); - lAppLog("DIFFERENCE: %d va: %u\n", difference,currentValue); - nearby=currentValue; - if ( millis() > nextHapticBeat ) { - //if ( nearby > ) - ttgo->motor->onec(255-nearby); - nextHapticBeat=millis()+1000; - } - //wristGauge->DirectDraw(); - } - if (millis() > nextRedraw ) { - TakeBMPSample(); // taint system about collect fresh gyroscope data (more than usual) - //lLog("degX: %.2f degY: %.2f degZ: %.2f\n",degX,degY,degZ); - - wristGauge->selectedAngle=degX; - canvas->fillSprite(canvas->color565(255-nearby,255-nearby,255-nearby)); - - char buffer[20]; - canvas->setTextSize(2); - canvas->setFreeFont(&FreeMonoBold24pt7b); - canvas->setTextDatum(CC_DATUM); - canvas->setTextWrap(false,false); - sprintf(buffer,"%d", currentLevel ); - canvas->setTextColor(TFT_WHITE); - canvas->drawString(buffer, 120, 120); - - canvas->setTextSize(1); - canvas->setFreeFont(&FreeMonoBold12pt7b); - sprintf(buffer,"%d", wristGauge->selectedAngle ); - canvas->setTextDatum(TL_DATUM); - canvas->drawString(buffer, 5, 5); - - canvas->setTextDatum(TR_DATUM); - sprintf(buffer,"%d", levelDriftAngle ); - canvas->drawString(buffer, TFT_WIDTH-5, 5); - - - canvas->setTextDatum(BR_DATUM); - sprintf(buffer,"%d", levelCorrectAngle ); - canvas->drawString(buffer, TFT_WIDTH-5, TFT_HEIGHT-5); - - wristGauge->DrawTo(canvas); - TemplateApplication::Tick(); - nextRedraw=millis()+(1000/12); // tune your required refresh - return true; - } - return false; -} diff --git a/src/app/LockPicking.hpp b/src/app/LockPicking.hpp deleted file mode 100644 index 1a8a774..0000000 --- a/src/app/LockPicking.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// -// LunokWatch, a open source smartwatch software -// Copyright (C) 2022,2023 Jordi Rubió -// This file is part of LunokWatch. -// -// LunokWatch is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// LunokWatch is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// LunokWatch. If not, see . -// - -#ifndef __LUNOKIOT__LOCKPICKING_GAME__ -#define __LUNOKIOT__LOCKPICKING_GAME__ - -#include "../UI/AppTemplate.hpp" -#include "../UI/widgets/GaugeWidget.hpp" - -class LockPickingGameApplication: public TemplateApplication { - unsigned long nextRedraw=0; - GaugeWidget * wristGauge = nullptr; - int16_t lastAngle=0; - int16_t levelCorrectAngle=0; - int16_t levelDriftAngle=20; - int16_t currentLevel=0; - bool playerWin=false; - const int16_t aMIN=90; - const int16_t aMAX=250; - uint8_t nearby=0; - unsigned long nextHapticBeat=0; - public: - const char *AppName() override { return "LockPickingGame"; }; - LockPickingGameApplication(); - ~LockPickingGameApplication(); - bool Tick(); -}; - -#endif diff --git a/src/app/LogView.cpp b/src/app/LogView.cpp index 0d3c7f0..7b0ada8 100644 --- a/src/app/LogView.cpp +++ b/src/app/LogView.cpp @@ -19,7 +19,7 @@ #include #include -#include +//#include #include "../UI/UI.hpp" #include "LogView.hpp" #include "../system/Datasources/database.hpp" diff --git a/src/app/LogView.hpp b/src/app/LogView.hpp index 1539d73..7936a45 100644 --- a/src/app/LogView.hpp +++ b/src/app/LogView.hpp @@ -22,8 +22,9 @@ #include #include -//#include +#ifdef LILYGO_DEV #include +#endif #include "../UI/AppTemplate.hpp" diff --git a/src/app/LuIBufferTest.cpp b/src/app/LuIBufferTest.cpp index 7a3620c..3bf4477 100644 --- a/src/app/LuIBufferTest.cpp +++ b/src/app/LuIBufferTest.cpp @@ -54,7 +54,7 @@ LuIBufferTestApplication::LuIBufferTestApplication() { // 1.7 + 0.3 = 2.0 of quota (fine for 2 slots) // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + LuI::Button *backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=10; backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap // load icon in XBM format diff --git a/src/app/LuIButtonsTest.cpp b/src/app/LuIButtonsTest.cpp index e758fc3..d451ef8 100644 --- a/src/app/LuIButtonsTest.cpp +++ b/src/app/LuIButtonsTest.cpp @@ -53,7 +53,7 @@ DebugLuIButtonsApplication::DebugLuIButtonsApplication() { // 1.7 + 0.3 = 2.0 of quota (fine for 2 slots) // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + LuI::Button *backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap // load icon in XBM format XBM * backButtonIcon = new XBM(img_backscreen_24_width,img_backscreen_24_height,img_backscreen_24_bits); @@ -78,17 +78,17 @@ DebugLuIButtonsApplication::DebugLuIButtonsApplication() { //leftContainer->AddChild(basicButton); // -----> text button - Button *textButton = new Button(); // a basic default button + LuI::Button *textButton = new LuI::Button(); // a basic default button textButton->AddChild(new Text("Hello")); leftContainer->AddChild(textButton); // -----> text button with font - Button *textButtonAlt = new Button(); // a basic default button + LuI::Button *textButtonAlt = new LuI::Button(); // a basic default button textButtonAlt->AddChild(new Text("Yep!",TFT_YELLOW,false,1,&FreeSerifItalic12pt7b)); leftContainer->AddChild(textButtonAlt); // -----> xbm 1 bit image button - Button *XBMButton = new Button(); + LuI::Button *XBMButton = new LuI::Button(); XBMButton->AddChild(new XBM(img_xbm_32_width,img_xbm_32_height,img_xbm_32_bits)); leftContainer->AddChild(XBMButton); @@ -96,19 +96,19 @@ DebugLuIButtonsApplication::DebugLuIButtonsApplication() { // right view side -----------------------------------> // -----> 16 bit image button with mask color - Button *ImageButton = new Button(); + LuI::Button *ImageButton = new LuI::Button(); ImageButton->AddChild(new Image(img_house_32.width,img_house_32.height,img_house_32.pixel_data,TFT_GREEN)); rightContainer->AddChild(ImageButton); // -----> using Container properties of Button to add two controls - Button *CombinedButton = new Button(LuI_Vertical_Layout,2); + LuI::Button *CombinedButton = new LuI::Button(LuI_Vertical_Layout,2); CombinedButton->AddChild(new Image(img_house_32.width,img_house_32.height,img_house_32.pixel_data,TFT_GREEN),0.8); CombinedButton->AddChild(new Text("Home"),1.2); rightContainer->AddChild(CombinedButton); // -----> can compose with multiple other components, any control can be added - Button *Button3d = new Button(LuI_Vertical_Layout,2); + LuI::Button *Button3d = new LuI::Button(LuI_Vertical_Layout,2); Mesh3D * sparkles = new Mesh3D(&BackButtonMesh); // load 3D mesh View3D * sparklesView = new View3D(); // create view for 3D mesh sparklesView->SetGlobalScale(0.15); // mesh methers=pixels 240Meters=240pixels diff --git a/src/app/LuIDemoMask.cpp b/src/app/LuIDemoMask.cpp index 76ef134..ce4f8e3 100644 --- a/src/app/LuIDemoMask.cpp +++ b/src/app/LuIDemoMask.cpp @@ -31,13 +31,13 @@ #include "LogView.hpp" #include "../UI/UI.hpp" -#include +//#include using namespace LuI; #include "../resources.hpp" #include "../../static/img_background_panda.c" #include "../../static/img_background_toon.c" -extern TFT_eSPI * tft; +//extern TFT_eSPI * tft; LuIExperimentMaskApplication::LuIExperimentMaskApplication() { directDraw=false; // disable direct draw meanwhile build the UI @@ -72,7 +72,7 @@ LuIExperimentMaskApplication::LuIExperimentMaskApplication() { screen->AddChild(bottomButtonContainer,0.32); // add back button to dismiss - backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=10; backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap // load icon in XBM format diff --git a/src/app/LuIDemoMask.hpp b/src/app/LuIDemoMask.hpp index 3ae13f3..bb7b0e7 100644 --- a/src/app/LuIDemoMask.hpp +++ b/src/app/LuIDemoMask.hpp @@ -22,7 +22,7 @@ #include "../UI/AppLuITemplate.hpp" #include "../UI/controls/Button.hpp" -#include +//#include class LuIExperimentMaskApplication : public TemplateLuIApplication { public: diff --git a/src/app/LuIDemoPlanet.cpp b/src/app/LuIDemoPlanet.cpp index 05608a9..719698f 100644 --- a/src/app/LuIDemoPlanet.cpp +++ b/src/app/LuIDemoPlanet.cpp @@ -31,8 +31,8 @@ #include "LogView.hpp" #include "../UI/UI.hpp" -#include -using namespace LuI; +//#include +//using namespace LuI; #include "../resources.hpp" #include "../../static/img_asteroid0_64.c" @@ -40,7 +40,13 @@ using namespace LuI; #include "../../static/img_asteroid2_64.c" #include "../../static/img_brokenMoon.c" +#ifdef LILYGO_DEV +#include extern TFT_eSPI * tft; +#elif defined(M5_DEV) +#include +extern M5Display * tft; +#endif LuIExperimentPlanetApplication::LuIExperimentPlanetApplication() { directDraw=false; // disable direct draw meanwhile build the UI @@ -48,12 +54,12 @@ LuIExperimentPlanetApplication::LuIExperimentPlanetApplication() { canvas->fillSprite(TFT_BLACK); // use theme colors /// create root container with two slots horizontal - Container * screen = new Container(LuI_Horizontal_Layout,2); + LuI::Container * screen = new LuI::Container(LuI_Horizontal_Layout,2); // bottom buttons container - Container * bottomButtonContainer = new Container(LuI_Vertical_Layout,2); + LuI::Container * bottomButtonContainer = new LuI::Container(LuI_Vertical_Layout,2); // main view space - Container * viewContainer = new Container(LuI_Horizontal_Layout,1); + LuI::Container * viewContainer = new LuI::Container(LuI_Horizontal_Layout,1); //viewContainer->border=10; // if use quota, all the slot quotas must sum equal the total number of elements // example: default quota in 2 controls result 50/50% of view space with 1.0 of quota everyone (2.0 in total) @@ -63,11 +69,11 @@ LuIExperimentPlanetApplication::LuIExperimentPlanetApplication() { screen->AddChild(bottomButtonContainer,0.32); // add back button to dismiss - backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=10; backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap // load icon in XBM format - XBM * backButtonIcon = new XBM(img_backscreen_24_width,img_backscreen_24_height,img_backscreen_24_bits); + LuI::XBM * backButtonIcon = new LuI::XBM(img_backscreen_24_width,img_backscreen_24_height,img_backscreen_24_bits); // put the icon inside the button backButton->AddChild(backButtonIcon); // shrink button to left and empty control oversized (want button on left bottom) @@ -76,7 +82,7 @@ LuIExperimentPlanetApplication::LuIExperimentPlanetApplication() { // here the main view LuI::View3D * view3DTest1 = new LuI::View3D(); - view3DTest1->RenderMode=LuI::View3D::RENDER::NODRAW; // only will show bilboards, not meshes + view3DTest1->RenderMode=LuI::View3D::RENDER::nodraw; // only will show bilboards, not meshes LuI::Mesh3D * myMesh3d = new LuI::Mesh3D(&CubeMesh); // render into bilboards diff --git a/src/app/LuIDemoRubiks.cpp b/src/app/LuIDemoRubiks.cpp deleted file mode 100644 index 7905227..0000000 --- a/src/app/LuIDemoRubiks.cpp +++ /dev/null @@ -1,304 +0,0 @@ -// -// LunokWatch, a open source smartwatch software -// Copyright (C) 2022,2023 Jordi Rubió -// This file is part of LunokWatch. -// -// LunokWatch is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// LunokWatch is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// LunokWatch. If not, see . -// - -#include "../UI/AppLuITemplate.hpp" -#include "LuIDemoRubiks.hpp" -#include "../UI/controls/base/Container.hpp" -#include "../UI/controls/Button.hpp" -#include "../UI/controls/Text.hpp" -#include "../UI/controls/Image.hpp" -#include "../UI/controls/Check.hpp" -#include "../UI/controls/IconMenu.hpp" -#include "../UI/controls/XBM.hpp" -#include "../UI/controls/View3D/View3D.hpp" -#include "../UI/controls/Buffer.hpp" -#include "LogView.hpp" - -#include "../UI/UI.hpp" -#include -using namespace LuI; -#include "../resources.hpp" -#include "../static/img_checkboard_16.c" -#include "sys/param.h" -//#include "../tool/Cuboid001.c" - -extern TFT_eSPI * tft; - -LuIExperimentRubiksApplication::~LuIExperimentRubiksApplication() { - if ( nullptr != texture ) { - if ( texture->created() ) { texture->deleteSprite(); } - delete texture; - texture=nullptr; - } -} - -LuIExperimentRubiksApplication::LuIExperimentRubiksApplication() { - directDraw=false; // disable direct draw meanwhile build the UI - // fill view with background color - canvas->fillSprite(TFT_BLACK); // use theme colors - - /// create root container with two slots horizontal - Container * screen = new Container(LuI_Horizontal_Layout,2); - // bottom buttons container - Container * bottomButtonContainer = new Container(LuI_Vertical_Layout,2); - - // main view space - Container * viewContainer = new Container(LuI_Horizontal_Layout,1); - //viewContainer->border=10; - // if use quota, all the slot quotas must sum equal the total number of elements - // example: default quota in 2 controls result 50/50% of view space with 1.0 of quota everyone (2.0 in total) - - screen->AddChild(viewContainer,1.68); - // add bottom button bar shirnked - screen->AddChild(bottomButtonContainer,0.32); - - // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); - backButton->border=10; - backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap - // load icon in XBM format - XBM * backButtonIcon = new XBM(img_backscreen_24_width,img_backscreen_24_height,img_backscreen_24_bits); - // put the icon inside the button - backButton->AddChild(backButtonIcon); - // shrink button to left and empty control oversized (want button on left bottom) - bottomButtonContainer->AddChild(backButton,0.35); - bottomButtonContainer->AddChild(nullptr,1.65); - - - texture = new TFT_eSprite(tft); - texture->setColorDepth(16); - texture->createSprite(img_checkboard_16.width,img_checkboard_16.height); - texture->setSwapBytes(true); - texture->pushImage(0,0,img_checkboard_16.width,img_checkboard_16.height,(uint16_t *)img_checkboard_16.pixel_data); - - // here the main view - LuI::View3D * view3DTest1 = new LuI::View3D(); - view3DTest1->RenderMode=LuI::View3D::RENDER::FULL; // only will show bilboards, not meshes - - float cubeSize=38; - // fake center cube on 0,0,0 - LuI::Mesh3D * cube0 = new LuI::Mesh3D(&CuboidMesh); - cube0->Translate({0,0,0}); - cube0->Rotate({0,0,0}); - view3DTest1->AddMesh3D(cube0); -/* -// cross - LuI::Mesh3D * cube1 = new LuI::Mesh3D(&CubeMesh); - cube1->Translate({cubeSize,0,0}); - view3DTest1->AddMesh3D(cube1); - - LuI::Mesh3D * cube2 = new LuI::Mesh3D(&CubeMesh); - cube2->Translate({cubeSize*-1,0,0}); - view3DTest1->AddMesh3D(cube2); - - LuI::Mesh3D * cube3 = new LuI::Mesh3D(&CubeMesh); - cube3->Translate({0,cubeSize,0}); - view3DTest1->AddMesh3D(cube3); - - LuI::Mesh3D * cube4 = new LuI::Mesh3D(&CubeMesh); - cube4->Translate({0,cubeSize*-1,0}); - view3DTest1->AddMesh3D(cube4); - -//center ring - LuI::Mesh3D * cube5 = new LuI::Mesh3D(&CubeMesh); - cube5->Translate({0,0,cubeSize}); - view3DTest1->AddMesh3D(cube5); - - LuI::Mesh3D * cube6 = new LuI::Mesh3D(&CubeMesh); - cube6->Translate({0,0,cubeSize*-1}); - view3DTest1->AddMesh3D(cube6); - - LuI::Mesh3D * cube7 = new LuI::Mesh3D(&CubeMesh); - cube7->Translate({cubeSize,0,cubeSize*-1}); - view3DTest1->AddMesh3D(cube7); - - LuI::Mesh3D * cube8 = new LuI::Mesh3D(&CubeMesh); - cube8->Translate({cubeSize,0,cubeSize}); - view3DTest1->AddMesh3D(cube8); - - LuI::Mesh3D * cube9 = new LuI::Mesh3D(&CubeMesh); - cube9->Translate({cubeSize*-1,0,cubeSize*-1}); - view3DTest1->AddMesh3D(cube9); - - LuI::Mesh3D * cube10 = new LuI::Mesh3D(&CubeMesh); - cube10->Translate({cubeSize*-1,0,cubeSize}); - view3DTest1->AddMesh3D(cube10); - -// down - - LuI::Mesh3D * cube11 = new LuI::Mesh3D(&CubeMesh); - cube11->Translate({0,cubeSize,cubeSize}); - view3DTest1->AddMesh3D(cube11); - - LuI::Mesh3D * cube12 = new LuI::Mesh3D(&CubeMesh); - cube12->Translate({0,cubeSize,cubeSize*-1}); - view3DTest1->AddMesh3D(cube12); - - LuI::Mesh3D * cube13 = new LuI::Mesh3D(&CubeMesh); - cube13->Translate({cubeSize,cubeSize,cubeSize*-1}); - view3DTest1->AddMesh3D(cube13); - - LuI::Mesh3D * cube14 = new LuI::Mesh3D(&CubeMesh); - cube14->Translate({cubeSize,cubeSize,cubeSize}); - view3DTest1->AddMesh3D(cube14); - - LuI::Mesh3D * cube15 = new LuI::Mesh3D(&CubeMesh); - cube15->Translate({cubeSize*-1,cubeSize,cubeSize*-1}); - view3DTest1->AddMesh3D(cube15); - - LuI::Mesh3D * cube16 = new LuI::Mesh3D(&CubeMesh); - cube16->Translate({cubeSize*-1,cubeSize,cubeSize}); - view3DTest1->AddMesh3D(cube16); - - // taps - LuI::Mesh3D * cube17 = new LuI::Mesh3D(&CubeMesh); - cube17->Translate({cubeSize,cubeSize,0}); - view3DTest1->AddMesh3D(cube17); - - LuI::Mesh3D * cube18 = new LuI::Mesh3D(&CubeMesh); - cube18->Translate({cubeSize*-1,cubeSize,0}); - view3DTest1->AddMesh3D(cube18); - -// up - - LuI::Mesh3D * cube19 = new LuI::Mesh3D(&CubeMesh); - cube19->Translate({0,cubeSize*-1,cubeSize}); - view3DTest1->AddMesh3D(cube19); - - LuI::Mesh3D * cube20 = new LuI::Mesh3D(&CubeMesh); - cube20->Translate({0,cubeSize*-1,cubeSize*-1}); - view3DTest1->AddMesh3D(cube20); - - LuI::Mesh3D * cube21 = new LuI::Mesh3D(&CubeMesh); - cube21->Translate({cubeSize,cubeSize*-1,cubeSize*-1}); - view3DTest1->AddMesh3D(cube21); - - - - LuI::Mesh3D * cube22 = new LuI::Mesh3D(&CubeMesh); - cube22->Translate({cubeSize,cubeSize*-1,cubeSize}); - view3DTest1->AddMesh3D(cube22); - - LuI::Mesh3D * cube23 = new LuI::Mesh3D(&CubeMesh); - cube23->Translate({cubeSize*-1,cubeSize*-1,cubeSize*-1}); - view3DTest1->AddMesh3D(cube23); - - LuI::Mesh3D * cube24 = new LuI::Mesh3D(&CubeMesh); - cube24->Translate({cubeSize*-1,cubeSize*-1,cubeSize}); - view3DTest1->AddMesh3D(cube24); - - // taps - LuI::Mesh3D * cube25 = new LuI::Mesh3D(&CubeMesh); - cube25->Translate({cubeSize,cubeSize*-1,0}); - view3DTest1->AddMesh3D(cube25); - - LuI::Mesh3D * cube26 = new LuI::Mesh3D(&CubeMesh); - cube26->Translate({cubeSize*-1,cubeSize*-1,0}); - view3DTest1->AddMesh3D(cube26); - */ - - view3DTest1->SetGlobalLocation({ 0,0,0 }); - //view3DTest1->SetGlobalScale(0.025); - view3DTest1->SetBackgroundColor(TFT_BLACK); //ThCol(background); - view3DTest1->stepCallbackParam=view3DTest1; - view3DTest1->stepCallback=[&](void * obj){ // called when data refresh is done (before render) - LuI::View3D * self=(LuI::View3D *)obj; - static int rotationDeg=359; - static float scale=0.1; - static float scaleIncrement=0.05; - static float xLocation=-100; - scale+=scaleIncrement; - if ( scale > 3.5 ) { scaleIncrement*=-1; } - else if ( scale < 0.1 ) { scaleIncrement*=-1; } - rotationDeg-=5; - if ( rotationDeg > 359 ) { rotationDeg-=360; } - else if ( rotationDeg < 0 ) { rotationDeg+=360; } - self->SetGlobalLocation({0,xLocation,0}); - //self->SetGlobalRotation({0,float(rotationDeg),0}); - //self->mesh[0]->Translate({xLocation,0,0}); - xLocation+=5.0; - if ( xLocation > 200 ) { xLocation = -100; } - self->dirty=true; // mark control as dirty (forces redraw) - }; - /* no background - view3DTest1->beforeRenderCallbackParam=view3DTest1; - view3DTest1->beforeRenderCallback=[&](void * obj, void *canvas){ // called when data refresh is done (before render) - LuI::View3D * self=(LuI::View3D *)obj; // recover the view3DTest0 - TFT_eSprite * myView=(TFT_eSprite *)canvas; // recover the view3DTest0 - myView->setSwapBytes(true); - myView->pushImage(0,0,img_brokenMoon.width,img_brokenMoon.height,(const uint16_t *)img_brokenMoon.pixel_data); - myView->setSwapBytes(false); - }; - */ - // post-render - /* - view3DTest1->polygonCallbackParam=view3DTest1; - view3DTest1->polygonCallback=[&](void * obj, void *canvas, void * faceData) { - LuI::View3D * self=(LuI::View3D *)obj; // recover the view3DTest0 - TFT_eSprite * myView=(TFT_eSprite *)canvas; // recover the view3DTest0 - OrderedFace3D * face=(OrderedFace3D*)faceData; // get face data - - TransformationMatrix transform { 2,0,0,2 }; // default flat - //@TODO do something with the polygon vertex and get the transform - - //float polyArea = area(face->p0x,face->p0y,face->p1x,face->p1y,face->p2x,face->p2y); - //float scaleValue=(polyArea/1000)*2; // is a triangle, double is a square - //lLog("Scale ratio: %f\n",scaleValue); - int16_t minX = MIN(face->p0x,face->p1x); - minX = MIN(minX,face->p2x); - int16_t maxX = MAX(face->p0x,face->p1x); - maxX = MAX(maxX,face->p2x); - - int16_t minY = MIN(face->p0y,face->p1y); - minY = MIN(minY,face->p2y); - int16_t maxY = MAX(face->p0y,face->p1y); - maxY = MAX(maxY,face->p2y); - // A/D Scale - // B/C Rotate - transform.b = ((float(minX)/float(maxX))*2)-1.0; - transform.c = ((float(minY)/float(maxY))*2)-1.0; - //lLog("Transform A: %f\n",transform.a); - //lLog("Transform C: %f\n",transform.c); - - TFT_eSprite * finalImage = ShearSprite(texture,transform); - int16_t drawOffsetX = ((face->p0x+face->p1x+face->p2x)/3)-(finalImage->width()/2); - int16_t drawOffsetY = ((face->p0y+face->p1y+face->p2y)/3)-(finalImage->height()/2); - for ( int y=0;yheight();y++) { - for ( int x=0;xwidth();x++) { - uint16_t pixColor = finalImage->readPixel(x,y); - if ( TFT_PINK == pixColor ) { continue; } - int fx=drawOffsetX+x; - int fy=drawOffsetY+y; - bool validPix = isInside(fx,fy,face->p0x,face->p0y, - face->p1x,face->p1y, - face->p2x,face->p2y); - if ( validPix ) { myView->drawPixel(fx,fy,pixColor); } - } - } - finalImage->deleteSprite(); - delete finalImage; - }; - */ - - viewContainer->AddChild(view3DTest1); - - AddChild(screen); - directDraw=true; // allow controls to direct redraw itself instead of push whole view Sprite - // Thats all! the app is running -} diff --git a/src/app/LuIDemoRubiks.hpp b/src/app/LuIDemoRubiks.hpp deleted file mode 100644 index 094928c..0000000 --- a/src/app/LuIDemoRubiks.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// -// LunokWatch, a open source smartwatch software -// Copyright (C) 2022,2023 Jordi Rubió -// This file is part of LunokWatch. -// -// LunokWatch is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// LunokWatch is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// LunokWatch. If not, see . -// - -#ifndef __LUNOKIOT__APPLICATION__LUI_EXPERIMENT_RUBIKS__ -#define __LUNOKIOT__APPLICATION__LUI_EXPERIMENT_RUBIKS__ - -#include "../UI/AppLuITemplate.hpp" -//#include "../UI/controls/View3D/View3D.hpp" -#include - -class LuIExperimentRubiksApplication : public TemplateLuIApplication { - public: - TFT_eSprite * texture=nullptr; - LuIExperimentRubiksApplication(); - ~LuIExperimentRubiksApplication(); - const char *AppName() override { return "LuI Demo Rubik's cube"; }; -}; - -#endif diff --git a/src/app/LuIGameOfLife.cpp b/src/app/LuIGameOfLife.cpp index 3a9449e..bc158cc 100644 --- a/src/app/LuIGameOfLife.cpp +++ b/src/app/LuIGameOfLife.cpp @@ -31,11 +31,18 @@ #include "LogView.hpp" #include "../UI/UI.hpp" +#ifdef LILYGO_DEV #include +extern TFT_eSPI * tft; +#elif defined(M5_DEV) +#include +extern M5Display * tft; +#endif + using namespace LuI; #include "../resources.hpp" -extern TFT_eSPI * tft; + const uint8_t pixelSize=20; bool gameStart=false; @@ -62,7 +69,7 @@ LuIDemoGameOfLifeApplication::LuIDemoGameOfLifeApplication() { screen->AddChild(bottomButtonContainer,0.32); // add back button to dismiss - backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=10; backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap // load icon in XBM format @@ -145,7 +152,7 @@ LuIDemoGameOfLifeApplication::LuIDemoGameOfLifeApplication() { viewContainer->AddChild(gameOfLife); - Button *launchButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + LuI::Button *launchButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); launchButton->border=10; launchButton->AddChild(new Text((char*)"Start/Stop")); launchButton->tapCallbackParam=gameOfLife; diff --git a/src/app/LuIMainMenu.cpp b/src/app/LuIMainMenu.cpp index 6fa0b9f..fc8b254 100644 --- a/src/app/LuIMainMenu.cpp +++ b/src/app/LuIMainMenu.cpp @@ -25,7 +25,7 @@ #include "../UI/controls/Text.hpp" #include "LogView.hpp" -#include +//#include #include "../resources.hpp" @@ -45,7 +45,7 @@ //#include "ScreenTest.hpp" #include "KnowLocations.hpp" #include "LuiGamesMenu.hpp" -//#include "LuaLauncher.hpp" +#include "LuaLauncher.hpp" //#include "FileBrowser.hpp" #ifdef LUNOKIOT_LILYGO_TWATCH_BUTTON_FAULTY #include "Lamp.hpp" @@ -55,10 +55,19 @@ //#include "Dungeon/Dungeon.hpp" //#include "LuiChess.hpp" #include "MostUsedApps.hpp" +#include "Provisioning2.hpp" +#include "FreehandKeyboardSetup.hpp" +#include "NuKeyboard.hpp" + using namespace LuI; const IconMenuEntry LuIMenuItems[] = { {"Back", img_mainmenu_back_bits, img_mainmenu_back_height, img_mainmenu_back_width, [](IGNORE_PARAM) { LaunchWatchface(); } }, +// {"About",img_mainmenu_about_bits, img_mainmenu_about_height, img_mainmenu_about_width, [](IGNORE_PARAM) { LaunchApplication(new AboutApplication()); } }, +// {"Prov", img_mainmenu_provisioning_bits, img_mainmenu_provisioning_height, img_mainmenu_provisioning_width, [](void *unused) { LaunchApplication(new Provisioning2Application()); } }, + +// {"NuKeyb",img_mainmenu_keyboard_bits, img_mainmenu_keyboard_height, img_mainmenu_keyboard_width, [](void *unused) { LaunchApplication(new NuKeyboardApplication()); } }, +// {"Keyboard",img_mainmenu_keyboard_bits, img_mainmenu_keyboard_height, img_mainmenu_keyboard_width, [](void *unused) { LaunchApplication(new FreeHandKeyboardSetupApplication()); } }, // {"MostUsed",img_mainmenu_debug_bits, img_mainmenu_debug_height, img_mainmenu_debug_width, [](IGNORE_PARAM) { LaunchApplication(new LuIMostUsedApplication()); } }, // {"Chess",img_mainmenu_chess_bits, img_mainmenu_chess_height, img_mainmenu_chess_width, [](IGNORE_PARAM) { LaunchApplication(new ChessApplication()); } }, @@ -72,7 +81,7 @@ const IconMenuEntry LuIMenuItems[] = { // {"Prov", img_mainmenu_provisioning_bits, img_mainmenu_provisioning_height, img_mainmenu_provisioning_width, [](void *unused) { LaunchApplication(new Provisioning2Application()); } }, -// {"Lua",img_mainmenu_debug_bits, img_mainmenu_debug_height, img_mainmenu_debug_width, [&](IGNORE_PARAM) { LaunchApplication(new LuaLauncher(HelloworldLuaScript)); } }, +// {"Lua",img_mainmenu_debug_bits, img_mainmenu_debug_height, img_mainmenu_debug_width, [](IGNORE_PARAM) { LaunchApplication(new LuaLauncher(HelloworldLuaScript)); } }, // {"Screen",img_mainmenu_debug_bits, img_mainmenu_debug_height, img_mainmenu_debug_width, [&](IGNORE_PARAM) { LaunchApplication(new ScreenTestApplication()); } }, // {"Rubik's",img_mainmenu_debug_bits, img_mainmenu_debug_height, img_mainmenu_debug_width, [](IGNORE_PARAM) { LaunchApplication(new LuIExperimentRubiksApplication()); } }, // {"LuIDemos",img_mainmenu_debug_bits, img_mainmenu_debug_height, img_mainmenu_debug_width, [](IGNORE_PARAM) { LaunchApplication(new LuiExperimentApplication()); } }, diff --git a/src/app/LuIRotation.cpp b/src/app/LuIRotation.cpp index e3605ee..4f3d8e0 100644 --- a/src/app/LuIRotation.cpp +++ b/src/app/LuIRotation.cpp @@ -29,14 +29,19 @@ #include "../system/Datasources/kvo.hpp" #include "../system/SystemEvents.hpp" #include -#include +#ifdef LILYGO_DEV +#include +extern TFT_eSPI * tft; +#elif defined(M5_DEV) +#include +extern M5Display * tft; +#endif using namespace LuI; extern uint8_t bmaRotation; extern SemaphoreHandle_t UISemaphore; -extern TFT_eSPI * tft; LuIRotateApplication::~LuIRotateApplication() { if ( nullptr != ScreenRotateEvent ) { delete ScreenRotateEvent; } @@ -61,7 +66,8 @@ uint8_t LuIRotateApplication::BMAtoTFTOrientation(uint8_t bma) { } void LuIRotateApplication::CleanPush(TFT_eSprite * frame, float angle) { const uint32_t frameDelay=20; - //tft->fillScreen(TFT_BLACK); + + #ifdef LILYGO_DEV int16_t minX,minY,maxX,maxY; frame->getRotatedBounds(angle,&minX,&minY,&maxX,&maxY); // up @@ -72,6 +78,9 @@ void LuIRotateApplication::CleanPush(TFT_eSprite * frame, float angle) { tft->fillRect(0,maxY,canvas->width(),canvas->height()-maxY,TFT_BLACK); // right tft->fillRect(maxX,minY,canvas->width()-maxX,maxY,TFT_BLACK); + #else + tft->fillScreen(TFT_BLACK); + #endif frame->pushRotated(angle); delay(frameDelay); @@ -139,7 +148,7 @@ LuIRotateApplication::LuIRotateApplication() { screen->AddChild(bottomButtonContainer,0.35); // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); + LuI::Button *backButton = new LuI::Button(LuI_Vertical_Layout,1,NO_DECORATION); backButton->border=10; backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap // load icon in XBM format diff --git a/src/app/LuISettingsMenu.cpp b/src/app/LuISettingsMenu.cpp index 73e38c8..0bdb8db 100644 --- a/src/app/LuISettingsMenu.cpp +++ b/src/app/LuISettingsMenu.cpp @@ -25,7 +25,7 @@ #include "../UI/controls/Text.hpp" #include "LogView.hpp" -#include +//#include #include "../resources.hpp" #include "LuIMainMenu.hpp" diff --git a/src/app/LuITest.cpp b/src/app/LuITest.cpp index 1246a02..79ee880 100644 --- a/src/app/LuITest.cpp +++ b/src/app/LuITest.cpp @@ -31,10 +31,16 @@ #include "LogView.hpp" #include "../UI/UI.hpp" +#ifdef LILYGO_DEV #include +extern TFT_eSPI * tft; +#elif defined(M5_DEV) +#include +extern M5Display * tft; +#endif + using namespace LuI; #include "../resources.hpp" -extern TFT_eSPI * tft; LuITestApplication::LuITestApplication() { lAppLog("BEGIN CONSTRUCTOR HERE\n"); diff --git a/src/app/LuITest.hpp b/src/app/LuITest.hpp index 6e1faa0..990ea8c 100644 --- a/src/app/LuITest.hpp +++ b/src/app/LuITest.hpp @@ -23,7 +23,7 @@ #include "../UI/AppLuITemplate.hpp" #include "../UI/controls/Text.hpp" #include "../UI/controls/View3D/View3D.hpp" -#include +//#include class LuITestApplication : public TemplateLuIApplication { public: diff --git a/src/app/LuiChess.cpp b/src/app/LuiChess.cpp deleted file mode 100644 index fb53c3d..0000000 --- a/src/app/LuiChess.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// -// LunokWatch, a open source smartwatch software -// Copyright (C) 2022,2023 Jordi Rubió -// This file is part of LunokWatch. -// -// LunokWatch is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// LunokWatch is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// LunokWatch. If not, see . -// -#include "../lunokiot_config.hpp" -#include "../UI/AppLuITemplate.hpp" -#include "LuiChess.hpp" -#include "../UI/controls/base/Container.hpp" -#include "../UI/controls/Button.hpp" -#include "../UI/controls/Text.hpp" -#include "../UI/controls/Image.hpp" -#include "../UI/controls/Check.hpp" -#include "../UI/controls/IconMenu.hpp" -#include "../UI/controls/XBM.hpp" -#include "../UI/controls/View3D/View3D.hpp" -#include "../UI/controls/Buffer.hpp" -#include "LogView.hpp" -#include "../UI/UI.hpp" -#include -#include "../UI/widgets/CanvasWidget.hpp" -using namespace LuI; -#include "../resources.hpp" - -//#include "../system/Datasources/database.hpp" -#include "../system/Datasources/perceptron.hpp" - -void ChessApplication::StartGame() { - lAppLog("Start new game!\n"); - boardData->canvas->fillSprite(TFT_BLACK); - // rook, knight, bishop, queen, king, bishop, knight, rook, 8x pawns - - // @TODO DISTINGUISH PLAYER BY COLOR - lAppLog("Pushing pieces...\n"); - // rooks - boardData->canvas->drawPixel(0,0,PIECE_ROOK_COLOR); - boardData->canvas->drawPixel(0,7,PIECE_ROOK_COLOR); - boardData->canvas->drawPixel(7,0,PIECE_ROOK_COLOR); - boardData->canvas->drawPixel(7,7,PIECE_ROOK_COLOR); - - // knight - boardData->canvas->drawPixel(1,0,PIECE_KNIGHT_COLOR); - boardData->canvas->drawPixel(6,0,PIECE_KNIGHT_COLOR); - boardData->canvas->drawPixel(6,7,PIECE_KNIGHT_COLOR); - boardData->canvas->drawPixel(1,7,PIECE_KNIGHT_COLOR); - - // bishop - boardData->canvas->drawPixel(2,0,PIECE_BISHOP_COLOR); - boardData->canvas->drawPixel(5,0,PIECE_BISHOP_COLOR); - boardData->canvas->drawPixel(2,7,PIECE_BISHOP_COLOR); - boardData->canvas->drawPixel(5,7,PIECE_BISHOP_COLOR); - - // queen - boardData->canvas->drawPixel(3,0,PIECE_QUEEN_COLOR); - boardData->canvas->drawPixel(3,7,PIECE_QUEEN_COLOR); - - // king - boardData->canvas->drawPixel(4,0,PIECE_KING_COLOR); - boardData->canvas->drawPixel(4,7,PIECE_KING_COLOR); - - // pawns - boardData->canvas->drawPixel(0,1,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(1,1,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(2,1,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(3,1,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(4,1,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(5,1,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(6,1,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(7,1,PIECE_PAWN_COLOR); - - boardData->canvas->drawPixel(0,6,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(1,6,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(2,6,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(3,6,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(4,6,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(5,6,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(6,6,PIECE_PAWN_COLOR); - boardData->canvas->drawPixel(7,6,PIECE_PAWN_COLOR); - //userBoard->dirty=true; -} - -ChessApplication::ChessApplication() { - directDraw=false; - canvas->fillSprite(ThCol(background)); - Container * screen = new Container(LuI_Horizontal_Layout,2); - // bottom buttons container - Container * bottomButtonContainer = new Container(LuI_Vertical_Layout,2); - // main view space - Container * viewContainer = new Container(LuI_Horizontal_Layout,1); - viewContainer->border=5; - // add back button to dismiss - Button *backButton = new Button(LuI_Vertical_Layout,1,NO_DECORATION); - backButton->border=0; - backButton->tapCallback=[](void * obj){ LaunchWatchface(); }; // callback when tap - // load icon in XBM format - XBM * backButtonIcon = new XBM(img_backscreen_42_width,img_backscreen_42_height,img_backscreen_42_bits); - // put the icon inside the button - backButton->AddChild(backButtonIcon); - // shrink button to left and empty control oversized (want button on left bottom) - bottomButtonContainer->AddChild(backButton,0.3); - boardData = new CanvasWidget(8,8); - userBoard = new Image(TileSize*8,TileSize*8); - StartGame(); - //userBoard->drawPushCallback = [&,this](IGNORE_PARAM) { - lAppLog("Redraw board\n"); - TFT_eSprite * drawCanvas=userBoard->GetBuffer(); - //drawCanvas->fillSprite(ThCol(background)); - drawCanvas->fillSprite(ByteSwap(TFT_GREEN)); - drawCanvas->setTextFont(1); - drawCanvas->setTextSize(3); - drawCanvas->setTextDatum(TL_DATUM); - uint8_t current=0; - int32_t rY=0; - bool whiteTile=true; - for(int y=1;y<8;y++) { - int32_t rX=0; - for(int x=1;x<8;x++) { - uint16_t color = TFT_BLACK; - uint16_t textColor = TFT_WHITE; - if ( whiteTile ) { color=TFT_WHITE; textColor=TFT_BLACK; } - lAppLog("%u Floor Color 0x%04x %d %d\n",current,color,x-1,y-1); - current++; - drawCanvas->fillRect(rX,rY,TileSize,TileSize,color); - drawCanvas->setTextColor(textColor); - uint16_t currentDataColor = boardData->canvas->readPixel(x-1,y-1); - if ( TFT_BLACK != currentDataColor ) { - lAppLog(" Piece Color 0x%04x %d %d\n",currentDataColor,x-1,y-1); - if (PIECE_PAWN_COLOR == currentDataColor ) { drawCanvas->drawString("P",rX,rY); } - else if ( PIECE_ROOK_COLOR == currentDataColor ) { drawCanvas->drawString("R",rX,rY); } - else if (PIECE_KNIGHT_COLOR == currentDataColor ) { drawCanvas->drawString("N",rX,rY); } - else if (PIECE_BISHOP_COLOR == currentDataColor ) { drawCanvas->drawString("B",rX,rY); } - else if (PIECE_QUEEN_COLOR == currentDataColor ) { drawCanvas->drawString("Q",rX,rY); } - else if (PIECE_KING_COLOR == currentDataColor ) { drawCanvas->drawString("K",rX,rY); } - else { drawCanvas->drawString("O",rX,rY); } - } - whiteTile=(!whiteTile); // swap color on every column - rX=TileSize*x; - } - whiteTile=(!whiteTile); // swap color on every line - rY=TileSize*y; - } - drawCanvas->fillCircle(0,0,20,ByteSwap(TFT_RED)); - //}; - viewContainer->AddChild(userBoard); - //userBoard->GetBuffer()->setPivot(20,5); - //canvas->setPivot(canvas->width()/2,canvas->height()/2); - //imageCanvas->setPivot(imageCanvas->width()/2,imageCanvas->height()/2); - //userBoard->GetBuffer()->fillSprite(TFT_GREEN); - screen->AddChild(viewContainer,1.65); - screen->AddChild(bottomButtonContainer,0.35); - - AddChild(screen); - size_t totalAllocations=0; - brain=(Perceptron **)ps_calloc(MAX_PERCEPTRONS,sizeof(Perceptron *)); - totalAllocations+=MAX_PERCEPTRONS*sizeof(Perceptron *); - for (int16_t y=0;y -// This file is part of LunokWatch. -// -// LunokWatch is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// LunokWatch is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// LunokWatch. If not, see . -// - -#ifndef __LUNOKIOT__APPLICATION__GAME_CHESS__ -#define __LUNOKIOT__APPLICATION__GAME_CHESS__ -#include "../UI/UI.hpp" -#include "../UI/widgets/CanvasWidget.hpp" -#include "../UI/controls/Image.hpp" - -#include "../UI/AppLuITemplate.hpp" -#include "../system/Datasources/perceptron.hpp" - -class ChessApplication : public TemplateLuIApplication { - public: - const uint16_t PIECE_PAWN_COLOR=TFT_WHITE; - const uint16_t PIECE_ROOK_COLOR=TFT_RED; - const uint16_t PIECE_KNIGHT_COLOR=TFT_GREEN; - const uint16_t PIECE_BISHOP_COLOR=TFT_BLUE; - const uint16_t PIECE_QUEEN_COLOR=TFT_YELLOW; - const uint16_t PIECE_KING_COLOR=TFT_CYAN; - CanvasWidget * boardData=nullptr; - LuI::Image * userBoard=nullptr; - const uint8_t TileSize=20; - // input layer / hidden layer / output layer - // input: 8x8 to see whole board - // hidden: arbitrary reduction to 32 possibilities - // output: piece selection (16), piece direction (2^3) = 0~6, piece step (2^3) = 0~8 - // rook, knight, bishop, queen, king, bishop, knight, rook, 8x pawns - // https://en.wikipedia.org/wiki/Algebraic_notation_(chess) - const size_t MAX_PERCEPTRONS = (8*8)+32+(16+3+3); - Perceptron **brain; // all of them - void StartGame(); - ~ChessApplication(); - ChessApplication(); - const char *AppName() override { return "Chess"; }; - bool Tick() override; -}; - -#endif diff --git a/src/app/LuiExperiment.cpp b/src/app/LuiExperiment.cpp index 02f3314..30ace11 100644 --- a/src/app/LuiExperiment.cpp +++ b/src/app/LuiExperiment.cpp @@ -30,7 +30,7 @@ #include "../UI/controls/Buffer.hpp" #include "LogView.hpp" #include "../UI/UI.hpp" -#include + using namespace LuI; #include "../resources.hpp" @@ -38,7 +38,7 @@ using namespace LuI; #include "LuIGameOfLife.hpp" #include "LuIDemoMask.hpp" -extern TFT_eSPI * tft; + #include "../../static/img_worldcollide_160.c" diff --git a/src/app/LuiGamesMenu.cpp b/src/app/LuiGamesMenu.cpp index 54816d0..0a6ee01 100644 --- a/src/app/LuiGamesMenu.cpp +++ b/src/app/LuiGamesMenu.cpp @@ -30,7 +30,7 @@ //#include "../system/Datasources/kvo.hpp" //#include "../system/SystemEvents.hpp" -#include +//#include #include "../resources.hpp" #include "LuIMainMenu.hpp" diff --git a/src/app/LunoNoid.cpp b/src/app/LunoNoid.cpp index ec93882..5ca6100 100644 --- a/src/app/LunoNoid.cpp +++ b/src/app/LunoNoid.cpp @@ -17,12 +17,19 @@ // LunokWatch. If not, see . // #include "LunoNoid.hpp" + +#ifdef LILYGO_DEV #include -//#include +extern TFT_eSPI * tft; +extern TTGOClass *ttgo; +#elif defined(M5_DEV) +#include +extern M5Display * tft; +#endif + #include "LogView.hpp" // for lLog functions #include extern SemaphoreHandle_t I2cMutex; -extern TTGOClass *ttgo; #include "../static/img_nanonoid_level69.c" #include "../static/img_nanonoid_level4.c" #include "../static/img_nanonoid_level3.c" @@ -41,7 +48,8 @@ const uint16_t * LunoNoidLevelData[] = { LunoNoidGameApplication::~LunoNoidGameApplication() { if ( nullptr != enemyMap ) { - if ( enemyMap->created() ) { enemyMap->deleteSprite(); } + //if ( enemyMap->created() ) { enemyMap->deleteSprite(); } + enemyMap->deleteSprite(); delete enemyMap; enemyMap=nullptr; } @@ -69,10 +77,11 @@ LunoNoidGameApplication::LunoNoidGameApplication() { void LunoNoidGameApplication::GatherButtons() { // launch ball on touch if ( touched ) { stickyBall=false; } + #ifdef LILYGO_DEV // get accel dta - Accel acc; BaseType_t done = xSemaphoreTake(I2cMutex, LUNOKIOT_EVENT_FAST_TIME_TICKS); if (pdTRUE != done) { return; } + Accel acc; bool res = ttgo->bma->getAccel(acc); xSemaphoreGive(I2cMutex); rollval = atan2(acc.x,acc.z) * RAD_TO_DEG; @@ -97,6 +106,8 @@ void LunoNoidGameApplication::GatherButtons() { if ( 0 > pitchval ) { pitchval+=360; } // dirty module else if ( pitchval > 360 ) { pitchval-=360; } //lLog("PITCH: %f ROLL: %f\n",pitchval,rollval); + #endif + } bool LunoNoidGameApplication::Tick() { diff --git a/src/app/Provisioning2.cpp b/src/app/Provisioning2.cpp index 4e225bb..3d0e3d7 100644 --- a/src/app/Provisioning2.cpp +++ b/src/app/Provisioning2.cpp @@ -213,7 +213,7 @@ void Provisioning2Application::GenerateQRCode() { } const int32_t radius = 28; - uint16_t iconColor = canvas->color24to16(0x0a0f1e); + uint16_t iconColor = Get16BitFromRGB(0x0a0f1e); // border currentQRRendered->fillCircle((currentQRRendered->width()/2),(currentQRRendered->height()/2),radius, TFT_WHITE); // background @@ -320,7 +320,7 @@ Provisioning2Application::Provisioning2Application() { } WiFi.onEvent(Provisioning2_SysProvEvent); - },img_provisioning_48_bits,img_provisioning_48_height,img_provisioning_48_width,TFT_WHITE,canvas->color24to16(0x2347bc)); + },img_provisioning_48_bits,img_provisioning_48_height,img_provisioning_48_width,TFT_WHITE,Get16BitFromRGB(0x2347bc)); startProvBtn->taskStackSize=LUNOKIOT_PROVISIONING_STACK_SIZE; Tick(); } @@ -354,7 +354,7 @@ bool Provisioning2Application::Tick() { startProvBtn->Interact(touched,touchX,touchY); wifiOrBLE->Interact(touched,touchX,touchY); if (millis() > nextRedraw ) { - canvas->fillSprite(canvas->color24to16(0x212121)); + canvas->fillSprite(Get16BitFromRGB(0x212121)); btnBack->DrawTo(canvas); clearProvBtn->DrawTo(canvas); startProvBtn->DrawTo(canvas); diff --git a/src/app/Provisioning2.hpp b/src/app/Provisioning2.hpp index 97a81bb..327ee3a 100644 --- a/src/app/Provisioning2.hpp +++ b/src/app/Provisioning2.hpp @@ -21,7 +21,7 @@ #define __LUNOKIOT__PROVISIONING2_APP__ #include -#include +//#include #include "../UI/AppTemplate.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" #include "../UI/widgets/SwitchWidget.hpp" diff --git a/src/app/SetDate.cpp b/src/app/SetDate.cpp index e774ea4..87089f6 100644 --- a/src/app/SetDate.cpp +++ b/src/app/SetDate.cpp @@ -50,7 +50,7 @@ SetDateApplication::SetDateApplication() { month->InternalRedraw(); backButton=new ButtonImageXBMWidget(5,TFT_HEIGHT-69,64,64,[&,this](void *unused){ LaunchWatchface(); - },img_back_32_bits,img_back_32_height,img_back_32_width,TFT_WHITE,canvas->color24to16(0x353e45),false); + },img_back_32_bits,img_back_32_height,img_back_32_width,TFT_WHITE,Get16BitFromRGB(0x353e45),false); setDateButton=new ButtonImageXBMWidget(5+64+15,TFT_HEIGHT-69,64,80,[&,this](void *unused){ lAppLog("SetTime: RTC and localtime sync\n"); RTC_Date test = ttgo->rtc->getDateTime(); @@ -62,10 +62,10 @@ SetDateApplication::SetDateApplication() { currentMonth = month->selectedValue -1; ntpSyncDone=true; - },img_calendar_32_bits,img_calendar_32_height,img_calendar_32_width,TFT_WHITE,canvas->color24to16(0x353e45)); + },img_calendar_32_bits,img_calendar_32_height,img_calendar_32_width,TFT_WHITE,Get16BitFromRGB(0x353e45)); showTimeButton=new ButtonImageXBMWidget(TFT_WIDTH-69,TFT_HEIGHT-69,64,64,[&,this](void *unused){ LaunchApplication(new SetTimeApplication()); - },img_settime_32_bits,img_settime_32_height,img_settime_32_width,TFT_WHITE,canvas->color24to16(0x353e45),false); + },img_settime_32_bits,img_settime_32_height,img_settime_32_width,TFT_WHITE,Get16BitFromRGB(0x353e45),false); Tick(); } bool SetDateApplication::Tick() { @@ -79,7 +79,7 @@ bool SetDateApplication::Tick() { //} if (millis() > nextRedraw ) { - canvas->fillSprite(canvas->color24to16(0x212121)); + canvas->fillSprite(Get16BitFromRGB(0x212121)); day->DrawTo(canvas); month->DrawTo(canvas); setDateButton->DrawTo(canvas); diff --git a/src/app/SetTime.cpp b/src/app/SetTime.cpp index cb44e9f..2fb321d 100644 --- a/src/app/SetTime.cpp +++ b/src/app/SetTime.cpp @@ -56,7 +56,7 @@ SetTimeApplication::SetTimeApplication() { minute->InternalRedraw(); backButton=new ButtonImageXBMWidget(5,TFT_HEIGHT-69,64,64,[&,this](void *unused){ LaunchWatchface(); - },img_back_32_bits,img_back_32_height,img_back_32_width,TFT_WHITE,canvas->color24to16(0x353e45),false); + },img_back_32_bits,img_back_32_height,img_back_32_width,TFT_WHITE,Get16BitFromRGB(0x353e45),false); setTimeButton=new ButtonImageXBMWidget(5+64+15,TFT_HEIGHT-69,64,80,[&,this](void *unused){ //Serial.println("SetTime: RTC and localtime sync"); RTC_Date test = ttgo->rtc->getDateTime(); @@ -68,10 +68,10 @@ SetTimeApplication::SetTimeApplication() { currentMin = minute->selectedValue; ntpSyncDone = true; - },img_settime_32_bits,img_settime_32_height,img_settime_32_width,TFT_WHITE,canvas->color24to16(0x353e45)); + },img_settime_32_bits,img_settime_32_height,img_settime_32_width,TFT_WHITE,Get16BitFromRGB(0x353e45)); showDateButton=new ButtonImageXBMWidget(TFT_WIDTH-69,TFT_HEIGHT-69,64,64,[&,this](void *unused){ LaunchApplication(new SetDateApplication()); - },img_calendar_32_bits,img_calendar_32_height,img_calendar_32_width,TFT_WHITE,canvas->color24to16(0x353e45),false); + },img_calendar_32_bits,img_calendar_32_height,img_calendar_32_width,TFT_WHITE,Get16BitFromRGB(0x353e45),false); Tick(); } bool SetTimeApplication::Tick() { @@ -89,7 +89,7 @@ bool SetTimeApplication::Tick() { // nextSelectorTick=millis()+(1000/4); //} if (millis() > nextRedraw ) { - canvas->fillSprite(canvas->color24to16(0x212121)); + canvas->fillSprite(Get16BitFromRGB(0x212121)); hour->DrawTo(canvas); minute->DrawTo(canvas); setTimeButton->DrawTo(canvas); diff --git a/src/app/SetTime.hpp b/src/app/SetTime.hpp index 9a526f2..42fcf67 100644 --- a/src/app/SetTime.hpp +++ b/src/app/SetTime.hpp @@ -21,7 +21,7 @@ #define __LUNOKIOT__SET_TIME_APP__ #include -#include +//#include #include "../system/Application.hpp" #include "../UI/widgets/CanvasWidget.hpp" #include "../UI/widgets/ValueSelector.hpp" diff --git a/src/app/SetTimeZone.cpp b/src/app/SetTimeZone.cpp index 32f27fe..c5e2f3b 100644 --- a/src/app/SetTimeZone.cpp +++ b/src/app/SetTimeZone.cpp @@ -42,16 +42,16 @@ SetTimeZoneApplication::~SetTimeZoneApplication() { SetTimeZoneApplication::SetTimeZoneApplication() { btnBack=new ButtonImageXBMWidget(5,TFT_HEIGHT-69,64,64,[&,this](void *unused){ LaunchWatchface(); - },img_back_32_bits,img_back_32_height,img_back_32_width,TFT_WHITE,canvas->color24to16(0x353e45),false); + },img_back_32_bits,img_back_32_height,img_back_32_width,TFT_WHITE,Get16BitFromRGB(0x353e45),false); - switchDaylight=new SwitchWidget(10,10, [&,this](void *unused) { }, canvas->color24to16(0x555f68)); + switchDaylight=new SwitchWidget(10,10, [&,this](void *unused) { }, Get16BitFromRGB(0x555f68)); btnSetGMT=new ButtonImageXBMWidget(70,TFT_HEIGHT-69,64,110,[&,this](void *unused){ lAppLog("Summer time: '%s', GMT: %+d\n",(switchDaylight->switchEnabled?"yes":"no"),timezoneGMTSelector->selectedValue); - },img_timezone_32_bits,img_timezone_32_height,img_timezone_32_width,TFT_WHITE, canvas->color24to16(0x353e45)); + },img_timezone_32_bits,img_timezone_32_height,img_timezone_32_width,TFT_WHITE, Get16BitFromRGB(0x353e45)); timezoneGMTSelector = new ValueSelector(120,60,100,115,-12,12, - canvas->color24to16(0x212121),true); + Get16BitFromRGB(0x212121),true); bool daylight = LoT().GetSettings()->GetInt(SystemSettings::SettingKey::Daylight); long timezone = LoT().GetSettings()->GetInt(SystemSettings::SettingKey::TimeZone); lAppLog("Summer time: '%s', GMT: %+d\n",(daylight?"yes":"no"),timezone); @@ -71,7 +71,7 @@ bool SetTimeZoneApplication::Tick() { // nextSelectorTick=millis()+(1000/4); //} if (millis() > nextRedraw ) { - canvas->fillSprite(canvas->color24to16(0x212121)); + canvas->fillSprite(Get16BitFromRGB(0x212121)); btnBack->DrawTo(canvas); switchDaylight->DrawTo(canvas); timezoneGMTSelector->DrawTo(canvas); diff --git a/src/app/SetTimeZone.hpp b/src/app/SetTimeZone.hpp index e6fd26f..5d5ff91 100644 --- a/src/app/SetTimeZone.hpp +++ b/src/app/SetTimeZone.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__SETTIMEZONE_APP__ #define __LUNOKIOT__SETTIMEZONE_APP__ #include -#include +//#include #include "../system/Application.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/Steps.hpp b/src/app/Steps.hpp index bb32ec3..ee74d83 100644 --- a/src/app/Steps.hpp +++ b/src/app/Steps.hpp @@ -20,7 +20,7 @@ #ifndef __LUNOKIOT__STEPS_APP__ #define __LUNOKIOT__STEPS_APP__ #include -#include +//#include #include "../UI/AppTemplate.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/Stopwatch.hpp b/src/app/Stopwatch.hpp index 9b8da36..9d546b2 100644 --- a/src/app/Stopwatch.hpp +++ b/src/app/Stopwatch.hpp @@ -24,7 +24,7 @@ */ #include -#include +//#include #include "../UI/AppTemplate.hpp" #include "../UI/widgets/ButtonImageXBMWidget.hpp" diff --git a/src/app/Theme.cpp b/src/app/Theme.cpp index c1c268b..6830826 100644 --- a/src/app/Theme.cpp +++ b/src/app/Theme.cpp @@ -90,13 +90,13 @@ bool ThemeApplication::Tick() { themeButton[i]->Interact(touched,touchX,touchY); themeButton[i]->canvas->fillSprite(CanvasWidget::MASK_COLOR); - themeButton[i]->canvas->fillCircle(40,40,30,canvas->color24to16(AllColorPaletes[i].colors[0])); + themeButton[i]->canvas->fillCircle(40,40,30,Get16BitFromRGB(AllColorPaletes[i].colors[0])); int offColor = 0; for(int y=20;y<=60;y+=20) { for(int x=20;x<=60;x+=20) { offColor++; if ( offColor >= AllColorPaletes[i].size ) { break; } - themeButton[i]->canvas->fillCircle(x,y,9,canvas->color24to16(AllColorPaletes[i].colors[offColor])); + themeButton[i]->canvas->fillCircle(x,y,9,Get16BitFromRGB(AllColorPaletes[i].colors[offColor])); } } diff --git a/src/app/Watchface2.cpp b/src/app/Watchface2.cpp index f5663da..f590b98 100644 --- a/src/app/Watchface2.cpp +++ b/src/app/Watchface2.cpp @@ -271,9 +271,9 @@ Watchface2Application::Watchface2Application() { // initialize corner buttons const int16_t ButtonSize = 45; const int16_t MenuButtonSize = 50; - bottomLeftButton = new ButtonImageXBMWidget(0, canvas->height()-ButtonSize, ButtonSize, ButtonSize, [](IGNORE_PARAM) { LaunchApplication(new BatteryApplication()); },img_battery_16_bits,img_battery_16_height,img_battery_16_width,tft->color24to16(0x3565ff),TFT_BLACK,false); - topLeftButton = new ButtonImageXBMWidget(0, 0, ButtonSize, ButtonSize, [](IGNORE_PARAM) { LaunchApplication(new SettingsApplication()); },img_settings_16_bits,img_settings_16_height,img_settings_16_width,tft->color24to16(0x3565ff),TFT_BLACK,false); - topRightButton = new ButtonImageXBMWidget(canvas->width()-ButtonSize, 0, ButtonSize, ButtonSize, [](IGNORE_PARAM) { LaunchApplication(new StepsApplication()); },img_steps_16_bits,img_steps_16_height,img_steps_16_width,tft->color24to16(0x3565ff),TFT_BLACK,false); + bottomLeftButton = new ButtonImageXBMWidget(0, canvas->height()-ButtonSize, ButtonSize, ButtonSize, [](IGNORE_PARAM) { LaunchApplication(new BatteryApplication()); },img_battery_16_bits,img_battery_16_height,img_battery_16_width,Get16BitFromRGB(0x3565ff),TFT_BLACK,false); + topLeftButton = new ButtonImageXBMWidget(0, 0, ButtonSize, ButtonSize, [](IGNORE_PARAM) { LaunchApplication(new SettingsApplication()); },img_settings_16_bits,img_settings_16_height,img_settings_16_width,Get16BitFromRGB(0x3565ff),TFT_BLACK,false); + topRightButton = new ButtonImageXBMWidget(canvas->width()-ButtonSize, 0, ButtonSize, ButtonSize, [](IGNORE_PARAM) { LaunchApplication(new StepsApplication()); },img_steps_16_bits,img_steps_16_height,img_steps_16_width,Get16BitFromRGB(0x3565ff),TFT_BLACK,false); bottomRightButton = new ButtonImageXBMWidget(canvas->width()-MenuButtonSize, canvas->height()-MenuButtonSize, MenuButtonSize, MenuButtonSize, [](IGNORE_PARAM) { LaunchApplication(new LuIMainMenuApplication()); },img_home_32_bits,img_home_32_height,img_home_32_width,TFT_DARKGREY,TFT_BLACK,false); // generate proceduraly the backface (no bitmap using space on flash) @@ -297,14 +297,14 @@ Watchface2Application::Watchface2Application() { } // Buttons - outherSphere->canvas->fillRect(0, 0, middleX, middleY, tft->color24to16(0x000408)); - outherSphere->canvas->fillRect(middleX, 0, middleX, middleY, tft->color24to16(0x000408)); - outherSphere->canvas->fillRect(0, middleY, middleX, middleY, tft->color24to16(0x000408)); - outherSphere->canvas->fillRect(middleX, middleY, middleX, middleY, tft->color24to16(0x102048)); + outherSphere->canvas->fillRect(0, 0, middleX, middleY, Get16BitFromRGB(0x000408)); + outherSphere->canvas->fillRect(middleX, 0, middleX, middleY, Get16BitFromRGB(0x000408)); + outherSphere->canvas->fillRect(0, middleY, middleX, middleY, Get16BitFromRGB(0x000408)); + outherSphere->canvas->fillRect(middleX, middleY, middleX, middleY, Get16BitFromRGB(0x102048)); outherSphere->canvas->fillCircle(middleX, middleY, radius + (margin * 2), TFT_PINK); // outher circle - outherSphere->canvas->fillCircle(middleX, middleY, radius - margin, tft->color24to16(0x384058)); + outherSphere->canvas->fillCircle(middleX, middleY, radius - margin, Get16BitFromRGB(0x384058)); outherSphere->canvas->fillCircle(middleX, middleY, radius - (margin * 2), TFT_PINK); DescribeCircle(middleX, middleY, radius - (margin * 2.5), [&, this](int x, int y, int cx, int cy, int angle, int step, void *payload) { @@ -315,7 +315,7 @@ Watchface2Application::Watchface2Application() { }); DescribeCircle(middleX, middleY, radius - (margin * 2), [&, this](int x, int y, int cx, int cy, int angle, int step, void *payload) { if (0 == (angle % 30)) { // blue 5mins bumps - uint16_t color = tft->color24to16(0x384058); + uint16_t color = Get16BitFromRGB(0x384058); int heightLine=0; DescribeLine(x,y,cx,cy,[&,this](int x, int y, IGNORE_PARAM) { heightLine++; @@ -336,7 +336,7 @@ Watchface2Application::Watchface2Application() { // inner quarter right+down decoration (maybe future data panel) CanvasWidget * innerSphere = new CanvasWidget(canvas->width() / 2, canvas->height() / 2); innerSphere->canvas->fillSprite(TFT_PINK); - innerSphere->canvas->fillCircle(0, 0, 95, tft->color24to16(0x182858)); + innerSphere->canvas->fillCircle(0, 0, 95, Get16BitFromRGB(0x182858)); innerSphere->canvas->fillCircle(0, 0, 45, TFT_PINK); innerSphere->DumpTo(SphereBackground->canvas, middleX, middleY, TFT_PINK); delete innerSphere; @@ -345,7 +345,7 @@ Watchface2Application::Watchface2Application() { // time mark DescribeCircle(middleX, middleY, radius - 1, [&, this](int x, int y, int cx, int cy, int angle, int step, void *payload) { int angleEnd = (markAngle + 90) % 360; - if ((angle > markAngle) && (angle < angleEnd)) { SphereBackground->canvas->fillCircle(x, y, 1, tft->color24to16(0x5890e8)); } + if ((angle > markAngle) && (angle < angleEnd)) { SphereBackground->canvas->fillCircle(x, y, 1, Get16BitFromRGB(0x5890e8)); } return true; }); textBuffer = (char *)ps_malloc(255); diff --git a/src/app/Watchface2.hpp b/src/app/Watchface2.hpp index af6bc3b..3cc41d5 100644 --- a/src/app/Watchface2.hpp +++ b/src/app/Watchface2.hpp @@ -94,7 +94,7 @@ class Watchface2Application: public LunokIoTApplication { bool wifiStatus=false; bool weatherStatus=false; tunable: - const uint16_t DisplayColor=tft->color24to16(0x437aff); + const uint16_t DisplayColor=Get16BitFromRGB(0x437aff); const int16_t DisplaySpeed=12; // speed of text display const int8_t DotSize=3; // hour numbers on watchface (12/3/6/9) @@ -102,9 +102,9 @@ class Watchface2Application: public LunokIoTApplication { const int16_t NumberMargin = 16; // distance inner border of sphere const GFXfont * NumberFreeFont = &FreeMonoBold18pt7b; // font const uint8_t NumberSize = 1; // size - const uint16_t NumberColorBright=tft->color24to16(0x546084); // bright - const uint16_t NumberColor=tft->color24to16(0x1f2d56); // color - const uint16_t NumberColorShadow=tft->color24to16(0x071232); // shadow + const uint16_t NumberColorBright=Get16BitFromRGB(0x546084); // bright + const uint16_t NumberColor=Get16BitFromRGB(0x1f2d56); // color + const uint16_t NumberColorShadow=Get16BitFromRGB(0x071232); // shadow const uint8_t OverSphereAlpha=92; // hands values const int32_t SecondsTickness = 2; @@ -113,13 +113,13 @@ class Watchface2Application: public LunokIoTApplication { const uint8_t MaxSecondsLen = 98; // define the lenght of hand (from up) const int32_t MinutesTickness = 6; - const uint16_t MinutesColor=tft->color24to16(0x787ca0); + const uint16_t MinutesColor=Get16BitFromRGB(0x787ca0); const uint16_t MinutesBrightColor=tft->alphaBlend(128,MinutesColor,TFT_WHITE); const uint8_t MinMinutesLen = 30; const uint8_t MaxMinutesLen = 80; // define the lenght of hand const int32_t HoursTickness = 8; - const uint16_t HoursColor=tft->color24to16(0xfcb61d); + const uint16_t HoursColor=Get16BitFromRGB(0xfcb61d); const uint16_t HoursBrightColor=tft->alphaBlend(128,HoursColor,TFT_BLACK); const uint8_t MinHourLen = 30; const uint8_t MaxHourLen = 45; // define the lenght of hand diff --git a/src/app/WatchfaceBasic.hpp b/src/app/WatchfaceBasic.hpp index 289845b..5bc24c7 100644 --- a/src/app/WatchfaceBasic.hpp +++ b/src/app/WatchfaceBasic.hpp @@ -34,8 +34,8 @@ class WatchfaceBasic : public LunokIoTApplication { uint8_t dotSize=8; CanvasWidget * displayBuffer = nullptr; // RED - const uint32_t LedTimeColor=tft->color24to16(0xdd3030); - // BLUE const uint32_t LedTimeColor=tft->color24to16(0x005fff); + const uint32_t LedTimeColor=Get16BitFromRGB(0xdd3030); + // BLUE const uint32_t LedTimeColor=Get16BitFromRGB(0x005fff); int32_t refreshPoint=0; int32_t refreshPointDelayMS=0; public: diff --git a/src/main.cpp b/src/main.cpp index 13d967e..e0c163c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,4 +43,4 @@ #include "lunokIoT.hpp" // thats me! void setup() { LoT(); /* thats all, folks! */ } -void loop() { vTaskDelete( NULL ); /* harakiri!!! (use apps further) */ } +void loop() { vTaskDelete( NULL ); /* harakiri!!! (use apps ::Tick() further) */ } diff --git a/src/system/Application.hpp b/src/system/Application.hpp index 17cc8b3..080f9ff 100644 --- a/src/system/Application.hpp +++ b/src/system/Application.hpp @@ -26,7 +26,15 @@ const uint8_t APPLICATIONCORE=UICORE; //#include //#include +#ifdef LILYGO_DEV #include +#endif + +#ifdef M5_DEV +#include +#include +#endif + #include #include "../system/Datasources/perceptron.hpp" #define tunable public // all settings accesable from outside diff --git a/src/system/Network/Tasks/GeoIP.hpp b/src/system/Network/Tasks/GeoIP.hpp index 9b7783e..093295f 100644 --- a/src/system/Network/Tasks/GeoIP.hpp +++ b/src/system/Network/Tasks/GeoIP.hpp @@ -22,7 +22,12 @@ #define ___LUNOKIOT__GEOIP__WIFI_TASK___ #include "../WiFi.hpp" -#include + +//#ifdef LILYGO_DEV +//#include +//#elif defined(M5_DEV) +//#include +//#endif class GeoIPWifiTask: public LoTWiFiTask { private: diff --git a/src/system/Network/Tasks/NTP.hpp b/src/system/Network/Tasks/NTP.hpp index 4aed27e..0ba08c2 100644 --- a/src/system/Network/Tasks/NTP.hpp +++ b/src/system/Network/Tasks/NTP.hpp @@ -22,16 +22,23 @@ #define ___LUNOKIOT__NTP__WIFI_TASK___ #include "../WiFi.hpp" +#ifdef LILYGO_DEV #include +#endif class NTPWifiTask: public LoTWiFiTask { private: const unsigned long Every24H = 1000*60*60*24; unsigned long nextShoot = 0; + #ifdef LILYGO_DEV + private: PCF8563_Class * rtc = nullptr; public: - const static char * ntpServer; NTPWifiTask(PCF8563_Class * rtc=nullptr); + #elif defined(M5_DEV) + #endif + public: + const static char * ntpServer; ~NTPWifiTask() override; const char * Name() override { return "NTP"; } void Launch() override; diff --git a/src/system/Network/Tasks/Weather.hpp b/src/system/Network/Tasks/Weather.hpp index c03c75e..fd113e0 100644 --- a/src/system/Network/Tasks/Weather.hpp +++ b/src/system/Network/Tasks/Weather.hpp @@ -22,7 +22,7 @@ #define ___LUNOKIOT__WEATHER__WIFI_TASK___ #include "../WiFi.hpp" -#include +//#include class WeatherWifiTask: public LoTWiFiTask { diff --git a/src/system/SystemEvents.cpp b/src/system/SystemEvents.cpp index 1b087d4..69ea5a6 100644 --- a/src/system/SystemEvents.cpp +++ b/src/system/SystemEvents.cpp @@ -1289,7 +1289,7 @@ static void AXPInterruptController(void *args) { taskEXIT_CRITICAL(&AXPMux);*/ esp_event_post_to(systemEventloopHandler, SYSTEM_EVENTS, PMU_EVENT_PEK_SHORT, nullptr, 0, LUNOKIOT_EVENT_MANDATORY_TIME_TICKS); continue; - } else if (ttgo->power->isPEKLongtPressIRQ()) { + } else if (ttgo->power->isPEKLongPressIRQ()) { ttgo->power->clearIRQ(); lEvLog("AXP202: Event PEK Button long press\n"); xSemaphoreGive(I2cMutex); diff --git a/src/system/lunokIoT.cpp b/src/system/lunokIoT.cpp index 60274e2..15ce0d6 100644 --- a/src/system/lunokIoT.cpp +++ b/src/system/lunokIoT.cpp @@ -31,9 +31,15 @@ #include #include #include -//#include +#ifdef LILYGO_DEV #include +#endif + +#ifdef M5_DEV +#include +#endif + #include "driver/uart.h" //#include @@ -73,11 +79,16 @@ void ARDUINO_ISR_ATTR *__wrap_ps_malloc(size_t size) { return address; }*/ +#ifdef LILYGO_DEV TTGOClass *ttgo = TTGOClass::getWatch(); -//TFT_eSPI * tft = nullptr; -//TFT_eSPI * tft = new TFT_eSPI(); TFT_eSPI * tft = nullptr; PCF8563_Class * rtc = nullptr; +#endif + +#ifdef M5_DEV +M5Display * tft = nullptr; +//PCF8563_Class * rtc = nullptr; +#endif extern bool ntpSyncDone; //extern const char *ntpServer; @@ -232,10 +243,16 @@ LunokIoT::LunokIoT() { // report initial memory FreeSpace(); // Initialize lilygo lib (mandatory at this time) +#ifdef LILYGO_DEV ttgo->begin(); tft = ttgo->tft; // set convenient extern - rtc = ttgo->rtc; // set convenient extern +#endif + +#ifdef M5_DEV + M5.begin(); + tft = &M5.Lcd; +#endif settings=new SystemSettings(); // setup the tft orientation @@ -309,7 +326,7 @@ LunokIoT::LunokIoT() { configTime(timezone*3600, daylight*3600, NTPWifiTask::ntpServer); // set ntp server query struct tm timeinfo; - +#ifdef LILYGO_DEV BaseType_t done = xSemaphoreTake(I2cMutex, LUNOKIOT_EVENT_IMPORTANT_TIME_TICKS); if (pdTRUE == done) { if ( ttgo->rtc->isValid() ) { // woa! RTC seems to guard the correct timedate from last execution :D @@ -326,6 +343,7 @@ LunokIoT::LunokIoT() { } xSemaphoreGive(I2cMutex); } +#endif SplashAnnounce(" Cleanup "); DestroyOldFiles(); //SplashAnnounce(" VFS "); @@ -558,7 +576,11 @@ void LunokIoT::LogRotate() { // reset all counters +#ifdef LILYGO_DEV ttgo->bma->resetStepCounter(); +#elif defined(M5_DEV) + lSysLog("@TODO M5 support for BMA\n"); +#endif beginStepsBMAActivity=0; // sorry current activity is discarded beginBMAActivity=0; @@ -692,7 +714,11 @@ void LunokIoT::DestroyWiFi() { LoTWiFi * LunokIoT::CreateWiFi() { LoTWiFi * response = new LoTWiFi(); +#ifdef LILYGO_DEV response->AddTask(new NTPWifiTask(rtc)); +#elif defined(M5_DEV) + lNetLog("CreateWiFi cannot add NTP task due no M5 RTC support @TODO\n"); +#endif response->AddTask(new GeoIPWifiTask()); response->AddTask(new WeatherWifiTask()); if ( false == NVS.getInt("WifiEnabled") ) {