COSA
An Object-Oriented Platform for Arduino Programming
MAX72XX.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_MAX72XX_HH
22 #define COSA_MAX72XX_HH
23 
24 #include "Cosa/LCD.hh"
25 
64 class MAX72XX : public LCD::Device {
65 public:
67  static const uint8_t WIDTH = 8;
68  static const uint8_t HEIGHT = 1;
69  static const uint8_t LINES = 1;
70 
78  MAX72XX(LCD::IO* io, const uint8_t* font = NULL);
79 
86  virtual bool begin();
87 
93  virtual bool end();
94 
100  virtual void display_contrast(uint8_t level);
101 
106  virtual void display_on();
107 
112  virtual void display_off();
113 
118  virtual void display_clear();
119 
126  virtual void set_cursor(uint8_t x, uint8_t y);
127 
137  virtual int putchar(char c);
138 
139 protected:
143  enum Register {
144  NOP = 0x00,
145  DIGIT0 = 0x01,
146  DIGIT1 = 0x02,
147  DIGIT2 = 0x03,
148  DIGIT3 = 0x04,
149  DIGIT4 = 0x05,
150  DIGIT5 = 0x06,
151  DIGIT6 = 0x07,
152  DIGIT7 = 0x08,
153  DECODE_MODE = 0x09,
154  INTENSITY = 0x0a,
155  SCAN_LIMIT = 0x0b,
156  DISPLAY_MODE = 0x0c,
157  DISPLAY_TEST = 0x0f
158  } __attribute__((packed));
159 
163  enum {
164  SHUTDOWN_MODE = 0x00,
166  } __attribute__((packed));
167 
171  enum {
172  NO_DECODE = 0x00,
173  ALL_DECODE = 0xff
174  } __attribute__((packed));
175 
177  static const uint8_t font[] PROGMEM;
178 
181  const uint8_t* m_font;
182  char m_latest;
183 
189  void set(Register reg, uint8_t value);
190 };
191 
192 #endif
virtual void display_clear()
Definition: MAX72XX.cpp:184
virtual void set_cursor(uint8_t x, uint8_t y)
Definition: MAX72XX.cpp:198
char m_latest
Latest character code.
Definition: MAX72XX.hh:182
Digit 5 (encode or segment data).
Definition: MAX72XX.hh:150
virtual int putchar(char c)
Definition: MAX72XX.cpp:205
Display Test (0..1, on/off).
Definition: MAX72XX.hh:157
#define NULL
Definition: Types.h:101
Display Mode (shutdown, normal).
Definition: MAX72XX.hh:156
virtual void display_off()
Definition: MAX72XX.cpp:178
virtual void display_on()
Definition: MAX72XX.cpp:172
virtual void display_contrast(uint8_t level)
Definition: MAX72XX.cpp:192
Decode Mode (0..255, digit bitset).
Definition: MAX72XX.hh:153
Digit 1 (encode or segment data).
Definition: MAX72XX.hh:146
Digit 6 (encode or segment data).
Definition: MAX72XX.hh:151
Intensity (0..15, level).
Definition: MAX72XX.hh:154
No-operation.
Definition: MAX72XX.hh:144
static const uint8_t font[]
Definition: MAX72XX.hh:177
Digit 2 (encode or segment data).
Definition: MAX72XX.hh:147
Digit 3 (encode or segment data).
Definition: MAX72XX.hh:148
MAX72XX(LCD::IO *io, const uint8_t *font=NULL)
Definition: MAX72XX.cpp:137
Definition: LCD.hh:190
Shutdown mode.
Definition: MAX72XX.hh:164
Code B decode for digits 7-0.
Definition: MAX72XX.hh:173
virtual bool begin()
Definition: MAX72XX.cpp:154
No decode for digits 7-0.
Definition: MAX72XX.hh:172
static const uint8_t HEIGHT
Definition: MAX72XX.hh:68
Normal operation.
Definition: MAX72XX.hh:165
virtual bool end()
Definition: MAX72XX.cpp:165
Digit 7 (encode or segment data).
Definition: MAX72XX.hh:152
const uint8_t * m_font
Font in program memory.
Definition: MAX72XX.hh:181
static const uint8_t LINES
Definition: MAX72XX.hh:69
Scan Limit (0..7, digits 1..8).
Definition: MAX72XX.hh:155
Digit 0 (encode or segment data).
Definition: MAX72XX.hh:145
static const uint8_t WIDTH
Definition: MAX72XX.hh:67
LCD::IO * m_io
Display adapter.
Definition: MAX72XX.hh:180
Digit 4 (encode or segment data).
Definition: MAX72XX.hh:149