upm  0.3.2
Sensor/Actuator repository for libmraa (v0.7.2)
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 #include <mraa/gpio.hpp>
38 #include "lcd.h"
39 
40 namespace upm
41 {
62 class Lcm1602 : public LCD
63 {
64  public:
73  Lcm1602(int bus, int address, bool isExpander=true);
74 
87  Lcm1602(uint8_t rs, uint8_t enable,
88  uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
89 
93  ~Lcm1602();
101  mraa_result_t write(std::string msg);
109  mraa_result_t setCursor(int row, int column);
115  mraa_result_t clear();
121  mraa_result_t home();
122 
130  mraa_result_t createChar(uint8_t charSlot, uint8_t charData[]);
131 
137  mraa_result_t displayOn();
138 
144  mraa_result_t displayOff();
145 
151  mraa_result_t cursorOn();
152 
158  mraa_result_t cursorOff();
159 
165  mraa_result_t cursorBlinkOn();
166 
172  mraa_result_t cursorBlinkOff();
173 
179  mraa_result_t scrollDisplayLeft();
180 
186  mraa_result_t scrollDisplayRight();
187 
193  mraa_result_t entryLeftToRight();
194 
200  mraa_result_t entryRightToLeft();
201 
207  mraa_result_t autoscrollOn();
208 
214  mraa_result_t autoscrollOff();
215 
216 
217  protected:
218  mraa_result_t send(uint8_t value, int mode);
219  mraa_result_t write4bits(uint8_t value);
220  mraa_result_t expandWrite(uint8_t value);
221  mraa_result_t pulseEnable(uint8_t value);
222 
223  uint8_t m_displayControl;
224  uint8_t m_entryDisplayMode;
225 
226  // Add a command() and data() virtual member functions, with a
227  // default implementation in lcm1602. This is expected to be
228  // implemented by derived classes with different needs (Jhd1313m1,
229  // for example).
230  virtual mraa_result_t command(uint8_t cmd);
231  virtual mraa_result_t data(uint8_t data);
232 
233  int m_lcd_control_address;
234  mraa::I2c* m_i2c_lcd_control;
235 
236  private:
237 
238  // true if using i2c, false otherwise (gpio)
239  bool m_isI2C;
240 
241  // gpio operation
242  mraa::Gpio* m_gpioRS;
243  mraa::Gpio* m_gpioEnable;
244  mraa::Gpio* m_gpioD0;
245  mraa::Gpio* m_gpioD1;
246  mraa::Gpio* m_gpioD2;
247  mraa::Gpio* m_gpioD3;
248 };
249 }
~Lcm1602()
Definition: lcm1602.cxx:159
Lcm1602(int bus, int address, bool isExpander=true)
Definition: lcm1602.cxx:41
mraa_result_t entryRightToLeft()
Definition: lcm1602.cxx:289
mraa_result_t cursorBlinkOff()
Definition: lcm1602.cxx:267
mraa_result_t cursorOff()
Definition: lcm1602.cxx:255
mraa_result_t write(std::string msg)
Definition: lcm1602.cxx:184
mraa_result_t setCursor(int row, int column)
Definition: lcm1602.cxx:194
mraa_result_t entryLeftToRight()
Definition: lcm1602.cxx:283
Definition: a110x.h:29
mraa_result_t createChar(uint8_t charSlot, uint8_t charData[])
Definition: lcm1602.cxx:223
mraa_result_t cursorOn()
Definition: lcm1602.cxx:249
Definition: lcd.h:36
mraa_result_t scrollDisplayRight()
Definition: lcm1602.cxx:278
mraa_result_t clear()
Definition: lcm1602.cxx:205
mraa_result_t displayOff()
Definition: lcm1602.cxx:243
mraa_result_t cursorBlinkOn()
Definition: lcm1602.cxx:261
mraa_result_t displayOn()
Definition: lcm1602.cxx:237
mraa_result_t autoscrollOn()
Definition: lcm1602.cxx:295
mraa_result_t autoscrollOff()
Definition: lcm1602.cxx:301
mraa_result_t home()
Definition: lcm1602.cxx:214
mraa_result_t scrollDisplayLeft()
Definition: lcm1602.cxx:273
API for the LCM1602 I2C controller for HD44780-based displays.
Definition: lcm1602.h:62