Snake! (#10936)
* Snake! * Add spiLock to snake score saving * Check fixes * More careful locking * WIP: Big Display Node * Update src/graphics/HUB75Display.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Add HUB75 Native * Add Tetris game module with core logic and UI integration - Implement TetrisGame class for game logic, including piece movement, rotation, and line clearing. - Create TetrisModule class to manage game state, input handling, and rendering on OLED display. - Introduce high score tracking with persistence and optional mesh broadcasting. - Define UI states for title, playing, paused, game over, and high scores. - Implement input handling for game controls and state transitions. - Add rendering functions for the game board, high scores, and title screen. * feat(snake): add snake graphics and update display logic in SnakeModule * Prompt for Initials for Tetris, too * refactor games module * Games refactor * hub75 native double buffer * Games tuning * Make joystick repeat events on held button * Add clouds and colors * Fix breakout and more color * difficulty tuning * trunk * refactor game announcements, etc * Scale chirpy gravity as game speed increases * Portduino, check for hub75 display before reading in hub75 options * Final(?) games tuning * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Properly ignore input when games screen not shown * Fail gracefully when HUB75 is selected but not supported. --------- Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Ixitxachitl <kramerfm@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
GitHub
Thomas Göttgens
coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Ixitxachitl
Copilot Autofix powered by AI
parent
d3d02af817
commit
8d1fbbf55f
@@ -0,0 +1,20 @@
|
||||
; Big Visualizer - ESP32-S3-DevKitC-1 (N16R8) + 128x64 HUB75 matrix + Wio-SX1262 - DIY
|
||||
[env:visualizer-hub75]
|
||||
extends = esp32s3_base
|
||||
board = esp32-s3-devkitc-1
|
||||
board_check = true
|
||||
board_build.partitions = default_16MB.csv
|
||||
board_level = extra
|
||||
board_upload.flash_size = 16MB ; N16R8 -> 16MB flash
|
||||
board_build.arduino.memory_type = qio_opi ; N16R8 -> 8MB octal (OPI) PSRAM
|
||||
build_flags =
|
||||
${esp32s3_base.build_flags}
|
||||
-D VISUALIZER_HUB75
|
||||
-D BOARD_HAS_PSRAM
|
||||
-D ARDUINO_USB_MODE=1
|
||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||
-I variants/esp32s3/visualizer-hub75
|
||||
lib_deps =
|
||||
${esp32s3_base.lib_deps}
|
||||
# renovate: datasource=github-tags depName=ESP32-HUB75-MatrixPanel-I2S-DMA packageName=mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA
|
||||
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA/archive/refs/tags/3.0.14.zip
|
||||
@@ -0,0 +1,66 @@
|
||||
// Big Visualizer - ESP32-S3-DevKitC-1 (N16R8) driving a 128x64 HUB75 RGB matrix
|
||||
// via the seengreat "RGB Matrix Adapter Board (E)" Rev. 2.2 (V2.x), plus a
|
||||
// Wio-SX1262 (for XIAO, Seeed p/n 6379) LoRa header board.
|
||||
|
||||
#define BUTTON_PIN 0
|
||||
|
||||
#define I2C_SDA 41
|
||||
#define I2C_SCL 42
|
||||
|
||||
// --- Display: HUB75 via seengreat Shield (V2.x, hard-wired) -----------------
|
||||
#define HAS_SPI_TFT 1 // enable the color BaseUI path (TFTColorRegions/theming)
|
||||
#define DISPLAY_FORCE_SMALL_FONTS // 128x64 panel: keep OLED-sized fonts, not big TFT fonts
|
||||
#define USE_HUB75 // select HUB75Display in Screen.cpp
|
||||
|
||||
#define TFT_WIDTH 128
|
||||
#define TFT_HEIGHT 64
|
||||
#define HUB75_BRIGHTNESS_DEFAULT 180
|
||||
|
||||
// RGB data lines.
|
||||
// This panel is BGR: R and B are swapped per half vs. the nominal seengreat
|
||||
// mapping (R1<->B1, R2<->B2), verified at bring-up. Software-only fix; the
|
||||
// shield board is unchanged. G / address / control lines stay as routed.
|
||||
#define HUB75_R1 17
|
||||
#define HUB75_G1 8
|
||||
#define HUB75_B1 18
|
||||
#define HUB75_R2 15
|
||||
#define HUB75_G2 1
|
||||
#define HUB75_B2 16
|
||||
// Row-address lines (1/32 scan -> A..E)
|
||||
#define HUB75_A 7
|
||||
#define HUB75_B 48
|
||||
#define HUB75_C 6
|
||||
#define HUB75_D 47
|
||||
#define HUB75_E 2
|
||||
// Control lines
|
||||
#define HUB75_CLK 5
|
||||
#define HUB75_LAT 21
|
||||
#define HUB75_OE 4
|
||||
|
||||
// --- Radio: Wio-SX1262 for XIAO (header board, Seeed p/n 6379) ---------------
|
||||
#define USE_SX1262
|
||||
|
||||
#define LORA_SCK 12
|
||||
#define LORA_MISO 13
|
||||
#define LORA_MOSI 11
|
||||
#define LORA_CS 10
|
||||
#define LORA_RESET 9
|
||||
#define LORA_DIO1 40
|
||||
|
||||
#define SX126X_CS LORA_CS
|
||||
#define SX126X_SCK LORA_SCK
|
||||
#define SX126X_MOSI LORA_MOSI
|
||||
#define SX126X_MISO LORA_MISO
|
||||
#define SX126X_DIO1 LORA_DIO1
|
||||
#define SX126X_BUSY 14
|
||||
#define SX126X_RESET LORA_RESET
|
||||
|
||||
#define SX126X_DIO2_AS_RF_SWITCH
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||
|
||||
#define SX126X_RXEN 39
|
||||
#define SX126X_TXEN RADIOLIB_NC
|
||||
|
||||
#define SX126X_MAX_POWER 22
|
||||
|
||||
#define LED_HEARTBEAT 38
|
||||
@@ -56,6 +56,8 @@ build_flags_common =
|
||||
-luv
|
||||
-std=gnu17
|
||||
-std=gnu++17
|
||||
-DBASEUI_HAS_GAMES=1
|
||||
-DMAX_TFT_COLOR_REGIONS=64
|
||||
|
||||
build_flags =
|
||||
${portduino_base.build_flags_common}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
#if defined(HAS_HUB75_NATIVE)
|
||||
|
||||
#include <OLEDDisplay.h>
|
||||
|
||||
#ifndef HUB75_BRIGHTNESS_DEFAULT
|
||||
#define HUB75_BRIGHTNESS_DEFAULT 100 // rpi-rgb-led-matrix brightness is a 1..100 percentage
|
||||
#endif
|
||||
|
||||
namespace rgb_matrix
|
||||
{
|
||||
class RGBMatrix;
|
||||
class FrameCanvas;
|
||||
} // namespace rgb_matrix
|
||||
|
||||
/**
|
||||
* Native (Raspberry Pi / Portduino) HUB75 RGB-matrix display backend.
|
||||
*
|
||||
* Drives the panel with hzeller/rpi-rgb-led-matrix. Like the ESP32 HUB75Display it plugs into the
|
||||
* BaseUI color path by subclassing OLEDDisplay and expanding the mono framebuffer into RGB via the
|
||||
* shared TFTColorRegions/TFTPalette helpers. It is a separate class (not shared with the ESP32
|
||||
* driver) so no rpi-rgb-led-matrix code lives in src/graphics/. All wiring/tuning comes from
|
||||
* config.yaml (portduino_config.hub75_*); the library owns the GPIO pins.
|
||||
*
|
||||
* Bodies live in src/platform/portduino/HUB75Native.cpp (compiled native-only).
|
||||
*/
|
||||
class HUB75Native : public OLEDDisplay
|
||||
{
|
||||
public:
|
||||
HUB75Native(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus);
|
||||
~HUB75Native();
|
||||
|
||||
// Redraw the whole panel from the BaseUI buffer (region-aware color expansion).
|
||||
void display() override;
|
||||
|
||||
void setDisplayBrightness(uint8_t brightness);
|
||||
|
||||
protected:
|
||||
int getBufferOffset(void) override { return 0; }
|
||||
|
||||
void sendCommand(uint8_t com) override;
|
||||
|
||||
bool connect() override;
|
||||
|
||||
private:
|
||||
rgb_matrix::RGBMatrix *matrix = nullptr;
|
||||
// Offscreen buffer for tear-free updates: display() draws here, then SwapOnVSync() atomically
|
||||
// presents it. Without this, writing into the live canvas while the refresh thread scans it
|
||||
// tears (worse when display() is contended during packet TX/RX).
|
||||
rgb_matrix::FrameCanvas *offscreen = nullptr;
|
||||
uint8_t brightness = HUB75_BRIGHTNESS_DEFAULT; // 1..100
|
||||
};
|
||||
|
||||
#endif // HAS_HUB75_NATIVE
|
||||
@@ -20,6 +20,11 @@ build_flags = ${native_base.build_flags}
|
||||
!pkg-config --libs openssl --silence-errors || :
|
||||
!pkg-config --cflags --libs sdl2 --silence-errors || :
|
||||
!pkg-config --cflags --libs libbsd-overlay --silence-errors || :
|
||||
; Optional HUB75 RGB-matrix support on Raspberry Pi via hzeller/rpi-rgb-led-matrix.
|
||||
; When the lib is installed (provides rgbmatrix.pc), these add its include/link flags and
|
||||
; __has_include(<led-matrix.h>) enables HAS_HUB75_NATIVE (see configuration.h). Absent -> no-op.
|
||||
!pkg-config --cflags rgbmatrix --silence-errors || :
|
||||
!pkg-config --libs rgbmatrix --silence-errors || :
|
||||
|
||||
[env:native-tft]
|
||||
extends = native_base
|
||||
|
||||
Reference in New Issue
Block a user