From a679a4019bc02dee30eff7b8d2b59ecccfb4a686 Mon Sep 17 00:00:00 2001 From: Dave Plummer Date: Sun, 7 Jul 2024 14:15:42 -0700 Subject: [PATCH] M5StickCPlus2 Support --- include/deviceconfig.h | 2 +- include/effects.h | 1 + include/effects/strip/misceffects.h | 42 +++++++++++++ include/globals.h | 95 +++++++++++++++++++++++++---- include/screen.h | 9 +-- include/soundanalyzer.h | 51 +++++++++++----- platformio.ini | 29 +++++++++ src/effects.cpp | 4 ++ src/main.cpp | 17 +++++- 9 files changed, 213 insertions(+), 37 deletions(-) diff --git a/include/deviceconfig.h b/include/deviceconfig.h index b2f067ee..7153945f 100644 --- a/include/deviceconfig.h +++ b/include/deviceconfig.h @@ -86,7 +86,7 @@ #define NTP_SERVER_DEFAULT "0.pool.ntp.org" #define BRIGHTNESS_MIN uint8_t(10) #define BRIGHTNESS_MAX uint8_t(255) -#define POWER_LIMIT_MIN 2000 +#define POWER_LIMIT_MIN 1000 #define POWER_LIMIT_DEFAULT 4500 // DeviceConfig holds, persists and loads device-wide configuration settings. Effect-specific settings should diff --git a/include/effects.h b/include/effects.h index 36d4865f..68479344 100644 --- a/include/effects.h +++ b/include/effects.h @@ -146,6 +146,7 @@ #define EFFECT_MATRIX_ANIMATEDGIF 158 #define EFFECT_MATRIX_STOCKS 159 #define EFFECT_MATRIX_SILON 160 +#define EFFECT_MATRIX_PDPGRID 161 // Hexagon Effects #define EFFECT_HEXAGON_OUTER_RING 201 diff --git a/include/effects/strip/misceffects.h b/include/effects/strip/misceffects.h index 96c0bc4a..c60b8e98 100644 --- a/include/effects/strip/misceffects.h +++ b/include/effects/strip/misceffects.h @@ -551,6 +551,48 @@ class SilonEffect : public LEDStripEffect } }; +// PDPGridEffect +// +// A Display for the front of the PDP-11/34 + +class PDPGridEffect : public LEDStripEffect +{ + public: + + PDPGridEffect() : LEDStripEffect(EFFECT_MATRIX_PDPGRID, "PDPGRIDEffect") + { + } + + PDPGridEffect(const JsonObjectConst& jsonObject) + : LEDStripEffect(jsonObject) + { + } + + int _offset = 0; + int _direction = 1; + + virtual size_t DesiredFramesPerSecond() const + { + return 20; + } + + virtual void Draw() override + { + fadeAllChannelsToBlackBy(255 * g_Values.AppTime.LastFrameTime()); + + EVERY_N_MILLISECONDS(200) + { + g()->MoveY(1); + for (int x = 0; x < MATRIX_WIDTH; x++) + { + if (random(0, 100) < 20) + setPixelOnAllChannels(x, MATRIX_HEIGHT-1, CRGB::Red); + else + setPixelOnAllChannels(x, MATRIX_HEIGHT-1, CRGB::Black); + } + } + } +}; #if HEXAGON //////////////////////////////////////////////// diff --git a/include/globals.h b/include/globals.h index 17f5fe78..e8527370 100644 --- a/include/globals.h +++ b/include/globals.h @@ -172,6 +172,11 @@ #undef min // They define a min() on us #endif +#if M5STICKCPLUS2 +#include "M5StickCPlus2.h" +#undef min // They define a min() on us +#endif + #if M5STACKCORE2 #include "M5Core2.h" #undef min // They define a min() on us @@ -276,7 +281,7 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define ENABLE_NTP 0 // Set the clock from the web #define ENABLE_OTA 0 // Accept over the air flash updates - #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 + #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 || M5STICKCPLUS2 #define LED_PIN0 32 #elif LILYGOTDISPLAYS3 #define LED_PIN0 21 @@ -320,7 +325,7 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define ENABLE_AUDIO 1 // Listen for audio from the microphone and process it #define COLORDATA_SERVER_ENABLED 0 #define MIN_VU 20 - #define NOISE_CUTOFF 10 + #define NOISE_CUTOFF 1000 #if USE_PSRAM #define MAX_BUFFERS 500 @@ -330,7 +335,7 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define DEFAULT_EFFECT_INTERVAL (60*60*24*5) - #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 + #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 || M5STICKCPLUS2 #define LED_PIN0 32 #elif LILYGOTDISPLAYS3 #define LED_PIN0 21 @@ -341,7 +346,7 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define TOGGLE_BUTTON_1 37 #define TOGGLE_BUTTON_2 39 - #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 + #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 || M5STICKCPLUS2 #define LED_PIN0 32 #elif LILYGOTDISPLAYS3 #define LED_PIN0 21 @@ -382,7 +387,7 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #if M5STICKC #define LED_PIN0 33 - #elif M5STICKCPLUS || M5STACKCORE2 + #elif M5STICKCPLUS || M5STACKCORE2 || M5STICKCPLUS2 #define LED_PIN0 32 #else #define LED_PIN0 5 @@ -400,6 +405,55 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define TOGGLE_BUTTON_1 37 #define TOGGLE_BUTTON_2 39 +#elif PDPGRID + + // A matrix grid display for the front of the PDP-11 + + #ifndef PROJECT_NAME + #define PROJECT_NAME "PDPGrid" + #endif + + #define NUM_FANS 1 + #define NUM_RINGS 4 + #define FAN_SIZE (RING_SIZE_0 + RING_SIZE_1 + RING_SIZE_2 + RING_SIZE_3) + #define RING_SIZE_0 16 + #define RING_SIZE_1 12 + #define RING_SIZE_2 8 + #define RING_SIZE_3 1 + #define MATRIX_WIDTH 14 + #define MATRIX_HEIGHT 16 + #define NUM_LEDS (MATRIX_WIDTH*MATRIX_HEIGHT) + #define NUM_CHANNELS 1 + #define ENABLE_AUDIO 1 + + #define POWER_LIMIT_MW 1000 + + // Once you have a working project, selectively enable various additional features by setting + // them to 1 in the list below. This config assumes no audio (mic), or screen, etc. + + #define ENABLE_WIFI 1 // Connect to WiFi + #define INCOMING_WIFI_ENABLED 1 // Accepting incoming color data and commands + #define TIME_BEFORE_LOCAL 1 // How many seconds before the lamp times out and shows local contexnt + #define ENABLE_NTP 1 // Set the clock from the web + #define ENABLE_OTA 1 // Accept over the air flash updates + #define ENABLE_WEBSERVER 1 // Turn on the internal webserver + + #define LED_PIN0 32 + + #define MIN_VU 280 + #define NOISE_CUTOFF 1000 + #define NOISE_FLOOR 2000 + + // The webserver serves files that are baked into the device firmware. When running you should be able to + // see/select the list of effects by visiting the chip's IP in a browser. You can get the chip's IP by + // watching the serial output or checking your router for the DHCP given to a new device; often they're + // named "esp32-" followed by a seemingly random 6-digit hexadecimal number. + + #define DEFAULT_EFFECT_INTERVAL 0 + + #define TOGGLE_BUTTON_1 37 + #define TOGGLE_BUTTON_2 39 + #elif TREESET #ifndef PROJECT_NAME @@ -903,7 +957,6 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define ENABLE_OTA 0 // Accept over the air flash updates #define ENABLE_REMOTE 1 // IR Remote Control #define ENABLE_AUDIO 1 // Listen for audio from the microphone and process it - #define COLORDATA_SERVER_ENABLED 0 #if USE_PSRAM #define INCOMING_WIFI_ENABLED 1 // Accepting incoming color data and commands @@ -943,8 +996,15 @@ extern RemoteDebug Debug; // Let everyone in the project know about it // The mic in the M5 is not quite the same as the Mesmerizer, so it gets a different minimum VU than default - #define MIN_VU 280 - #define NOISE_CUTOFF 1000 + #if M5STICKCPLUS2 + // The M5 Stick C Plus TWO seems to generate very high audio levels, so the cutoffs are wildly different, + // though I'm curious if that could be a bug elsewhere, or if adapting these level is the right thing to do. + #define MIN_VU 60000 + #define NOISE_CUTOFF 100000 + #define NOISE_FLOOR 200000 + #else + #define NOISE_CUTOFF 1000 + #endif #if !(ELECROW) #define TOGGLE_BUTTON_1 37 @@ -961,7 +1021,7 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define PROJECT_NAME "Helmet" #endif - #define POWER_LIMIT_MW 3000 + #define POWER_LIMIT_MW 1000 #define ENABLE_AUDIOSERIAL 0 // Report peaks at 2400baud on serial port for PETRock consumption #define ENABLE_WIFI 1 // Connect to WiFi @@ -1261,7 +1321,7 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define AUDIO_PEAK_REMOTE_TIMEOUT 1000.0f // How long after remote PeakData before local microphone is used again #endif #ifndef ENABLE_AUDIO_SMOOTHING - #define ENABLE_AUDIO_SMOOTHING 1 + #define ENABLE_AUDIO_SMOOTHING 0 #endif #ifndef BARBEAT_ENHANCE #define BARBEAT_ENHANCE 0.3 // How much the SpectrumAnalyzer "pulses" with the music @@ -1400,6 +1460,10 @@ extern RemoteDebug Debug; // Let everyone in the project know about it #define USE_M5DISPLAY 1 // enable the M5's LCD screen + #elif M5STICKCPLUS2 // screen definitions for m5stick-c-plus2 + + #define USE_M5DISPLAY 1 // enable the M5's LCD screen + #elif M5STICKC // screen definitions for m5stick-c (or m5stick-c plus) #define USE_M5DISPLAY 1 // enable the M5's LCD screen @@ -1497,7 +1561,10 @@ extern RemoteDebug Debug; // Let everyone in the project know about it extern DRAM_ATTR const int g_aRingSizeTable[]; -#define MICROS_PER_SECOND 1000000UL +#ifndef MICROS_PER_SECOND + #define MICROS_PER_SECOND 1000000 +#endif + #define MILLIS_PER_SECOND 1000 #define MICROS_PER_MILLI 1000 @@ -1509,6 +1576,10 @@ extern DRAM_ATTR const int g_aRingSizeTable[]; #define M5STICKCPLUS 0 #endif +#ifndef M5STICKCPLUS2 +#define M5STICKCPLUS2 0 +#endif + #ifndef M5STACKCORE2 #define M5STACKCORE2 0 #endif @@ -1534,7 +1605,7 @@ extern DRAM_ATTR const int g_aRingSizeTable[]; #elif M5STACKCORE2 #define INPUT_PIN (0) #define IO_PIN (0) - #elif M5STICKC || M5STICKCPLUS + #elif M5STICKC || M5STICKCPLUS || M5STICKCPLUS2 #define INPUT_PIN (34) #define IO_PIN (0) #else diff --git a/include/screen.h b/include/screen.h index c6e5b285..11208188 100644 --- a/include/screen.h +++ b/include/screen.h @@ -117,7 +117,9 @@ class Screen : public GFXBase // // Display code for the M5 based TFT displays on the M5 Stick, Stick C Plus, and Stack - #include + #if M5STICKCPLUS2 + #include + #endif // M5Screen // @@ -125,16 +127,11 @@ class Screen : public GFXBase class M5Screen : public Screen { - private: - - M5Display m5display; - public: M5Screen(int w, int h) : Screen(w, h) { M5.Lcd.fillScreen(GREEN16); - M5.Lcd.setRotation(1); } virtual void drawPixel(int16_t x, int16_t y, uint16_t color) override diff --git a/include/soundanalyzer.h b/include/soundanalyzer.h index 5ea39ffe..6244ca90 100644 --- a/include/soundanalyzer.h +++ b/include/soundanalyzer.h @@ -60,7 +60,7 @@ struct AudioVariables float _VURatio = 1.0; // Current VU as a ratio to its recent min and max float _VURatioFade = 1.0; // Same as gVURatio but with a slow decay float _VU = 0.0; // Instantaneous read of VU value - float _PeakVU = MAX_VU; // How high our peak VU scale is in live mode + float _PeakVU = 0.0; // How high our peak VU scale is in live mode float _MinVU = 0.0; // How low our peak VU scale is in live mode unsigned long _cSamples = 0U; // Total number of samples successfully collected int _AudioFPS = 0; // Framerate of the audio sampler @@ -120,7 +120,8 @@ class PeakData { MESMERIZERMIC, PCREMOTE, - M5 + M5, + M5PLUS2 } MicrophoneType; PeakData() @@ -153,7 +154,7 @@ class PeakData { case MESMERIZERMIC: { - static constexpr std::array Scalars16 = {0.4, .5, 0.75, 1.0, 0.6, 0.6, 0.8, 0.8, 1.2, 1.5, 3.0, 3.0, 3.0, 3.0, 3.5, 3.5}; // {0.08, 0.12, 0.3, 0.35, 0.35, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.4, 1.0, 1.0, 1.0}; + static constexpr std::array Scalars16 = {0.4, .5, 0.75, 1.0, 0.6, 0.6, 0.8, 0.8, 1.2, 1.5, 3.0, 3.0, 3.0, 3.0, 3.5, 2.5}; // {0.08, 0.12, 0.3, 0.35, 0.35, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.4, 1.0, 1.0, 1.0}; float result = (NUM_BANDS == 16) ? Scalars16[i] : map(i, 0, NUM_BANDS - 1, 1.0, 1.0); return result; } @@ -164,9 +165,15 @@ class PeakData float result = (NUM_BANDS == 16) ? Scalars16[i] : map(i, 0, NUM_BANDS - 1, 1.0, 1.0); return result; } + case M5PLUS2: + { + static constexpr std::array Scalars16 = {0.3, .5, 0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.7, 0.7, 0.7}; + float result = (NUM_BANDS == 16) ? Scalars16[i] : map(i, 0, NUM_BANDS - 1, 1.0, 1.0); + return result; + } default: { - static constexpr std::array Scalars16 = {0.2, .25, 0.4, 0.6, 1.5, 1.2, 1.5, 1.6, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 6.0, 5.0}; // {0.08, 0.12, 0.3, 0.35, 0.35, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.4, 1.0, 1.0, 1.0}; + static constexpr std::array Scalars16 = {0.5, .5, 0.8, 1.0, 1.5, 1.2, 1.5, 1.6, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 5.0, 2.5}; float result = (NUM_BANDS == 16) ? Scalars16[i] : map(i, 0, NUM_BANDS - 1, 1.0, 1.0); return result; } @@ -212,7 +219,7 @@ class SoundAnalyzer : public AudioVariables float _oldMinVU; // Old min VU value for damping double * _vPeaks; // The peak value for each band - PeakData::MicrophoneType _MicMode = PeakData::M5; + PeakData::MicrophoneType _MicMode; // GetBandIndex // @@ -266,7 +273,7 @@ class SoundAnalyzer : public AudioVariables { arduinoFFT _FFT(_vReal, _vImaginary, MAX_SAMPLES, SAMPLING_FREQUENCY); _FFT.DCRemoval(); - _FFT.Windowing(FFT_WIN_TYP_HAMMING, FFT_FORWARD); + _FFT.Windowing(FFT_WIN_TYP_BLACKMAN, FFT_FORWARD); _FFT.Compute(FFT_FORWARD); _FFT.ComplexToMagnitude(); _FFT.MajorPeak(); @@ -278,8 +285,11 @@ class SoundAnalyzer : public AudioVariables size_t bytesRead = 0; - #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 || ELECROW + #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 || ELECROW ESP_ERROR_CHECK(i2s_read(I2S_NUM_0, (void *)ptrSampleBuffer.get(), bytesExpected, &bytesRead, (100 / portTICK_RATE_MS))); + #elif M5STICKCPLUS2 + if (M5.Mic.record((int16_t *)ptrSampleBuffer.get(), MAX_SAMPLES, SAMPLING_FREQUENCY, false)) + bytesRead = bytesExpected; #else ESP_ERROR_CHECK(i2s_adc_enable(EXAMPLE_I2S_NUM)); ESP_ERROR_CHECK(i2s_read(EXAMPLE_I2S_NUM, (void *) ptrSampleBuffer.get(), bytesExpected, &bytesRead, (100 / portTICK_RATE_MS))); @@ -293,7 +303,9 @@ class SoundAnalyzer : public AudioVariables } for (int i = 0; i < MAX_SAMPLES; i++) + { _vReal[i] = ptrSampleBuffer[i]; + } } // UpdateVU @@ -350,7 +362,6 @@ class SoundAnalyzer : public AudioVariables double averageSum = 0.0f; - int hitCount[NUM_BANDS] = {0}; for (int i = 0; i < NUM_BANDS; i++) _vPeaks[i] = 0.0f; @@ -361,22 +372,23 @@ class SoundAnalyzer : public AudioVariables { // Track the average and the peak value - averageSum += _vReal[i]; + double vVal = _vReal[i]; + averageSum += vVal; // If it's above the noise floor, figure out which band this belongs to and // if it's a new peak for that band, record that fact int iBand = GetBandIndex(freq); - _vPeaks[iBand] += _vReal[i]; - hitCount[iBand]++; + if (vVal > _vPeaks[iBand]) + _vPeaks[iBand] = _vReal[i]; } } + averageSum = averageSum / (MAX_SAMPLES / 2 - 2); // Noise gate - if the signal in this band is below a threshold we define, then we say there's no energy in this band for (int i = 0; i < NUM_BANDS; i++) { - _vPeaks[i] /= std::max(1, hitCount[i]); // max to avoid div by zero error _vPeaks[i] *= PeakData::GetBandScalar(_MicMode, i); if (_vPeaks[i] < NOISE_CUTOFF) _vPeaks[i] = 0.0f; @@ -415,7 +427,8 @@ class SoundAnalyzer : public AudioVariables // We'll use the average as the gVU. I assume the average of the samples tracks sound pressure level, but don't really know... - float newval = averageSum / (MAX_SAMPLES / 2 - 2); + float newval = averageSum; + debugV("AverageSum : %f", averageSum); debugV("Newval : %f", newval); @@ -424,7 +437,7 @@ class SoundAnalyzer : public AudioVariables EVERY_N_MILLISECONDS(100) { auto peaks = GetPeakData(); - debugV("Audio Data -- Sum: %0.2f, _MinVU: %f0.2, _PeakVU: %f0.2, _VU: %f, Peak0: %f, Peak1: %f, Peak2: %f, Peak3: %f", averageSum, _MinVU, _PeakVU, _VU, peaks[0], peaks[1], peaks[2], peaks[3]); + debugV("Audio Data -- Sum: %0.2f, _MinVU: %0.2f, _PeakVU: %0.2f, _VU: %f, Peak0: %f, Peak1: %f, Peak2: %f, Peak3: %f", averageSum, _MinVU, _PeakVU, _VU, peaks[0], peaks[1], peaks[2], peaks[3]); } return PeakData(_vPeaks); @@ -536,7 +549,11 @@ class SoundAnalyzer : public AudioVariables err += i2s_set_pin(Speak_I2S_NUMBER, &tx_pin_config); // Set the I2S pin number. err += i2s_set_clk(Speak_I2S_NUMBER, SAMPLING_FREQUENCY, I2S_BITS_PER_SAMPLE_16BIT, I2S_CHANNEL_MONO); // Set the clock and bitwidth used by I2S Rx and Tx. - #elif M5STICKC || M5STICKCPLUS + #elif M5STICKCPLUS2 + + M5.Mic.begin(); + + #elif M5STICKC || M5STICKCPLUS i2s_config_t i2s_config = { @@ -706,7 +723,9 @@ class SoundAnalyzer : public AudioVariables { if (millis() - _msLastRemote > AUDIO_PEAK_REMOTE_TIMEOUT) { - #if M5STICKC || M5STICKCPLUS || M5STACKCORE2 + #if M5STICKCPLUS2 + _MicMode = PeakData::M5PLUS2; + #elif M5STICKC || M5STICKCPLUS || M5STACKCORE2 _MicMode = PeakData::M5; #else _MicMode = PeakData::MESMERIZERMIC; diff --git a/platformio.ini b/platformio.ini index a5de10b4..45989644 100644 --- a/platformio.ini +++ b/platformio.ini @@ -161,6 +161,20 @@ build_flags = -DUSE_SCREEN=1 lib_deps = ${base.lib_deps} m5stack/M5StickCPlus @ ^0.0.2 +[dev_m5stick-c-plus2] +extends = base +board = m5stick-c ; Requires the M5 Stick C Plus (note the Plus) +monitor_speed = 115200 +upload_speed = 2000000 +build_flags = -DUSE_SCREEN=1 + -DM5STICKCPLUS2=1 + ${base.build_flags} + ${psram_flags.build_flags} +lib_deps = ${base.lib_deps} + https://github.com/m5stack/M5StickCPlus2.git +board_build.partitions = config/partitions_custom_8M.csv +board_upload.flash_size = 8MB + [dev_m5stack] extends = base board = m5stack-core2 @@ -490,6 +504,15 @@ build_flags = -DSPECTRUM=1 ${dev_m5stick-c-plus.build_flags} board_build.partitions = config/partitions_custom_noota.csv +[env:spectrum2] +extends = dev_m5stick-c-plus2 +build_flags = -DSPECTRUM=1 + -DSHOW_VU_METER=1 + -DM5STICKCPLUS2=1 + ${remote_flags.build_flags} + ${dev_m5stick-c-plus2.build_flags} +board_build.partitions = config/partitions_custom_noota.csv + [env:helmet] extends = dev_m5stick-c-plus build_flags = -DHELMET=1 @@ -577,6 +600,12 @@ build_flags = -DLANTERN=1 ${remote_flags.build_flags} ${dev_m5stick-c.build_flags} +[env:pdpgrid] +extends = dev_m5stick-c-plus2 +build_flags = -DPDPGRID=1 + ${remote_flags.build_flags} + ${dev_m5stick-c-plus2.build_flags} + [env:chieftain] extends = dev_tinypico build_flags = -DCHIEFTAIN=1 diff --git a/src/effects.cpp b/src/effects.cpp index a71e7a44..7fa4ef52 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -212,6 +212,10 @@ void LoadEffectFactories() ADD_EFFECT(EFFECT_STRIP_PALETTE, PaletteEffect, RainbowColors_p, 2.0f, 0.1, 0.0, 1.0, 0.0, LINEARBLEND, true, 1.0); ADD_EFFECT(EFFECT_STRIP_RAINBOW_FILL, RainbowFillEffect, 10, 32); + #elif PDPGRID + + ADD_EFFECT(EFFECT_MATRIX_PDPGRID, PDPGridEffect); + #elif LANTERN ADD_EFFECT(EFFECT_STRIP_FIRE, FireEffect, "Calm Fire", NUM_LEDS, 40, 5, 50, 3, 3, true, true); diff --git a/src/main.cpp b/src/main.cpp index 049aec99..221bdbd7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -427,12 +427,25 @@ void setup() debugW("Creating LCD Screen"); g_ptrSystem->SetupDisplay(TFT_HEIGHT, TFT_WIDTH); - #elif M5STICKC || M5STICKCPLUS || M5STACKCORE2 + #elif M5STICKCPLUS2 + + auto cfg = M5.config(); + + M5.begin(cfg); + M5.Display.startWrite(); + M5.Display.setRotation(1); + M5.Display.setTextDatum(top_center); + M5.Display.setTextColor(WHITE); + + g_ptrSystem->SetupDisplay(M5.Lcd.width(), M5.Lcd.height()); + + #elif M5STICKC || M5STICKCPLUS || M5STACKCORE2 #if USE_M5DISPLAY M5.begin(); + M5.Lcd.setRotation(1); debugW("Creating M5 Screen"); - g_ptrSystem->SetupDisplay(TFT_HEIGHT, TFT_WIDTH); + g_ptrSystem->SetupDisplay(M5.Lcd.width(), M5.Lcd.height()); #else M5.begin(false); #endif