1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Library for using Freetronics dot matrix displays

This commit is contained in:
Rhys Weatherley
2012-05-25 17:41:27 +10:00
parent d26dcdc740
commit 081aab987b
20 changed files with 3030 additions and 2 deletions

View File

@@ -0,0 +1,144 @@
/*
This example demonstrates how to use the DMD and related classes to
draw things on a Freetronics Large Dot Matrix Display.
This example is placed into the public domain.
*/
#include <DMD.h>
#include <DejaVuSans9.h>
#include <DejaVuSansBold9.h>
#include <DejaVuSansItalic9.h>
#include <Mono5x7.h>
DMD display;
ISR(TIMER1_OVF_vect)
{
display.refresh();
}
void setup() {
display.enableTimer1();
}
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()
{
display.clear();
display.drawCircle(6, 8, 3);
display.drawFilledCircle(16, 8, 3);
display.drawLine(22, 5, 28, 11);
display.drawLine(28, 5, 22, 11);
display.drawRect(0, 0, display.width() - 1, display.height() - 1);
}
void drawBricks()
{
static const uint8_t bricks[] PROGMEM = {
16, 6,
B11111111, B11111111,
B10000000, B10000000,
B10000000, B10000000,
B11111111, B11111111,
B00001000, B00001000,
B00001000, B00001000
};
display.fill(0, 0, display.width(), display.height(), bricks);
}
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
};
display.clear();
display.drawBitmap(2, 1, stickFigure);
display.drawInvertedBitmap(12, 1, stickFigure);
display.drawBitmap(22, 1, stickFigure);
}
void drawText()
{
display.clear();
display.setFont(DejaVuSans9);
display.drawText(0, 0, "Hello");
display.drawText(9, 8, "World");
}
void drawBoldText()
{
display.clear();
display.setFont(DejaVuSansBold9);
display.drawText(0, 0, "Hello");
display.drawText(4, 8, "World");
}
void drawItalicText()
{
display.clear();
display.setFont(DejaVuSansItalic9);
display.drawText(0, 0, "Hello");
display.drawText(2, 8, "World");
}
void drawMonoText()
{
display.clear();
display.setFont(Mono5x7);
display.drawText(0, 0, "Hello");
display.drawText(3, 8, "World");
}
static const char message[] = "Eat at Joes!";
void drawMarquee()
{
int width = display.width();
display.setFont(DejaVuSans9);
int msgWidth = display.textWidth(message);
int fullScroll = msgWidth + width + 1;
for (int x = 0; x < fullScroll; ++x) {
display.clear();
display.drawText(width - x, 3, message);
delay(50);
}
}

View File

@@ -0,0 +1,135 @@
/*
* Copyright (C) 2012 Southern Storm Software, Pty Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <DMD.h>
DMD display;
// Running stick figure pictures are loosely based on those from this tutorial:
// http://www.fluidanims.com/FAelite/phpBB3/viewtopic.php?f=10&t=102
byte const run1[] PROGMEM = {
16, 16,
B00000000, B00001100,
B00000000, B00011110,
B00000111, B11111110,
B00001111, B11111110,
B00011100, B11111100,
B00000001, B11111100,
B00000001, B11110000,
B00000011, B11111000,
B00000111, B00011000,
B00001110, B01110000,
B00011100, B01100000,
B00111000, B00000000,
B01110000, B00000000,
B01100000, B00000000,
B01000000, B00000000,
B00000000, B00000000
};
byte const run2[] PROGMEM = {
18, 16,
B00000000, B01110011, B10000000,
B00000000, B11111111, B10000000,
B00000000, B00011111, B10000000,
B00000000, B00111111, B11000000,
B00000000, B01111011, B11000000,
B00000000, B11110011, B10000000,
B00000001, B11100000, B00000000,
B00000011, B11100000, B00000000,
B00000111, B01110000, B00000000,
B01111110, B00111000, B00000000,
B11111100, B00011100, B00000000,
B00000000, B00001110, B00000000,
B00000000, B00000111, B00000000,
B00000000, B00000011, B10000000,
B00000000, B00000001, B00000000,
B00000000, B00000000, B00000000
};
byte const run3[] PROGMEM = {
18, 16,
B00000000, B00110000, B00000000,
B00000000, B01111000, B00000000,
B00000000, B00011111, B00000000,
B00000000, B00011111, B00000000,
B00000000, B00111111, B10000000,
B00000000, B01111111, B11000000,
B00000000, B11100011, B10000000,
B00000001, B11000000, B00000000,
B00000011, B11100000, B00000000,
B11111111, B01110000, B00000000,
B11111110, B00111000, B00000000,
B00000000, B00011000, B00000000,
B00000000, B00011100, B00000000,
B00000000, B00001110, B00000000,
B00000000, B00000100, B00000000,
B00000000, B00000000, B00000000
};
byte const run4[] PROGMEM = {
16, 16,
B00000001, B11100000,
B00000011, B11111100,
B00000000, B00111110,
B00000000, B01111110,
B00000000, B11111100,
B00000001, B10011111,
B00000011, B00001110,
B00000011, B00000000,
B00000011, B10000000,
B11111111, B10000000,
B11111000, B11000000,
B00000001, B11000000,
B00000011, B10000000,
B00000111, B00000000,
B00000110, B00000000,
B00000100, B00000000
};
const prog_uint8_t *frames[] = {
run1,
run2,
run3,
run4
};
#define NUM_FRAMES (sizeof(frames) / sizeof(frames[0]))
#define ADVANCE_MS (1000 / NUM_FRAMES)
unsigned int frame = 0;
unsigned long lastFrame;
void setup() {
display.drawBitmap(8, 0, run1);
lastFrame = millis();
}
void loop() {
if ((millis() - lastFrame) >= ADVANCE_MS) {
frame = (frame + 1) % NUM_FRAMES;
display.clear();
int x = (32 - pgm_read_byte(frames[frame])) / 2;
display.drawBitmap(x, 0, frames[frame]);
lastFrame += ADVANCE_MS;
}
display.loop();
}