apps/graphics/ft80x: Add support for reading/writing multiple registers. Add interface to obtain the touchscreen transform matrix. apps/examples/ft80x: Add more co-processor demos.
This commit is contained in:
parent
189996add6
commit
157da4f1ab
@ -153,6 +153,10 @@ int ft80x_prim_rectangles(int fd, FAR struct ft80x_dlbuffer_s *buffer);
|
||||
|
||||
int ft80x_coproc_progressbar(int fd, FAR struct ft80x_dlbuffer_s *buffer);
|
||||
int ft80x_coproc_scrollbar(int fd, FAR struct ft80x_dlbuffer_s *buffer);
|
||||
int ft80x_coproc_slider(int fd, FAR struct ft80x_dlbuffer_s *buffer);
|
||||
int ft80x_coproc_dial(int fd, FAR struct ft80x_dlbuffer_s *buffer);
|
||||
int ft80x_coproc_toggle(int fd, FAR struct ft80x_dlbuffer_s *buffer);
|
||||
int ft80x_coproc_calibrate(int fd, FAR struct ft80x_dlbuffer_s *buffer);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -111,11 +111,11 @@ static const struct ft80x_exampleinfo_s g_primitives[] =
|
||||
* --None-- CMD_KEYS Draw a row of keys
|
||||
* ft80x_coproc_progressbar CMD_PROGRESS Draw a progress bar
|
||||
* ft80x_coproc_scrollbar CMD_SCROLLBAR Draw a scroll bar
|
||||
* --None-- CMD_SLIDER Draw a slider
|
||||
* --None-- CMD_DIAL Draw a rotary dial control
|
||||
* --None-- CMD_TOGGLE Draw a toggle switch
|
||||
* ft80x_coproc_slider CMD_SLIDER Draw a slider
|
||||
* ft80x_coproc_dial CMD_DIAL Draw a rotary dial control
|
||||
* ft80x_coproc_toggle CMD_TOGGLE Draw a toggle switch
|
||||
* --None-- CMD_NUMBER Draw a decimal number
|
||||
* --None-- CMD_CALIBRATE Execute the touch screen
|
||||
* ft80x_coproc_calibrate CMD_CALIBRATE Execute the touch screen
|
||||
calibration routine
|
||||
* --None-- CMD_SPINNER Start an animated spinner
|
||||
* --None-- CMD_SCREENSAVER Start an animated screensaver
|
||||
@ -128,7 +128,11 @@ static const struct ft80x_exampleinfo_s g_primitives[] =
|
||||
static const struct ft80x_exampleinfo_s g_coproc[] =
|
||||
{
|
||||
{ "Progress Bar", ft80x_coproc_progressbar },
|
||||
{ "Scroll Bar", ft80x_coproc_scrollbar }
|
||||
{ "Scroll Bar", ft80x_coproc_scrollbar },
|
||||
{ "Slider", ft80x_coproc_slider },
|
||||
{ "Dial", ft80x_coproc_dial },
|
||||
{ "Toggle", ft80x_coproc_toggle },
|
||||
{ "Calibrate", ft80x_coproc_calibrate }
|
||||
};
|
||||
|
||||
#define NCOPROC (sizeof(g_primitives) / sizeof(ft80x_example_t))
|
||||
|
@ -39,8 +39,9 @@ include $(APPDIR)/Make.defs
|
||||
|
||||
# FTDI/BridgeTek FT80x library
|
||||
|
||||
ASRCS =
|
||||
CSRCS = ft80x_dl.c ft80x_ramg.c ft80x_ramdl.c ft80x_ramcmd.c ft80x_regs.c
|
||||
ASRCS =
|
||||
CSRCS = ft80x_dl.c ft80x_ramg.c ft80x_ramdl.c ft80x_ramcmd.c ft80x_touch.c
|
||||
CSRCS += ft80x_regs.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
@ -137,6 +137,26 @@ int ft80x_getreg8(int fd, uint32_t addr, FAR uint8_t *value);
|
||||
int ft80x_getreg16(int fd, uint32_t addr, FAR uint16_t *value);
|
||||
int ft80x_getreg32(int fd, uint32_t addr, FAR uint16_t *value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_getregs
|
||||
*
|
||||
* Description:
|
||||
* Read multiple 32-bit FT80x register values.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* addr - The 32-bit aligned, 22-bit start register address
|
||||
* nregs - The number of registers to read.
|
||||
* value - The location to return the register values
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_getregs(int fd, uint32_t addr, uint8_t nregs, FAR uint32_t *value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_putreg8/16/32
|
||||
*
|
||||
@ -158,6 +178,27 @@ int ft80x_putreg8(int fd, uint32_t addr, uint8_t value);
|
||||
int ft80x_putreg16(int fd, uint32_t addr, uint16_t value);
|
||||
int ft80x_putreg32(int fd, uint32_t addr, uint32_t value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_putregs
|
||||
*
|
||||
* Description:
|
||||
* Write multiple 32-bit FT80x register values.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* addr - The 32-bit aligned, 22-bit start register address
|
||||
* nregs - The number of registers to write.
|
||||
* value - The of the register values to be written.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_putregs(int fd, uint32_t addr, uint8_t nregs,
|
||||
FAR const uint32_t *value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_ramdl_rewind
|
||||
*
|
||||
|
@ -75,7 +75,7 @@
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* addr - The 32-bit aligned, 22-bit register value
|
||||
* addr - The 32-bit aligned, 22-bit register address
|
||||
* value - The location to return the register value
|
||||
*
|
||||
* Returned Value:
|
||||
@ -95,10 +95,15 @@ int ft80x_getreg8(int fd, uint32_t addr, FAR uint8_t *value)
|
||||
reg.addr = addr;
|
||||
ret = ioctl(fd, FT80X_IOC_GETREG8, (unsigned long)((uintptr_t)®));
|
||||
|
||||
if (ret >= 0)
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
ft80x_err("ERROR: ioctl(FT80X_IOC_GETREG8) failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = reg.value.u8;
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -116,10 +121,15 @@ int ft80x_getreg16(int fd, uint32_t addr, FAR uint16_t *value)
|
||||
reg.addr = addr;
|
||||
ret = ioctl(fd, FT80X_IOC_GETREG16, (unsigned long)((uintptr_t)®));
|
||||
|
||||
if (ret >= 0)
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
ft80x_err("ERROR: ioctl(FT80X_IOC_GETREG16) failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = reg.value.u16;
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -137,10 +147,57 @@ int ft80x_getreg32(int fd, uint32_t addr, FAR uint16_t *value)
|
||||
reg.addr = addr;
|
||||
ret = ioctl(fd, FT80X_IOC_GETREG32, (unsigned long)((uintptr_t)®));
|
||||
|
||||
if (ret >= 0)
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
ft80x_err("ERROR: ioctl(FT80X_IOC_GETREG32) failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = reg.value.u32;
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_getregs
|
||||
*
|
||||
* Description:
|
||||
* Read multiple 32-bit FT80x register values.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* addr - The 32-bit aligned, 22-bit start register address
|
||||
* nregs - The number of registers to read.
|
||||
* value - The location to return the register values
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_getregs(int fd, uint32_t addr, uint8_t nregs, FAR uint32_t *value)
|
||||
{
|
||||
struct ft80x_registers_s regs;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(value != NULL && (addr & 3) == 0 && addr < 0xffc00000);
|
||||
|
||||
/* Perform the IOCTL to get the register value */
|
||||
|
||||
regs.addr = addr;
|
||||
regs.nregs = nregs;
|
||||
regs.value = value;
|
||||
|
||||
ret = ioctl(fd, FT80X_IOC_GETREGS, (unsigned long)((uintptr_t)®s));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
ft80x_err("ERROR: ioctl(FT80X_IOC_GETREGS) failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -155,7 +212,7 @@ int ft80x_getreg32(int fd, uint32_t addr, FAR uint16_t *value)
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* addr - The 32-bit aligned, 22-bit register value
|
||||
* addr - The 32-bit aligned, 22-bit register address
|
||||
* value - The register value to write.
|
||||
*
|
||||
* Returned Value:
|
||||
@ -166,6 +223,7 @@ int ft80x_getreg32(int fd, uint32_t addr, FAR uint16_t *value)
|
||||
int ft80x_putreg8(int fd, uint32_t addr, uint8_t value)
|
||||
{
|
||||
struct ft80x_register_s reg;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(value != NULL && (addr & 3) == 0 && addr < 0xffc00000);
|
||||
|
||||
@ -173,12 +231,22 @@ int ft80x_putreg8(int fd, uint32_t addr, uint8_t value)
|
||||
|
||||
reg.addr = addr;
|
||||
reg.value.u8 = value;
|
||||
return ioctl(fd, FT80X_IOC_PUTREG8, (unsigned long)((uintptr_t)®));
|
||||
|
||||
ret = ioctl(fd, FT80X_IOC_PUTREG8, (unsigned long)((uintptr_t)®));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
ft80x_err("ERROR: ioctl(FT80X_IOC_PUTREG8) failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ft80x_putreg16(int fd, uint32_t addr, uint16_t value)
|
||||
{
|
||||
struct ft80x_register_s reg;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(value != NULL && (addr & 3) == 0 && addr < 0xffc00000);
|
||||
|
||||
@ -186,12 +254,22 @@ int ft80x_putreg16(int fd, uint32_t addr, uint16_t value)
|
||||
|
||||
reg.addr = addr;
|
||||
reg.value.u16 = value;
|
||||
return ioctl(fd, FT80X_IOC_PUTREG16, (unsigned long)((uintptr_t)®));
|
||||
|
||||
ret = ioctl(fd, FT80X_IOC_PUTREG16, (unsigned long)((uintptr_t)®));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
ft80x_err("ERROR: ioctl(FT80X_IOC_PUTREG16) failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ft80x_putreg32(int fd, uint32_t addr, uint32_t value)
|
||||
{
|
||||
struct ft80x_register_s reg;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(value != NULL && (addr & 3) == 0 && addr < 0xffc00000);
|
||||
|
||||
@ -199,7 +277,59 @@ int ft80x_putreg32(int fd, uint32_t addr, uint32_t value)
|
||||
|
||||
reg.addr = addr;
|
||||
reg.value.u32 = value;
|
||||
return ioctl(fd, FT80X_IOC_PUTREG32, (unsigned long)((uintptr_t)®));
|
||||
|
||||
ret = ioctl(fd, FT80X_IOC_PUTREG32, (unsigned long)((uintptr_t)®));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
ft80x_err("ERROR: ioctl(FT80X_IOC_PUTREG32) failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_putregs
|
||||
*
|
||||
* Description:
|
||||
* Write multiple 32-bit FT80x register values.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* addr - The 32-bit aligned, 22-bit start register address
|
||||
* nregs - The number of registers to write.
|
||||
* value - The of the register values to be written.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_putregs(int fd, uint32_t addr, uint8_t nregs,
|
||||
FAR const uint32_t *value)
|
||||
{
|
||||
struct ft80x_registers_s regs;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(value != NULL && (addr & 3) == 0 && addr < 0xffc00000);
|
||||
|
||||
/* Perform the IOCTL to get the register value */
|
||||
|
||||
regs.addr = addr;
|
||||
regs.nregs = nregs;
|
||||
regs.value = (FAR uint32_t *)value; /* Discard const qualifier */
|
||||
|
||||
ret = ioctl(fd, FT80X_IOC_PUTREGS, (unsigned long)((uintptr_t)®s));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
ft80x_err("ERROR: ioctl(FT80X_IOC_PUTREGS) failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
85
graphics/ft80x/ft80x_touch.c
Normal file
85
graphics/ft80x/ft80x_touch.c
Normal file
@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/ft80x/ft80x_touch.c
|
||||
*
|
||||
* Copyright (C) 2018 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/lcd/ft80x.h>
|
||||
|
||||
#include "graphics/ft80x.h"
|
||||
#include "ft80x.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_touch_gettransform
|
||||
*
|
||||
* Description:
|
||||
* Read the touch transfrom matrix
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* matrix - The location to return the transfrom matrix
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_touch_gettransform(int fd, FAR uint32_t matrix[6])
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Read FT80X_REG_TOUCH_TRANSFORM_A through FT80X_REG_TOUCH_TRANSFORM_F */
|
||||
|
||||
ret = ft80x_getregs(fd, FT80X_REG_TOUCH_TRANSFORM_A, 6, matrix);
|
||||
if (ret < 0)
|
||||
{
|
||||
ft80x_err("ERROR: ft80x_getregs failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
@ -258,6 +258,25 @@ int ft80x_dl_create(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
||||
|
||||
int ft80x_ramg_write(int fd, unsigned int offset, FAR const void *data,
|
||||
unsigned int nbytes);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_touch_gettransform
|
||||
*
|
||||
* Description:
|
||||
* Read the touch transfrom matrix
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* matrix - The location to return the transfrom matrix
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_touch_gettransform(int fd, FAR uint32_t matrix[6]);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user