Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (88 sloc) 2.825 kb
27e5b20 @kigster #ifndef to avoid "Redefition of class error"
kigster authored
1 #ifndef HT1632_H_
2 #define HT1632_H_
3
dd535ea @PaintYourDragon Arduino 1.0 compatible
PaintYourDragon authored
4 #if(ARDUINO >= 100)
5 #include <Arduino.h>
6 #else
7 #include <WProgram.h>
8 #endif
56176ed @ladyada initial commit
ladyada authored
9
10 #define HT1632_READ 0x6
11 #define HT1632_WRITE 0x5
12 #define HT1632_COMMAND 0x4
13
14 #define HT1632_SYS_DIS 0x00
15 #define HT1632_SYS_EN 0x01
16 #define HT1632_LED_OFF 0x02
17 #define HT1632_LED_ON 0x03
18 #define HT1632_BLINK_OFF 0x08
19 #define HT1632_BLINK_ON 0x09
20 #define HT1632_SLAVE_MODE 0x10
21 #define HT1632_MASTER_MODE 0x14
22 #define HT1632_INT_RC 0x18
23 #define HT1632_EXT_CLK 0x1C
24 #define HT1632_PWM_CONTROL 0xA0
25
26 #define HT1632_COMMON_8NMOS 0x20
27 #define HT1632_COMMON_16NMOS 0x24
28 #define HT1632_COMMON_8PMOS 0x28
29 #define HT1632_COMMON_16PMOS 0x2C
30
31 class HT1632 {
32
33 public:
34 HT1632(int8_t data, int8_t wr, int8_t cs, int8_t rd = -1);
35
36 void begin(uint8_t type);
37
94a6f3d @ladyada Added brightness control and blink()
ladyada authored
38 void clrPixel(uint16_t i);
39 void setPixel(uint16_t i);
40
41 void blink(boolean state);
42 void setBrightness(uint8_t pwm);
43
56176ed @ladyada initial commit
ladyada authored
44 void clearScreen();
45 void fillScreen();
46 void writeScreen();
47 void dumpScreen();
94a6f3d @ladyada Added brightness control and blink()
ladyada authored
48
56176ed @ladyada initial commit
ladyada authored
49 private:
50 int8_t WIDTH, HEIGHT;
51 int8_t _data, _cs, _wr, _rd;
52 uint8_t ledmatrix[48]; // 16 * 24 / 8
d10f9a0 @PaintYourDragon Arduino 1.0 compliant
PaintYourDragon authored
53 void sendcommand(uint8_t c);
56176ed @ladyada initial commit
ladyada authored
54 void writedata(uint16_t d, uint8_t bits);
55 void writeRAM(uint8_t addr, uint8_t data);
56 };
b21983a @ladyada Add example tester
ladyada authored
57
48919d9 @ladyada shapes, text, examples.
ladyada authored
58 class HT1632LEDMatrix : public Print {
b21983a @ladyada Add example tester
ladyada authored
59 public:
60 HT1632LEDMatrix(uint8_t data, uint8_t wr, uint8_t cs1);
b41fc01 @ladyada Added support for 2 chained displays
ladyada authored
61 HT1632LEDMatrix(uint8_t data, uint8_t wr, uint8_t cs1, uint8_t cs2);
49577de @ladyada Support for 4 panels, clearing pixels
ladyada authored
62 HT1632LEDMatrix(uint8_t data, uint8_t wr, uint8_t cs1,
63 uint8_t cs, uint8_t cs3);
64 HT1632LEDMatrix(uint8_t data, uint8_t wr, uint8_t cs1,
65 uint8_t cs2, uint8_t cs3, uint8_t cs4);
b21983a @ladyada Add example tester
ladyada authored
66
b41fc01 @ladyada Added support for 2 chained displays
ladyada authored
67 void begin(uint8_t type);
68 void clearScreen(void);
69 void fillScreen(void);
70 void blink(boolean b);
71 void setBrightness(uint8_t brightness);
72 void writeScreen();
73 uint8_t width();
74 uint8_t height();
75
49577de @ladyada Support for 4 panels, clearing pixels
ladyada authored
76 void clrPixel(uint8_t x, uint8_t y);
b41fc01 @ladyada Added support for 2 chained displays
ladyada authored
77 void setPixel(uint8_t x, uint8_t y);
49577de @ladyada Support for 4 panels, clearing pixels
ladyada authored
78 void drawPixel(uint8_t x, uint8_t y, uint8_t color);
b21983a @ladyada Add example tester
ladyada authored
79
48919d9 @ladyada shapes, text, examples.
ladyada authored
80 void drawLine(int8_t x0, int8_t y0, int8_t x1, int8_t y1, uint8_t color);
81 void drawRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color);
82 void fillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color);
83 void drawCircle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color);
84 void fillCircle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color);
85
86 // Printing
87 void setCursor(uint8_t x, uint8_t y);
88 void setTextSize(uint8_t s);
89 void setTextColor(uint8_t c);
dd535ea @PaintYourDragon Arduino 1.0 compatible
PaintYourDragon authored
90 #if(ARDUINO >= 100)
91 size_t write(uint8_t c);
92 #else
48919d9 @ladyada shapes, text, examples.
ladyada authored
93 void write(uint8_t c);
dd535ea @PaintYourDragon Arduino 1.0 compatible
PaintYourDragon authored
94 #endif
48919d9 @ladyada shapes, text, examples.
ladyada authored
95 void drawChar(uint8_t x, uint8_t y, char c, uint16_t color, uint8_t size);
96
e37df68 @ladyada added bitmap drawing ability, tweaked examples
ladyada authored
97 void drawBitmap(uint8_t x, uint8_t y,
98 const uint8_t *bitmap, uint8_t w, uint8_t h,
99 uint8_t color);
48919d9 @ladyada shapes, text, examples.
ladyada authored
100
101
b21983a @ladyada Add example tester
ladyada authored
102 private:
103 HT1632 *matrices;
b41fc01 @ladyada Added support for 2 chained displays
ladyada authored
104 uint8_t matrixNum, _width, _height;
48919d9 @ladyada shapes, text, examples.
ladyada authored
105 uint8_t cursor_x, cursor_y, textsize, textcolor;
b21983a @ladyada Add example tester
ladyada authored
106 };
27e5b20 @kigster #ifndef to avoid "Redefition of class error"
kigster authored
107
108
109 #endif /* HT1632_H_ */
Something went wrong with that request. Please try again.