COSA
An Object-Oriented Platform for Arduino Programming
ST7565.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_ST7565_HH
22 #define COSA_ST7565_HH
23 
24 #include "Cosa/Board.hh"
25 #include "Cosa/OutputPin.hh"
26 #include "Cosa/LCD.hh"
27 #include "Cosa/SPI.hh"
28 
29 #include <Canvas.h>
30 #include "System5x7.hh"
31 
85 class ST7565 : public LCD::Device {
86 public:
88  static const uint8_t WIDTH = 128;
89  static const uint8_t HEIGHT = 64;
90  static const uint8_t LINES = 8;
91 
99 #if !defined(BOARD_ATTINY)
101  Font* font = &system5x7);
102 #else
104  Font* font = &system5x7);
105 #endif
106 
112  virtual bool begin();
113 
119  virtual bool end();
120 
126  virtual void display_contrast(uint8_t level);
127 
132  virtual void display_on();
133 
138  virtual void display_off();
139 
144  virtual void display_normal();
145 
150  virtual void display_inverse();
151 
156  virtual void display_clear();
157 
164  virtual void set_cursor(uint8_t x, uint8_t y);
165 
171  {
172  return (m_font);
173  }
174 
181  __attribute__((always_inline))
182  {
183  Font* previous = m_font;
184  m_font = font;
185  return (previous);
186  }
187 
193  void draw_icon(const uint8_t* bp);
194 
201  void draw_bitmap(uint8_t* bp, uint8_t width, uint8_t height);
202 
211  void draw_bar(uint8_t percent, uint8_t width, uint8_t pattern = 0x55);
212 
221  virtual int putchar(char c);
222 
223 protected:
227  enum {
228  DISPLAY_OFF = 0xAE,
229  DISPLAY_ON = 0xAF,
232  SET_Y_ADDR = 0xB0,
233  Y_ADDR_MASK = 0x0f,
234  SET_X_ADDR = 0x10,
235  X_ADDR_MASK = 0x0f,
236  ADC_NORMAL = 0xA0,
237  ADC_REVERSE = 0xA1,
238  DISPLAY_NORMAL = 0xA6,
242  LCD_BIAS_9 = 0xA2,
243  LCD_BIAS_7 = 0xA3,
244  X_ADDR_INC = 0xE0,
245  X_ADDR_CLEAR = 0xEE,
246  INTERNAL_RESET = 0xE2,
250  POWER_MASK = 0x07,
252  RESISTOR_MASK = 0x07,
253  SET_CONSTRAST = 0x81,
254  CONSTRAST_MASK = 0x3f,
255  INDICATOR_OFF = 0xAC,
256  INDICATOR_ON = 0xAD,
257  FLASHING_OFF = 0x00,
258  FLASHING_ON = 0x01,
263  NOP = 0xE3,
264  SCRIPT_PAUSE = 0xF0,
265  SCRIPT_END = 0xFF
266  } __attribute__((packed));
267 
269  static const uint8_t script[] PROGMEM;
270 
274  uint8_t m_line;
276 
281  void set(uint8_t cmd);
282 
288  void set(uint8_t x, uint8_t y);
289 
295  void fill(uint8_t data, uint16_t count);
296 };
297 
298 #endif
Non-operation.
Definition: ST7565.hh:263
Init script pause (ms).
Definition: ST7565.hh:264
Display all points.
Definition: ST7565.hh:241
virtual int putchar(char c)
Definition: ST7565.cpp:220
Set normal address correspondence.
Definition: ST7565.hh:236
uint8_t m_line
Display start line.
Definition: ST7565.hh:274
Definition: Font.hh:30
void draw_bar(uint8_t percent, uint8_t width, uint8_t pattern=0x55)
Definition: ST7565.cpp:197
Set start line address.
Definition: ST7565.hh:230
static const uint8_t WIDTH
Definition: ST7565.hh:88
static const uint8_t LINES
Definition: ST7565.hh:90
Voltage ratio 1/7 bias.
Definition: ST7565.hh:243
Set page address.
Definition: ST7565.hh:232
Set indicator flashing mode off.
Definition: ST7565.hh:257
Voltage ratio 1/9 bias.
Definition: ST7565.hh:242
void fill(uint8_t data, uint16_t count)
Definition: ST7565.cpp:74
Turn display off.
Definition: ST7565.hh:228
void draw_bitmap(uint8_t *bp, uint8_t width, uint8_t height)
Definition: ST7565.cpp:182
virtual void display_inverse()
Definition: ST7565.cpp:138
static const uint8_t script[]
Definition: ST7565.hh:269
virtual void display_contrast(uint8_t level)
Definition: ST7565.cpp:109
virtual void display_clear()
Definition: ST7565.cpp:144
Turn display on.
Definition: ST7565.hh:229
Init script end.
Definition: ST7565.hh:265
Clear read/modify/write.
Definition: ST7565.hh:245
Set booster ratio.
Definition: ST7565.hh:259
Normal output scan direction.
Definition: ST7565.hh:247
Normal display mode.
Definition: ST7565.hh:238
Set reverse address correspondence.
Definition: ST7565.hh:237
Select internal power supply mode.
Definition: ST7565.hh:249
Reverse display mode.
Definition: ST7565.hh:239
OutputPin m_dc
Data(1) or command(0).
Definition: ST7565.hh:273
void draw_icon(const uint8_t *bp)
Definition: ST7565.cpp:165
Set column address (2x4 bits).
Definition: ST7565.hh:234
virtual void set_cursor(uint8_t x, uint8_t y)
Definition: ST7565.cpp:154
Select internal resistor ratio.
Definition: ST7565.hh:251
Font * get_text_font() const
Definition: ST7565.hh:170
Font * set_text_font(Font *font)
Definition: ST7565.hh:180
virtual bool begin()
Definition: ST7565.cpp:82
Display normal.
Definition: ST7565.hh:240
Column address increment.
Definition: ST7565.hh:244
virtual void display_off()
Definition: ST7565.cpp:126
System5x7 system5x7
Definition: System5x7.cpp:24
Internal reset.
Definition: ST7565.hh:246
ST7565(LCD::IO *io, Board::DigitalPin dc=Board::D8, Font *font=&system5x7)
Definition: ST7565.cpp:43
Set output voltage volume register.
Definition: ST7565.hh:253
Definition: LCD.hh:190
static const uint8_t HEIGHT
Definition: ST7565.hh:89
virtual void display_on()
Definition: ST7565.cpp:120
Font * m_font
Font.
Definition: ST7565.hh:275
virtual bool end()
Definition: ST7565.cpp:102
LCD::IO * m_io
Display adapter.
Definition: ST7565.hh:272
Static indicator off.
Definition: ST7565.hh:255
virtual void display_normal()
Definition: ST7565.cpp:132
Definition: ST7565.hh:85