mirror of
https://github.com/apache/nuttx.git
synced 2026-05-24 16:11:56 +08:00
PCB-Logic PIC32MX LCD1602 driver now supports SLCD CODED; Added an SLCD ioctl command to get cursor position
This commit is contained in:
@@ -4797,3 +4797,9 @@
|
||||
kconfig-frontends tool (2013-5-25).
|
||||
* configs/pcblogic-pic32mx/src: Renamed files using pic32mx_ vs up_
|
||||
prefix. Enable building of LCD1602 LCD (2013-5-25).
|
||||
* configs/pcblogic-pic32mx/src/pic32mx_lcd1602.c: Now uses SLCD CODEC
|
||||
(2013-5-25)
|
||||
* configs/stm32ldiscovery/src/stm32_lcd.c: Now supports ioctl to get
|
||||
cursor position (2013-5-25).
|
||||
* include/nuttx/lcd/slcd_ioctl.h: Moved ioctls commands and structures
|
||||
from slcd_codec.h (2013-5-25)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -788,7 +788,7 @@ Configuration sub-directories
|
||||
4. To enable SLCD support:
|
||||
|
||||
Board Selection:
|
||||
CONFIG_ARCH_LEDS=y : Disable LED support
|
||||
CONFIG_ARCH_LEDS=n : Disable LED support
|
||||
|
||||
Library Routines:
|
||||
CONFIG_LIB_SLCDCODEC=y : Enable the SLCD CODEC
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include <nuttx/ascii.h>
|
||||
#include <nuttx/streams.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/lcd/slcd_ioctl.h>
|
||||
#include <nuttx/lcd/slcd_codec.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
@@ -313,8 +314,8 @@ static void slcd_writebar(void);
|
||||
static inline uint16_t slcd_mapch(uint8_t ch);
|
||||
static inline void slcd_writemem(uint16_t segset, int curpos);
|
||||
static void slcd_writech(uint8_t ch, uint8_t curpos, uint8_t options);
|
||||
static inline void slcd_appendch(uint8_t ch, uint8_t options);
|
||||
static inline void slcd_action(enum slcdcode_e code, uint8_t count);
|
||||
static void slcd_appendch(uint8_t ch, uint8_t options);
|
||||
static void slcd_action(enum slcdcode_e code, uint8_t count);
|
||||
|
||||
/* Character driver methods */
|
||||
|
||||
@@ -999,7 +1000,7 @@ static void slcd_action(enum slcdcode_e code, uint8_t count)
|
||||
|
||||
case SLCDCODE_RIGHT: /* Cursor right by N characters */
|
||||
{
|
||||
/* Don't permit movement past the lcd of the SLCD */
|
||||
/* Don't permit movement past the end of the SLCD */
|
||||
|
||||
if (g_slcdstate.curpos < (SLCD_NCHARS - 1))
|
||||
{
|
||||
@@ -1040,6 +1041,11 @@ static ssize_t slcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
/* Try to read the entire display. Notice that the seek offset
|
||||
* (filp->f_pos) is ignored. It probably should be taken into account
|
||||
* and also updated after each read and write.
|
||||
*/
|
||||
|
||||
for (i = 0; i < SLCD_NCHARS && ret < len; i++)
|
||||
{
|
||||
/* Return the character */
|
||||
@@ -1233,6 +1239,29 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
||||
}
|
||||
break;
|
||||
|
||||
/* SLCDIOC_CURPOS: Get the SLCD cursor positioni (rows x characters)
|
||||
*
|
||||
* argument: Pointer to struct slcd_curpos_s in which values will be
|
||||
* returned
|
||||
*/
|
||||
|
||||
|
||||
case SLCDIOC_CURPOS:
|
||||
{
|
||||
FAR struct slcd_curpos_s *curpos = (FAR struct slcd_curpos_s *)((uintptr_t)arg);
|
||||
|
||||
lcdvdbg("SLCDIOC_CURPOS: row=0 column=%d\n", g_slcdstate.curpos);
|
||||
|
||||
if (!curpos)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
curpos->row = 0;
|
||||
curpos->column = g_slcdstate.curpos;
|
||||
}
|
||||
break;
|
||||
|
||||
/* SLCDIOC_SETBAR: Set bars on a bar display
|
||||
*
|
||||
* argument: 32-bit bitset, with each bit corresponding to one bar.
|
||||
@@ -1477,7 +1506,7 @@ int stm32_slcd_initialize(void)
|
||||
|
||||
/* Register the LCD device driver */
|
||||
|
||||
ret = register_driver("/dev/slcd", &g_slcdops, 0644, (FAR struct file_operations *)&g_slcdops);
|
||||
ret = register_driver("/dev/slcd", &g_slcdops, 0644, &g_slcdstate);
|
||||
g_slcdstate.initialized = true;
|
||||
|
||||
/* Then clear the display */
|
||||
|
||||
@@ -79,6 +79,19 @@
|
||||
|
||||
#define HD4478OU_BUSY(bf,ac) ((bf) << 7 | (ac))
|
||||
|
||||
/* DDRAM Addressing.
|
||||
*
|
||||
* Internally, the HD44780U supports a display size of up to 2x40 addressed
|
||||
* as follows:
|
||||
*
|
||||
* Column 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... 39
|
||||
* Row 0 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ... 27
|
||||
* Ro1 1 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f ... 67
|
||||
*/
|
||||
|
||||
#define HD4478OU_DDRAM_ROW0 0x00
|
||||
#define HD4478OU_DDRAM_ROW1 0x40
|
||||
|
||||
/********************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************************/
|
||||
|
||||
@@ -43,52 +43,12 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/streams.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#ifdef CONFIG_LIB_SLCDCODEC
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* IOCTL commands that may be supported by some SLCD drivers */
|
||||
|
||||
/* SLCDIOC_GEOMETRY: Get the SLCD geometry (rows x characters)
|
||||
*
|
||||
* argument: Pointer to struct slcd_geometry_s in which values will be
|
||||
* returned
|
||||
*/
|
||||
|
||||
#define SLCDIOC_GEOMETRY _SLCDIOC(0x0001)
|
||||
|
||||
/* SLCDIOC_SETBAR: Set bars on a bar display
|
||||
*
|
||||
* argument: 32-bit bitset, with each bit corresponding to one bar.
|
||||
*/
|
||||
|
||||
#define SLCDIOC_SETBAR _SLCDIOC(0x0002)
|
||||
|
||||
/* SLCDIOC_GETCONTRAST: Get the current contrast setting
|
||||
*
|
||||
* argument: Pointer type int that will receive the current contrast
|
||||
* setting
|
||||
*/
|
||||
|
||||
#define SLCDIOC_GETCONTRAST _SLCDIOC(0x0003)
|
||||
|
||||
/* SLCDIOC_MAXCONTRAST: Get the maximum contrast setting
|
||||
*
|
||||
* argument: Pointer type int that will receive the maximum contrast
|
||||
* setting
|
||||
*/
|
||||
|
||||
#define SLCDIOC_MAXCONTRAST _SLCDIOC(0x0004)
|
||||
|
||||
/* SLCDIOC_SETCONTRAST: Set the contrast to a new value
|
||||
*
|
||||
* argument: The new contrast value
|
||||
*/
|
||||
|
||||
#define SLCDIOC_SETCONTRAST _SLCDIOC(0x0005)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
@@ -142,15 +102,6 @@ enum slcdret_e
|
||||
SLCDRET_EOF /* An EOF (or possibly an error) occurred */
|
||||
};
|
||||
|
||||
/* Used with the SLCDIOC_GEOMETRY ioctl call */
|
||||
|
||||
struct slcd_geometry_s
|
||||
{
|
||||
uint16_t nrows; /* Number of the rows on the SLCD */
|
||||
uint16_t ncolumns; /* Number of characters in one row on the SLCD */
|
||||
uint8_t nbars; /* Number of bars supported by the SLCD */
|
||||
};
|
||||
|
||||
/* Working data needed by slcd_encode that must be provided and initialized
|
||||
* by the caller.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/************************************************************************************
|
||||
* include/nuttx/input/slcd_ioctl.h
|
||||
* IOCTL commands for segment LCDs
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 NuttX 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 OWNER 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 __INCLUDE_NUTTX_INPUT_SLCD_IOCTL_H
|
||||
#define __INCLUDE_NUTTX_INPUT_SLCD_IOCTL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* IOCTL commands that may be supported by some SLCD drivers */
|
||||
|
||||
/* SLCDIOC_GEOMETRY: Get the SLCD geometry (rows x characters)
|
||||
*
|
||||
* argument: Pointer to struct slcd_geometry_s in which values will be
|
||||
* returned
|
||||
*/
|
||||
|
||||
#define SLCDIOC_GEOMETRY _SLCDIOC(0x0001)
|
||||
|
||||
/* SLCDIOC_CURPOS: Get the SLCD cursor positioni (rows x characters)
|
||||
*
|
||||
* argument: Pointer to struct slcd_curpos_s in which values will be
|
||||
* returned
|
||||
*/
|
||||
|
||||
#define SLCDIOC_CURPOS _SLCDIOC(0x0002)
|
||||
|
||||
/* SLCDIOC_SETBAR: Set bars on a bar display
|
||||
*
|
||||
* argument: 32-bit bitset, with each bit corresponding to one bar.
|
||||
*/
|
||||
|
||||
#define SLCDIOC_SETBAR _SLCDIOC(0x0003)
|
||||
|
||||
/* SLCDIOC_GETCONTRAST: Get the current contrast setting
|
||||
*
|
||||
* argument: Pointer type int that will receive the current contrast
|
||||
* setting
|
||||
*/
|
||||
|
||||
#define SLCDIOC_GETCONTRAST _SLCDIOC(0x0004)
|
||||
|
||||
/* SLCDIOC_MAXCONTRAST: Get the maximum contrast setting
|
||||
*
|
||||
* argument: Pointer type int that will receive the maximum contrast
|
||||
* setting
|
||||
*/
|
||||
|
||||
#define SLCDIOC_MAXCONTRAST _SLCDIOC(0x0005)
|
||||
|
||||
/* SLCDIOC_SETCONTRAST: Set the contrast to a new value
|
||||
*
|
||||
* argument: The new contrast value
|
||||
*/
|
||||
|
||||
#define SLCDIOC_SETCONTRAST _SLCDIOC(0x0006)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Used with the SLCDIOC_GEOMETRY ioctl call */
|
||||
|
||||
struct slcd_geometry_s
|
||||
{
|
||||
uint16_t nrows; /* Number of the rows on the SLCD */
|
||||
uint16_t ncolumns; /* Number of characters in one row on the SLCD */
|
||||
uint8_t nbars; /* Number of bars supported by the SLCD */
|
||||
};
|
||||
|
||||
/* Used with the SLCDIOC_CURPOS ioctl call */
|
||||
|
||||
struct slcd_curpos_s
|
||||
{
|
||||
uint16_t row; /* Current row (zero-based) */
|
||||
uint16_t column; /* Current column (zero-based) */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_INPUT_SLCD_IOCTL_H */
|
||||
|
||||
Reference in New Issue
Block a user