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

API Description

/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
*
* 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 "jhd1313m1.h"
#include "upm_utilities.h"
#include "signal.h"
#include "string.h"
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
// initialize a JHD1313m1 on I2C bus 0, LCD address 0x3e, RGB
// address 0x62
jhd1313m1_context lcd = jhd1313m1_init(0, 0x3e, 0x62);
if (!lcd)
{
printf("jhd1313m1_i2c_init() failed\n");
return 1;
}
int ndx = 0;
char str[23];
uint8_t rgb[7][3] = {
{0xd1, 0x00, 0x00},
{0xff, 0x66, 0x22},
{0xff, 0xda, 0x21},
{0x33, 0xdd, 0x00},
{0x11, 0x33, 0xcc},
{0x22, 0x00, 0x66},
{0x33, 0x00, 0x44}};
while (shouldRun)
{
snprintf(str, sizeof(str), "Hello World %d", ndx);
// Alternate rows on the LCD
jhd1313m1_set_cursor(lcd, ndx%2, 0);
jhd1313m1_write(lcd, str, strlen(str));
// Change the color
uint8_t r = rgb[ndx%7][0];
uint8_t g = rgb[ndx%7][1];
uint8_t b = rgb[ndx%7][2];
jhd1313m1_set_color(lcd, r, g, b);
// Echo via printf
printf("Hello World %d rgb: 0x%02x%02x%02x\n", ndx++, r, g, b);
upm_delay(1);
}
return 0;
}

Go to the source code of this file.

Data Structures

struct  _jhd1313m1_context
 

Functions

jhd1313m1_context jhd1313m1_init (int bus, int lcd_addr, int rgb_addr)
 
void jhd1313m1_close (jhd1313m1_context dev)
 
upm_result_t jhd1313m1_write (const jhd1313m1_context dev, char *buffer, int len)
 
upm_result_t jhd1313m1_set_cursor (const jhd1313m1_context dev, unsigned int row, unsigned int column)
 
upm_result_t jhd1313m1_clear (const jhd1313m1_context dev)
 
upm_result_t jhd1313m1_home (const jhd1313m1_context dev)
 
upm_result_t jhd1313m1_set_color (const jhd1313m1_context dev, uint8_t r, uint8_t g, uint8_t b)
 
upm_result_t jhd1313m1_create_char (const jhd1313m1_context dev, unsigned int slot, char *data)
 
upm_result_t jhd1313m1_display_on (const jhd1313m1_context dev, bool on)
 
upm_result_t jhd1313m1_cursor_on (const jhd1313m1_context dev, bool on)
 
upm_result_t jhd1313m1_cursor_blink_on (const jhd1313m1_context dev, bool on)
 
upm_result_t jhd1313m1_backlight_on (const jhd1313m1_context dev, bool on)
 
upm_result_t jhd1313m1_scroll (const jhd1313m1_context dev, bool direction)
 
upm_result_t jhd1313m1_scroll_display_left (const jhd1313m1_context dev)
 
upm_result_t jhd1313m1_scroll_display_right (const jhd1313m1_context dev)
 
upm_result_t jhd1313m1_entry_left_to_right (const jhd1313m1_context dev, bool on)
 
upm_result_t jhd1313m1_autoscroll_on (const jhd1313m1_context dev, bool on)
 
upm_result_t jhd1313m1_command (const jhd1313m1_context dev, uint8_t cmd)
 
upm_result_t jhd1313m1_data (const jhd1313m1_context dev, uint8_t data)
 

Typedefs

typedef struct _jhd1313m1_contextjhd1313m1_context
 

Function Documentation

jhd1313m1_context jhd1313m1_init ( int  bus,
int  lcd_addr,
int  rgb_addr 
)

JHD1313M1 I2C initialization.

Parameters
busI2C bus to use.
lcd_addrI2C address the LCD controller is on.
rgb_addrI2C address the RGB backlight controller is on.
Returns
Device Ccontext, or NULL on error.

Here is the call graph for this function:

void jhd1313m1_close ( jhd1313m1_context  dev)

JHD1313M1 close.

Parameters
devThe device context.

Here is the caller graph for this function:

upm_result_t jhd1313m1_write ( const jhd1313m1_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 jhd1313m1_set_cursor ( const jhd1313m1_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 jhd1313m1_clear ( const jhd1313m1_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 jhd1313m1_home ( const jhd1313m1_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 jhd1313m1_set_color ( const jhd1313m1_context  dev,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets the color of the backlight Can be used to change the color even when the backlight is off

Parameters
devThe device context.
r0-255 value for red
g0-255 value for green
b0-255 value for blue
Returns
UPM result.

Here is the caller graph for this function:

upm_result_t jhd1313m1_create_char ( const jhd1313m1_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 jhd1313m1_display_on ( const jhd1313m1_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 jhd1313m1_cursor_on ( const jhd1313m1_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 jhd1313m1_cursor_blink_on ( const jhd1313m1_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 jhd1313m1_backlight_on ( const jhd1313m1_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 jhd1313m1_scroll ( const jhd1313m1_context  dev,
bool  direction 
)

Makes the LCD scroll text

Parameters
directionTrue if scrolling to the right, false otherwise
Returns
Result of the operation

Here is the call graph for this function:

Here is the caller graph for this function:

upm_result_t jhd1313m1_scroll_display_left ( const jhd1313m1_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 jhd1313m1_scroll_display_right ( const jhd1313m1_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 jhd1313m1_entry_left_to_right ( const jhd1313m1_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 jhd1313m1_autoscroll_on ( const jhd1313m1_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:

upm_result_t jhd1313m1_command ( const jhd1313m1_context  dev,
uint8_t  cmd 
)

Send a command byte to the LCD controller. This is a low level function that should not be used directly unless you know what you are doing.

Parameters
devThe device context.
cmdThe command byte to send.
Returns
UPM result.

Here is the caller graph for this function:

upm_result_t jhd1313m1_data ( const jhd1313m1_context  dev,
uint8_t  data 
)

Send a data byte the LCD controller. This is a low level function that should not be used directly unless you know what you are doing.

Parameters
devThe device context.
cmdThe command byte to send.
Returns
UPM result.

Here is the caller graph for this function:

Typedef Documentation

Device context