COSA
An Object-Oriented Platform for Arduino Programming
DFRobot_IIC_LCD_Module.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_DFROBOT_IIC_LCD_MODULE_HH
22 #define COSA_DFROBOT_IIC_LCD_MODULE_HH
23 
24 #include <HD44780.h>
25 #include <PCF8574.h>
26 
47 class DFRobot_IIC_LCD_Module : public HD44780::IO, private PCF8574 {
48 public:
54  DFRobot_IIC_LCD_Module(uint8_t subaddr = 7) : PCF8574(subaddr), m_port() {}
55 
61  virtual bool setup();
62 
68  virtual void write4b(uint8_t data);
69 
75  virtual void write8b(uint8_t data);
76 
83  virtual void write8n(const void* buf, size_t size);
84 
91  virtual void set_mode(uint8_t flag);
92 
98  virtual void set_backlight(uint8_t flag);
99 
100 protected:
102  static const uint8_t TMP_MAX = 32;
103 
105  union port_t {
106  uint8_t as_uint8;
107  struct {
108  uint8_t rs:1;
109  uint8_t rw:1;
110  uint8_t en:1;
111  uint8_t bt:1;
112  uint8_t data:4;
113  };
114  operator uint8_t()
115  {
116  return (as_uint8);
117  }
119  {
120  as_uint8 = 0;
121  }
122  };
124 };
125 
126 #endif
virtual void set_backlight(uint8_t flag)
virtual void write8b(uint8_t data)
virtual void write4b(uint8_t data)
uint8_t rs
Command/Data select (P0).
virtual void write8n(const void *buf, size_t size)
DFRobot_IIC_LCD_Module(uint8_t subaddr=7)
uint8_t as_uint8
Unsigned byte access.
static const uint8_t TMP_MAX
virtual void set_mode(uint8_t flag)