Skip to content

Commit 5a84641

Browse files
authored
Merge pull request #1309 from arduino/karlsoderby/unor4-update-6sep
[UNO R4 WiFi] Add Scroll example
2 parents e647ad0 + a7f6849 commit 5a84641

File tree

1 file changed

+59
-4
lines changed
  • content/hardware/02.hero/boards/uno-r4-wifi/tutorials/led-matrix

1 file changed

+59
-4
lines changed

content/hardware/02.hero/boards/uno-r4-wifi/tutorials/led-matrix/led-matrix.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: "Using the Arduino UNO R4 WiFi LED Matrix"
3-
description: "Get off the ground with the Arduino UNO R4 WiFi's built in LED matrix. Learn the different techniques for controlling it, create animations, graphics or even games."
2+
title: 'Using the Arduino UNO R4 WiFi LED Matrix'
3+
description: 'Get off the ground with the Arduino UNO R4 WiFi built-in LED matrix. Learn the different techniques for controlling it, create animations, graphics or even games.'
44
tags:
55
- Guide
66
- LED Matrix
@@ -276,7 +276,62 @@ matrix.renderBitmap(frame, 8, 12);
276276
delay(1000);
277277
}
278278
```
279-
279+
280+
## Scrolling Text Example
281+
282+
The LED Matrix now supports printing characters via the [ArduinoGraphics](https://github.com/arduino-libraries/ArduinoGraphics) library. With it, you are able to:
283+
- Set a start location for the text via `matrix.beginText(x,y, 0xFFFFFF)`. The "0xFFFFFF" represents the default color (red). As the **ArduinoGraphics** library supports other hardware with multiple colors, we need to specify it.
284+
- Print the text via `matrix.printText("This message is printed")`
285+
- End the print and (optionally) specify scroll direction with `matrix.endText(direction)`
286+
- `SCROLL_LEFT`, `SCROLL_RIGHT` are supported. Leave blank if no scroll is desired.
287+
288+
The example below simply prints out **"Hello World!"** on the matrix.
289+
290+
```arduino
291+
// To use ArduinoGraphics APIs, please include BEFORE Arduino_LED_Matrix
292+
#include "ArduinoGraphics.h"
293+
#include "Arduino_LED_Matrix.h"
294+
295+
ArduinoLEDMatrix matrix;
296+
297+
void setup() {
298+
Serial.begin(115200);
299+
matrix.begin();
300+
301+
matrix.beginDraw();
302+
matrix.stroke(0xFFFFFFFF);
303+
// add some static text
304+
// will only show "UNO" (not enough space on the display)
305+
const char text[] = "UNO r4";
306+
matrix.textFont(Font_4x6);
307+
matrix.beginText(0, 1, 0xFFFFFF);
308+
matrix.println(text);
309+
matrix.endText();
310+
311+
matrix.endDraw();
312+
313+
delay(2000);
314+
}
315+
316+
void loop() {
317+
318+
// Make it scroll!
319+
matrix.beginDraw();
320+
321+
matrix.stroke(0xFFFFFFFF);
322+
matrix.textScrollSpeed(50);
323+
324+
// add the text
325+
const char text[] = " Hello World! ";
326+
matrix.textFont(Font_5x7);
327+
matrix.beginText(0, 1, 0xFFFFFF);
328+
matrix.println(text);
329+
matrix.endText(SCROLL_LEFT);
330+
331+
matrix.endDraw();
332+
}
333+
```
334+
280335
## Animation Generation
281336
We have developed a tool that is used to generate frames and animations to be rendered on the LED Matrix in your browser. This tool is part of [Arduino labs](https://labs.arduino.cc), and is therefore considered experimental software.
282337

@@ -311,7 +366,7 @@ void loop() {
311366
[Click here](https://ledmatrix-editor.arduino.cc) to go to the LED Matrix tool.
312367

313368

314-
![LED Matrix Editor](./assets/led-matrix-tool.png)
369+
![LED Matrix Editor](assets/led-matrix-tool.png)
315370

316371
Once you've made your animations, you can export them from the tool in the format that lets you use them like [previously discussed](#how-to-write-a-frame).
317372

0 commit comments

Comments
 (0)