grove-lcd: import of Grove LCD I2C controller
Initial import of the Grove LCD I2C controller. Data sheet can be found at: http://www.seeedstudio.com/wiki/images/0/03/JHD1214Y_YG_1.0.pdf [DL: Updated command sequence according to datasheet.] Change-Id: Id1b491f8dce346769dc42c41fac0ea3aabe3950a Signed-off-by: Daniel Leung <daniel.leung@intel.com> Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
This commit is contained in:
parent
314432e90f
commit
61d87f57f8
6 changed files with 598 additions and 0 deletions
168
include/display/grove_lcd.h
Normal file
168
include/display/grove_lcd.h
Normal file
|
@ -0,0 +1,168 @@
|
|||
/* grove_lcd.h - Public API for the Grove RGB LCD device */
|
||||
/*
|
||||
* Copyright (c) 2015 Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1) Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3) Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef DISPLAY_GROVE_LCD_H
|
||||
#define DISPLAY_GROVE_LCD_H
|
||||
|
||||
#define GROVE_LCD_NAME "GLCD"
|
||||
|
||||
/**
|
||||
* @brief Send text to the screen
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
* @param data the ASCII text to display
|
||||
* @param size the length of the text in bytes
|
||||
*/
|
||||
void glcd_print(struct device *port, unsigned char *data, uint32_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set text cursor position for next additions
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
* @param col the column for the cursor to be moved to (0-15)
|
||||
* @param row the row it should be moved to (0 or 1)
|
||||
*/
|
||||
void glcd_cursor_pos_set(struct device *port, uint8_t col, uint8_t row);
|
||||
|
||||
/**
|
||||
* @brief Clear the current display
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
*/
|
||||
void glcd_clear(struct device *port);
|
||||
|
||||
/* Defines for the GLCD_CMD_DISPLAY_SWITCH options */
|
||||
#define GLCD_DS_DISPLAY_ON (1 << 2)
|
||||
#define GLCD_DS_DISPLAY_OFF (0 << 2)
|
||||
#define GLCD_DS_CURSOR_ON (1 << 1)
|
||||
#define GLCD_DS_CURSOR_OFF (0 << 1)
|
||||
#define GLCD_DS_BLINK_ON (1 << 0)
|
||||
#define GLCD_DS_BLINK_OFF (0 << 0)
|
||||
/**
|
||||
* @brief Function to change the display state.
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
* @param opt An 8bit bitmask of GLCD_DS_* options.
|
||||
*
|
||||
* @details This function provides the user the ability to change the state
|
||||
* of the display as per needed. Controlling things like powering on or off
|
||||
* the screen, the option to display the cusror or not, and the ability to
|
||||
* blink the cursor.
|
||||
*/
|
||||
void glcd_display_state_set(struct device *port, uint8_t opt);
|
||||
|
||||
/**
|
||||
* @brief return the display feature set associated with the device
|
||||
* @param the Grove LCD to get the display features set
|
||||
*
|
||||
* @return the display feature set associated with the device.
|
||||
*/
|
||||
uint8_t glcd_display_state_get(struct device *port);
|
||||
|
||||
/* Defines for the GLCD_CMD_INPUT_SET to change text direction */
|
||||
#define GLCD_IS_SHIFT_INCREMENT (1 << 1)
|
||||
#define GLCD_IS_SHIFT_DECREMENT (0 << 1)
|
||||
#define GLCD_IS_ENTRY_LEFT (1 << 0)
|
||||
#define GLCD_IS_ENTRY_RIGHT (0 << 0)
|
||||
/**
|
||||
* @brief Function to change the input state.
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
* @param opt A bitmask of GLCD_IS_* options
|
||||
*
|
||||
* @details This function provides the user the ability to change the state
|
||||
* of the text input. Controlling things like text entry from the left or
|
||||
* right side, and how far to increment on new text
|
||||
*/
|
||||
void glcd_input_state_set(struct device *port, uint8_t opt);
|
||||
|
||||
/**
|
||||
* @brief return the input set associated with the device
|
||||
* @param the Grove LCD to get the input features set
|
||||
*
|
||||
* @return the input set associated with the device.
|
||||
*/
|
||||
uint8_t glcd_input_state_get(struct device *port);
|
||||
|
||||
/* Defines for the LCD_FUNCTION_SET */
|
||||
#define GLCD_FS_8BIT_MODE (1 << 4)
|
||||
#define GLCD_FS_ROWS_2 (1 << 3)
|
||||
#define GLCD_FS_ROWS_1 (0 << 3)
|
||||
#define GLCD_FS_DOT_SIZE_BIG (1 << 2)
|
||||
#define GLCD_FS_DOT_SIZE_LITTLE (0 << 2)
|
||||
/* Bits 0, 1 are not defined for this register */
|
||||
|
||||
/**
|
||||
* @brief Function to set the functional state of the display.
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
* @param opt A bitmask of GLCD_FS_* options
|
||||
*
|
||||
* @details This function provides the user the ability to change the state
|
||||
* of the display as per needed. Controlling things like the number of rows,
|
||||
* dot size, and text display quality.
|
||||
*/
|
||||
void glcd_function_set(struct device *port, uint8_t opt);
|
||||
|
||||
/**
|
||||
* @brief return the function set associated with the device
|
||||
* @param the Grove LCD to get the functions set
|
||||
*
|
||||
* @return the function features set associated with the device.
|
||||
*/
|
||||
uint8_t glcd_function_get(struct device *port);
|
||||
|
||||
|
||||
/* Available color selections */
|
||||
#define GROVE_RGB_WHITE 0
|
||||
#define GROVE_RGB_RED 1
|
||||
#define GROVE_RGB_GREEN 2
|
||||
#define GROVE_RGB_BLUE 3
|
||||
/**
|
||||
* @brief Set LCD background to a predfined color
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
* @param color One of the pre-defined color options
|
||||
*/
|
||||
void glcd_color_select(struct device *port, uint8_t color);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set LCD background to custom RGB color value
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
* @param r A numeric value for the red color (max is 255)
|
||||
* @param g A numeric value for the green color (max is 255)
|
||||
* @param b A numeric value for the blue color (max is 255)
|
||||
*/
|
||||
void glcd_color_set(struct device *port, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the Grove LCD panel
|
||||
* @param port Pointer to device structure for driver instance.
|
||||
* @return Returns DEV_OK if all passes
|
||||
*/
|
||||
int glcd_initialize(struct device *port);
|
||||
|
||||
#endif /* DISPLAY_GROVE_LCD_H */
|
Loading…
Add table
Add a link
Reference in a new issue