upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Data Structures | Functions | Typedefs
Include dependency graph for lcdks.h:

API Description

/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2017 Intel Corporation.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include "upm_utilities.h"
#include "lcdks.h"
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
// Instantiate a LCDKS (LCD Keypad Shield) using default pins
// LCD connection:
// LCD RS pin to digital pin 8
// LCD Enable pin to digital pin 9
// LCD D4 pin to digital pin 4
// LCD D5 pin to digital pin 5
// LCD D6 pin to digital pin 6
// LCD D7 pin to digital pin 7
// Keypad analog pin 0
// Backlight GPIO -1 (disabled)
// NOTE: The default pins do not include support for a gpio
// controlled backlight. If you need one, specify the correct pin
// as the last argument instead of -1.
lcdks_context lcd = lcdks_init(8, 9, 4, 5, 6, 7, 0, -1);
if (!lcd)
{
printf("lcdks_init() failed.\n");
return 1;
}
lcdks_set_cursor(lcd, 0, 0);
lcdks_write(lcd, "LCDKS driver", 12);
lcdks_set_cursor(lcd, 1, 2);
lcdks_write(lcd, "Hello World", 11);
// output current key value every second.
while (shouldRun)
{
printf("Button value: %f\n", lcdks_get_key_value(lcd));
upm_delay(1);
}
return 0;
}

Go to the source code of this file.

Data Structures

struct  _lcdks_context
 

Functions

lcdks_context lcdks_init (int rs, int enable, int d0, int d1, int d2, int d3, int keypad, int backlight)
 
void lcdks_close (lcdks_context dev)
 
upm_result_t lcdks_write (const lcdks_context dev, char *buffer, int len)
 
upm_result_t lcdks_set_cursor (const lcdks_context dev, unsigned int row, unsigned int column)
 
upm_result_t lcdks_clear (const lcdks_context dev)
 
upm_result_t lcdks_home (const lcdks_context dev)
 
upm_result_t lcdks_create_char (const lcdks_context dev, unsigned int slot, char *data)
 
upm_result_t lcdks_display_on (const lcdks_context dev, bool on)
 
upm_result_t lcdks_cursor_on (const lcdks_context dev, bool on)
 
upm_result_t lcdks_cursor_blink_on (const lcdks_context dev, bool on)
 
upm_result_t lcdks_backlight_on (const lcdks_context dev, bool on)
 
upm_result_t lcdks_scroll_display_left (const lcdks_context dev)
 
upm_result_t lcdks_scroll_display_right (const lcdks_context dev)
 
upm_result_t lcdks_entry_left_to_right (const lcdks_context dev, bool on)
 
upm_result_t lcdks_autoscroll_on (const lcdks_context dev, bool on)
 
float lcdks_get_key_value (const lcdks_context dev)
 

Typedefs

typedef struct _lcdks_contextlcdks_context
 

Function Documentation

lcdks_context lcdks_init ( int  rs,
int  enable,
int  d0,
int  d1,
int  d2,
int  d3,
int  keypad,
int  backlight 
)

LCDKS initialization

As this is a shield, you will not likely have any choice over the pins that are used. For this reason, we provide defaults for all of them – of course they can be changed if your device is different.

Parameters
rsRegister select pin.
enableEnable pin.
d0Data 0 pin.
d1Data 1 pin.
d2Data 2 pin.
d3Data 3 pin.
keypadAnalog pin of the keypad.
backlightOptional GPIO backlight pin. Specify -1 if not in use or not supported on your device.
Returns
LCDKS context, or NULL if an error occurs.

Here is the call graph for this function:

void lcdks_close ( lcdks_context  dev)

LCDKS close.

Parameters
devThe device context.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_write ( const lcdks_context  dev,
char *  buffer,
int  len 
)

Writes a string to the LCD.

Parameters
devThe device context.
bufferCharacter buffer containing characters to write to the display; note: only ASCII characters are supported
lenThe number of characters to write.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_set_cursor ( const lcdks_context  dev,
unsigned int  row,
unsigned int  column 
)

Sets the cursor to specified coordinates

Parameters
devThe device context.
rowRow to set the cursor to.
columnColumn to set the cursor to.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_clear ( const lcdks_context  dev)

Clears the display of all characters.

Parameters
devThe device context.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_home ( const lcdks_context  dev)

Returns to the home coordinates (0,0).

Parameters
devThe device context.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_create_char ( const lcdks_context  dev,
unsigned int  slot,
char *  data 
)

Create a custom character.

Parameters
devThe device context.
slotThe character slot to write, only 8 are available.
dataThe character data (8 bytes) making up the character.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_display_on ( const lcdks_context  dev,
bool  on 
)

Turn the display on.

Parameters
devThe device context.
ontrue to turn display on, false otherwise.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_cursor_on ( const lcdks_context  dev,
bool  on 
)

Turn the cursor on.

Parameters
devThe device context.
ontrue to turn cursor on, false otherwise.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_cursor_blink_on ( const lcdks_context  dev,
bool  on 
)

Turn cursor blink on.

Parameters
devThe device context.
ontrue to turn cursor blink on, false otherwise.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_backlight_on ( const lcdks_context  dev,
bool  on 
)

Turn backlight on.

Parameters
devThe device context.
ontrue to turn backlight on, false otherwise.
Returns
UPM result.

Here is the caller graph for this function:

upm_result_t lcdks_scroll_display_left ( const lcdks_context  dev)

Scroll the display left, without changing the character RAM.

Parameters
devThe device context.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_scroll_display_right ( const lcdks_context  dev)

Scroll the display right, without changing the character RAM.

Parameters
devThe device context.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_entry_left_to_right ( const lcdks_context  dev,
bool  on 
)

Set the entry mode so that characters are added left to right.

Parameters
devThe device context.
ontrue to add characters left to right, false for right to left.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t lcdks_autoscroll_on ( const lcdks_context  dev,
bool  on 
)

Right justify text entered from the cursor.

Parameters
devThe device context.
ontrue right justify text, false to left justify text.
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

float lcdks_get_key_value ( const lcdks_context  dev)

Returns the floating point representation of the key that is being pushed. Each key produces a different value between 0.0 and 1.0, and only one key can be read at a time.

Parameters
devThe device context.
Returns
the floating point value representing a key

Here is the caller graph for this function:

Typedef Documentation

typedef struct _lcdks_context * lcdks_context

Device context