upm  0.4.0
Sensor/Actuator repository for libmraa (v0.8.0)
lcm1602.h
1 /*
2  * The MIT License (MIT)
3  *
4  * Author: Daniel Mosquera
5  * Copyright (c) 2013 Daniel Mosquera
6  *
7  * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
8  * Copyright (c) 2014 Intel Corporation.
9  *
10  * Contributions: Jon Trulson <jtrulson@ics.com>
11  *
12  * Permission is hereby granted, free of uint8_tge, to any person
13  * obtaining a copy of this software and associated documentation
14  * files (the "Software"), to deal in the Software without
15  * restriction, including without limitation the rights to use, copy,
16  * modify, merge, publish, distribute, sublicense, and/or sell copies
17  * of the Software, and to permit persons to whom the Software is
18  * furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be
21  * included in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #pragma once
34 
35 #include <string>
36 #include <mraa/i2c.hpp>
37 
38 #include <mraa/gpio.hpp>
39 
40 #include "lcd.h"
41 
42 namespace upm
43 {
64 class Lcm1602 : public LCD
65 {
66  public:
75  Lcm1602(int bus, int address, bool isExpander=true);
76 
89  Lcm1602(uint8_t rs, uint8_t enable,
90  uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
91 
95  ~Lcm1602();
103  mraa::Result write(std::string msg);
111  mraa::Result setCursor(int row, int column);
117  mraa::Result clear();
123  mraa::Result home();
124 
132  mraa::Result createChar(uint8_t charSlot, uint8_t charData[]);
133 
139  mraa::Result displayOn();
140 
146  mraa::Result displayOff();
147 
153  mraa::Result cursorOn();
154 
160  mraa::Result cursorOff();
161 
167  mraa::Result cursorBlinkOn();
168 
174  mraa::Result cursorBlinkOff();
175 
181  mraa::Result scrollDisplayLeft();
182 
188  mraa::Result scrollDisplayRight();
189 
195  mraa::Result entryLeftToRight();
196 
202  mraa::Result entryRightToLeft();
203 
209  mraa::Result autoscrollOn();
210 
216  mraa::Result autoscrollOff();
217 
218 
219  protected:
220  mraa::Result send(uint8_t value, int mode);
221  mraa::Result write4bits(uint8_t value);
222  mraa::Result expandWrite(uint8_t value);
223  mraa::Result pulseEnable(uint8_t value);
224 
225  uint8_t m_displayControl;
226  uint8_t m_entryDisplayMode;
227 
228  // Add a command() and data() virtual member functions, with a
229  // default implementation in lcm1602. This is expected to be
230  // implemented by derived classes with different needs (Jhd1313m1,
231  // for example).
232  virtual mraa::Result command(uint8_t cmd);
233  virtual mraa::Result data(uint8_t data);
234 
235  int m_lcd_control_address;
236  mraa::I2c* m_i2c_lcd_control;
237 
238  private:
239 
240  // true if using i2c, false otherwise (gpio)
241  bool m_isI2C;
242 
243  // gpio operation
244  mraa::Gpio* m_gpioRS;
245  mraa::Gpio* m_gpioEnable;
246  mraa::Gpio* m_gpioD0;
247  mraa::Gpio* m_gpioD1;
248  mraa::Gpio* m_gpioD2;
249  mraa::Gpio* m_gpioD3;
250 };
251 }
mraa::Result cursorOff()
Definition: lcm1602.cxx:257
mraa::Result autoscrollOff()
Definition: lcm1602.cxx:303
mraa::Result clear()
Definition: lcm1602.cxx:207
~Lcm1602()
Definition: lcm1602.cxx:161
Lcm1602(int bus, int address, bool isExpander=true)
Definition: lcm1602.cxx:42
mraa::Result write(std::string msg)
Definition: lcm1602.cxx:186
mraa::Result displayOff()
Definition: lcm1602.cxx:245
mraa::Result cursorOn()
Definition: lcm1602.cxx:251
mraa::Result cursorBlinkOn()
Definition: lcm1602.cxx:263
Definition: a110x.h:33
mraa::Result scrollDisplayRight()
Definition: lcm1602.cxx:280
Definition: lcd.h:37
mraa::Result cursorBlinkOff()
Definition: lcm1602.cxx:269
mraa::Result scrollDisplayLeft()
Definition: lcm1602.cxx:275
mraa::Result entryLeftToRight()
Definition: lcm1602.cxx:285
mraa::Result createChar(uint8_t charSlot, uint8_t charData[])
Definition: lcm1602.cxx:225
mraa::Result home()
Definition: lcm1602.cxx:216
mraa::Result autoscrollOn()
Definition: lcm1602.cxx:297
mraa::Result setCursor(int row, int column)
Definition: lcm1602.cxx:196
mraa::Result entryRightToLeft()
Definition: lcm1602.cxx:291
API for the LCM1602 I2C controller for HD44780-based displays.
Definition: lcm1602.h:64
mraa::Result displayOn()
Definition: lcm1602.cxx:239