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,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