COSA
An Object-Oriented Platform for Arduino Programming
Adafruit_I2C_LCD_Backpack.cpp
Go to the documentation of this file.
1 
22 
23 bool
25 {
26  if (!begin()) return (false);
27  data_direction(0);
28  return (false);
29 }
30 
31 void
33 {
34  uint8_t buf[2];
35  m_port.data = data;
36  m_port.en = 1;
37  buf[0] = m_port;
38  m_port.en = 0;
39  buf[1] = m_port;
40  write(buf, sizeof(buf));
41 }
42 
43 void
45 {
46  uint8_t buf[4];
47  m_port.data = (data >> 4);
48  m_port.en = 1;
49  buf[0] = m_port;
50  m_port.en = 0;
51  buf[1] = m_port;
52  m_port.data = data;
53  m_port.en = 1;
54  buf[2] = m_port.as_uint8;
55  m_port.en = 0;
56  buf[3] = m_port.as_uint8;
57  write(buf, sizeof(buf));
58 }
59 
60 void
61 Adafruit_I2C_LCD_Backpack::write8n(const void* buf, size_t size)
62 {
63  const uint8_t* bp = (const uint8_t*) buf;
64  while (size != 0) {
65  uint8_t tmp[TMP_MAX];
66  uint8_t n = (size > sizeof(tmp) / 4 ? sizeof(tmp) / 4 : size);
67  size -= n;
68  uint8_t m = n * 4;
69  for (uint8_t i = 0; i < m;) {
70  uint8_t data = *bp++;
71  m_port.data = (data >> 4);
72  m_port.en = 1;
73  tmp[i++] = m_port;
74  m_port.en = 0;
75  tmp[i++] = m_port;
76  m_port.data = data;
77  m_port.en = 1;
78  tmp[i++] = m_port;
79  m_port.en = 0;
80  tmp[i++] = m_port;
81  }
82  write(tmp, m);
83  }
84 }
85 
86 void
88 {
89  m_port.rs = flag;
90 }
91 
92 void
94 {
95  m_port.bt = flag;
97 }
98 
bool begin()
Definition: MCP23008.cpp:24
virtual void write8b(uint8_t data)
virtual void set_backlight(uint8_t flag)
bool write(uint8_t value)
Definition: MCP23008.cpp:139
uint8_t rs
Command/Data select (GP1).
uint8_t as_uint8
Unsigned byte access.
virtual void write8n(const void *buf, size_t size)
virtual void set_mode(uint8_t flag)
bool data_direction(uint8_t iodir)
Definition: MCP23008.cpp:47
virtual void write4b(uint8_t data)