includes go-rpi-rgb-led-matrix as a dep

This commit is contained in:
2023-12-21 11:06:27 -05:00
parent d1d6e2d9f9
commit 4dcea50309
187 changed files with 1174372 additions and 0 deletions
@@ -0,0 +1,41 @@
CSHARP_LIB=RGBLedMatrix.dll
CSHARP_COMPILER=mcs
CSHARP_LIBDIR=..
CSHARP_LIBRARY=$(CSHARP_LIBDIR)/$(CSHARP_LIB)
RGB_LIBDIR=../../../lib
RGB_LIBRARY_NAME=librgbmatrix
RGB_LIBRARY=$(RGB_LIBDIR)/$(RGB_LIBRARY_NAME).so.1
all: $(CSHARP_LIB)
cp $(RGB_LIBRARY) $(RGB_LIBRARY_NAME).so
cp $(CSHARP_LIBRARY) $(CSHARP_LIB)
$(CSHARP_COMPILER) -r:$(CSHARP_LIB) -out:minimal-example.exe minimal-example.cs
$(CSHARP_COMPILER) -r:$(CSHARP_LIB) -out:matrix-rain.exe matrix-rain.cs
$(CSHARP_COMPILER) -r:$(CSHARP_LIB) -out:font-example.exe font-example.cs
$(CSHARP_COMPILER) -r:$(CSHARP_LIB) -out:pulsing-brightness.exe pulsing-brightness.cs
minimal-example.exe: $(CSHARP_LIB)
cp $(RGB_LIBRARY) $(RGB_LIBRARY_NAME).so
cp $(CSHARP_LIBRARY) $(CSHARP_LIB)
$(CSHARP_COMPILER) -r:$(CSHARP_LIB) -out:minimal-example.exe minimal-example.cs
matrix-rain.exe: $(CSHARP_LIB)
cp $(RGB_LIBRARY) $(RGB_LIBRARY_NAME).so
cp $(CSHARP_LIBRARY) $(CSHARP_LIB)
$(CSHARP_COMPILER) -r:$(CSHARP_LIB) -out:matrix-rain.exe matrix-rain.cs
font-example.exe: $(CSHARP_LIB)
cp $(RGB_LIBRARY) $(RGB_LIBRARY_NAME).so
cp $(CSHARP_LIBRARY) $(CSHARP_LIB)
$(CSHARP_COMPILER) -r:$(CSHARP_LIB) -out:font-example.exe font-example.cs
pulsing-brightness.exe: $(CSHARP_LIB)
cp $(RGB_LIBRARY) $(RGB_LIBRARY_NAME).so
cp $(CSHARP_LIBRARY) $(CSHARP_LIB)
$(CSHARP_COMPILER) -r:$(CSHARP_LIB) -out:pulsing-brightness.exe pulsing-brightness.cs
$(CSHARP_LIB) :
$(MAKE) -C $(CSHARP_LIBDIR)
.PHONY : all
@@ -0,0 +1,36 @@
using rpi_rgb_led_matrix_sharp;
using System;
using System.Threading;
namespace font_example
{
class Program
{
static int Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("font-example.exe [font_path] <text>");
return -1;
}
string text = "Hello World!";
if (args.Length > 1)
text = args[1];
var matrix = new RGBLedMatrix(32, 2, 1);
var canvas = matrix.CreateOffscreenCanvas();
var font = new RGBLedFont(args[0]);
canvas.DrawText(font, 1, 6, new Color(0, 255, 0), text);
matrix.SwapOnVsync(canvas);
while (!Console.KeyAvailable)
{
Thread.Sleep(250);
}
return 0;
}
}
}
@@ -0,0 +1,90 @@
using rpi_rgb_led_matrix_sharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace matrix_rain
{
class Program
{
const int MAX_HEIGHT = 16;
const int COLOR_STEP = 15;
const int FRAME_STEP = 1;
static int Main(string[] args)
{
var matrix = new RGBLedMatrix(new RGBLedMatrixOptions { ChainLength = 2 });
var canvas = matrix.CreateOffscreenCanvas();
var rnd = new Random();
var points = new List<Point>();
var recycled = new Stack<Point>();
int frame = 0;
var stopwatch = new Stopwatch();
while (!Console.KeyAvailable) {
stopwatch.Restart();
frame++;
if (frame % FRAME_STEP == 0)
{
if (recycled.Count == 0)
points.Add(new Point(rnd.Next(0, canvas.Width - 1), 0));
else
{
var point = recycled.Pop();
point.x = rnd.Next(0, canvas.Width - 1);
point.y = 0;
point.recycled = false;
}
}
canvas.Clear();
foreach (var point in points)
{
if (!point.recycled)
{
point.y++;
if (point.y - MAX_HEIGHT > canvas.Height)
{
point.recycled = true;
recycled.Push(point);
}
for (var i=0; i< MAX_HEIGHT; i++)
{
canvas.SetPixel(point.x, point.y - i, new Color(0, 255 - i * COLOR_STEP, 0));
}
}
}
canvas = matrix.SwapOnVsync(canvas);
// force 30 FPS
var elapsed= stopwatch.ElapsedMilliseconds;
if (elapsed < 33)
{
Thread.Sleep(33 - (int)elapsed);
}
}
return 0;
}
class Point
{
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
public int x;
public int y;
public bool recycled;
}
}
}
@@ -0,0 +1,32 @@
using rpi_rgb_led_matrix_sharp;
namespace minimal_example
{
class Program
{
static int Main(string[] args)
{
var matrix= new RGBLedMatrix(32, 2, 1);
var canvas = matrix.CreateOffscreenCanvas();
for (var i = 0; i < 1000; ++i)
{
for (var y = 0; y < canvas.Height; ++y)
{
for (var x = 0; x < canvas.Width; ++x)
{
canvas.SetPixel(x, y, new Color(i & 0xff, x, y));
}
}
canvas.DrawCircle(canvas.Width / 2, canvas.Height / 2, 6, new Color(0, 0, 255));
canvas.DrawLine(canvas.Width / 2 - 3, canvas.Height / 2 - 3, canvas.Width / 2 + 3, canvas.Height / 2 + 3, new Color(0, 0, 255));
canvas.DrawLine(canvas.Width / 2 - 3, canvas.Height / 2 + 3, canvas.Width / 2 + 3, canvas.Height / 2 - 3, new Color(0, 0, 255));
canvas = matrix.SwapOnVsync(canvas);
}
return 0;
}
}
}
@@ -0,0 +1,54 @@
using rpi_rgb_led_matrix_sharp;
using System;
using System.Threading;
namespace pulsing_brightness
{
class Program
{
static int Main(string[] args)
{
var matrix = new RGBLedMatrix(new RGBLedMatrixOptions {Rows = 32, Cols = 64});
var canvas = matrix.CreateOffscreenCanvas();
var maxBrightness = matrix.Brightness;
var count = 0;
const int c = 255;
while (!Console.KeyAvailable)
{
if (matrix.Brightness < 1)
{
matrix.Brightness = maxBrightness;
count += 1;
}
else
{
matrix.Brightness -= 1;
}
switch (count % 4)
{
case 0:
canvas.Fill(new Color(c, 0, 0));
break;
case 1:
canvas.Fill(new Color(0, c, 0));
break;
case 2:
canvas.Fill(new Color(0, 0, c));
break;
case 3:
canvas.Fill(new Color(c, c, c));
break;
}
canvas = matrix.SwapOnVsync(canvas);
Thread.Sleep(20);
}
return 0;
}
}
}