This demo shows off various features of drawing with the Bitmap class to a DMD display:
- Drawing circles, lines, and rectangles.
- Filling the screen with a bitmap-based brick pattern.
- Drawing bitmaps directly from program memory.
- Drawing text in various fonts.
- Scrolling text in a "marquee".
RunningFigure provides another example of drawing and animating bitmaps.
The full source code for the demo follows:
#include <DMD.h>
#include <DejaVuSans9.h>
#include <DejaVuSansBold9.h>
#include <DejaVuSansItalic9.h>
#include <Mono5x7.h>
ISR(TIMER1_OVF_vect)
{
}
void setup() {
}
void loop() {
drawShapes();
delay(1000);
drawBricks();
delay(1000);
drawStickFigures();
delay(1000);
drawText();
delay(1000);
drawBoldText();
delay(1000);
drawItalicText();
delay(1000);
drawMonoText();
delay(1000);
drawMarquee();
delay(500);
}
void drawShapes()
{
}
void drawBricks()
{
static const uint8_t bricks[] PROGMEM = {
16, 6,
B11111111, B11111111,
B10000000, B10000000,
B10000000, B10000000,
B11111111, B11111111,
B00001000, B00001000,
B00001000, B00001000
};
}
void drawStickFigures()
{
static const uint8_t stickFigure[] PROGMEM = {
9, 13,
B00111110, B00000000,
B01000001, B00000000,
B01000001, B00000000,
B00111110, B00000000,
B00001000, B00000000,
B00001000, B00000000,
B11111111, B10000000,
B00001000, B00000000,
B00001000, B00000000,
B00010100, B00000000,
B00100010, B00000000,
B01000001, B00000000,
B10000000, B10000000
};
}
void drawText()
{
}
void drawBoldText()
{
}
void drawItalicText()
{
display.
setFont(DejaVuSansItalic9);
}
void drawMonoText()
{
}
static const char message[] = "Eat at Joes!";
void drawMarquee()
{
int width = display.
width();
int fullScroll = msgWidth + width + 1;
for (int x = 0; x < fullScroll; ++x) {
display.
drawText(width - x, 3, message);
delay(50);
}
}