mirror of
https://gitlab.waag.org/make/fablab/interns/2025/sam.git
synced 2025-08-03 11:54:58 +00:00
Compare commits
2 Commits
7b81c1dda8
...
2dd30990bc
Author | SHA1 | Date | |
---|---|---|---|
2dd30990bc | |||
5104f71dc6 |
@@ -38,9 +38,10 @@
|
||||
// lines are arranged in columns, progressive order. The shield uses
|
||||
// 800 KHz (v2) pixels that expect GRB color data.
|
||||
|
||||
void scrollingText(String text, int speed);
|
||||
void scrollingText(String text, int speed, int color);
|
||||
void playGif(const uint16_t* gifData[], int frameCount, int frameDelay);
|
||||
void displayFullScreenBMP(const uint16_t* bitmap);
|
||||
void bootSequence();
|
||||
|
||||
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
|
||||
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
|
||||
@@ -48,35 +49,47 @@ Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
|
||||
NEO_GRB + NEO_KHZ800);
|
||||
|
||||
const uint16_t colors[] = {
|
||||
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };
|
||||
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) }; //RGB
|
||||
|
||||
void setup() {
|
||||
matrix.begin();
|
||||
matrix.setTextWrap(false);
|
||||
matrix.setBrightness(40);
|
||||
matrix.setTextColor(colors[0]);
|
||||
matrix.setBrightness(25);
|
||||
matrix.setTextColor(matrix.Color(255, 255, 255));
|
||||
|
||||
bootSequence();
|
||||
}
|
||||
|
||||
int x = matrix.width();
|
||||
int pass = 0;
|
||||
|
||||
void loop() {
|
||||
displayFullScreenBMP(EEP);
|
||||
scrollingText("BOO AAAA!", 50, matrix.Color(255, 0, 255));
|
||||
}
|
||||
|
||||
void scrollingText(String text, int speed) {
|
||||
matrix.fillScreen(0);
|
||||
matrix.setCursor(x, 0);
|
||||
matrix.print(text);
|
||||
|
||||
if(--x < -(text.length() * 6)) {
|
||||
x = matrix.width();
|
||||
if(++pass >= 3) pass = 0;
|
||||
matrix.setTextColor(colors[pass]);
|
||||
void scrollingText(String text, int speed, int color) {
|
||||
// Save original position and color state
|
||||
int textX = matrix.width();
|
||||
int textPass = 0;
|
||||
matrix.setTextColor(color);
|
||||
|
||||
// Calculate the total scroll distance needed for the text to completely scroll through
|
||||
// We want to scroll until the text has fully entered from the right AND fully exited to the left
|
||||
int textWidth = text.length() * 6; // Approx 6 pixels per character
|
||||
int totalScrollDistance = matrix.width() + textWidth;
|
||||
|
||||
// Continue scrolling until the text has completely passed through
|
||||
for (int i = 0; i < totalScrollDistance; i++) {
|
||||
matrix.fillScreen(0);
|
||||
matrix.setCursor(textX, 0);
|
||||
matrix.print(text);
|
||||
matrix.show();
|
||||
|
||||
// Move text position one pixel to the left
|
||||
textX--;
|
||||
|
||||
delay(speed);
|
||||
}
|
||||
matrix.show();
|
||||
delay(speed);
|
||||
|
||||
}
|
||||
|
||||
void playGif(const uint16_t* gifData[], int frameCount, int frameDelay) {
|
||||
@@ -104,4 +117,17 @@ void displayFullScreenBMP(const uint16_t* bitmap) {
|
||||
int height = matrix.height();
|
||||
matrix.drawRGBBitmap(0, 0, bitmap, width, height);
|
||||
matrix.show();
|
||||
}
|
||||
|
||||
void bootSequence() {
|
||||
//just display something cool on startup. This is hardcoded asf
|
||||
|
||||
matrix.fillScreen(0);
|
||||
matrix.setCursor(5, 0);
|
||||
matrix.setTextColor(matrix.Color(0, 0, 255));
|
||||
matrix.print("Boot");
|
||||
matrix.show();
|
||||
|
||||
delay(5000);
|
||||
|
||||
}
|
Reference in New Issue
Block a user