upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
jhd1313m1.h
Go to the documentation of this file.
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Based on UPM C++ drivers originally developed by:
6  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
7  * Copyright (c) 2014 Intel Corporation.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28 
29 #pragma once
30 
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <upm.h>
34 
35 #include <mraa/i2c.h>
36 #include <mraa/gpio.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
55  typedef struct _jhd1313m1_context {
56  // I2C LCD command (lcm1602-like)
57  mraa_i2c_context i2cLCD;
58  // I2C RGB backlight control
59  mraa_i2c_context i2cRGB;
60 
61  // display command
62  uint8_t displayControl;
63  uint8_t entryDisplayMode;
65 
74  jhd1313m1_context jhd1313m1_init(int bus, int lcd_addr, int rgb_addr);
75 
82 
92  upm_result_t jhd1313m1_write(const jhd1313m1_context dev, char *buffer,
93  int len);
94 
103  upm_result_t jhd1313m1_set_cursor(const jhd1313m1_context dev,
104  unsigned int row, unsigned int column);
105 
112  upm_result_t jhd1313m1_clear(const jhd1313m1_context dev);
113 
120  upm_result_t jhd1313m1_home(const jhd1313m1_context dev);
121 
132  upm_result_t jhd1313m1_set_color(const jhd1313m1_context dev,
133  uint8_t r, uint8_t g, uint8_t b);
134 
143  upm_result_t jhd1313m1_create_char(const jhd1313m1_context dev,
144  unsigned int slot,
145  char *data);
146 
154  upm_result_t jhd1313m1_display_on(const jhd1313m1_context dev, bool on);
155 
163  upm_result_t jhd1313m1_cursor_on(const jhd1313m1_context dev, bool on);
164 
172  upm_result_t jhd1313m1_cursor_blink_on(const jhd1313m1_context dev,
173  bool on);
174 
182  upm_result_t jhd1313m1_backlight_on(const jhd1313m1_context dev, bool on);
183 
190  upm_result_t jhd1313m1_scroll(const jhd1313m1_context dev, bool direction);
191 
198  upm_result_t jhd1313m1_scroll_display_left(const jhd1313m1_context dev);
199 
206  upm_result_t jhd1313m1_scroll_display_right(const jhd1313m1_context dev);
207 
216  upm_result_t jhd1313m1_entry_left_to_right(const jhd1313m1_context dev,
217  bool on);
218 
226  upm_result_t jhd1313m1_autoscroll_on(const jhd1313m1_context dev, bool on);
227 
237  upm_result_t jhd1313m1_command(const jhd1313m1_context dev, uint8_t cmd);
238 
248  upm_result_t jhd1313m1_data(const jhd1313m1_context dev, uint8_t data);
249 
250 
251 #ifdef __cplusplus
252 }
253 #endif
upm_result_t jhd1313m1_cursor_on(const jhd1313m1_context dev, bool on)
Definition: jhd1313m1.c:252
struct _jhd1313m1_context * jhd1313m1_context
upm_result_t jhd1313m1_scroll_display_left(const jhd1313m1_context dev)
Definition: jhd1313m1.c:303
upm_result_t jhd1313m1_set_cursor(const jhd1313m1_context dev, unsigned int row, unsigned int column)
Definition: jhd1313m1.c:180
upm_result_t jhd1313m1_data(const jhd1313m1_context dev, uint8_t data)
Definition: jhd1313m1.c:356
upm_result_t jhd1313m1_create_char(const jhd1313m1_context dev, unsigned int slot, char *data)
Definition: jhd1313m1.c:217
upm_result_t jhd1313m1_display_on(const jhd1313m1_context dev, bool on)
Definition: jhd1313m1.c:240
upm_result_t jhd1313m1_backlight_on(const jhd1313m1_context dev, bool on)
Definition: jhd1313m1.c:276
upm_result_t jhd1313m1_write(const jhd1313m1_context dev, char *buffer, int len)
Definition: jhd1313m1.c:166
upm_result_t jhd1313m1_home(const jhd1313m1_context dev)
Definition: jhd1313m1.c:207
upm_result_t jhd1313m1_scroll_display_right(const jhd1313m1_context dev)
Definition: jhd1313m1.c:311
upm_result_t jhd1313m1_command(const jhd1313m1_context dev, uint8_t cmd)
Definition: jhd1313m1.c:343
upm_result_t jhd1313m1_clear(const jhd1313m1_context dev)
Definition: jhd1313m1.c:197
jhd1313m1_context jhd1313m1_init(int bus, int lcd_addr, int rgb_addr)
Definition: jhd1313m1.c:38
upm_result_t jhd1313m1_set_color(const jhd1313m1_context dev, uint8_t r, uint8_t g, uint8_t b)
Definition: jhd1313m1.c:144
upm_result_t jhd1313m1_entry_left_to_right(const jhd1313m1_context dev, bool on)
Definition: jhd1313m1.c:319
Definition: jhd1313m1.h:55
upm_result_t jhd1313m1_cursor_blink_on(const jhd1313m1_context dev, bool on)
Definition: jhd1313m1.c:264
void jhd1313m1_close(jhd1313m1_context dev)
Definition: jhd1313m1.c:132
upm_result_t jhd1313m1_scroll(const jhd1313m1_context dev, bool direction)
Definition: jhd1313m1.c:295
upm_result_t jhd1313m1_autoscroll_on(const jhd1313m1_context dev, bool on)
Definition: jhd1313m1.c:331