Skip to content

Commit

Permalink
M5StickCPlus2 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
davepl committed Jul 7, 2024
1 parent af23da1 commit a679a40
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 37 deletions.
2 changes: 1 addition & 1 deletion include/deviceconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions include/effects/strip/misceffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
////////////////////////////////////////////////
Expand Down
95 changes: 83 additions & 12 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 3 additions & 6 deletions include/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,21 @@ class Screen : public GFXBase
//
// Display code for the M5 based TFT displays on the M5 Stick, Stick C Plus, and Stack

#include <M5Display.h>
#if M5STICKCPLUS2
#include <M5UnitLCD.h>
#endif

// M5Screen
//
// Screen class that supports the M5 devices

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
Expand Down
Loading

0 comments on commit a679a40

Please sign in to comment.