upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
lcdks.h
Go to the documentation of this file.
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2017 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  * The MIT License
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29  */
30 
31 #pragma once
32 
33 #include <unistd.h>
34 #include <stdlib.h>
35 #include <stdio.h>
36 
37 #include <mraa/gpio.h>
38 #include <mraa/aio.h>
39 
40 #include <upm.h>
41 #include "lcm1602.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 
59  typedef struct _lcdks_context {
60  // LCM1602 context - does most of the work
61  lcm1602_context lcm1602;
62  // aio context for keypad
63  mraa_aio_context aio;
64  // optional GPIO context for backlight pin
65  mraa_gpio_context gpio;
66  } *lcdks_context;
67 
87  lcdks_context lcdks_init(int rs, int enable,
88  int d0, int d1, int d2, int d3,
89  int keypad, int backlight);
90 
96  void lcdks_close(lcdks_context dev);
97 
107  upm_result_t lcdks_write(const lcdks_context dev, char *buffer,
108  int len);
109 
118  upm_result_t lcdks_set_cursor(const lcdks_context dev,
119  unsigned int row, unsigned int column);
120 
127  upm_result_t lcdks_clear(const lcdks_context dev);
128 
135  upm_result_t lcdks_home(const lcdks_context dev);
136 
145  upm_result_t lcdks_create_char(const lcdks_context dev,
146  unsigned int slot,
147  char *data);
148 
156  upm_result_t lcdks_display_on(const lcdks_context dev, bool on);
157 
165  upm_result_t lcdks_cursor_on(const lcdks_context dev, bool on);
166 
174  upm_result_t lcdks_cursor_blink_on(const lcdks_context dev,
175  bool on);
176 
184  upm_result_t lcdks_backlight_on(const lcdks_context dev, bool on);
185 
192  upm_result_t lcdks_scroll_display_left(const lcdks_context dev);
193 
200  upm_result_t lcdks_scroll_display_right(const lcdks_context dev);
201 
210  upm_result_t lcdks_entry_left_to_right(const lcdks_context dev,
211  bool on);
212 
220  upm_result_t lcdks_autoscroll_on(const lcdks_context dev, bool on);
221 
230  float lcdks_get_key_value(const lcdks_context dev);
231 
232 
233 #ifdef __cplusplus
234 }
235 #endif
Definition: lcm1602.h:59
upm_result_t lcdks_autoscroll_on(const lcdks_context dev, bool on)
Definition: lcdks.c:205
lcdks_context lcdks_init(int rs, int enable, int d0, int d1, int d2, int d3, int keypad, int backlight)
Definition: lcdks.c:38
upm_result_t lcdks_entry_left_to_right(const lcdks_context dev, bool on)
Definition: lcdks.c:198
upm_result_t lcdks_scroll_display_left(const lcdks_context dev)
Definition: lcdks.c:184
upm_result_t lcdks_display_on(const lcdks_context dev, bool on)
Definition: lcdks.c:148
struct _lcdks_context * lcdks_context
Definition: lcdks.h:59
upm_result_t lcdks_backlight_on(const lcdks_context dev, bool on)
Definition: lcdks.c:169
upm_result_t lcdks_write(const lcdks_context dev, char *buffer, int len)
Definition: lcdks.c:109
upm_result_t lcdks_cursor_blink_on(const lcdks_context dev, bool on)
Definition: lcdks.c:162
float lcdks_get_key_value(const lcdks_context dev)
Definition: lcdks.c:212
void lcdks_close(lcdks_context dev)
Definition: lcdks.c:95
upm_result_t lcdks_create_char(const lcdks_context dev, unsigned int slot, char *data)
Definition: lcdks.c:139
upm_result_t lcdks_home(const lcdks_context dev)
Definition: lcdks.c:132
upm_result_t lcdks_clear(const lcdks_context dev)
Definition: lcdks.c:125
upm_result_t lcdks_scroll_display_right(const lcdks_context dev)
Definition: lcdks.c:191
upm_result_t lcdks_set_cursor(const lcdks_context dev, unsigned int row, unsigned int column)
Definition: lcdks.c:117
C API for the LCM1602 family of LCD displays.
upm_result_t lcdks_cursor_on(const lcdks_context dev, bool on)
Definition: lcdks.c:155