upm  1.0.2
Sensor/Actuator repository for libmraa (v1.1.1)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
69  typedef char jhd1313m1_custom_char_t[8];
70 
79  jhd1313m1_context jhd1313m1_init(int bus, int lcd_addr, int rgb_addr);
80 
87 
97  upm_result_t jhd1313m1_write(const jhd1313m1_context dev, char *buffer,
98  int len);
99 
108  upm_result_t jhd1313m1_set_cursor(const jhd1313m1_context dev,
109  unsigned int row, unsigned int column);
110 
117  upm_result_t jhd1313m1_clear(const jhd1313m1_context dev);
118 
125  upm_result_t jhd1313m1_home(const jhd1313m1_context dev);
126 
137  upm_result_t jhd1313m1_set_color(const jhd1313m1_context dev,
138  uint8_t r, uint8_t g, uint8_t b);
139 
148  upm_result_t jhd1313m1_create_char(const jhd1313m1_context dev,
149  unsigned int slot,
150  jhd1313m1_custom_char_t data);
151 
159  upm_result_t jhd1313m1_display_on(const jhd1313m1_context dev, bool on);
160 
168  upm_result_t jhd1313m1_cursor_on(const jhd1313m1_context dev, bool on);
169 
177  upm_result_t jhd1313m1_cursor_blink_on(const jhd1313m1_context dev,
178  bool on);
179 
187  upm_result_t jhd1313m1_backlight_on(const jhd1313m1_context dev, bool on);
188 
195  upm_result_t jhd1313m1_scroll(const jhd1313m1_context dev, bool direction);
196 
203  upm_result_t jhd1313m1_scroll_display_left(const jhd1313m1_context dev);
204 
211  upm_result_t jhd1313m1_scroll_display_right(const jhd1313m1_context dev);
212 
221  upm_result_t jhd1313m1_entry_left_to_right(const jhd1313m1_context dev,
222  bool on);
223 
231  upm_result_t jhd1313m1_autoscroll_on(const jhd1313m1_context dev, bool on);
232 
242  upm_result_t jhd1313m1_command(const jhd1313m1_context dev, uint8_t cmd);
243 
253  upm_result_t jhd1313m1_data(const jhd1313m1_context dev, uint8_t data);
254 
255 
256 #ifdef __cplusplus
257 }
258 #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_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_create_char(const jhd1313m1_context dev, unsigned int slot, jhd1313m1_custom_char_t data)
Definition: jhd1313m1.c:217
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
char jhd1313m1_custom_char_t[8]
Definition: jhd1313m1.h:69