diff --git a/lib/M5ez/library.json b/lib/M5ez/library.json index 9c81926..1ff9100 100644 --- a/lib/M5ez/library.json +++ b/lib/M5ez/library.json @@ -12,7 +12,7 @@ "url": "https://github.com/ropg/M5ez" }, "dependencies": { - "name": "M5Stack" + "name": "M5Unified" }, "version": "2.1.2", "framework": "arduino", diff --git a/lib/M5ez/src/M5ez.cpp b/lib/M5ez/src/M5ez.cpp index da364eb..4d1aab9 100644 --- a/lib/M5ez/src/M5ez.cpp +++ b/lib/M5ez/src/M5ez.cpp @@ -764,10 +764,6 @@ void ezSettings::begin() { ez.settings.menuObj.addItem("Theme chooser", ez.theme->menu); } ez.settings.menuObj.addItem("Factory defaults", ez.settings.defaults); - -#ifdef M5STACK_CORE2 - M5.Lcd.setRotation(1); -#endif } void ezSettings::menu() { @@ -836,7 +832,6 @@ void ezBacklight::menu() { _brightness = 48; } float p = float(_brightness) / 2.48; - Serial.println(_brightness); bl.value(p); M5.Display.setBrightness(_brightness); if (b == "Back") @@ -892,22 +887,44 @@ void ezBacklight::activity() { _last_activity = millis(); } +void changeCpuPower(bool reduce) { + switch (M5.getBoard()) { + case m5::board_t::board_M5StickC: + case m5::board_t::board_M5StickCPlus: + // do nothing, lightSleep() works with backlight control + break; + default: + // Backlight is PWM controlled, lightSleep() stops PWM + if (reduce) { + setCpuFrequencyMhz(10); + } else { + setCpuFrequencyMhz(80); + } + } +} + uint16_t ezBacklight::loop(void *private_data) { if (!_backlight_off && _inactivity) { if (millis() > _last_activity + 30000 * _inactivity) { _backlight_off = true; M5.Display.setBrightness(64); + changeCpuPower(true); while (true) { if (M5.BtnA.wasClicked() || M5.BtnB.wasClicked()) break; ez.yield(); -#if M5STACK_CORE2 - delay(100); -#else - M5.Power.lightSleep(100000); -#endif + switch (M5.getBoard()) { + case m5::board_t::board_M5StickC: + case m5::board_t::board_M5StickCPlus: + M5.Power.lightSleep(100000); + break; + default: + // PWM inactive during lightSleep, thus display backlight not controlled + delay(100); + } } ez.buttons.releaseWait(); // Make sure the key pressed to wake display gets ignored + changeCpuPower(false); M5.Display.setBrightness(_brightness); activity(); _backlight_off = false; @@ -2229,8 +2246,13 @@ long M5ez::_text_cursor_millis; void M5ez::begin() { auto cfg = M5.config(); + cfg.internal_imu = false; + cfg.internal_spk = false; + cfg.internal_mic = false; M5.begin(cfg); +#if ARDUINO_M5STICK_C || ARDUINO_M5STICK_C_PLUS M5.Lcd.setRotation(3); +#endif ezTheme::begin(); ez.screen.begin(); ez.settings.begin(); @@ -2862,7 +2884,7 @@ void M5ez::setFont(const GFXfont *font) { } int16_t M5ez::fontHeight() { -#if M5STICKC_PLUS || M5STACK_CORE2 +#if ARDUINO_M5STICK_C_PLUS || ARDUINO_M5STACK_CORE_ESP32 return M5.Lcd.fontHeight(M5.Lcd.getFont()); #else return 11; diff --git a/lib/M5ez/src/M5ez.h b/lib/M5ez/src/M5ez.h index 01edce9..19848cd 100644 --- a/lib/M5ez/src/M5ez.h +++ b/lib/M5ez/src/M5ez.h @@ -61,7 +61,7 @@ #define NO_COLOR TFT_TRANSPARENT -#ifdef M5STICKC_PLUS +#if ARDUINO_M5STICK_C_PLUS #define TFT_W 240 #define TFT_H 135 #define TFT_FONT sans16 @@ -70,7 +70,7 @@ #define TFT_RADIUS 8 #endif -#ifdef M5STICKC +#if ARDUINO_M5STICK_C #define TFT_W 160 #define TFT_H 80 #define TFT_FONT hzk16 @@ -79,7 +79,7 @@ #define TFT_RADIUS 3 #endif -#ifdef M5STACK_CORE2 +#if ARDUINO_M5STACK_CORE_ESP32 || ARDUINO_M5STACK_CORE2 #define TFT_W 320 #define TFT_H 240 #define TFT_FONT (&FreeMono12pt7b) diff --git a/platformio.ini b/platformio.ini index adf77fe..dc82b4a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,5 +1,5 @@ [furble] -build_flags = -D FURBLE_VERSION=\"${sysenv.FURBLE_VERSION}\" +build_flags = -Wall -D FURBLE_VERSION=\"${sysenv.FURBLE_VERSION}\" [env] platform = espressif32 @@ -13,16 +13,16 @@ lib_deps = [env:m5stick-c] board = m5stick-c -build_flags = ${furble.build_flags} -D M5STICKC +build_flags = ${furble.build_flags} -D ARDUINO_M5STICK_C=1 [env:m5stick-c-plus] board = m5stick-c -build_flags = ${furble.build_flags} -D M5STICKC_PLUS +build_flags = ${furble.build_flags} -D ARDUINO_M5STICK_C_PLUS=1 [env:m5stack-core] board = m5stack-core-esp32 -build_flags = ${furble.build_flags} -D M5STACK_CORE2 +build_flags = ${furble.build_flags} -D ARDUINO_M5STACK_CORE_ESP32=1 [env:m5stack-core2] board = m5stack-core2 -build_flags = ${furble.build_flags} -D M5STACK_CORE2 +build_flags = ${furble.build_flags} -D ARDUINO_M5STACK_CORE2=1 diff --git a/requirements.txt b/requirements.txt index 21c6546..743c865 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -platformio==6.1.5 +platformio==6.1.13 diff --git a/src/furble.cpp b/src/furble.cpp index d45489b..50c1686 100644 --- a/src/furble.cpp +++ b/src/furble.cpp @@ -55,17 +55,17 @@ static void show_shutter_control(bool shutter_locked, unsigned long lock_start_m unsigned long seconds = (total_ms / 1000) % 60; prev_update_ms = now; - char duration[8] = {0x0}; - snprintf(duration, 8, "%02lu:%02lu", minutes, seconds); + char duration[16] = {0x0}; + snprintf(duration, 16, "%02lu:%02lu", minutes, seconds); -#ifdef M5STACK_CORE2 +#if ARDUINO_M5STACK_CORE_ESP32 || ARDUINO_M5STACK_CORE2 ez.msgBox("Remote Shutter", "Shutter Locked|" + String(duration), "Unlock#Unlock#Back", false); #else ez.msgBox("Remote Shutter", "Shutter Locked|" + String(duration) + "||Back: Power", "Unlock#Unlock", false); #endif } else { -#ifdef M5STACK_CORE2 +#if ARDUINO_M5STACK_CORE_ESP32 || ARDUINO_M5STACK_CORE2 ez.msgBox("Remote Shutter", "Lock: Focus+Release", "Release#Focus#Back", false); #else ez.msgBox("Remote Shutter", "Lock: Focus+Release|Back: Power", "Release#Focus", false); diff --git a/src/furble_gps.cpp b/src/furble_gps.cpp index 4c845ce..950c509 100644 --- a/src/furble_gps.cpp +++ b/src/furble_gps.cpp @@ -8,6 +8,13 @@ #include "settings.h" static const uint32_t GPS_BAUD = 9600; +#if ARDUINO_M5STACK_CORE_ESP32 || ARDUINO_M5STACK_CORE2 +static const int8_t GPS_RX = 22; +static const int8_t GPS_TX = 21; +#else +static const int8_t GPS_RX = 33; +static const int8_t GPS_TX = 32; +#endif static const uint16_t GPS_SERVICE_MS = 250; static const uint32_t GPS_MAX_AGE_MS = 60 * 1000; @@ -106,7 +113,7 @@ static uint16_t current_service(void *private_data) { void furble_gps_init(void) { furble_gps_enable = settings_load_gps(); - Serial2.begin(GPS_BAUD, SERIAL_8N1, 33, 32); + Serial2.begin(GPS_BAUD, SERIAL_8N1, GPS_RX, GPS_TX); uint8_t width = 4 * M5.Lcd.textWidth("5") + ez.theme->header_hmargin * 2; ez.header.insert(CURRENT_POSITION, "current", width, current_draw_widget); diff --git a/src/interval.cpp b/src/interval.cpp index 88c93e8..84c78f8 100644 --- a/src/interval.cpp +++ b/src/interval.cpp @@ -33,6 +33,8 @@ static void display_interval_msg(interval_state_t state, case INTERVAL_DELAY: statestr = "DELAY"; break; + case INTERVAL_EXIT: + break; } unsigned long rem = next - now; @@ -65,8 +67,6 @@ static void do_interval(FurbleCtx *fctx, interval_t *interval) { const unsigned long config_shutter = sv2ms(&interval->shutter); unsigned int icount = 0; - unsigned long idelay = 0; - unsigned long ishutter = 0; interval_state_t state = INTERVAL_SHUTTER_OPEN; diff --git a/src/spinner.cpp b/src/spinner.cpp index 1ef39ff..7c829f1 100644 --- a/src/spinner.cpp +++ b/src/spinner.cpp @@ -238,6 +238,8 @@ unsigned long sv2ms(SpinValue *sv) { return (sv->value * 1000); case SPIN_UNIT_MS: return (sv->value); + default: + return 0; } return 0; }