Arduino-LCD
LCD library for Arduino
PP7W.h
Go to the documentation of this file.
1 
18 #ifndef LCD_ADAPTER_PP7W_H
19 #define LCD_ADAPTER_PP7W_H
20 
21 #include "LCD.h"
22 #include "Driver/HD44780.h"
23 #include "GPIO.h"
24 
65 namespace LCD {
66 template<BOARD::pin_t D0_PIN,
67  BOARD::pin_t D1_PIN,
68  BOARD::pin_t D2_PIN,
69  BOARD::pin_t D3_PIN,
70  BOARD::pin_t RS_PIN,
71  BOARD::pin_t EN_PIN,
72  BOARD::pin_t BT_PIN>
73 class PP7W : public HD44780::Adapter {
74 public:
79  PP7W() :
80  HD44780::Adapter()
81  {
82  m_d0.output();
83  m_d1.output();
84  m_d2.output();
85  m_d3.output();
86  m_rs.output();
87  m_en.output();
88  m_bt.output();
89  m_bt.high();
90  }
91 
97  virtual void write4b(uint8_t data)
98  {
99  m_d0.write(data & 0x01);
100  m_d1.write(data & 0x02);
101  m_d2.write(data & 0x04);
102  m_d3.write(data & 0x08);
103  m_en.toggle();
104  m_en.toggle();
105  }
106 
112  virtual void write8b(uint8_t data)
113  {
114  m_d0.write(data & 0x10);
115  m_d1.write(data & 0x20);
116  m_d2.write(data & 0x40);
117  m_d3.write(data & 0x80);
118  m_en.toggle();
119  m_en.toggle();
120  m_d0.write(data & 0x01);
121  m_d1.write(data & 0x02);
122  m_d2.write(data & 0x04);
123  m_d3.write(data & 0x08);
124  m_en.toggle();
125  m_en.toggle();
126  delayMicroseconds(SHORT_EXEC_TIME);
127  }
128 
135  virtual void set_mode(uint8_t flag)
136  {
137  m_rs.write(flag);
138  }
139 
145  virtual void set_backlight(uint8_t flag)
146  {
147  m_bt.write(flag);
148  }
149 
150 protected:
152  static const uint16_t SHORT_EXEC_TIME = 32;
153 
154  GPIO<D0_PIN> m_d0;
155  GPIO<D1_PIN> m_d1;
156  GPIO<D2_PIN> m_d2;
157  GPIO<D3_PIN> m_d3;
158  GPIO<RS_PIN> m_rs;
159  GPIO<EN_PIN> m_en;
160  GPIO<BT_PIN> m_bt;
161 };
162 };
163 #endif
virtual void set_mode(uint8_t flag)
Definition: PP7W.h:135
GPIO< RS_PIN > m_rs
Register select (0/instruction, 1/data).
Definition: PP7W.h:158
GPIO< D1_PIN > m_d1
Data pin; d1.
Definition: PP7W.h:155
static const uint16_t SHORT_EXEC_TIME
Definition: PP7W.h:152
GPIO< BT_PIN > m_bt
Back-light control (0/on, 1/off).
Definition: PP7W.h:160
virtual void set_backlight(uint8_t flag)
Definition: PP7W.h:145
Definition: Debug.h:28
GPIO< D2_PIN > m_d2
Data pin; d2.
Definition: PP7W.h:156
Definition: PP7W.h:73
virtual void write8b(uint8_t data)
Definition: PP7W.h:112
virtual void write4b(uint8_t data)
Definition: PP7W.h:97
GPIO< EN_PIN > m_en
Starts data read/write.
Definition: PP7W.h:159
PP7W()
Definition: PP7W.h:79
GPIO< D3_PIN > m_d3
Data pin; d3.
Definition: PP7W.h:157
GPIO< D0_PIN > m_d0
Data pin; d0.
Definition: PP7W.h:154