COSA
An Object-Oriented Platform for Arduino Programming
PCD8544.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_PCD8544_HH
22 #define COSA_PCD8544_HH
23 
24 #include "Cosa/Board.hh"
25 #include "Cosa/OutputPin.hh"
26 #include "Cosa/LCD.hh"
27 
28 #include <Canvas.h>
29 #include "System5x7.hh"
30 
71 class PCD8544 : public LCD::Device {
72 public:
74  static const uint8_t WIDTH = 84;
75  static const uint8_t HEIGHT = 48;
76  static const uint8_t LINES = HEIGHT / CHARBITS;
77 
85 #if !defined(BOARD_ATTINY)
87  Font* font = &system5x7);
88 #else
90  Font* font = &system5x7);
91 #endif
92 
98  virtual bool begin();
99 
105  virtual bool end();
106 
112  virtual void display_contrast(uint8_t level);
113 
118  virtual void display_on();
119 
124  virtual void display_off();
125 
130  virtual void display_normal();
131 
136  virtual void display_inverse();
137 
142  virtual void display_clear();
143 
150  virtual void set_cursor(uint8_t x, uint8_t y);
151 
157  {
158  return (m_font);
159  }
160 
167  __attribute__((always_inline))
168  {
169  Font* previous = m_font;
170  m_font = font;
171  return (previous);
172  }
173 
179  void draw_icon(const uint8_t* bp);
180 
187  void draw_bitmap(uint8_t* bp, uint8_t width, uint8_t height);
188 
197  void draw_bar(uint8_t percent, uint8_t width, uint8_t pattern = 0x55);
198 
207  virtual int putchar(char c);
208 
209 protected:
213  enum {
214  NOP = 0x00,
215  SET_FUNC = 0x20,
216  BASIC_INST = 0x00,
217  EXTENDED_INST = 0x01,
219  VERTICAL_ADDR = 0x02,
220  POWER_UP_MODE = 0x00,
222  DISPLAY_CNTL = 0x08,
223  DISPLAY_OFF = 0x00,
224  DISPLAY_ON = 0x01,
225  NORMAL_MODE = 0x04,
226  INVERSE_MODE = 0x05,
227  SET_Y_ADDR = 0x40,
228  Y_ADDR_MASK = 0x07,
229  SET_X_ADDR = 0x80,
230  X_ADDR_MASK = 0x7f,
231  SET_TEMP_COEFF = 0x04,
232  SET_BIAS_SYS = 0x10,
233  SET_VOP = 0x80,
234  VOP_MASK = 0x7f,
235  SCRIPT_END = 0xff
236  } __attribute__((packed));
237 
239  static const uint8_t script[] PROGMEM;
240 
245 
250  void set(uint8_t cmd);
251 
257  void set(uint8_t x, uint8_t y);
258 
264  void fill(uint8_t data, uint16_t count);
265 };
266 
267 #endif
Mask X-addres.
Definition: PCD8544.hh:230
Set Bias System (0..7).
Definition: PCD8544.hh:232
virtual void display_on()
Definition: PCD8544.cpp:96
Sets X-address of RAM (0..83).
Definition: PCD8544.hh:229
void fill(uint8_t data, uint16_t count)
Definition: PCD8544.cpp:66
PCD8544(LCD::IO *io, Board::DigitalPin dc=Board::D8, Font *font=&system5x7)
Definition: PCD8544.cpp:36
Power up mode.
Definition: PCD8544.hh:220
Definition: Font.hh:30
Display control.
Definition: PCD8544.hh:222
Set temperature coefficient (0..3).
Definition: PCD8544.hh:231
No operation.
Definition: PCD8544.hh:214
Turn display on.
Definition: PCD8544.hh:224
virtual int putchar(char c)
Definition: PCD8544.cpp:206
OutputPin m_dc
Data/command output pin.
Definition: PCD8544.hh:243
Font * m_font
Font.
Definition: PCD8544.hh:244
Horizontal addressing.
Definition: PCD8544.hh:218
Extended instruction set control.
Definition: PCD8544.hh:217
void draw_bitmap(uint8_t *bp, uint8_t width, uint8_t height)
Definition: PCD8544.cpp:167
Turn display off.
Definition: PCD8544.hh:223
virtual void display_contrast(uint8_t level)
Definition: PCD8544.cpp:128
Power down mode.
Definition: PCD8544.hh:221
static const uint8_t HEIGHT
Definition: PCD8544.hh:75
virtual bool begin()
Definition: PCD8544.cpp:74
Font * get_text_font() const
Definition: PCD8544.hh:156
#define CHARBITS
Definition: Types.h:57
LCD::IO * m_io
Display adapter.
Definition: PCD8544.hh:242
static const uint8_t LINES
Definition: PCD8544.hh:76
void draw_icon(const uint8_t *bp)
Definition: PCD8544.cpp:150
Normal display mode.
Definition: PCD8544.hh:225
virtual bool end()
Definition: PCD8544.cpp:89
virtual void display_normal()
Definition: PCD8544.cpp:108
System5x7 system5x7
Definition: System5x7.cpp:24
Definition: LCD.hh:190
Mask Vop.
Definition: PCD8544.hh:234
Write Vop to register.
Definition: PCD8544.hh:233
Sets Y-address of RAM (0..5).
Definition: PCD8544.hh:227
virtual void display_inverse()
Definition: PCD8544.cpp:114
Mask Y-address.
Definition: PCD8544.hh:228
Set function.
Definition: PCD8544.hh:215
Basic instruction set.
Definition: PCD8544.hh:216
static const uint8_t WIDTH
Definition: PCD8544.hh:74
Vertical addressing.
Definition: PCD8544.hh:219
static const uint8_t script[]
Definition: PCD8544.hh:239
virtual void set_cursor(uint8_t x, uint8_t y)
Definition: PCD8544.cpp:140
Init script end.
Definition: PCD8544.hh:235
Inverse display mode.
Definition: PCD8544.hh:226
Font * set_text_font(Font *font)
Definition: PCD8544.hh:166
virtual void display_off()
Definition: PCD8544.cpp:102
void draw_bar(uint8_t percent, uint8_t width, uint8_t pattern=0x55)
Definition: PCD8544.cpp:183
virtual void display_clear()
Definition: PCD8544.cpp:120