PCB-Logic PIC32MX LCD1602 driver now supports SLCD CODED; Added an SLCD ioctl command to get cursor position

This commit is contained in:
Gregory Nutt
2013-05-25 13:46:43 -06:00
parent 4867c1f891
commit 6c64f9286a
3 changed files with 597 additions and 19 deletions
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -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
+33 -4
View File
@@ -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 */