Displays text on a WS2812 (NeoPixel) matrix display

Dependencies:   mbed miniFont wsDrive

Displays text on an array of WS2812 LEDs (NeoPixels)

Text is 5 rows tall so any grid larger than that can be used. The font supports A-Z (capitals only, any lowercase input will be capitalised) numbers and some basic punctuation. Letters are 5 LEDs wide, some numbers and punctuation are smaller but generally you need 6 pixels wide per character you wish to fit. If displaying a string a 1 row space is left between characters, for other spacings either edit the code or print one letter at a time and adjust the offset for the next letter.

LEDs must be connected in horizontal rows, top row first. Rows can be either direction or alternating directions.

NOTE: The testing on this has been fairly minimal. It works with my one physical configuration, I think the logic for other configurations is correct but haven't tested it. If you find a problem please let me know.

Committer:
AndyA
Date:
Thu Nov 06 17:32:12 2014 +0000
Revision:
1:2014f027ed6f
Parent:
0:bada179a0b70
Tidied up a bit.; Added option to reverse direction of the top row. ; Added the initGradient function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AndyA 0:bada179a0b70 1 #ifndef __miniFont_h__
AndyA 0:bada179a0b70 2 #define __miniFont_h__
AndyA 0:bada179a0b70 3
AndyA 0:bada179a0b70 4 #include "mbed.h"
AndyA 0:bada179a0b70 5
AndyA 0:bada179a0b70 6 class miniFont
AndyA 0:bada179a0b70 7 {
AndyA 0:bada179a0b70 8 public:
AndyA 0:bada179a0b70 9
AndyA 0:bada179a0b70 10 miniFont();
AndyA 0:bada179a0b70 11 uint8_t getPixWidth(char letter);
AndyA 0:bada179a0b70 12 uint8_t getPixHeight(char letter);
AndyA 0:bada179a0b70 13 bool getChar(char letter, const char **rowArray);
AndyA 0:bada179a0b70 14
AndyA 0:bada179a0b70 15 bool isFixedWidth() {return fixedWidth;};
AndyA 0:bada179a0b70 16 void setFixedWidth(bool newValue) {fixedWidth = newValue;};
AndyA 0:bada179a0b70 17
AndyA 0:bada179a0b70 18 bool isRotated() {return rotate90;};
AndyA 0:bada179a0b70 19 void setRotated(bool newValue) {rotate90 = newValue;};
AndyA 0:bada179a0b70 20
AndyA 0:bada179a0b70 21 private:
AndyA 0:bada179a0b70 22
AndyA 0:bada179a0b70 23
AndyA 0:bada179a0b70 24 uint8_t getMinPixWidth(char letter);
AndyA 0:bada179a0b70 25 bool getRawChar(char letter, const char **rowArray);
AndyA 0:bada179a0b70 26 bool getVerticalChar(char letter, const char **rowArray);
AndyA 0:bada179a0b70 27
AndyA 0:bada179a0b70 28 static const uint8_t maxWidth = 5;
AndyA 0:bada179a0b70 29 static const uint8_t maxHeight = 5;
AndyA 0:bada179a0b70 30
AndyA 0:bada179a0b70 31 bool rotate90;
AndyA 0:bada179a0b70 32 bool fixedWidth;
AndyA 0:bada179a0b70 33 char letterBuffer[5];
AndyA 0:bada179a0b70 34 char rotateBuffer[5];
AndyA 0:bada179a0b70 35
AndyA 0:bada179a0b70 36
AndyA 0:bada179a0b70 37 static const char letters[26][5];
AndyA 0:bada179a0b70 38
AndyA 0:bada179a0b70 39 static const char numbers[10][5];
AndyA 0:bada179a0b70 40
AndyA 0:bada179a0b70 41 static const char dot[5];
AndyA 0:bada179a0b70 42 static const char space[5];
AndyA 0:bada179a0b70 43 static const char exclam[5];
AndyA 0:bada179a0b70 44 static const char quest[5];
AndyA 0:bada179a0b70 45
AndyA 0:bada179a0b70 46 };
AndyA 0:bada179a0b70 47
AndyA 0:bada179a0b70 48
AndyA 0:bada179a0b70 49 #endif