Compare commits

...

1 Commits

Author SHA1 Message Date
eb81dc22a7 port back to 1x64x64 matrix 2023-04-19 14:59:05 +02:00
3 changed files with 38 additions and 32 deletions

View File

@ -9,7 +9,7 @@ namespace RPI_Matrix {
public static class RPI_Matrix {
// Initialize variables
private static int debugIndex;
private static int debugIndex, debugOffset;
private static bool debugMenu, debugSelect;
private static List<string> gamepadListeners = new();
private static int selectionIndex, keypressFrame, frameCount;
@ -20,9 +20,12 @@ namespace RPI_Matrix {
// Connect to RGB LED Matrix
RGBLedMatrix matrix = new(
new RGBLedMatrixOptions {
HardwareMapping = "adafruit-hat",
LimitRefreshRateHz = 0,
GpioSlowdown = 5,
ChainLength = 3,
Parallel = 3,
ChainLength = 1,
Parallel = 1,
ScanMode = 1,
Rows = 64,
Cols = 64,
});
@ -37,7 +40,7 @@ namespace RPI_Matrix {
new Thread(InterpretGamepadInput).Start();
// Initialize Text-Font and -Color
RGBLedFont font = new("fonts/9x18B.bdf");
RGBLedFont font = new("fonts/5x8.bdf");
Color col = new(255, 255, 255);
// Game Menu
@ -50,15 +53,15 @@ namespace RPI_Matrix {
while (selection) {
// Display Games and Cursor on Matrix
canvas.Clear();
canvas.DrawText(font, 0, 18, col, "Spielauswahl:");
canvas.DrawText(font, 0, 54, col, " ) SnakeGame");
canvas.DrawText(font, 0, 72, col, " ) FlappyBird");
canvas.DrawText(font, 0, 90, col, " ) Tetris");
canvas.DrawText(font, 0, 126, col, " ) Einstellungen");
canvas.DrawText(font, 0, 144, col, " ) Beenden");
canvas.DrawText(font, 0, 8, col, "Spielauswahl:");
canvas.DrawText(font, 0, 24, col, " ) SnakeGame");
canvas.DrawText(font, 0, 32, col, " ) FlappyBird");
canvas.DrawText(font, 0, 40, col, " ) Tetris");
canvas.DrawText(font, 0, 56, col, " ) Einstell.");
canvas.DrawText(font, 0, 64, col, " ) Beenden");
// Cursor is a '#' at (0, 24 + i * 8) where i may be [0, 1, 2, 3, 5]
int nx = selectionIndex + ((selectionIndex >= 3) ? 1 : 0);
canvas.DrawText(font, 0, 54 + nx * 18, col, "#");
canvas.DrawText(font, 0, 24 + nx * 8, col, "#");
canvas = matrix.SwapOnVsync(canvas);
// Handle key presses for selecting a game
@ -134,31 +137,35 @@ namespace RPI_Matrix {
selection = false;
// Initialize Text-Font and -Color
RGBLedFont font = new("fonts/9x18B.bdf");
RGBLedFont font = new("fonts/5x8.bdf");
Color col = new(255, 255, 255);
// Game selection Menu
debugMenu = true;
while (debugMenu) {
// Cursor is a '#' at (0, 24 + i * 8) where i may be [0, 2]
int nx = debugIndex, ny = 0;
if (debugIndex >= 1) nx++;
if (debugIndex >= 4) {
nx += 2;
ny += 3;
}
if (debugIndex >= 5) nx++;
// Calculate offset based on cursor
// Display Games and Cursor on Matrix
canvas.Clear();
canvas.DrawText(font, 0, 18, col, "Tetris:");
canvas.DrawText(font, 0, 36, col, $" ) PTB Logo {(Tetris.Tetris.ptbLogo ? "I" : "O")}");
canvas.DrawText(font, 0, 54, col, "FlappyBird:");
canvas.DrawText(font, 0, 72, col, $" ) Höhe {FlappyBird.FlappyBird.spaceHeight}");
canvas.DrawText(font, 0, 90, col, $" ) Gravitation {FlappyBird.FlappyBird.gravity}");
canvas.DrawText(font, 0, 108, col, $" ) Sprung Ges. {FlappyBird.FlappyBird.jumpVel}");
canvas.DrawText(font, 0, 126, col, "SnakeGame");
canvas.DrawText(font, 0, 144, col, $" ) Basis Länge {SnakeGame.SnakeGame.baseLength}");
canvas.DrawText(font, 0, 180, col, " ) Zurück");
// Cursor is a '#' at (0, 24 + i * 8) where i may be [0, 2]
int nx = debugIndex;
if (debugIndex >= 1) nx++;
if (debugIndex >= 4) nx++;
if (debugIndex >= 5) nx++;
canvas.DrawText(font, 0, 36 + nx * 18, col, "#");
canvas.DrawText(font, 0, 8 - ny * 8, col, "Tetris:");
canvas.DrawText(font, 0, 16 - ny * 8, col, $" ) PTB Logo {(Tetris.Tetris.ptbLogo ? "I" : "O")}");
canvas.DrawText(font, 0, 24 - ny * 8, col, "FlappyBird:");
canvas.DrawText(font, 0, 32 - ny * 8, col, $" ) Höhe {FlappyBird.FlappyBird.spaceHeight}");
canvas.DrawText(font, 0, 40 - ny * 8, col, $" ) Grav. {FlappyBird.FlappyBird.gravity}");
canvas.DrawText(font, 0, 48 - ny * 8, col, $" ) Spr. {FlappyBird.FlappyBird.jumpVel}");
canvas.DrawText(font, 0, 64 - ny * 8, col, "SnakeGame");
canvas.DrawText(font, 0, 72 - ny * 8, col, $" ) Basis {SnakeGame.SnakeGame.baseLength}");
canvas.DrawText(font, 0, 88 - ny * 8, col, " ) Zurück");
// Display Cursor
canvas.DrawText(font, 0, 16 + (nx - ny) * 8, col, "#");
canvas = matrix.SwapOnVsync(canvas);
// Handle key presses for selecting a game

View File

@ -13,14 +13,13 @@
<PropertyGroup>
<MainEntryPoint>RPI_Matrix.RPI_Matrix</MainEntryPoint>
<StartupObject>RPI_Matrix.RPI_Matrix</StartupObject>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<SelfContained>true</SelfContained>
<TargetFramework>net6.0</TargetFramework>
<PublishReadyToRun>true</PublishReadyToRun>
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<StartupObject>RPI_Matrix.RPI_Matrix</StartupObject>
</PropertyGroup>
<ItemGroup>

Binary file not shown.