[-]
[+]
|
Changed |
serdisplib.changes
|
|
[-]
[+]
|
Changed |
serdisplib.spec
^
|
|
[-]
[+]
|
Deleted |
serdisplib-1.97.8.tar.bz2/buildfiles/serdisplib_1.97.8.bb
^
|
@@ -1,56 +0,0 @@
-DESCRIPTION = "library to drive LC-displays"
-SECTION = "libs"
-DEPENDS += "libusb"
-LICENSE = "GPL"
-PRIORITY = "optional"
-MAINTAINER ="maf; Wolfgang Astleitner <mrwastl@users.sf.net>"
-DEFAULT_PREFERENCE = "1"
-
-PREMIRRORS_prepend () {
- ${SOURCEFORGE_MIRROR} http://mesh.dl.sourceforge.net/sourceforge
-}
-SRC_URI = "${SOURCEFORGE_MIRROR}/serdisplib/serdisplib-${PV}.tar.gz"
-
-S = "${WORKDIR}/serdisplib-${PV}"
-
-inherit autotools
-
-HEADER_FILES = serdisp.h serdisp_control.h serdisp_connect.h serdisp_messages.h \
- serdisp_colour.h serdisp_tools.h serdisp_parport.h
-
-EXTRA_OECONF = "--enable-libusb"
-
-do_stage() {
- oe_libinstall -a -so lib/libserdisp ${STAGING_LIBDIR}
-
- install -d ${STAGING_BINDIR}
- install -m 755 src/testserdisp ${STAGING_BINDIR}
- if test -e tools/multidisplay; then
- install -m 755 tools/multidisplay ${STAGING_BINDIR}
- fi
-
- install -d ${STAGING_INCDIR}/serdisplib
- for X in ${HEADER_FILES}
- do
- install -m 0644 include/serdisplib/$X ${STAGING_INCDIR}/serdisplib/$X
- done
-}
-
-
-do_install () {
- oe_libinstall -a -so lib/libserdisp ${D}${libdir}
-
- install -d ${D}${bindir}
- install -m 755 src/testserdisp ${D}${bindir}
- if test -e tools/multidisplay; then
- install -m 755 tools/multidisplay ${D}${bindir}
- fi
-
- install -d ${D}${includedir}/serdisplib
-
- for X in ${HEADER_FILES}
- do
- install -m 0644 include/serdisplib/$X ${D}${includedir}/serdisplib/$X
- done
-}
-
|
[-]
[+]
|
Deleted |
serdisplib-1.97.8.tar.bz2/src/serdisp_specific_alphacool.c
^
|
@@ -1,1054 +0,0 @@
-/*
- *************************************************************************
- *
- * serdisp_specific_alphacool.c
- * routines for controlling alphacool 200x64 and 240x128 USB-displays
- *
- *************************************************************************
- *
- * copyright (C) 2007 fen <fen@init-6.org>
- * copyright (C) 2007 nessie <nessie10@gmx.net> (original code)
- *
- * additional maintenance:
- * copyright (C) 2007-2008 wolfgang astleitner
- * email mrwastl@users.sourceforge.net
- *
- *************************************************************************
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA. Or, point your browser to
- * http://www.gnu.org/copyleft/gpl.html
- *************************************************************************
- */
-
-/*
- * Display organisation 200x64:
- *
- * Display is 200 by 64 pixel. The display transfer buffer uses the
- * following layout:
- *
- * data[0] column 0, rows 0 to 7, msb is row 0, lsb is row 7
- * data[1] column 1, rows 0 to 7, msb is row 0, lsb is row 7
- * ...
- * data[199] column 199, rows 0 to 7, msb is row 0, lsb is row 7
- * data[200] column 0, rows 8 to 15, msb is row 8, lsb is row 15
- * data[201] column 1, rows 8 to 15, msb is row 8, lsb is row 15
- * ...
- * data[399] column 199, rows 8 to 15, msb is row 8, lsb is row 15
- * ...
- *
- * every byte represents 8 rows of a column. the buffer is
- * 200 * 64 / 8 = 1600 bytes.
- *
- *
- * Display organisation 240x128:
- *
- * Display is 240 by 128 pixel. The display transfer buffer uses the
- * following layout:
- *
- * data[0] column 0 to 7, row 0, msb is column 0, lsb is column 7
- * data[1] column 8 to 15, row 0, msb is column 8, lsb is column 15
- * ...
- * data[239] column 232 to 239, row 0, msb is column 232, lsb is column 239
- * data[240] column 0 to 7, row 1, msb is column 0, lsb is column 7
- * data[241] column 8 to 15, row 1, msb is column 8, lsb is column 15
- * ...
- *
- * every byte represents 8 columns of a row. the buffer is
- * 240 * 128 / 8 = 3840 bytes.
- */
-
-/*
- * includes
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "serdisplib/serdisp_connect.h"
-#include "serdisplib/serdisp_tools.h"
-#include "serdisplib/serdisp_messages.h"
-#include "serdisplib/serdisp_connect_usb.h"
-#include <usb.h>
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- #include "serdisplib/serdisp_colour.h"
-#endif
-
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- extern void* libhnd_usb;
-
- extern int (*fp_usb_bulk_write) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
- extern int (*fp_usb_control_msg) (usb_dev_handle* dev, int requesttype, int request,
- int value, int index, char *bytes, int size, int timeout);
-#else
- #define fp_usb_bulk_write usb_bulk_write
- #define fp_usb_control_msg usb_control_msg
-#endif /* SERDISP_VERSION_CODE */
-
-
-
-
-/*
- * request constants
- */
-
-#define REQUEST_LCD_INIT 0x31
-#define REQUEST_LCD_GFX_WRITE_INIT 0x32
-#define REQUEST_LCD_GFX_WRITE_END 0x33
-#define REQUEST_LCD_GFX_WRITE_DATA 0x34
-#define REQUEST_LCD_GFX_CLEAR 0x35
-#define REQUEST_LCD_TXT_WRITE_INIT 0x36
-#define REQUEST_LCD_TXT_WRITE_END 0x37
-#define REQUEST_LCD_TXT_WRITE_DATA 0x38
-#define REQUEST_LCD_TXT_CLEAR 0x39
-#define REQUEST_LCD_CLEAR 0x3A
-#define REQUEST_LCD_CS 0x3B
-#define REQUEST_LCD_WRITE_DATA 0x3C
-#define REQUEST_LCD_WRITE_AUTO_DATA 0x3D
-#define REQUEST_LCD_WRITE_COMMAND 0x3E
-#define REQUEST_LCD_WRITE_COMMAND1 0x3F
-#define REQUEST_LCD_WRITE_COMMAND2 0x40
-#define REQUEST_LCD_READ_DATA 0x41
-#define REQUEST_LCD_READ_AUTO_DATA 0x42
-#define REQUEST_LCD_BKL 0x43
-#define REQUEST_LCD_AUTO_WRITE_RESET 0x44
-#define REQUEST_LCD_AUTO_READ_RESET 0x45
-#define REQUEST_LCD_SET_FONT 0x46
-#define REQUEST_LCD_DEVICE 0x47
-#define REQUEST_LCD_GET_ADDRESS 0x48
-#define REQUEST_LCD_SET_ADDRESS 0x49
-
-/*
- * additional constants
- */
-
-#define AC_200x64 0
-#define AC_240x128 1
-
-#define AC_MD_ROW 0
-#define AC_MD_COL 1
-
-#define DISPID_ALPHACOOL 1
-
-/*
- * endpoint constants
- */
-
-#define EP_DISPLAY_DATA_OUT 0x03
-#define IF_DISPLAY_DATA_OUT 0x00
-
-/*
- * macros
- */
-
-#define check(expr) serdisp_alphacool_runtime_check(expr, __func__, __FILE__, __LINE__)
-
-serdisp_options_t alphacool_options[] = {
- /* name aliasnames min max mod int defines */
- { "BACKLIGHT", "", 0, 1, 1, 1, "ON=1,OFF=0,YES=1,NO=0"}, /* backlight on/off */
- { "OPTALGO", "", 0, 1, 1, 1, "ON=1,OFF=0,YES=1,NO=0"} /* optimized algo */
-};
-
-/*
- * private function prototypes
- */
-
-static void serdisp_alphacool_init (serdisp_t *dd);
-static void serdisp_alphacool_update (serdisp_t *dd);
-static int serdisp_alphacool_setoption (serdisp_t *dd, const char *option, long value);
-static void serdisp_alphacool_close (serdisp_t *dd);
-static void serdisp_alphacool_setpixel (serdisp_t *dd, int x, int y, long colour);
-static long serdisp_alphacool_getpixel (serdisp_t *dd, int x, int y);
-static void* serdisp_alphacool_getvalueptr (serdisp_t *dd, const char *optionname, int *typesize);
-static void serdisp_alphacool_getrect (serdisp_t *dd, int *x1, int *y1, int *x2, int *y2, int *is_empty);
-static void serdisp_alphacool_transfer_rect (serdisp_t *dd, int x1, int y1, int x2, int y2);
-static int serdisp_alphacool_runtime_check (int condition, const char *function, const char *file, const int line);
-
-/*
- * private structures
- */
-
-typedef struct serdisp_alphacool_data_s
-{
- byte *trans_scrbuf; /* transfer buffer */
- int optalgo; /* use optimized algo */
- byte type; /* display type */
- int mode; /* buffer mode */
-} serdisp_alphacool_data_t;
-
-/* *********************************
- serdisp_t* serdisp_alphacool_setup(dispname, optionstring)
- *********************************
- sets up a display descriptor fitting to dispname and extra
- *********************************
- sdcd ... port descriptor
- dispname ... display name (case-insensitive)
- optionstring ... option string containing individual options
- *********************************
- returns a display descriptor
-*/
-serdisp_t* serdisp_alphacool_setup(const serdisp_CONN_t *sdcd, const char *dispname, const char *optionstring) {
- serdisp_t* dd = 0;
- serdisp_alphacool_data_t* data = 0;
- serdisp_usbdev_t* usbitems = 0;
-
- byte type = 0;
-
- sd_debug(2, ">>> %s(sdcd=%p, dispname='%s', optionstring='%s')", __func__, sdcd, dispname, optionstring);
-
- if(check(dispname == 0 || optionstring == 0)) { return (serdisp_t *)0; }
-
- if(sdcd) {
- /* maybe null in case of wirequery */
-
- usbitems = (serdisp_usbdev_t*)(sdcd->extra);
- }
-
- /* allocate descriptor */
-
- if(!(dd = (serdisp_t *)sdtools_malloc(sizeof(serdisp_t)))) {
- sd_error(SERDISP_EMALLOC, "%s(): cannot allocate display descriptor", __func__);
- return (serdisp_t *)0;
- }
-
- memset(dd, 0, sizeof(serdisp_t));
-
- /* allocate private data */
-
- if(!(data = sdtools_malloc(sizeof(serdisp_alphacool_data_t)))) {
- sd_error(SERDISP_EMALLOC, "%s(): cannot allocate private data", __func__);
- free(dd);
- dd = 0;
- return (serdisp_t *)0;
- }
-
- memset(data, 0, sizeof(serdisp_alphacool_data_t));
-
- dd->specific_data = data;
-
- /* assign dd->dsp_id */
-
- if(serdisp_comparedispnames("ALPHACOOL", dispname)) {
- dd->dsp_id = DISPID_ALPHACOOL;
- } else {
- sd_error(SERDISP_ENOTSUP, "%s(): display type '%s' not supported", __func__, dispname);
- free(dd->specific_data);
- free(dd);
- dd = 0;
- return (serdisp_t *)0;
- }
-
- /* detect display type */
-
- if(usbitems) {
- /* fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, REQUEST_LCD_INIT, 0,
- 0, NULL, 0, usbitems->write_timeout); */
- if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR|USB_ENDPOINT_IN,
- REQUEST_LCD_DEVICE, 0, 0, (char *)&type, 1,
- usbitems->write_timeout) == 1) {
- if(type == AC_200x64) {
- dd->width = 200; /* display width */
- dd->height = 64; /* display height */
- data->optalgo = 1; /* optimizer on */
- data->type = AC_200x64; /* display type */
- data->mode = AC_MD_COL; /* buffer organization */
- } else if(type == AC_240x128) {
- dd->width = 240; /* display width */
- dd->height = 128; /* display height */
- data->optalgo = 1; /* optimizer on */
- data->type = AC_240x128; /* display type */
- data->mode = AC_MD_ROW; /* buffer organization */
- } else {
- sd_error(SERDISP_ENOTSUP, "%s(): display type '%d' not supported", __func__, type);
- free(dd->specific_data);
- free(dd);
- dd = 0;
- return (serdisp_t *)0;
- }
-
- sd_debug(1, "%s(): detected %dx%d display", __func__, dd->width, dd->height);
- } else {
- /* use default if usb device is unavailable */
- dd->width = 240;
- dd->height = 128;
- data->optalgo = 1;
-
- sd_debug(1, "%s(): detection failed - using %dx%d as default", __func__, dd->width, dd->height);
- }
- }
-
- dd->depth = 1; /* display is monochrome */
- dd->feature_contrast = 0; /* no contrast support */
- dd->feature_invert = 1; /* can invert */
- dd->curr_invert = 0; /* not yet inverted */
- dd->curr_rotate = 0; /* not yet rotated */
- dd->feature_backlight = 1; /* has backlight */
- dd->curr_backlight = 1; /* backlight is on */
- dd->connection_types = SERDISPCONNTYPE_PARPORT;
- dd->fp_init = &serdisp_alphacool_init;
- dd->fp_update = &serdisp_alphacool_update;
- dd->fp_setoption = &serdisp_alphacool_setoption;
- dd->fp_close = &serdisp_alphacool_close;
- dd->fp_setpixel = &serdisp_alphacool_setpixel;
- dd->fp_getpixel = &serdisp_alphacool_getpixel;
- dd->fp_getvalueptr = &serdisp_alphacool_getvalueptr;
-
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- dd->colour_spaces = SD_CS_SCRBUFCUSTOM | SD_CS_GREYSCALE;
-#endif
-
- serdisp_setupstructinfos(dd, 0, 0, alphacool_options);
-
- /* parse and set options */
-
- if(serdisp_setupoptions(dd, dispname, optionstring)) {
- free(dd->specific_data);
- free(dd);
- dd = 0;
- return (serdisp_t *)0;
- }
-
- sd_debug(2, "<<< %s()", __func__);
- return(dd);
-}
-
-/* *********************************
- void serdisp_alphacool_init(dd)
- *********************************
- initialise an alphacool USB-display
- *********************************
- dd ... display descriptor
-*/
-void serdisp_alphacool_init(serdisp_t *dd) {
- serdisp_usbdev_t* usbitems = 0;
- serdisp_alphacool_data_t* data = 0;
-
- sd_debug(2, ">>> %s(dd=%p)", __func__, dd);
-
- if(check(dd == 0)) { return; }
-
- usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- if(check(usbitems == 0 || data == 0)) { return; }
-
- /* init display */
-
- if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, REQUEST_LCD_INIT, 0,
- 0, NULL, 0, usbitems->write_timeout) < 0) {
- sd_error(SERDISP_ERUNTIME, "%s(): request 'REQUEST_LCD_INIT' failed", __func__);
- }
-
- /* clear display */
-
- if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, REQUEST_LCD_CLEAR, 0,
- 0, NULL, 0, usbitems->write_timeout) < 0) {
- sd_error(SERDISP_ERUNTIME, "%s(): request 'REQUEST_LCD_CLEAR' failed", __func__);
- }
-
- /* set backlight */
-
- serdisp_alphacool_setoption(dd, "BACKLIGHT", dd->curr_backlight);
-
- /* alloc transferbuffer */
-
- if(data->trans_scrbuf) {
- /* free previously allocated buffer (if any) */
-
- free(data->trans_scrbuf);
- data->trans_scrbuf = 0;
- }
-
- if(!(data->trans_scrbuf = (byte *)sdtools_malloc(sizeof(byte) * dd->scrbuf_size))) {
- sd_error(SERDISP_EMALLOC, "%s(): cannot allocate translation screenbuffer", __func__);
- return;
- }
-
- memset(data->trans_scrbuf, 0, dd->scrbuf_size);
-
- sd_debug(2, "<<< %s()", __func__);
- return;
-}
-
-/* *********************************
- void serdisp_alphacool_update(dd)
- *********************************
- updates the display
- *********************************
- dd ... display descriptor
- *********************************
-*/
-void serdisp_alphacool_update(serdisp_t *dd) {
- int x1 = 0, y1 = 0, x2 = 0, y2 = 0; /* coords */
- int is_empty = 0; /* indicates empty rect */
- serdisp_alphacool_data_t *data = 0;
-
- sd_debug(2, ">>> %s(dd=%p)", __func__, dd);
-
- if(check(dd == 0)) { return; }
-
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- if(check(data == 0)) { return; }
-
- /*
- * compute area to transfer - start with the whole display
- * area. values are byte boundary.
- */
-
- switch(data->mode) {
- case AC_MD_ROW:
- x1 = 0;
- y1 = 0;
- x2 = (dd->width / 8) - 1;
- y2 = dd->height -1;
- break;
-
- case AC_MD_COL:
- x1 = 0;
- y1 = 0;
- x2 = dd->width - 1;
- y2 = (dd->height / 8) - 1;
- break;
-
- default:
- return;
- }
-
- /*
- * if optimizer has been requested by the user
- * try to make the rectangle to transfer out of
- * the display buffer as small as possible
- */
-
- if(data->optalgo)
- {
- sd_debug(2, " using optimized algo");
-
- /* detect the smallest rectangle to transfer */
-
- serdisp_alphacool_getrect(dd, &x1, &y1, &x2, &y2, &is_empty);
-
- if(!is_empty)
- {
- if(data->type == AC_200x64)
- {
- /*
- * this display type has a firmware bug. if the update region
- * is entirly in the right display half the update fails and
- * the left half will show the right half too. to avoid this
- * we make sure that at least 1 pixel of the update region
- * is in the left half of the display.
- */
-
- if(x1 > 99)
- {
- x1 = 99;
- }
- }
-
- /* transfer the rectangle to the display */
-
- serdisp_alphacool_transfer_rect(dd, x1, y1, x2, y2);
- }
- }
- else
- {
- sd_debug(2, " optimizer disabled");
-
- /* transfer the whole buffer */
-
- serdisp_alphacool_transfer_rect(dd, x1, y1, x2, y2);
- }
-
- /* reset change buffer */
-
- memset(dd->scrbuf_chg, 0x00, dd->scrbuf_chg_size);
-
- sd_debug(2, "<<< %s()", __func__);
- return;
-}
-
-/* *********************************
- void serdisp_alphacool_getrect(dd, x1, y1, x2, y2, is_empty)
- *********************************
- extracts the rectangle to transfer. returns
- coords of smallest rect in x1/y1/x2/y2.
- *********************************
- dd ... display descriptor
- x1/y1 ... upper left of search area
- x2/y2 ... lower right of search area
- is_empty ... return value for empty flag
-
- defs for mode AC_MD_ROW (row mode):
- x = value for column (byte based)
- y = value for row
-
- defs for mode AC_MD_COL (col mode):
- x = value for column
- y = value for row (byte based)
- *********************************
-*/
-void serdisp_alphacool_getrect(serdisp_t *dd, int *x1, int *y1, int *x2, int *y2, int *is_empty)
-{
- serdisp_alphacool_data_t* data = 0;
- int x = 0, y = 0;
- int x1_n = 0, y1_n = 0;
- int x2_n = 0, y2_n = 0;
- int bp = 0, byte_offset = 0, bit_offset = 0;
- byte d = 0;
-
-
- sd_debug(2, ">>> %s(dd=%p, x1=%d, y1=%d, x2=%d, y2=%d)", __func__, dd, *x1, *y1, *x2, *y2);
-
- if(check(dd == 0 || *x1 >= *x2 || *y1 >= *y2)) { return; }
-
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- if(check(data == 0)) { return; }
-
- /* init values with caller values */
-
- x1_n = *x2;
- y1_n = *y2;
- x2_n = *x1;
- y2_n = *y1;
-
- /* not found anything - consider rect as empty */
-
- *is_empty = 1;
-
- /*
- * search smallest rect in the change buffer
- * the buffer is bit oriented - so we need to do
- * a little extra math to mask the bits out
- * of the bytes. each bit represents the
- * corresponding byte of the display buffer.
- * ergo we have a 30 bit wide and 128 bit height
- * buffer which results in 480 bytes for a
- * 240x128 pixel display. the bit is set by
- * the setpixel sub if the byte in the buffer
- * is changed. this is some kind of delta bitmap
- * to the last picture sent to the display.
- */
-
- for(y=*y1; y<=*y2; y++)
- {
- for(x=*x1; x<=*x2; x++)
- {
- switch(data->mode)
- {
- case AC_MD_ROW:
- bp = y * (dd->width / 8) + x;
- break;
-
- case AC_MD_COL:
- bp = y * dd->width + x;
- break;
-
- default:
- return;
- }
-
- byte_offset = bp / 8;
- bit_offset = bp % 8;
-
- d = dd->scrbuf_chg[byte_offset] & (0x80 >> bit_offset);
-
- if(d) {
- /*
- * this bit is set - set the rect
- * accordingly...
- */
-
- if(x<x1_n) { x1_n = x; }
- if(x>x2_n) { x2_n = x; }
- if(y<y1_n) { y1_n = y; }
- if(y>y2_n) { y2_n = y; }
-
- /* tell the caller that we found something */
-
- *is_empty = 0;
- }
- }
- }
-
- /* transfer coords to the caller */
-
- if(!*is_empty)
- {
- *x1 = x1_n;
- *y1 = y1_n;
- *x2 = x2_n;
- *y2 = y2_n;
- }
-
- sd_debug(2, "<<< %s()", __func__);
- return;
-}
-
-/* *********************************
- void serdisp_alphacool_transfer_rect(dd, x1, y1, x2, y2)
- *********************************
- transfer a given rect to the display
- *********************************
- dd ... display descriptor
- x1/y1 ... upper left of area
- x2/y2 ... lower right of area
-
- defs for mode AC_MD_ROW:
- x = value for column (byte based)
- y = value for row
-
- defs for mode AC_MD_COL:
- x = value for column
- y = value for row (byte based)
- *********************************
-*/
-void serdisp_alphacool_transfer_rect(serdisp_t *dd, int x1, int y1, int x2, int y2)
-{
- serdisp_usbdev_t* usbitems = 0;
- serdisp_alphacool_data_t* data = 0;
-
- int delta_width = 0, delta_height = 0;
- int x =0, y = 0;
- int length = 0, d = 0;
-
- sd_debug(2, ">>> %s(dd=%p, x1=%d, y1=%d, x2=%d, y2=%d)", __func__, dd, x1, y1, x2, y2);
-
- if(check(dd == 0)) { return; }
-
- usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- if(check(usbitems == 0 || data == 0)) { return; }
-
- /*
- * we need to build the transfer buffer containing only the
- * bytes of the given region. this is rather simple.
- *
- * we do have a second buffer (data->trans_scrbuf) in the size of
- * the screenbuffer which has been allocated before. so to build
- * the transferbuffer we just copy the given rectangular region
- * from the display buffer and transfer the result to the display.
- */
-
- delta_width = x2 - x1 + 1; /* width of the change region in bytes */
- delta_height = y2 - y1 + 1; /* height of the change buffer */
- length = 0; /* length of the resulting transfer buffer */
-
- /* copy the transfer buffer */
-
- for(y=y1; y<=y2; y++)
- {
- for(x=x1; x<=x2; x++)
- {
- switch(data->mode)
- {
- case AC_MD_ROW:
- d = dd->scrbuf[y * (dd->width / 8) + x];
- break;
-
- case AC_MD_COL:
- d = dd->scrbuf[y * dd->width + x];
- break;
-
- default:
- d = 0;
- break;
- }
-
- /* copy the data and invert if requested */
-
- data->trans_scrbuf[length] = (dd->curr_invert) ? (d ^ 0xFF) : (d);
- length++;
- }
- }
-
- /*
- * now we got a transfer buffer (data->trans_scrbuf) with the width
- * of delta_width and the height of delta_height.
- */
-
- /*
- * init the transfer to the diplay by sending the
- * REQUEST_LCD_GFX_WRITE_INIT command to the display.
- * this command requires the coordinates of the area
- * to change as a long (32 bit) value which contains
- * the upper left coordinate, the width in bytes and
- * the height in pixels.
- *
- * the data is organized as YYXXHHWW so that we need
- * to do a little shifting
- */
-
- if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, REQUEST_LCD_GFX_WRITE_INIT,
- ((y1 << 8) | (x1 & 0xFF)), ((delta_height << 8) | (delta_width & 0xFF)),
- NULL, 0, usbitems->write_timeout) < 0) {
- sd_error(SERDISP_ERUNTIME, "%s(): request 'REQUEST_LCD_GFX_WRITE_INIT' failed", __func__);
- return;
- }
-
- /*
- * do a bulk write with the buffer which should be copied
- * into the rectangle identified by the prvious command.
- */
-
- if(fp_usb_bulk_write(usbitems->usb_dev, EP_DISPLAY_DATA_OUT,
- (char *)(data->trans_scrbuf), length,
- usbitems->write_timeout) < 0)
- {
- sd_error(SERDISP_ERUNTIME, "%s(): usb_bulk_write() failed", __func__);
- return;
- }
-
- /*
- * reset the endpoint
- */
-
- if (fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, REQUEST_LCD_GFX_WRITE_END,
- 0, 0,
- NULL, 0, usbitems->write_timeout) < 0) {
- sd_error(SERDISP_ERUNTIME, "%s(): request 'REQUEST_LCD_GFX_WRITE_END' failed", __func__);
- return;
- }
-
- return;
-}
-
-/* *********************************
- int serdisp_alphacool_setoption(dd, optionname, value)
- *********************************
- change a display option
- *********************************
- dd ... display descriptor
- optionname ... name of option to change
- value ... value for option
- *********************************
-*/
-int serdisp_alphacool_setoption(serdisp_t *dd, const char *optionname, long value) {
- serdisp_usbdev_t* usbitems = 0;
- serdisp_alphacool_data_t* data = 0;
-
- sd_debug(2, ">>> %s(dd=%p, optionname='%s', value=%ld)", __func__, dd, optionname, value);
-
- if(check(dd == 0 || optionname == 0)) { return 0; }
-
- usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- if(check(usbitems == 0 || data == 0)) { return 0; }
-
- if(dd->feature_backlight && serdisp_compareoptionnames(dd, optionname, "BACKLIGHT")) {
- /* backlight */
-
- if(value < 2) {
- dd->curr_backlight = value;
- } else {
- dd->curr_backlight = (dd->curr_backlight) ? 0 : 1;
- }
-
- if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, REQUEST_LCD_BKL, (dd->curr_backlight) ? 1 : 0,
- 0, NULL, 0, usbitems->write_timeout) < 0) {
- sd_error(SERDISP_ERUNTIME, "%s(): request 'REQUEST_LCD_BKL' failed", __func__);
- }
- } else if(serdisp_compareoptionnames(dd, optionname, "OPTALGO")) {
- /* transfer optimizer */
-
- if(value < 2) {
- data->optalgo = value;
- } else {
- data->optalgo = (data->optalgo) ? 0 : 1;
- }
- } else {
- /* option not found here: try generic one in calling serdisp_setoption(); */
-
- sd_debug(1, "%s(): option unhandled - using fallback", __func__);
- return 0;
- }
-
- sd_debug(2, "<<< %s()", __func__);
- return 1;
-}
-
-/* *********************************
- int serdisp_alphacool_getvalueptr(dd, optionname, typesize)
- *********************************
- get a display option
- *********************************
- dd ... display descriptor
- optionname ... name of option to change
- typesize ... pointer to typesize storage
-*/
-void *serdisp_alphacool_getvalueptr(serdisp_t *dd, const char *optionname, int *typesize) {
- serdisp_alphacool_data_t* data = 0;
-
- sd_debug(2, ">>> %s(dd=%p, optionname='%s', typesize=%p)", __func__, dd, optionname, typesize);
-
- if(check(dd == 0 || optionname == 0 || typesize == 0)) { return 0; }
-
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- if(check(data == 0)) { return 0; }
-
- if(serdisp_compareoptionnames(dd, optionname, "OPTALGO")) {
- *typesize = sizeof(int);
- return &(data->optalgo);
- }
-
- sd_debug(2, "<<< %s()", __func__);
- return 0;
-}
-
-/* *********************************
- void serdisp_alphacool_close(dd)
- *********************************
- close (switch off) display
- *********************************
- dd ... display descriptor
-*/
-void serdisp_alphacool_close(serdisp_t *dd) {
- serdisp_alphacool_data_t* data = 0;
-
- unsigned int last_backlight = 0;
- serdisp_usbdev_t* usbitems = 0;
-
- sd_debug(2, ">>> %s(dd=%p)", __func__, dd);
-
- if(check(dd == 0)) { return; }
-
- usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
-
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- /* set backlight off, but do not remember it */
-
- last_backlight = dd->curr_backlight;
- serdisp_alphacool_setoption(dd, "BACKLIGHT", 0);
- dd->curr_backlight = last_backlight;
-
- /* clear screen */
- /*serdisp_clear(dd);*/
- fp_usb_control_msg(usbitems->usb_dev,USB_TYPE_VENDOR, REQUEST_LCD_BKL, 0, 0, NULL, 0, 1);
- fp_usb_control_msg(usbitems->usb_dev,USB_TYPE_VENDOR, REQUEST_LCD_CLEAR, 0, 0, NULL, 0, 1000);
-
- /* free buffers */
-
- if(data) {
- if(data->trans_scrbuf) {
- free(data->trans_scrbuf);
- data->trans_scrbuf = 0;
- }
-
- free(data);
- dd->specific_data = 0;
- }
-
- sd_debug(2, "<<< %s()", __func__);
- return;
-}
-
-/* *********************************
- void serdisp_alphacool_setpixel(dd, x, y, colour)
- *********************************
- changes a pixel into the display buffer
- *********************************
- dd ... display descriptor
- x ... x-position
- y ... y-position
- colour ... monochrome: 0: clear (white), <>0: set (black)
-*/
-void serdisp_alphacool_setpixel(serdisp_t *dd, int x, int y, long colour) {
- serdisp_alphacool_data_t* data = 0;
-
- unsigned int x_i = 0, y_i = 0, w_b = 0, x_b = 0, y_b = 0, pos = 0;
- byte value_orig = 0, value = 0, mask = 0;
-
- if(check(dd == 0)) { return; }
-
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- if(check(data == 0)) { return; }
-
- if(dd->curr_rotate <= 1) {
- if(x >= dd->width || y >= dd->height || x < 0 || y < 0)
- {
- return;
- }
- } else {
- if(x >= dd->height || y >= dd->width || x < 0 || y < 0) {
- return;
- }
- }
-
- switch(dd->curr_rotate) {
- case 0: /* 0 degrees */
- x_i = dd->xreloctab[x];
- y_i = dd->yreloctab[y];
- break;
-
- case 1: /* 180 degrees */
- x_i = dd->xreloctab[dd->width - 1 - x];
- y_i = dd->yreloctab[dd->height - 1 - y];
- break;
-
- case 2: /* 90 degrees */
- x_i = dd->xreloctab[y];
- y_i = dd->yreloctab[dd->height - 1 - x];
- break;
-
- case 3: /* 270 degrees */
- x_i = dd->xreloctab[dd->width - 1 - y];
- y_i = dd->yreloctab[x];
- break;
- }
-
- /* set the bit in the buffer */
-
- switch(data->mode) {
- case AC_MD_ROW:
- w_b = dd->width / 8;
- x_b = x_i / 8;
- pos = y_i * w_b + x_b;
-
- value_orig = dd->scrbuf[pos];
- mask = 0x80 >> (x_i % 8);
- break;
-
- case AC_MD_COL:
- y_b = y_i / 8;
- pos = y_b * dd->width + x_i;
-
- value_orig = dd->scrbuf[pos];
- mask = 0x80 >> (y_i % 8);
- break;
-
- default:
- return;
- }
-
- value = (colour) ? (value_orig | mask) : (value_orig & (0xFF ^ mask));
-
- /* update the change buffer */
-
- if(value_orig != value) {
- dd->scrbuf[pos] = value;
- dd->scrbuf_chg[pos/8] |= 0x80 >> (pos % 8);
- }
-}
-
-/* *********************************
- int serdisp_alphacool_getpixel(dd, x, y)
- *********************************
- changes a pixel in the display buffer. supported depths: 1
- *********************************
- dd ... display descriptor
- x ... x-position
- y ... y-position
- *********************************
- returns the grey value (or hw dependend index) at (x/y)
-*/
-long serdisp_alphacool_getpixel(serdisp_t *dd, int x, int y) {
- serdisp_alphacool_data_t* data = 0;
-
- unsigned int x_i = 0, y_i = 0, w_b = 0, x_b = 0, y_b = 0, pos = 0;
- byte value = 0, mask = 0;
-
- if(check(dd == 0)) { return 0; }
-
- data = (serdisp_alphacool_data_t *)(dd->specific_data);
-
- if(check(data == 0)) { return 0; }
-
- if(dd->curr_rotate <= 1) {
- if(x >= dd->width || y >= dd->height || x < 0 || y < 0) {
- return 0;
- }
- } else {
- if(x >= dd->height || y >= dd->width || x < 0 || y < 0) {
- return 0;
- }
- }
-
- switch(dd->curr_rotate) {
- case 0: /* 0 degrees */
- x_i = dd->xreloctab[x];
- y_i = dd->yreloctab[y];
- break;
-
- case 1: /* 180 degrees */
- x_i = dd->xreloctab[dd->width - 1 - x];
- y_i = dd->yreloctab[dd->height - 1 - y];
- break;
-
- case 2: /* 90 degrees */
- x_i = dd->xreloctab[y];
- y_i = dd->yreloctab[dd->height - 1 - x];
- break;
-
- case 3: /* 270 degrees */
- x_i = dd->xreloctab[dd->width - 1 - y];
- y_i = dd->yreloctab[x];
- break;
- }
-
- /* get the corresponding bit from the buffer */
-
- switch(data->mode) {
- case AC_MD_ROW:
- w_b = dd->width / 8;
- x_b = x_i / 8;
- pos = y_i * w_b + x_b;
-
- value = dd->scrbuf[pos];
- mask = 0x80 >> (x_i % 8);
- break;
-
- case AC_MD_COL:
- y_b = y_i / 8;
- pos = y_b * dd->width + x_i;
-
- value = dd->scrbuf[pos];
- mask = 0x80 >> (y_i % 8);
- break;
-
- default:
- return 0;
- }
-
- return ((value & mask) ? 1 : 0);
-}
-
-/* *********************************
- int serdisp_alphacool_runtime_check(condition, function)
- *********************************
- check condition and sets global runtime error if appropriate
- *********************************
- condition ... evals to 'true' if there's an error
- function ... runtime function name (defined by check macro)
- file ... runtime file name (defined by check macro)
- line ... runtime line number (defined by check macro)
- *********************************
- returns the condition
-*/
-int serdisp_alphacool_runtime_check(int condition, const char *function, const char *file, const int line) {
- if(condition) {
- sd_runtimeerror = 1;
- sd_error(SERDISP_ERUNTIME, "%s(): runtime error detected (%s, line %d)", function, file, line);
- }
-
- return(condition);
-}
-
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/AUTHORS
^
|
@@ -12,6 +12,9 @@
Frank 'fen' Enderle <fen_-AT-_init-6_-DOT-_org>
* alphacool support
+jopka_-AT-_kvidex_-DOT-_ru
+* 4DOLED-282815: contribution + additional tests
+
Annotation:
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/HISTORY
^
|
@@ -1,6 +1,75 @@
library 'serdisplib' Revision History
-------------------------------------
+2010-02-21: v 1.97.9 (= SVN r286)
+- enhancements / bug-removal / changes
+ * testserdisp.c:
+ -> w/h info in test-pattern 'test' may now display up to 4 digits
+ -> new test patterns for displaying gradients:
+ 'gradient': display four gradient bars (black to white / red / green / blue)
+ 'gradient R', 'gradient G', 'gradient B': red/green/blue gradient
+ 'gradient r', 'gradient g', 'gradient b': ditto, but different algorithm
+ * new options:
+ -> DSPAREAWIDTH, DSPAREAHEIGHT (both optional): user definable display area dimension
+ (used for calculating aspect ratio)
+ -> BRIGHTNESS (values: 0 (dark) to 100 (full brightness))
+ (for all displays/modules with support for 'CONTRAST')
+ * output device:
+ -> usb: additionally accept textual device names like "FTDI/DLP2232M" (additionally to "0x403/0x6010")
+ -> usb: support for protocol differentiation (e.g.: USB@SPI) added.
+ (better differentiation between 'connection types' and 'protocols' in code and messages,
+ removed 'USBSPI' as connection type ('USB@SPI' now to be used instead))
+ * serdisp_control.c:
+ -> additionally accept hexadecimal values for options (if starting with 0x or 0X)
+ -> support added for additional (optional) field 'mid_contrast':
+ (to be able to use a power function based calculation of the contrast values)
+ * serdisp_colour.c / serdisp_tools.c / serdisp_control.c:
+ -> added functions, support, and enhancements for colour depths 18 (RGB666), 24, and 32
+ -> bugfix for macro SD_CS_ISGREY()
+ * serdisp_tools.c:
+ -> support for calculating bounding boxes added (sdtools_calc_bbox())
+ -> support for simple libm-independend replacements for log(), exp(), and pow()
+
+- enhancements to ./configure and Makefiles
+ * new option --enable-libSDL: enable driver 'directgfx' / SDL-output
+ * cleaner linking (only link shared objects that are really required)
+ * removed many bumps that caused problems with opensolaris and freebsd/pcbsd
+ * many cleanups
+
+- display driver bug-removal and enhancements
+ * alphacool:
+ -> usb initialisation problem (every 2nd start no output) solved
+ (but a minor problem where de-initialisation may last some seconds remains)
+ * n6100/s1d15g10:
+ -> initialisation/resetting of scrolling commands added
+ * l4m132c: added support for
+ -> depth=1 (faster output)
+ -> setting of fore/background colours (when using depth=1)
+ -> resolution mode 128x64 (spare pixels are then used for visual IR signal confirmation)
+ -> setting of alarm time (only if supported by firmware of module)
+
+- new displays/controllers:
+ * USB13700-module support
+ * new driver 'directgfx' with support for SDL-output
+ * LC7981-based displays (so far: DG-16080 series)
+ * BL160128A added to ssdoled.c: Bolymin BL160128A colour OLED, 160x128, 18bit
+ * 4DOLED282815 added to ssdoled.c: 4DOLED-282815 colour OLED, 128x128, 18bit
+
+- new tools
+ * l4m132c_tool (standalone tool for l4m132c modules):
+ -> change bootlogo
+ -> set alarm time / alarm days
+ -> set module time
+ -> change contrast/brightness
+ * sdcmegtron_tool (standalone tool for sdcmegtron modules):
+ -> change bootlogo
+ -> save screenshot
+ -> change brightness
+
+- many cleanups and small bugfixes (eg: enforcing/fixing scope visibility limits)
+ * see SVN revision log for detailed information
+
+
2008-07-31: v1.97.8
- enhancements / bug-removal / changes
* testserdisp.c: changed starting point of moving box in pattern #6
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/Makefile.in
^
|
@@ -1,5 +1,5 @@
# Makefile for project 'serdisplib', root-directory
-# (C) 2003-2008 by Wolfgang Astleitner
+# (C) 2003-2010 by Wolfgang Astleitner
SHELL = /bin/sh
@@ -59,7 +59,7 @@
# make snapshot is meant for internal use only
snapshot: distclean
cd $(top_srcdir)/.. && \
- /bin/gtar c --exclude "*~" --exclude ".svn" --exclude "temp" --exclude "*_bkp*" $(base_abs_top_srcdir) | /bin/gzip -c > $(base_abs_top_srcdir)_$(current_timestamp).tar.gz
+ /bin/gtar c --exclude "*~" --exclude ".svn" --exclude "temp" --exclude "*_bkp*" --exclude "*.o" $(base_abs_top_srcdir) | /bin/gzip -c > $(base_abs_top_srcdir)_$(current_timestamp).tar.gz
# automatic re-running of configure if the configure.in file has changed
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/README
^
|
@@ -5,6 +5,7 @@
Project's homepage: http://serdisplib.soureforge.net
Latest version available: http://sourceforge.net/projects/serdisplib/
+SVN development infos: http://sourceforge.net/apps/trac/serdisplib/
See the file COPYING for license information.
@@ -113,7 +114,8 @@
configure options:
--prefix=PREFIX install files in PREFIX default: /usr/local
- --enable-libusb include support for libusb default: no
+ --enable-libusb include support for libusb default: disabled
+ --enable-libSDL include support for libSDL default: disabled
examples: ./configure --enable-libusb ... include support for libusb (if libusb then can be found by configure)
./configure --prefix=/usr ... use /usr instead of /usr/local as base installation dir
@@ -126,6 +128,9 @@
* libusb-support is disabled by default
to include support for libusb, include option --enable-libusb when running ./configure
+* libSDL-support (for directgfx-output via SDL) is disabled by default
+ to include support for libSDL, include option --enable-libSDL when running ./configure
+
* multidisplay requires libgd. if libgd is not installed, ./configure will not include multidisplay
* GIF-support is included in recent versions of libgd only!
@@ -136,6 +141,9 @@
if not so, adapt 'configure.in' and run 'autoconf'
if multidisplay should be built, 'libgd' needs to be installed from the compagnion disc.
+* opensolaris:
+ install package 'SUNWsfwhea' to be able to compile with libusb-support
+ (if using package manager: search for: 'sfwhea')
DISPLAY NAME STRINGS SUPPORTED (case insensitive)
@@ -161,6 +169,7 @@
T6963SERMOD T6963-based display module with built-in parallel to serial converter
SED133X SED1330,SED1335 generic driver for SED1330/SED1335-based displays
S1D13700 generic driver for S1D13700-based displays
+USB13700 displays driven by USB13700 USB module
N3510I N3530 driver for Nokia 3510i/3530 displays (S1D15G14-based)
S1D15G10 N6100 driver for Nokia 6100 and compliant displays (S1D15G10-based)
KS0108 generic driver for KS0108-based displays
@@ -170,11 +179,17 @@
OLED96X36X1 Pictiva 96X36 OLED 1bit
OLED96X64X16 Pictiva 96X64 colour OLED 16bit
OLED128X64X4 Pictiva 128X64 yellow OLED 4bit
+BL160128A Bolymin BL160128A colour OLED 18bit
+4DOLED282815 4DOLED128 4DOLED-282815 colour OLED 18bit
L4ME5I linux4media USB-interface E-5i-USB
L4M132C linux4media USB-interface w/ 132x65 colour display
GOLDELOX UOLED160,UOLED128 displays driven by GOLDELOX-MD1 module
STV8105 OLED256X64X4 Pictiva 256X64 yellow OLED 4bit
ALPHACOOL Alphacool USB-displays 200x64 or 240x128
+SDCMEGTRON SDC-Megtron USB-displays 240x128
+SDL direct output to SDL window
+DG16080 DG-16080 160x80
+DG1608011 DG-16080-11 160x80 (non-square pixels)
@@ -285,6 +300,10 @@
CONTRIBUTORS (alphabetically sorted)
------------
+
+contributors of additional display support can be found in 'AUTHORS'.
+
+testing / bug reports:
* Daniel Badberg ... testing, bug reports
* Reuben Bond ... testing, bug reports, chardisp (generate text using serdisplib. superseded by multidisplay)
* Alan Carvalho ... bug report in makefile
@@ -295,9 +314,8 @@
* Andreas Fierlinger
* Michael Fuereder
-contributors of additional display support can be found in 'AUTHORS'.
-this list is not up-to-date and will be reworked/extended in a later release of serdisplib.
+this list may not be up-to-date and will be reworked/extended in a later release of serdisplib.
Have fun!
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/buildfiles/serdisplib_1.97.9.bb
^
|
@@ -0,0 +1,56 @@
+DESCRIPTION = "library to drive LC-displays"
+SECTION = "libs"
+DEPENDS += "libusb"
+LICENSE = "GPL"
+PRIORITY = "optional"
+MAINTAINER ="maf; Wolfgang Astleitner <mrwastl@users.sf.net>"
+DEFAULT_PREFERENCE = "1"
+
+PREMIRRORS_prepend () {
+ ${SOURCEFORGE_MIRROR} http://mesh.dl.sourceforge.net/sourceforge
+}
+SRC_URI = "${SOURCEFORGE_MIRROR}/serdisplib/serdisplib-${PV}.tar.gz"
+
+S = "${WORKDIR}/serdisplib-${PV}"
+
+inherit autotools
+
+HEADER_FILES = serdisp.h serdisp_control.h serdisp_connect.h serdisp_messages.h \
+ serdisp_colour.h serdisp_tools.h serdisp_parport.h
+
+EXTRA_OECONF = "--enable-libusb"
+
+do_stage() {
+ oe_libinstall -a -so lib/libserdisp ${STAGING_LIBDIR}
+
+ install -d ${STAGING_BINDIR}
+ install -m 755 src/testserdisp ${STAGING_BINDIR}
+ if test -e tools/multidisplay; then
+ install -m 755 tools/multidisplay ${STAGING_BINDIR}
+ fi
+
+ install -d ${STAGING_INCDIR}/serdisplib
+ for X in ${HEADER_FILES}
+ do
+ install -m 0644 include/serdisplib/$X ${STAGING_INCDIR}/serdisplib/$X
+ done
+}
+
+
+do_install () {
+ oe_libinstall -a -so lib/libserdisp ${D}${libdir}
+
+ install -d ${D}${bindir}
+ install -m 755 src/testserdisp ${D}${bindir}
+ if test -e tools/multidisplay; then
+ install -m 755 tools/multidisplay ${D}${bindir}
+ fi
+
+ install -d ${D}${includedir}/serdisplib
+
+ for X in ${HEADER_FILES}
+ do
+ install -m 0644 include/serdisplib/$X ${D}${includedir}/serdisplib/$X
+ done
+}
+
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/config.h.in
^
|
@@ -3,6 +3,9 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
+/* Define to 1 if you have the <gd2/gd.h> header file. */
+#undef HAVE_GD2_GD_H
+
/* Define to 1 if you have the `gdImageCreateFromGif' function. */
#undef HAVE_GDIMAGECREATEFROMGIF
@@ -24,7 +27,12 @@
/* Define to 1 if you have the `gd' library (-lgd). */
#undef HAVE_LIBGD
-/* Define to 1 if you have the `usb' library (-lusb). */
+/* whether libSDL is available and usable (header files and, if no dynamic
+ linking, library files available) */
+#undef HAVE_LIBSDL
+
+/* whether libusb is available and usable (header files and library files
+ available) */
#undef HAVE_LIBUSB
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
@@ -37,6 +45,15 @@
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
+/* Define to 1 if you have the <SDL.h> header file. */
+#undef HAVE_SDL_H
+
+/* Define to 1 if you have the <SDL/SDL.h> header file. */
+#undef HAVE_SDL_SDL_H
+
+/* Define to 1 if you have the `SDL_SetVideoMode' function. */
+#undef HAVE_SDL_SETVIDEOMODE
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@@ -97,6 +114,9 @@
/* Define to 1 if you have the `usb_get_string_simple' function. */
#undef HAVE_USB_GET_STRING_SIMPLE
+/* Define to 1 if you have the <usb.h> header file. */
+#undef HAVE_USB_H
+
/* Define to 1 if you have the </opt/sfw/include/gd.h> header file. */
#undef HAVE__OPT_SFW_INCLUDE_GD_H
@@ -124,8 +144,11 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
-/* driver support for alphacool */
-#undef WITH_DRIVER_ALPHACOOL
+/* driver support for acoolsdcm */
+#undef WITH_DRIVER_ACOOLSDCM
+
+/* driver support for directgfx */
+#undef WITH_DRIVER_DIRECTGFX
/* driver support for goldelox */
#undef WITH_DRIVER_GOLDELOX
@@ -139,6 +162,9 @@
/* driver support for l4m */
#undef WITH_DRIVER_L4M
+/* driver support for lc7981 */
+#undef WITH_DRIVER_LC7981
+
/* driver support for lh155 */
#undef WITH_DRIVER_LH155
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/configure
^
|
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for serdisplib 1.97.8.
+# Generated by GNU Autoconf 2.59 for serdisplib 1.97.
#
# Report bugs to <mrwastl@users.sf.net>.
#
@@ -269,8 +269,8 @@
# Identity of this package.
PACKAGE_NAME='serdisplib'
PACKAGE_TARNAME='serdisplib'
-PACKAGE_VERSION='1.97.8'
-PACKAGE_STRING='serdisplib 1.97.8'
+PACKAGE_VERSION='1.97'
+PACKAGE_STRING='serdisplib 1.97'
PACKAGE_BUGREPORT='mrwastl@users.sf.net'
# Factoring default headers for most tests.
@@ -310,7 +310,7 @@
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S AR ac_ct_AR MAKE ac_ct_MAKE SET_MAKE PACKAGE_VERSION_MAJOR PACKAGE_VERSION_MINOR PACKAGE_VERSION_SUBMINOR use_sharedlib CPP EGREP has_libgd_headers has_libgd_opt_sfw_headers has_libgd_lib LIBUSB_CONFIG LIBUSB_LIBS LIBUSB_CFLAGS has_libusb has_libusb_detach_kdriver use_soname WITH_DRIVER_SED153X WITH_DRIVER_PCD8544 WITH_DRIVER_SED156X WITH_DRIVER_I2C WITH_DRIVER_T6963 WITH_DRIVER_SED133X WITH_DRIVER_NOKCOL WITH_DRIVER_KS0108 WITH_DRIVER_LH155 WITH_DRIVER_SSDOLED WITH_DRIVER_L4M WITH_DRIVER_GOLDELOX WITH_DRIVER_STV8105 WITH_DRIVER_ALPHACOOL LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S AR ac_ct_AR MAKE ac_ct_MAKE SET_MAKE PACKAGE_VERSION_MAJOR PACKAGE_VERSION_MINOR PACKAGE_VERSION_SUBMINOR use_sharedlib CPP EGREP has_libgd_headers has_libgd_opt_sfw_headers has_libgd_lib LIBUSB_CONFIG has_libusb has_libusb_detach_kdriver HAVE_LIBUSB LIBSDL_CONFIG has_libSDL HAVE_LIBSDL use_soname WITH_DRIVER_SED153X WITH_DRIVER_PCD8544 WITH_DRIVER_SED156X WITH_DRIVER_I2C WITH_DRIVER_T6963 WITH_DRIVER_SED133X WITH_DRIVER_NOKCOL WITH_DRIVER_KS0108 WITH_DRIVER_LH155 WITH_DRIVER_SSDOLED WITH_DRIVER_L4M WITH_DRIVER_GOLDELOX WITH_DRIVER_STV8105 WITH_DRIVER_ACOOLSDCM WITH_DRIVER_DIRECTGFX WITH_DRIVER_LC7981 LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -779,7 +779,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures serdisplib 1.97.8 to adapt to many kinds of systems.
+\`configure' configures serdisplib 1.97 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -841,7 +841,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of serdisplib 1.97.8:";;
+ short | recursive ) echo "Configuration of serdisplib 1.97:";;
esac
cat <<\_ACEOF
@@ -850,7 +850,11 @@
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-statictools link tools (eg. testserdisp) to static version of
serdisplib (default is yes)
- --enable-libusb enable support for libusb (default is no)
+ --enable-libusb enable support for libusb, required by driver
+ 'acoolsdcm' and USB-based output devices (default is
+ no)
+ --enable-libSDL enable support for libSDL, required by driver
+ 'directgfx' (default is no)
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -865,7 +869,7 @@
possible drivers are:
sed153x, pcd8544, sed156x, i2c, t6963, sed133x,
nokcol, ks0108, lh155, ssdoled, l4m, goldelox, stv8105,
- alphacool
+ acoolsdcm, directgfx, lc7981
Some influential environment variables:
CC C compiler command
@@ -975,7 +979,7 @@
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-serdisplib configure 1.97.8
+serdisplib configure 1.97
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -989,7 +993,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by serdisplib $as_me 1.97.8, which was
+It was created by serdisplib $as_me 1.97, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1325,6 +1329,10 @@
+# set subminor-version here
+# (formerly used sub-splitting caused too many problems with some configurations (solaris, bsd))
+PACKAGE_VERSION_SUBMINOR="9"
+
#AC_CONFIG_SRCDIR([src/serdisp_control.c])
ac_config_headers="$ac_config_headers config.h"
@@ -2662,21 +2670,20 @@
# split version information
-PACKAGE_VERSION_TEMP=${PACKAGE_VERSION/\./\ }
-PACKAGE_VERSION_MAJOR=${PACKAGE_VERSION_TEMP/\ *}
-PACKAGE_VERSION_MINTEMP=${PACKAGE_VERSION_TEMP/*\ }
-if test "${PACKAGE_VERSION_TEMP/*\.*/\.}" = "\."; then
- PACKAGE_VERSION_MINOR=${PACKAGE_VERSION_MINTEMP/\.*}
- PACKAGE_VERSION_SUBMINOR=${PACKAGE_VERSION_MINTEMP/*\.}
-else
- PACKAGE_VERSION_MINOR=$PACKAGE_VERSION_MINTEMP
- PACKAGE_VERSION_SUBMINOR=""
+PACKAGE_VERSION_MAJOR=`echo "${PACKAGE_VERSION}" | sed 's/\..*//'`
+PACKAGE_VERSION_MINOR=`echo "${PACKAGE_VERSION}" | sed 's/^.*\.//'`
+
+# rebuild full PACKAGE_VERSION here
+if test -n "${PACKAGE_VERSION_SUBMINOR}" ; then
+ PACKAGE_VERSION="${PACKAGE_VERSION}.${PACKAGE_VERSION_SUBMINOR}"
fi
+
+
# configure options
@@ -2700,6 +2707,13 @@
else
enable_libusb=no
fi;
+# Check whether --enable-libSDL or --disable-libSDL was given.
+if test "${enable_libSDL+set}" = set; then
+ enableval="$enable_libSDL"
+
+else
+ enable_libSDL=no
+fi;
# link testserdisp, multidisplay using either the static or shared version of serdisplib
@@ -2712,7 +2726,6 @@
fi
-
# Checks for libraries.
ac_ext=c
@@ -3207,7 +3220,8 @@
-for ac_header in gd/gd.h gd.h /opt/sfw/include/gd.h /usr/local/include/gd.h
+
+for ac_header in gd/gd.h gd.h /opt/sfw/include/gd.h /usr/local/include/gd.h gd2/gd.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -3797,10 +3811,14 @@
done
-# libusb
-if ! test "$enable_libusb" = "no"; then
+# store current content of LIBS
+TEMP_LIBS="${LIBS}"
- # Extract the first word of "libusb-config", so it can be a program name with args.
+# check for libusb header and library
+# defines the following in config.h:
+# HAVE_USB_H
+# HAVE_LIBUSB
+# Extract the first word of "libusb-config", so it can be a program name with args.
set dummy libusb-config; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
@@ -3840,18 +3858,176 @@
fi
- if test ! -z "${LIBUSB_CONFIG}"; then
+has_libusb="false" # pre-init
+if test ! -z "${LIBUSB_CONFIG}"; then
+ LIBUSB_CFLAGS=`${LIBUSB_CONFIG} --cflags`
+ CFLAGS="${CFLAGS} ${LIBUSB_CFLAGS}"
+
+ #defines HAVE_USB_H if available
+
+for ac_header in usb.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ----------------------------------- ##
+## Report this to mrwastl@users.sf.net ##
+## ----------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ has_libusb_headers="true";break
+else
+ has_libusb_headers="false"
+fi
+
+done
+
+
+ if test "$has_libusb_headers" = "true"; then
+
LIBUSB_LIBS=`${LIBUSB_CONFIG} --libs`
- LIBUSB_CFLAGS=`${LIBUSB_CONFIG} --cflags`
- # we don't want all collected libs for all programs but we need to extend LDFLAGS for usb-detection
- # so LDFLAGS will be restored after usb-detection
+ # save current LDFLAGS (to be restored after usb-detection)
TEMP_LDFLAGS="${LDFLAGS}"
+
LDFLAGS="${LDFLAGS} ${LIBUSB_LIBS}"
- CFLAGS="${CFLAGS} ${LIBUSB_CFLAGS}"
+ if test "$enable_libusb" != "no"; then
- # if usb_get_string_simple() unavailable -> libusb too old (<= 0.1.7)
echo "$as_me:$LINENO: checking for usb_get_string_simple in -lusb" >&5
echo $ECHO_N "checking for usb_get_string_simple in -lusb... $ECHO_C" >&6
@@ -3898,90 +4074,516 @@
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_usb_usb_get_string_simple=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_usb_usb_get_string_simple=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_usb_usb_get_string_simple" >&5
+echo "${ECHO_T}$ac_cv_lib_usb_usb_get_string_simple" >&6
+if test $ac_cv_lib_usb_usb_get_string_simple = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBUSB 1
+_ACEOF
+
+ LIBS="-lusb $LIBS"
+
+fi
+
+ # if usb_get_string_simple() unavailable -> libusb too old (<= 0.1.7)
+
+for ac_func in usb_get_string_simple
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+ has_libusb="true";break
+else
+ has_libusb="false"
+fi
+done
+
+
+for ac_func in usb_detach_kernel_driver_np
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+ has_libusb_detach_kdriver="true";break
+else
+ has_libusb_detach_kdriver="false"
+fi
+done
+
+
+ # restore LDFLAGS
+ LDFLAGS="${TEMP_LDFLAGS}"
+
+ if test "$has_libusb" = "true"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LIBUSB 1
+_ACEOF
+
+ if test -z "$LIBUSB_LIBS"; then
+ has_libusb="false"
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LIBSDL 0
+_ACEOF
+
+ else
+ LDFLAGS="${LDFLAGS} ${LIBUSB_LIBS}"
+ fi
+ fi
+ fi
+ fi
+fi
+
+
+
+
+
+# libsdl
+# check for libSDL header and library
+# defines the following in config.h:
+# one of
+# HAVE_SDL_H
+# HAVE_SDL_SDL_H
+# HAVE_LIBSDL
+# Extract the first word of "sdl-config", so it can be a program name with args.
+set dummy sdl-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_LIBSDL_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $LIBSDL_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_LIBSDL_CONFIG="$LIBSDL_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_LIBSDL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ ;;
+esac
+fi
+LIBSDL_CONFIG=$ac_cv_path_LIBSDL_CONFIG
+
+if test -n "$LIBSDL_CONFIG"; then
+ echo "$as_me:$LINENO: result: $LIBSDL_CONFIG" >&5
+echo "${ECHO_T}$LIBSDL_CONFIG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+has_libSDL="false" # pre-init
+if test ! -z "${LIBSDL_CONFIG}"; then
+ LIBSDL_CFLAGS=`${LIBSDL_CONFIG} --cflags`
+ CFLAGS="${CFLAGS} ${LIBSDL_CFLAGS}"
+
+ #defines either HAVE_SDL_SDL_H or HAVE_SDL_H
+
+
+for ac_header in SDL/SDL.h SDL.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_cv_lib_usb_usb_get_string_simple=yes
+ ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-ac_cv_lib_usb_usb_get_string_simple=no
+ac_header_compiler=no
fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_usb_usb_get_string_simple" >&5
-echo "${ECHO_T}$ac_cv_lib_usb_usb_get_string_simple" >&6
-if test $ac_cv_lib_usb_usb_get_string_simple = yes; then
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ----------------------------------- ##
+## Report this to mrwastl@users.sf.net ##
+## ----------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBUSB 1
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
+ has_libSDL_headers="true";break
+else
+ has_libSDL_headers="false"
+fi
- LIBS="-lusb $LIBS"
+done
-fi
+ if test "$has_libSDL_headers" = "true"; then
+ if ! test "$enable_libSDL" = "no"; then
+ LIBSDL_LIBS=`${LIBSDL_CONFIG} --libs`
-for ac_func in usb_get_string_simple
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
+ # we don't want configure to auto-add libsdl because it will not be linked but included using libdl / dlopen() instead
+ # so LDFLAGS will be restored after libsdl-detection
+ TEMP_LDFLAGS="${LDFLAGS}"
+
+ LDFLAGS="${LDFLAGS} ${LIBSDL_LIBS}"
+
+ #
+
+echo "$as_me:$LINENO: checking for SDL_SetVideoMode in -lSDL" >&5
+echo $ECHO_N "checking for SDL_SetVideoMode in -lSDL... $ECHO_C" >&6
+if test "${ac_cv_lib_SDL_SDL_SetVideoMode+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- cat >conftest.$ac_ext <<_ACEOF
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lSDL $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
-{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
+char SDL_SetVideoMode ();
int
main ()
{
-return f != $ac_func;
+SDL_SetVideoMode ();
;
return 0;
}
@@ -4008,30 +4610,30 @@
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- eval "$as_ac_var=yes"
+ ac_cv_lib_SDL_SDL_SetVideoMode=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+ac_cv_lib_SDL_SDL_SetVideoMode=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
+echo "$as_me:$LINENO: result: $ac_cv_lib_SDL_SDL_SetVideoMode" >&5
+echo "${ECHO_T}$ac_cv_lib_SDL_SDL_SetVideoMode" >&6
+if test $ac_cv_lib_SDL_SDL_SetVideoMode = yes; then
cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+#define HAVE_LIBSDL 1
_ACEOF
- has_libusb="true";break
-else
- has_libusb="false"
+
+ LIBS="-lSDL $LIBS"
+
fi
-done
-for ac_func in usb_detach_kernel_driver_np
+for ac_func in SDL_SetVideoMode
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -4128,26 +4730,43 @@
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
- has_libusb_detach_kdriver="true";break
+ has_libSDL="true";break
else
- has_libusb_detach_kdriver="false"
+ has_libSDL="false"
fi
done
+ # restore LDFLAGS
+ LDFLAGS="${TEMP_LDFLAGS}"
+ if test "$has_libSDL" = "true"; then
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LIBSDL 1
+_ACEOF
+ #CFLAGS="${CFLAGS} ${LIBSDL_CFLAGS}"
+ if test -z "$LIBSDL_LIBS"; then
+ has_libSDL="false"
- # restore LDFLAGS
- LDFLAGS="${TEMP_LDFLAGS}"
-
- else
- has_libusb="false"
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LIBSDL 0
+_ACEOF
+ else
+ LDFLAGS="${LDFLAGS} ${LIBSDL_LIBS}"
+ fi
+ fi
+ fi
fi
fi
+
+
+# restore LIBS
+LIBS="${TEMP_LIBS}"
+
# ugly hack for determination whether to build w/ or w/o soname, will be enhanced later
# for now: soname only together with linux
case $build in
@@ -4586,46 +5205,119 @@
fi
;;
- alphacool)
+ acoolsdcm|alphacool)
if test "${val}" = "yes" ; then
if test "$has_libusb" = "true" ; then
cat >>confdefs.h <<\_ACEOF
-#define WITH_DRIVER_ALPHACOOL 1
+#define WITH_DRIVER_ACOOLSDCM 1
+_ACEOF
+
+ if test "1" = "1"; then
+ WITH_DRIVER_ACOOLSDCM=true
+ enabled_drivers="${enabled_drivers}, acoolsdcm"
+ else
+ WITH_DRIVER_ACOOLSDCM=false
+ fi
+
+ else
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_DRIVER_ACOOLSDCM 0
+_ACEOF
+
+ if test "0" = "1"; then
+ WITH_DRIVER_ACOOLSDCM=true
+ enabled_drivers="${enabled_drivers}, acoolsdcm"
+ else
+ WITH_DRIVER_ACOOLSDCM=false
+ fi
+
+ fi
+ else
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_DRIVER_ACOOLSDCM 0
+_ACEOF
+
+ if test "0" = "1"; then
+ WITH_DRIVER_ACOOLSDCM=true
+ enabled_drivers="${enabled_drivers}, acoolsdcm"
+ else
+ WITH_DRIVER_ACOOLSDCM=false
+ fi
+
+ fi
+ ;;
+ directgfx)
+ if test "${val}" = "yes" ; then
+ if test "$has_libSDL" = "true" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_DRIVER_DIRECTGFX 1
_ACEOF
if test "1" = "1"; then
- WITH_DRIVER_ALPHACOOL=true
- enabled_drivers="${enabled_drivers}, alphacool"
+ WITH_DRIVER_DIRECTGFX=true
+ enabled_drivers="${enabled_drivers}, directgfx"
else
- WITH_DRIVER_ALPHACOOL=false
+ WITH_DRIVER_DIRECTGFX=false
fi
else
cat >>confdefs.h <<\_ACEOF
-#define WITH_DRIVER_ALPHACOOL 0
+#define WITH_DRIVER_DIRECTGFX 0
_ACEOF
if test "0" = "1"; then
- WITH_DRIVER_ALPHACOOL=true
- enabled_drivers="${enabled_drivers}, alphacool"
+ WITH_DRIVER_DIRECTGFX=true
+ enabled_drivers="${enabled_drivers}, directgfx"
else
- WITH_DRIVER_ALPHACOOL=false
+ WITH_DRIVER_DIRECTGFX=false
fi
fi
else
cat >>confdefs.h <<\_ACEOF
-#define WITH_DRIVER_ALPHACOOL 0
+#define WITH_DRIVER_DIRECTGFX 0
+_ACEOF
+
+ if test "0" = "1"; then
+ WITH_DRIVER_DIRECTGFX=true
+ enabled_drivers="${enabled_drivers}, directgfx"
+ else
+ WITH_DRIVER_DIRECTGFX=false
+ fi
+
+ fi
+ ;;
+ lc7981)
+ if test "${val}" = "yes" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_DRIVER_LC7981 1
+_ACEOF
+
+ if test "1" = "1"; then
+ WITH_DRIVER_LC7981=true
+ enabled_drivers="${enabled_drivers}, lc7981"
+ else
+ WITH_DRIVER_LC7981=false
+ fi
+
+ else
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_DRIVER_LC7981 0
_ACEOF
if test "0" = "1"; then
- WITH_DRIVER_ALPHACOOL=true
- enabled_drivers="${enabled_drivers}, alphacool"
+ WITH_DRIVER_LC7981=true
+ enabled_drivers="${enabled_drivers}, lc7981"
else
- WITH_DRIVER_ALPHACOOL=false
+ WITH_DRIVER_LC7981=false
fi
fi
@@ -4824,22 +5516,52 @@
fi
fi
- if test -z "${WITH_DRIVER_ALPHACOOL}" ; then
+ if test -z "${WITH_DRIVER_ACOOLSDCM}" ; then
if test "$has_libusb" = "true" ; then
cat >>confdefs.h <<\_ACEOF
-#define WITH_DRIVER_ALPHACOOL 1
+#define WITH_DRIVER_ACOOLSDCM 1
+_ACEOF
+
+ if test "1" = "1"; then
+ WITH_DRIVER_ACOOLSDCM=true
+ enabled_drivers="${enabled_drivers}, acoolsdcm"
+ else
+ WITH_DRIVER_ACOOLSDCM=false
+ fi
+
+ fi
+ fi
+ if test -z "${WITH_DRIVER_DIRECTGFX}" ; then
+ if test "$has_libSDL" = "true" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_DRIVER_DIRECTGFX 1
_ACEOF
if test "1" = "1"; then
- WITH_DRIVER_ALPHACOOL=true
- enabled_drivers="${enabled_drivers}, alphacool"
+ WITH_DRIVER_DIRECTGFX=true
+ enabled_drivers="${enabled_drivers}, directgfx"
else
- WITH_DRIVER_ALPHACOOL=false
+ WITH_DRIVER_DIRECTGFX=false
fi
fi
fi
+ if test -z "${WITH_DRIVER_LC7981}" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_DRIVER_LC7981 1
+_ACEOF
+
+ if test "1" = "1"; then
+ WITH_DRIVER_LC7981=true
+ enabled_drivers="${enabled_drivers}, lc7981"
+ else
+ WITH_DRIVER_LC7981=false
+ fi
+
+ fi
fi
@@ -6241,7 +6963,7 @@
} >&5
cat >&5 <<_CSEOF
-This file was extended by serdisplib $as_me 1.97.8, which was
+This file was extended by serdisplib $as_me 1.97, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6304,7 +7026,7 @@
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-serdisplib config.status 1.97.8
+serdisplib config.status 1.97
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@@ -6537,10 +7259,12 @@
s,@has_libgd_opt_sfw_headers@,$has_libgd_opt_sfw_headers,;t t
s,@has_libgd_lib@,$has_libgd_lib,;t t
s,@LIBUSB_CONFIG@,$LIBUSB_CONFIG,;t t
-s,@LIBUSB_LIBS@,$LIBUSB_LIBS,;t t
-s,@LIBUSB_CFLAGS@,$LIBUSB_CFLAGS,;t t
s,@has_libusb@,$has_libusb,;t t
s,@has_libusb_detach_kdriver@,$has_libusb_detach_kdriver,;t t
+s,@HAVE_LIBUSB@,$HAVE_LIBUSB,;t t
+s,@LIBSDL_CONFIG@,$LIBSDL_CONFIG,;t t
+s,@has_libSDL@,$has_libSDL,;t t
+s,@HAVE_LIBSDL@,$HAVE_LIBSDL,;t t
s,@use_soname@,$use_soname,;t t
s,@WITH_DRIVER_SED153X@,$WITH_DRIVER_SED153X,;t t
s,@WITH_DRIVER_PCD8544@,$WITH_DRIVER_PCD8544,;t t
@@ -6555,7 +7279,9 @@
s,@WITH_DRIVER_L4M@,$WITH_DRIVER_L4M,;t t
s,@WITH_DRIVER_GOLDELOX@,$WITH_DRIVER_GOLDELOX,;t t
s,@WITH_DRIVER_STV8105@,$WITH_DRIVER_STV8105,;t t
-s,@WITH_DRIVER_ALPHACOOL@,$WITH_DRIVER_ALPHACOOL,;t t
+s,@WITH_DRIVER_ACOOLSDCM@,$WITH_DRIVER_ACOOLSDCM,;t t
+s,@WITH_DRIVER_DIRECTGFX@,$WITH_DRIVER_DIRECTGFX,;t t
+s,@WITH_DRIVER_LC7981@,$WITH_DRIVER_LC7981,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF
@@ -7183,36 +7909,42 @@
echo ""
echo ""
-echo "supported extra protocols"
+echo "supported extra libraries"
echo "========================="
if test "$has_libusb" = "true"; then
if test "$has_libusb_detach_kdriver" = "true"; then
- echo " * libusb support ... yes"
+ echo " * libusb support ... yes"
else
- echo " * libusb support ... yes, but without usb_detach_kernel_driver_np()"
+ echo " * libusb support ... yes, but without usb_detach_kernel_driver_np()"
fi
else
if test "$enable_libusb" = "no"; then
- echo " * libusb support ... disabled"
+ echo " * libusb support ... disabled"
+ elif test "$has_libusb_headers" = "false"; then
+ echo " * libusb support ... header file (usb.h) not found"
else
- echo " * libusb support ... no, or too old (at least libusb 0.1.7 is needed)"
+ echo " * libusb support ... no, or too old (at least headers for libusb 0.1.7 are needed)"
fi
fi
-echo ""
-echo ""
-echo "supported features"
-echo "=================="
+if test "$has_libSDL" = "true"; then
+ echo " * libSDL support ... yes"
+else
+ if test "$enable_libSDL" = "no"; then
+ echo " * libSDL support ... disabled"
+ else
+ echo " * libSDL support ... no (header files and/or library not found)"
+ fi
+fi
-echo ""
if test "$has_libgd_lib" = "true"; then
if test "$has_libgd_headers" = "true"; then
- echo " * libgd >= 2 support ... yes"
+ echo " * libgd >= 2 support ... yes"
else
- echo " * libgd >= 2 support ... yes, but header files are missing"
+ echo " * libgd >= 2 support ... yes, but header files are missing"
fi
else
- echo " * libgd >= 2 support ... no "
+ echo " * libgd >= 2 support ... no "
fi
@@ -7242,17 +7974,17 @@
echo "tools"
echo "====="
if test "$has_libgd_headers" = "true" -a "$has_libgd_lib" = "true"; then
- echo " * multidisplay ... yes"
+ echo " * multidisplay ... yes"
if test "$ac_cv_func_gdImageCreateFromGif" = "yes" ; then
- echo " - with GIF support ... yes"
+ echo " - with GIF support ... yes"
else
- echo " - with GIF support ... no (recent libgd needed for GIF support)"
+ echo " - with GIF support ... no (recent libgd needed for GIF support)"
fi
else
if test "$has_libgd_lib" = "false"; then
- echo " * multidisplay ... no (because of missing libgd)"
+ echo " * multidisplay ... no (because of missing libgd)"
else
- echo " * multidisplay ... no (because of missing header files for libgd)"
+ echo " * multidisplay ... no (because of missing header files for libgd)"
fi
fi
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/configure.in
^
|
@@ -2,7 +2,11 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.5)
-AC_INIT([serdisplib], [1.97.8], [mrwastl@users.sf.net])
+AC_INIT([serdisplib], [1.97], [mrwastl@users.sf.net])
+# set subminor-version here
+# (formerly used sub-splitting caused too many problems with some configurations (solaris, bsd))
+PACKAGE_VERSION_SUBMINOR="9"
+
#AC_CONFIG_SRCDIR([src/serdisp_control.c])
AC_CONFIG_HEADER([config.h])
AC_CANONICAL_SYSTEM
@@ -16,16 +20,15 @@
AC_PROG_MAKE_SET
# split version information
-PACKAGE_VERSION_TEMP=${PACKAGE_VERSION/\./\ }
-PACKAGE_VERSION_MAJOR=${PACKAGE_VERSION_TEMP/\ *}
-PACKAGE_VERSION_MINTEMP=${PACKAGE_VERSION_TEMP/*\ }
-if test "${PACKAGE_VERSION_TEMP/*\.*/\.}" = "\."; then
- PACKAGE_VERSION_MINOR=${PACKAGE_VERSION_MINTEMP/\.*}
- PACKAGE_VERSION_SUBMINOR=${PACKAGE_VERSION_MINTEMP/*\.}
-else
- PACKAGE_VERSION_MINOR=$PACKAGE_VERSION_MINTEMP
- PACKAGE_VERSION_SUBMINOR=""
+PACKAGE_VERSION_MAJOR=`echo "${PACKAGE_VERSION}" | sed 's/\..*//'`
+PACKAGE_VERSION_MINOR=`echo "${PACKAGE_VERSION}" | sed 's/^.*\.//'`
+
+# rebuild full PACKAGE_VERSION here
+if test -n "${PACKAGE_VERSION_SUBMINOR}" ; then
+ PACKAGE_VERSION="${PACKAGE_VERSION}.${PACKAGE_VERSION_SUBMINOR}"
fi
+
+AC_SUBST([PACKAGE_VERSION])
AC_SUBST([PACKAGE_VERSION_MAJOR])
AC_SUBST([PACKAGE_VERSION_MINOR])
AC_SUBST([PACKAGE_VERSION_SUBMINOR])
@@ -53,7 +56,8 @@
, [ac_cv_use_$1=$withval], [ac_cv_use_$1=$2])])
MY_ARG_ENABLE_CUSTOMHELP([statictools], yes, [link tools (eg. testserdisp) to static version of serdisplib])
-MY_ARG_ENABLE_CUSTOMHELP([libusb], no, [enable support for libusb])
+MY_ARG_ENABLE_CUSTOMHELP([libusb], no, [enable support for libusb, required by driver 'acoolsdcm' and USB-based output devices])
+MY_ARG_ENABLE_CUSTOMHELP([libSDL], no, [enable support for libSDL, required by driver 'directgfx'])
# link testserdisp, multidisplay using either the static or shared version of serdisplib
@@ -66,9 +70,8 @@
fi
AC_SUBST(use_sharedlib)
-
# Checks for libraries.
-AC_CHECK_HEADERS([gd/gd.h gd.h /opt/sfw/include/gd.h /usr/local/include/gd.h], [has_libgd_headers="true";break], [has_libgd_headers="false"])
+AC_CHECK_HEADERS([gd/gd.h gd.h /opt/sfw/include/gd.h /usr/local/include/gd.h gd2/gd.h], [has_libgd_headers="true";break], [has_libgd_headers="false"])
AC_SUBST(has_libgd_headers)
# special case sun solaris
AC_CHECK_HEADERS([/opt/sfw/include/gd.h], [has_libgd_opt_sfw_headers="true";break], [has_libgd_opt_sfw_headers="false"])
@@ -80,39 +83,111 @@
AC_SUBST(has_libgd_lib)
AC_CHECK_FUNCS([gdImageCreateFromGif])
-# libusb
-if ! test "$enable_libusb" = "no"; then
+# store current content of LIBS
+TEMP_LIBS="${LIBS}"
- AC_PATH_PROG(LIBUSB_CONFIG, libusb-config)
+# check for libusb header and library
+# defines the following in config.h:
+# HAVE_USB_H
+# HAVE_LIBUSB
+AC_PATH_PROG(LIBUSB_CONFIG, libusb-config)
+
+has_libusb="false" # pre-init
+if test ! -z "${LIBUSB_CONFIG}"; then
+ LIBUSB_CFLAGS=`${LIBUSB_CONFIG} --cflags`
+ CFLAGS="${CFLAGS} ${LIBUSB_CFLAGS}"
+
+ #defines HAVE_USB_H if available
+ AC_CHECK_HEADERS([usb.h], [has_libusb_headers="true";break], [has_libusb_headers="false"])
+
+ if test "$has_libusb_headers" = "true"; then
- if test ! -z "${LIBUSB_CONFIG}"; then
LIBUSB_LIBS=`${LIBUSB_CONFIG} --libs`
- LIBUSB_CFLAGS=`${LIBUSB_CONFIG} --cflags`
- # we don't want all collected libs for all programs but we need to extend LDFLAGS for usb-detection
- # so LDFLAGS will be restored after usb-detection
+ # save current LDFLAGS (to be restored after usb-detection)
TEMP_LDFLAGS="${LDFLAGS}"
- LDFLAGS="${LDFLAGS} ${LIBUSB_LIBS}"
- CFLAGS="${CFLAGS} ${LIBUSB_CFLAGS}"
+ LDFLAGS="${LDFLAGS} ${LIBUSB_LIBS}"
- # if usb_get_string_simple() unavailable -> libusb too old (<= 0.1.7)
- AC_CHECK_LIB([usb], [usb_get_string_simple])
- AC_CHECK_FUNCS([usb_get_string_simple], [has_libusb="true";break], [has_libusb="false"])
- AC_CHECK_FUNCS([usb_detach_kernel_driver_np], [has_libusb_detach_kdriver="true";break], [has_libusb_detach_kdriver="false"])
-
- AC_SUBST(LIBUSB_LIBS)
- AC_SUBST(LIBUSB_CFLAGS)
- AC_SUBST(has_libusb)
- AC_SUBST(has_libusb_detach_kdriver)
- # restore LDFLAGS
- LDFLAGS="${TEMP_LDFLAGS}"
+ if test "$enable_libusb" != "no"; then
- else
- has_libusb="false"
- AC_SUBST(has_libusb)
+ AC_CHECK_LIB([usb], [usb_get_string_simple])
+ # if usb_get_string_simple() unavailable -> libusb too old (<= 0.1.7)
+ AC_CHECK_FUNCS([usb_get_string_simple], [has_libusb="true";break], [has_libusb="false"])
+ AC_CHECK_FUNCS([usb_detach_kernel_driver_np], [has_libusb_detach_kdriver="true";break], [has_libusb_detach_kdriver="false"])
+
+ # restore LDFLAGS
+ LDFLAGS="${TEMP_LDFLAGS}"
+
+ if test "$has_libusb" = "true"; then
+ AC_DEFINE(HAVE_LIBUSB, 1, [whether libusb is available and usable (header files and library files available)])
+ if test -z "$LIBUSB_LIBS"; then
+ has_libusb="false"
+ AC_DEFINE(HAVE_LIBSDL, 0, [whether libusb is available and usable (header files and library files available)])
+ else
+ LDFLAGS="${LDFLAGS} ${LIBUSB_LIBS}"
+ fi
+ fi
+ fi
+ fi
+fi
+AC_SUBST(has_libusb)
+AC_SUBST(has_libusb_detach_kdriver)
+AC_SUBST(HAVE_LIBUSB)
+
+
+# libsdl
+# check for libSDL header and library
+# defines the following in config.h:
+# one of
+# HAVE_SDL_H
+# HAVE_SDL_SDL_H
+# HAVE_LIBSDL
+AC_PATH_PROG(LIBSDL_CONFIG, sdl-config)
+
+has_libSDL="false" # pre-init
+if test ! -z "${LIBSDL_CONFIG}"; then
+ LIBSDL_CFLAGS=`${LIBSDL_CONFIG} --cflags`
+ CFLAGS="${CFLAGS} ${LIBSDL_CFLAGS}"
+
+ #defines either HAVE_SDL_SDL_H or HAVE_SDL_H
+ AC_CHECK_HEADERS([SDL/SDL.h SDL.h], [has_libSDL_headers="true";break], [has_libSDL_headers="false"])
+
+ if test "$has_libSDL_headers" = "true"; then
+ if ! test "$enable_libSDL" = "no"; then
+ LIBSDL_LIBS=`${LIBSDL_CONFIG} --libs`
+
+ # we don't want configure to auto-add libsdl because it will not be linked but included using libdl / dlopen() instead
+ # so LDFLAGS will be restored after libsdl-detection
+ TEMP_LDFLAGS="${LDFLAGS}"
+
+ LDFLAGS="${LDFLAGS} ${LIBSDL_LIBS}"
+
+ #
+ AC_CHECK_LIB([SDL], [SDL_SetVideoMode])
+ AC_CHECK_FUNCS([SDL_SetVideoMode], [has_libSDL="true";break], [has_libSDL="false"])
+
+ # restore LDFLAGS
+ LDFLAGS="${TEMP_LDFLAGS}"
+
+ if test "$has_libSDL" = "true"; then
+ AC_DEFINE(HAVE_LIBSDL, 1, [whether libSDL is available and usable (header files and, if no dynamic linking, library files available)])
+ #CFLAGS="${CFLAGS} ${LIBSDL_CFLAGS}"
+ if test -z "$LIBSDL_LIBS"; then
+ has_libSDL="false"
+ AC_DEFINE(HAVE_LIBSDL, 0, [whether libSDL is available and usable (header files and, if no dynamic linking, library files available)])
+ else
+ LDFLAGS="${LDFLAGS} ${LIBSDL_LIBS}"
+ fi
+ fi
+ fi
fi
fi
+AC_SUBST(has_libSDL)
+AC_SUBST(HAVE_LIBSDL)
+
+# restore LIBS
+LIBS="${TEMP_LIBS}"
# ugly hack for determination whether to build w/ or w/o soname, will be enhanced later
# for now: soname only together with linux
@@ -155,7 +230,7 @@
[ possible drivers are:]
[ sed153x, pcd8544, sed156x, i2c, t6963, sed133x, ]
[ nokcol, ks0108, lh155, ssdoled, l4m, goldelox, stv8105, ]
- [ alphacool ],
+ [ acoolsdcm, directgfx, lc7981 ],
drivers=${withval},
drivers=all
)
@@ -279,15 +354,33 @@
MY_WITH_DRIVER(STV8105, 0, [stv8105])
fi
;;
- alphacool)
+ acoolsdcm|alphacool)
if test "${val}" = "yes" ; then
if test "$has_libusb" = "true" ; then
- MY_WITH_DRIVER(ALPHACOOL, 1, [alphacool])
+ MY_WITH_DRIVER(ACOOLSDCM, 1, [acoolsdcm])
else
- MY_WITH_DRIVER(ALPHACOOL, 0, [alphacool])
+ MY_WITH_DRIVER(ACOOLSDCM, 0, [acoolsdcm])
fi
else
- MY_WITH_DRIVER(ALPHACOOL, 0, [alphacool])
+ MY_WITH_DRIVER(ACOOLSDCM, 0, [acoolsdcm])
+ fi
+ ;;
+ directgfx)
+ if test "${val}" = "yes" ; then
+ if test "$has_libSDL" = "true" ; then
+ MY_WITH_DRIVER(DIRECTGFX, 1, [directgfx])
+ else
+ MY_WITH_DRIVER(DIRECTGFX, 0, [directgfx])
+ fi
+ else
+ MY_WITH_DRIVER(DIRECTGFX, 0, [directgfx])
+ fi
+ ;;
+ lc7981)
+ if test "${val}" = "yes" ; then
+ MY_WITH_DRIVER(LC7981, 1, [lc7981])
+ else
+ MY_WITH_DRIVER(LC7981, 0, [lc7981])
fi
;;
*)
@@ -339,11 +432,19 @@
if test -z "${WITH_DRIVER_STV8105}" ; then
MY_WITH_DRIVER(STV8105, 1, [stv8105])
fi
- if test -z "${WITH_DRIVER_ALPHACOOL}" ; then
+ if test -z "${WITH_DRIVER_ACOOLSDCM}" ; then
if test "$has_libusb" = "true" ; then
- MY_WITH_DRIVER(ALPHACOOL, 1, [alphacool])
+ MY_WITH_DRIVER(ACOOLSDCM, 1, [acoolsdcm])
fi
fi
+ if test -z "${WITH_DRIVER_DIRECTGFX}" ; then
+ if test "$has_libSDL" = "true" ; then
+ MY_WITH_DRIVER(DIRECTGFX, 1, [directgfx])
+ fi
+ fi
+ if test -z "${WITH_DRIVER_LC7981}" ; then
+ MY_WITH_DRIVER(LC7981, 1, [lc7981])
+ fi
fi
@@ -389,36 +490,42 @@
echo ""
echo ""
-echo "supported extra protocols"
+echo "supported extra libraries"
echo "========================="
if test "$has_libusb" = "true"; then
if test "$has_libusb_detach_kdriver" = "true"; then
- echo " * libusb support ... yes"
+ echo " * libusb support ... yes"
else
- echo " * libusb support ... yes, but without usb_detach_kernel_driver_np()"
+ echo " * libusb support ... yes, but without usb_detach_kernel_driver_np()"
fi
else
if test "$enable_libusb" = "no"; then
- echo " * libusb support ... disabled"
+ echo " * libusb support ... disabled"
+ elif test "$has_libusb_headers" = "false"; then
+ echo " * libusb support ... header file (usb.h) not found"
else
- echo " * libusb support ... no, or too old (at least libusb 0.1.7 is needed)"
+ echo " * libusb support ... no, or too old (at least headers for libusb 0.1.7 are needed)"
fi
fi
-echo ""
-echo ""
-echo "supported features"
-echo "=================="
+if test "$has_libSDL" = "true"; then
+ echo " * libSDL support ... yes"
+else
+ if test "$enable_libSDL" = "no"; then
+ echo " * libSDL support ... disabled"
+ else
+ echo " * libSDL support ... no (header files and/or library not found)"
+ fi
+fi
-echo ""
if test "$has_libgd_lib" = "true"; then
if test "$has_libgd_headers" = "true"; then
- echo " * libgd >= 2 support ... yes"
+ echo " * libgd >= 2 support ... yes"
else
- echo " * libgd >= 2 support ... yes, but header files are missing"
+ echo " * libgd >= 2 support ... yes, but header files are missing"
fi
else
- echo " * libgd >= 2 support ... no "
+ echo " * libgd >= 2 support ... no "
fi
@@ -448,17 +555,17 @@
echo "tools"
echo "====="
if test "$has_libgd_headers" = "true" -a "$has_libgd_lib" = "true"; then
- echo " * multidisplay ... yes"
+ echo " * multidisplay ... yes"
if test "$ac_cv_func_gdImageCreateFromGif" = "yes" ; then
- echo " - with GIF support ... yes"
+ echo " - with GIF support ... yes"
else
- echo " - with GIF support ... no (recent libgd needed for GIF support)"
+ echo " - with GIF support ... no (recent libgd needed for GIF support)"
fi
else
if test "$has_libgd_lib" = "false"; then
- echo " * multidisplay ... no (because of missing libgd)"
+ echo " * multidisplay ... no (because of missing libgd)"
else
- echo " * multidisplay ... no (because of missing header files for libgd)"
+ echo " * multidisplay ... no (because of missing header files for libgd)"
fi
fi
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/include/serdisplib/serdisp_colour.h
^
|
@@ -1,7 +1,7 @@
/** \file serdisp_colour.h
*
* \brief Colour and colour space specific functions
- * \date (C) 2003-2008
+ * \date (C) 2003-2009
* \author wolfgang astleitner (mrwastl@users.sourceforge.net)
*/
@@ -72,6 +72,7 @@
#define SD_CS_RGB333 0x00020000
#define SD_CS_RGB444 0x00040000
#define SD_CS_RGB565 0x00080000
+#define SD_CS_RGB666 0x00100000
#define SD_CS_BGR 0x00800000
/* bits 28-31: true colour spaces */
@@ -81,7 +82,7 @@
/* mask of all indexed colour spaces */
#define SD_CS_INDEXED_SPACE SD_CS_GREYSCALE
-#define SD_CS_ISGREY(_dd) ( ( ((_dd)->colour_spaces) & 0x000000F0L) ? 1 : 0 )
+#define SD_CS_ISGREY(_dd) ( ( (((_dd)->colour_spaces) & 0x000000F0L) && (((_dd)->depth) <=8) ) ? 1 : 0 )
#define SD_CS_ISMONOCHROME(_dd) ( ( ((_dd)->depth) == 1 ) ? 1 : 0 )
/* is packed colour space RGB (0) or BGR (1) ? */
@@ -116,6 +117,8 @@
long serdisp_getcolour (serdisp_t* dd, int x, int y);
byte serdisp_getgrey (serdisp_t* dd, int x, int y);
+ int serdisp_sdcol_init (serdisp_t* dd);
+
long serdisp_transcolour (serdisp_t* dd, long colour);
long serdisp_transgrey (serdisp_t* dd, byte greyvalue);
@@ -125,49 +128,6 @@
void serdisp_setcoltabentry (serdisp_t* dd, int idx, long colour);
long serdisp_getcoltabentry (serdisp_t* dd, int idx);
-
-
- /* colour space specific routines */
- long serdisp_transcolour_bw (serdisp_t* dd, long colour);
- long serdisp_transgrey_bw (serdisp_t* dd, byte greyvalue);
- long serdisp_lookupcolour_bw (serdisp_t* dd, long colour);
- byte serdisp_lookupgrey_bw (serdisp_t* dd, long colour);
-
- long serdisp_transcolour_grey2_4 (serdisp_t* dd, long colour);
- long serdisp_transgrey_grey2_4 (serdisp_t* dd, byte greyvalue);
- long serdisp_lookupcolour_grey2_4(serdisp_t* dd, long colour);
- byte serdisp_lookupgrey_grey2_4 (serdisp_t* dd, long colour);
-
- long serdisp_transcolour_grey8 (serdisp_t* dd, long colour);
- long serdisp_transgrey_grey8 (serdisp_t* dd, byte greyvalue);
- long serdisp_lookupcolour_grey8 (serdisp_t* dd, long colour);
- byte serdisp_lookupgrey_grey8 (serdisp_t* dd, long colour);
-
- long serdisp_transcolour_rgb332 (serdisp_t* dd, long colour);
- long serdisp_transgrey_rgb332 (serdisp_t* dd, byte greyvalue);
- long serdisp_lookupcolour_rgb332 (serdisp_t* dd, long colour);
- byte serdisp_lookupgrey_rgb332 (serdisp_t* dd, long colour);
-
- long serdisp_transcolour_bgr332 (serdisp_t* dd, long colour);
- long serdisp_transgrey_bgr332 (serdisp_t* dd, byte greyvalue);
- long serdisp_lookupcolour_bgr332 (serdisp_t* dd, long colour);
- byte serdisp_lookupgrey_bgr332 (serdisp_t* dd, long colour);
-
- long serdisp_transcolour_rgb444 (serdisp_t* dd, long colour);
- long serdisp_transgrey_rgb444 (serdisp_t* dd, byte greyvalue);
- long serdisp_lookupcolour_rgb444 (serdisp_t* dd, long colour);
- byte serdisp_lookupgrey_rgb444 (serdisp_t* dd, long colour);
-
- long serdisp_transcolour_rgb565 (serdisp_t* dd, long colour);
- long serdisp_transgrey_rgb565 (serdisp_t* dd, byte greyvalue);
- long serdisp_lookupcolour_rgb565 (serdisp_t* dd, long colour);
- byte serdisp_lookupgrey_rgb565 (serdisp_t* dd, long colour);
-
- long serdisp_transcolour_bgr565 (serdisp_t* dd, long colour);
- long serdisp_transgrey_bgr565 (serdisp_t* dd, byte greyvalue);
- long serdisp_lookupcolour_bgr565 (serdisp_t* dd, long colour);
- byte serdisp_lookupgrey_bgr565 (serdisp_t* dd, long colour);
-
#ifdef __cplusplus
}
#endif
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/include/serdisplib/serdisp_connect.h
^
|
@@ -1,7 +1,7 @@
/** \file serdisp_connect.h
*
* \brief Functions for accessing supported output devices (parport, serial device, ..)
- * \date (C) 2003-2008
+ * \date (C) 2003-2010
* \author wolfgang astleitner (mrwastl@users.sourceforge.net)
*/
@@ -98,8 +98,8 @@
#define SERDISPCONNTYPE_IOW24 0x0008
#define SERDISPCONNTYPE_SERVER 0x0010
#define SERDISPCONNTYPE_HIDDEV 0x0020
-#define SERDISPCONNTYPE_SPI 0x0040
#define SERDISPCONNTYPE_RS232 0x0080
+#define SERDISPCONNTYPE_OUT 0x8000
/* short forms for connection types */
#define SDCT_PP SERDISPCONNTYPE_PARPORT
@@ -107,14 +107,23 @@
#define SDCT_I2C SERDISPCONNTYPE_I2C
#define SDCT_IOW24 SERDISPCONNTYPE_IOW24
#define SDCT_HIDDEV SERDISPCONNTYPE_HIDDEV
-#define SDCT_SPI SERDISPCONNTYPE_SPI
#define SDCT_RS232 SERDISPCONNTYPE_RS232
+#define SDCT_OUT SERDISPCONNTYPE_OUT
+
+/* protocols */
+#define SDPROTO_DONTCARE 0x0000 /* default */
+#define SDPROTO_EMULATION 0x0001
+#define SDPROTO_I2C 0x0002
+#define SDPROTO_RS232 0x0004
+#define SDPROTO_SPI 0x0010
/* hardware types */
#define SDHWT_ALL 0xFFFF /* valid for all hw-types */
#define SDHWT_PARSER 0x0001 /* parallel or serial port (or usb->serial adapter) */
+#define SDHWT_OUT 0x0080 /* dummy protocol for file / direct / ... output */
+
/* 0xFF00 reserved for usb-devices */
#define SDHWT_USB 0xFF00 /* mask that hw needs usb routines */
#define SDHWT_USBFTDI2232 0x0100 /* FTDI: 01 - 0F */
@@ -122,7 +131,8 @@
#define SDHWT_USBIOW24 0x1000 /* c't maeusekino usb-display */
#define SDHWT_USBALPHACOOL 0x2000 /* alphacool 240x128 or 200x64 usb display */
#define SDHWT_USBL4ME5I 0x3000 /* linux4media E-5i internal board + 128x64 LCD */
-
+#define SDHWT_USB13700 0x4000 /* USB13700 module by henri (lcdinfo.com) */
+#define SDHWT_USBSDCMEGTRON 0x5000 /* smart-display-company/megtron 240x128 LCD */
/* *************************** *
* constants for parallel port *
@@ -179,6 +189,11 @@
#define SD_MAX_SUPP_SIGNALS 32 /* maximum supported signals */
+/* device health */
+#define SD_STATUS_OK 0 /* device is ok */
+#define SD_STATUS_ERROR 1 /* runtime error - device not functioning */
+#define SD_STATUS_RESETTING 2 /* device currently being reset */
+
/* needed by iowarrior, copied from iowarrior.h ((C) codemercenaris) */
#define USB_VENDOR_ID_CODEMERCS 1984
@@ -225,11 +240,11 @@
} gen_stream_device_t;
-
/* struct containing all infos and other things concerning a display */
typedef struct serdisp_CONN_s {
short conntype; /* one of SERDISPCONNTYPE_* */
short hardwaretype; /* one of SDHWT_*. default: SDHWT_SERPAR */
+ short protocol; /* one of SDPROTP_*. default: SDPROTO_DONTCARE */
#ifndef __cplusplus /* qt/moc is having problems with the label 'signals' (name clash) */
long signals[SD_MAX_SUPP_SIGNALS]; /* lookup vector for signals */
@@ -265,6 +280,34 @@
int debug_count; /* counter for debugging purposes */
void* extra; /* extra device data */
+
+ int device_status; /* one of SD_STATUS_OK, SD_STATUS_ERROR, SD_STATUS_RESETTING */
+ unsigned long timestamp; /* if resetting device: timestamp (in seconds) of last test. else: 0 */
+
+ int needs_confinit; /* non-default configuration needed before 1st commit or read/write operation */
+ union {
+ struct {
+ byte framelen :4; /* SPI frame length intern = SPI frame length - 4 ([0 - 15] -> [4 - 19]) */
+ byte cpol :1; /* SPI clock polarity (0 or 1) */
+ byte cpha :1; /* SPI clock phase (0 or 1) */
+ byte data_high :1; /* 1: data = active high, 0: command = active high */
+ byte dc_extsig :1; /* 0: D/C bit part of SPI stream, 1: separate D/C signal wire */
+ byte prescaler; /* SPI prescaler [2 - 254] */
+ unsigned short divider; /* SPI divider */
+ } spi;
+ struct {
+ unsigned int baudrate; /* define according to cfsetspeed(), eg B500000 */
+
+ byte c_cs8_decr :2; /* databits: 8 - cs8_decr (default: 0 == 8 databits, 1 == 7, 2 == 6, 3 == 5) */
+ byte c_cstopb :1; /* 0: 1 stop bits (default), 1: 2 stop bits */
+ byte c_parenb :1; /* 0: don't enable parent bit; 1: enable parent bit */
+ byte c_parodd :1; /* 0: even parity; 1: odd parity */
+ byte c_cread :1; /* 0: don't enable receiver; 1: enable receiver */
+ byte c_local :1; /* 0: no local line; 1: local line */
+ byte c_rtscts :1; /* 0: no hw flow control; 1: enable hw flow control (if supp. by plattform) */
+
+ } rs232;
+ };
} serdisp_CONN_t;
@@ -311,6 +354,7 @@
void SDCONN_write (serdisp_CONN_t* sdcd, long data, byte flags);
void SDCONN_writedelay (serdisp_CONN_t* sdcd, long data, byte flags, long ns);
long SDCONN_read (serdisp_CONN_t* sdcd, byte flags);
+ int SDCONN_readstream (serdisp_CONN_t* sdcd, byte* buf, int count);
void SDCONN_commit (serdisp_CONN_t* sdcd);
void SDCONN_usleep (serdisp_CONN_t* sdcd, unsigned long usec);
@@ -324,9 +368,6 @@
}
#endif
-
-
-
#endif /* SERDISP_CONNECT_H */
/*! @} */
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/include/serdisplib/serdisp_connect_usb.h
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -54,11 +54,10 @@
int out_ep; /* endpoint address for sending data to the interface */
int in_ep; /* endpoint address for receiving data from the interface */
int read_timeout;
- int write_timeout;
+ int write_timeout;
} serdisp_usbdev_t;
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -70,11 +69,11 @@
int SDCONNusb_readstream (serdisp_CONN_t* sdcd, byte* buf, int count);
void SDCONNusb_commit (serdisp_CONN_t* sdcd);
void SDCONNusb_usleep (serdisp_CONN_t* sdcd, unsigned long usec);
+ /* protected functions */
+ int SDCONNusb_confinit (serdisp_CONN_t* sdcd);
#ifdef __cplusplus
}
#endif
-
-
#endif /* SERDISP_CONNECT_H */
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/include/serdisplib/serdisp_control.h
^
|
@@ -1,7 +1,7 @@
/** \file serdisp_control.h
*
* \brief Functions for accessing and controlling a display
- * \date (C) 2003-2008
+ * \date (C) 2003-2010
* \author wolfgang astleitner (mrwastl@users.sourceforge.net)
*/
@@ -42,7 +42,7 @@
#define SERDISP_VERSION_MAJOR 1 /**< \brief major version of serdisplib \hideinitializer */
#define SERDISP_VERSION_MINOR 97 /**< \brief minor version of serdisplib \hideinitializer */
-#define SERDISP_VERSION_EXTRA 8 /**< \brief extra version postfix (ignored) \hideinitializer */
+#define SERDISP_VERSION_EXTRA 9 /**< \brief extra version postfix (ignored) \hideinitializer */
/** \hideinitializer
* \brief calculates a serdisplib version code
@@ -177,6 +177,10 @@
min_contrast contains the lower border at which the display is just about to be readable */
int max_contrast; /**< if feature_contrast = true =>
max_contrast contains the upper border at which the display is still readable */
+ int mid_contrast; /**< if feature_contrast = true =>
+ if mid_contrast is not set (==0): linear contrast from min_contrast to max_contrast
+ if mid_contrast is set: the default linear function for the contrast values is changed
+ to a power function with fixed point for CONTRAST=5 => mid_contrast */
long delay; /**< delay after each write-operation (in nanoseconds).\n
ns = 0: ignore (no delay)\n
@@ -189,7 +193,6 @@
void* specific_data; /**< place for a specific display-dependend struct (eg: i2c-ids, ...) */
long* ctable; /**< colour table for indexed colour table */
- int* greytable; /**< look up table for grey values: grey value -> index */
long colour_spaces; /**< colour spaces supported by this display (bit field). 0 == auto-detect */
@@ -203,6 +206,12 @@
int curr_contrast; /**< current value for contrast */
int curr_backlight; /**< status of backlight */
int curr_invert; /**< display inverted (1) or not (0) */
+ int curr_dimming; /**< current value for dimming (in percent) - between 0 and 100, default: 0\n
+ dimming = 100 - BRIGHTNESS (if dimming = 0%, brightness = 100%)
+ driver needs to support option 'BRIGHTNESS' for this value to take effect
+ */
+
+ int supp_protocols; /**< protocols supported by this display / module (bit field) */
int dbg_cnt; /**< counter. may be used for debugging issues */
@@ -213,6 +222,7 @@
void (*fp_update) (struct serdisp_s* dd);
void (*fp_clear) (struct serdisp_s* dd);
int (*fp_setoption) (struct serdisp_s* dd, const char* option, long value);
+ long (*fp_getoption) (struct serdisp_s* dd, const char* option, int* typesize);
void (*fp_close) (struct serdisp_s* dd);
void (*fp_setpixel) (struct serdisp_s* dd, int x, int y, long colour);
long (*fp_getpixel) (struct serdisp_s* dd, int x, int y);
@@ -266,6 +276,7 @@
/*!@{*/
serdisp_t* serdisp_init (serdisp_CONN_t*, const char dispname[], const char optionstring[]);
void serdisp_close (serdisp_t* dd);
+ void serdisp_freeresources (serdisp_t* dd);
void serdisp_quit (serdisp_t* dd);
int serdisp_reset (serdisp_t* dd);
serdisp_t* serdisp_fullreset (serdisp_t* dd);
@@ -344,10 +355,12 @@
serdisp_t* serdisp_sed156x_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_ssdoled_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_t6963_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
- serdisp_t* serdisp_alphacool_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
+ serdisp_t* serdisp_acoolsdcm_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_l4m_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_goldelox_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_stv8105_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
+ serdisp_t* serdisp_directgfx_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
+ serdisp_t* serdisp_lc7981_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
#ifdef __cplusplus
}
#endif
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/include/serdisplib/serdisp_control.h.in
^
|
@@ -1,7 +1,7 @@
/** \file serdisp_control.h
*
* \brief Functions for accessing and controlling a display
- * \date (C) 2003-2008
+ * \date (C) 2003-2010
* \author wolfgang astleitner (mrwastl@users.sourceforge.net)
*/
@@ -177,6 +177,10 @@
min_contrast contains the lower border at which the display is just about to be readable */
int max_contrast; /**< if feature_contrast = true =>
max_contrast contains the upper border at which the display is still readable */
+ int mid_contrast; /**< if feature_contrast = true =>
+ if mid_contrast is not set (==0): linear contrast from min_contrast to max_contrast
+ if mid_contrast is set: the default linear function for the contrast values is changed
+ to a power function with fixed point for CONTRAST=5 => mid_contrast */
long delay; /**< delay after each write-operation (in nanoseconds).\n
ns = 0: ignore (no delay)\n
@@ -189,7 +193,6 @@
void* specific_data; /**< place for a specific display-dependend struct (eg: i2c-ids, ...) */
long* ctable; /**< colour table for indexed colour table */
- int* greytable; /**< look up table for grey values: grey value -> index */
long colour_spaces; /**< colour spaces supported by this display (bit field). 0 == auto-detect */
@@ -203,6 +206,12 @@
int curr_contrast; /**< current value for contrast */
int curr_backlight; /**< status of backlight */
int curr_invert; /**< display inverted (1) or not (0) */
+ int curr_dimming; /**< current value for dimming (in percent) - between 0 and 100, default: 0\n
+ dimming = 100 - BRIGHTNESS (if dimming = 0%, brightness = 100%)
+ driver needs to support option 'BRIGHTNESS' for this value to take effect
+ */
+
+ int supp_protocols; /**< protocols supported by this display / module (bit field) */
int dbg_cnt; /**< counter. may be used for debugging issues */
@@ -213,6 +222,7 @@
void (*fp_update) (struct serdisp_s* dd);
void (*fp_clear) (struct serdisp_s* dd);
int (*fp_setoption) (struct serdisp_s* dd, const char* option, long value);
+ long (*fp_getoption) (struct serdisp_s* dd, const char* option, int* typesize);
void (*fp_close) (struct serdisp_s* dd);
void (*fp_setpixel) (struct serdisp_s* dd, int x, int y, long colour);
long (*fp_getpixel) (struct serdisp_s* dd, int x, int y);
@@ -266,6 +276,7 @@
/*!@{*/
serdisp_t* serdisp_init (serdisp_CONN_t*, const char dispname[], const char optionstring[]);
void serdisp_close (serdisp_t* dd);
+ void serdisp_freeresources (serdisp_t* dd);
void serdisp_quit (serdisp_t* dd);
int serdisp_reset (serdisp_t* dd);
serdisp_t* serdisp_fullreset (serdisp_t* dd);
@@ -344,10 +355,12 @@
serdisp_t* serdisp_sed156x_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_ssdoled_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_t6963_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
- serdisp_t* serdisp_alphacool_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
+ serdisp_t* serdisp_acoolsdcm_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_l4m_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_goldelox_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
serdisp_t* serdisp_stv8105_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
+ serdisp_t* serdisp_directgfx_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
+ serdisp_t* serdisp_lc7981_setup (const serdisp_CONN_t* sdcd, const char* dispname, const char* paramstring);
#ifdef __cplusplus
}
#endif
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/include/serdisplib/serdisp_fctptr.h
^
|
@@ -0,0 +1,118 @@
+/** \file serdisp_fctptr.h
+ *
+ * \brief Initialisation of additional libraries and function pointers
+ * \date (C) 2010
+ * \author wolfgang astleitner (mrwastl@users.sourceforge.net)
+ */
+
+/*
+ *************************************************************************
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+/** \addtogroup SERDISP_CONNECT
+
+ \section SDFP_INTRODUCTION Introduction
+ serdisp_fctptr.h offers functions for initialising additional libraries and function pointers
+ and requesting information about the additional libraries.
+
+
+ * @{
+ */
+
+
+#ifndef SERDISP_FCTPTR_H
+#define SERDISP_FCTPTR_H
+
+/* define 'byte' if not available yet */
+#ifndef byte
+ #define byte unsigned char
+#endif
+
+#define SDFCTPTR_LIBUSB 1
+#define SDFCTPTR_PTHREAD 2
+#define SDFCTPTR_NETSOCK 3
+#define SDFCTPTR_LIBSDL 4
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void SDFCTPTR_init (void);
+ int SDFCTPTR_checkavail (int libID);
+ void SDFCTPTR_cleanup (void);
+#ifdef __cplusplus
+ }
+#endif
+
+
+#ifdef HAVE_LIBUSB
+ #include <usb.h>
+
+extern void (*fp_usb_init) (void);
+extern usb_dev_handle* (*fp_usb_open) (struct usb_device* dev);
+extern int (*fp_usb_close) (usb_dev_handle* dev);
+extern int (*fp_usb_reset) (usb_dev_handle* dev);
+extern int (*fp_usb_interrupt_read) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
+extern int (*fp_usb_release_interface)(usb_dev_handle* dev, int interface);
+extern int (*fp_usb_find_busses) (void);
+extern int (*fp_usb_find_devices) (void);
+extern struct usb_bus* (*fp_usb_get_busses) (void);
+extern int (*fp_usb_claim_interface) (usb_dev_handle* dev, int interface);
+
+extern int (*fp_usb_bulk_read) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
+extern int (*fp_usb_bulk_write) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
+extern int (*fp_usb_control_msg) (usb_dev_handle* dev, int requesttype, int request,
+ int value, int index, char *bytes, int size, int timeout);
+extern int (*fp_usb_clear_halt) (usb_dev_handle *dev, unsigned int ep);
+
+extern int (*fp_usb_set_altinterface) (usb_dev_handle *dev, int alternate);
+extern int (*fp_usb_set_configuration)(usb_dev_handle *dev, int configuration);
+extern int (*fp_usb_get_string_simple)(usb_dev_handle *dev, int index, char *buf, size_t buflen);
+
+extern int (*fp_usb_detach_kernel_driver_np) (usb_dev_handle* dev, int interface);
+#endif /* HAVE_LIBUSB */
+
+
+#ifdef HAVE_LIBSDL
+ #ifdef HAVE_SDL_SDL_H
+ #include "SDL/SDL.h"
+ #else
+ #include "SDL.h"
+ #endif
+
+ #include <inttypes.h>
+
+ #define dfn_SDL_MUSTLOCK SDL_MUSTLOCK
+
+extern int (*fp_SDL_Init) (uint32_t);
+extern SDL_Surface* (*fp_SDL_SetVideoMode) (int, int, int, uint32_t);
+extern char* (*fp_SDL_GetError) (void);
+extern void (*fp_SDL_WM_SetCaption) (const char*, const char*);
+extern int (*fp_SDL_LockSurface) (SDL_Surface*);
+extern void (*fp_SDL_UnlockSurface) (SDL_Surface*);
+extern int (*fp_SDL_Flip) (SDL_Surface*);
+extern void (*fp_SDL_FreeSurface) (SDL_Surface*);
+extern uint32_t (*fp_SDL_MapRGB) (SDL_PixelFormat*, uint8_t, uint8_t, uint8_t);
+extern void (*fp_SDL_Quit) (void);
+#endif /* HAVE_LIBSDL */
+
+
+#endif /* SERDISP_FCTPTR_H */
+
+/*! @} */
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/include/serdisplib/serdisp_tools.h
^
|
@@ -92,6 +92,23 @@
int sdtools_strtrimmedlen (const char* str, int len);
/*!@}*/
+
+/** \name Calculation functions
+ */
+/*!@{*/
+ int sdtools_calc_bbox (serdisp_t* dd, int hor, int* xt, int* yt, int* xb, int* yb);
+/*!@}*/
+
+
+/** \name Math function replacements which do not require math.h nor -lm
+ */
+/*!@{*/
+ double sdtools_exp (double x);
+ double sdtools_log (double x);
+ double sdtools_logN (double x, double base);
+ double sdtools_pow (double x, double y);
+/*!@}*/
+
#ifdef __cplusplus
}
#endif
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/serdisplib.spec
^
|
@@ -1,22 +1,34 @@
Summary: Library to drive several graphical LC-displays
Name: serdisplib
-Version: 1.97.8
+Version: 1.97.9
Release: 1
License: GPL
Group: System Environment/Libraries
URL: http://serdisplib.sourceforge.net/
Packager: Wolfgang Astleitner <mrwastl@users.sf.net>
-
Source: http://prdownloads.sourceforge.net/serdisplib/serdisplib-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-BuildRequires: autoconf >= 2.5 gd-devel >= 2 libusb-devel >= 0.1.8
+# conditional dependencies: default values are --with-libusb --without-libSDL
+# e.g: to build RPMs with support for libSDL:
+# rpmbuild --with libSDL --rebuild serdisplib-x.y-1.src.rpm
+%{!?_with_libusb: %{!?_without_libusb: %define _with_libusb --with-libusb}}
+%{!?_with_libSDL: %{!?_without_libSDL: %define _without_libSDL --without-libSDL}}
+
+#AutoReqProv: no
+#%{?_with_libusb:Requires: libusb >= 0.1.8}
+#%{?_with_libSDL:Requires: SDL >= 1.2.0}
+
+BuildRequires: autoconf >= 2.5 gd-devel >= 2
+%{?_with_libusb:BuildRequires: libusb-devel >= 0.1.8}
+%{?_with_libSDL:BuildRequires: SDL-devel >= 1.2.0}
%description
serdisplib is a library to drive graphical LC-displays
%package devel
+#AutoReqProv: no
Requires: serdisplib = %{version}-%{release}
Summary: The development libraries and header files for serdisplib
Group: Development/Libraries
@@ -26,6 +38,7 @@
%package tools
+#AutoReqProv: no
Requires: serdisplib = %{version}-%{release}
Requires: gd >= 2
Summary: Serdisplib Tools (testserdisp, multidisplay)
@@ -38,7 +51,7 @@
%prep
%setup
-%configure --enable-libusb
+%configure %{?_with_libusb:--enable-libusb} %{?_with_libSDL:--enable-libSDL}
#%patch
@@ -84,6 +97,8 @@
%changelog
+* Sun Feb 13 2010 Wolfgang Astleitner <mrwastl@users.sf.net> - 1.97.9-1
+- conditional dependencies libusb (--with-libusb, default: yes) and libSDL (--with-libSDL, default: no)
* Sun Feb 22 2007 Wolfgang Astleitner <mrwastl@users.sf.net> - 1.97.4-1
- dependency libusb -> libusb-devel
* Sun Feb 11 2007 Wolfgang Astleitner <mrwastl@users.sf.net> - 1.97.3-1
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/serdisplib.spec.in
^
|
@@ -7,16 +7,28 @@
URL: http://serdisplib.sourceforge.net/
Packager: Wolfgang Astleitner <mrwastl@users.sf.net>
-
Source: http://prdownloads.sourceforge.net/serdisplib/serdisplib-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-BuildRequires: autoconf >= 2.5 gd-devel >= 2 libusb-devel >= 0.1.8
+# conditional dependencies: default values are --with-libusb --without-libSDL
+# e.g: to build RPMs with support for libSDL:
+# rpmbuild --with libSDL --rebuild serdisplib-x.y-1.src.rpm
+%{!?_with_libusb: %{!?_without_libusb: %define _with_libusb --with-libusb}}
+%{!?_with_libSDL: %{!?_without_libSDL: %define _without_libSDL --without-libSDL}}
+
+#AutoReqProv: no
+#%{?_with_libusb:Requires: libusb >= 0.1.8}
+#%{?_with_libSDL:Requires: SDL >= 1.2.0}
+
+BuildRequires: autoconf >= 2.5 gd-devel >= 2
+%{?_with_libusb:BuildRequires: libusb-devel >= 0.1.8}
+%{?_with_libSDL:BuildRequires: SDL-devel >= 1.2.0}
%description
serdisplib is a library to drive graphical LC-displays
%package devel
+#AutoReqProv: no
Requires: serdisplib = %{version}-%{release}
Summary: The development libraries and header files for serdisplib
Group: Development/Libraries
@@ -26,6 +38,7 @@
%package tools
+#AutoReqProv: no
Requires: serdisplib = %{version}-%{release}
Requires: gd >= 2
Summary: Serdisplib Tools (testserdisp, multidisplay)
@@ -38,7 +51,7 @@
%prep
%setup
-%configure --enable-libusb
+%configure %{?_with_libusb:--enable-libusb} %{?_with_libSDL:--enable-libSDL}
#%patch
@@ -84,6 +97,8 @@
%changelog
+* Sun Feb 13 2010 Wolfgang Astleitner <mrwastl@users.sf.net> - 1.97.9-1
+- conditional dependencies libusb (--with-libusb, default: yes) and libSDL (--with-libSDL, default: no)
* Sun Feb 22 2007 Wolfgang Astleitner <mrwastl@users.sf.net> - 1.97.4-1
- dependency libusb -> libusb-devel
* Sun Feb 11 2007 Wolfgang Astleitner <mrwastl@users.sf.net> - 1.97.3-1
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/Makefile.in
^
|
@@ -1,5 +1,5 @@
# Makefile for project 'serdisplib', sub-directory src/
-# (C) 2003-2008 by Wolfgang Astleitner
+# (C) 2003-2010 by Wolfgang Astleitner
VERSION=@PACKAGE_VERSION@
@@ -36,7 +36,8 @@
INSTALL_DATA = @INSTALL_DATA@
# libusb/usb.h don't go together with -ansi
-CFLAGS=@CFLAGS@ -Wall -Wno-implicit -fPIC -I../include -I..
+#CFLAGS=@CFLAGS@ -Wall -Wno-implicit -fPIC -I../include -I..
+CFLAGS=@CFLAGS@ -Wall -fPIC -I../include -I..
LDFLAGS=@LDFLAGS@
LIBS=@LIBS@
#CFLAGS=@CFLAGS@ -ansi -Wall -Wno-implicit -fPIC -I../include -I..
@@ -44,7 +45,7 @@
#CFLAGS=-g -ansi -Wall -Wno-implicit -fPIC -O2 -I. -I../include
-LIB_OBJECTS=serdisp_control.o serdisp_connect.o \
+LIB_OBJECTS=serdisp_fctptr.o serdisp_control.o serdisp_connect.o \
serdisp_colour.o serdisp_tools.o serdisp_messages.o
LIB_HEADERFILES=serdisp.h serdisp_control.h serdisp_connect.h serdisp_messages.h \
@@ -65,17 +66,15 @@
# link shared or static lib to executables
ifeq "@use_sharedlib@" "true"
LIB_SERDISP=-L$(LIB_DIR) -l$(LIB_NAME)
+ STATIC_LDFLAGS=
else
LIB_SERDISP=$(LIB_DIR)/$(LIB_STATIC)
+ STATIC_LDFLAGS=$(LDFLAGS)
endif
ifeq "@has_libusb@" "true"
LIB_OBJECTS+= serdisp_connect_usb.o
- EXTRA_LIBS+=@LIBUSB_LIBS@
- ifneq "@use_sharedlib@" "true"
- EXTRA_LIBS_STATIC+=$(EXTRA_LIBS)
- endif
endif
@@ -118,8 +117,14 @@
ifeq "@WITH_DRIVER_STV8105@" "true"
LIB_OBJECTS+= serdisp_specific_stv8105.o
endif
-ifeq "@WITH_DRIVER_ALPHACOOL@" "true"
- LIB_OBJECTS+= serdisp_specific_alphacool.o
+ifeq "@WITH_DRIVER_ACOOLSDCM@" "true"
+ LIB_OBJECTS+= serdisp_specific_acoolsdcm.o
+endif
+ifeq "@WITH_DRIVER_DIRECTGFX@" "true"
+ LIB_OBJECTS+= serdisp_specific_directgfx.o
+endif
+ifeq "@WITH_DRIVER_LC7981@" "true"
+ LIB_OBJECTS+= serdisp_specific_lc7981.o
endif
@@ -145,7 +150,7 @@
$(LIB_DIR)/$(LIB_SHARED): $(LIB_OBJECTS)
$(top_srcdir)/mkinstalldirs $(top_srcdir)/lib
- $(CC) -fPIC -shared $(SONAME_FLAG) -o $(LIB_DIR)/$(LIB_SHARED) $(LIB_OBJECTS) $(EXTRA_LIBS)
+ $(CC) -fPIC -shared $(SONAME_FLAG) -o $(LIB_DIR)/$(LIB_SHARED) $(LIB_OBJECTS) $(LDFLAGS)
if [ -n "$(VERSION_SUBMINOR)" ] ; then \
cd $(LIB_DIR) && $(LN_S) -f $(LIB_SHARED) lib$(LIB_NAME).so.$(VERSION_MAJOR).$(VERSION_MINOR) ; \
fi
@@ -153,7 +158,7 @@
cd $(LIB_DIR) && $(LN_S) -f lib$(LIB_NAME).so.$(VERSION_MAJOR) lib$(LIB_NAME).so
testserdisp: $(LIB_DIR)/$(LIB_STATIC) $(OBJECTS)
- $(CC) -o testserdisp $(OBJECTS) $(LIB_SERDISP) $(TARGET_LDFLAGS) $(EXTRA_LIBS_STATIC)
+ $(CC) -o testserdisp $(OBJECTS) $(LIB_SERDISP) $(STATIC_LDFLAGS)
clean:
/bin/rm -f $(OBJECTS) $(LIB_OBJECTS) $(LIB_DIR)/*.a $(LIB_DIR)/*.so*
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_colour.c
^
|
@@ -1,7 +1,7 @@
/** \file serdisp_colour.c
*
* \brief Colour and colour space specific functions
- * \date (C) 2003-2008
+ * \date (C) 2003-2010
* \author wolfgang astleitner (mrwastl@users.sourceforge.net)
*/
@@ -28,6 +28,65 @@
#include "serdisplib/serdisp_control.h"
#include "serdisplib/serdisp_colour.h"
+/* internal functions */
+static long serdisp_transcolour_bw (serdisp_t* dd, long colour);
+static long serdisp_transgrey_bw (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_bw (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_bw (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_grey2_4 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_grey2_4 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_grey2_4(serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_grey2_4 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_grey8 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_grey8 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_grey8 (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_grey8 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_rgb332 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_rgb332 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_rgb332 (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_rgb332 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_bgr332 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_bgr332 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_bgr332 (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_bgr332 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_rgb444 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_rgb444 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_rgb444 (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_rgb444 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_rgb565 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_rgb565 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_rgb565 (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_rgb565 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_bgr565 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_bgr565 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_bgr565 (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_bgr565 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_rgb666 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_rgb666 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_rgb666 (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_rgb666 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_rgb888 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_rgb888 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_rgb888 (serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_rgb888 (serdisp_t* dd, long colour);
+
+static long serdisp_transcolour_rgba888 (serdisp_t* dd, long colour);
+static long serdisp_transgrey_rgba888 (serdisp_t* dd, byte greyvalue);
+static long serdisp_lookupcolour_rgba888(serdisp_t* dd, long colour);
+static byte serdisp_lookupgrey_rgba888 (serdisp_t* dd, long colour);
+
+static long serdisp_colourdistance (long col1, long col2);
+
+
/**
* \brief set a colour in the display buffer
*
@@ -107,6 +166,103 @@
}
+/**
+ * \brief initialises colour conversion function pointers
+ *
+ * \param dd device descriptor
+ *
+ * \retval 0 no error occured
+ * \retval -1 depth/colour-space combination not supported
+ *
+ * \since 1.97.9
+ */
+int serdisp_sdcol_init (serdisp_t* dd) {
+ switch (serdisp_getdepth(dd)) {
+ case 1:
+ dd->fp_transcolour = serdisp_transcolour_bw;
+ dd->fp_transgrey = serdisp_transgrey_bw;
+ dd->fp_lookupcolour = serdisp_lookupcolour_bw;
+ dd->fp_lookupgrey = serdisp_lookupgrey_bw;
+ break;
+ case 2:
+ case 4:
+ dd->fp_transcolour = serdisp_transcolour_grey2_4;
+ dd->fp_transgrey = serdisp_transgrey_grey2_4;
+ dd->fp_lookupcolour = serdisp_lookupcolour_grey2_4;
+ dd->fp_lookupgrey = serdisp_lookupgrey_grey2_4;
+ break;
+ case 8:
+ if (dd->colour_spaces & SD_CS_RGB332) {
+ if (SD_CS_ISBGR(dd)) {
+ dd->fp_transcolour = serdisp_transcolour_bgr332;
+ dd->fp_transgrey = serdisp_transgrey_bgr332;
+ dd->fp_lookupcolour = serdisp_lookupcolour_bgr332;
+ dd->fp_lookupgrey = serdisp_lookupgrey_bgr332;
+ } else {
+ dd->fp_transcolour = serdisp_transcolour_rgb332;
+ dd->fp_transgrey = serdisp_transgrey_rgb332;
+ dd->fp_lookupcolour = serdisp_lookupcolour_rgb332;
+ dd->fp_lookupgrey = serdisp_lookupgrey_rgb332;
+ }
+ } else {
+ dd->fp_transcolour = serdisp_transcolour_grey8;
+ dd->fp_transgrey = serdisp_transgrey_grey8;
+ dd->fp_lookupcolour = serdisp_lookupcolour_grey8;
+ dd->fp_lookupgrey = serdisp_lookupgrey_grey8;
+ }
+ break;
+ case 12:
+ if (SD_CS_ISBGR(dd))
+ return -1;
+ dd->fp_transcolour = serdisp_transcolour_rgb444;
+ dd->fp_transgrey = serdisp_transgrey_rgb444;
+ dd->fp_lookupcolour = serdisp_lookupcolour_rgb444;
+ dd->fp_lookupgrey = serdisp_lookupgrey_rgb444;
+ break;
+ case 16:
+ if (dd->colour_spaces & SD_CS_RGB565) {
+ if (SD_CS_ISBGR(dd)) {
+ dd->fp_transcolour = serdisp_transcolour_bgr565;
+ dd->fp_transgrey = serdisp_transgrey_bgr565;
+ dd->fp_lookupcolour = serdisp_lookupcolour_bgr565;
+ dd->fp_lookupgrey = serdisp_lookupgrey_bgr565;
+ } else {
+ dd->fp_transcolour = serdisp_transcolour_rgb565;
+ dd->fp_transgrey = serdisp_transgrey_rgb565;
+ dd->fp_lookupcolour = serdisp_lookupcolour_rgb565;
+ dd->fp_lookupgrey = serdisp_lookupgrey_rgb565;
+ }
+ }
+ break;
+ case 18:
+ if (SD_CS_ISBGR(dd))
+ return -1;
+ dd->fp_transcolour = serdisp_transcolour_rgb666;
+ dd->fp_transgrey = serdisp_transgrey_rgb666;
+ dd->fp_lookupcolour = serdisp_lookupcolour_rgb666;
+ dd->fp_lookupgrey = serdisp_lookupgrey_rgb666;
+ break;
+ case 24:
+ if (SD_CS_ISBGR(dd))
+ return -1;
+ dd->fp_transcolour = serdisp_transcolour_rgb888;
+ dd->fp_transgrey = serdisp_transgrey_rgb888;
+ dd->fp_lookupcolour = serdisp_lookupcolour_rgb888;
+ dd->fp_lookupgrey = serdisp_lookupgrey_rgb888;
+ break;
+ case 32:
+ if (SD_CS_ISBGR(dd))
+ return -1;
+ dd->fp_transcolour = serdisp_transcolour_rgba888;
+ dd->fp_transgrey = serdisp_transgrey_rgba888;
+ dd->fp_lookupcolour = serdisp_lookupcolour_rgba888;
+ dd->fp_lookupgrey = serdisp_lookupgrey_rgba888;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
/**
@@ -302,6 +458,22 @@
return ( (( colour & 0x00F80000L) >> 19) | ((colour & 0x0000FC00L) >> 5) | ((colour & 0x000000F8L) << 8) );
}
+/* 8 bit colour part -> 6 bit by throwing away 2 least significant bits */
+/* 0xAARRGGBB -> 6bit R 6bit G 6bit B */
+long serdisp_transcolour_rgb666 (serdisp_t* dd, long colour) {
+ return ( (( colour & 0x00FC0000L) >> 6) | ((colour & 0x0000FC00L) >> 4) | ((colour & 0x000000FCL) >> 2) );
+}
+
+/* truecolour without alpha */
+long serdisp_transcolour_rgb888 (serdisp_t* dd, long colour) {
+ return ( colour & 0x00FFFFFFL );
+}
+
+/* truecolour with alpha */
+long serdisp_transcolour_rgba888 (serdisp_t* dd, long colour) {
+ return colour;
+}
+
/* *********************************
@@ -360,6 +532,20 @@
return ( ((0xF8 & (long)greyvalue) << 8) | ((0xFC & (long)greyvalue) <<3 ) | ((0xF8 & (long)greyvalue) >> 3) );
}
+long serdisp_transgrey_rgb666 (serdisp_t* dd, byte greyvalue) {
+ return ( ((long)(0xFC & greyvalue) << 10) | ((long)(0xFC & greyvalue) <<4 ) | ((long)(0xFC & greyvalue) >> 2) );
+}
+
+/* truecolour without alpha */
+long serdisp_transgrey_rgb888 (serdisp_t* dd, byte greyvalue) {
+ return ( ((long)greyvalue << 16) | ((long)greyvalue << 8) | (long)greyvalue );
+}
+
+/* truecolour with alpha */
+long serdisp_transgrey_rgba888 (serdisp_t* dd, byte greyvalue) {
+ return ( 0xFF000000L | ((long)greyvalue << 16) | ((long)greyvalue << 8) | (long)greyvalue );
+}
+
/* *********************************
@@ -412,6 +598,21 @@
return ( 0xFF070307L | ((0x001FL & colour) << 19 ) | ((0x07E0L & colour) << 5 ) | ((0xF800L & colour) >> 8 ) );
}
+/* 6bit R 6bit G 6bit B -> 0xAARRGGBB */
+long serdisp_lookupcolour_rgb666(serdisp_t* dd, long colour) {
+ return ( 0xFF030303L | ((0x03F000L & colour) << 6 ) | ((0x000FC0L & colour) << 4 ) | ((0x00003FL & colour) << 2 ) );
+}
+
+/* truecolour without alpha */
+long serdisp_lookupcolour_rgb888 (serdisp_t* dd, long colour) {
+ return ( 0xFF000000L | colour );
+}
+
+/* truecolour with alpha */
+long serdisp_lookupcolour_rgba888 (serdisp_t* dd, long colour) {
+ return colour;
+}
+
/* *********************************
@@ -460,6 +661,16 @@
return ( serdisp_ARGB2GREY(serdisp_lookupcolour_bgr565(dd, colour)) );
}
+byte serdisp_lookupgrey_rgb666(serdisp_t* dd, long colour) {
+ return ( serdisp_ARGB2GREY(serdisp_lookupcolour_rgb666(dd, colour)) );
+}
+/* truecolour without alpha */
+byte serdisp_lookupgrey_rgb888 (serdisp_t* dd, long colour) {
+ return ( serdisp_ARGB2GREY(serdisp_lookupcolour_rgb888(dd, colour)) );
+}
-
+/* truecolour with alpha */
+byte serdisp_lookupgrey_rgba888 (serdisp_t* dd, long colour) {
+ return ( serdisp_ARGB2GREY(serdisp_lookupcolour_rgba888(dd, colour)) );
+}
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_connect.c
^
|
@@ -1,7 +1,7 @@
/** \file serdisp_connect.c
*
* \brief Functions for accessing supported output devices (parport, serial device, ..)
- * \date (C) 2003-2008
+ * \date (C) 2003-2010
* \author wolfgang astleitner (mrwastl@users.sourceforge.net)
*/
@@ -52,6 +52,7 @@
#include "serdisplib/serdisp_connect.h"
#include "serdisplib/serdisp_tools.h"
#include "serdisplib/serdisp_messages.h"
+#include "serdisplib/serdisp_fctptr.h"
#ifdef HAVE_LIBUSB
#include "serdisplib/serdisp_connect_usb.h"
@@ -130,6 +131,7 @@
,{"HIDDEV", SDCT_HIDDEV, "" }
#endif
,{"RS232", SDCT_RS232, "" }
+ ,{"OUT", SDCT_OUT, "" }
};
@@ -196,7 +198,7 @@
} serdisp_defaultdevs_t;
-/* devices where the corresponding protocol is pre-defined */
+/* devices where the corresponding connection type is pre-defined */
/* -> instead of PARPORT:/dev/parport0 one may simply write: /dev/parport0 */
serdisp_defaultdevs_t serdisp_defaultdevices[] = {
{"/dev/parport", "PARPORT", SD_MATCHMODE_STARTSWITH }
@@ -216,6 +218,8 @@
#endif
};
+/* internal functions */
+static int SDCONN_confinit (serdisp_CONN_t* sdcd);
/**
@@ -223,13 +227,13 @@
*
* \param sdcdev device name or port-number of device to open
*
- * \b Format: <tt>[protocol:]device</tt>
- * \li protocol is case insensitive
- * \li no protocol is needed for known devices (list below)
+ * \b Format: <tt>[conntype:]device</tt>
+ * \li conntype (connection type) is case insensitive
+ * \li no connection type is needed for known devices (list below)
*
* <b>List of known devices:</b>
\verbatim
- device protocol remark
+ device conntype remark
---------------- -------- ----------------------------------------
/dev/parportX PAR or PARPORT (alias name)
/dev/ppiX PAR bsd
@@ -253,7 +257,7 @@
"0x3f8" serial port, direct IO, linux x86 only
"serraw:/dev/ttyS0" serial device, ioctl
- "SERRAW:/dev/ttyS0" the same as above because protocol is case-insensitive
+ "SERRAW:/dev/ttyS0" the same as above because connection type is case-insensitive
"SERPORT:/dev/ttyS0" the same because SERPORT and SERRAW are synonyms
"serraw:0x3f8" serial device, direct IO
"par:/dev/parport0" linux, ioctl \endverbatim
@@ -267,9 +271,9 @@
*/
serdisp_CONN_t* SDCONN_open(const char sdcdev[]) {
serdisp_CONN_t* sdcd = 0;
- char protocol[20];
+ char connproto[20];
char* devname;
- char* idx; /* index of ':' in protocol:devicename */
+ char* idx; /* index of ':' in conntype:devicename */
int found = 0;
int i = 0;
@@ -281,17 +285,35 @@
struct ecpp_regs eregs;
#endif /* !defined (__sun__) */
+ /* initialise function pointers */
+ SDFCTPTR_init();
/* forward USB-specific devices to SDCONNusb_open() */
- if (strncasecmp(sdcdev, "USB", 3) == 0) {
+ if (strncasecmp(sdcdev, "USB:", 4) == 0 || strncasecmp(sdcdev, "USB@", 4) == 0) {
#ifdef HAVE_LIBUSB
return SDCONNusb_open(sdcdev);
#else
- sd_error(SERDISP_ENOPROTOOPT, "libusb-based protocols are disabled (library has been built without libusb-support)");
+ sd_error(SERDISP_ENOPROTOOPT, "libusb-based connections are disabled (library has been built without libusb-support)");
return (serdisp_CONN_t*)0;
#endif /* HAVE_LIBUSB */
}
+ /* setup dummy sdcd-struct for output drivers */
+ if (strncasecmp(sdcdev, "OUT:", 4) == 0) {
+ sdcd = (serdisp_CONN_t*)sdtools_malloc( sizeof(serdisp_CONN_t) );
+ if( !sdcd ) {
+ sd_error(SERDISP_EMALLOC, "%s(): unable to allocate memory for sdcd", __func__);
+ return NULL;
+ }
+ memset( sdcd, 0, sizeof(serdisp_CONN_t) );
+ sdcd->sdcdev = (char*)sdcdev;
+ sdcd->conntype = SERDISPCONNTYPE_OUT;
+ sdcd->hardwaretype = SDHWT_OUT;
+
+ return sdcd;
+ }
+
+
if (! (sdcd = (serdisp_CONN_t*)sdtools_malloc(sizeof(serdisp_CONN_t)) ) ) {
return (serdisp_CONN_t*)0;
}
@@ -303,7 +325,7 @@
/* no device given -> use default device */
sdcd->sdcdev = (sdcdev == 0 || strlen((char*)sdcdev) > 0) ? (char*)sdcdev : SERDISP_DEFAULTDEVICE;
- /* split into protocol and device name */
+ /* split into connection type (+ protocol) and device name */
idx = index(sdcd->sdcdev, ':');
if (!idx) {
devname = sdcd->sdcdev;
@@ -336,19 +358,26 @@
SDCONN_close(sdcd);
return (serdisp_CONN_t*)0;
} else {
- strcpy(protocol, serdisp_defaultdevices[i].connname);
+ strcpy(connproto, serdisp_defaultdevices[i].connname);
}
} else {
- sdtools_strncpy(protocol, sdcd->sdcdev, ((18 < serdisp_ptrdistance(idx, sdcd->sdcdev)) ? 18 : serdisp_ptrdistance(idx, sdcd->sdcdev)));
- protocol[(18 < serdisp_ptrdistance(idx, sdcd->sdcdev)) ? 18 : serdisp_ptrdistance(idx, sdcd->sdcdev)] = '\0';
+ sdtools_strncpy(connproto, sdcd->sdcdev, ((18 < serdisp_ptrdistance(idx, sdcd->sdcdev)) ? 18 : serdisp_ptrdistance(idx, sdcd->sdcdev)));
+ connproto[(18 < serdisp_ptrdistance(idx, sdcd->sdcdev)) ? 18 : serdisp_ptrdistance(idx, sdcd->sdcdev)] = '\0';
devname = (idx+1);
}
+ /* separate connection type from protocol */
+ if (index(connproto, '@')) {
+ sd_error(SERDISP_EDEVNOTSUP, "protocol differentiation 'conntype@protocol' is not yet supported by this connection type");
+ SDCONN_close(sdcd);
+ return (serdisp_CONN_t*)0;
+ }
+
i = 0;
found = 0;
- /* look if given protocol is suppported */
+ /* look if given connection type is suppported */
while (!found && i < sizeof(serdisp_connection_types) / sizeof(serdisp_conntype_t) ) {
- if (strncasecmp(protocol, serdisp_connection_types[i].connname, 18) == 0) {
+ if (strncasecmp(connproto, serdisp_connection_types[i].connname, 18) == 0) {
found = 1;
} else {
i++;
@@ -356,6 +385,7 @@
}
if (!found) {
+ sd_error(SERDISP_EDEVNOTSUP, "connection type '%s' is not supported", connproto);
free (sdcd);
return (serdisp_CONN_t*)0;
}
@@ -587,7 +617,7 @@
}
- if ((sdcd->fd = open(devname, O_RDWR)) < 0) {
+ if ((sdcd->fd = open(devname, O_RDWR | O_NONBLOCK)) < 0) {
sd_error(SERDISP_ENXIO, "opening device %s failed (cause: %s)", devname, strerror(errno));
SDCONN_close(sdcd);
return (serdisp_CONN_t*)0;
@@ -660,7 +690,6 @@
}
#endif /* defined(__sd_available_hiddev__) */
} else if (sdcd->conntype == SERDISPCONNTYPE_RS232) {
- int tiocm;
gen_stream_device_t* streamitems;
if (! (sdcd->extra = (void*)sdtools_malloc(sizeof(gen_stream_device_t)) ) ) {
@@ -682,7 +711,8 @@
streamitems->streampos = 0;
- if ((sdcd->fd = open(devname, O_RDWR)) < 0) {
+ /* if O_NDELAY is used goldelox will fail */
+ if ((sdcd->fd = open(devname, O_RDWR | O_NOCTTY)) < 0) {
sd_error(SERDISP_ENXIO, "opening device %s failed (cause: %s)", devname, strerror(errno));
SDCONN_close(sdcd);
return (serdisp_CONN_t*)0;
@@ -698,43 +728,24 @@
SDCONN_close(sdcd);
return (serdisp_CONN_t*)0;
}
+#if 0
+ {
+ int tiocm = TIOCM_DTR;
+ ioctl(sdcd->fd, TIOCMSET, &tiocm); /* control the reset pin */
-#if defined(__sun__)
- /* solaris doesn't support cfmakeraw() and cfsetspeed() */
- sdcd->termstate.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
-
- sdcd->termstate.c_oflag &= ~OPOST;
- sdcd->termstate.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
- sdcd->termstate.c_cflag &= ~(CSIZE|PARENB);
- sdcd->termstate.c_cflag |= CS8;
-
- cfsetospeed( &(sdcd->termstate), B230400); /* set initial baudrate */
-#else
- cfmakeraw( &(sdcd->termstate) );
- cfsetspeed( &(sdcd->termstate), B230400); /* set initial baudrate */
-#endif
-
- tiocm = TIOCM_DTR;
- ioctl(sdcd->fd, TIOCMSET, &tiocm); /* control the reset pin */
-
- tiocm = 0;
- ioctl(sdcd->fd, TIOCMGET, &tiocm);
+ tiocm = 0;
+ ioctl(sdcd->fd, TIOCMGET, &tiocm);
- if (tiocm & TIOCM_DTR) {
- sd_debug(2, "%s(): DTR is set on device %s", __func__, devname);
- } else {
- sd_debug(1, "%s(): DTR is NOT set on device %s", __func__, devname);
- }
-
- if (tcsetattr(sdcd->fd, TCSANOW, &(sdcd->termstate)) < 0) {
- sd_error(SERDISP_ENXIO, "setting attributes for device %s failed (cause: %s)", devname, strerror(errno));
- SDCONN_close(sdcd);
- return (serdisp_CONN_t*)0;
+ if (tiocm & TIOCM_DTR) {
+ sd_debug(2, "%s(): DTR is set on device %s", __func__, devname);
+ } else {
+ sd_debug(1, "%s(): DTR is NOT set on device %s", __func__, devname);
+ }
}
+#endif
- tcflush(sdcd->fd, TCIOFLUSH); /* flush buffers */
-
- usleep(2);
+ /* extra configuration and initialisation will be done by SDCONN_confinit() prior to 1st read/write operation */
+ sdcd->needs_confinit = 1;
} else { /* unsupported connection type */
free (sdcd);
return (serdisp_CONN_t*)0;
@@ -749,6 +760,9 @@
* \param sdcd serdisp connect descriptor
*/
void SDCONN_close(serdisp_CONN_t* sdcd) {
+ if (sdcd->hardwaretype & SDHWT_OUT) {
+ ;
+ } else
#ifdef HAVE_LIBUSB
if (sdcd->hardwaretype & SDHWT_USB) {
SDCONNusb_close(sdcd);
@@ -844,6 +858,114 @@
}
+/* *********************************
+ int SDCONN_confinit(sdcd)
+ *********************************
+ extra configuration and initialisation before first write/commit/read-operations
+ *********************************
+ sdcd ... serdisp connect descriptor
+ *********************************
+ returns:
+ 0 ... no configuration needed
+ 1 ... confinit successful
+ -1 ... extra/delayed configuration not supported by this device
+ -2 ... unsupported configuration
+*/
+int SDCONN_confinit(serdisp_CONN_t* sdcd) {
+ if (!sdcd->needs_confinit) /* bail out if no extra configuration is needed */
+ return 0;
+
+#ifdef HAVE_LIBUSB
+ if (sdcd->hardwaretype & SDHWT_USB) {
+ return SDCONNusb_confinit(sdcd);
+ }
+#endif
+ if (sdcd->hardwaretype & SDHWT_OUT) {
+ return 0;
+ }
+
+ /* may only be called once */
+ sdcd->needs_confinit = 0;
+
+ if (sdcd->conntype == SERDISPCONNTYPE_RS232) {
+ unsigned int baudrate = (sdcd->rs232.baudrate) ? sdcd->rs232.baudrate : B1200;
+
+/* pre-init raw-transfer */
+#if defined(__sun__)
+ /* solaris doesn't support cfmakeraw() */
+ sdcd->termstate.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+
+ sdcd->termstate.c_oflag &= ~OPOST;
+ sdcd->termstate.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+ sdcd->termstate.c_cflag &= ~(CSIZE|PARENB);
+ sdcd->termstate.c_cflag |= CS8;
+#else
+ cfmakeraw( &(sdcd->termstate) );
+#endif
+
+#if defined(__sun__)
+ /* solaris doesn't support cfsetspeed() */
+ cfsetospeed( &(sdcd->termstate), baudrate); /* set initial baudrate */
+#else
+ cfsetspeed( &(sdcd->termstate), baudrate); /* set initial baudrate */
+#endif
+
+ /* set amount of data bits */
+ sdcd->termstate.c_cflag &= ~CSIZE; /* bit mask for data bits */
+ switch(sdcd->rs232.c_cs8_decr) {
+ case 1: sdcd->termstate.c_cflag |= CS7; break;
+ case 2: sdcd->termstate.c_cflag |= CS6; break;
+ case 3: sdcd->termstate.c_cflag |= CS5; break;
+ default: sdcd->termstate.c_cflag |= CS8; break;
+ }
+
+ if (sdcd->rs232.c_cstopb)
+ sdcd->termstate.c_cflag |= CSTOPB; /* 2 stop bits */
+ else
+ sdcd->termstate.c_cflag &= ~CSTOPB; /* 1 stop bits (default) */
+
+ if (sdcd->rs232.c_parenb)
+ sdcd->termstate.c_cflag |= PARENB; /* enable parent bit */
+ else
+ sdcd->termstate.c_cflag &= ~PARENB; /* don't enable parent bit (default) */
+
+ if (sdcd->rs232.c_parodd)
+ sdcd->termstate.c_cflag |= PARODD; /* odd parity instead of even */
+ else
+ sdcd->termstate.c_cflag &= ~PARODD; /* even parity (default) */
+
+ if (sdcd->rs232.c_cread)
+ sdcd->termstate.c_cflag |= CREAD; /* enable receiver */
+ else
+ sdcd->termstate.c_cflag &= ~CREAD; /* don't enable receiver (default) */
+
+ if (sdcd->rs232.c_local)
+ sdcd->termstate.c_cflag |= CLOCAL; /* enable local line */
+ else
+ sdcd->termstate.c_cflag &= ~CLOCAL; /* don't enable local line (default) */
+
+ if (sdcd->rs232.c_rtscts)
+ sdcd->termstate.c_cflag |= CRTSCTS; /* enable hardware flow control */
+ else
+ sdcd->termstate.c_cflag &= ~CRTSCTS; /* no hardware flow control (default) */
+
+ if (tcsetattr(sdcd->fd, TCSANOW, &(sdcd->termstate)) < 0) {
+ sd_error(SERDISP_ENXIO, "setting attributes for device '%s' failed (cause: %s)", sdcd->sdcdev, strerror(errno));
+ /*SDCONN_close(sdcd);*/
+ sd_runtimeerror = 1;
+ return -2;
+ }
+
+ tcflush(sdcd->fd, TCIOFLUSH); /* flush buffers */
+
+ usleep(2);
+ return 1;
+ } else {
+ /* should never ever occur, but if it happenes to be: sdcd->need_config is mis-configured in driver! */
+ sd_error(SERDISP_ERUNTIME, "%s(): switch-case: extra config./init. not supported by device!", __func__);
+ }
+ return -1;
+}
/* *********************************
@@ -876,6 +998,9 @@
if (sd_runtime_error())
return;
+ if (sdcd->needs_confinit)
+ SDCONN_confinit(sdcd);
+
/* if 'flags' is not set: use io_flags_default set in serdisp descriptor */
if (!flags)
flags = sdcd->io_flags_default;
@@ -1132,6 +1257,9 @@
if (sd_runtime_error())
return 0;
+ if (sdcd->needs_confinit)
+ SDCONN_confinit(sdcd);
+
#ifdef HAVE_LIBUSB
if (sdcd->hardwaretype & SDHWT_USB) {
return SDCONNusb_read(sdcd, flags);
@@ -1257,6 +1385,51 @@
/* *********************************
+ int SDCONN_readstream(sdcd, buf, count)
+ *********************************
+ read a stream from the serdisp connect device into a buffer
+ *********************************
+ sdcd ... serdisp connect descriptor
+ buf ... buffer for stream
+ count ... read up to 'count' bytes info the buffer (note: count <= sizeof(buf) !!!)
+ *********************************
+ returns the number of bytes read.
+ 0 ... indicates end of stream
+ -1 ... error when reading stream
+ =================================================
+
+*/
+int SDCONN_readstream(serdisp_CONN_t* sdcd, byte* buf, int count) {
+ int rc = 0;
+
+ if (sd_runtime_error())
+ return 0;
+
+ if (sdcd->needs_confinit)
+ SDCONN_confinit(sdcd);
+
+#ifdef HAVE_LIBUSB
+ if (sdcd->hardwaretype & SDHWT_USB) {
+ return SDCONNusb_readstream(sdcd, buf, count);
+ } else
+#endif /* HAVE_LIBUSB */
+
+ rc = read(sdcd->fd, buf, count);
+
+ if( rc < 0 ) {
+ if ( errno!=EAGAIN ) {
+ sd_error(SERDISP_ERUNTIME, "%s(): could not read from device: %s (%d)", __func__, strerror(errno), errno);
+ } else {
+ usleep(100);
+ }
+ }
+
+ return rc;
+}
+
+
+
+/* *********************************
void SDCONN_commit(sdcd)
*********************************
commits an usb fast write stream (in non-usb modes and non-streaming usb modes: no effect)
@@ -1264,6 +1437,9 @@
sdcd ... serdisp connect descriptor
*/
void SDCONN_commit(serdisp_CONN_t* sdcd) {
+ if (sdcd->needs_confinit)
+ SDCONN_confinit(sdcd);
+
#ifdef HAVE_LIBUSB
if (sdcd->hardwaretype & SDHWT_USB) {
SDCONNusb_commit(sdcd);
@@ -1410,6 +1586,13 @@
if (idxpos)
n = serdisp_ptrstrlen(idxpos, str);
+ /* ',' or ';' may end the signal name */
+ if (!idxpos) {
+ idxpos = index(str, ';');
+ if (idxpos)
+ n = serdisp_ptrstrlen(idxpos, str);
+ }
+
i = 0;
while (i < sizeof(serdisp_signalnames) / sizeof(serdisp_signalnames_t) ) {
if ((serdisp_signalnames[i].conntype == conntype) &&
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_connect_usb.c
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -65,67 +65,14 @@
#include "serdisplib/serdisp_tools.h"
#include "serdisplib/serdisp_messages.h"
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- #include <pthread.h>
+#include "serdisplib/serdisp_fctptr.h"
+#ifdef HAVE_LIBPTHREAD
pthread_mutex_t mutex_usb = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex_commit = PTHREAD_MUTEX_INITIALIZER;
+#endif
- extern int fp_initialised;
-
- extern void* libhnd_pthread;
-
- extern int (*fp_pthread_mutex_lock) (pthread_mutex_t* mutex);
- extern int (*fp_pthread_mutex_unlock) (pthread_mutex_t* mutex);
-
-
- extern void* libhnd_usb;
-
- extern void (*fp_usb_init) (void);
- extern usb_dev_handle* (*fp_usb_open) (struct usb_device* dev);
- extern int (*fp_usb_close) (usb_dev_handle* dev);
- extern int (*fp_usb_reset) (usb_dev_handle* dev);
- extern int (*fp_usb_interrupt_read) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
- extern int (*fp_usb_release_interface)(usb_dev_handle* dev, int interface);
- extern int (*fp_usb_find_busses) (void);
- extern int (*fp_usb_find_devices) (void);
- extern struct usb_bus* (*fp_usb_get_busses) (void);
- extern int (*fp_usb_claim_interface) (usb_dev_handle* dev, int interface);
-
- extern int (*fp_usb_bulk_read) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
- extern int (*fp_usb_bulk_write) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
- extern int (*fp_usb_control_msg) (usb_dev_handle* dev, int requesttype, int request,
- int value, int index, char *bytes, int size, int timeout);
- extern int (*fp_usb_clear_halt) (usb_dev_handle *dev, unsigned int ep);
-
- extern int (*fp_usb_set_altinterface) (usb_dev_handle *dev, int alternate);
- extern int (*fp_usb_set_configuration)(usb_dev_handle *dev, int configuration);
-
- extern int (*fp_usb_detach_kernel_driver_np) (usb_dev_handle* dev, int interface);
-#else
- #define fp_usb_init usb_init
- #define fp_usb_open usb_open
- #define fp_usb_close usb_close
- #define fp_usb_reset usb_reset
- #define fp_usb_interrupt_read usb_interrupt_read
- #define fp_usb_release_interface usb_release_interface
- #define fp_usb_find_busses usb_find_busses
- #define fp_usb_find_devices usb_find_devices
- #define fp_usb_get_busses usb_get_busses
- #define fp_usb_claim_interface usb_claim_interface
-
- #define fp_usb_bulk_read usb_bulk_read
- #define fp_usb_bulk_write usb_bulk_write
- #define fp_usb_control_msg usb_control_msg
- #define fp_usb_clear_halt usb_clear_halt
-
- #define fp_usb_set_altinterface usb_set_altinterface
- #define fp_usb_set_configuration usb_set_configuration
-
- #define fp_usb_detach_kernel_driver_np usb_detach_kernel_driver_np
-#endif /* SERDISP_VERSION_CODE */
-
/* supported usb-devices */
typedef struct serdisp_usbdevice_s {
int vendorID;
@@ -142,8 +89,10 @@
serdisp_usbdevices_t usbdevices[] = {
/* vendorID productID bcdDevice deviceID streamsize claim maxIO */
{0x07C0, 0x1501, -1, SDHWT_USBIOW24, 8, 0xFF, 16 }
- ,{0x060C, 0x04EB, -1, SDHWT_USBALPHACOOL, 8, 0x01, 16 }
+ ,{0x060C, 0x04EB, -1, SDHWT_USBALPHACOOL, 8, 0x00, 16 }
,{0x4243, 0xee08, -1, SDHWT_USBL4ME5I, 60, 0x00, 16 }
+ ,{0x16C0, 0x08A2, -1, SDHWT_USB13700, 32768, 0xFF, 16 }
+ ,{0x152A, 0x8380, -1, SDHWT_USBSDCMEGTRON, 8, 0x00, 16 }
#ifdef ENABLE_FTDI
,{0x0403, 0x6010, 0x0500, SDHWT_USBFTDI2232, 4096, 0xFF, 16 }
,{0x0403, 0x6001, 0x0200, SDHWT_USBFTDI245, 4096, 0xFF, 8 }
@@ -152,25 +101,12 @@
};
-
-#if (SERDISP_VERSION_CODE <= SERDISP_VERSION(1,97))
-/* local impl. of usb_detach_kernel_driver_np */
-#ifndef HAVE_USB_DETACH_KERNEL_DRIVER_NP
-int usb_detach_kernel_driver_np(usb_dev_handle* dev, int interface) {
- sd_debug(0, "usb_detach_kernel_driver_np(): *** this function is not provided in this version of libusb.");
- sd_debug(0, "usb_detach_kernel_driver_np(): *** either upgrade libusb to at least version 0.8 or you'll");
- sd_debug(0, "usb_detach_kernel_driver_np(): *** have to detach kernel modules by yourself.");
- return 0;
-}
-#endif /* HAVE_USB_DETACH_KERNEL_DRIVER_NP */
-#endif /* SERDISP_VERSION_CODE */
-
-
/* internal functions */
-usb_dev_handle* SDCONNusb_find (int vendorID, int productID, int bcdDevice, int occurrence,
- int* dev_idx, struct usb_device** dev_ptr
+static
+usb_dev_handle* SDCONNusb_find (int vendorID, int productID, int bcdDevice, char* hr_name,
+ int occurrence, int* dev_idx, struct usb_device** dev_ptr
);
-int SDCONNusb_claim_interfaces (serdisp_CONN_t* sdcd, byte ifmask, unsigned char* claimed);
+static int SDCONNusb_claim_interfaces (serdisp_CONN_t* sdcd, byte ifmask, unsigned char* claimed);
/* *********************************
@@ -178,19 +114,35 @@
*********************************
opens an usb device for a serdisp lcd
*********************************
- sdcdev ... device identifier. format:
-
- devid = 'USB:' [ occurrence ':' ] ( PRODUCT | DEVICENAME )
+ sdcdev ... device identifier.
+
+ format:
+
+ sdcdev = CONNTYPE [ '@' PROTOCOL ] ':' [ occurrence ':' ] ( PRODUCT | DEVICENAME )
+ CONNTYPE = 'USB'
+ PROTOCOL = 'SPI'
PRODUCT = vendorID '/' productID [ '/' bcdDevice ]
- DEVICENAME = manufacturer '/' productdesc (not implemented yet)
+ DEVICENAME = [ [ manufacturer ] '/' ] product [ '/' serial ]
+
+
+ annotations:
+ DEVICENAME supported since rev.183
+ PROTOCOL supported since rev. 192
+
+ if PRODUCT-items (vendorID, productID, bcdDevice) are not numeric (hexadecimal with or without leading '0x')
+ than DEVICENAME is assumed
+
- examples:
- "USB:0x0403/0x6010/0x0500" (vendorID = 0x0403, productID = 0x6010, bcdDevice = 0x500)
- "USB:403/6010" (the same, w/o bcdDevice (first device matching 403/6010 is returned))
- not implemented yet:
- "USB:FTDI/DLP2232M" (identified through manufacturer info and product description)
- "USB:0:FTDI/DLP2232M" (the same, fist occurrence (default))
- "USB:1:FTDI/DLP2232M" (the same, but 2nd occurrence (if > 1 DLP2232M are connected))
+ examples:
+ "USB:0x0403/0x6010/0x0500" (vendorID = 0x0403, productID = 0x6010, bcdDevice = 0x500)
+ "USB:403/6010" (the same, w/o bcdDevice (first device matching 403/6010 is returned))
+
+ "USB:FTDI/DLP2232M" (identified through manufacturer info and product description)
+ "USB:DLP2232M" (the same, but only product name as identification)
+ "USB:0:FTDI/DLP2232M" (the same, first occurrence (default))
+ "USB:1:FTDI/DLP2232M" (the same, but 2nd occurrence (if > 1 DLP2232M are connected))
+
+ "USB@SPI:DLP2232M" protcol is SPI (instead of default emulated signalling)
*********************************
returns a serdisp connect descriptor or (serdisp_CONN_t*)0 if operation was unsuccessful
@@ -201,33 +153,47 @@
struct usb_device* dev = 0;
usb_dev_handle* usb_dev = 0;
char* devname;
- char protocol[20];
+ char* hr_name;
+ char connproto[20];
char buffer[10];
- char* idx; /* index of ':' in protocol:devicename */
+ char* idx; /* index of ':' in conntype:devicename */
char* endptr; /* for strtol */
int occurrence = 0;
int vendorID = -1;
int productID = -1;
int bcdDevice = -1;
int dev_idx;
+ char* idx_proto;
+ int protocol;
serdisp_usbdev_t* usbitems = (serdisp_usbdev_t*)0;
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- /* function pointers for libusb-functions not initialised -> bail out */
- if (!libhnd_usb)
+ if ( ! SDFCTPTR_checkavail(SDFCTPTR_LIBUSB) ) {
+ sd_error(SERDISP_ERUNTIME, "%s(): libusb is not loaded.", __func__);
return (serdisp_CONN_t*)0;
-#endif
+ }
devname = (char*)sdcdev;
idx = index(devname, ':');
if (serdisp_ptrdistance(idx, devname) >= 18) {
- sd_error(SERDISP_ENXIO, "%s(): invalid protocol (too long)", __func__);
+ sd_error(SERDISP_ENXIO, "%s(): invalid connection type / protocol (too long)", __func__);
return (serdisp_CONN_t*)0;
}
- sdtools_strncpy(protocol, devname, serdisp_ptrdistance(idx, devname));
+ sdtools_strncpy(connproto, devname, serdisp_ptrdistance(idx, devname));
+
+ protocol = SDPROTO_DONTCARE; /* default: don't care about protocol */
+ idx_proto = index(connproto, '@');
+ if (idx_proto) {
+ if (sdtools_ismatching("SPI", -1, idx_proto+1, -1)) {
+ protocol = SDPROTO_SPI;
+ } else {
+ sd_error(SERDISP_EDEVNOTSUP, "protocol '%s' is undefined", idx_proto+1);
+ return (serdisp_CONN_t*)0;
+ }
+ }
+
devname = (idx+1);
idx = index(devname, ':');
@@ -242,6 +208,8 @@
occurrence = (int)strtol(buffer, 0, 10);
}
+ hr_name = devname; /* "vendorID/productID[/bcdDevice]" might also be "[manufacturer]/product[/serial]" */
+
idx = index(devname, '/');
if (idx && serdisp_ptrdistance(idx, devname) < 7) {
sdtools_strncpy(buffer, devname, serdisp_ptrdistance(idx, devname));
@@ -282,7 +250,7 @@
}
}
- usb_dev = SDCONNusb_find(vendorID, productID, bcdDevice, occurrence, &dev_idx, &dev);
+ usb_dev = SDCONNusb_find(vendorID, productID, bcdDevice, hr_name, occurrence, &dev_idx, &dev);
if (usb_dev) {
if (! (sdcd = (serdisp_CONN_t*)sdtools_malloc(sizeof(serdisp_CONN_t)) ) ) {
@@ -295,6 +263,7 @@
sdcd->conntype = SERDISPCONNTYPE_PARPORT;
sdcd->hardwaretype = SDHWT_USB;
+ sdcd->protocol = protocol;
if (! (sdcd->extra = (void*)sdtools_malloc(sizeof(serdisp_usbdev_t)) ) ) {
sd_error(SERDISP_EMALLOC, "%s(): unable to allocate memory for sdcd->extra", __func__);
@@ -325,7 +294,8 @@
usbitems->claimed = 0; /* start with no interfaces claimed */
if (SDCONNusb_claim_interfaces(sdcd, usbdevices[dev_idx].claim, &(usbitems->claimed)) != 0) {
- sd_error(SERDISP_EACCES, "%s(): unable to claim interfaces", __func__);
+ /* SDCONNusb_claim_interfaces() will generate an error message on its own -> use that one */
+ /*sd_error(SERDISP_EACCES, "%s(): unable to claim interfaces", __func__);*/
if (usbitems->usb_dev)
if (fp_usb_close(usbitems->usb_dev)) /* != 0: close failed */
fp_usb_reset(usbitems->usb_dev);
@@ -341,37 +311,36 @@
case SDHWT_USBFTDI2232:
case SDHWT_USBFTDI245:
- if (fp_usb_control_msg(usb_dev, 0x40, 0, 0, 1/*ftdi->index*/, NULL, 0, usbitems->write_timeout) != 0) {
+ usbitems->out_ep = 0x02;
+ usbitems->in_ep = 0x81;
+
+ if (fp_usb_control_msg(usb_dev, 0x40, 0, 0, 1, NULL, 0, usbitems->write_timeout) != 0) {
sd_error(SERDISP_ERUNTIME, "%s(): resetting FTDI-chip failed", __func__);
}
- if (strncasecmp(sdcdev, "USBSPI", 6) == 0) {
- char buf[256];
- sdcd->conntype = SERDISPCONNTYPE_SPI;
+ if (fp_usb_control_msg(usb_dev, 0x40, 0, 1, 1, NULL, 0, usbitems->write_timeout) != 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): FTDI: purging of RX buffer failed", __func__);
+ }
- if (fp_usb_control_msg(usb_dev, 0x40, 0x0B, 0x0200, 1/*ftdi->index*/, NULL, 0, usbitems->write_timeout) != 0) {
- sd_error(SERDISP_ERUNTIME, "%s(): entering MPSSE mode failed", __func__);
- }
+ if (fp_usb_control_msg(usb_dev, 0x40, 0, 2, 1, NULL, 0, usbitems->write_timeout) != 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): FTDI: purging of TX buffer failed", __func__);
+ }
- usbitems->stream[usbitems->streampos++] = 0x80; /* set data bits */
- usbitems->stream[usbitems->streampos++] = 0x00; /* CS=low, DI=low, DO=low, SK=low */
- usbitems->stream[usbitems->streampos++] = 0x0B; /* CS=out, DI=out, DO=out */
-
- usbitems->stream[usbitems->streampos++] = 0x86; /* set clock divisor */
- usbitems->stream[usbitems->streampos++] = 0x00; /* low byte */
- usbitems->stream[usbitems->streampos++] = 0x00; /* high byte */
- /* usbitems->stream[usbitems->streampos++] = 0x85;*/ /* turn off loop-back */
+ if (sdcd->protocol == SDPROTO_SPI) {
+ if (fp_usb_control_msg(usb_dev, 0x40, 0x0B, 0x0200, 1, NULL, 0, usbitems->write_timeout) != 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): entering MPSSE mode failed", __func__);
+ }
- /* empty non-empty read buffer */
- fp_usb_bulk_read(usbitems->usb_dev, 0x81, buf, 256, usbitems->read_timeout);
+ /* extra configuration and initialisation will be done by SDCONNusb_confinit() */
+ sdcd->needs_confinit = 1;
} else { /* sdcd->conntype == SERDISPCONNTYPE_PARPORT */
- if (fp_usb_control_msg(usb_dev, 0x40, 0x0B, 0x0100 | 0xFF , 1/*ftdi->index*/, NULL, 0, usbitems->write_timeout) != 0) {
+ if (fp_usb_control_msg(usb_dev, 0x40, 0x0B, 0x0100 | 0xFF , 1, NULL, 0, usbitems->write_timeout) != 0) {
sd_error(SERDISP_ERUNTIME, "%s(): entering bitbang mode failed", __func__);
}
- if (fp_usb_control_msg(usb_dev, 0x40, 3, 0x0, 1/*ftdi->index*/, NULL, 0, usbitems->write_timeout) != 0) {
+ if (fp_usb_control_msg(usb_dev, 0x40, 3, 0, 0x1, NULL, 0, usbitems->write_timeout) != 0) {
sd_error(SERDISP_ERUNTIME, "%s(): setting baudrate failed", __func__);
}
}
@@ -459,8 +428,32 @@
}
}
break;
- case SDHWT_USBALPHACOOL:
+ case SDHWT_USBALPHACOOL: {
fp_usb_set_configuration(usbitems->usb_dev,1); /* w/o this one, alphacool might fail on init */
+
+ /* if claiming is done before usb_set_configuration() display may hang */
+ SDCONNusb_claim_interfaces(sdcd, 0x01, &(usbitems->claimed));
+ usbitems->out_ep = 0x03;
+ usbitems->in_ep = 0x00;
+ }
+ break;
+ case SDHWT_USBSDCMEGTRON: {
+ fp_usb_set_configuration(usbitems->usb_dev,1); /* w/o this one, alphacool might fail on init */
+
+ /* if claiming is done before usb_set_configuration() display may hang */
+ SDCONNusb_claim_interfaces(sdcd, 0x01, &(usbitems->claimed));
+ usbitems->out_ep = 0x04;
+ usbitems->in_ep = 0x00;
+ }
+ break;
+ case SDHWT_USB13700: {
+ /*fp_usb_set_configuration(usbitems->usb_dev,1);*/
+ usbitems->out_ep = 0x02;
+ usbitems->in_ep = 0x82;
+ /* clean up endpoints */
+ usbitems->read_timeout = 500;
+ fp_usb_clear_halt(usbitems->usb_dev, usbitems->in_ep);
+ }
break;
default:
@@ -541,6 +534,10 @@
break;
case SDHWT_USBALPHACOOL:
break;
+ case SDHWT_USB13700: {
+ /*fp_usb_clear_halt(usbitems->usb_dev, usbitems->out_ep);*/
+ }
+ break;
default: /* should never ever occur */
sd_error(SERDISP_ERUNTIME, "%s(): switch-case: hwtype not defined!!!", __func__);
}
@@ -566,6 +563,72 @@
/* *********************************
+ int SDCONNusb_confinit(sdcd)
+ *********************************
+ extra configuration and initialisation before first write/commit/read-operations
+ *********************************
+ sdcd ... serdisp connect descriptor
+ *********************************
+ returns:
+ 0 ... no configuration needed
+ 1 ... confinit successful
+ -1 ... extra/delayed configuration not supported by this device
+ -2 ... unsupported configuration
+*/
+int SDCONNusb_confinit(serdisp_CONN_t* sdcd) {
+ serdisp_usbdev_t* usbitems = (serdisp_usbdev_t*)(sdcd->extra);
+
+ /* bail out if no extra configuration is needed */
+ if (!sdcd->needs_confinit)
+ return 0;
+
+ /* may only be called once */
+ sdcd->needs_confinit = 0;
+
+ switch (usbdevices[usbitems->devID].deviceID) {
+#ifdef ENABLE_FTDI
+ case SDHWT_USBFTDI2232:
+ case SDHWT_USBFTDI245: {
+ int sig_sk = (sdcd->spi.cpol) ? 0 : 1;
+
+ /* default initialisation if framelen is not set:
+ 3-wire SPI with 1 bit D/C, 8 bit data, CPOL = 1, CPHA = 1, DATA = active high, COMMAND = active low
+ */
+ if (sdcd->spi.framelen == 0) {
+ sdcd->spi.framelen = 5; /* framelen + 4 -> 9 bits */
+ sdcd->spi.cpol = 1; /* SK (SCLK) high */
+ sdcd->spi.cpha = 1; /* DO (SI) write at falling SCLK */
+ sdcd->spi.data_high= 1; /* data = active high; command = active low */
+ }
+
+ if (sdcd->spi.framelen < 4 || sdcd->spi.framelen > 5) {
+ sd_error(SERDISP_ERUNTIME, "%s(): unsupported SPI frame length %d", __func__, sdcd->spi.framelen+4);
+ sd_runtimeerror = 1;
+ return -2;
+ }
+
+ usbitems->stream[usbitems->streampos++] = 0x86; /* set clock divisor */
+ usbitems->stream[usbitems->streampos++] = 0x00; /* low byte */
+ usbitems->stream[usbitems->streampos++] = 0x00; /* high byte */
+
+ usbitems->stream[usbitems->streampos++] = 0x80; /* set data bits */
+ usbitems->stream[usbitems->streampos++] = 0x00 | sig_sk; /* CS=low, DI=low, DO=low */
+ usbitems->stream[usbitems->streampos++] = 0x0B; /* CS=out, DI=out, DO=out */
+
+ /* empty non-empty read buffer */
+ /*fp_usb_bulk_read(usbitems->usb_dev, usbitems->in_ep, buf, 256, usbitems->read_timeout);*/
+ return 1;
+ }
+ break;
+#endif
+ default: /* should never ever occur, but if it happenes to be: sdcd->need_config is mis-configured in driver! */
+ sd_error(SERDISP_ERUNTIME, "%s(): switch-case: extra config./init. not supported by device!", __func__);
+ }
+ return -1;
+}
+
+
+/* *********************************
void SDCONNusb_write(sdcd, ldata, flags)
*********************************
write a byte to the serdisp connect device
@@ -617,29 +680,18 @@
#ifdef ENABLE_FTDI
case SDHWT_USBFTDI2232:
case SDHWT_USBFTDI245:
- if (sdcd->conntype == SERDISPCONNTYPE_PARPORT) {
- usbitems->stream[usbitems->streampos++] = t_data;
- } else { /* SERDISPCONNTYPE_SPI */
- byte chunksize = 3; /* mininum of 3 bytes to send */
+ if (sdcd->protocol == SDPROTO_SPI) {
+ int sig_sk = (sdcd->spi.cpol) ? 0 : 1;
+
+ byte chunksize = 6; /* commit and data/command need 6 bytes in buffer */
+
/* t_flags: 8421 0000
0000 8421
^--- ---- ---x: x=0: t_data == data byte, x=1: t_data == command byte
^---- ---- --1*: commit
^----- ---- -x--: x=0: data = 0, command = 1; x=1: data = 1, command = 0
- ^------ ---- x---: x=0: 9 bit (data/cmd + data); x=1: 8 bit, data/cmd: ADBUS4
- (not implemented yet: only 9bit-mode available for now)
- ^-------- ---x ----: x=0: clean transfer (extra step between D/C-bit and data)
- x=1: display supports saving of extra step
*/
- /* commit or 9bit-mode: 3 more bytes to send (max. total now: 6) */
- if ((t_flags & 0x02) || !(t_flags & 0x04))
- chunksize += 3;
-
- /* extra step between D/C-bit and data: 3 more bytes to send (max. total now: 9) */
- if (!(t_flags & 0x02) || !(t_flags & 0x10))
- chunksize += 3;
-
/* beware of buffer overflow */
if ((usbitems->streampos + chunksize) >= usbitems->streamsize)
SDCONNusb_commit(sdcd);
@@ -647,40 +699,40 @@
if (t_flags & 0x02) { /* t_flags & 0x2 -> commit */
byte lastbit = ((t_data & 0x1) << 1);
- /* commit (CS, SK -> high, then pull CS to low leaving SK high) */
- usbitems->stream[usbitems->streampos++] = 0x80; /* set signals */
- usbitems->stream[usbitems->streampos++] = 0x09 | lastbit; /* CS=high, SK=high */
- usbitems->stream[usbitems->streampos++] = 0x0B; /* CS=out, DO=out, SK=out */
-
- usbitems->stream[usbitems->streampos++] = 0x80; /* set signals */
- usbitems->stream[usbitems->streampos++] = 0x01 | lastbit; /* CS=low, SK=high */
- usbitems->stream[usbitems->streampos++] = 0x0B; /* CS=out, DO=out, SK=out */
+ /* commit (CS -> high, SK -> low, then pull CS to low leaving SK low) */
+ usbitems->stream[usbitems->streampos++] = 0x80; /* set signals */
+ usbitems->stream[usbitems->streampos++] = 0x08 | lastbit | sig_sk; /* CS=high */
+ usbitems->stream[usbitems->streampos++] = 0x0B; /* CS=out, DO=out, SK=out */
+
+ usbitems->stream[usbitems->streampos++] = 0x80; /* set signals */
+ usbitems->stream[usbitems->streampos++] = 0x00 | lastbit | sig_sk; /* CS=low */
+ usbitems->stream[usbitems->streampos++] = 0x0B; /* CS=out, DO=out, SK=out */
} else { /* t_flags & 0x1 == 1: command; t_flags & 0x1 == 0: data */
- byte dc = (t_flags & 0x1);
+ /*byte dc = (t_flags & 0x1);*/
+ byte sig_dc = (t_flags & 0x1);
+ byte write_on_falling = (sdcd->spi.cpol == sdcd->spi.cpha) ? 1 : 0;
/* toggle level of D/C if data-bit==HIGH */
- if (t_flags & 0x4)
- dc = (dc) ? 0 : 1;
+ /*if (t_flags & 0x4)
+ dc = (dc) ? 0 : 1;*/
+ /* toggle active high vs. active low depending on sdcd->spi.data_high; */
+ if (sdcd->spi.data_high)
+ sig_dc = (sig_dc) ? 0 : 1;
- usbitems->stream[usbitems->streampos++] = 0x1B; /* clock out D/C-bit, start with SK=low */
+ /* clock out D/C-bit, data change on raising or falling edge of SK */
+ usbitems->stream[usbitems->streampos++] = 0x1A | write_on_falling;
usbitems->stream[usbitems->streampos++] = 0; /* 1 bit */
- usbitems->stream[usbitems->streampos++] = dc;
-
- if (t_flags & 0x10) { /* faster transfer, but not supported by every display */
- /* clock out data byte to DO, start with SK=high */
- usbitems->stream[usbitems->streampos++] = 0x12;
- } else { /* extra step needed between D/C-bit and data byte */
- usbitems->stream[usbitems->streampos++] = 0x80; /* set signals */
- usbitems->stream[usbitems->streampos++] = 0x00; /* all to low */
- usbitems->stream[usbitems->streampos++] = 0x0B; /* CS=out, DO=out, SK=out */
+ usbitems->stream[usbitems->streampos++] = sig_dc;
- /* clock out data byte to DO, start with SK=low */
- usbitems->stream[usbitems->streampos++] = 0x13;
- }
+ /* clock out data byte to DO, data change on raising or falling edge of SK */
+ usbitems->stream[usbitems->streampos++] = 0x12 | write_on_falling;
usbitems->stream[usbitems->streampos++] = 7; /* clock out 8 bits */
usbitems->stream[usbitems->streampos++] = t_data; /* data byte */
}
+ } else { /* SDPROTO_EMULATION */
+ usbitems->stream[usbitems->streampos++] = t_data;
}
+
if (usbitems->streampos >= usbitems->streamsize)
SDCONNusb_commit(sdcd);
break;
@@ -702,8 +754,8 @@
SDCONNusb_commit(sdcd);
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- if (libhnd_pthread)
+#ifdef HAVE_LIBPTHREAD
+ if ( SDFCTPTR_checkavail(SDFCTPTR_PTHREAD) )
fp_pthread_mutex_lock( &mutex_usb );
#endif
@@ -744,14 +796,14 @@
}
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- if (libhnd_pthread)
+#ifdef HAVE_LIBPTHREAD
+ if ( SDFCTPTR_checkavail(SDFCTPTR_PTHREAD) )
fp_pthread_mutex_unlock( &mutex_usb );
} else if (t_flags == 0x03) { /* enable/disable rc5-mode */
SDCONNusb_commit(sdcd);
- if (libhnd_pthread)
+ if ( SDFCTPTR_checkavail(SDFCTPTR_PTHREAD) )
fp_pthread_mutex_lock( &mutex_usb );
IOW_FILLSTREAM(usbitems->stream, IOW_RC5_ENABLE_REPORT, t_data, 0, 0 ,0,0,0,0);
@@ -769,9 +821,9 @@
sd_error(SERDISP_ERUNTIME, "%s(): IOW/RC5 reading ack report failed", __func__);
}
- if (libhnd_pthread)
+ if ( SDFCTPTR_checkavail(SDFCTPTR_PTHREAD) )
fp_pthread_mutex_unlock( &mutex_usb );
-#endif /* SERDISP_VERSION_CODE */
+#endif /* HAVE_LIBPTHREAD */
} else if (usbitems->laststatus != (t_flags & 0x01) ) {
SDCONNusb_commit(sdcd);
usbitems->laststatus = (t_flags & 0x01);
@@ -827,6 +879,13 @@
}
}
break;
+ case SDHWT_USB13700:
+ {
+ usbitems->stream[usbitems->streampos++] = t_data;
+ if (usbitems->streampos >= usbitems->streamsize)
+ SDCONNusb_commit(sdcd);
+ }
+ break;
};
sdcd->debug_count++;
@@ -876,10 +935,21 @@
if (sd_runtime_error())
return 0;
- rc = fp_usb_interrupt_read(usbitems->usb_dev, usbitems->out_ep, (char*)buf, count, usbitems->read_timeout );
- if( rc<0 )
- if( errno!=EAGAIN )
- sd_error(SERDISP_ERUNTIME, "%s(): IOW/READ could not read from device: %s (%d)", __func__, strerror(errno), errno);
+ switch (usbdevices[usbitems->devID].deviceID) {
+ case SDHWT_USB13700: {
+ rc = fp_usb_bulk_read(usbitems->usb_dev, usbitems->in_ep, (char*)buf, count, usbitems->read_timeout );
+ if( rc<0 )
+ if( errno!=EAGAIN )
+ sd_error(SERDISP_ERUNTIME, "%s(): bulk read could not read from device: %s (%d)", __func__, strerror(errno), errno);
+ }
+ break;
+ default: {
+ rc = fp_usb_interrupt_read(usbitems->usb_dev, usbitems->out_ep, (char*)buf, count, usbitems->read_timeout );
+ if( rc<0 )
+ if( errno!=EAGAIN )
+ sd_error(SERDISP_ERUNTIME, "%s(): IOW/READ could not read from device: %s (%d)", __func__, strerror(errno), errno);
+ }
+ }
return rc;
}
@@ -896,19 +966,19 @@
void SDCONNusb_commit(serdisp_CONN_t* sdcd) {
serdisp_usbdev_t* usbitems = (serdisp_usbdev_t*)(sdcd->extra);
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- if (libhnd_pthread)
- fp_pthread_mutex_lock( &mutex_commit );
+#ifdef HAVE_LIBPTHREAD
+ if ( SDFCTPTR_checkavail(SDFCTPTR_PTHREAD) )
+ fp_pthread_mutex_lock( &mutex_commit );
#endif
if (usbitems->streampos > 0) {
switch (usbdevices[usbitems->devID].deviceID) {
-#ifdef ENABLE_FTDI
+#ifdef ENABLE_FTDI
case SDHWT_USBFTDI2232:
case SDHWT_USBFTDI245:
if(fp_usb_bulk_write(
usbitems->usb_dev,
- 0x02/*ftdi->out_ep*/,
+ usbitems->out_ep,
usbitems->stream, usbitems->streampos,
usbitems->write_timeout
) < 0) {
@@ -944,11 +1014,19 @@
}
}
break;
+ case SDHWT_USB13700: {
+ if (fp_usb_bulk_write(
+ usbitems->usb_dev, usbitems->out_ep, usbitems->stream, usbitems->streampos, usbitems->write_timeout
+ ) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): USB13700 commiting buffer failed, error: %s", __func__, strerror(errno));
+ }
+ }
+ break;
}
usbitems->streampos = 0;
}
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
- if (libhnd_pthread)
+#ifdef HAVE_LIBPTHREAD
+ if ( SDFCTPTR_checkavail(SDFCTPTR_PTHREAD) )
fp_pthread_mutex_unlock( &mutex_commit );
#endif
}
@@ -970,23 +1048,35 @@
-
+/* internal use only:
+ replace all '/' and ' ' through '_'
+*/
+void normalise_string(char* str, int maxlen) {
+ int i;
+ if (maxlen == -1)
+ maxlen = strlen(str);
+ for (i = 0 ; i < strlen(str) ; i++) {
+ if (str[i] == '/' || str[i] == ' ')
+ str[i] = '_';
+ }
+}
/* *********************************
- usb_dev_handle* SDCONNusb_find(vendorID, productID, bcdDevice, occurrence, &dev_idx, &dev_ptr)
+ usb_dev_handle* SDCONNusb_find(vendorID, productID, bcdDevice, hr_name, occurrence, &dev_idx, &dev_ptr)
*********************************
find an usb device
*********************************
vendorID ... vendor ID
productID ... product ID
bcdDevice ... device ID (if -1 => don't care)
+ hr_name ... human readable device description (eg.: FTDI/DLM2232M)
&dev_idx ... index in usbdevices[]
&dev_ptr ... pointer to usb device (call by reference)
*********************************
returns a handle to an usb device or (usb_dev_handle*)0 if operation was unsuccessful
*/
-usb_dev_handle* SDCONNusb_find(int vendorID, int productID, int bcdDevice, int occurrence, int* dev_idx, struct usb_device** dev_ptr) {
+usb_dev_handle* SDCONNusb_find(int vendorID, int productID, int bcdDevice, char* hr_name, int occurrence, int* dev_idx, struct usb_device** dev_ptr) {
usb_dev_handle* usb_dev = 0;
struct usb_bus* bus = 0;
@@ -1013,9 +1103,76 @@
while (!found && dev) {
usb_dev = fp_usb_open(dev);
if (usb_dev) {
- if ( (dev->descriptor.idVendor == vendorID) &&
- (dev->descriptor.idProduct == productID) &&
- (bcdDevice == -1 || dev->descriptor.bcdDevice == bcdDevice)
+ int hr_match = 0;
+
+ /* no numeric vendorID: try if hr_name contains textual description of device */
+ if (vendorID == -1 && strlen(hr_name) > 0) {
+ char string[255];
+
+ char* delim_idx;
+ int hr_manu_match = -1;
+ int hr_prod_match = 0;
+ int hr_sern_match = -1;
+
+ char* hr_name_dup = strdup(hr_name);
+
+ delim_idx = index(hr_name_dup, '/');
+
+ if (delim_idx) {
+ if (serdisp_ptrdistance(delim_idx, hr_name_dup) > 0) {
+ fp_usb_get_string_simple(usb_dev, dev->descriptor.iManufacturer, string, sizeof(string));
+ normalise_string(string, -1);
+ normalise_string(hr_name_dup, serdisp_ptrdistance(delim_idx, hr_name_dup));
+ hr_manu_match = sdtools_ismatching(hr_name, serdisp_ptrdistance(delim_idx, hr_name_dup), string, -1);
+ } else {
+ hr_manu_match = -1; /* not given => don't care */
+ }
+
+ hr_name = (delim_idx+1);
+
+ delim_idx = index(hr_name_dup, '/');
+
+ fp_usb_get_string_simple(usb_dev, dev->descriptor.iProduct, string, sizeof(string));
+ normalise_string(string, -1);
+ normalise_string(hr_name_dup, serdisp_ptrdistance(delim_idx, hr_name_dup));
+ hr_prod_match =
+ sdtools_ismatching(
+ hr_name_dup,
+ (!delim_idx) ? -1 : serdisp_ptrdistance(delim_idx, hr_name_dup),
+ string,
+ -1
+ );
+
+ if (delim_idx) {
+ fp_usb_get_string_simple(usb_dev, dev->descriptor.iSerialNumber, string, sizeof(string));
+ normalise_string(string, -1);
+ normalise_string((delim_idx+1), -1);
+ hr_sern_match = sdtools_ismatching((delim_idx+1), -1, string, -1);
+ }
+ } else {
+ hr_manu_match = -1;
+ hr_sern_match = -1;
+ fp_usb_get_string_simple(usb_dev, dev->descriptor.iProduct, string, sizeof(string));
+ normalise_string(string, -1);
+ normalise_string(hr_name_dup, -1);
+ hr_prod_match = sdtools_ismatching(hr_name_dup, -1, string, -1);
+ }
+
+ free(hr_name_dup);
+
+ hr_match = (hr_manu_match != 0) && (hr_prod_match != 0) && (hr_sern_match != 0);
+ if (hr_match) {
+ vendorID = dev->descriptor.idVendor;
+ productID = dev->descriptor.idProduct;
+ bcdDevice = -1;
+ }
+ }
+
+ if ( hr_match ||
+ ( (dev->descriptor.idVendor == vendorID) &&
+ (dev->descriptor.idProduct == productID) &&
+ (bcdDevice == -1 || dev->descriptor.bcdDevice == bcdDevice)
+ )
) {
if (occurrence == occ_count) {
found = 1;
@@ -1076,6 +1233,14 @@
serdisp_usbdev_t* usbitems = (serdisp_usbdev_t*)(sdcd->extra);
struct usb_config_descriptor *config;
+ if (usbitems->dev->descriptor.bNumConfigurations == 0) {
+ sd_error(SERDISP_ERUNTIME,
+ "%s(): bNumConfigurations == 0. Try connecting device without using a USB hub.",
+ __func__
+ );
+ return -1;
+ }
+
config = &(usbitems->dev)->config[0]; /* dev->config->bNumInterfaces crashes with bsd */
/* claim interfaces */
@@ -1083,9 +1248,7 @@
for (i = 0; i < config->bNumInterfaces; i++) {
if ((ifmask == 0xFF) || ( ifmask & (1 << i)) ) {
/* detach from kernel module if bound to one */
-#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
if (fp_usb_detach_kernel_driver_np)
-#endif
fp_usb_detach_kernel_driver_np(usbitems->usb_dev, i);
if ((rc = fp_usb_claim_interface(usbitems->usb_dev, i)) != 0) {
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_control.c
^
|
@@ -1,7 +1,7 @@
/** \file serdisp_control.c
*
* \brief Functions for controlling serial lc-displays (eg: optrex323, nokia displays, ... )
- * \date (C) 2003-2008
+ * \date (C) 2003-2010
* \author wolfgang astleitner (mrwastl@users.sourceforge.net)
*/
@@ -25,14 +25,14 @@
*************************************************************************
*/
+#include "../config.h"
+
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
-#include <fcntl.h>
#include <string.h>
#include <strings.h>
-#include <sys/ioctl.h>
#include "serdisplib/serdisp_control.h"
#include "serdisplib/serdisp_connect.h"
@@ -40,7 +40,8 @@
#include "serdisplib/serdisp_messages.h"
#include "serdisplib/serdisp_colour.h"
-#include "../config.h"
+#include "serdisplib/serdisp_fctptr.h"
+
typedef struct serdisp_setup_s {
char* dispname;
@@ -83,6 +84,9 @@
#if WITH_DRIVER_SED133X
{"SED133X", "SED1330,SED1335", serdisp_sed133x_setup, "", "generic driver for SED1330/SED1335-based displays"},
{"S1D13700", "", serdisp_sed133x_setup, "", "generic driver for S1D13700-based displays"},
+ #if HAVE_LIBUSB
+ {"USB13700", "", serdisp_sed133x_setup, "", "displays driven by USB13700 USB module"},
+ #endif
#endif
#if WITH_DRIVER_NOKCOL
{"N3510I", "N3530", serdisp_nokcol_setup, "", "driver for Nokia 3510i/3530 displays (S1D15G14-based)"},
@@ -100,6 +104,8 @@
{"OLED96X36X1", "", serdisp_ssdoled_setup, "", "Pictiva 96X36 OLED 1bit"},
{"OLED96X64X16", "", serdisp_ssdoled_setup, "", "Pictiva 96X64 colour OLED 16bit"},
{"OLED128X64X4", "", serdisp_ssdoled_setup, "", "Pictiva 128X64 yellow OLED 4bit"},
+ {"BL160128A", "", serdisp_ssdoled_setup, "", "Bolymin BL160128A colour OLED 18bit"},
+ {"4DOLED282815", "4DOLED128", serdisp_ssdoled_setup, "", "4DOLED-282815 colour OLED 18bit"},
#endif
#if WITH_DRIVER_L4M
{"L4ME5I", "", serdisp_l4m_setup, "", "linux4media USB-interface E-5i-USB"},
@@ -111,8 +117,16 @@
#if WITH_DRIVER_STV8105
{"STV8105", "OLED256X64X4", serdisp_stv8105_setup, "", "Pictiva 256X64 yellow OLED 4bit"},
#endif
-#if WITH_DRIVER_ALPHACOOL
- {"ALPHACOOL", "", serdisp_alphacool_setup, "", "Alphacool USB-displays 200x64 or 240x128"},
+#if WITH_DRIVER_ACOOLSDCM
+ {"ALPHACOOL", "", serdisp_acoolsdcm_setup, "", "Alphacool USB-displays 200x64 or 240x128"},
+ {"SDCMEGTRON", "", serdisp_acoolsdcm_setup, "", "SDC-Megtron USB-displays 240x128"},
+#endif
+#if WITH_DRIVER_DIRECTGFX
+ {"SDL", "", serdisp_directgfx_setup, "", "direct output to SDL window"},
+#endif
+#if WITH_DRIVER_LC7981
+ {"DG16080", "", serdisp_lc7981_setup, "", "DG-16080 160x80"},
+ {"DG1608011", "", serdisp_lc7981_setup, "", "DG-16080-11 160x80 (non-square pixels)"},
#endif
};
@@ -132,21 +146,23 @@
SD_OPTIONFLAG_RW, "1=180,YES=180,NO=0,TRUE=180,FALSE=0,TOGGLE=2"}
,{ "INVERT", "INV", 0, 1, 1, SD_OPTIONFLAG_STD |
SD_OPTIONFLAG_RW, "YES=1,NO=0,TRUE=1,FALSE=0"}
+ ,{ "DSPAREAWIDTH", "DSPAREAW",0, -1, -1, SD_OPTIONFLAG_STD, ""}
+ ,{ "DSPAREAHEIGHT","DSPAREAH",0, -1, -1, SD_OPTIONFLAG_STD, ""}
+ ,{ "SELFEMITTING", "", 0, 1, -1, SD_OPTIONFLAG_STD, "YES=1,NO=0,TRUE=1,FALSE=0"}
,{ "CONTRAST", "", -1, -1, -1, 0, ""}
,{ "BACKLIGHT", "BG", -1, -1, -1, 0, "YES=1,NO=0,TRUE=1,FALSE=0,ON=1,OFF=0"}
,{ "DELAY", "", -1, -1, -1, 0, "NONE=0"}
,{ "WIDTH", "W", -1, -1, -1, 0, ""}
,{ "HEIGHT", "H", -1, -1, -1, 0, ""}
,{ "DEPTH", "", -1, -1, -1, 0, ""}
+ ,{ "BRIGHTNESS", "", -1, -1, -1, 0, ""}
};
-/* prototypes for locally used functions */
-void serdisp_freeresources(serdisp_t* dd);
-char* serdisp_getwiresignalname(serdisp_t* dd, int idx);
-int serdisp_getstandardoptionindex(const char* optionname);
-int serdisp_getoptionindex(serdisp_t* dd, const char* optionname);
+/* prototypes for functions with local-only scope */
+static char* serdisp_getwiresignalname(serdisp_t* dd, int idx);
+static int serdisp_setupwirings(serdisp_t* dd, const char* wiredef, int wiredef_len);
/**
@@ -208,9 +224,17 @@
if (! (dd->connection_types & sdcd->conntype)) {
serdisp_freeresources(dd);
dd = 0;
+ sd_error(SERDISP_ENOTSUP, "selected connection type is unsupported");
return (serdisp_t*)0;
}
+ /* unsupported protocol */
+ if (! (sdcd->protocol == SDPROTO_DONTCARE || dd->supp_protocols & sdcd->protocol)) {
+ serdisp_freeresources(dd);
+ dd = 0;
+ sd_error(SERDISP_ENOTSUP, "selected protocol is unsupported");
+ return (serdisp_t*)0;
+ }
/* initialise other items to default values not set by fp_setup */
if (! dd->fp_setpixel)
@@ -224,7 +248,7 @@
/* filter incompatible settings */
- if (dd->depth <=0 || dd->depth > 16/* || (8 % dd->depth)*/) { /* unsupported colour depth */
+ if (dd->depth <=0 || dd->depth > 32/* || (8 % dd->depth)*/) { /* unsupported colour depth */
sd_debug(1, "serdisp_init(); colour depth must be 1, 2, 4, or 8. depth %d is not supported (%s)", dd->depth, dispname);
serdisp_freeresources(dd);
dd = 0;
@@ -239,7 +263,8 @@
/* dd->scrbuf_chg_size = sizeof(byte) * (dd->width + dd->xcolgaps) * ((( dd->height +dd->ycolgaps + (cifiob*8-1))/(cifiob*8))); */
if (dd->depth >= 8) {
- dd->scrbuf_size = sizeof(byte) * (( (dd->width + dd->xcolgaps) * (dd->height + dd->ycolgaps) * dd->depth + 7) / 8);
+ int bitspercol = (dd->depth == 18) ? 24 : dd->depth; /* for speed reasons, align depth 18 to 24 bits in screen buffer */
+ dd->scrbuf_size = sizeof(byte) * (( (dd->width + dd->xcolgaps) * (dd->height + dd->ycolgaps) * bitspercol + 7) / 8);
/* one byte is able to store 8 change infos. one change info == one changed pixel */
dd->scrbuf_chg_size = sizeof(byte) * ( (( (dd->width+dd->xcolgaps) + 7) >> 3) * (dd->height+dd->ycolgaps) );
@@ -276,34 +301,6 @@
dd->scrbuf_bits_used = 8;
}
- /* generate default relocation tables if not set by fp_setup */
- if (! dd->xreloctab) {
- int j;
-
- if (! (dd->xreloctab = (int*) sdtools_malloc( sizeof(int) * (dd->width + dd->xcolgaps) ) ) ) {
- sd_error(SERDISP_EMALLOC, "serdisp_init(): cannot allocate relocation table");
- serdisp_freeresources(dd);
- dd = 0;
- return (serdisp_t*)0;
- }
-
- for (j = 0; j < dd->width + dd->xcolgaps; j++)
- dd->xreloctab[j] = j;
- }
- if (! dd->yreloctab) {
- int j;
-
- if (! (dd->yreloctab = (int*) sdtools_malloc( sizeof(int) * (dd->height + dd->ycolgaps) ) ) ) {
- sd_error(SERDISP_EMALLOC, "serdisp_init(): cannot allocate relocation table");
- serdisp_freeresources(dd);
- dd = 0;
- return (serdisp_t*)0;
- }
-
- for (j = 0; j < dd->height + dd->ycolgaps; j++)
- dd->yreloctab[j] = j;
- }
-
/* colour spaces */
if (!dd->colour_spaces) { /* auto detect */
switch (serdisp_getdepth(dd)) {
@@ -316,6 +313,9 @@
case 12:
dd->colour_spaces = SD_CS_RGB444;
break;
+ case 18:
+ dd->colour_spaces = SD_CS_RGB666;
+ break;
default:
sd_error(SERDISP_ENOTSUP, "serdisp_init(): cannot auto-detect colour space. dd->colour_spaces has to be set for this driver");
serdisp_freeresources(dd);
@@ -326,7 +326,9 @@
/* indexed colour table */
/* initialise colour table (greyscale values and indexed colour schemes only; leave uninitialised otherwise) */
- if ((! dd->ctable) && ( dd->colour_spaces & SD_CS_INDEXED_SPACE) ) { /* no default colour table (only for indexed colours) */
+
+ /* no default colour table (only for indexed colours) */
+ if ((! dd->ctable) && (! SD_CS_ISDIRECTCOLOUR(dd)) && ( dd->colour_spaces & SD_CS_INDEXED_SPACE) ) {
if (! (dd->ctable = (long*) sdtools_malloc( sizeof(long) * serdisp_getcolours(dd) ) ) ) {
sd_error(SERDISP_EMALLOC, "serdisp_init(): cannot allocate indexed colour table");
@@ -351,67 +353,12 @@
}
if ( ! dd->fp_transcolour || ! dd->fp_transgrey || ! dd->fp_lookupcolour || ! dd->fp_lookupgrey ) {
- switch (serdisp_getdepth(dd)) {
- case 1:
- dd->fp_transcolour = serdisp_transcolour_bw;
- dd->fp_transgrey = serdisp_transgrey_bw;
- dd->fp_lookupcolour = serdisp_lookupcolour_bw;
- dd->fp_lookupgrey = serdisp_lookupgrey_bw;
- break;
- case 2:
- case 4:
- dd->fp_transcolour = serdisp_transcolour_grey2_4;
- dd->fp_transgrey = serdisp_transgrey_grey2_4;
- dd->fp_lookupcolour = serdisp_lookupcolour_grey2_4;
- dd->fp_lookupgrey = serdisp_lookupgrey_grey2_4;
- break;
- case 8:
- if (dd->colour_spaces & SD_CS_RGB332) {
- if (SD_CS_ISBGR(dd)) {
- dd->fp_transcolour = serdisp_transcolour_bgr332;
- dd->fp_transgrey = serdisp_transgrey_bgr332;
- dd->fp_lookupcolour = serdisp_lookupcolour_bgr332;
- dd->fp_lookupgrey = serdisp_lookupgrey_bgr332;
- } else {
- dd->fp_transcolour = serdisp_transcolour_rgb332;
- dd->fp_transgrey = serdisp_transgrey_rgb332;
- dd->fp_lookupcolour = serdisp_lookupcolour_rgb332;
- dd->fp_lookupgrey = serdisp_lookupgrey_rgb332;
- }
- } else {
- dd->fp_transcolour = serdisp_transcolour_grey8;
- dd->fp_transgrey = serdisp_transgrey_grey8;
- dd->fp_lookupcolour = serdisp_lookupcolour_grey8;
- dd->fp_lookupgrey = serdisp_lookupgrey_grey8;
- }
- break;
- case 12:
- dd->fp_transcolour = serdisp_transcolour_rgb444;
- dd->fp_transgrey = serdisp_transgrey_rgb444;
- dd->fp_lookupcolour = serdisp_lookupcolour_rgb444;
- dd->fp_lookupgrey = serdisp_lookupgrey_rgb444;
- break;
- case 16:
- if (dd->colour_spaces & SD_CS_RGB565) {
- if (SD_CS_ISBGR(dd)) {
- dd->fp_transcolour = serdisp_transcolour_bgr565;
- dd->fp_transgrey = serdisp_transgrey_bgr565;
- dd->fp_lookupcolour = serdisp_lookupcolour_bgr565;
- dd->fp_lookupgrey = serdisp_lookupgrey_bgr565;
- } else {
- dd->fp_transcolour = serdisp_transcolour_rgb565;
- dd->fp_transgrey = serdisp_transgrey_rgb565;
- dd->fp_lookupcolour = serdisp_lookupcolour_rgb565;
- dd->fp_lookupgrey = serdisp_lookupgrey_rgb565;
- }
- }
- break;
- default:
- sd_error(SERDISP_ENOTSUP, "serdisp_init(): cannot initialise colour-space specific colour functions.");
- serdisp_freeresources(dd);
- dd = 0;
- return (serdisp_t*)0;
- }
+ if (serdisp_sdcol_init(dd)) {
+ sd_error(SERDISP_ENOTSUP, "serdisp_init(): cannot initialise colour-space specific colour functions.");
+ serdisp_freeresources(dd);
+ dd = 0;
+ return (serdisp_t*)0;
+ }
}
dd->sdcd = sdcd;
@@ -421,7 +368,7 @@
if (optionstring && strlen(optionstring) > 0) {
while( !found && (patternptr = sdtools_nextpattern(patternptr, ';', &patternlen, &patternborder)) ) {
-
+
if ( strncasecmp(patternptr, "WIRING=", strlen("WIRING=")) == 0 ||
strncasecmp(patternptr, "WIRE=", strlen("WIRE=")) == 0
) {
@@ -606,6 +553,9 @@
* \return amount of supported colours
*/
int serdisp_getcolours(serdisp_t* dd) {
+ /* depth 32 = depth 24 + alpha channel, thus only 2^24 different colours */
+ if (dd->depth >= 24)
+ return (1 << 24);
return 1 << dd->depth;
}
@@ -804,6 +754,10 @@
*typesize = sizeof(int);
return (long)sdtools_contrast_hw2norm(dd, dd->curr_contrast);
+ } else if (serdisp_getstandardoptionindex("BRIGHTNESS") == stdidx) {
+ if (typesize)
+ *typesize = sizeof(int);
+ return (long) (100 - dd->curr_dimming);
} else if ( (serdisp_getstandardoptionindex("BACKLIGHT") == stdidx) && dd->feature_backlight) {
if (typesize)
*typesize = sizeof(int);
@@ -827,6 +781,18 @@
if (typesize)
*typesize = sizeof(long);
return (long) dd->delay;
+ } else if (serdisp_getstandardoptionindex("DSPAREAWIDTH") == stdidx) {
+ if (typesize)
+ *typesize = sizeof(long);
+ return (long) dd->dsparea_width;
+ } else if (serdisp_getstandardoptionindex("DSPAREAHEIGHT") == stdidx) {
+ if (typesize)
+ *typesize = sizeof(long);
+ return (long) dd->dsparea_height;
+ } else if (serdisp_getstandardoptionindex("SELFEMITTING") == stdidx) {
+ if (typesize)
+ *typesize = sizeof(byte);
+ return (long) ((SD_CS_ISSELFEMITTING(dd)) ? 1 : 0);
/* driver-specific values */
} else {
@@ -1331,8 +1297,8 @@
</pre>
*
* \attention
- * this function is <i>hardware dependend</i>! \n
- * for <i>hardware independend</i> pixel changing serdisp_setcolour() should be used.
+ * this function is <i>hardware dependent</i>! \n
+ * for <i>hardware independent</i> pixel changing serdisp_setcolour() should be used.
*/
void serdisp_setpixel(serdisp_t* dd, int x, int y, long colour) {
dd->fp_setpixel(dd, x, y, colour);
@@ -1348,11 +1314,11 @@
* \param x x-position
* \param y y-position
*
- * \return hardware dependend colour information at (x/y)
+ * \return hardware dependent colour information at (x/y)
*
* \attention
- * this function is <i>hardware dependend</i>! \n
- * for getting the <i>hardware independend</i> colour information serdisp_getcolour() should be used.
+ * this function is <i>hardware dependent</i>! \n
+ * for getting the <i>hardware independent</i> colour information serdisp_getcolour() should be used.
*/
long serdisp_getpixel(serdisp_t* dd, int x, int y) {
return dd->fp_getpixel(dd, x, y);
@@ -1524,10 +1490,10 @@
for (n = 1; n <= (cnt<<1); n++) {
if (what == 0 && dd->feature_backlight) {
serdisp_setoption(dd, "BACKLIGHT", SD_OPTION_TOGGLE);
- usleep(delta);
+ SDCONN_usleep(dd->sdcd, delta);
} else if (what == 1 /* && dd->feature_invert*/) {
serdisp_setoption(dd, "INVERT", SD_OPTION_TOGGLE);
- usleep(delta);
+ SDCONN_usleep(dd->sdcd, delta);
}
}
}
@@ -1641,13 +1607,22 @@
int optidx = 0;
char* tokenidx = strchr(optionname, '=');
int namelen = (tokenidx) ? serdisp_ptrstrlen(tokenidx, optionname) : -1;
+ char* optionname_full = (char*) optionname;
if (!dd->options)
return -1;
+ /* is optionname an alias which is defined in standard options? if so, use non-alias name of option */
+ /* eg: optioname = 'BG' -> use 'BACKLIGHT' instead for searching in dd->options */
+ if ( (optidx = serdisp_getstandardoptionindex(optionname)) >= 0) {
+ optionname_full = serdisp_standardoptions[optidx].name;
+ namelen = -1; /* in this case optionname_full is \0-terminated */
+ }
+
+ optidx = 0;
while (optidx < dd->amountoptions ) {
- if (sdtools_ismatching(dd->options[optidx].name, -1, optionname, namelen) ||
- sdtools_isinelemlist(dd->options[optidx].aliasnames, optionname, namelen) > -1
+ if (sdtools_ismatching(dd->options[optidx].name, -1, optionname_full, namelen) ||
+ sdtools_isinelemlist(dd->options[optidx].aliasnames, optionname_full, namelen) > -1
) {
/* early exit */
return optidx;
@@ -1762,7 +1737,11 @@
dd->sdcd->io_flags_readstatus = 0;
dd->sdcd->io_flags_writedata = 0;
dd->sdcd->io_flags_writecmd = 0;
-
+
+ /* setup wiring only for protocols EMULATION (or if protocol == DONTCARE) */
+ if ( ! (dd->sdcd->protocol == SDPROTO_DONTCARE || dd->sdcd->protocol == SDPROTO_EMULATION))
+ return 0;
+
/* no customisable wiring supported by this driver -> return */
if (! dd->wiresignals && ! dd->wiredefs)
return 0;
@@ -2097,7 +2076,13 @@
}
}
- optvalue = strtol(optvalueptr, &tempptr, 10);
+ /* accept base 10 and base 16 values (base 16 if value starts with 0x or 0X) */
+ if (strncasecmp(optvalueptr, "0x", 2) == 0) {
+ optvalue = strtol(optvalueptr, &tempptr, 16);
+ } else {
+ optvalue = strtol(optvalueptr, &tempptr, 10);
+ }
+
/* verify if optvalueptr contained a valid number */
if (optvalueptr == tempptr || ( (*tempptr != '\0') && (tempptr < (optvalueptr + optvalueptrlen)) ) ) {
snprintf(buffer, ( (optvalueptrlen >= 49) ? 50 : optvalueptrlen+1), "%s", optvalueptr);
@@ -2118,23 +2103,34 @@
/* assign option value to dd-structure variable */
if (foundstdopt) {
/* this should be solved in a better way ... */
- if (strcasecmp(curroption.name, "ROTATE") == 0)
+ if (strcasecmp(curroption.name, "ROTATE") == 0) {
dd->curr_rotate = sdtools_rotate_deg2intern(dd, (int)optvalue);
- else if (strcasecmp(curroption.name, "INVERT") == 0)
+ } else if (strcasecmp(curroption.name, "INVERT") == 0) {
dd->curr_invert = (int)optvalue;
- else if (strcasecmp(curroption.name, "CONTRAST") == 0)
+ } else if (strcasecmp(curroption.name, "CONTRAST") == 0) {
dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)optvalue);
- else if (strcasecmp(curroption.name, "BACKLIGHT") == 0)
+ } else if (strcasecmp(curroption.name, "BRIGHTNESS") == 0) {
+ dd->curr_dimming = (100 - (int)optvalue);
+ } else if (strcasecmp(curroption.name, "BACKLIGHT") == 0) {
dd->curr_backlight = (int)optvalue;
- else if (strcasecmp(curroption.name, "WIDTH") == 0)
+ } else if (strcasecmp(curroption.name, "WIDTH") == 0) {
dd->width = (int)optvalue;
- else if (strcasecmp(curroption.name, "HEIGHT") == 0)
+ } else if (strcasecmp(curroption.name, "HEIGHT") == 0) {
dd->height = (int)optvalue;
- else if (strcasecmp(curroption.name, "DEPTH") == 0)
+ } else if (strcasecmp(curroption.name, "DEPTH") == 0) {
dd->depth = (int)optvalue;
- else if (strcasecmp(curroption.name, "DELAY") == 0)
+ } else if (strcasecmp(curroption.name, "DELAY") == 0) {
dd->delay = optvalue;
-
+ } else if (strcasecmp(curroption.name, "DSPAREAWIDTH") == 0) {
+ dd->dsparea_width = optvalue;
+ } else if (strcasecmp(curroption.name, "DSPAREAHEIGHT") == 0) {
+ dd->dsparea_height = optvalue;
+ } else if (strcasecmp(curroption.name, "SELFEMITTING") == 0) {
+ if (optvalue)
+ dd->colour_spaces |= SD_CS_SELFEMITTING;
+ else
+ dd->colour_spaces &= (0xFFFFFFFFL ^ SD_CS_SELFEMITTING);
+ }
} else { /* non standard option */
if (dd->fp_getvalueptr) {
int typesize;
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/src/serdisp_fctptr.c
^
|
@@ -0,0 +1,183 @@
+/** \file serdisp_fctptr.c
+ *
+ * \brief Initialisation of additional libraries and function pointers
+ * \date (C) 2010
+ * \author wolfgang astleitner (mrwastl@users.sourceforge.net)
+ */
+
+/*
+ *************************************************************************
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+#include "../config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+
+#include "serdisplib/serdisp_messages.h"
+#include "serdisplib/serdisp_fctptr.h"
+
+#ifdef WITH_DYNLOADING
+#include <dlfcn.h>
+#endif /* WITH_DYNLOADING */
+
+static int fp_initialised = 0;
+
+static int available_libusb = 0; /* usb_*() */
+static int available_pthread = 0; /* pthread_*() */
+static int available_netsock = 0; /* gethostbyname, gethostbyaddr, sethostent, endhostent, ... */
+static int available_libSDL = 0;
+
+#ifdef HAVE_LIBUSB
+void (*fp_usb_init) (void);
+usb_dev_handle* (*fp_usb_open) (struct usb_device* dev);
+int (*fp_usb_close) (usb_dev_handle* dev);
+int (*fp_usb_reset) (usb_dev_handle* dev);
+int (*fp_usb_interrupt_read) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
+int (*fp_usb_release_interface)(usb_dev_handle* dev, int interface);
+int (*fp_usb_find_busses) (void);
+int (*fp_usb_find_devices) (void);
+struct usb_bus* (*fp_usb_get_busses) (void);
+int (*fp_usb_claim_interface) (usb_dev_handle* dev, int interface);
+
+int (*fp_usb_bulk_read) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
+int (*fp_usb_bulk_write) (usb_dev_handle* dev, int ep, char* bytes, int size, int timeout);
+int (*fp_usb_control_msg) (usb_dev_handle* dev, int requesttype, int request,
+ int value, int index, char *bytes, int size, int timeout);
+int (*fp_usb_clear_halt) (usb_dev_handle *dev, unsigned int ep);
+
+int (*fp_usb_set_altinterface) (usb_dev_handle *dev, int alternate);
+int (*fp_usb_set_configuration)(usb_dev_handle *dev, int configuration);
+int (*fp_usb_get_string_simple)(usb_dev_handle *dev, int index, char *buf, size_t buflen);
+
+int (*fp_usb_detach_kernel_driver_np) (usb_dev_handle* dev, int interface);
+#endif /* HAVE_LIBUSB */
+
+#ifdef HAVE_LIBSDL
+int (*fp_SDL_Init) (uint32_t);
+SDL_Surface* (*fp_SDL_SetVideoMode) (int, int, int, uint32_t);
+char* (*fp_SDL_GetError) (void);
+void (*fp_SDL_WM_SetCaption) (const char*, const char*);
+int (*fp_SDL_LockSurface) (SDL_Surface*);
+void (*fp_SDL_UnlockSurface) (SDL_Surface*);
+int (*fp_SDL_Flip) (SDL_Surface*);
+void (*fp_SDL_FreeSurface) (SDL_Surface*);
+uint32_t (*fp_SDL_MapRGB) (SDL_PixelFormat*, uint8_t, uint8_t, uint8_t);
+void (*fp_SDL_Quit) (void);
+#endif /* HAVE_LIBSDL */
+
+
+/**
+ * \brief initialises additional function pointers
+ *
+ * additional function pointers are initialised when calling this function.
+ * if dynamic loading of libraries is used: dlopen/dlsym are used for initialising the function pointers,
+ * defines are used if additional libraries are to be linked directly to serdisplib.
+ *
+ * \attention this function will only be executed once. further calls will be ignored.
+ *
+ * \since 1.98.0
+ */
+void SDFCTPTR_init(void) {
+ if (fp_initialised)
+ return;
+
+ fp_initialised = 1;
+
+ available_libusb = 0;
+ available_pthread = 0;
+ available_netsock = 0;
+ available_libSDL = 0;
+
+#ifdef HAVE_LIBUSB
+ fp_usb_init = usb_init;
+ fp_usb_open = usb_open;
+ fp_usb_close = usb_close;
+ fp_usb_reset = usb_reset;
+ fp_usb_interrupt_read = usb_interrupt_read;
+ fp_usb_release_interface = usb_release_interface;
+ fp_usb_find_busses = usb_find_busses;
+ fp_usb_find_devices = usb_find_devices;
+ fp_usb_get_busses = usb_get_busses;
+ fp_usb_claim_interface = usb_claim_interface;
+
+ fp_usb_bulk_read = usb_bulk_read;
+ fp_usb_bulk_write = usb_bulk_write;
+ fp_usb_control_msg = usb_control_msg;
+ fp_usb_clear_halt = usb_clear_halt;
+
+ fp_usb_set_altinterface = usb_set_altinterface;
+ fp_usb_set_configuration = usb_set_configuration;
+ fp_usb_get_string_simple = usb_get_string_simple;
+
+ #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
+ fp_usb_detach_kernel_driver_np = usb_detach_kernel_driver_np;
+ #else
+ fp_usb_detach_kernel_driver_np = 0;
+ #endif
+
+ available_libusb = 1;
+#endif /* HAVE_LIBUSB */
+
+#ifdef HAVE_LIBSDL
+ fp_SDL_Init = (int(*)(uint32_t)) SDL_Init;
+ fp_SDL_SetVideoMode = (SDL_Surface*(*)(int, int, int, uint32_t)) SDL_SetVideoMode;
+ fp_SDL_GetError = (char*(*)(void)) SDL_GetError;
+ fp_SDL_WM_SetCaption = (void(*)(const char*, const char*)) SDL_WM_SetCaption;
+ fp_SDL_LockSurface = (int(*)(SDL_Surface*)) SDL_LockSurface;
+ fp_SDL_UnlockSurface = (void(*)(SDL_Surface*)) SDL_UnlockSurface;
+ fp_SDL_Flip = (int(*)(SDL_Surface*)) SDL_Flip;
+ fp_SDL_FreeSurface = (void(*)(SDL_Surface*)) SDL_FreeSurface;
+ fp_SDL_MapRGB = (uint32_t(*)(SDL_PixelFormat*, uint8_t, uint8_t, uint8_t)) SDL_MapRGB;
+ fp_SDL_Quit = (void(*)(void)) SDL_Quit;
+
+ available_libSDL = 1;
+#endif /* HAVE_LIBSDL */
+}
+
+
+/**
+ * \brief checks if an additional functionality is supported
+ *
+ * \param libID one of SDFCTPTR_[LIBUSB | PTHREAD | NETSOCK | LIBSDL]
+ *
+ * \retval 0 additional functionality is not supported
+ * \retval 1 additional functionality is supported
+ *
+ * \since 1.98.0
+ */
+int SDFCTPTR_checkavail(int libID) {
+ switch (libID) {
+ case SDFCTPTR_LIBUSB: return (available_libusb == 1); break;
+ case SDFCTPTR_PTHREAD: return (available_pthread == 1); break;
+ case SDFCTPTR_NETSOCK: return (available_netsock == 1); break;
+ case SDFCTPTR_LIBSDL: return (available_libSDL == 1); break;
+ }
+ return 0;
+}
+
+
+/**
+ * \brief closes all open dyn. loaded libraries
+ *
+ * \since 1.98.0
+ */
+void SDFCTPTR_cleanup (void) {
+}
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_acoolsdcm.c
^
|
@@ -0,0 +1,1431 @@
+/*
+ *************************************************************************
+ *
+ * serdisp_specific_acoolsdcm.c
+ * routines for controlling
+ * Alphacool 200x64 and 240x128 USB-displays
+ * SDC-Megtron 240x128 USB-display
+ *
+ *************************************************************************
+ *
+ * copyright (C) 2007 fen <fen@init-6.org>
+ * copyright (C) 2007 nessie <nessie10@gmx.net> (original code)
+ *
+ * adaptation for SDC-Megtron 240x128 LCD
+ * copyright (C) 2009 smart-display-company
+ * email info@smart-display-company.de
+ *
+ * additional maintenance:
+ * copyright (C) 2007-2010 wolfgang astleitner
+ * email mrwastl@users.sourceforge.net
+ *
+ *************************************************************************
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+/*
+ * Display organisation 200x64:
+ *
+ * Display is 200 by 64 pixel. The display transfer buffer uses the
+ * following layout:
+ *
+ * data[0] column 0, rows 0 to 7, msb is row 0, lsb is row 7
+ * data[1] column 1, rows 0 to 7, msb is row 0, lsb is row 7
+ * ...
+ * data[199] column 199, rows 0 to 7, msb is row 0, lsb is row 7
+ * data[200] column 0, rows 8 to 15, msb is row 8, lsb is row 15
+ * data[201] column 1, rows 8 to 15, msb is row 8, lsb is row 15
+ * ...
+ * data[399] column 199, rows 8 to 15, msb is row 8, lsb is row 15
+ * ...
+ *
+ * every byte represents 8 rows of a column. the buffer is
+ * 200 * 64 / 8 = 1600 bytes.
+ *
+ *
+ * Display organisation 240x128:
+ *
+ * Display is 240 by 128 pixel. The display transfer buffer uses the
+ * following layout:
+ *
+ * data[0] column 0 to 7, row 0, msb is column 0, lsb is column 7
+ * data[1] column 8 to 15, row 0, msb is column 8, lsb is column 15
+ * ...
+ * data[239] column 232 to 239, row 0, msb is column 232, lsb is column 239
+ * data[240] column 0 to 7, row 1, msb is column 0, lsb is column 7
+ * data[241] column 8 to 15, row 1, msb is column 8, lsb is column 15
+ * ...
+ *
+ * every byte represents 8 columns of a row. the buffer is
+ * 240 * 128 / 8 = 3840 bytes.
+ */
+
+/*
+ * includes
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../config.h"
+
+#include "serdisplib/serdisp_connect.h"
+#include "serdisplib/serdisp_tools.h"
+#include "serdisplib/serdisp_messages.h"
+#include "serdisplib/serdisp_fctptr.h"
+#include "serdisplib/serdisp_connect_usb.h"
+
+#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
+ #include "serdisplib/serdisp_colour.h"
+#endif
+
+#ifdef HAVE_LIBPTHREAD
+ #include "serdisplib/serdisp_gpevents.h"
+#endif
+
+
+/*
+ * alphacool constants
+ */
+
+#define ALPHACOOL_INIT 0x31
+#define ALPHACOOL_GFX_WRITE_INIT 0x32
+#define ALPHACOOL_GFX_WRITE_END 0x33
+#define ALPHACOOL_GFX_WRITE_DATA 0x34
+#define ALPHACOOL_GFX_CLEAR 0x35
+#define ALPHACOOL_TXT_WRITE_INIT 0x36
+#define ALPHACOOL_TXT_WRITE_END 0x37
+#define ALPHACOOL_TXT_WRITE_DATA 0x38
+#define ALPHACOOL_TXT_CLEAR 0x39
+#define ALPHACOOL_CLEAR 0x3A
+#define ALPHACOOL_CS 0x3B
+#define ALPHACOOL_WRITE_DATA 0x3C
+#define ALPHACOOL_WRITE_AUTO_DATA 0x3D
+#define ALPHACOOL_WRITE_COMMAND 0x3E
+#define ALPHACOOL_WRITE_COMMAND1 0x3F
+#define ALPHACOOL_WRITE_COMMAND2 0x40
+#define ALPHACOOL_READ_DATA 0x41
+#define ALPHACOOL_READ_AUTO_DATA 0x42
+#define ALPHACOOL_BKL 0x43
+#define ALPHACOOL_AUTO_WRITE_RESET 0x44
+#define ALPHACOOL_AUTO_READ_RESET 0x45
+#define ALPHACOOL_SET_FONT 0x46
+#define ALPHACOOL_DEVICE 0x47
+#define ALPHACOOL_GET_ADDRESS 0x48
+#define ALPHACOOL_SET_ADDRESS 0x49
+
+
+/*
+ * SDC-megtron constants + in-source display driving documentation
+ */
+
+#define USB_LCDAPI_REQUEST 0xA0
+#define USB_LCDAPI_GFXDRAW 0xA1
+
+/* firmware API commands for USB_LCDAPI_REQUEST */
+#define USB_LCDCMD_VERSION 0x01 /* get current firmware version (word) */
+#define USB_LCDCMD_RESET 0x10 /* reset module (also USB!) */
+#define USB_LCDCMD_INIT 0x11 /* reset and re-init T6963 */
+#define USB_LCDCMD_CLRSCR 0x12 /* clear screen (see "clrscr option" below) */
+#define USB_LCDCMD_STORELIGHT 0x13 /* store light value to EE as default (word, 0-255) */
+#define USB_LCDCMD_GETSTOREDLIGHT 0x14 /* get the stored value from EE */
+
+#define USB_LCDCMD_SETTEXTMODE 0x15 /* module supports overlay text (8x8) - see "text modes" below */
+#define USB_LCDCMD_GETTEXTMODE 0x16
+#define USB_LCDCMD_SETCURSORTYPE 0x17 /* see "cursor types" below */
+#define USB_LCDCMD_GETCURSORTYPE 0x18
+#define USB_LCDCMD_SETCURSORPOS 0x19 /* Col/Row shifted to parameter word CCRR, col 0-29, row 0-15 */
+#define USB_LCDCMD_WRITE_TEXT 0x1A /* writes a string at given Col,Row to TXT screen */
+#define USB_LCDCMD_PRINT_TEXT 0x1B /* terminal style writing at current cursor pos */
+#define USB_LCDCMD_READ_TEXT 0x1C /* get the current TXT screen (480 chars) */
+#define USB_LCDCMD_READ_GFX 0x1D /* get the current GFX screen (3840 byte) */
+
+#define USB_LCDCMD_SETLIGHT 0x20 /* set backlight (word) 0-255 */
+#define USB_LCDCMD_GETLIGHT 0x21 /* get current backlight value */
+#define USB_LCDCMD_SETINVERT 0x22 /* module can manage inverted screen by itself, value is also stored to EE */
+#define USB_LCDCMD_GETINVERT 0x23 /* get current setting from EE */
+
+#define USB_LCDCMD_SET_FLAG 0x27
+#define USB_LCDCMD_RESET_FLAG 0x28
+#define USB_LCDCMD_READ_FLAGS 0x29
+#define USB_LCDCMD_WRITE_FLAGS 0x2A
+#define USB_LCDCMD_STOREBOOTLOGO 0x2B /* store/internaly transfer the current screen as startup image to flash */
+#define USB_LCDCMD_DRAWBOOTLOGO 0x2C /* draw stored image from flash to screen */
+#define USB_LCDCMD_READBOOTLOGO 0x2D /* read startup image data from flash (3840 byte) */
+#define USB_LCDCMD_SETFLIPPED 0x2E
+ /* module can not really manage a flipped screen due to performance reasons.
+ only the startup image is automatically flipped. if option is used, application
+ should read option first and must flip content by itself (if option is set) before
+ sending pixel data to LCD screen.
+ "flip" means left/top is at right/bottom and each pixel byte must be mirrored
+ e.g. 11000001 => 10000011
+ */
+#define USB_LCDCMD_GETFLIPPED 0x2F
+
+/* firmware config Flags */
+#define LCD_FLAG_BOOTLOGO_POWERUP 0x0001
+#define LCD_FLAG_BOOTLOGO_RESUME 0x0002
+#define LCD_FLAG_BOOTLOGO_CONFIG 0x0004
+#define LCD_FLAG_SHUTDOWN_SUSPEND 0x0008
+#define LCD_FLAG_SHUTDOWN_RELEASE 0x0010
+#define LCD_FLAG_BOOTLOGO_RELEASE 0x0040
+#define LCD_FLAG_SHUTDOWN_EFFECT 0x0080
+
+/* text modes */
+#define LCD_TEXT_MODE_OR 0x0000
+#define LCD_TEXT_MODE_XOR 0x0001
+#define LCD_TEXT_MODE_AND 0x0002
+#define LCD_TEXT_MODE_STORE_EE 0x8000
+
+/* clrscr option
+ text screen is overlay to GFX screen, you can delete complete screen or just one of them
+*/
+#define LCD_BOTH_CLRSCR 0x00
+#define LCD_GFX_CLRSCR 0x01
+#define LCD_TEXT_CLRSCR 0x02
+
+/* cursor types */
+#define LCD_CURSOR_OFF 0x0000
+#define LCD_CURSOR_ON 0x0001
+#define LCD_CURSOR_BLINK 0x0002
+#define LCD_CURSOR_1_LINE 0x0100
+#define LCD_CURSOR_2_LINE 0x0200
+#define LCD_CURSOR_3_LINE 0x0300
+#define LCD_CURSOR_4_LINE 0x0400
+#define LCD_CURSOR_5_LINE 0x0500
+#define LCD_CURSOR_6_LINE 0x0600
+#define LCD_CURSOR_7_LINE 0x0700
+#define LCD_CURSOR_8_LINE 0x0800
+#define LCD_CURSOR_STORE_EE 0x8000 /* also store the given type to EEPROM */
+/* make a firmware API command:
+
+ simple command: (like USB_LCDCMD_RESET)
+ fp_usb_control_msg(USBHandle, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, 0, USB_LCDCMD_XXX, NULL, 0, TIMEOUT)
+
+ command and parameter: (like USB_LCDCMD_SETLIGHT)
+ fp_usb_control_msg(USBHandle, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, wValue, USB_LCDCMD_XXX, NULL, 0, TIMEOUT)
+
+
+ command and data: (like USB_LCDCMD_PRINT_TEXT)
+ fp_usb_control_msg(USBHandle, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, 0, USB_LCDCMD_XXX, pStr, pStrLength, TIMEOUT)
+ remarks: text without 0 termination char, max. 30 chars
+
+ command, parameter and data: (like USB_LCDCMD_WRITE_TEXT)
+ fp_usb_control_msg(USBHandle, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, wValue, USB_LCDCMD_XXX, pStr, pStrLength, TIMEOUT)
+ remarks: wValue for USB_LCDCMD_WRITE_TEXT is CCRR, Col:0-29, Row:0-15
+
+ command and read parameter (word): (like USB_LCDCMD_GETLIGHT)
+ fp_usb_control_msg(USBHandle, USB_TYPE_VENDOR|USB_ENDPOINT_IN, USB_LCDAPI_REQUEST, 0, USB_LCDCMD_XXX, (char*)&wValue, 2, TIMEOUT)
+
+ command and read data: (like USB_LCDCMD_READ_TEXT, DataSizeToRead = 480)
+ fp_usb_control_msg(USBHandle, USB_TYPE_VENDOR|USB_ENDPOINT_IN, USB_LCDAPI_REQUEST, 0, USB_LCDCMD_XXX, (char*)pData, pDataSizeToRead, TIMEOUT)
+
+
+ sending data to screen:
+
+ start transfer:
+ fp_usb_control_msg(USBHandle, USB_TYPE_VENDOR, USB_LCDAPI_GFXDRAW, LEFT_TOP, RIGHT_BOTTOM, NULL, 0, TIMEOUT)
+ LEFT_TOP and RIGHT_BOTTOM: XXYY, X:0-239,Y:0-127
+ X must be multible of 8!
+
+ and send pixel data:
+ fp_usb_bulk_write(USBHandle, EP_DISPLAY_DATA_OUT, (char*)pPixelData, wDataLength, TIMEOUT)
+ remarks: wDataLength MUST be multible of 128 byte! (this additional bytes are not drawn to screen)
+*/
+
+
+
+/*
+ * additional constants
+ */
+
+#define AC_200x64 0
+#define AC_240x128 1
+
+#define AC_MD_ROW 0
+#define AC_MD_COL 1
+
+#define DISPID_ALPHACOOL 1
+#define DISPID_SDCMEGTRON 2
+
+/*
+ * endpoint constants
+ */
+
+/*
+ * macros
+ */
+
+#define check(expr) serdisp_acoolsdcm_runtime_check(expr, __func__, __FILE__, __LINE__)
+
+serdisp_options_t alphacool_options[] = {
+ /* name aliasnames min max mod int defines */
+ { "BACKLIGHT", "", 0, 1, 1, 1, "ON=1,OFF=0,YES=1,NO=0"} /* backlight on/off */
+ ,{ "OPTALGO", "", 0, 1, 1, 1, "ON=1,OFF=0,YES=1,NO=0"} /* optimized algo */
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness, 0: bg-light off, <>0: dd->curr_backlight */
+};
+
+serdisp_options_t sdcmegtron_options[] = {
+ /* name aliasnames min max mod int defines */
+ { "BACKLIGHT", "", 0, 1, 1, 1, "ON=1,OFF=0,YES=1,NO=0"} /* backlight on/off */
+ ,{ "OPTALGO", "", 0, 1, 1, 1, "ON=1,OFF=0,YES=1,NO=0"} /* optimized algo */
+ ,{ "BACKLIGHTLEVEL", "BGLEVEL", 0, 0xFF, 1, 1, ""} /* backlight level */
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
+};
+
+/*
+ * private function prototypes
+ */
+
+static void serdisp_acoolsdcm_init (serdisp_t *dd);
+static void serdisp_acoolsdcm_update (serdisp_t *dd);
+static int serdisp_acoolsdcm_setoption (serdisp_t *dd, const char *option, long value);
+static void serdisp_acoolsdcm_close (serdisp_t *dd);
+static void serdisp_acoolsdcm_clear (serdisp_t *dd);
+
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+static void serdisp_acoolsdcm_setpixel (serdisp_t *dd, int x, int y, SDCol sdcol);
+static SDCol serdisp_acoolsdcm_getpixel (serdisp_t *dd, int x, int y);
+#else
+static void serdisp_acoolsdcm_setpixel (serdisp_t *dd, int x, int y, long colour);
+static long serdisp_acoolsdcm_getpixel (serdisp_t *dd, int x, int y);
+#endif
+static void* serdisp_acoolsdcm_getvalueptr (serdisp_t *dd, const char *optionname, int *typesize);
+static void serdisp_acoolsdcm_getrect (serdisp_t *dd, int *x1, int *y1, int *x2, int *y2, int *is_empty);
+static void serdisp_acoolsdcm_transfer_rect (serdisp_t *dd, int x1, int y1, int x2, int y2);
+static int serdisp_acoolsdcm_runtime_check (int condition, const char *function, const char *file, const int line);
+
+static int sdcmegtron_bglevel2brightness (int bglevel);
+static int sdcmegtron_brightness2bglevel (int brightness);
+
+#ifdef HAVE_LIBPTHREAD
+static int updating_wait (int* upd_flag);
+static void updating_post (int* upd_flag);
+#endif
+/*
+ * private structures
+ */
+
+typedef struct serdisp_acoolsdcm_data_s
+{
+ byte *trans_scrbuf; /* transfer buffer */
+ int optalgo; /* use optimized algo */
+ byte type; /* display type */
+ int mode; /* buffer mode */
+ byte bglevel; /* backlight level (sdcmegtron only) */
+#ifdef HAVE_LIBPTHREAD
+ int updating; /* flag: display is currently being updated */
+#endif
+} serdisp_acoolsdcm_data_t;
+
+/* *********************************
+ serdisp_t* serdisp_acoolsdcm_setup(dispname, optionstring)
+ *********************************
+ sets up a display descriptor fitting to dispname and extra
+ *********************************
+ sdcd ... port descriptor
+ dispname ... display name (case-insensitive)
+ optionstring ... option string containing individual options
+ *********************************
+ returns a display descriptor
+*/
+serdisp_t* serdisp_acoolsdcm_setup(const serdisp_CONN_t *sdcd, const char *dispname, const char *optionstring) {
+ serdisp_t* dd = 0;
+ serdisp_acoolsdcm_data_t* data = 0;
+ serdisp_usbdev_t* usbitems = 0;
+
+ byte type = 0;
+
+ sd_debug(2, ">>> %s(sdcd=%p, dispname='%s', optionstring='%s')", __func__, sdcd, dispname, optionstring);
+
+ if(check(dispname == 0 || optionstring == 0)) { return (serdisp_t *)0; }
+
+ if ( ! SDFCTPTR_checkavail(SDFCTPTR_LIBUSB) ) {
+ sd_error(SERDISP_ERUNTIME, "%s(): libusb is not loaded but is a requirement for serdisp_specific_acoolsdcm.c.", __func__);
+ return (serdisp_t*)0;
+ }
+
+ if(sdcd) {
+ /* maybe null in case of wirequery */
+
+ usbitems = (serdisp_usbdev_t*)(sdcd->extra);
+ }
+
+ /* allocate descriptor */
+
+ if(!(dd = (serdisp_t *)sdtools_malloc(sizeof(serdisp_t)))) {
+ sd_error(SERDISP_EMALLOC, "%s(): cannot allocate display descriptor", __func__);
+ return (serdisp_t *)0;
+ }
+
+ memset(dd, 0, sizeof(serdisp_t));
+
+ /* allocate private data */
+
+ if(!(data = sdtools_malloc(sizeof(serdisp_acoolsdcm_data_t)))) {
+ sd_error(SERDISP_EMALLOC, "%s(): cannot allocate private data", __func__);
+ free(dd);
+ dd = 0;
+ return (serdisp_t *)0;
+ }
+
+ memset(data, 0, sizeof(serdisp_acoolsdcm_data_t));
+
+ dd->specific_data = data;
+
+ /* assign dd->dsp_id */
+
+ if(serdisp_comparedispnames("ALPHACOOL", dispname)) {
+ dd->dsp_id = DISPID_ALPHACOOL;
+ } else if(serdisp_comparedispnames("SDCMEGTRON", dispname)) {
+ dd->dsp_id = DISPID_SDCMEGTRON;
+ } else {
+ sd_error(SERDISP_ENOTSUP, "%s(): display type '%s' not supported", __func__, dispname);
+ free(dd->specific_data);
+ free(dd);
+ dd = 0;
+ return (serdisp_t *)0;
+ }
+
+ /* detect display type */
+
+ if(usbitems) {
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR|USB_ENDPOINT_IN,
+ ALPHACOOL_DEVICE, 0, 0, (char *)&type, 1,
+ usbitems->write_timeout) == 1) {
+ if(type == AC_200x64) {
+ dd->width = 200; /* display width */
+ dd->height = 64; /* display height */
+ data->optalgo = 1; /* optimizer on */
+ data->type = AC_200x64; /* display type */
+ data->mode = AC_MD_COL; /* buffer organization */
+ } else if(type == AC_240x128) {
+ dd->width = 240; /* display width */
+ dd->height = 128; /* display height */
+ data->optalgo = 1; /* optimizer on */
+ data->type = AC_240x128; /* display type */
+ data->mode = AC_MD_ROW; /* buffer organization */
+ } else {
+ sd_error(SERDISP_ENOTSUP, "%s(): display type '%d' not supported", __func__, type);
+ free(dd->specific_data);
+ free(dd);
+ dd = 0;
+ return (serdisp_t *)0;
+ }
+
+ sd_debug(1, "%s(): detected %dx%d display", __func__, dd->width, dd->height);
+ } else {
+ /* use default if usb device is unavailable */
+ dd->width = 240;
+ dd->height = 128;
+ data->optalgo = 1;
+
+ sd_debug(1, "%s(): detection failed - using %dx%d as default", __func__, dd->width, dd->height);
+ }
+ } else { /* DISPID_SDCMEGTRON */
+ dd->width = 240; /* display width */
+ dd->height = 128; /* display height */
+ data->optalgo = 1; /* optimizer on */
+ data->type = AC_240x128; /* display type */
+ data->mode = AC_MD_ROW; /* buffer organization */
+
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR|USB_ENDPOINT_IN,
+ USB_LCDAPI_REQUEST, 0, USB_LCDCMD_GETSTOREDLIGHT, (char*)&(data->bglevel), 2,
+ usbitems->write_timeout) == 1) {
+ /* be sure we have at least something */
+ if(data->bglevel < 1) data->bglevel = 0xFF;
+ } else {
+ sd_debug(1, "%s(): USB_LCDCMD_GETSTOREDLIGHT failed", __func__);
+ }
+ }
+ }
+
+ dd->depth = 1; /* display is monochrome */
+ dd->feature_contrast = 0; /* no contrast support */
+ dd->feature_invert = 1; /* can invert */
+ dd->curr_invert = 0; /* not yet inverted */
+ dd->curr_rotate = 0; /* not yet rotated */
+ dd->feature_backlight = 1; /* has backlight */
+ dd->curr_backlight = 1; /* backlight is on */
+ dd->connection_types = SERDISPCONNTYPE_PARPORT;
+ dd->fp_init = &serdisp_acoolsdcm_init;
+ dd->fp_update = &serdisp_acoolsdcm_update;
+ dd->fp_setoption = &serdisp_acoolsdcm_setoption;
+ dd->fp_close = &serdisp_acoolsdcm_close;
+ dd->fp_getvalueptr = &serdisp_acoolsdcm_getvalueptr;
+ dd->fp_clear = &serdisp_acoolsdcm_clear;
+
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ dd->fp_setsdpixel = &serdisp_acoolsdcm_setpixel;
+ dd->fp_getsdpixel = &serdisp_acoolsdcm_getpixel;
+#else
+ dd->fp_setpixel = &serdisp_acoolsdcm_setpixel;
+ dd->fp_getpixel = &serdisp_acoolsdcm_getpixel;
+#endif
+
+#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
+ dd->colour_spaces = SD_CS_SCRBUFCUSTOM | SD_CS_GREYSCALE;
+#endif
+
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ serdisp_setupstructinfos(dd, 0, 0, alphacool_options);
+ } else {
+ serdisp_setupstructinfos(dd, 0, 0, sdcmegtron_options);
+ }
+
+#if 0
+#if (SERDISP_VERSION_CODE > SERDISP_VERSION(1,97))
+ /* add gpevset */
+ if (! (dd->gpevset = (SDGP_gpevset_t*) sdtools_malloc( sizeof(SDGP_gpevset_t)) )) {
+ sd_debug(0,
+ "serdisp_sed153x_init(): cannot allocate memory for event structures. continuing without command processor support ..."
+ );
+ }
+#endif
+#endif
+
+ /* parse and set options */
+
+ if(serdisp_setupoptions(dd, dispname, optionstring)) {
+ free(dd->specific_data);
+ free(dd);
+ dd = 0;
+ return (serdisp_t *)0;
+ }
+
+ /* correct bglevel if option 'BRIGHTNESS' was set */
+ if (dd->dsp_id == DISPID_SDCMEGTRON && dd->curr_dimming) {
+ data->bglevel = sdcmegtron_brightness2bglevel(100 - dd->curr_dimming);
+ }
+
+ sd_debug(2, "<<< %s()", __func__);
+ return(dd);
+}
+
+/* *********************************
+ void serdisp_acoolsdcm_init(dd)
+ *********************************
+ initialise an alphacool USB-display
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_acoolsdcm_init(serdisp_t *dd) {
+ serdisp_usbdev_t* usbitems = 0;
+ serdisp_acoolsdcm_data_t* data = 0;
+
+ sd_debug(2, ">>> %s(dd=%p)", __func__, dd);
+
+ if(check(dd == 0)) { return; }
+
+ usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if(check(usbitems == 0 || data == 0)) { return; }
+
+
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ /* init display */
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, ALPHACOOL_INIT, 0,
+ 0, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'ALPHACOOL_INIT' failed", __func__);
+ }
+ }
+
+#if 0
+ /* clear display */
+
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, ALPHACOOL_CLEAR, 0,
+ 0, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'ALPHACOOL_CLEAR' failed", __func__);
+ }
+#endif
+
+ /* set backlight */
+
+ serdisp_acoolsdcm_setoption(dd, "BACKLIGHT", dd->curr_backlight);
+
+ /* alloc transferbuffer */
+
+ if(data->trans_scrbuf) {
+ /* free previously allocated buffer (if any) */
+
+ free(data->trans_scrbuf);
+ data->trans_scrbuf = 0;
+ }
+
+ if(!(data->trans_scrbuf = (byte *)sdtools_malloc(sizeof(byte) * dd->scrbuf_size))) {
+ sd_error(SERDISP_EMALLOC, "%s(): cannot allocate translation screenbuffer", __func__);
+ return;
+ }
+
+ memset(data->trans_scrbuf, 0, dd->scrbuf_size);
+
+ sd_debug(2, "<<< %s()", __func__);
+ return;
+}
+
+/* *********************************
+ void serdisp_acoolsdcm_update(dd)
+ *********************************
+ updates the display
+ *********************************
+ dd ... display descriptor
+ *********************************
+*/
+void serdisp_acoolsdcm_update(serdisp_t *dd) {
+ int x1 = 0, y1 = 0, x2 = 0, y2 = 0; /* coords */
+ int is_empty = 0; /* indicates empty rect */
+ serdisp_acoolsdcm_data_t *data = 0;
+
+ sd_debug(2, ">>> %s(dd=%p)", __func__, dd);
+
+ if(check(dd == 0)) { return; }
+
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if(check(data == 0)) { return; }
+
+ /*
+ * compute area to transfer - start with the whole display
+ * area. values are byte boundary.
+ */
+
+ switch(data->mode) {
+ case AC_MD_ROW:
+ x1 = 0;
+ y1 = 0;
+ x2 = (dd->width / 8) - 1;
+ y2 = dd->height -1;
+ break;
+
+ case AC_MD_COL:
+ x1 = 0;
+ y1 = 0;
+ x2 = dd->width - 1;
+ y2 = (dd->height / 8) - 1;
+ break;
+
+ default:
+ return;
+ }
+
+ /*
+ * if optimizer has been requested by the user
+ * try to make the rectangle to transfer out of
+ * the display buffer as small as possible
+ */
+
+ if(data->optalgo)
+ {
+ sd_debug(2, " using optimized algo");
+
+ /* detect the smallest rectangle to transfer */
+
+ serdisp_acoolsdcm_getrect(dd, &x1, &y1, &x2, &y2, &is_empty);
+
+ if(!is_empty)
+ {
+ if(data->type == AC_200x64)
+ {
+ /*
+ * this display type has a firmware bug. if the update region
+ * is entirly in the right display half the update fails and
+ * the left half will show the right half too. to avoid this
+ * we make sure that at least 1 pixel of the update region
+ * is in the left half of the display.
+ */
+
+ if(x1 > 99)
+ {
+ x1 = 99;
+ }
+ }
+
+ /* transfer the rectangle to the display */
+
+ serdisp_acoolsdcm_transfer_rect(dd, x1, y1, x2, y2);
+ }
+ }
+ else
+ {
+ sd_debug(2, " optimizer disabled");
+
+ /* transfer the whole buffer */
+
+ serdisp_acoolsdcm_transfer_rect(dd, x1, y1, x2, y2);
+ }
+
+ /* reset change buffer */
+
+ memset(dd->scrbuf_chg, 0x00, dd->scrbuf_chg_size);
+
+ sd_debug(2, "<<< %s()", __func__);
+ return;
+}
+
+/* *********************************
+ void serdisp_acoolsdcm_getrect(dd, x1, y1, x2, y2, is_empty)
+ *********************************
+ extracts the rectangle to transfer. returns
+ coords of smallest rect in x1/y1/x2/y2.
+ *********************************
+ dd ... display descriptor
+ x1/y1 ... upper left of search area
+ x2/y2 ... lower right of search area
+ is_empty ... return value for empty flag
+
+ defs for mode AC_MD_ROW (row mode):
+ x = value for column (byte based)
+ y = value for row
+
+ defs for mode AC_MD_COL (col mode):
+ x = value for column
+ y = value for row (byte based)
+ *********************************
+*/
+void serdisp_acoolsdcm_getrect(serdisp_t *dd, int *x1, int *y1, int *x2, int *y2, int *is_empty)
+{
+ serdisp_acoolsdcm_data_t* data = 0;
+ int x = 0, y = 0;
+ int x1_n = 0, y1_n = 0;
+ int x2_n = 0, y2_n = 0;
+ int bp = 0, byte_offset = 0, bit_offset = 0;
+ byte d = 0;
+
+
+ sd_debug(2, ">>> %s(dd=%p, x1=%d, y1=%d, x2=%d, y2=%d)", __func__, dd, *x1, *y1, *x2, *y2);
+
+ if(check(dd == 0 || *x1 >= *x2 || *y1 >= *y2)) { return; }
+
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if(check(data == 0)) { return; }
+
+ /* init values with caller values */
+
+ x1_n = *x2;
+ y1_n = *y2;
+ x2_n = *x1;
+ y2_n = *y1;
+
+ /* not found anything - consider rect as empty */
+
+ *is_empty = 1;
+
+ /*
+ * search smallest rect in the change buffer
+ * the buffer is bit oriented - so we need to do
+ * a little extra math to mask the bits out
+ * of the bytes. each bit represents the
+ * corresponding byte of the display buffer.
+ * ergo we have a 30 bit wide and 128 bit height
+ * buffer which results in 480 bytes for a
+ * 240x128 pixel display. the bit is set by
+ * the setpixel sub if the byte in the buffer
+ * is changed. this is some kind of delta bitmap
+ * to the last picture sent to the display.
+ */
+
+ for(y=*y1; y<=*y2; y++)
+ {
+ for(x=*x1; x<=*x2; x++)
+ {
+ switch(data->mode)
+ {
+ case AC_MD_ROW:
+ bp = y * (dd->width / 8) + x;
+ break;
+
+ case AC_MD_COL:
+ bp = y * dd->width + x;
+ break;
+
+ default:
+ return;
+ }
+
+ byte_offset = bp / 8;
+ bit_offset = bp % 8;
+
+ d = dd->scrbuf_chg[byte_offset] & (0x80 >> bit_offset);
+
+ if(d) {
+ /*
+ * this bit is set - set the rect
+ * accordingly...
+ */
+
+ if(x<x1_n) { x1_n = x; }
+ if(x>x2_n) { x2_n = x; }
+ if(y<y1_n) { y1_n = y; }
+ if(y>y2_n) { y2_n = y; }
+
+ /* tell the caller that we found something */
+
+ *is_empty = 0;
+ }
+ }
+ }
+
+ /* transfer coords to the caller */
+
+ if(!*is_empty)
+ {
+ *x1 = x1_n;
+ *y1 = y1_n;
+ *x2 = x2_n;
+ *y2 = y2_n;
+ }
+
+ sd_debug(2, "<<< %s()", __func__);
+ return;
+}
+
+/* *********************************
+ void serdisp_acoolsdcm_transfer_rect(dd, x1, y1, x2, y2)
+ *********************************
+ transfer a given rect to the display
+ *********************************
+ dd ... display descriptor
+ x1/y1 ... upper left of area
+ x2/y2 ... lower right of area
+
+ defs for mode AC_MD_ROW:
+ x = value for column (byte based)
+ y = value for row
+
+ defs for mode AC_MD_COL:
+ x = value for column
+ y = value for row (byte based)
+ *********************************
+*/
+void serdisp_acoolsdcm_transfer_rect(serdisp_t *dd, int x1, int y1, int x2, int y2)
+{
+ serdisp_usbdev_t* usbitems = 0;
+ serdisp_acoolsdcm_data_t* data = 0;
+
+ int delta_width = 0, delta_height = 0;
+ int x =0, y = 0;
+ int length = 0, d = 0;
+
+ sd_debug(2, ">>> %s(dd=%p, x1=%d, y1=%d, x2=%d, y2=%d)", __func__, dd, x1, y1, x2, y2);
+
+ if(check(dd == 0)) { return; }
+
+ usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if(check(usbitems == 0 || data == 0)) { return; }
+
+ /*
+ * we need to build the transfer buffer containing only the
+ * bytes of the given region. this is rather simple.
+ *
+ * we do have a second buffer (data->trans_scrbuf) in the size of
+ * the screenbuffer which has been allocated before. so to build
+ * the transferbuffer we just copy the given rectangular region
+ * from the display buffer and transfer the result to the display.
+ */
+
+ delta_width = x2 - x1 + 1; /* width of the change region in bytes */
+ delta_height = y2 - y1 + 1; /* height of the change buffer */
+ length = 0; /* length of the resulting transfer buffer */
+
+ /* copy the transfer buffer */
+
+ for(y=y1; y<=y2; y++)
+ {
+ for(x=x1; x<=x2; x++)
+ {
+ switch(data->mode)
+ {
+ case AC_MD_ROW:
+ d = dd->scrbuf[y * (dd->width / 8) + x];
+ break;
+
+ case AC_MD_COL:
+ d = dd->scrbuf[y * dd->width + x];
+ break;
+
+ default:
+ d = 0;
+ break;
+ }
+
+ /* copy the data and invert if requested */
+
+ data->trans_scrbuf[length] = (dd->curr_invert) ? (d ^ 0xFF) : (d);
+ length++;
+ }
+ }
+
+ if (dd->dsp_id == DISPID_SDCMEGTRON) {
+ /* Atmel MCU Bug: data transfer is banked (ping/pong) and each bank must be filled completely.
+ * So data length must be a multible of 128 byte
+ */
+ length = ((length + 127) / 128) * 128;
+ }
+
+#ifdef HAVE_LIBPTHREAD
+ if (updating_wait(&data->updating) < 0)
+ return;
+#endif
+
+ /*
+ * now we got a transfer buffer (data->trans_scrbuf) with the width
+ * of delta_width and the height of delta_height.
+ */
+
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ /*
+ * init the transfer to the diplay by sending the
+ * ALPHACOOL_GFX_WRITE_INIT command to the display.
+ * this command requires the coordinates of the area
+ * to change as a long (32 bit) value which contains
+ * the upper left coordinate, the width in bytes and
+ * the height in pixels.
+ *
+ * the data is organized as YYXXHHWW so that we need
+ * to do a little shifting
+ */
+
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, ALPHACOOL_GFX_WRITE_INIT,
+ ((y1 << 8) | (x1 & 0xFF)), ((delta_height << 8) | (delta_width & 0xFF)),
+ NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'ALPHACOOL_GFX_WRITE_INIT' failed", __func__);
+ return;
+ }
+ } else { /* DISPID_SDCMEGTRON */
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, USB_LCDAPI_GFXDRAW,
+ (((x1 * 8) << 8) | (y1 & 0xFF)), ((((x2 + 1) * 8) << 8) | ((y2 + 1) & 0xFF)),
+ NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'USB_LCDAPI_GFXDRAW' failed", __func__);
+ return;
+ }
+ }
+
+ /*
+ * do a bulk write with the buffer which should be copied
+ * into the rectangle identified by the prvious command.
+ */
+
+ if(fp_usb_bulk_write(usbitems->usb_dev, usbitems->out_ep /*EP_DISPLAY_DATA_OUT*/,
+ (char *)(data->trans_scrbuf), length,
+ usbitems->write_timeout) < 0)
+ {
+ sd_error(SERDISP_ERUNTIME, "%s(): usb_bulk_write() failed", __func__);
+ return;
+ }
+
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ /*
+ * reset the endpoint
+ */
+
+ if (fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, ALPHACOOL_GFX_WRITE_END,
+ 0, 0,
+ NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'ALPHACOOL_GFX_WRITE_END' failed", __func__);
+ return;
+ }
+ }
+
+#ifdef HAVE_LIBPTHREAD
+ updating_post(&data->updating); /* clear update tag */
+#endif
+
+ return;
+}
+
+/* *********************************
+ int serdisp_acoolsdcm_setoption(dd, optionname, value)
+ *********************************
+ change a display option
+ *********************************
+ dd ... display descriptor
+ optionname ... name of option to change
+ value ... value for option
+ *********************************
+*/
+int serdisp_acoolsdcm_setoption(serdisp_t *dd, const char *optionname, long value) {
+ serdisp_usbdev_t* usbitems = 0;
+ serdisp_acoolsdcm_data_t* data = 0;
+
+ sd_debug(2, ">>> %s(dd=%p, optionname='%s', value=%ld)", __func__, dd, optionname, value);
+
+ if(check(dd == 0 || optionname == 0)) { return 0; }
+
+ usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if(check(usbitems == 0 || data == 0)) { return 0; }
+
+#ifdef HAVE_LIBPTHREAD
+ /* safety shortcut - ugly temp. hack */
+ if (updating_wait(&data->updating) < 0)
+ return 0;
+#endif
+
+ if(dd->feature_backlight && serdisp_compareoptionnames(dd, optionname, "BACKLIGHT")) {
+ /* backlight */
+ byte curr_bgvalue = 0;
+
+ if(value < 2) {
+ dd->curr_backlight = value;
+ } else {
+ dd->curr_backlight = (dd->curr_backlight) ? 0 : 1;
+ }
+
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ curr_bgvalue = (dd->curr_dimming == 100) ? 0 : ( (dd->curr_backlight) ? 1 : 0 );
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, ALPHACOOL_BKL, curr_bgvalue,
+ 0, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'ALPHACOOL_BKL' failed", __func__);
+ }
+ } else { /* DISPID_SDCMEGTRON */
+ dd->curr_dimming = 100 - sdcmegtron_bglevel2brightness(data->bglevel);
+
+ curr_bgvalue = (dd->curr_dimming == 100 || !dd->curr_backlight) ? 0 : data->bglevel;
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, curr_bgvalue,
+ USB_LCDCMD_SETLIGHT, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'USB_LCDCMD_SETLIGHT' failed", __func__);
+ }
+ }
+ } else if(serdisp_compareoptionnames(dd, optionname, "BACKLIGHTLEVEL") ||
+ serdisp_compareoptionnames(dd, optionname, "BRIGHTNESS"))
+ {
+ byte curr_bgvalue = 0;
+
+ /* DISPID_SDCMEGTRON only! */
+ if (serdisp_compareoptionnames(dd, optionname, "BACKLIGHTLEVEL")) {
+ data->bglevel = (value > 255 || value < 0) ? 0xFF : (byte)value;
+ dd->curr_dimming = 100 - sdcmegtron_bglevel2brightness(data->bglevel);
+
+ curr_bgvalue = (dd->curr_backlight == 0) ? 0 : data->bglevel;
+ } else { /* BRIGHTNESS */
+ if (value < 0) value = 0; if (value > 100) value = 100;
+ dd->curr_dimming = 100 - value;
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ curr_bgvalue = (value == 0) ? 0 : dd->curr_backlight;
+ } else {
+ data->bglevel = sdcmegtron_brightness2bglevel(value);
+ curr_bgvalue = (dd->curr_backlight == 0) ? 0 : data->bglevel;
+ }
+ }
+
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, ALPHACOOL_BKL, curr_bgvalue,
+ 0, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'ALPHACOOL_BKL' failed", __func__);
+ }
+ } else {
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, curr_bgvalue,
+ USB_LCDCMD_SETLIGHT, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'USB_LCDCMD_SETLIGHT' failed", __func__);
+ }
+ }
+ } else if(serdisp_compareoptionnames(dd, optionname, "OPTALGO")) {
+ /* transfer optimizer */
+
+ if(value < 2) {
+ data->optalgo = value;
+ } else {
+ data->optalgo = (data->optalgo) ? 0 : 1;
+ }
+ } else {
+ /* option not found here: try generic one in calling serdisp_setoption(); */
+
+ sd_debug(1, "%s(): option unhandled - using fallback", __func__);
+#ifdef HAVE_LIBPTHREAD
+ updating_post(&data->updating);
+#endif
+ return 0;
+ }
+
+ sd_debug(2, "<<< %s()", __func__);
+
+#ifdef HAVE_LIBPTHREAD
+ updating_post(&data->updating);
+#endif
+
+ return 1;
+}
+
+
+/* *********************************
+ void serdisp_acoolsdcm_clear(dd)
+ *********************************
+ clear display
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_acoolsdcm_clear(serdisp_t* dd) {
+ serdisp_usbdev_t* usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
+#ifdef HAVE_LIBPTHREAD
+ serdisp_acoolsdcm_data_t* data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if (updating_wait(&data->updating) < 0)
+ return;
+#endif
+
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, ALPHACOOL_CLEAR, 0,
+ 0, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'ALPHACOOL_CLEAR' failed", __func__);
+ }
+ } else {
+ fp_usb_control_msg(usbitems->usb_dev,USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, 0, USB_LCDCMD_CLRSCR, NULL, 0, 100);
+ }
+
+#ifdef HAVE_LIBPTHREAD
+ updating_post(&data->updating);
+#endif
+}
+
+
+/* *********************************
+ int serdisp_acoolsdcm_getvalueptr(dd, optionname, typesize)
+ *********************************
+ get a display option
+ *********************************
+ dd ... display descriptor
+ optionname ... name of option to change
+ typesize ... pointer to typesize storage
+*/
+void *serdisp_acoolsdcm_getvalueptr(serdisp_t *dd, const char *optionname, int *typesize) {
+ serdisp_acoolsdcm_data_t* data = 0;
+
+ sd_debug(2, ">>> %s(dd=%p, optionname='%s', typesize=%p)", __func__, dd, optionname, typesize);
+
+ if(check(dd == 0 || optionname == 0 || typesize == 0)) { return 0; }
+
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if(check(data == 0)) { return 0; }
+
+ if(serdisp_compareoptionnames(dd, optionname, "OPTALGO")) {
+ *typesize = sizeof(int);
+ return &(data->optalgo);
+ } else if(serdisp_compareoptionnames(dd, optionname, "BACKLIGHTLEVEL")) {
+ *typesize = sizeof(byte);
+ return &(data->bglevel);
+ }
+
+ sd_debug(2, "<<< %s()", __func__);
+ return 0;
+}
+
+/* *********************************
+ void serdisp_acoolsdcm_close(dd)
+ *********************************
+ close (switch off) display
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_acoolsdcm_close(serdisp_t *dd) {
+ serdisp_acoolsdcm_data_t* data = 0;
+
+#if 0
+ unsigned int last_backlight = 0;
+#endif
+ serdisp_usbdev_t* usbitems = 0;
+
+ sd_debug(2, ">>> %s(dd=%p)", __func__, dd);
+
+ if(check(dd == 0)) { return; }
+
+ usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
+
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+#if 0
+ /* set backlight off, but do not remember it */
+
+ last_backlight = dd->curr_backlight;
+ serdisp_acoolsdcm_setoption(dd, "BACKLIGHT", 0);
+ dd->curr_backlight = last_backlight;
+#endif
+
+ /* clear screen */
+ serdisp_clear(dd);
+#ifdef HAVE_LIBPTHREAD
+ if (updating_wait(&data->updating) >= 0) {
+#endif
+ if (dd->dsp_id == DISPID_ALPHACOOL) {
+ fp_usb_control_msg(usbitems->usb_dev,USB_TYPE_VENDOR, ALPHACOOL_BKL, 0, 0, NULL, 0, 1);
+ /*fp_usb_control_msg(usbitems->usb_dev,USB_TYPE_VENDOR, ALPHACOOL_CLEAR, 0, 0, NULL, 0, 1000);*/
+ } else {
+ fp_usb_control_msg(usbitems->usb_dev,USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, 0, USB_LCDCMD_SETLIGHT, NULL, 0, 100);
+ fp_usb_control_msg(usbitems->usb_dev,USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, 0, USB_LCDCMD_CLRSCR, NULL, 0, 100);
+ }
+#ifdef HAVE_LIBPTHREAD
+ }
+ updating_post(&data->updating);
+#endif
+
+
+ /* free buffers */
+
+ if(data) {
+ if(data->trans_scrbuf) {
+ free(data->trans_scrbuf);
+ data->trans_scrbuf = 0;
+ }
+
+ free(data);
+ dd->specific_data = 0;
+ }
+
+ sd_debug(2, "<<< %s()", __func__);
+ return;
+}
+
+/* *********************************
+ void serdisp_acoolsdcm_setpixel(dd, x, y, colour)
+ *********************************
+ changes a pixel into the display buffer
+ *********************************
+ dd ... display descriptor
+ x ... x-position
+ y ... y-position
+ colour ... monochrome: 0: clear (white), <>0: set (black)
+*/
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+void serdisp_acoolsdcm_setpixel(serdisp_t *dd, int x, int y, SDCol colour) {
+#else
+void serdisp_acoolsdcm_setpixel(serdisp_t *dd, int x, int y, long colour) {
+#endif
+ serdisp_acoolsdcm_data_t* data = 0;
+
+ unsigned int x_i = 0, y_i = 0, w_b = 0, x_b = 0, y_b = 0, pos = 0;
+ byte value_orig = 0, value = 0, mask = 0;
+
+ if(check(dd == 0)) { return; }
+
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if(check(data == 0)) { return; }
+
+ if(dd->curr_rotate <= 1) {
+ if(x >= dd->width || y >= dd->height || x < 0 || y < 0)
+ {
+ return;
+ }
+ } else {
+ if(x >= dd->height || y >= dd->width || x < 0 || y < 0) {
+ return;
+ }
+ }
+
+ switch(dd->curr_rotate) { /* no reloctabs used by alphacool: so we don't have to consider them here */
+ case 0: /* 0 degrees */
+ x_i = x;
+ y_i = y;
+ break;
+ case 1: /* 180 degrees */
+ x_i = dd->width - 1 - x;
+ y_i = dd->height - 1 - y;
+ break;
+ case 2: /* 90 degrees */
+ x_i = y;
+ y_i = dd->height - 1 - x;
+ break;
+ case 3: /* 270 degrees */
+ x_i = dd->width - 1 - y;
+ y_i = x;
+ break;
+ }
+
+ /* set the bit in the buffer */
+
+ switch(data->mode) {
+ case AC_MD_ROW:
+ w_b = dd->width / 8;
+ x_b = x_i / 8;
+ pos = y_i * w_b + x_b;
+
+ value_orig = dd->scrbuf[pos];
+ mask = 0x80 >> (x_i % 8);
+ break;
+
+ case AC_MD_COL:
+ y_b = y_i / 8;
+ pos = y_b * dd->width + x_i;
+
+ value_orig = dd->scrbuf[pos];
+ mask = 0x80 >> (y_i % 8);
+ break;
+
+ default:
+ return;
+ }
+
+ value = (colour) ? (value_orig | mask) : (value_orig & (0xFF ^ mask));
+
+ /* update the change buffer */
+
+ if(value_orig != value) {
+ dd->scrbuf[pos] = value;
+ dd->scrbuf_chg[pos/8] |= 0x80 >> (pos % 8);
+ }
+}
+
+/* *********************************
+ SDCol serdisp_acoolsdcm_getpixel(dd, x, y) (arch indep. colour functions)
+ long serdisp_acoolsdcm_getpixel(dd, x, y) (arch dep. colour functions (using 'long'))
+ *********************************
+ changes a pixel in the display buffer. supported depths: 1
+ *********************************
+ dd ... display descriptor
+ x ... x-position
+ y ... y-position
+ *********************************
+ returns the grey value (or hw dependend index) at (x/y)
+*/
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+SDCol serdisp_acoolsdcm_getpixel(serdisp_t *dd, int x, int y) {
+#else
+long serdisp_acoolsdcm_getpixel(serdisp_t *dd, int x, int y) {
+#endif
+ serdisp_acoolsdcm_data_t* data = 0;
+
+ unsigned int x_i = 0, y_i = 0, w_b = 0, x_b = 0, y_b = 0, pos = 0;
+ byte value = 0, mask = 0;
+
+ if(check(dd == 0)) { return 0; }
+
+ data = (serdisp_acoolsdcm_data_t *)(dd->specific_data);
+
+ if(check(data == 0)) { return 0; }
+
+ if(dd->curr_rotate <= 1) {
+ if(x >= dd->width || y >= dd->height || x < 0 || y < 0) {
+ return 0;
+ }
+ } else {
+ if(x >= dd->height || y >= dd->width || x < 0 || y < 0) {
+ return 0;
+ }
+ }
+
+ switch(dd->curr_rotate) { /* no reloctabs used by alphacool: so we don't have to consider them here */
+ case 0: /* 0 degrees */
+ x_i = x;
+ y_i = y;
+ break;
+ case 1: /* 180 degrees */
+ x_i = dd->width - 1 - x;
+ y_i = dd->height - 1 - y;
+ break;
+ case 2: /* 90 degrees */
+ x_i = y;
+ y_i = dd->height - 1 - x;
+ break;
+ case 3: /* 270 degrees */
+ x_i = dd->width - 1 - y;
+ y_i = x;
+ break;
+ }
+
+ /* get the corresponding bit from the buffer */
+
+ switch(data->mode) {
+ case AC_MD_ROW:
+ w_b = dd->width / 8;
+ x_b = x_i / 8;
+ pos = y_i * w_b + x_b;
+
+ value = dd->scrbuf[pos];
+ mask = 0x80 >> (x_i % 8);
+ break;
+
+ case AC_MD_COL:
+ y_b = y_i / 8;
+ pos = y_b * dd->width + x_i;
+
+ value = dd->scrbuf[pos];
+ mask = 0x80 >> (y_i % 8);
+ break;
+
+ default:
+ return 0;
+ }
+
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ return (SDCol)((value & mask) ? 1 : 0);
+#else
+ return (long)((value & mask) ? 1 : 0);
+#endif
+}
+
+/* *********************************
+ int serdisp_acoolsdcm_runtime_check(condition, function)
+ *********************************
+ check condition and sets global runtime error if appropriate
+ *********************************
+ condition ... evals to 'true' if there's an error
+ function ... runtime function name (defined by check macro)
+ file ... runtime file name (defined by check macro)
+ line ... runtime line number (defined by check macro)
+ *********************************
+ returns the condition
+*/
+int serdisp_acoolsdcm_runtime_check(int condition, const char *function, const char *file, const int line) {
+ if(condition) {
+ sd_runtimeerror = 1;
+ sd_error(SERDISP_ERUNTIME, "%s(): runtime error detected (%s, line %d)", function, file, line);
+ }
+
+ return(condition);
+}
+
+
+int sdcmegtron_bglevel2brightness (int bglevel) {
+ /* bglevel: [0 - 255]
+ brightness: [0 - 100]
+ */
+ return (bglevel * 100 ) / 255;
+}
+
+int sdcmegtron_brightness2bglevel (int brightness) {
+ return (brightness * 255) / 100;
+}
+
+
+
+#ifdef HAVE_LIBPTHREAD
+int updating_wait (int* upd_flag) {
+ int max_try = 20;
+ while (*upd_flag && max_try > 0) {
+ usleep(1);
+ max_try --;
+ }
+ if (*upd_flag) {
+ return -1;
+ }
+ *upd_flag = 1; /* grab it for our uses */
+ return 0;
+}
+
+void updating_post (int* upd_flag) {
+ *upd_flag = 0;
+}
+#endif
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_directgfx.c
^
|
@@ -0,0 +1,428 @@
+/*
+ *************************************************************************
+ *
+ * serdisp_specific_directgfx.c
+ * routines for drawing content to SDL / GL / ... output
+ *
+ *************************************************************************
+ *
+ * copyright (C) 2008-2010 wolfgang astleitner
+ * email mrwastl@users.sourceforge.net
+ *
+ *************************************************************************
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "../config.h"
+
+#include "serdisplib/serdisp_connect.h"
+#include "serdisplib/serdisp_tools.h"
+#include "serdisplib/serdisp_messages.h"
+#include "serdisplib/serdisp_colour.h"
+
+#include "serdisplib/serdisp_fctptr.h"
+
+
+/* #define OPT_USEOLDUPDATEALGO */
+
+/*
+ * constants
+ */
+
+/* different display types/models supported by this driver */
+#define DISPID_SDL 1
+
+
+serdisp_options_t serdisp_directgfx_options[] = {
+ /* name aliasnames min max mod int defines */
+ { "DEPTH", "COLS,COLOURS", 1, 32, 2, 0, "64k=16,4096=12,4k=12,256=8"}
+ ,{ "WIDTH", "", 1, 1024, 1, 0, ""}
+ ,{ "HEIGHT", "", 1, 1024, 1, 0, ""}
+/* ,{ "FULLSCREEN", "FS", 0, 1, 1, 0, ""}*/
+};
+
+
+/* internal typedefs and functions */
+
+static void serdisp_directgfx_init (serdisp_t*);
+static void serdisp_directgfx_update (serdisp_t*);
+static int serdisp_directgfx_setoption (serdisp_t*, const char*, long);
+static void serdisp_directgfx_close (serdisp_t*);
+
+
+typedef struct serdisp_directgfx_specific_s {
+ int fullscreen;
+ void* screen;
+} serdisp_directgfx_specific_t;
+
+
+static serdisp_directgfx_specific_t* serdisp_directgfx_internal_getStruct(serdisp_t* dd) {
+ return (serdisp_directgfx_specific_t*)(dd->specific_data);
+}
+
+
+/* callback-function for setting non-standard options */
+static void* serdisp_directgfx_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+ if (serdisp_compareoptionnames(dd, optionname, "DEPTH")) {
+ *typesize = sizeof(byte);
+ return &(dd->depth);
+ } else if (serdisp_compareoptionnames(dd, optionname, "FULLSCREEN")) {
+ *typesize = sizeof(int);
+ return &(serdisp_directgfx_internal_getStruct(dd)->fullscreen);
+ }
+ return 0;
+}
+
+
+
+/* main functions */
+
+
+/* *********************************
+ serdisp_t* serdisp_directgfx_setup(sdcd, dispname, optionstring)
+ *********************************
+ sets up a display descriptor fitting to dispname and extra
+ *********************************
+ sdcd ... output device handle
+ dispname ... display name (case-insensitive)
+ optionstring ... option string containing individual options
+ *********************************
+ returns a display descriptor
+*/
+serdisp_t* serdisp_directgfx_setup(const serdisp_CONN_t* sdcd, const char* dispname, const char* optionstring) {
+ serdisp_t* dd;
+
+ if ( ! SDFCTPTR_checkavail(SDFCTPTR_LIBSDL) ) {
+ sd_error(SERDISP_ERUNTIME, "%s(): libSDL is not loaded.", __func__);
+ return (serdisp_t*)0;
+ }
+
+ if (! (dd = (serdisp_t*)sdtools_malloc(sizeof(serdisp_t)) ) ) {
+ sd_error(SERDISP_EMALLOC, "%s(): cannot allocate display descriptor", __func__);
+ return (serdisp_t*)0;
+ }
+ memset(dd, 0, sizeof(serdisp_t));
+
+ if (! (dd->specific_data = (void*) sdtools_malloc( sizeof(serdisp_directgfx_specific_t)) )) {
+ free(dd);
+ return (serdisp_t*)0;
+ }
+ memset(dd->specific_data, 0, sizeof(serdisp_directgfx_specific_t));
+
+ /* output devices like SDL supported here */
+ /* assign dd->dsp_id */
+ if (serdisp_comparedispnames("SDL", dispname))
+ dd->dsp_id = DISPID_SDL;
+ else { /* should not occur */
+ sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_specific_directgfx.c", dispname);
+ return (serdisp_t*)0;
+ }
+
+ dd->sdcd = (serdisp_CONN_t*)sdcd;
+
+ /* supported output devices */
+ dd->connection_types = SERDISPCONNTYPE_OUT;
+
+
+ serdisp_directgfx_internal_getStruct(dd)->fullscreen = 1;
+
+ dd->feature_contrast = 0;
+ dd->feature_backlight = 0;
+ dd->feature_invert = 0;
+
+ /* per display settings */
+
+ dd->width = 320;
+ dd->height = 240;
+ dd->depth = 32;
+
+ /* max. delta for optimised update algorithm */
+ dd->optalgo_maxdelta = 0; /* unused, bbox is used for optimisation */
+
+ dd->delay = 0;
+
+ /* finally set some non display specific defaults */
+
+ dd->curr_rotate = 0; /* unrotated display */
+ dd->curr_invert = 0; /* display not inverted */
+
+ dd->curr_backlight = 0; /* start with backlight on */
+
+ /* supported colour spaces */
+ dd->colour_spaces = SD_CS_GREYSCALE | SD_CS_RGB332 | SD_CS_RGB444 | SD_CS_RGB565;
+ dd->colour_spaces |= SD_CS_TRUECOLOUR | SD_CS_ATRUECOLOUR;
+ dd->colour_spaces |= SD_CS_SELFEMITTING;
+
+ dd->fp_init = &serdisp_directgfx_init;
+ dd->fp_update = &serdisp_directgfx_update;
+/* dd->fp_clear = &serdisp_directgfx_clear;*/
+ dd->fp_close = &serdisp_directgfx_close;
+ dd->fp_setoption = &serdisp_directgfx_setoption;
+ dd->fp_getvalueptr = &serdisp_directgfx_getvalueptr;
+
+ serdisp_setupstructinfos(dd, 0, 0, serdisp_directgfx_options);
+
+ /* parse and set options */
+ if (serdisp_setupoptions(dd, dispname, optionstring) ) {
+ serdisp_freeresources(dd);
+ dd = 0;
+ return (serdisp_t*)0;
+ }
+
+ return dd;
+}
+
+
+
+/* *********************************
+ void serdisp_directgfx_init(dd)
+ *********************************
+ initialise
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_directgfx_init(serdisp_t* dd) {
+ char caption[40];
+ SDL_Surface* screen;
+
+ if (fp_SDL_Init(SDL_INIT_VIDEO) != 0) {
+ sd_error(SERDISP_ENOTSUP, "%s(): unable to initialise SDL: %s", __func__, fp_SDL_GetError());
+ sd_runtimeerror = 1;
+ fp_SDL_Quit();
+ return;
+ }
+
+ screen = serdisp_directgfx_internal_getStruct(dd)->screen =
+ (void*)fp_SDL_SetVideoMode(dd->width, dd->height, 0 /*sdl_depth*/, SDL_HWSURFACE | SDL_HWACCEL);
+
+ if (screen == NULL) {
+ sd_error(SERDISP_ENOTSUP, "%s(): unable to set video mode: %s", __func__, fp_SDL_GetError());
+ sd_runtimeerror = 1;
+ fp_SDL_Quit();
+ return;
+ }
+
+ snprintf(caption, sizeof(caption)-1, "serdisplib::SDL %dx%dx%d", screen->w, screen->h, screen->format->BitsPerPixel);
+ fp_SDL_WM_SetCaption(caption, NULL);
+
+ sd_debug(2, "%s(): done with initialising", __func__);
+}
+
+
+
+/* *********************************
+ void serdisp_directgfx_update(dd)
+ *********************************
+ updates the display using display-buffer scrbuf+scrbuf_chg
+ *********************************
+ dd ... display descriptor
+ *********************************
+ the display is redrawn using a time-saving algorithm
+*/
+void serdisp_directgfx_update(serdisp_t* dd) {
+ int x, y;
+
+ SDL_Surface* screen = (SDL_Surface*)serdisp_directgfx_internal_getStruct(dd)->screen;
+ uint8_t* bufp8;
+ uint16_t* bufp16;
+ uint32_t* bufp32;
+ uint32_t colour;
+ uint32_t colour_raw;
+ byte ashift = screen->format->Ashift/8;
+ byte rshift = screen->format->Rshift/8;
+ byte gshift = screen->format->Gshift/8;
+ byte bshift = screen->format->Bshift/8;
+
+ if(dfn_SDL_MUSTLOCK( screen ) )
+ fp_SDL_LockSurface( screen );
+
+ if (screen->format->BitsPerPixel == dd->depth && dd->depth >= 24) {
+ int idx;
+ uint8_t* ddbuf = (uint8_t*)dd->scrbuf;
+ bufp8 = (uint8_t*)screen->pixels;
+ int xstep = (dd->depth == 24) ? 3 : 4;
+
+ int idx_start = 0;
+ int idx_end = dd->scrbuf_size;
+#ifdef OPT_USEOLDUPDATEALGO
+ /* unoptimised display update (slow. all pixels are redrawn) */
+#else
+ int idx_limit = 0;
+ int idx_border = 0;
+
+ if (dd->scrbuf_chg) {
+ idx_start = dd->scrbuf_size;
+ idx_end = 0;
+
+ idx = 0;
+ idx_border = 0;
+ while (idx < dd->scrbuf_chg_size) {
+ if (dd->scrbuf_chg[idx]) {
+ idx_start = idx_border;
+ idx_limit = idx;
+ idx = dd->scrbuf_chg_size;
+ } else {
+ idx++;
+ idx_border += xstep << 3;
+ }
+ }
+ idx = dd->scrbuf_chg_size - 1;
+ idx_border = (idx << 3) * xstep + (xstep << 3) - 1;
+ while (idx >= 0 && idx > idx_limit) {
+ if (dd->scrbuf_chg[idx]) {
+ idx_end = idx_border;
+ idx = -1;
+ } else {
+ idx--;
+ idx_border -= xstep << 3;
+ }
+ }
+ }
+/* fprintf(stderr, "idx_start: %d idx_end: %d\n", idx_start, idx_end);*/
+#endif /* OPT_USEOLDUPDATEALGO */
+ if (dd->depth == 24) {
+ for (idx = idx_start; idx < idx_end; idx += xstep) {
+ *(bufp8 + idx + rshift) = *(ddbuf + idx);
+ *(bufp8 + idx + gshift) = *(ddbuf + idx + 1);
+ *(bufp8 + idx + bshift) = *(ddbuf + idx + 2);
+
+ if (dd->curr_invert) {
+ *(bufp8 + idx + rshift) = ~ *(bufp8 + idx + rshift);
+ *(bufp8 + idx + gshift) = ~ *(bufp8 + idx + gshift);
+ *(bufp8 + idx + bshift) = ~ *(bufp8 + idx + bshift);
+ }
+ }
+ } else {
+ for (idx = idx_start; idx < idx_end; idx += xstep) {
+ *(bufp8 + idx + ashift) = *(ddbuf + idx);
+ *(bufp8 + idx + rshift) = *(ddbuf + idx + 1);
+ *(bufp8 + idx + gshift) = *(ddbuf + idx + 2);
+ *(bufp8 + idx + bshift) = *(ddbuf + idx + 3);
+
+ if (dd->curr_invert) {
+ *(bufp8 + idx + rshift) = ~ *(bufp8 + idx + rshift);
+ *(bufp8 + idx + gshift) = ~ *(bufp8 + idx + gshift);
+ *(bufp8 + idx + bshift) = ~ *(bufp8 + idx + bshift);
+ }
+ }
+ }
+ } else {
+ /* unset curr_rotate so that it will not interfere with serdisp_setsdcol() */
+ int temp_rotate = dd->curr_rotate;
+ dd->curr_rotate = 0;
+
+ for (y = 0; y < dd->height; y++) {
+ for (x = 0; x < dd->width; x++) {
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ colour_raw = serdisp_getsdcol(dd, x, y);
+#else
+ colour_raw = (uint32_t)serdisp_getcolour(dd, x, y);
+#endif
+
+ if (dd->curr_invert)
+ colour_raw = (colour_raw & 0xFF000000) | ~(colour_raw & 0x00FFFFFF);
+
+ colour = fp_SDL_MapRGB(
+ screen->format,
+ (colour_raw & 0x00FF0000) >> 16,
+ (colour_raw & 0x0000FF00) >> 8,
+ (colour_raw & 0x000000FF)
+ );
+
+ switch(screen->format->BytesPerPixel) {
+ case 1: {
+ bufp8 = (uint8_t*)screen->pixels + y * screen->pitch + x;
+ *bufp8 = (uint8_t)colour;
+ }
+ break;
+ case 2: {
+ bufp16 = (uint16_t*)screen->pixels + y * screen->pitch/2 + x;
+ *bufp16 = (uint16_t)colour;
+ }
+ break;
+ case 3: {
+ bufp8 = (uint8_t*)screen->pixels + y * screen->pitch + x * 3;
+ *(bufp8 + rshift) = (colour_raw & 0x00FF0000) >> 16;
+ *(bufp8 + gshift) = (colour_raw & 0x0000FF00) >> 8;
+ *(bufp8 + bshift) = (colour_raw & 0x000000FF);
+ }
+ break;
+ case 4: {
+ bufp32 = (uint32_t*)screen->pixels + y * screen->pitch/4 + x;
+ *bufp32 = (uint32_t)colour;
+ }
+ break;
+ }
+ }
+ }
+ /* re-enable curr_rotate */
+ dd->curr_rotate = temp_rotate;
+ }
+
+#ifndef OPT_USEOLDUPDATEALGO
+ memset(dd->scrbuf_chg, 0x00, dd->scrbuf_chg_size);
+#endif
+
+ if(dfn_SDL_MUSTLOCK( screen ) )
+ fp_SDL_UnlockSurface( screen );
+
+ fp_SDL_Flip(screen);
+}
+
+
+
+/* *********************************
+ int serdisp_directgfx_setoption(dd, option, value)
+ *********************************
+ change a display option
+ *********************************
+ dd ... display descriptor
+ option ... name of option to change
+ value ... value for option
+*/
+int serdisp_directgfx_setoption(serdisp_t* dd, const char* option, long value) {
+#if 0
+ if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST")) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+#endif
+ /* option not found here: try generic one in calling serdisp_setoption(); */
+ return 0;
+#if 0
+ }
+ return 1;
+#endif
+}
+
+
+/* *********************************
+ void serdisp_directgfx_close(dd)
+ *********************************
+ close (switch off) display
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_directgfx_close(serdisp_t* dd) {
+ fp_SDL_FreeSurface((SDL_Surface*)(serdisp_directgfx_internal_getStruct(dd)->screen));
+ fp_SDL_Quit();
+}
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_goldelox.c
^
|
@@ -7,7 +7,7 @@
*
*************************************************************************
*
- * copyright (C) 2007-2008 wolfgang astleitner
+ * copyright (C) 2007-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -55,6 +55,7 @@
{ "DEPTH", "COLS,COLOURS", 8, 16, 8, 0, "65536=16,64k=16,256=8"}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
,{ "BACKLIGHT", "", 0, 1, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
};
@@ -66,13 +67,19 @@
static void serdisp_goldelox_clear (serdisp_t*);
static void serdisp_goldelox_close (serdisp_t*);
+static int serdisp_goldelox_is_oled (byte);
+static int serdisp_goldelox_translate_rescode (byte code);
+static int read_ACK (serdisp_t*);
+static void write_byte (serdisp_t*, byte);
+static void do_commit (serdisp_t*);
+
typedef struct serdisp_goldelox_specific_s {
int is_oled;
} serdisp_goldelox_specific_t;
-serdisp_goldelox_specific_t* serdisp_goldelox_internal_getStruct(serdisp_t* dd) {
+static serdisp_goldelox_specific_t* serdisp_goldelox_internal_getStruct(serdisp_t* dd) {
return (serdisp_goldelox_specific_t*)(dd->specific_data);
}
@@ -126,17 +133,8 @@
}
-int read_buffer (serdisp_t* dd, unsigned char* buf, int len) {
- int i;
- for (i = 0; i < len; i++) {
- buf[i] = SDCONN_read(dd->sdcd, 0);
- }
- return len;
-}
-
-
/* callback-function for setting non-standard options */
-void* serdisp_goldelox_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+static void* serdisp_goldelox_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
if (serdisp_compareoptionnames(dd, optionname, "DEPTH")) {
*typesize = sizeof(byte);
return &(dd->depth);
@@ -207,13 +205,16 @@
return (serdisp_t*)0;
}
+ /* set RS232 parameters (will be set / initialised by SDCONN_confinit() */
+ dd->sdcd->rs232.baudrate = B230400;
+
write_byte (dd, 0x55); /* baud autodetect */
read_ACK (dd);
write_byte (dd, 0x56); /* request display information */
write_byte (dd, 0x00); /* param: 0x00 */
do_commit (dd);
- read_buffer(dd, infobuffer, 5);
+ SDCONN_readstream(dd->sdcd, infobuffer, 5);
/* returns 5 values:
0: device type: 0x00: OLED, 0x01: LCD, 0x02: VGA
@@ -263,9 +264,6 @@
dd->fp_setoption = &serdisp_goldelox_setoption;
dd->fp_getvalueptr = &serdisp_goldelox_getvalueptr;
- dd->fp_setpixel = &sdtools_generic_setpixel;
- dd->fp_getpixel = &sdtools_generic_getpixel;
-
serdisp_setupstructinfos(dd, 0, 0, serdisp_goldelox_options);
/* parse and set options */
@@ -429,12 +427,25 @@
write_byte (dd, 0x00); /* mode: backlight on/off */
write_byte (dd, dd->curr_backlight);
read_ACK (dd);
- } else if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST")) {
- dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else if (dd->feature_contrast &&
+ (serdisp_compareoptionnames(dd, option, "CONTRAST" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ )
+ {
+ int dimmed_contrast;
+
+ if ( serdisp_compareoptionnames(dd, option, "CONTRAST" ) ) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+ dd->curr_dimming = 100 - (int)value;
+ }
+
+ dimmed_contrast = (((dd->curr_contrast - dd->min_contrast) * (100 - dd->curr_dimming)) / 100) + dd->min_contrast;
write_byte (dd, 0x59); /* display control */
write_byte (dd, 0x02); /* mode: display contrast */
- write_byte (dd, dd->curr_contrast);
+ write_byte (dd, dimmed_contrast /*dd->curr_contrast*/);
read_ACK (dd);
} else {
/* option not found here: try generic one in calling serdisp_setoption(); */
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_i2c.c
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -42,9 +42,6 @@
/*#define OPT_NOOUTPUT*/
/*#define OPT_USEOLDUPDATEALGO*/
-/* delay 5 ms */
-#define DELAY_RESET() usleep(5)
-
#define SIG_SDA (dd->sdcd->signals[0])
#define SIG_SCLK (dd->sdcd->signals[1])
@@ -87,6 +84,10 @@
static void serdisp_i2c_close (serdisp_t*);
static void serdisp_i2c_transfer (serdisp_t*, int, byte);
+static void serdisp_i2c_t2x_cmd_init (serdisp_t* dd);
+static void serdisp_i2c_r520_cmd_init (serdisp_t* dd);
+
+
typedef struct serdisp_i2c_specific_s {
byte address;
byte address2;
@@ -103,12 +104,12 @@
} serdisp_i2c_specific_t;
-serdisp_i2c_specific_t* serdisp_i2c_internal_getStruct(serdisp_t* dd) {
+static serdisp_i2c_specific_t* serdisp_i2c_internal_getStruct(serdisp_t* dd) {
return (serdisp_i2c_specific_t*)(dd->specific_data);
}
-void serdisp_i2c_internal_i2cSIGNALS(serdisp_t* dd, int sda, int sclk) {
+static void serdisp_i2c_internal_i2cSIGNALS(serdisp_t* dd, int sda, int sclk) {
long td = 0;
if (dd->feature_backlight && dd->curr_backlight)
@@ -123,7 +124,7 @@
}
-void serdisp_i2c_internal_i2cSTART(serdisp_t* dd) {
+static void serdisp_i2c_internal_i2cSTART(serdisp_t* dd) {
/* start with SDA and SCLK set to high */
serdisp_i2c_internal_i2cSIGNALS(dd, 1, 1);
/* SDA -> low; SCLK stays high */
@@ -135,7 +136,7 @@
serdisp_i2c_transfer(dd, 0, (serdisp_i2c_internal_getStruct(dd))->curr_address);
}
-void serdisp_i2c_internal_i2cSTOP(serdisp_t* dd) {
+static void serdisp_i2c_internal_i2cSTOP(serdisp_t* dd) {
/* start with SDA set to low, and SCLK set to high */
serdisp_i2c_internal_i2cSIGNALS(dd, 0, 1);
/* SDA -> high; SCLK stays high */
@@ -152,20 +153,20 @@
}
-void serdisp_i2c_t2x_cmd_blank(serdisp_t* dd) {
+static void serdisp_i2c_t2x_cmd_blank(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x3);
}
-void serdisp_i2c_t2x_cmd_normal(serdisp_t* dd) {
+static void serdisp_i2c_t2x_cmd_normal(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x9);
}
-void serdisp_i2c_t2x_cmd_allon(serdisp_t* dd) {
+static void serdisp_i2c_t2x_cmd_allon(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x2);
}
-void serdisp_i2c_t2x_cmd_setpos(serdisp_t* dd, int x, int page) {
+static void serdisp_i2c_t2x_cmd_setpos(serdisp_t* dd, int x, int page) {
serdisp_i2c_transfer(dd, 0, 0x9 | (page<<5));
serdisp_i2c_transfer(dd, 0, x);
}
@@ -183,24 +184,24 @@
}
-void serdisp_i2c_r520_cmd_blank(serdisp_t* dd) {
+static void serdisp_i2c_r520_cmd_blank(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x1); /* found using trial&error */
}
-void serdisp_i2c_r520_cmd_normal(serdisp_t* dd) {
+static void serdisp_i2c_r520_cmd_normal(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x2); /* trial&error (and was also the 2nd line in z01's trace) */
}
-void serdisp_i2c_r520_cmd_invert(serdisp_t* dd) {
+static void serdisp_i2c_r520_cmd_invert(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x3); /* found using trial&error */
}
-void serdisp_i2c_r520_cmd_allon(serdisp_t* dd) {
+static void serdisp_i2c_r520_cmd_allon(serdisp_t* dd) {
/* serdisp_i2c_transfer(dd, 0, 0x2);*/
}
-void serdisp_i2c_r520_cmd_setpos(serdisp_t* dd, int x, int page) {
+static void serdisp_i2c_r520_cmd_setpos(serdisp_t* dd, int x, int page) {
serdisp_i2c_transfer(dd, 0, 0x42); /* extracted from z01's trace */
serdisp_i2c_transfer(dd, 0, page);
serdisp_i2c_transfer(dd, 0, x);
@@ -220,28 +221,28 @@
serdisp_i2c_transfer(dd, 0, 0x0C); /* display control; set normal mode (D=1, E=0) */
}
-void serdisp_i2c_r320_cmd_blank(serdisp_t* dd) {
+static void serdisp_i2c_r320_cmd_blank(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x80); /* control byte with set Co bit and D/C set to logical 0 */
serdisp_i2c_transfer(dd, 0, 0x08); /* display control; set blank mode (D=0, E=0) */
}
-void serdisp_i2c_r320_cmd_normal(serdisp_t* dd) {
+static void serdisp_i2c_r320_cmd_normal(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x80); /* control byte with set Co bit and D/C set to logical 0 */
serdisp_i2c_transfer(dd, 0, 0x0C); /* display control; set normal mode (D=1, E=0) */
}
-void serdisp_i2c_r320_cmd_allon(serdisp_t* dd) {
+static void serdisp_i2c_r320_cmd_allon(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x80); /* control byte with set Co bit and D/C set to logical 0 */
serdisp_i2c_transfer(dd, 0, 0x09); /* display control; set all on mode (D=0, E=0) */
}
-void serdisp_i2c_r320_cmd_invert(serdisp_t* dd) {
+static void serdisp_i2c_r320_cmd_invert(serdisp_t* dd) {
serdisp_i2c_transfer(dd, 0, 0x80); /* control byte with set Co bit and D/C set to logical 0 */
serdisp_i2c_transfer(dd, 0, 0x0d); /* display control; set revese mode (D=1, E=1) */
}
-void serdisp_i2c_r320_cmd_setpos(serdisp_t* dd, int x, int page) {
+static void serdisp_i2c_r320_cmd_setpos(serdisp_t* dd, int x, int page) {
#if 0
if (x >= 0 && x <= 0x7f) {
serdisp_i2c_transfer(dd, 0, 0x80); /* one control byte */
@@ -316,8 +317,6 @@
dd->fp_update = &serdisp_i2c_update;
dd->fp_setoption = &serdisp_i2c_setoption;
dd->fp_close = &serdisp_i2c_close;
- dd->fp_setpixel = &sdtools_generic_setpixel;
- dd->fp_getpixel = &sdtools_generic_getpixel;
/* per display settings */
@@ -358,16 +357,29 @@
serdisp_i2c_internal_getStruct(dd)->fp_cmd_invert = &serdisp_i2c_r520_cmd_invert;
/* allocate and initialise colour table */
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ if (! (dd->ctable = (SDCol*) sdtools_malloc( sizeof(SDCol) * 4 ) ) ) {
+#else
if (! (dd->ctable = (long*) sdtools_malloc( sizeof(long) * 4 ) ) ) {
+#endif
sd_error(SERDISP_EMALLOC, "serdisp_i2c_setup(): cannot allocate indexed colour table");
free(dd->specific_data);
free(dd);
return (serdisp_t*)0;
}
+
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ serdisp_setsdcoltabentry(dd, 0, serdisp_GREY2ARGB(0xFF)); /* white */
+ serdisp_setsdcoltabentry(dd, 1, serdisp_GREY2ARGB(0xAA));
+ serdisp_setsdcoltabentry(dd, 2, serdisp_GREY2ARGB(0x55));
+ serdisp_setsdcoltabentry(dd, 3, serdisp_GREY2ARGB(0x00)); /* black */
+#else
serdisp_setcoltabentry(dd, 0, serdisp_GREY2ARGB(0xFF)); /* white */
serdisp_setcoltabentry(dd, 1, serdisp_GREY2ARGB(0xAA));
serdisp_setcoltabentry(dd, 2, serdisp_GREY2ARGB(0x55));
serdisp_setcoltabentry(dd, 3, serdisp_GREY2ARGB(0x00)); /* black */
+#endif
+
#if 0
} else if (dd->dsp_id == DISPID_ERICSSONR320) {
dd->width = 102;
@@ -452,10 +464,12 @@
if (dd->sdcd->conntype == SERDISPCONNTYPE_PARPORT && SIG_RESET) {
/* RESET to low */
SDCONN_write(dd->sdcd, SIG_RESET, 0);
- DELAY_RESET();
+
+ /* delay 5 ms */
+ SDCONN_usleep(dd->sdcd, 5);
}
-
- usleep(1); /* if serraw: give display enough time to init after powering up */
+
+ SDCONN_usleep(dd->sdcd, 1); /* if serraw: give display enough time to init after powering up */
serdisp_i2c_internal_i2cSTART(dd);
serdisp_i2c_internal_getStruct(dd)->fp_cmd_init(dd);
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_ks0108.c
^
|
@@ -7,7 +7,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -42,9 +42,6 @@
#undef OPT_USEOLDUPDATEALGO
#define OPT_USEUPDATEDELTAALGO
-/* min. 1 uS according to data sheet. we use 5 to be sure */
-#define DELAY_RESET() usleep(5)
-
/*
* command constants
@@ -138,7 +135,7 @@
-serdisp_ks0108_specific_t* serdisp_ks0108_internal_getStruct(serdisp_t* dd) {
+static serdisp_ks0108_specific_t* serdisp_ks0108_internal_getStruct(serdisp_t* dd) {
return (serdisp_ks0108_specific_t*)(dd->specific_data);
}
@@ -194,8 +191,6 @@
dd->fp_update = &serdisp_ks0108_update;
dd->fp_setoption = &serdisp_ks0108_setoption;
dd->fp_close = &serdisp_ks0108_close;
- dd->fp_setpixel = &sdtools_generic_setpixel;
- dd->fp_getpixel = &sdtools_generic_getpixel;
serdisp_ks0108_internal_getStruct(dd)->fp_transfer = &serdisp_ks0108_transfer_parport;
serdisp_ks0108_internal_getStruct(dd)->fp_switchcs = &serdisp_ks0108_switchcs_parport;
@@ -547,10 +542,11 @@
SDCONN_write(dd->sdcd, SIG_RESET | SIG_EN | serdisp_ks0108_internal_getStruct(dd)->chipselect[ctr],
dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
}
- DELAY_RESET();
+ /* min. 1 uS according to data sheet. we use 5 to be sure */
+ SDCONN_usleep(dd->sdcd, 5);
SDCONN_write(dd->sdcd, SIG_EN | serdisp_ks0108_internal_getStruct(dd)->chipselect[ctr],
dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
}
break;
default:
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_l4m.c
^
|
@@ -10,7 +10,7 @@
*
*************************************************************************
*
- * copyright (C) 2007-2008 wolfgang astleitner
+ * copyright (C) 2007-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -64,9 +64,16 @@
serdisp_options_t serdisp_l4m132c_options[] = {
/* name aliasnames min max mod int defines */
-/* { "DEPTH", "COLS,COLOURS", 1, 16, 16, 0, "MONOCHROME=1,MONO=1,64k=16"}*/
- { "CONTRAST", "", 0, 10, 1, 1, ""}
+ { "DEPTH", "COLS,COLOURS", 1, 16, 16, 0, "MONOCHROME=1,MONO=1,64k=16"}
+ ,{ "CONTRAST", "", 0, 10, 1, 1, ""}
+ ,{ "RESMODE", "", 0, 1, 1, 0, "132x65=0,128x64=1"}
,{ "POSTOFFMODE", "POSTOFF", 0, 1, 1, 0, "CLOCK=1"}
+ ,{ "BGCOLOUR", "BGCOLOR,BGCOL",0,0xFFFFFF, 1, 1, ""}
+ ,{ "FGCOLOUR", "FGCOLOR,FGCOL",0,0xFFFFFF, 1, 1, ""}
+ ,{ "ALARMHOUR", "ALHOUR", 0, 23, 1, 0, ""}
+ ,{ "ALARMMINUTE", "ALMIN", 0, 59, 1, 0, ""}
+ ,{ "ALARMDAYS", "ALDAYS", 0, 0x7F, 1, 0, "OFF=0,ALL=127"}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
,{ "RAWCMD", "", 0, 255, 1, 1, ""} /* for development - internal use only */
};
@@ -80,24 +87,50 @@
static void serdisp_l4m_update_l4me5i (serdisp_t*);
static void serdisp_l4m_update_l4m132c (serdisp_t*);
+static void serdisp_l4m_update_l4m132c_mono (serdisp_t*);
static void serdisp_l4m_clear_l4m132c (serdisp_t*);
typedef struct serdisp_l4m132c_specific_s {
int postoffmode;
+ int resmode;
+ long fgcol;
+ long bgcol;
+ byte alarmhour, alarmminute, alarmdays;
} serdisp_l4m132c_specific_t;
-serdisp_l4m132c_specific_t* serdisp_l4m132c_internal_getStruct(serdisp_t* dd) {
+static serdisp_l4m132c_specific_t* serdisp_l4m132c_internal_getStruct(serdisp_t* dd) {
return (serdisp_l4m132c_specific_t*)(dd->specific_data);
}
/* callback-function for setting non-standard options */
-void* serdisp_l4m132c_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+static void* serdisp_l4m132c_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
if (serdisp_compareoptionnames(dd, optionname, "POSTOFFMODE")) {
*typesize = sizeof(int);
return &(serdisp_l4m132c_internal_getStruct(dd)->postoffmode);
+ } else if (serdisp_compareoptionnames(dd, optionname, "RESMODE")) {
+ *typesize = sizeof(int);
+ return &(serdisp_l4m132c_internal_getStruct(dd)->resmode);
+ } else if (serdisp_compareoptionnames(dd, optionname, "FGCOLOUR")) {
+ *typesize = sizeof(long);
+ return &(serdisp_l4m132c_internal_getStruct(dd)->fgcol);
+ } else if (serdisp_compareoptionnames(dd, optionname, "BGCOLOUR")) {
+ *typesize = sizeof(long);
+ return &(serdisp_l4m132c_internal_getStruct(dd)->bgcol);
+ } else if (serdisp_compareoptionnames(dd, optionname, "DEPTH")) {
+ *typesize = sizeof(byte);
+ return &(dd->depth);
+ } else if (serdisp_compareoptionnames(dd, optionname, "ALARMHOUR")) {
+ *typesize = sizeof(byte);
+ return &(serdisp_l4m132c_internal_getStruct(dd)->alarmhour);
+ } else if (serdisp_compareoptionnames(dd, optionname, "ALARMMINUTE")) {
+ *typesize = sizeof(byte);
+ return &(serdisp_l4m132c_internal_getStruct(dd)->alarmminute);
+ } else if (serdisp_compareoptionnames(dd, optionname, "ALARMDAYS")) {
+ *typesize = sizeof(byte);
+ return &(serdisp_l4m132c_internal_getStruct(dd)->alarmdays);
}
return 0;
}
@@ -132,7 +165,7 @@
else if (serdisp_comparedispnames("L4M132C", dispname))
dd->dsp_id = DISPID_L4M132C;
else { /* should not occur */
- sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_l4m_ssdoled.c", dispname);
+ sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_specific_l4m.c", dispname);
return (serdisp_t*)0;
}
@@ -152,8 +185,6 @@
dd->fp_update = &serdisp_l4m_update_l4me5i;
dd->fp_close = &serdisp_l4m_close;
dd->fp_setoption = &serdisp_l4m_setoption;
- dd->fp_setpixel = &sdtools_generic_setpixel;
- dd->fp_getpixel = &sdtools_generic_getpixel;
/* per display settings */
@@ -179,8 +210,9 @@
dd->depth = 16;
dd->feature_contrast = 1;
- dd->min_contrast = 0x10;
- dd->max_contrast = 0x80;
+ dd->min_contrast = 0x02;
+ dd->max_contrast = 0x9F;
+ dd->mid_contrast = 0x35;
dd->dsparea_width = 60000; /* active viewing area in micrometres */
dd->dsparea_height = 31000; /* measured */
@@ -189,6 +221,9 @@
dd->colour_spaces = SD_CS_RGB565;
serdisp_l4m132c_internal_getStruct(dd)->postoffmode = 0; /* no clock after power off */
+ serdisp_l4m132c_internal_getStruct(dd)->resmode = 0; /* default mode: 132x65 */
+ serdisp_l4m132c_internal_getStruct(dd)->fgcol = 0xFFFFFFL;
+ serdisp_l4m132c_internal_getStruct(dd)->bgcol = 0;
dd->fp_update = &serdisp_l4m_update_l4m132c;
dd->fp_clear = &serdisp_l4m_clear_l4m132c;
@@ -219,6 +254,25 @@
return (serdisp_t*)0;
}
+ if (dd->dsp_id == DISPID_L4M132C && serdisp_l4m132c_internal_getStruct(dd)->resmode == 1) {
+ dd->width = 128;
+ dd->height = 64;
+ }
+
+ if (dd->dsp_id == DISPID_L4M132C && dd->depth == 1) {
+ dd->colour_spaces = SD_CS_SCRBUFCUSTOM | SD_CS_GREYSCALE;
+ dd->fp_update = &serdisp_l4m_update_l4m132c_mono;
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ dd->fp_setsdpixel = &sdtools_generic_setsdpixel_greyhoriz;
+ dd->fp_getsdpixel = &sdtools_generic_getsdpixel_greyhoriz;
+#else
+ dd->fp_setpixel = &sdtools_generic_setpixel_greyhoriz;
+ dd->fp_getpixel = &sdtools_generic_getpixel_greyhoriz;
+#endif
+ dd->scrbuf_size = sizeof(byte) * ( ((dd->width + 7) / 8) * dd->height);
+ dd->scrbuf_chg_size = sizeof(byte) * ( (((dd->width + 7) / 8 + 7) / 8) * dd->height);
+ }
+
return dd;
}
@@ -236,13 +290,29 @@
if (dd->dsp_id == DISPID_L4M132C) {
SDCONN_write(dd->sdcd, 0x10000 | 0x54, 0); /* disable clock */
}
+
+ if (dd->dsp_id == DISPID_L4M132C && serdisp_l4m132c_internal_getStruct(dd)->resmode == 0) {
+ SDCONN_write(dd->sdcd, 0x1F, 0); /* set resolution (ignored by older firmware versions) */
+ SDCONN_write(dd->sdcd, 0, 0); /* 1: 128x64 (default), 0: 132x65 */
+ SDCONN_commit(dd->sdcd);
+ }
+
if ( ! dd->fp_clear) {
/* clear lcd. with L4ME5I command 0x02 does not work correctly ->
send flag to tell write-functions to fix this */
SDCONN_write(dd->sdcd, ((dd->dsp_id == DISPID_L4ME5I) ? 0x020000 : 0) | 0x010000 | 0x02, 0);
}
+
+ /* send dummy clear to ensure customised colour settings for depth == 1 */
+ if (dd->dsp_id == DISPID_L4M132C && dd->depth == 1) {
+ serdisp_clear(dd);
+ }
+
SDCONN_write(dd->sdcd, 0x10000 | 0x05, 0); /* set normal display */
SDCONN_write(dd->sdcd, 0x10000 | 0x06, 0); /* autoadjust polarity (== bind pol. to empty screen) */
+
+ SDCONN_commit(dd->sdcd);
+
sd_debug(2, "%s(): done with initialising", __func__);
}
@@ -457,6 +527,99 @@
+/* *********************************
+ void serdisp_l4m_update_l4m132c_mono(dd)
+ *********************************
+ updates the display using display-buffer scrbuf+scrbuf_chg
+ *********************************
+ dd ... display descriptor
+ *********************************
+
+ the display is redrawn using a time-saving algorithm:
+*/
+void serdisp_l4m_update_l4m132c_mono (serdisp_t* dd) {
+ int x;
+ int y;
+ byte data;
+ int cols = (dd->width + 7) >> 3; /* data columns per line */
+
+#ifdef OPT_USEOLDUPDATEALGO
+ if (serdisp_l4m132c_internal_getStruct(dd)->resmode == 0) { /* 132x65 */
+ /* FIX for last data byte bug:
+
+ problem with very last possible data byte of last line:
+ unused bits will be written into first pixels of last line.
+ workaround: mirror first pixel bits into these unused bits of last data byte */
+ /* (h - 1) * cols + (cols - 1) == h * cols - 1 */
+
+ for (y = 0; y < dd->height-1; y++) {
+ dd->scrbuf[ (y + 1) * cols - 1] |= ((dd->scrbuf[ (y + 1) * cols] & 0xF0) >> 4);
+ }
+
+ dd->scrbuf[ dd->height * cols - 1] |= (dd->scrbuf[ (dd->height - 1) * cols] & 0xF0) >> 4;
+ }
+
+ for (y = 0; y < dd->height; y++) {
+ SDCONN_write(dd->sdcd, 0x12, 0);
+ SDCONN_write(dd->sdcd, y, 0);
+ SDCONN_write(dd->sdcd, 0, 0);
+ SDCONN_write(dd->sdcd, cols, 0);
+
+ for (x = 0; x < cols; x++) {
+ data = dd->scrbuf[y*cols + x];
+ SDCONN_write(dd->sdcd, data, 0);
+ }
+
+ SDCONN_commit(dd->sdcd);
+ }
+
+#else /* OPT_USEOLDUPDATEALGO */
+
+ /* display is drawn using an optimising algorithm which tries to only send as few data as possible to the display */
+
+ int rc;
+ int xt = 0, yt = 0, xb = 0, yb = 0;
+ int chunk = 0;
+ int wraparound = 0;
+
+ rc = sdtools_calc_bbox (dd, 1, &xt, &yt, &xb, &yb);
+ /*fprintf(stderr, "[%d] %3d/%3d - %3d/%3d\n", rc, xt, yt, xb, yb);*/
+
+ if (rc != 0) {
+ chunk = (xb - xt + 1 + 7) / 8;
+ wraparound = ((xb - xt + 1) % 8);
+
+ for (y = yt; y <= yb; y++) {
+
+ SDCONN_write(dd->sdcd, 0x12, 0);
+ SDCONN_write(dd->sdcd, y, 0);
+ SDCONN_write(dd->sdcd, xt, 0);
+ SDCONN_write(dd->sdcd, chunk, 0);
+
+ for (x = xt; x <= xb; x+=8) {
+ if (wraparound && x >= 128) {
+ int y_i = (y < dd->height-1) ? y+1 : y; /* avoid reading out of bounds */
+ data = (dd->scrbuf[y*cols + (x/8)] & 0xF0) | ((dd->scrbuf[y_i*cols + (xt/8)] & 0xF0) >> 4) ;
+ } else {
+ data = dd->scrbuf[y*cols + (x/8)];
+ }
+ SDCONN_write(dd->sdcd, data, 0);
+ }
+
+ SDCONN_commit(dd->sdcd);
+ }
+ memset(dd->scrbuf_chg, 0x00, dd->scrbuf_chg_size);
+ }
+
+#endif /* OPT_USEOLDUPDATEALGO */
+
+ /* add an extra NOP to avoid erraneous pixels when releasing parport */
+ SDCONN_commit(dd->sdcd); /* if streaming: be sure that every data is transmitted */
+}
+
+
+
+
/* *********************************
int serdisp_l4m_setoption(dd, option, value)
@@ -476,11 +639,28 @@
dd->curr_invert = (dd->curr_invert) ? 0 : 1;
/* 0x04: invers mode; 0x05: normal mode */
SDCONN_write(dd->sdcd, 0x10000 | ((dd->curr_invert) ? 0x04 : 0x05), 0);
- } else if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST" )) {
- dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else if (dd->feature_contrast &&
+ (serdisp_compareoptionnames(dd, option, "CONTRAST" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ ) {
+ int dimmed_contrast;
+
+ if ( serdisp_compareoptionnames(dd, option, "CONTRAST" ) ) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+ dd->curr_dimming = 100 - (int)value;
+ }
+
+ dimmed_contrast = (((dd->curr_contrast - dd->min_contrast) * (100 - dd->curr_dimming)) / 100) + dd->min_contrast;
+
+ /* workaround to be able to disable backlight or set values < dd->min_contrast */
+ if (dd->curr_dimming >= (100 - dd->min_contrast)) {
+ dimmed_contrast -= (dd->min_contrast - (100 - dd->curr_dimming));
+ }
SDCONN_write(dd->sdcd, 0x15, 0);
- SDCONN_write(dd->sdcd, dd->curr_contrast, 0);
+ SDCONN_write(dd->sdcd, dimmed_contrast /*dd->curr_contrast*/, 0);
SDCONN_commit(dd->sdcd);
} else if (serdisp_compareoptionnames(dd, option, "RAWCMD")) {
fprintf(stderr, "val: 0x%02x\n", (byte)(0xFF & value));
@@ -510,6 +690,23 @@
/* clear display using internal function 0x02 */
SDCONN_write(dd->sdcd, 0x010000 | 0x02, 0);
+ if (dd->dsp_id == DISPID_L4M132C && dd->depth == 1) {
+ long fgcol = serdisp_l4m132c_internal_getStruct(dd)->fgcol;
+ long bgcol = serdisp_l4m132c_internal_getStruct(dd)->bgcol;
+
+ SDCONN_write(dd->sdcd, 0x13, 0);
+ SDCONN_write(dd->sdcd, (byte)((fgcol & 0xFF0000L) >> 16), 0);
+ SDCONN_write(dd->sdcd, (byte)((fgcol & 0x00FF00L) >> 8), 0);
+ SDCONN_write(dd->sdcd, (byte)(fgcol & 0x0000FFL), 0);
+ SDCONN_commit(dd->sdcd);
+
+ SDCONN_write(dd->sdcd, 0x14, 0);
+ SDCONN_write(dd->sdcd, (byte)((bgcol & 0xFF0000L) >> 16), 0);
+ SDCONN_write(dd->sdcd, (byte)((bgcol & 0x00FF00L) >> 8), 0);
+ SDCONN_write(dd->sdcd, (byte)(bgcol & 0x0000FFL), 0);
+ SDCONN_commit(dd->sdcd);
+ }
+
/* restore invert-modus */
SDCONN_write(dd->sdcd, 0x010000 | ((dd->curr_invert) ? 0x04 : 0x05), 0);
}
@@ -527,6 +724,12 @@
SDCONN_write(dd->sdcd, 0x10000 | 0x05, 0); /* force normal mode */
if (dd->dsp_id == DISPID_L4M132C) {
+ /* if alarm is set: force postoffmode */
+ if (serdisp_l4m132c_internal_getStruct(dd)->postoffmode == 0 &&
+ serdisp_l4m132c_internal_getStruct(dd)->alarmdays != 0) {
+ serdisp_l4m132c_internal_getStruct(dd)->postoffmode = 1;
+ }
+
switch (serdisp_l4m132c_internal_getStruct(dd)->postoffmode) {
case 1: { /* enable clock after closing display */
time_t t;
@@ -547,7 +750,8 @@
SDCONN_write(dd->sdcd, sdtools_dec2bcd(tm->tm_year % 100), 0); /* tm_year = years since 1900 */
SDCONN_commit(dd->sdcd);
- SDCONN_write(dd->sdcd, 0x10000 | 0x53, 0); /* set time */
+ SDCONN_write(dd->sdcd, 0x53, 0); /* set time */
+ SDCONN_commit(dd->sdcd);
};
break;
default: { /* clear display using bgcolour = black */
@@ -561,5 +765,18 @@
SDCONN_write(dd->sdcd, 0x010000 | 0x02, 0);
}
}
+
+ /* enable / disable alarm time */
+ SDCONN_write(dd->sdcd, 0x56, 0);
+ if (serdisp_l4m132c_internal_getStruct(dd)->alarmdays) {
+ SDCONN_write(dd->sdcd, sdtools_dec2bcd(serdisp_l4m132c_internal_getStruct(dd)->alarmminute), 0);
+ SDCONN_write(dd->sdcd, sdtools_dec2bcd(serdisp_l4m132c_internal_getStruct(dd)->alarmhour), 0);
+ SDCONN_write(dd->sdcd, serdisp_l4m132c_internal_getStruct(dd)->alarmdays, 0);
+ } else {
+ SDCONN_write(dd->sdcd, 0, 0);
+ SDCONN_write(dd->sdcd, 0, 0);
+ SDCONN_write(dd->sdcd, 0x00, 0);
+ }
+ SDCONN_commit(dd->sdcd);
}
}
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_lc7981.c
^
|
@@ -0,0 +1,493 @@
+/*
+ *************************************************************************
+ *
+ * serdisp_specific_lc7981.c
+ * routines for controlling displays controlled by Sanyo LC7981
+ *
+ * supported:
+ * - DG-16080 160x80 monochrome
+ *
+ *************************************************************************
+ *
+ * copyright (C) 2009-2010 wolfgang astleitner
+ * email mrwastl@users.sourceforge.net
+ *
+ *************************************************************************
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "serdisplib/serdisp_connect.h"
+#include "serdisplib/serdisp_tools.h"
+#include "serdisplib/serdisp_messages.h"
+#include "serdisplib/serdisp_colour.h"
+
+
+/* #define OPT_USEOLDUPDATEALGO */
+
+
+/*
+ * command constants
+ */
+
+/*
+ * values used mainly for initialization
+ */
+
+
+/* define shorts for signals to make coding simpler. must match order of serdisp_lc7981_wiresignals[] */
+#define SIG_D0 (dd->sdcd->signals[ 0])
+#define SIG_D1 (dd->sdcd->signals[ 1])
+#define SIG_D2 (dd->sdcd->signals[ 2])
+#define SIG_D3 (dd->sdcd->signals[ 3])
+#define SIG_D4 (dd->sdcd->signals[ 4])
+#define SIG_D5 (dd->sdcd->signals[ 5])
+#define SIG_D6 (dd->sdcd->signals[ 6])
+#define SIG_D7 (dd->sdcd->signals[ 7])
+#define SIG_CS (dd->sdcd->signals[ 8])
+#define SIG_RS (dd->sdcd->signals[ 9])
+#define SIG_RW (dd->sdcd->signals[10])
+#define SIG_E (dd->sdcd->signals[11])
+#define SIG_RESET (dd->sdcd->signals[12])
+#define SIG_BACKLIGHT (dd->sdcd->signals[13])
+
+
+/* different display types/models supported by this driver */
+#define DISPID_DG16080 1
+#define DISPID_DG1608011 2
+
+
+serdisp_wiresignal_t serdisp_lc7981_wiresignals[] = {
+ /* type signame actlow cord index */
+ {SDCT_PP, "CS", 1, 'C', 8 }
+ ,{SDCT_PP, "RS", 0, 'C', 9 }
+ ,{SDCT_PP, "RW", 0, 'C', 10 }
+ ,{SDCT_PP, "E", 0, 'C', 11 }
+ ,{SDCT_PP, "RESET", 1, 'D', 12 }
+ ,{SDCT_PP, "BACKLIGHT", 0, 'D', 13 }
+};
+
+/*wirings */
+serdisp_wiredef_t serdisp_lc7981_wiredefs[] = {
+ { 0, SDCT_PP, "Simple", "DATA8,RS:INIT,E:nSTRB", "Simple wiring"}
+ ,{ 1, SDCT_PP, "SimpleSWRes", "DATA8,RS:INIT,E:nSTRB,RESET:nSELIN", "Simple wiring w/ software reset"}
+ ,{ 2, SDCT_PP, "Standard", "DATA8,RS:INIT,E:nSTRB,RW:nAUTO,CS:nSELIN", "Standard wiring"}
+ ,{ 3, SDCT_PP, "StandardSWRes", "DATA8,RS:INIT,E:nSTRB,RW:nAUTO,RESET:nSELIN", "Simple wiring w/ software reset"}
+ ,{ 4, SDCT_PP, "Backlight", "DATA8,RS:nAUTO,E:nSTRB,BACKLIGHT:INIT", "Backlight support"}
+ ,{ 5, SDCT_PP, "BacklightSWRes","DATA8,RS:nAUTO,E:nSTRB,BACKLIGHT:INIT,RESET:nSELIN", "Backlight support w/ software reset"}
+};
+
+serdisp_options_t serdisp_lc7981_options[] = {
+ /* name aliasnames min max mod int defines */
+ { "DELAY", "", 0, -1, 1, 1, ""}
+ ,{ "BACKLIGHT", "", 0, 1, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness, 0: bg-light off, <>0: dd->curr_backlight */
+};
+
+
+/* internal typedefs and functions */
+
+static void serdisp_lc7981_init (serdisp_t*);
+static void serdisp_lc7981_update (serdisp_t*);
+static int serdisp_lc7981_setoption (serdisp_t*, const char*, long);
+static void serdisp_lc7981_close (serdisp_t*);
+
+static void serdisp_lc7981_transfer (serdisp_t*, int, byte);
+static void serdisp_lc7981_writecmd (serdisp_t*, byte);
+static void serdisp_lc7981_writedata (serdisp_t*, byte);
+
+
+void serdisp_lc7981_transfer(serdisp_t* dd, int iscmd, byte item) {
+ int i;
+
+ long item_split = 0;
+ long td_clk1 = 0;
+ long td_clk2 = 0;
+ long td_clk3 = 0;
+
+ /* active-low signals are internally seen active-high because they will be auto-inverted later if needed */
+ td_clk1 = 0;
+ td_clk2 = SIG_E;
+ td_clk3 = 0;
+
+ /* enable backlight if
+ * signal SIG_BACKLIGHT is defined
+ * dd->curr_backlight = 1
+ * brightness > 0 (== dd->curr_dimming != 100)
+ */
+ if (dd->feature_backlight && dd->curr_backlight && dd->curr_dimming < 100) {
+ td_clk1 |= SIG_BACKLIGHT;
+ td_clk2 |= SIG_BACKLIGHT;
+ td_clk3 |= SIG_BACKLIGHT;
+ }
+
+ if (SIG_CS) {
+ td_clk1 |= SIG_CS;
+ td_clk2 |= SIG_CS;
+ td_clk3 |= SIG_CS;
+ }
+
+ if (iscmd) {
+ td_clk1 |= SIG_RS;
+ td_clk2 |= SIG_RS;
+ td_clk3 |= SIG_RS;
+ }
+
+ for (i = 0; i < 8; i++)
+ if (item & (1 << i))
+ item_split |= dd->sdcd->signals[i];
+
+ td_clk1 |= item_split;
+ td_clk2 |= item_split;
+
+ SDCONN_write(dd->sdcd, td_clk1, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
+ sdtools_nsleep(dd->delay);
+ SDCONN_write(dd->sdcd, td_clk2, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
+ sdtools_nsleep(dd->delay);
+ SDCONN_write(dd->sdcd, td_clk3, dd->sdcd->io_flags_writecmd);
+ sdtools_nsleep(dd->delay);
+}
+
+
+void serdisp_lc7981_writecmd(serdisp_t* dd, byte cmd) {
+ serdisp_lc7981_transfer(dd, 1, cmd);
+}
+
+
+void serdisp_lc7981_writedata(serdisp_t* dd, byte data) {
+ serdisp_lc7981_transfer(dd, 0, data);
+}
+
+
+/* main functions */
+
+
+/* *********************************
+ serdisp_t* serdisp_lc7981_setup(sdcd, dispname, optionstring)
+ *********************************
+ sets up a display descriptor fitting to dispname and extra
+ *********************************
+ sdcd ... output device handle (not used in here)
+ dispname ... display name (case-insensitive)
+ optionstring ... option string containing individual options
+ *********************************
+ returns a display descriptor
+*/
+serdisp_t* serdisp_lc7981_setup(const serdisp_CONN_t* sdcd, const char* dispname, const char* optionstring) {
+ serdisp_t* dd;
+
+ if (! (dd = (serdisp_t*)sdtools_malloc(sizeof(serdisp_t)) ) ) {
+ sd_error(SERDISP_EMALLOC, "%s(): cannot allocate display descriptor", __func__);
+ return (serdisp_t*)0;
+ }
+ memset(dd, 0, sizeof(serdisp_t));
+
+ /* assign dd->dsp_id */
+ if (serdisp_comparedispnames("DG16080", dispname))
+ dd->dsp_id = DISPID_DG16080;
+ else if (serdisp_comparedispnames("DG1608011", dispname))
+ dd->dsp_id = DISPID_DG1608011;
+ else { /* should not occur */
+ sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_specific_lc7981.c", dispname);
+ return (serdisp_t*)0;
+ }
+
+ /* default setup for function pointers */
+ dd->fp_init = &serdisp_lc7981_init;
+ dd->fp_update = &serdisp_lc7981_update;
+ dd->fp_close = &serdisp_lc7981_close;
+ dd->fp_setoption = &serdisp_lc7981_setoption;
+
+
+ /* per display settings */
+
+ dd->width = 160;
+ dd->height = 80;
+ dd->depth = 1;
+ dd->feature_contrast = 0;
+ dd->feature_backlight = 1;
+ dd->feature_invert = 0;
+ dd->curr_backlight = 1; /* start with backlight on */
+
+ if (dd->dsp_id == DISPID_DG1608011) {
+ dd->dsparea_width = 67000; /* display area in micrometres (measured) */
+ dd->dsparea_height = 48500;
+ }
+
+ /* max. delta for optimised update algorithm */
+ dd->optalgo_maxdelta = 2;
+
+ dd->delay = 0;
+
+ /* finally set some non display specific defaults */
+
+ dd->curr_rotate = 0; /* unrotated display */
+ dd->curr_invert = 0; /* display not inverted */
+
+ /* supported output devices */
+ dd->connection_types = SERDISPCONNTYPE_PARPORT;
+
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ dd->fp_setsdpixel = &sdtools_generic_setsdpixel_greyhoriz;
+ dd->fp_getsdpixel = &sdtools_generic_getsdpixel_greyhoriz;
+#else
+ dd->fp_setpixel = &sdtools_generic_setpixel_greyhoriz;
+ dd->fp_getpixel = &sdtools_generic_getpixel_greyhoriz;
+#endif
+
+ serdisp_setupstructinfos(dd, serdisp_lc7981_wiresignals, serdisp_lc7981_wiredefs, serdisp_lc7981_options);
+
+ /* parse and set options */
+ if (serdisp_setupoptions(dd, dispname, optionstring) ) {
+ free(dd->specific_data);
+ free(dd);
+ dd = 0;
+ return (serdisp_t*)0;
+ }
+
+ return dd;
+}
+
+
+
+/* *********************************
+ void serdisp_lc7981_init(dd)
+ *********************************
+ initialise a lc7981-based display
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_lc7981_init(serdisp_t* dd) {
+ /* de-activate backlight support if matching signal not defined */
+ if (! SIG_BACKLIGHT)
+ dd->feature_backlight = 0;
+
+ if (SIG_RESET)
+ SDCONN_write(dd->sdcd, SIG_RESET | ((SIG_CS) ? SIG_CS : 0),
+ dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
+
+ SDCONN_usleep(dd->sdcd, 5);
+
+ SDCONN_write(dd->sdcd,
+ ((SIG_CS) ? SIG_CS : 0) | ((SIG_BACKLIGHT) ? SIG_BACKLIGHT : 0),
+ dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata
+ );
+
+ SDCONN_usleep(dd->sdcd, 5);
+
+ /* init sequence taken from http://www.frozeneskimo.com,
+ file http://www.frozeneskimo.com/samsunglcd/avr-lc7981-v1/lc7981.c
+ */
+ serdisp_lc7981_writecmd (dd, 0x00); /* mode control */
+ serdisp_lc7981_writedata (dd, 0x32); /* 0011 0010: display on, master on, graphic mode */
+
+ serdisp_lc7981_writecmd (dd, 0x01); /* char pitch */
+ serdisp_lc7981_writedata (dd, 7); /* hor. pitch - 1 */
+
+ serdisp_lc7981_writecmd (dd, 0x02); /* number of characters */
+ serdisp_lc7981_writedata (dd, (dd->width/8)-1); /* number of bytes in hor. dir - 1 */
+
+ serdisp_lc7981_writecmd (dd, 0x03); /* time division number */
+ serdisp_lc7981_writedata (dd, 80-1); /* display duty = 1/80 according to datasheet */
+
+ serdisp_lc7981_writecmd (dd, 0x04); /* cursor line */
+ serdisp_lc7981_writedata (dd, 0);
+
+ serdisp_lc7981_writecmd (dd, 0x08); /* set lower start address */
+ serdisp_lc7981_writedata (dd, 0);
+ serdisp_lc7981_writecmd (dd, 0x09); /* set upper start address */
+ serdisp_lc7981_writedata (dd, 0);
+
+ sd_debug(2, "%s(): done with initialising", __func__);
+}
+
+
+
+/* *********************************
+ void serdisp_lc7981_update(dd)
+ *********************************
+ updates the display using display-buffer scrbuf+scrbuf_chg
+ *********************************
+ dd ... display descriptor
+ *********************************
+
+ the display is redrawn using a time-saving algorithm:
+
+ background knowledge: after writing a data-entry to the display RAM,
+ the RAM address is increased automatically =>
+ * try to utilize this auto-increasing
+ * on the other hand try to avoid writing of unchanged data
+
+*/
+void serdisp_lc7981_update(serdisp_t* dd) {
+ int i;
+ byte data;
+
+#ifdef OPT_USEOLDUPDATEALGO
+
+ serdisp_lc7981_writecmd (dd, 0x0A); /* set cursor lower address */
+ serdisp_lc7981_writedata (dd, 0 );
+ serdisp_lc7981_writecmd (dd, 0x0B); /* set cursor upper start address */
+ serdisp_lc7981_writedata (dd, 0);
+
+ for (i = 0; i < dd->scrbuf_size; i++) {
+ data = sdtools_reversebits(dd->scrbuf [ i ]);
+
+ if (dd->curr_invert)
+ data = ~data;
+
+ /* really sick way of sending data.
+ actually it would be possible to do:
+ writecmd(0x0C), writedata(data), writedata(data), and so on
+ but this would require a very, veeery long delay after each writedata() ...
+
+ writecmd(0x0C), writedata(data), writecmd(0x0C), writedata(data), and so on
+ seems to be much faster and even more stable.
+ */
+ serdisp_lc7981_writecmd (dd, 0x0C); /* write display data */
+ serdisp_lc7981_writedata (dd, data);
+ }
+
+#else /* OPT_USEOLDUPDATEALGO */
+
+ /* display is drawn using an optimising algorithm which tries to only send as few data as possible to the display */
+
+ /* more detailed explanations of principle:
+ see serdisp_specific_optrex323.c / i2c.c / pcd8544.c / sed153x.c / sed1565.c
+ */
+
+ int delta;
+ int i_delta = 0; /* i_delta - i: how many columns to transfer in one take */
+ int max_col = dd->width >> 3;
+ int max_col_chg = (max_col + 7) / 8;
+
+ i = 0;
+
+ while (i < dd->scrbuf_size) {
+ int i_chg = i % max_col;
+ int j_chg = i / max_col;
+
+ int li_chg;
+ int lj_chg;
+
+ if ( dd->scrbuf_chg[ j_chg * max_col_chg + (i_chg >> 3) ] & ( 1 << (i_chg%8) ) ) {
+ int l;
+
+ i_delta = i+1;
+ delta = 0;
+
+ while (i_delta < dd->scrbuf_size-delta-1 && delta < dd->optalgo_maxdelta) {
+ int i_delta_chg = i_delta % max_col;
+ int j_delta_chg = i_delta / max_col;
+
+ if ( dd->scrbuf_chg[ j_delta_chg * max_col_chg + (i_delta_chg >> 3)] & ( 1 << (i_delta_chg%8) ) ) {
+ i_delta += delta+1;
+ delta = 0;
+ } else {
+ delta++;
+ }
+ }
+
+ serdisp_lc7981_writecmd (dd, 0x0A); /* set cursor lower address */
+ serdisp_lc7981_writedata (dd, i & 0x00FF );
+ serdisp_lc7981_writecmd (dd, 0x0B); /* set cursor upper start address */
+ serdisp_lc7981_writedata (dd, (i & 0xFF00) >> 8 );
+
+ for (l = i; l <= i_delta; l++) {
+ data = sdtools_reversebits(dd->scrbuf [ l ]);
+
+ if (dd->curr_invert)
+ data = ~data;
+
+ li_chg = l % max_col;
+ lj_chg = l / max_col;
+
+ serdisp_lc7981_writecmd (dd, 0x0C); /* write display data */
+ serdisp_lc7981_writedata (dd, data);
+ dd->scrbuf_chg[ lj_chg * max_col_chg + (li_chg >> 3) ] &= (0xFF ^ (1 << (li_chg % 8)));
+ }
+
+ i = i_delta+1;
+ } else {
+ i++;
+ }
+ }
+
+#endif /* OPT_USEOLDUPDATEALGO */
+
+ SDCONN_commit(dd->sdcd); /* if streaming: be sure that every data is transmitted */
+}
+
+
+/* *********************************
+ int serdisp_lc7981_setoption(dd, option, value)
+ *********************************
+ change a display option
+ *********************************
+ dd ... display descriptor
+ option ... name of option to change
+ value ... value for option
+*/
+int serdisp_lc7981_setoption(serdisp_t* dd, const char* option, long value) {
+ if (dd->feature_backlight &&
+ (serdisp_compareoptionnames(dd, option, "BACKLIGHT" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ )
+ {
+ if ( serdisp_compareoptionnames(dd, option, "BRIGHTNESS" ) ) {
+ dd->curr_dimming = 100 - (int)value;
+ } else {
+ if (value < 2)
+ dd->curr_backlight = (int)value;
+ else
+ dd->curr_backlight = (dd->curr_backlight) ? 0 : 1;
+ }
+ /* no command for en/disable backlight, so issue 'dummy'-command
+ (which indirectly enables/disabled backlight) */
+ serdisp_rewrite(dd);
+ } else {
+ /* option not found here: try generic one in calling serdisp_setoption(); */
+ return 0;
+ }
+ return 1;
+}
+
+
+
+/* *********************************
+ void serdisp_lc7981_close(dd)
+ *********************************
+ close (switch off) display
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_lc7981_close(serdisp_t* dd) {
+ dd->curr_backlight = 0;
+ serdisp_lc7981_writecmd (dd, 0x00); /* mode control */
+ serdisp_lc7981_writedata (dd, 0x12); /* 0001 0010: display off, master on, graphic mode */
+}
+
+
+
+
+
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_lh155.c
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2006-2007 wolfgang astleitner
+ * copyright (C) 2006-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -41,8 +41,6 @@
/* #define OPT_USEOLDUPDATEALGO */
-#define DELAY_RESET() usleep(300*1000)
-
/*
* command constants
*/
@@ -143,13 +141,17 @@
static int serdisp_lh155_setoption (serdisp_t*, const char*, long);
static void serdisp_lh155_close (serdisp_t*);
+static void serdisp_lh155_transfer (serdisp_t* dd, int iscmd, byte item);
+static void serdisp_lh155_writecmd (serdisp_t* dd, byte cmd);
+static void serdisp_lh155_writedata (serdisp_t* dd, byte data);
+
typedef struct serdisp_lh155_specific_s {
int interfacemode;
} serdisp_lh155_specific_t;
-serdisp_lh155_specific_t* serdisp_lh155_internal_getStruct(serdisp_t* dd) {
+static serdisp_lh155_specific_t* serdisp_lh155_internal_getStruct(serdisp_t* dd) {
return (serdisp_lh155_specific_t*)(dd->specific_data);
}
@@ -214,7 +216,7 @@
/* callback-function for setting non-standard options */
-void* serdisp_lh155_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+static void* serdisp_lh155_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
if (serdisp_compareoptionnames(dd, optionname, "INTERFACE")) {
*typesize = sizeof(int);
return &(serdisp_lh155_internal_getStruct(dd)->interfacemode);
@@ -293,8 +295,13 @@
dd->fp_setoption = &serdisp_lh155_setoption;
dd->fp_getvalueptr = &serdisp_lh155_getvalueptr;
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ dd->fp_setsdpixel = &sdtools_generic_setsdpixel_greyhoriz;
+ dd->fp_getsdpixel = &sdtools_generic_getsdpixel_greyhoriz;
+#else
dd->fp_setpixel = &sdtools_generic_setpixel_greyhoriz;
dd->fp_getpixel = &sdtools_generic_getpixel_greyhoriz;
+#endif
serdisp_setupstructinfos(dd, serdisp_lh155_wiresignals, serdisp_lh155_wiredefs, serdisp_lh155_options);
@@ -335,9 +342,10 @@
void serdisp_lh155_init(serdisp_t* dd) {
if (SIG_RESET) {
SDCONN_write(dd->sdcd, SIG_RESET, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 300*1000);
+
SDCONN_write(dd->sdcd, 0, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- /*DELAY_RESET();*/
+ /*SDCONN_usleep(dd->sdcd, 300*1000);*/
}
serdisp_lh155_writecmd (dd, CMD_RESETOFF);
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_nokcol.c
^
|
@@ -8,7 +8,7 @@
*
*************************************************************************
*
- * copyright (C) 2006-2008 wolfgang astleitner
+ * copyright (C) 2006-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
* S1D15G10 support contributed by:
@@ -107,6 +107,7 @@
{ "DEPTH", "COLS,COLOURS", 8, 12, 4, 0, "4096=12,4k=12,256=8"}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
,{ "BACKLIGHT", "", 0, 1, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
#if SUPPORT_DELAY
,{ "DELAY", "", 0, -1, 1, 1, ""}
#endif
@@ -120,6 +121,7 @@
,{ "BACKLIGHT", "", 0, 1, 1, 1, ""}
,{ "OFFSETX", "", 0, 2, 1, 0, ""}
,{ "OFFSETY", "", 0, 2, 1, 0, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
#if SUPPORT_DELAY
,{ "DELAY", "", 0, -1, 1, 1, ""}
#endif
@@ -134,13 +136,19 @@
static int serdisp_nokcol_setoption (serdisp_t*, const char*, long);
static void serdisp_nokcol_close (serdisp_t*);
+static void serdisp_nokcol_transfer_signals (serdisp_t* dd, int mode, byte item);
+static void serdisp_nokcol_transfer_spi (serdisp_t* dd, int mode, byte item);
+static void serdisp_nokcol_writecmd (serdisp_t* dd, byte cmd);
+static void serdisp_nokcol_writedata (serdisp_t* dd, byte data);
+static void serdisp_nokcol_writecommit (serdisp_t* dd, byte data);
+
typedef struct serdisp_nokcol_specific_s {
void (*fp_transfer) (serdisp_t* dd, int type, byte item);
} serdisp_nokcol_specific_t;
-serdisp_nokcol_specific_t* serdisp_nokcol_internal_getStruct(serdisp_t* dd) {
+static serdisp_nokcol_specific_t* serdisp_nokcol_internal_getStruct(serdisp_t* dd) {
return (serdisp_nokcol_specific_t*)(dd->specific_data);
}
@@ -232,13 +240,9 @@
/* mode: 0 .. data 1 ... command 2 ... cs commit */
/* flags:
---- --xx: mode
- ---- 01--: 0x08: 9 bit mode; 0x04: meaning of D/C is inverted
- ---x ----: x=0: clean D/C-bit transfer mode (needed only with n3510i)
*/
SDCONN_writedelay(
- dd->sdcd,
- ((mode | 0x04 | ((dd->dsp_id == DISPID_N3510I) ? 0x00 : /* 0x10 */ 0x00) ) << 16) | (long)item,
- dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata,
+ dd->sdcd, (mode << 16) | (long)item, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata,
dd->delay
);
}
@@ -247,7 +251,7 @@
void serdisp_nokcol_writecmd(serdisp_t* dd, byte cmd) {
serdisp_nokcol_internal_getStruct(dd)->fp_transfer(dd, 1, cmd);
- serdisp_nokcol_internal_getStruct(dd)->fp_transfer(dd, 2, cmd); /* commit */
+/* serdisp_nokcol_internal_getStruct(dd)->fp_transfer(dd, 2, cmd); */ /* commit */
}
@@ -261,7 +265,7 @@
/* callback-function for setting non-standard options */
-void* serdisp_nokcol_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+static void* serdisp_nokcol_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
if (serdisp_compareoptionnames(dd, optionname, "DEPTH")) {
*typesize = sizeof(byte);
return &(dd->depth);
@@ -343,7 +347,8 @@
dd->curr_backlight = 1; /* start with backlight on */
/* supported output devices */
- dd->connection_types = SERDISPCONNTYPE_PARPORT | SERDISPCONNTYPE_SPI;
+ dd->connection_types = SERDISPCONNTYPE_PARPORT;
+ dd->supp_protocols = SDPROTO_EMULATION | SDPROTO_SPI;
/* supported colour spaces */
dd->colour_spaces = SD_CS_RGB444 | SD_CS_RGB332;
@@ -354,10 +359,6 @@
dd->fp_setoption = &serdisp_nokcol_setoption;
dd->fp_getvalueptr = &serdisp_nokcol_getvalueptr;
- dd->fp_setpixel = &sdtools_generic_setpixel;
- dd->fp_getpixel = &sdtools_generic_getpixel;
-
-
if (dd->dsp_id == DISPID_S1D15G10) {
serdisp_setupstructinfos(dd, serdisp_nokcol_wiresignals, serdisp_nokcol_wiredefs, serdisp_s1d15g10_options);
} else {
@@ -430,12 +431,20 @@
dd->optalgo_maxdelta = (dd->optalgo_maxdelta * dd->depth) / 8;
/* select transfer modus */
- if (dd->sdcd->conntype == SERDISPCONNTYPE_SPI) { /* send SPI directly, clocking is done by the receiver */
+ if (dd->sdcd->protocol == SDPROTO_SPI) { /* send SPI directly, clocking is done by the receiver */
SIG_RESET = 0L;
SIG_BACKLIGHT = 0L;
SIG_SDATA = 0L;
SIG_SCLK = 0L;
serdisp_nokcol_internal_getStruct(dd)->fp_transfer = &serdisp_nokcol_transfer_spi;
+
+ /* set SPI parameters (will be set / initialised by SDCONNxxx_confinit() */
+ dd->sdcd->spi.framelen = 5; /* framelen + 4 -> 9 bits */
+ dd->sdcd->spi.cpol = 1; /* SK (SCLK) high */
+ dd->sdcd->spi.cpha = 1; /* DO (SI) write at falling SCLK */
+ dd->sdcd->spi.data_high= 1; /* data = active high; command = active low */
+ dd->sdcd->spi.divider = 0; /* auto */
+ dd->sdcd->spi.prescaler= 0; /* auto */
} else { /* emulate SPI protocol (including clocking a.s.o) */
serdisp_nokcol_internal_getStruct(dd)->fp_transfer = &serdisp_nokcol_transfer_signals;
}
@@ -573,6 +582,15 @@
default: val = 0x01; break; /* 8 greysclae */
}
serdisp_nokcol_writedata (dd, val); /* 8/12 bit / pixel */
+
+ serdisp_nokcol_writecmd (dd, 0xAA); /* ASCSET - area scroll set */
+ serdisp_nokcol_writedata (dd, 0); /* top block address */
+ serdisp_nokcol_writedata (dd, 41); /* bottom block address */
+ serdisp_nokcol_writedata (dd, 41); /* number of specified blocks */
+ serdisp_nokcol_writedata (dd, 1); /* top screen scroll */
+
+ serdisp_nokcol_writecmd (dd, 0xAB); /* SCSTART - scroll start address */
+ serdisp_nokcol_writedata (dd, 0); /* start block address */
}
/* do equal handling stuff (valid for both n3510i and s1d5gxx) */
@@ -878,18 +896,30 @@
else
dd->curr_backlight = (dd->curr_backlight) ? 0 : 1;
serdisp_nokcol_writecmd (dd, cmd_nop); /* NOP */
- } else if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST")) {
+ } else if (dd->feature_contrast &&
+ (serdisp_compareoptionnames(dd, option, "CONTRAST" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ )
+ {
+ int dimmed_contrast;
byte cmd_wrcntr = (dd->dsp_id == DISPID_N3510I) ? 0x25 : 0x81; /* WRCNTR */
- dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ if ( serdisp_compareoptionnames(dd, option, "CONTRAST" ) ) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+ dd->curr_dimming = 100 - (int)value;
+ }
+
+ dimmed_contrast = (((dd->curr_contrast - dd->min_contrast) * (100 - dd->curr_dimming)) / 100) + dd->min_contrast;
serdisp_nokcol_writecmd (dd, cmd_wrcntr); /* WRCNTR: write contrast */
- serdisp_nokcol_writedata (dd, dd->curr_contrast);
+ serdisp_nokcol_writedata (dd, dimmed_contrast /*dd->curr_contrast*/);
if (dd->dsp_id == DISPID_S1D15G10) {
serdisp_nokcol_writedata (dd, 0x03);
serdisp_nokcol_writecommit(dd, 0x03);
} else {
- serdisp_nokcol_writecommit(dd, dd->curr_contrast);
+ serdisp_nokcol_writecommit(dd, dimmed_contrast /*dd->curr_contrast*/);
}
} else {
/* option not found here: try generic one in calling serdisp_setoption(); */
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_pcd8544.c
^
|
@@ -9,7 +9,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
* PCF8511 support and 9bit serial communication contributed by:
@@ -45,8 +45,6 @@
#include "serdisplib/serdisp_messages.h"
-#define DELAY_RESET() usleep(300*1000)
-
#define PutData(_dd, _data) serdisp_pcd8544_transfer((_dd), (1), (_data))
#define PutCtrl(_dd, _data) serdisp_pcd8544_transfer((_dd), (0), (_data))
@@ -103,6 +101,7 @@
/* name aliasnames min max mod int defines */
{ "DELAY", "", 0, -1, 1, 1, ""}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
+ ,{ "BRIGHTNESS","", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
,{ "BACKLIGHT", "", 0, 1, 1, 1, ""}
};
@@ -169,8 +168,7 @@
dd->fp_update = &serdisp_pcd8544_update;
dd->fp_setoption = &serdisp_pcd8544_setoption;
dd->fp_close = &serdisp_pcd8544_close;
- dd->fp_setpixel = &sdtools_generic_setpixel;
- dd->fp_getpixel = &sdtools_generic_getpixel;
+
dd->delay = 0;
if (dd->dsp_id == DISPID_PCF8511) {
@@ -191,15 +189,12 @@
dd->max_contrast = 0x5F; /* values > 0x5F: display is too dark */
- if (! dd->yreloctab) {
- if (! (dd->yreloctab = (int*) sdtools_malloc( sizeof(int) * (dd->height + dd->ycolgaps) ) ) ) {
- sd_error(SERDISP_EMALLOC, "serdisp_pcd8544_setup(): cannot allocate relocation table");
- free(dd->xreloctab);
- free(dd);
- dd = 0;
- return (serdisp_t*)0;
- }
- }
+ if (! (dd->yreloctab = (int*) sdtools_malloc( sizeof(int) * (dd->height + dd->ycolgaps) ) ) ) {
+ sd_error(SERDISP_EMALLOC, "serdisp_pcd8544_setup(): cannot allocate relocation table");
+ free(dd);
+ dd = 0;
+ return (serdisp_t*)0;
+ }
/* first row on display == second 'row' (second bit-row in page 0) in display memory */
/* this is valid here because height = 60 (60/8 = 7.5 => 4 rows available for y-shifting */
@@ -238,7 +233,8 @@
if (SIG_RESET)
SDCONN_write(dd->sdcd, SIG_RESET, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 300*1000);
+
if (dd->dsp_id == DISPID_PCF8511) {
PutCtrl(dd, 0xE1); /* exit powersave */
@@ -511,17 +507,29 @@
/* no command for en/disable backlight, so issue 'dummy'-command
(which indirectly enables/disabled backlight) */
PutCtrl(dd, cmd_nop); /* NOP */
- } else if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST" )) {
+ } else if (dd->feature_contrast &&
+ (serdisp_compareoptionnames(dd, option, "CONTRAST" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ )
+ {
+ int dimmed_contrast;
+
+ if ( serdisp_compareoptionnames(dd, option, "CONTRAST" ) ) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+ dd->curr_dimming = 100 - (int)value;
+ }
- dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ dimmed_contrast = (((dd->curr_contrast - dd->min_contrast) * (100 - dd->curr_dimming)) / 100) + dd->min_contrast;
if (dd->dsp_id == DISPID_PCF8511) {
PutCtrl(dd, 0x81); /* set vop: */
PutCtrl(dd, 0x3F); /* vop */
- PutCtrl(dd, 0x20 + dd->curr_contrast );
+ PutCtrl(dd, 0x20 + dimmed_contrast /*dd->curr_contrast*/ );
} else {
PutCtrl(dd, 0x21); /* EXTENDEDSET: following command is an extended one */
- PutCtrl(dd, 0x80 | dd->curr_contrast ); /* 0x80+value: set contrast */
+ PutCtrl(dd, 0x80 | dimmed_contrast ); /* 0x80+value: set contrast */
PutCtrl(dd, 0x20); /* STANDARDSET: following commands are standard ones again */
}
} else {
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_sed133x.c
^
|
@@ -2,11 +2,14 @@
*************************************************************************
*
* serdisp_specific_sed133x.c
- * routines for controlling displays controlled by sed1330/sed1335/s1d13700
+ * routines for controlling displays controlled by
+ * * sed1330/sed1335/s1d13700
+ * * usb13700 usb module
+ *
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -41,9 +44,11 @@
#include "serdisplib/serdisp_colour.h"
#endif
+#include "serdisplib/serdisp_fctptr.h"
/*#define OPT_USEOLDUPDATEALGO */
+
/*
* command constants
*/
@@ -94,6 +99,7 @@
/* different display types/models supported by this driver */
#define DISPID_SED133X 1
#define DISPID_S1D13700 2
+#define DISPID_USB13700 3
serdisp_wiresignal_t serdisp_sed133x_wiresignals[] = {
@@ -137,6 +143,16 @@
/* ,{ "DEPTH", "", 1, 4, 2, 0, ""}*/
};
+serdisp_options_t serdisp_usb13700_options[] = {
+ /* name aliasnames min max mod int defines */
+ { "WIDTH", "", 0, 640, 8, 0, "AUTO=0"}
+ ,{ "HEIGHT", "", 0, 240, 8, 0, "AUTO=0"}
+ ,{ "BACKLIGHT", "", 0, 1, 1, 1, ""}
+ ,{ "DISPCLKDIV", "DISPCLK", 0, 10, 1, 1, "AUTO=0"}
+ ,{ "FPSHIFTDIV", "FPSHIFT", -1, 2, 1, 1, "AUTO=-1"}
+ ,{ "TCRCRDIFF", "TCRCR", 0, 253, 1, 0, "AUTO=0,DEFAULT=1"}
+};
+
/* internal typedefs and functions */
@@ -145,16 +161,35 @@
static int serdisp_sed133x_setoption (serdisp_t*, const char*, long);
static void serdisp_sed133x_close (serdisp_t*);
+static void serdisp_usb13700_init (serdisp_t*);
+static void serdisp_usb13700_update (serdisp_t*);
+static int serdisp_usb13700_setoption (serdisp_t*, const char*, long);
+static void serdisp_usb13700_close (serdisp_t*);
+
+static void serdisp_sed133x_transfer (serdisp_t* dd, int iscmd, byte item);
+static void serdisp_sed133x_writecmd (serdisp_t* dd, byte cmd);
+static void serdisp_sed133x_writedata (serdisp_t* dd, byte data);
+static void serdisp_sed133x_systemset (serdisp_t* dd, int* cr);
typedef struct serdisp_sed133x_specific_s {
int interfacemode;
int fosc;
int ws;
+ /* the following values are used by usb13700 only */
+ int dispclkdiv;
+ int fpshiftdiv;
+ int tcrcrdiff;
+ /* usb13700 only: values that are stored in the module */
+ int pre_width;
+ int pre_height;
+ int pre_dispclkdiv;
+ int pre_fpshiftdiv;
+ int pre_tcrcrdiff;
} serdisp_sed133x_specific_t;
-serdisp_sed133x_specific_t* serdisp_sed133x_internal_getStruct(serdisp_t* dd) {
+static serdisp_sed133x_specific_t* serdisp_sed133x_internal_getStruct(serdisp_t* dd) {
return (serdisp_sed133x_specific_t*)(dd->specific_data);
}
@@ -217,7 +252,7 @@
/* callback-function for setting non-standard options */
-void* serdisp_sed133x_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+static void* serdisp_sed133x_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
if (serdisp_compareoptionnames(dd, optionname, "OSCILLATOR")) {
*typesize = sizeof(int);
return &(serdisp_sed133x_internal_getStruct(dd)->fosc);
@@ -227,6 +262,15 @@
} else if (serdisp_compareoptionnames(dd, optionname, "DUALPANEL")) {
*typesize = sizeof(int);
return &(serdisp_sed133x_internal_getStruct(dd)->ws);
+ } else if (serdisp_compareoptionnames(dd, optionname, "DISPCLKDIV")) {
+ *typesize = sizeof(int);
+ return &(serdisp_sed133x_internal_getStruct(dd)->dispclkdiv);
+ } else if (serdisp_compareoptionnames(dd, optionname, "FPSHIFTDIV")) {
+ *typesize = sizeof(int);
+ return &(serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv);
+ } else if (serdisp_compareoptionnames(dd, optionname, "TCRCRDIFF")) {
+ *typesize = sizeof(int);
+ return &(serdisp_sed133x_internal_getStruct(dd)->tcrcrdiff);
}
return 0;
}
@@ -257,24 +301,33 @@
}
memset(dd, 0, sizeof(serdisp_t));
- if (! (dd->specific_data = (void*) sdtools_malloc( sizeof(serdisp_sed133x_specific_t)) )) {
- free(dd);
- return (serdisp_t*)0;
- }
-
- memset(dd->specific_data, 0, sizeof(serdisp_sed133x_specific_t));
-
/* "SED133X" and "S1D13700" based displays supported in here */
/* assign dd->dsp_id */
- if (serdisp_comparedispnames("SED133X", dispname))
+ if (serdisp_comparedispnames("SED133X", dispname)) {
dd->dsp_id = DISPID_SED133X;
- else if (serdisp_comparedispnames("S1D13700", dispname))
+ } else if (serdisp_comparedispnames("S1D13700", dispname)) {
dd->dsp_id = DISPID_S1D13700;
- else { /* should not occur */
+ } else if (serdisp_comparedispnames("USB13700", dispname)) {
+ if ( ! SDFCTPTR_checkavail(SDFCTPTR_LIBUSB) ) {
+ sd_error(SERDISP_ERUNTIME, "%s(): libusb is not loaded but is a requirement for display '%s'", __func__, dispname);
+ free(dd);
+ dd = 0;
+ return (serdisp_t*)0;
+ }
+ dd->dsp_id = DISPID_USB13700;
+ } else { /* should not occur */
sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_specific_sed133x.c", dispname);
+ free(dd);
+ dd = 0;
return (serdisp_t*)0;
}
+ if (! (dd->specific_data = (void*) sdtools_malloc( sizeof(serdisp_sed133x_specific_t)) )) {
+ free(dd);
+ return (serdisp_t*)0;
+ }
+ memset(dd->specific_data, 0, sizeof(serdisp_sed133x_specific_t));
+
/* per display settings */
dd->width = 240;
@@ -309,13 +362,101 @@
dd->fp_setoption = &serdisp_sed133x_setoption;
dd->fp_getvalueptr = &serdisp_sed133x_getvalueptr;
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ dd->fp_setsdpixel = &sdtools_generic_setsdpixel_greyhoriz;
+ dd->fp_getsdpixel = &sdtools_generic_getsdpixel_greyhoriz;
+#else
dd->fp_setpixel = &sdtools_generic_setpixel_greyhoriz;
dd->fp_getpixel = &sdtools_generic_getpixel_greyhoriz;
+#endif
- if (dd->dsp_id == DISPID_S1D13700) {
- serdisp_setupstructinfos(dd, serdisp_sed133x_wiresignals, serdisp_sed133x_wiredefs, serdisp_s1d13700_options);
- } else {
- serdisp_setupstructinfos(dd, serdisp_sed133x_wiresignals, serdisp_sed133x_wiredefs, serdisp_sed133x_options);
+ /* special settings for usb13700 module */
+ if (dd->dsp_id == DISPID_USB13700) {
+ byte buf_get_conf[64];
+
+ if (!sdcd) {
+ sd_error(SERDISP_ERUNTIME, "%s(): sdcd not initialised", __func__);
+ return (serdisp_t*)0;
+ }
+
+ dd->width = 0; /* auto */
+ dd->height = 0; /* auto */
+ dd->feature_backlight = 1;
+
+ dd->optalgo_maxdelta = 40; /* 40 bytes min. difference */
+ dd->curr_backlight = 1;
+
+ serdisp_sed133x_internal_getStruct(dd)->dispclkdiv = 0; /* auto */
+ serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv = -1; /* auto */
+ serdisp_sed133x_internal_getStruct(dd)->tcrcrdiff = 0; /* auto */
+
+ dd->connection_types = SERDISPCONNTYPE_PARPORT;
+
+ dd->fp_init = &serdisp_usb13700_init;
+ dd->fp_update = &serdisp_usb13700_update;
+ dd->fp_close = &serdisp_usb13700_close;
+ dd->fp_setoption = &serdisp_usb13700_setoption;
+
+/* if (sdcd)
+ sdcd->conntype = SDHWT_USB13700;*/
+ SDCONN_write((serdisp_CONN_t*)sdcd, 0xfe, 0);
+ SDCONN_write((serdisp_CONN_t*)sdcd, 1, 0); /* CMD_GET_BASICCONFIGDATA */
+ SDCONN_write((serdisp_CONN_t*)sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_commit((serdisp_CONN_t*)sdcd);
+ SDCONN_readstream((serdisp_CONN_t*)sdcd, buf_get_conf, 64);
+
+ /* sometimes the first command may fail. simple workaround: send it twice ... */
+ if (buf_get_conf[0] != 1 /* CMD_GET_BASICCONFIGDATA */ || buf_get_conf[1] != 20 /* MSG_REPLY */) {
+ SDCONN_write((serdisp_CONN_t*)sdcd, 0xfe, 0);
+ SDCONN_write((serdisp_CONN_t*)sdcd, 1, 0); /* CMD_GET_BASICCONFIGDATA */
+ SDCONN_write((serdisp_CONN_t*)sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_commit((serdisp_CONN_t*)sdcd);
+ SDCONN_readstream((serdisp_CONN_t*)sdcd, buf_get_conf, 64);
+ }
+
+ if (buf_get_conf[0] != 1 /* CMD_GET_BASICCONFIGDATA */ || buf_get_conf[1] != 20 /* MSG_REPLY */) {
+ sd_error(SERDISP_ERUNTIME, "%s(): unable to get basic config data from usb13700 module", __func__);
+ return (serdisp_t*)0;
+ }
+
+ serdisp_sed133x_internal_getStruct(dd)->pre_width = buf_get_conf[2] | (buf_get_conf[3]<<8);
+ serdisp_sed133x_internal_getStruct(dd)->pre_height = buf_get_conf[4] | (buf_get_conf[5]<<8);
+ serdisp_sed133x_internal_getStruct(dd)->pre_dispclkdiv = buf_get_conf[57];
+ serdisp_sed133x_internal_getStruct(dd)->pre_fpshiftdiv = buf_get_conf[58];
+ serdisp_sed133x_internal_getStruct(dd)->pre_tcrcrdiff = buf_get_conf[59];
+
+ sd_debug(1, "%s():CMD_GET_BASICCONFIGDATA:", __func__);
+ sd_debug(1, "%s():------------------------", __func__);
+ sd_debug(1, "%s(): Width/Height: %d/%d", __func__,
+ serdisp_sed133x_internal_getStruct(dd)->pre_width,
+ serdisp_sed133x_internal_getStruct(dd)->pre_height
+ );
+ sd_debug(1, "%s(): Device Name: \"%32s\"", __func__, &buf_get_conf[6]);
+ sd_debug(1, "%s(): User Name: \"%16s\"", __func__, &buf_get_conf[38]);
+ sd_debug(1, "%s(): Mode: %d", __func__, buf_get_conf[54]);
+ sd_debug(1, "%s(): Firmware: %d.%d", __func__, buf_get_conf[55], buf_get_conf[56]);
+ sd_debug(1, "%s(): DispClkDiv: %d", __func__, serdisp_sed133x_internal_getStruct(dd)->pre_dispclkdiv);
+ sd_debug(1, "%s(): FPSHIFTDiv: %d", __func__, serdisp_sed133x_internal_getStruct(dd)->pre_fpshiftdiv);
+ sd_debug(1, "%s(): TCRCRDiff: %d", __func__, serdisp_sed133x_internal_getStruct(dd)->pre_tcrcrdiff);
+
+ if (buf_get_conf[55] == 0 && buf_get_conf[56] < 9) {
+ sd_error(SERDISP_ERUNTIME, "%s(): firmware version %d.%d detected. only firmware versions >= 0.9 are supported.",
+ __func__, buf_get_conf[55], buf_get_conf[56]
+ );
+ return (serdisp_t*)0;
+ }
+ }
+
+
+ switch (dd->dsp_id) {
+ case DISPID_S1D13700:
+ serdisp_setupstructinfos(dd, serdisp_sed133x_wiresignals, serdisp_sed133x_wiredefs, serdisp_s1d13700_options);
+ break;
+ case DISPID_USB13700:
+ serdisp_setupstructinfos(dd, 0, 0, serdisp_usb13700_options);
+ break;
+ default:
+ serdisp_setupstructinfos(dd, serdisp_sed133x_wiresignals, serdisp_sed133x_wiredefs, serdisp_sed133x_options);
}
/* parse and set options */
@@ -326,6 +467,17 @@
return (serdisp_t*)0;
}
+ /* setup auto values for usb13700 module */
+ if (dd->dsp_id == DISPID_USB13700) {
+ if (dd->width <= 0) dd->width = serdisp_sed133x_internal_getStruct(dd)->pre_width;
+ if (dd->height <= 0) dd->height = serdisp_sed133x_internal_getStruct(dd)->pre_height;
+ if (serdisp_sed133x_internal_getStruct(dd)->dispclkdiv <= 0)
+ serdisp_sed133x_internal_getStruct(dd)->dispclkdiv = serdisp_sed133x_internal_getStruct(dd)->pre_dispclkdiv;
+ if (serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv <= -1)
+ serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv = serdisp_sed133x_internal_getStruct(dd)->pre_fpshiftdiv;
+ if (serdisp_sed133x_internal_getStruct(dd)->tcrcrdiff <= 0)
+ serdisp_sed133x_internal_getStruct(dd)->tcrcrdiff = serdisp_sed133x_internal_getStruct(dd)->pre_tcrcrdiff;
+ }
scrbuf_columns = (dd->width + 7) / 8;
@@ -352,11 +504,13 @@
int opt_fx = 8, opt_fy = 1, opt_ws;
int opt_vc, opt_cr, opt_tcr, opt_ap;
- opt_vc = dd->width / opt_fx; /* characters per line */
- opt_cr = ((opt_fx + 7) / 8) * opt_vc; /* [CR] = Round([FX] / 8) * [VC] */
+ opt_vc = (dd->width + 7) / opt_fx; /* characters per line */
+ opt_cr = opt_vc * dd->depth; /* [CR] = Round([FX] / 8) * [VC] * DEPTH */
opt_ws = serdisp_sed133x_internal_getStruct(dd)->ws;
+ opt_ap = opt_cr; /* AP .. horizontal address range of virtual screen. == cr (depth already included) */
+
/* TCR must satisfy two conditions:
1) fosc >= ([TCR] * 9 + 1) * [LF] *fFR LF = lines per frame => height; fFR = 70 Hz
@@ -372,8 +526,6 @@
sd_debug(1, "%s(): fosc too low. corrected to meet condition [TRC] >= [CR] + 4", __func__);
}
- opt_ap = opt_cr * dd->depth; /* AP .. horizontal address range of virtual screen. == cr * depth in our case */
-
sd_debug(2, "%s(): VC: %d, CR: %d, TCR: %d, AP: %d", __func__, opt_vc, opt_cr, opt_tcr, opt_ap);
@@ -402,7 +554,7 @@
*/
serdisp_sed133x_writedata(dd, 0x80 | (opt_fx -1) ); /* MOD=1|0|0|0|FX=fx-1| */
serdisp_sed133x_writedata(dd, (opt_fy-1) ); /* [FY] - 1 */
- serdisp_sed133x_writedata(dd, (opt_cr * dd->depth) -1); /* [CR] * depth - 1 */
+ serdisp_sed133x_writedata(dd, (opt_cr-1) ); /* [CR] - 1 */
serdisp_sed133x_writedata(dd, (opt_tcr -1)); /* [TCR] - 1 */
serdisp_sed133x_writedata(dd, (dd->height - 1)); /* [LF] - 1 LF lines per frame */
serdisp_sed133x_writedata(dd, (byte)((opt_ap & 0x00FF))); /* AP low byte */
@@ -427,9 +579,9 @@
opt_ws = serdisp_sed133x_internal_getStruct(dd)->ws;
if (dd->dsp_id == DISPID_S1D13700) {
- usleep(10000); /* after power on: wait 10 millisecs */
+ SDCONN_usleep(dd->sdcd, 10000); /* after power on: wait 10 millisecs */
serdisp_sed133x_writecmd (dd, CMD_SYSTEMSET); /* wake up s1d13700 from power save mode */
- usleep(10000); /* after wake up: wait 10 millisecs */
+ SDCONN_usleep(dd->sdcd, 10000); /* after wake up: wait 10 millisecs */
}
serdisp_sed133x_systemset(dd, &opt_cr);
@@ -488,7 +640,7 @@
*/
void serdisp_sed133x_update(serdisp_t* dd) {
int i, col;
- int max_col = ((dd->width + dd->xcolgaps + 7) / 8);
+ int max_col = ((dd->width + dd->xcolgaps + 7) / 8) * dd->depth;
byte data;
#ifdef OPT_USEOLDUPDATEALGO
@@ -626,3 +778,274 @@
serdisp_sed133x_writecmd (dd, CMD_DISPOFF);
}
+
+/* *********************************
+ void serdisp_usb13700_init(dd)
+ *********************************
+ initialise a display driven by the usb13700-module
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_usb13700_init(serdisp_t* dd) {
+
+ if ( (dd->width != serdisp_sed133x_internal_getStruct(dd)->pre_width) ||
+ (dd->height != serdisp_sed133x_internal_getStruct(dd)->pre_height) ||
+ (serdisp_sed133x_internal_getStruct(dd)->dispclkdiv != serdisp_sed133x_internal_getStruct(dd)->pre_dispclkdiv) ||
+ (serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv != serdisp_sed133x_internal_getStruct(dd)->pre_fpshiftdiv) ||
+ (serdisp_sed133x_internal_getStruct(dd)->tcrcrdiff != serdisp_sed133x_internal_getStruct(dd)->pre_tcrcrdiff)
+ ) {
+ byte buf_get_bgconf[8];
+ byte buf_get_conf[64];
+
+ sd_debug(1,"%s: calling GET_BASICCONFIGDATA:", __func__);
+ sd_debug(1,"%s: W: %d <-> %d", __func__, dd->width, serdisp_sed133x_internal_getStruct(dd)->pre_width);
+ sd_debug(1,"%s: H: %d <-> %d", __func__, dd->height, serdisp_sed133x_internal_getStruct(dd)->pre_height);
+ sd_debug(1,"%s: D: %d <-> %d", __func__, serdisp_sed133x_internal_getStruct(dd)->dispclkdiv, serdisp_sed133x_internal_getStruct(dd)->pre_dispclkdiv);
+ sd_debug(1,"%s: F: %d <-> %d", __func__, serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv, serdisp_sed133x_internal_getStruct(dd)->pre_fpshiftdiv);
+ sd_debug(1,"%s: T: %d <-> %d", __func__, serdisp_sed133x_internal_getStruct(dd)->tcrcrdiff, serdisp_sed133x_internal_getStruct(dd)->pre_tcrcrdiff);
+
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 1, 0); /* CMD_GET_BASICCONFIGDATA */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_commit(dd->sdcd);
+ SDCONN_readstream(dd->sdcd, buf_get_conf, 64);
+
+ if (buf_get_conf[0] == 1 /* CMD_GET_BASICCONFIGDATA */ && buf_get_conf[1] == 20 /* MSG_REPLY */) {
+
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 5, 0); /* CMD_GET_BACKLIGHTCONFIGDATA */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_commit(dd->sdcd);
+ SDCONN_readstream(dd->sdcd, buf_get_bgconf, 7);
+ if (buf_get_bgconf[0] == 5 /* CMD_GET_BACKLIGHTCONFIGDATA */ && buf_get_bgconf[1] == 20 /* MSG_REPLY */) {
+ byte buf_get_result[4];
+ int i;
+
+ sd_debug(1, "%s():CMD_GET_BACKLIGHTCONFIGDATA:", __func__);
+ sd_debug(1, "%s():----------------------------", __func__);
+ sd_debug(1, "%s(): Control PWM: %d", __func__, buf_get_bgconf[2]);
+ sd_debug(1, "%s(): CCFLPWM: %d", __func__, buf_get_bgconf[3]);
+ sd_debug(1, "%s(): BG Config: %d", __func__, buf_get_bgconf[4]);
+ sd_debug(1, "%s(): PWM Frequency: %d", __func__, buf_get_bgconf[5] | (buf_get_bgconf[6] << 8));
+
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 3, 0); /* CMD_SET_CONFIGDATA */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_write(dd->sdcd, dd->width & 0xff, 0); /* [ 3] new width */
+ SDCONN_write(dd->sdcd, dd->width >> 8, 0); /* [ 4] */
+ SDCONN_write(dd->sdcd, dd->height & 0xff, 0); /* [ 5] new height */
+ SDCONN_write(dd->sdcd, dd->height >> 8, 0); /* [ 6] */
+ for (i = 0; i < 16; i++) /* [ 7-22] 16 char user name */
+ SDCONN_write(dd->sdcd, buf_get_conf[38+i], 0);
+ SDCONN_write(dd->sdcd, serdisp_sed133x_internal_getStruct(dd)->dispclkdiv & 0xff, 0); /* [23] dispclkdiv */
+ SDCONN_write(dd->sdcd, serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv & 0xff, 0); /* [24] fpshiftdiv */
+ for (i = 0; i < 5; i++) /* [25-29] payload from background config data */
+ SDCONN_write(dd->sdcd, buf_get_bgconf[2+i], 0);
+ SDCONN_write(dd->sdcd, serdisp_sed133x_internal_getStruct(dd)->tcrcrdiff & 0xff, 0); /* [30] tcrcrdiff */
+ SDCONN_write(dd->sdcd, serdisp_sed133x_internal_getStruct(dd)->tcrcrdiff > 8, 0); /* [31] tcrcrdiff */
+ SDCONN_commit(dd->sdcd);
+
+ SDCONN_readstream(dd->sdcd, buf_get_result, 3);
+ if (buf_get_result[0] == 3 /* CMD_SET_CONFIGDATA */ &&
+ buf_get_result[1] == 20 /* MSG_REPLY */ &&
+ buf_get_result[2] == 1 /* CMD_SUCCESS */
+ ) {
+ sd_debug(2, "%s(): CMD_SET_CONFIGDATA successful", __func__);
+ } else {
+ sd_error(SERDISP_ERUNTIME, "%s(): CMD_SET_CONFIGDATA unsuccessful", __func__);
+ }
+ }
+ }
+ }
+
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 7, 0); /* CMD_WRITE_S1D13700_COMMAND */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_write(dd->sdcd, CMD_DISPON, 0); /* display on */
+ SDCONN_commit(dd->sdcd);
+}
+
+
+/* *********************************
+ void serdisp_usb13700_update(dd)
+ *********************************
+ updates the display using display-buffer scrbuf+scrbuf_chg
+ *********************************
+ dd ... display descriptor
+ *********************************
+
+ the display is redrawn using a time-saving algorithm:
+
+ background knowledge: after writing a page-entry to the display,
+ the x-address is increased automatically =>
+ * try to utilize this auto-increasing
+ (if a whole horizontal line needs to be redrawn: only 4x PutCtrl per page will be needed)
+
+ * on the other hand try to avoid writing of unchanged data:
+ best case: no need to change any data in a certain page: 0x PutCtrl (set page) + 0x PutCtrl (set xpos) + 0x PutData)
+
+*/
+void serdisp_usb13700_update(serdisp_t* dd) {
+ byte data;
+ int i;
+ int max_col = ((dd->width + dd->xcolgaps + 7) / 8);
+#ifdef OPT_USEOLDUPDATEALGO
+ int col;
+ /* unoptimised display update (slow. all pixels are redrawn) */
+
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 2, 0); /* CMD_WRITE_FULLSCREEN */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_write(dd->sdcd, dd->scrbuf_size & 0xff, 0); /* w */
+ SDCONN_write(dd->sdcd, dd->scrbuf_size >> 8, 0); /* databytes */
+
+ for (i = 0; i < dd->height; i++) {
+ for (col = 0; col < max_col; col++) {
+ data = dd->scrbuf [ max_col * i + col];
+
+ /* if (dd->curr_invert && !(dd->feature_invert)) */
+ if (dd->curr_invert)
+ data = ~data;
+
+ SDCONN_write(dd->sdcd, (long)data, dd->sdcd->io_flags_writedata);
+ }
+ }
+
+#else /* OPT_USEOLDUPDATEALGO */
+
+ /* display is drawn using an optimising algorithm which tries to only send as few data as possible to the display */
+
+ int x, y;
+ int xt = 0, yt = 0, xb = 0, yb = 0;
+ i = sdtools_calc_bbox (dd, 1, &xt, &yt, &xb, &yb);
+ /*fprintf(stderr, "[%d] %3d/%3d - %3d/%3d\n", i, xt, yt, xb, yb);*/
+
+ if (i != 0) {
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 13, 0); /* CMD_WRITE_AREA */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_write(dd->sdcd, xt & 0xff, 0); /* x */
+ SDCONN_write(dd->sdcd, xt >> 8, 0); /* */
+ SDCONN_write(dd->sdcd, yt & 0xff, 0); /* y */
+ SDCONN_write(dd->sdcd, yt >> 8, 0); /* */
+ SDCONN_write(dd->sdcd, (xb-xt+1) & 0xff, 0); /* w */
+ SDCONN_write(dd->sdcd, (xb-xt+1) >> 8, 0); /* */
+ SDCONN_write(dd->sdcd, (yb-yt+1) & 0xff, 0); /* h */
+ SDCONN_write(dd->sdcd, (yb-yt+1) >> 8, 0); /* */
+ SDCONN_write(dd->sdcd, 0, 0); /* horicontally */
+ SDCONN_write(dd->sdcd, 0, 0); /* reserved */
+
+ for (y = yt; y <= yb; y++) {
+ for (x = xt; x <= xb; x+=8) {
+ data = dd->scrbuf [ y * max_col + x/8];
+
+ if (dd->curr_invert)
+ data = ~data;
+
+ SDCONN_write(dd->sdcd, data, 0); /* data */
+ dd->scrbuf_chg[ y * (max_col / 8) + (x / 64)] &= (0xFF ^ (1 << ((x/8) % 8)));
+ }
+ }
+ }
+#endif /* OPT_USEOLDUPDATEALGO */
+
+ SDCONN_commit(dd->sdcd);
+}
+
+
+/* *********************************
+ int serdisp_usb13700_setoption(dd, option, value)
+ *********************************
+ change a display option
+ *********************************
+ dd ... display descriptor
+ option ... name of option to change
+ value ... value for option
+*/
+int serdisp_usb13700_setoption(serdisp_t* dd, const char* option, long value) {
+ if (dd->feature_backlight && serdisp_compareoptionnames(dd, option, "BACKLIGHT")) {
+ byte buf[4];
+
+ if (value < 2)
+ dd->curr_backlight = (int)value;
+ else
+ dd->curr_backlight = (dd->curr_backlight) ? 0 : 1;
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 4, 0); /* CMD_SET_BACKLIGHT */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_write(dd->sdcd,dd->curr_backlight, 0); /* on/off */
+ SDCONN_write(dd->sdcd, 255, 0); /* brightness */
+ SDCONN_commit(dd->sdcd);
+ SDCONN_readstream(dd->sdcd, buf, 3);
+ if (!buf[2]) /* if 3rd byte from response == 0: command was unsucessful */
+ sd_debug(1, "%s(): unable to switch %s background light", __func__, ((dd->curr_backlight) ? "on" : "off"));
+ } else if (serdisp_compareoptionnames(dd, option, "DISPCLKDIV")) {
+ byte buf[4];
+ serdisp_sed133x_internal_getStruct(dd)->dispclkdiv = value;
+
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 23, 0); /* CMD_SET_S1D13700_CLK_DIV */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_write(dd->sdcd,serdisp_sed133x_internal_getStruct(dd)->dispclkdiv, 0); /* dispclkdiv */
+ SDCONN_write(dd->sdcd,serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv, 0); /* tcrcrdiff */
+ SDCONN_commit(dd->sdcd);
+ SDCONN_readstream(dd->sdcd, buf, 3);
+
+ if (buf[0] == 23 /* CMD_SET_CONFIGDATA */ &&
+ buf[1] == 20 /* MSG_REPLY */ &&
+ buf[2] == 1 /* CMD_SUCCESS */
+ ) {
+ sd_debug(2, "%s(): successfully changed DISPCLKDIV and FPSHIFTDIV (%d / %d)", __func__,
+ serdisp_sed133x_internal_getStruct(dd)->dispclkdiv,
+ serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv
+ );
+ } else {
+ sd_debug(1, "%s(): unable to change DISPCLKDIV and FPSHIFTDIV", __func__);
+ }
+ } else if (serdisp_compareoptionnames(dd, option, "FPSHIFTDIV")) {
+ byte buf[4];
+ serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv = value;
+
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 23, 0); /* CMD_SET_S1D13700_CLK_DIV */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_write(dd->sdcd,serdisp_sed133x_internal_getStruct(dd)->dispclkdiv, 0); /* dispclkdiv */
+ SDCONN_write(dd->sdcd,serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv, 0); /* tcrcrdiff */
+ SDCONN_commit(dd->sdcd);
+ SDCONN_readstream(dd->sdcd, buf, 3);
+
+ if (buf[0] == 23 /* CMD_SET_CONFIGDATA */ &&
+ buf[1] == 20 /* MSG_REPLY */ &&
+ buf[2] == 1 /* CMD_SUCCESS */
+ ) {
+ sd_debug(2, "%s(): successfully changed DISPCLKDIV and FPSHIFTDIV (%d / %d)", __func__,
+ serdisp_sed133x_internal_getStruct(dd)->dispclkdiv,
+ serdisp_sed133x_internal_getStruct(dd)->fpshiftdiv
+ );
+ } else {
+ sd_debug(1, "%s(): unable to change DISPCLKDIV and FPSHIFTDIV", __func__);
+ }
+ } else {
+ /* option not found here: try generic one in calling serdisp_setoption(); */
+ return 0;
+ }
+ return 1;
+}
+
+
+/* *********************************
+ void serdisp_usb13700_close(dd)
+ *********************************
+ close (switch off) display
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_usb13700_close(serdisp_t* dd) {
+ SDCONN_write(dd->sdcd, 0xfe, 0);
+ SDCONN_write(dd->sdcd, 7, 0); /* CMD_WRITE_S1D13700_COMMAND */
+ SDCONN_write(dd->sdcd, 10, 0); /* MSG_COMMAND */
+ SDCONN_write(dd->sdcd, CMD_DISPOFF, 0); /* display off */
+ SDCONN_commit(dd->sdcd);
+}
+
+
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_sed153x.c
^
|
@@ -7,7 +7,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -53,9 +53,6 @@
#undef OPT_USEOLDUPDATEALGO
-/* min. 1 uS according to data sheet. we use 5 to be sure */
-#define DELAY_RESET() usleep(5)
-
#define PutData(_dd, _data) serdisp_sed153x_transfer((_dd), (1), (_data))
#define PutCtrl(_dd, _data) serdisp_sed153x_transfer((_dd), (0), (_data))
@@ -163,6 +160,7 @@
{ "DELAY", "", 0, -1, 1, 1, ""}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
,{ "BACKLIGHT", "", 0, 1, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
};
@@ -179,7 +177,7 @@
int interfacemode;
} serdisp_sed153x_specific_t;
-serdisp_sed153x_specific_t* serdisp_sed153x_internal_getStruct(serdisp_t* dd) {
+static serdisp_sed153x_specific_t* serdisp_sed153x_internal_getStruct(serdisp_t* dd) {
return (serdisp_sed153x_specific_t*)(dd->specific_data);
}
@@ -231,8 +229,6 @@
dd->fp_update = &serdisp_sed153x_update;
dd->fp_setoption = &serdisp_sed153x_setoption;
dd->fp_close = &serdisp_sed153x_close;
- dd->fp_setpixel = &sdtools_generic_setpixel;
- dd->fp_getpixel = &sdtools_generic_getpixel;
dd->width = 96;
dd->height = 32;
@@ -286,23 +282,19 @@
/* allocate relocation tables */
if (dd->dsp_id != DISPID_E08552) {
- if (! dd->xreloctab) {
- if (! (dd->xreloctab = (int*) sdtools_malloc( sizeof(int) * (dd->width + dd->xcolgaps) ) ) ) {
- sd_error(SERDISP_EMALLOC, "serdisp_sed153x_setup(): cannot allocate relocation table");
- free(dd);
- dd = 0;
- return (serdisp_t*)0;
- }
- }
- if (! dd->yreloctab) {
- if (! (dd->yreloctab = (int*) sdtools_malloc( sizeof(int) * (dd->height + dd->ycolgaps) ) ) ) {
- sd_error(SERDISP_EMALLOC, "serdisp_sed153x_setup(): cannot allocate relocation table");
- free(dd->xreloctab);
- free(dd);
- dd = 0;
- return (serdisp_t*)0;
- }
- }
+ if (! (dd->xreloctab = (int*) sdtools_malloc( sizeof(int) * (dd->width + dd->xcolgaps) ) ) ) {
+ sd_error(SERDISP_EMALLOC, "serdisp_sed153x_setup(): cannot allocate relocation table");
+ free(dd);
+ dd = 0;
+ return (serdisp_t*)0;
+ }
+ if (! (dd->yreloctab = (int*) sdtools_malloc( sizeof(int) * (dd->height + dd->ycolgaps) ) ) ) {
+ sd_error(SERDISP_EMALLOC, "serdisp_sed153x_setup(): cannot allocate relocation table");
+ free(dd->xreloctab);
+ free(dd);
+ dd = 0;
+ return (serdisp_t*)0;
+ }
}
@@ -369,13 +361,13 @@
/* reset */
if (SIG_RESET) { /* reset signal sent by parport */
SDCONN_write(dd->sdcd, SIG_RESET | SIG_ICS, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
SDCONN_write(dd->sdcd, 0, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
} else { /* reset signal generated by R/C circuit */
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
SDCONN_write(dd->sdcd, 0, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
}
if (dd->dsp_id == DISPID_LSU7S1011A) {
@@ -412,13 +404,13 @@
/* reset */
if (SIG_RESET) { /* reset signal sent by parport */
SDCONN_write(dd->sdcd, SIG_RESET, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
SDCONN_write(dd->sdcd, 0, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
} else { /* reset signal generated by R/C circuit */
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
SDCONN_write(dd->sdcd, 0, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
}
/* Epson E0855-2 */
@@ -731,10 +723,23 @@
/* no command for en/disable backlight, so issue 'dummy'-command
(which indirectly enables/disabled backlight) */
PutCtrl(dd, CMD_NOP);
- } else if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST") ) {
- dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else if (dd->feature_contrast &&
+ (serdisp_compareoptionnames(dd, option, "CONTRAST" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ )
+ {
+ int dimmed_contrast;
- PutCtrl(dd, INI_V5_CONTR | dd->curr_contrast ); /* contrast: max. value: 0x1F */
+ if ( serdisp_compareoptionnames(dd, option, "CONTRAST" ) ) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+ dd->curr_dimming = 100 - (int)value;
+ }
+
+ dimmed_contrast = (((dd->curr_contrast - dd->min_contrast) * (100 - dd->curr_dimming)) / 100) + dd->min_contrast;
+
+ PutCtrl(dd, INI_V5_CONTR | dimmed_contrast /*dd->curr_contrast*/); /* contrast: max. value: 0x1F */
/* PutCtrl(dd, CMD_NOP );*/
} else {
/* option not found here: try generic one in calling serdisp_setoption(); */
@@ -766,8 +771,8 @@
serdisp_setoption(dd, "BACKLIGHT", 0);
PutCtrl(dd, CMD_RESET); /* reset */
}
-
- DELAY_RESET();
+
+ SDCONN_usleep(dd->sdcd, 5);
}
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_sed156x.c
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -41,8 +41,6 @@
/* #undef OPT_USEOLDUPDATEALGO */
-#define DELAY_RESET() usleep(1000)
-
#define PutData(_dd, _data) serdisp_sed156x_transfer((_dd), (1), (_data))
#define PutCtrl(_dd, _data) serdisp_sed156x_transfer((_dd), (0), (_data))
@@ -153,7 +151,7 @@
} serdisp_sed156x_specific_t;
-serdisp_sed156x_specific_t* serdisp_sed156x_internal_getStruct(serdisp_t* dd) {
+static serdisp_sed156x_specific_t* serdisp_sed156x_internal_getStruct(serdisp_t* dd) {
return (serdisp_sed156x_specific_t*)(dd->specific_data);
}
@@ -192,6 +190,7 @@
{ "DELAY", "", 0, -1, 1, 1, ""}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
,{ "BACKLIGHT", "", 0, 1, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
};
@@ -335,8 +334,8 @@
/* reset */
/* SIG_RESET and SIG_ICS are active low and are auto-inverted by software */
- SDCONN_write(dd->sdcd, (SIG_RESET) ? SIG_RESET : 0, 0); DELAY_RESET();
- SDCONN_write(dd->sdcd, 0, 0); DELAY_RESET();
+ SDCONN_write(dd->sdcd, (SIG_RESET) ? SIG_RESET : 0, 0); SDCONN_usleep(dd->sdcd, 1000);
+ SDCONN_write(dd->sdcd, 0, 0); SDCONN_usleep(dd->sdcd, 1000);
PutCtrl(dd, INI_BIAS_1DIV7); /* set bias to 1/7 */
PutCtrl(dd, INI_ADCREVERSE); /* ADC select */
@@ -357,10 +356,10 @@
} else if (dd->dsp_id == DISPID_HP12542R) {
if (SIG_RESET) {
SDCONN_write(dd->sdcd, SIG_RESET, 0);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 1000);
SDCONN_write(dd->sdcd, 0, 0);
- DELAY_RESET();
- }
+ SDCONN_usleep(dd->sdcd, 1000);
+ }
PutCtrl(dd, CMD_DSPLINESTRT); /* display line start: 0 */
PutCtrl(dd, INI_ADCNORMAL); /* ADC select */
PutCtrl(dd, INI_BIAS_1DIV7); /* set bias to 1/7 */
@@ -387,7 +386,7 @@
int ost = (dd->dsp_id == DISPID_NEC21A) ? 0x2 : 0xC;
PutCtrl(dd, CMD_RESET); /* reset */
- usleep(20000);
+ SDCONN_usleep(dd->sdcd, 20000);
PutCtrl(dd, CMD_DISPLAYOFF); /* display off during init */
@@ -399,7 +398,7 @@
PutCtrl(dd, INI_OUTPSTATREG+ost); /* output status register set */
PutCtrl(dd, INI_POWSUPP_ON); /* power supp on */
- sleep(1);
+ SDCONN_usleep(dd->sdcd, 1000000); /* sleep 1sec */
PutCtrl(dd, INI_POWON_COMPL); /* set power-on completion */
PutCtrl(dd, INI_ELVOL_CONTR+0xF); /* volume control (set to maximum) */
@@ -714,17 +713,29 @@
/* no command for en/disable backlight, so issue 'dummy'-command
(which indirectly enables/disabled backlight) */
PutCtrl(dd, CMD_NOP);
- } else if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST" )) {
- dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else if (dd->feature_contrast &&
+ (serdisp_compareoptionnames(dd, option, "CONTRAST" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ )
+ {
+ int dimmed_contrast;
+
+ if ( serdisp_compareoptionnames(dd, option, "CONTRAST" ) ) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+ dd->curr_dimming = 100 - (int)value;
+ }
+
+ dimmed_contrast = (((dd->curr_contrast - dd->min_contrast) * (100 - dd->curr_dimming)) / 100) + dd->min_contrast;
if (dd->dsp_id == DISPID_NOKIA7110 || dd->dsp_id == DISPID_HP12542R) {
PutCtrl(dd, INI_EL_VOL_SET ); /* Electronic Volume Mode Set (double byte command)*/
- PutCtrl(dd, dd->curr_contrast ); /* contrast: max. value: 0x3F (bits D7, D6 are ignored) */
+ PutCtrl(dd, dimmed_contrast /*dd->curr_contrast*/ ); /* contrast: max. value: 0x3F, bits D7, D6 are ignored */
PutCtrl(dd, CMD_NOP );
} else {
- PutCtrl(dd, 0x80 + dd->curr_contrast ); /* contrast: max. value: 0x1F */
+ PutCtrl(dd, 0x80 + dimmed_contrast /*dd->curr_contrast*/ ); /* contrast: max. value: 0x1F */
}
-
} else {
/* option not found here: try generic one in calling serdisp_setoption(); */
return 0;
@@ -747,9 +758,9 @@
/* reset */
if (serdisp_sed156x_internal_getStruct(dd)->interfacemode == INTERFACE_SERIAL) {
if (SIG_RESET) {
- SDCONN_write(dd->sdcd, SIG_RESET, 0); DELAY_RESET();
+ SDCONN_write(dd->sdcd, SIG_RESET, 0); SDCONN_usleep(dd->sdcd, 1000);
}
- SDCONN_write(dd->sdcd, 0, 0); DELAY_RESET();
+ SDCONN_write(dd->sdcd, 0, 0); SDCONN_usleep(dd->sdcd, 1000);
} else {
PutCtrl(dd, CMD_RESET); /* reset */
}
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_ssdoled.c
^
|
@@ -8,10 +8,13 @@
* - Osram Pictiva 96x36x1, 1.0", controller SSD0303
* - Osram Pictiva 96x64x16, 1.0", controller SSD1332
* - Osram Pictiva 128x64x4, 2.7", controller SSD0323
+ * - Bolymin BL160128A 160x128x18, controller SSD1353
*
+ * contributions:
+ * - 4DOLED-282815 128x128x18 1.5" controller SSD1339 added by jopka@kvidex.ru
*************************************************************************
*
- * copyright (C) 2006-2008 wolfgang astleitner
+ * copyright (C) 2006-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -39,7 +42,6 @@
#include <sys/ioctl.h>
#include "serdisplib/serdisp_connect.h"
-/*#include "serdisplib/serdisp_specific_ssdoled.h"*/
#include "serdisplib/serdisp_tools.h"
#include "serdisplib/serdisp_messages.h"
#include "serdisplib/serdisp_colour.h"
@@ -48,9 +50,6 @@
/* #define OPT_USEOLDUPDATEALGO */
-/* min. 1 uS according to data sheet. we use 5 to be sure */
-#define DELAY_RESET() usleep(5)
-
/*
* command constants
*/
@@ -96,6 +95,8 @@
#define DISPID_OLED96X36X1 1
#define DISPID_OLED96X64X16 2
#define DISPID_OLED128X64X4 3
+#define DISPID_BL160128A 4
+#define DISPID_4DOLED282815 5
serdisp_wiresignal_t serdisp_ssdoled_wiresignals[] = {
@@ -114,14 +115,16 @@
serdisp_wiredef_t serdisp_ssdoled_wiredefs[] = {
{ 0, SDCT_PP, "Original", "DATA8,CS:nSELIN,DC:INIT,WR:nAUTO,RD:nSTRB", "Original wiring"}
,{ 1, SDCT_PP, "OriginalSWRes", "DATA8,CS:nSELIN,DC:INIT,RESET:nAUTO,WR:nSTRB", "Original wiring w/ software reset"}
- ,{ 2, SDCT_PP, "I2C", "SCLK:D0,SDA:D1", "simple I2C wiring"}
- ,{ 3, SDCT_PP, "SPI", "SCLK:D0,SDA:D1,CS:D2,DC:D3", "simple SPI wiring"}
+ ,{ 2, SDCT_PP, "I2C", "SCLK:D0,SDA:D1", "simple I2C wiring"}
+ ,{ 3, SDCT_PP, "SPI", "SCLK:D0,SDA:D1,CS:D2,DC:D3", "simple SPI wiring"}
+ ,{ 4, SDCT_PP, "Simple", "DATA8,DC:INIT,WR:nLINEFD", "simple parallel port wiring"}
};
serdisp_options_t serdisp_ssdoled_options[] = {
/* name aliasnames min max mod int defines */
{ "DELAY", "", 0, -1, 1, 1, ""}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
/* ,{ "INTERFACE", "MODE", 0, 3, 1, 0, "8080=0,6800=1,SPI=2,SERIAL=2,I2C=3"} */ /* i2c not yet supported */
,{ "INTERFACE", "MODE", 0, 2, 1, 0, "8080=0,6800=1,SPI=2,SERIAL=2"}
,{ "RAWCMD", "", 0, 255, 1, 1, ""} /* for development - internal use only */
@@ -133,6 +136,7 @@
{ "DEPTH", "COLS,COLOURS",8, 16, 8, 0, "65536=16,64k=16,256=8"}
,{ "DELAY", "", 0, -1, 1, 1, ""}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
,{ "INTERFACE", "MODE", 0, 2, 1, 0, "8080=0,6800=1,SPI=2,SERIAL=2"}
,{ "RAWCMD", "", 0, 255, 1, 1, ""} /* for development - internal use only */
};
@@ -141,10 +145,34 @@
/* name aliasnames min max mod int defines */
{ "DELAY", "", 0, -1, 1, 1, ""}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
,{ "INTERFACE", "MODE", 0, 2, 1, 0, "8080=0,6800=1,SPI=2,SERIAL=2"}
,{ "RAWCMD", "", 0, 255, 1, 1, ""} /* for development - internal use only */
};
+serdisp_options_t serdisp_bl160128a_options[] = {
+ /* name aliasnames min max mod int defines */
+ { "DEPTH", "COLS,COLOURS",8, 18, 2, 0, "256K=18,65536=16,64k=16,256=8"}
+ ,{ "DELAY", "", 0, -1, 1, 1, ""}
+ ,{ "CONTRAST", "", 0, 10, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
+ ,{ "SLOPPYSIGNAL","SLOPPY", 0, 1, 1, 1, ""}
+ ,{ "GSTABLECORR", "GSCORR", 50, 300, 1, 1, ""}
+ ,{ "RAWCMD", "", 0, 255, 1, 1, ""} /* for development - internal use only */
+};
+
+serdisp_options_t serdisp_4doled282815_options[] = {
+ /* name aliasnames min max mod int defines */
+ { "DEPTH", "COLS,COLOURS",8, 18, 2, 0, "256K=18,65536=16,64k=16,256=8"}
+ ,{ "DELAY", "", 0, -1, 1, 1, ""}
+ ,{ "CONTRAST", "", 0, 10, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
+ ,{ "INTERFACE", "MODE", 0, 2, 1, 0, "8080=0,6800=1,SPI=2,SERIAL=2"}
+ ,{ "SLOPPYSIGNAL","SLOPPY", 0, 1, 1, 1, ""}
+ ,{ "GSTABLECORR", "GSCORR", 50, 300, 1, 1, ""}
+ ,{ "RAWCMD", "", 0, 255, 1, 1, ""} /* for development - internal use only */
+};
+
/* internal typedefs and functions */
@@ -153,16 +181,25 @@
static int serdisp_ssdoled_setoption (serdisp_t*, const char*, long);
static void serdisp_ssdoled_close (serdisp_t*);
-static void serdisp_oled96x64x16_update (serdisp_t*);
+static void serdisp_ssdoled_clear (serdisp_t*);
+
+static void serdisp_oledcolour_cc_update(serdisp_t*); /* colour displays, both command + command options: D/C=C */
+static void serdisp_oledcolour_cd_update(serdisp_t*); /* colour dipslays, command: D/C=C, command options: D/C=D */
static void serdisp_oled128x64x4_update (serdisp_t*);
+static void serdisp_ssdoled_transfer (serdisp_t* dd, int iscmd, byte item);
+static void serdisp_ssdoled_writecmd (serdisp_t* dd, byte cmd);
+static void serdisp_ssdoled_writedata (serdisp_t* dd, byte data);
+
typedef struct serdisp_ssdoled_specific_s {
int interfacemode;
+ int sloppysignal;
+ int gstablecorr;
} serdisp_ssdoled_specific_t;
-serdisp_ssdoled_specific_t* serdisp_ssdoled_internal_getStruct(serdisp_t* dd) {
+static serdisp_ssdoled_specific_t* serdisp_ssdoled_internal_getStruct(serdisp_t* dd) {
return (serdisp_ssdoled_specific_t*)(dd->specific_data);
}
@@ -266,8 +303,10 @@
sdtools_nsleep(dd->delay);
SDCONN_write(dd->sdcd, td_clk2, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
sdtools_nsleep(dd->delay);
- SDCONN_write(dd->sdcd, td_clk3, dd->sdcd->io_flags_writecmd);
- sdtools_nsleep(dd->delay);
+ if (serdisp_ssdoled_internal_getStruct(dd)->sloppysignal == 0) {
+ SDCONN_write(dd->sdcd, td_clk3, dd->sdcd->io_flags_writecmd);
+ sdtools_nsleep(dd->delay);
+ }
}
}
@@ -283,10 +322,16 @@
/* callback-function for setting non-standard options */
-void* serdisp_ssdoled_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+static void* serdisp_ssdoled_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
if (serdisp_compareoptionnames(dd, optionname, "INTERFACE")) {
*typesize = sizeof(int);
return &(serdisp_ssdoled_internal_getStruct(dd)->interfacemode);
+ } else if (serdisp_compareoptionnames(dd, optionname, "SLOPPYSIGNAL")) {
+ *typesize = sizeof(int);
+ return &(serdisp_ssdoled_internal_getStruct(dd)->sloppysignal);
+ } else if (serdisp_compareoptionnames(dd, optionname, "GSTABLECORR")) {
+ *typesize = sizeof(int);
+ return &(serdisp_ssdoled_internal_getStruct(dd)->gstablecorr);
}
return 0;
}
@@ -329,6 +374,10 @@
dd->dsp_id = DISPID_OLED96X64X16;
else if (serdisp_comparedispnames("OLED128X64X4", dispname))
dd->dsp_id = DISPID_OLED128X64X4;
+ else if (serdisp_comparedispnames("BL160128A", dispname))
+ dd->dsp_id = DISPID_BL160128A;
+ else if (serdisp_comparedispnames("4DOLED282815", dispname))
+ dd->dsp_id = DISPID_4DOLED282815;
else { /* should not occur */
sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_specific_ssdoled.c", dispname);
return (serdisp_t*)0;
@@ -339,8 +388,6 @@
dd->fp_update = &serdisp_ssdoled_update;
dd->fp_close = &serdisp_ssdoled_close;
dd->fp_setoption = &serdisp_ssdoled_setoption;
- dd->fp_setpixel = &sdtools_generic_setpixel;
- dd->fp_getpixel = &sdtools_generic_getpixel;
dd->fp_getvalueptr = &serdisp_ssdoled_getvalueptr;
@@ -362,24 +409,23 @@
dd->optalgo_maxdelta = 3;
dd->delay = 0;
+ serdisp_ssdoled_internal_getStruct(dd)->gstablecorr = 100; /* default grey scale table */
if (dd->dsp_id == DISPID_OLED96X64X16) {
dd->height = 64;
dd->depth = 16;
- dd->startxcol = 0;
dd->colour_spaces = SD_CS_SELFEMITTING | SD_CS_BGR | SD_CS_RGB565 | SD_CS_RGB332;
dd->min_contrast = 0;
dd->max_contrast = 0x0F;
dd->dsparea_width = 20100; /* according to datasheet */
dd->dsparea_height = 13400;
- dd->fp_update = &serdisp_oled96x64x16_update;
+ dd->fp_update = &serdisp_oledcolour_cc_update;
dd->optalgo_maxdelta = 6;
} else if (dd->dsp_id == DISPID_OLED128X64X4) {
dd->width = 128;
dd->height = 64;
dd->depth = 4;
- dd->startxcol = 0;
dd->colour_spaces = SD_CS_SELFEMITTING | SD_CS_GREYSCALE;
dd->min_contrast = 0x00; /*0x10; */
dd->max_contrast = 0x7F; /*0x3F; */
@@ -387,12 +433,47 @@
dd->dsparea_height = 30700;
dd->fp_update = &serdisp_oled128x64x4_update;
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ dd->fp_setsdpixel = &sdtools_generic_setsdpixel_greyhoriz;
+ dd->fp_getsdpixel = &sdtools_generic_getsdpixel_greyhoriz;
+#else
dd->fp_setpixel = &sdtools_generic_setpixel_greyhoriz;
dd->fp_getpixel = &sdtools_generic_getpixel_greyhoriz;
+#endif
dd->optalgo_maxdelta = 6;
+ } else if (dd->dsp_id == DISPID_BL160128A) {
+ dd->width = 160;
+ dd->height = 128;
+ dd->depth = 18;
+ dd->colour_spaces = SD_CS_SELFEMITTING | SD_CS_RGB565 | SD_CS_RGB332 | SD_CS_RGB666;
+ dd->min_contrast = 0;
+ dd->max_contrast = 0x0F;
+ dd->dsparea_width = 37015; /* according to datasheet */
+ dd->dsparea_height = 30012;
+
+ dd->fp_clear = &serdisp_ssdoled_clear;
+ dd->fp_update = &serdisp_oledcolour_cd_update;
+ dd->optalgo_maxdelta = 6;
+
+ serdisp_ssdoled_internal_getStruct(dd)->gstablecorr = 200; /* contrast too high with default 100 */
+ } else if (dd->dsp_id == DISPID_4DOLED282815) {
+ dd->width = 128;
+ dd->height = 128;
+ dd->depth = 18;
+ dd->startycol = 4; /* first line on display: 4 */
+ dd->colour_spaces = SD_CS_SELFEMITTING | SD_CS_RGB565 | SD_CS_RGB332 | SD_CS_RGB666;
+ dd->min_contrast = 0x00;
+ dd->max_contrast = 0x0F;
+
+ dd->fp_clear = &serdisp_ssdoled_clear;
+ dd->fp_update = &serdisp_oledcolour_cd_update;
+ dd->optalgo_maxdelta = 6;
+
+ serdisp_ssdoled_internal_getStruct(dd)->gstablecorr = 200; /* contrast too high with default 100 */
}
serdisp_ssdoled_internal_getStruct(dd)->interfacemode = INTERFACE_8080;
+ serdisp_ssdoled_internal_getStruct(dd)->sloppysignal = 0; /* stay on the safe side per default */
/* finally set some non display specific defaults */
@@ -406,6 +487,10 @@
serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_oled96x64x16_options);
} else if (dd->dsp_id == DISPID_OLED128X64X4) {
serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_oled128x64x4_options);
+ } else if (dd->dsp_id == DISPID_BL160128A) {
+ serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_bl160128a_options);
+ } else if (dd->dsp_id == DISPID_4DOLED282815) {
+ serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_4doled282815_options);
} else {
serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_ssdoled_options);
}
@@ -418,6 +503,16 @@
return (serdisp_t*)0;
}
+ if (dd->dsp_id == DISPID_BL160128A || dd->dsp_id == DISPID_4DOLED282815) {
+ if ( ! (dd->depth == 8 || dd->depth == 16 || dd->depth == 18) ) {
+ sd_error(SERDISP_ENOTSUP, "%s(): display depth %d not supported (supported depths are: 8, 16, 18)", __func__, dd->depth);
+ free(dd->specific_data);
+ free(dd);
+ dd = 0;
+ return (serdisp_t*)0;
+ }
+ }
+
return dd;
}
@@ -435,11 +530,11 @@
SDCONN_write(dd->sdcd, SIG_RESET | ((SIG_CS) ? SIG_CS : 0),
dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
SDCONN_write(dd->sdcd, (SIG_CS) ? SIG_CS : 0, dd->sdcd->io_flags_writecmd | dd->sdcd->io_flags_writedata);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
if (dd->dsp_id == DISPID_OLED96X36X1) {
serdisp_ssdoled_writecmd (dd, 0x40); /* display start line at line 0 */
@@ -488,11 +583,11 @@
serdisp_ssdoled_writecmd (dd, 0x15); /* set column address */
serdisp_ssdoled_writecmd (dd, 0x00); /* start: 0 */
- serdisp_ssdoled_writecmd (dd, 95); /* end: 95 */
+ serdisp_ssdoled_writecmd (dd, dd->width-1); /* end: width-1 */
serdisp_ssdoled_writecmd (dd, 0x75); /* set row address */
serdisp_ssdoled_writecmd (dd, 0x00); /* start: 0 */
- serdisp_ssdoled_writecmd (dd, 63); /* end: 63 */
+ serdisp_ssdoled_writecmd (dd, dd->height-1); /* end: height-1 */
serdisp_ssdoled_writecmd (dd, 0x81); /* set contrast red */
serdisp_ssdoled_writecmd (dd, 0x2F);
@@ -516,7 +611,7 @@
serdisp_ssdoled_writecmd (dd, 0x00);
serdisp_ssdoled_writecmd (dd, 0xA8); /* multiplex ratio */
- serdisp_ssdoled_writecmd (dd, 0x3F);
+ serdisp_ssdoled_writecmd (dd, dd->height-1); /* height-1 */
serdisp_ssdoled_writecmd (dd, 0xA4); /* normal display (not inverted) */
@@ -547,75 +642,113 @@
serdisp_ssdoled_writecmd (dd, 0x00);
serdisp_ssdoled_writecmd (dd, 0xAF); /* entire display off/on: on */
-#if 0
- } else if (dd->dsp_id == DISPID_OLED128X64X4) {
+ } else if (dd->dsp_id == DISPID_BL160128A) {
+ int i, greyvalue;
+ double gscorr = (double)(serdisp_ssdoled_internal_getStruct(dd)->gstablecorr) / 100.0;
+ byte colour_mode = 0x00;
- serdisp_ssdoled_writecmd (dd, 0x15); /* set column address */
- serdisp_ssdoled_writecmd (dd, 0x00); /* start: 0 */
- serdisp_ssdoled_writecmd (dd, 63); /* end: 128/2 - 1 */
+ serdisp_ssdoled_writecmd (dd, 0xE2); /* sw reset */
- serdisp_ssdoled_writecmd (dd, 0x75); /* set row address */
- serdisp_ssdoled_writecmd (dd, 0x00); /* start: 0 */
- serdisp_ssdoled_writecmd (dd, 63); /* end: 63 */
+ serdisp_ssdoled_writecmd (dd, 0xFD); /* command lock */
+ serdisp_ssdoled_writedata(dd, 0x12); /* unlock */
- serdisp_ssdoled_writecmd (dd, 0x81); /* set contrast */
- serdisp_ssdoled_writecmd (dd, 0x33);
+ serdisp_ssdoled_writecmd (dd, 0xAE); /* entire display off/on: off */
- serdisp_ssdoled_writecmd (dd, 0x86); /* current range: full */
+ serdisp_ssdoled_writecmd (dd, CMD_NOP);
+
+ switch(dd->depth) {
+ case 16:
+ colour_mode = 0x40;
+ break;
+ case 18:
+ colour_mode = 0x80;
+ break;
+ default:
+ colour_mode = 0x00;
+ }
+ colour_mode |= 0x34; /* segment remap, colour-mode = RGB */
serdisp_ssdoled_writecmd (dd, 0xA0); /* segement remap, colour-mode */
- serdisp_ssdoled_writecmd (dd, 0x43);
+ serdisp_ssdoled_writedata(dd, colour_mode);
serdisp_ssdoled_writecmd (dd, 0xA1); /* set display start line */
- serdisp_ssdoled_writecmd (dd, 0x00);
+ serdisp_ssdoled_writedata(dd, 0x00);
serdisp_ssdoled_writecmd (dd, 0xA2); /* set display offset */
- serdisp_ssdoled_writecmd (dd, 0x44);
+ serdisp_ssdoled_writedata(dd, 0x00);
serdisp_ssdoled_writecmd (dd, 0xA8); /* multiplex ratio */
- serdisp_ssdoled_writecmd (dd, 0x3F /*0x4F*/);
+ serdisp_ssdoled_writedata(dd, dd->height-1); /* height-1 */
- serdisp_ssdoled_writecmd (dd, 0xB2); /* row period */
- serdisp_ssdoled_writecmd (dd, /*0x7C*/ 0x46); /* */
+#if 0
+ serdisp_ssdoled_writecmd (dd, 0x83); /* contrast colour A */
+ serdisp_ssdoled_writedata(dd, 0x7F/*0xB4*/);
+
+ serdisp_ssdoled_writecmd (dd, 0x82); /* contrast colour B */
+ serdisp_ssdoled_writedata(dd, 0x7F/*0x96*/);
+
+ serdisp_ssdoled_writecmd (dd, 0x81); /* contrast colour C */
+ serdisp_ssdoled_writedata(dd, 0x7F/*0xA0*/);
+#endif
+
+ serdisp_ssdoled_writecmd (dd, 0xB8); /* set grey scale table */
+ for (i = 0; i <= 63; i++ ) {
+ greyvalue = (int)(127.0 * sdtools_pow( (double)i / (double)63 , gscorr) + 0.5);
+ serdisp_ssdoled_writedata(dd, greyvalue);
+ }
serdisp_ssdoled_writecmd (dd, 0xA4); /* normal display (not inverted) */
- serdisp_ssdoled_writecmd (dd, 0xAD); /* Set DC-DC */
- serdisp_ssdoled_writecmd (dd, 0x02); /* disable */
+ serdisp_ssdoled_writecmd (dd, 0xAF); /* entire display off/on: on */
+ } else if (dd->dsp_id == DISPID_4DOLED282815) {
+ int i, greyvalue;
+ double gscorr = (double)(serdisp_ssdoled_internal_getStruct(dd)->gstablecorr) / 100.0;
+ byte colour_mode = 0x00;
+
+ serdisp_ssdoled_writecmd (dd, CMD_NOP);
- serdisp_ssdoled_writecmd (dd, 0xB0); /* precharge */
- serdisp_ssdoled_writecmd (dd, 0x08);
+ switch(dd->depth) {
+ case 16:
+ colour_mode = 0x40;
+ break;
+ case 18:
+ colour_mode = 0x80;
+ break;
+ default:
+ colour_mode = 0x00;
+ }
+ colour_mode |= 0x34; /* segment remap, colour-mode = RGB */
- serdisp_ssdoled_writecmd (dd, 0xB4); /* precharge level */
- serdisp_ssdoled_writecmd (dd, 0x00);
+ serdisp_ssdoled_writecmd (dd, 0xA0); /* segement remap, colour-mode */
+ serdisp_ssdoled_writedata(dd, colour_mode);
- serdisp_ssdoled_writecmd (dd, 0xB3); /* set clock divide */
- serdisp_ssdoled_writecmd (dd, /*0xF0*/ 0x41); /* */
+ serdisp_ssdoled_writecmd (dd, 0xA1); /* set display start line */
+ serdisp_ssdoled_writedata(dd, 0x00);
- serdisp_ssdoled_writecmd (dd, 0xB1); /* phase length */
- serdisp_ssdoled_writecmd (dd, /*0x13*/ 0x22);
+ serdisp_ssdoled_writecmd (dd, 0xA2); /* set display offset */
+ serdisp_ssdoled_writedata(dd, 0x00);
- serdisp_ssdoled_writecmd (dd, 0xBF); /* VSL */
- serdisp_ssdoled_writecmd (dd, /*0x02*/ 0x0B); /* */
+ serdisp_ssdoled_writecmd (dd, 0xA6); /* reset to normal display */
+
+ serdisp_ssdoled_writecmd (dd, 0xAD); /* set master configuration dc-dc */
+ serdisp_ssdoled_writedata(dd, 0x8E);
+
+ serdisp_ssdoled_writecmd (dd, 0xB1); /* pre-charge */
+ serdisp_ssdoled_writedata(dd, 0x74);
serdisp_ssdoled_writecmd (dd, 0xBE); /* VCOMH-level */
- serdisp_ssdoled_writecmd (dd, /*0x0B*/ 0x0B);
+ serdisp_ssdoled_writedata(dd, 0x3F);
- serdisp_ssdoled_writecmd (dd, 0xBC); /* VP */
- serdisp_ssdoled_writecmd (dd, /*0x18*/ 0x18);
+ serdisp_ssdoled_writecmd (dd, 0xB0); /* set powersafe */
+ serdisp_ssdoled_writedata(dd, 0x00);
- serdisp_ssdoled_writecmd (dd, 0xB8); /* grey scale table */
- serdisp_ssdoled_writecmd (dd, 0x01);
- serdisp_ssdoled_writecmd (dd, 0x11);
- serdisp_ssdoled_writecmd (dd, 0x22);
- serdisp_ssdoled_writecmd (dd, 0x32);
- serdisp_ssdoled_writecmd (dd, 0x43);
- serdisp_ssdoled_writecmd (dd, 0x54);
- serdisp_ssdoled_writecmd (dd, 0x65);
- serdisp_ssdoled_writecmd (dd, 0x76);
+ serdisp_ssdoled_writecmd (dd, 0xB8); /* set grey scale table */
+ for (i = 0; i <= 31; i++ ) {
+ greyvalue = (int)(127.0 * sdtools_pow( (double)i / (double)31 , gscorr) + 0.5);
+ serdisp_ssdoled_writedata(dd, greyvalue);
+ }
serdisp_ssdoled_writecmd (dd, 0xAF); /* entire display off/on: on */
-#endif
} else if (dd->dsp_id == DISPID_OLED128X64X4) {
serdisp_ssdoled_writecmd (dd, 0x15); /* set column address */
@@ -803,21 +936,151 @@
}
-/* separate update function for 96x64 colour oled, taken from serdisp_nokcol.c */
-void serdisp_oled96x64x16_update(serdisp_t* dd) {
+/* separate update function for colour oleds, taken from serdisp_nokcol.c */
+void serdisp_oledcolour_cc_update(serdisp_t* dd) {
int i;
#ifdef OPT_USEOLDUPDATEALGO
- serdisp_ssdoled_writecmd(dd, 0x15); /* set column address */
- serdisp_ssdoled_writecmd(dd, 0x00); /* start: 0 */
- serdisp_ssdoled_writecmd(dd, 95); /* end: 95 */
+ serdisp_ssdoled_writecmd (dd, 0x15); /* set column address */
+ serdisp_ssdoled_writecmd (dd, 0x00); /* start: 0 */
+ serdisp_ssdoled_writecmd (dd, dd->width-1); /* end: width-1 */
+
+ serdisp_ssdoled_writecmd (dd, 0x75); /* set row address */
+ serdisp_ssdoled_writecmd (dd, 0x00); /* start: 0 */
+ serdisp_ssdoled_writecmd (dd, dd->height-1); /* end: height-1 */
- serdisp_ssdoled_writecmd(dd, 0x75); /* set row address */
- serdisp_ssdoled_writecmd(dd, 0x00); /* start: 0 */
- serdisp_ssdoled_writecmd(dd, 63); /* end: 63 */
+ serdisp_ssdoled_writecmd (dd, CMD_NOP);
+
+ for (i = 0; i < dd->scrbuf_size; i++)
+ serdisp_ssdoled_writedata(dd, dd->scrbuf[i]);
+
+ serdisp_ssdoled_writecmd(dd, CMD_NOP);
+
+#else /* OPT_USEOLDUPDATEALGO */
+
+ /* display is drawn using an optimising algorithm which tries to only send as few data as possible to the display */
+
+ /* more detailed explanations of principle:
+ see serdisp_specific_optrex323.c / i2c.c / pcd8544.c / sed153x.c / sed1565.c
+ */
+
+ int col;
+ byte data;
+ int delta;
+ int i_delta = 0; /* i_delta - i: how many columns to transfer in one take */
+
+ int last_col_set = -1;
+ int r_transmitted = 0;
+
+ i = 0;
+
+ while (i < dd->width * dd->height) {
+ int y_i, col_i, l;
+
+ int y = i / dd->width;
+
+ col = i % dd->width;
+
+ /* first changed column-page */
+ if ( dd->scrbuf_chg[(col >> 3) + y * ((dd->width + 7 ) >> 3)] & ( 1 << (col%8) )) {
+ i_delta = i;
+
+ delta = 0;
+ while (i_delta < dd->width*dd->height-delta-1 && delta < dd->optalgo_maxdelta) {
+ y_i = (i_delta+delta+1) / dd->width;
+ col_i = (i_delta+delta+1) % dd->width;
+ if ( dd->scrbuf_chg[(col_i >> 3) + y_i * ((dd->width + 7 ) >> 3)] & ( 1 << (col_i%8) )) {
+ i_delta += delta+1;
+ delta = 0;
+ } else {
+ delta++;
+ }
+ }
+
+ last_col_set = -1;
+
+ /*fprintf(stderr, "col/y=%02d/%02d (i=%4d i_delta=%4d diff: %2d)\n", col, y, i, i_delta, i_delta-i);*/
+
+ for (l = i; l <= i_delta; l++) {
+ int idx_2, idx, bitspercol;
+
+ y_i = l / dd->width;
+ col_i = l % dd->width;
+
+ if (last_col_set == -1 || col_i < last_col_set) { /* start correction needed for CASET */
+ serdisp_ssdoled_writecmd (dd, 0x15); /* set column address */
+ serdisp_ssdoled_writecmd (dd, col_i); /* start column */
+ serdisp_ssdoled_writecmd (dd, dd->width-1); /* end column */
+
+ serdisp_ssdoled_writecmd (dd, 0x75); /* set row address */
+ serdisp_ssdoled_writecmd (dd, y_i); /* start row */
+ serdisp_ssdoled_writecmd (dd, dd->height-1); /* end row */
+
+ serdisp_ssdoled_writecmd (dd, CMD_NOP);
+
+ last_col_set = col_i;
+ r_transmitted = 0;
+ }
+
+ bitspercol = (dd->depth == 18) ? 24 : dd->depth; /* for speed reasons, align depth 18 to 24 bits in screen buffer */
+ idx_2 = ((col_i + y_i * dd->width) * (bitspercol << 1)) / 8;
+ idx = idx_2 >> 1;
+ switch(dd->depth) {
+ case 4:
+ case 8:
+ data = dd->scrbuf[idx];
+ serdisp_ssdoled_writedata(dd, data);
+ break;
+ case 16:
+ data = dd->scrbuf[idx];
+ serdisp_ssdoled_writedata(dd, data);
+ data = dd->scrbuf[idx+1];
+ serdisp_ssdoled_writedata(dd, data);
+ break;
+ case 18:
+ data = dd->scrbuf[idx];
+ serdisp_ssdoled_writedata(dd, data);
+ data = dd->scrbuf[idx+1];
+ serdisp_ssdoled_writedata(dd, data);
+ data = dd->scrbuf[idx+2];
+ serdisp_ssdoled_writedata(dd, data);
+ break;
+ }
+
+ dd->scrbuf_chg[ (col_i >> 3) + y_i * ((dd->width + 7 ) >> 3)] &= (0xFF ^ (1 << (col_i % 8)));
+ }
+
+ i = i_delta+1;
+
+ } else {
+ i++;
+ }
+ } /* while i < scrbuf_size */
+
+#endif /* OPT_USEOLDUPDATEALGO */
+ /* add an extra NOP to avoid erraneous pixels when releasing parport */
serdisp_ssdoled_writecmd(dd, CMD_NOP);
+ SDCONN_commit(dd->sdcd); /* if streaming: be sure that every data is transmitted */
+}
+
+
+/* separate update function for colour oleds, taken from serdisp_nokcol.c */
+void serdisp_oledcolour_cd_update(serdisp_t* dd) {
+ int i;
+
+#ifdef OPT_USEOLDUPDATEALGO
+
+ serdisp_ssdoled_writecmd (dd, 0x15); /* set column address */
+ serdisp_ssdoled_writedata(dd, 0x00); /* start: 0 */
+ serdisp_ssdoled_writedata(dd, dd->width-1); /* end: width-1 */
+
+ serdisp_ssdoled_writecmd (dd, 0x75); /* set row address */
+ serdisp_ssdoled_writedata(dd, 0x00 + dd->startycol); /* start: 0 */
+ serdisp_ssdoled_writedata(dd, dd->height-1 + dd->startycol); /* end: height-1 */
+
+ serdisp_ssdoled_writecmd (dd, 0x5C); /* write data to ram */
for (i = 0; i < dd->scrbuf_size; i++)
serdisp_ssdoled_writedata(dd, dd->scrbuf[i]);
@@ -836,19 +1099,19 @@
byte data;
int delta;
int i_delta = 0; /* i_delta - i: how many columns to transfer in one take */
-
+
int last_col_set = -1;
int r_transmitted = 0;
-
+
i = 0;
while (i < dd->width * dd->height) {
int y_i, col_i, l;
int y = i / dd->width;
-
+
col = i % dd->width;
-
+
/* first changed column-page */
if ( dd->scrbuf_chg[(col >> 3) + y * ((dd->width + 7 ) >> 3)] & ( 1 << (col%8) )) {
i_delta = i;
@@ -868,31 +1131,30 @@
last_col_set = -1;
/*fprintf(stderr, "col/y=%02d/%02d (i=%4d i_delta=%4d diff: %2d)\n", col, y, i, i_delta, i_delta-i);*/
-
+
for (l = i; l <= i_delta; l++) {
- int idx_2, idx;
-
+ int idx_2, idx, bitspercol;
+
y_i = l / dd->width;
col_i = l % dd->width;
- if (dd->curr_invert && !(dd->feature_invert))
- data = ~data;
-
if (last_col_set == -1 || col_i < last_col_set) { /* start correction needed for CASET */
- serdisp_ssdoled_writecmd(dd, 0x15); /* set column address */
- serdisp_ssdoled_writecmd(dd, col_i); /* start column */
- serdisp_ssdoled_writecmd(dd, dd->width-1); /* end column */
+ serdisp_ssdoled_writecmd (dd, 0x15); /* set column address */
+ serdisp_ssdoled_writedata(dd, col_i); /* start column */
+ serdisp_ssdoled_writedata(dd, dd->width-1); /* end column */
+
+ serdisp_ssdoled_writecmd (dd, 0x75); /* set row address */
+ serdisp_ssdoled_writedata(dd, y_i + dd->startycol); /* start row */
+ serdisp_ssdoled_writedata(dd, dd->height-1 + dd->startycol); /* end row */
- serdisp_ssdoled_writecmd(dd, 0x75); /* set row address */
- serdisp_ssdoled_writecmd(dd, y_i); /* start row */
- serdisp_ssdoled_writecmd(dd, dd->height-1); /* end row */
- serdisp_ssdoled_writecmd(dd, CMD_NOP);
+ serdisp_ssdoled_writecmd (dd, 0x5C); /* write data to ram */
last_col_set = col_i;
r_transmitted = 0;
}
- idx_2 = ((col_i + y_i * dd->width) * (dd->depth << 1)) / 8;
+ bitspercol = (dd->depth == 18) ? 24 : dd->depth; /* for speed reasons, align depth 18 to 24 bits in screen buffer */
+ idx_2 = ((col_i + y_i * dd->width) * (bitspercol << 1)) / 8;
idx = idx_2 >> 1;
switch(dd->depth) {
case 4:
@@ -906,8 +1168,16 @@
data = dd->scrbuf[idx+1];
serdisp_ssdoled_writedata(dd, data);
break;
+ case 18:
+ data = dd->scrbuf[idx];
+ serdisp_ssdoled_writedata(dd, data);
+ data = dd->scrbuf[idx+1];
+ serdisp_ssdoled_writedata(dd, data);
+ data = dd->scrbuf[idx+2];
+ serdisp_ssdoled_writedata(dd, data);
+ break;
}
-
+
dd->scrbuf_chg[ (col_i >> 3) + y_i * ((dd->width + 7 ) >> 3)] &= (0xFF ^ (1 << (col_i % 8)));
}
@@ -994,16 +1264,13 @@
last_col_set = -1;
/*fprintf(stderr, "col/y=%02d/%02d (i=%4d i_delta=%4d diff: %2d cols=%d)\n", col, y, i, i_delta, i_delta-i, cols);*/
-
+
for (l = i; l <= i_delta; l++) {
int idx;
-
+
y_i = l / cols;
col_i = l % cols;
- if (dd->curr_invert && !(dd->feature_invert))
- data = ~data;
-
if (last_col_set == -1 || col_i < last_col_set) { /* start correction needed for CASET */
serdisp_ssdoled_writecmd(dd, 0x15); /* set column address */
serdisp_ssdoled_writecmd(dd, col_i); /* start column */
@@ -1062,20 +1329,42 @@
dd->curr_invert = (int)value;
else
dd->curr_invert = (dd->curr_invert) ? 0 : 1;
- if (dd->dsp_id == DISPID_OLED96X36X1)
+ if (dd->dsp_id == DISPID_OLED96X36X1 || dd->dsp_id == DISPID_4DOLED282815)
serdisp_ssdoled_writecmd(dd, (dd->curr_invert) ? 0xA7 : 0xA6);
- else if (dd->dsp_id == DISPID_OLED96X64X16)
+ else if (dd->dsp_id == DISPID_OLED96X64X16 || dd->dsp_id == DISPID_BL160128A)
serdisp_ssdoled_writecmd(dd, (dd->curr_invert) ? 0xA7 : 0xA4);
else if (dd->dsp_id == DISPID_OLED128X64X4)
serdisp_ssdoled_writecmd(dd, (dd->curr_invert) ? 0xA7 : 0xA4);
serdisp_ssdoled_writecmd (dd, CMD_NOP);
- } else if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST" )) {
- dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else if (dd->feature_contrast &&
+ (serdisp_compareoptionnames(dd, option, "CONTRAST" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ )
+ {
+ int dimmed_contrast;
+ byte cmd_contrast = 0x81;
- serdisp_ssdoled_writecmd(dd, (dd->dsp_id == DISPID_OLED96X64X16) ? 0x87 : 0x81);
- serdisp_ssdoled_writecmd(dd, dd->curr_contrast);
- serdisp_ssdoled_writecmd(dd, CMD_NOP);
+ if ( serdisp_compareoptionnames(dd, option, "CONTRAST" ) ) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+ dd->curr_dimming = 100 - (int)value;
+ }
+
+ dimmed_contrast = (((dd->curr_contrast - dd->min_contrast) * (100 - dd->curr_dimming)) / 100) + dd->min_contrast;
+ if (dd->dsp_id == DISPID_OLED96X64X16 || dd->dsp_id == DISPID_BL160128A)
+ cmd_contrast = 0x87;
+ else if (dd->dsp_id == DISPID_4DOLED282815)
+ cmd_contrast = 0xC7;
+
+ serdisp_ssdoled_writecmd(dd, cmd_contrast);
+ if (dd->dsp_id == DISPID_BL160128A || dd->dsp_id == DISPID_4DOLED282815) {
+ serdisp_ssdoled_writedata(dd, dimmed_contrast);
+ } else {
+ serdisp_ssdoled_writecmd (dd, dimmed_contrast);
+ }
+ serdisp_ssdoled_writecmd(dd, CMD_NOP);
} else if (serdisp_compareoptionnames(dd, option, "RAWCMD")) {
fprintf(stderr, "val: 0x%02x\n", (byte)(0xFF & value));
serdisp_ssdoled_writecmd (dd, (byte)(0xFF & value));
@@ -1087,6 +1376,24 @@
}
+/* *********************************
+ void serdisp_ssdoled_clear(dd)
+ *********************************
+ clear display
+ *********************************
+ dd ... display descriptor
+*/
+void serdisp_ssdoled_clear(serdisp_t* dd) {
+ /* to be used with BL160128A and 4DOLED282815 only! */
+ serdisp_ssdoled_writecmd (dd, (dd->dsp_id == DISPID_BL160128A) ? 0x25 : 0x8E);
+ serdisp_ssdoled_writedata(dd, 0);
+ serdisp_ssdoled_writedata(dd, dd->startycol);
+ serdisp_ssdoled_writedata(dd, dd->width-1);
+ serdisp_ssdoled_writedata(dd, dd->height-1 + dd->startycol);
+
+ serdisp_ssdoled_writecmd(dd, CMD_NOP);
+}
+
/* *********************************
void serdisp_ssdoled_close(dd)
@@ -1098,6 +1405,10 @@
void serdisp_ssdoled_close(serdisp_t* dd) {
serdisp_ssdoled_writecmd (dd, 0xAE); /* display off */
serdisp_ssdoled_writecmd (dd, CMD_NOP);
+ if (dd->dsp_id == DISPID_BL160128A) {
+ serdisp_ssdoled_writecmd (dd, 0xFD); /* command lock */
+ serdisp_ssdoled_writedata(dd, 0x16); /* lock */
+ }
}
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_stv8105.c
^
|
@@ -9,7 +9,7 @@
*
*************************************************************************
*
- * copyright (C) 2007-2008 wolfgang astleitner
+ * copyright (C) 2007-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -46,9 +46,6 @@
/* #define OPT_NOISEFIX */
-/* min. 1 uS according to data sheet. we use 5 to be sure */
-#define DELAY_RESET() usleep(5)
-
/*
* values used mainly for initialization
@@ -59,7 +56,7 @@
#define INTERFACE_SPI 1
-/* define shorts for signals to make coding simpler. must match order of serdisp_ssdoled_wiresignals[] */
+/* define shorts for signals to make coding simpler. must match order of serdisp_stv8105_wiresignals[] */
#define SIG_SCLK (dd->sdcd->signals[ 0])
#define SIG_SDA (dd->sdcd->signals[ 1])
@@ -104,6 +101,7 @@
{ "DEPTH", "COLS,COLOURS",1, 4, 2, 0, "MONOCHROME=1,MONO=1"}
,{ "DELAY", "", 0, -1, 1, 1, ""}
,{ "CONTRAST", "", 0, 10, 1, 1, ""}
+ ,{ "BRIGHTNESS", "", 0, 100, 1, 1, ""} /* brightness [0 .. 100] */
,{ "OPTION", "", 1, 2, 1, 0, ""}
,{ "INTERFACE", "MODE", 0, 1, 1, 0, "PAR=0,PARALLEL=0,SERIAL=1,SPI=1"}
};
@@ -116,7 +114,11 @@
static int serdisp_stv8105_setoption (serdisp_t*, const char*, long);
static void serdisp_stv8105_close (serdisp_t*);
-static void serdisp_stv8105_update (serdisp_t*);
+static void serdisp_stv8105_update (serdisp_t*);
+
+static void serdisp_stv8105_transfer (serdisp_t* dd, int iscmd, byte item);
+static void serdisp_stv8105_writecmd (serdisp_t* dd, byte cmd);
+static void serdisp_stv8105_writedata (serdisp_t* dd, byte data);
typedef struct serdisp_stv8105_specific_s {
@@ -128,7 +130,7 @@
} serdisp_stv8105_specific_t;
-serdisp_stv8105_specific_t* serdisp_stv8105_internal_getStruct(serdisp_t* dd) {
+static serdisp_stv8105_specific_t* serdisp_stv8105_internal_getStruct(serdisp_t* dd) {
return (serdisp_stv8105_specific_t*)(dd->specific_data);
}
@@ -237,7 +239,7 @@
/* callback-function for setting non-standard options */
-void* serdisp_stv8105_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+static void* serdisp_stv8105_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
if (serdisp_compareoptionnames(dd, optionname, "INTERFACE")) {
*typesize = sizeof(int);
return &(serdisp_stv8105_internal_getStruct(dd)->interfacemode);
@@ -293,8 +295,13 @@
dd->fp_close = &serdisp_stv8105_close;
dd->fp_setoption = &serdisp_stv8105_setoption;
dd->fp_getvalueptr = &serdisp_stv8105_getvalueptr;
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ dd->fp_setsdpixel = &sdtools_generic_setsdpixel_greyhoriz;
+ dd->fp_getsdpixel = &sdtools_generic_getsdpixel_greyhoriz;
+#else
dd->fp_setpixel = &sdtools_generic_setpixel_greyhoriz;
dd->fp_getpixel = &sdtools_generic_getpixel_greyhoriz;
+#endif
/* per display settings */
@@ -352,14 +359,14 @@
/* *********************************
void serdisp_stv8105_init(dd)
*********************************
- initialise a ssdoled-based display
+ initialise a stv8105-based display
*********************************
dd ... display descriptor
*/
void serdisp_stv8105_init(serdisp_t* dd) {
if (SIG_RESET) {
SDCONN_write(dd->sdcd, SIG_RESET, dd->sdcd->io_flags_writecmd);
- DELAY_RESET();
+ SDCONN_usleep(dd->sdcd, 5);
SDCONN_write(dd->sdcd, 0, dd->sdcd->io_flags_writecmd);
}
@@ -574,11 +581,24 @@
dd->curr_invert = (dd->curr_invert) ? 0 : 1;
serdisp_stv8105_writecmd(dd, 0x10); /* DCTRL, dot-matrix display control */
serdisp_stv8105_writecmd(dd, (dd->curr_invert) ? 0x05 : 0x01);
- } else if (dd->feature_contrast && serdisp_compareoptionnames(dd, option, "CONTRAST" )) {
- dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else if (dd->feature_contrast &&
+ (serdisp_compareoptionnames(dd, option, "CONTRAST" ) ||
+ serdisp_compareoptionnames(dd, option, "BRIGHTNESS" )
+ )
+ )
+ {
+ int dimmed_contrast;
+
+ if ( serdisp_compareoptionnames(dd, option, "CONTRAST" ) ) {
+ dd->curr_contrast = sdtools_contrast_norm2hw(dd, (int)value);
+ } else {
+ dd->curr_dimming = 100 - (int)value;
+ }
+
+ dimmed_contrast = (((dd->curr_contrast - dd->min_contrast) * (100 - dd->curr_dimming)) / 100) + dd->min_contrast;
serdisp_stv8105_writecmd(dd, 0x16); /* DIMMERCTRL, dimmmer control */
- serdisp_stv8105_writecmd(dd, dd->curr_contrast);
+ serdisp_stv8105_writecmd(dd, dimmed_contrast /*dd->curr_contrast*/ );
} else {
/* option not found here: try generic one in calling serdisp_setoption(); */
return 0;
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_specific_t6963.c
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2007 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -95,12 +95,6 @@
#define SIG_RESET (dd->sdcd->signals[12])
#define SIG_BACKLIGHT (dd->sdcd->signals[13])
-
-static void serdisp_t6963_init (serdisp_t*);
-static void serdisp_t6963_update (serdisp_t*);
-static int serdisp_t6963_setoption (serdisp_t*, const char*, long);
-static void serdisp_t6963_close (serdisp_t*);
-
/* different display types/models supported by this driver */
#define DISPID_T6963 1
#define DISPID_TLX1391 2
@@ -147,6 +141,19 @@
/* internal typedef and functions */
+static void serdisp_t6963_init (serdisp_t*);
+static void serdisp_t6963_update (serdisp_t*);
+static int serdisp_t6963_setoption (serdisp_t*, const char*, long);
+static void serdisp_t6963_close (serdisp_t*);
+
+static void serdisp_t6963_checkready (serdisp_t* dd);
+static void serdisp_t6963_transfer (serdisp_t* dd, int iscmd, byte item);
+static void serdisp_t6963_writedata (serdisp_t* dd, byte data1);
+static void serdisp_t6963_writecmd0data (serdisp_t* dd, byte cmd);
+static void serdisp_t6963_writecmd1data (serdisp_t* dd, byte cmd, byte data1);
+static void serdisp_t6963_writecmd2data (serdisp_t* dd, byte cmd, byte data2, byte data1);
+
+
typedef struct serdisp_t6963_specific_s {
int interfacemode;
byte checkstatus;
@@ -154,12 +161,12 @@
-serdisp_t6963_specific_t* serdisp_t6963_internal_getStruct(serdisp_t* dd) {
+static serdisp_t6963_specific_t* serdisp_t6963_internal_getStruct(serdisp_t* dd) {
return (serdisp_t6963_specific_t*)(dd->specific_data);
}
-void* serdisp_t6963_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
+static void* serdisp_t6963_getvalueptr (serdisp_t* dd, const char* optionname, int* typesize) {
if (serdisp_compareoptionnames(dd, optionname, "CHECK")) {
*typesize = sizeof(byte);
return &(serdisp_t6963_internal_getStruct(dd)->checkstatus);
@@ -412,8 +419,13 @@
dd->fp_close = &serdisp_t6963_close;
dd->fp_setoption = &serdisp_t6963_setoption;
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ dd->fp_setsdpixel = &sdtools_generic_setsdpixel_greyhoriz;
+ dd->fp_getsdpixel = &sdtools_generic_getsdpixel_greyhoriz;
+#else
dd->fp_setpixel = &sdtools_generic_setpixel_greyhoriz;
dd->fp_getpixel = &sdtools_generic_getpixel_greyhoriz;
+#endif
dd->fp_getvalueptr = &serdisp_t6963_getvalueptr;
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/serdisp_tools.c
^
|
@@ -1,7 +1,7 @@
/** \file serdisp_tools.c
*
* \brief Common functions
- * \date (C) 2003-2008
+ * \date (C) 2003-2010
* \author wolfgang astleitner (mrwastl@users.sourceforge.net)
*/
@@ -30,11 +30,14 @@
#include <string.h>
#include <strings.h>
+#include <sys/time.h>
+#if 0
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/time.h>
#else
#include <sys/resource.h>
#endif
+#endif
#include "serdisplib/serdisp_tools.h"
#include "serdisplib/serdisp_messages.h"
@@ -157,7 +160,7 @@
serdisp_setpixel(dd, x, y, serdisp_getpixel(dd, w-1-x, h-1-y));
serdisp_setpixel(dd, w-1-x, h-1-y, temp);
}
- serdisp_update(dd);
+ serdisp_update(dd);
}
@@ -182,20 +185,20 @@
switch (dd->curr_rotate) {
case 0: /* 0 degrees */
- x_i = dd->xreloctab[x];
- y_i = dd->yreloctab[y];
+ x_i = (dd->xreloctab) ? dd->xreloctab[x] : x;
+ y_i = (dd->yreloctab) ? dd->yreloctab[y] : y;
break;
case 1: /* 180 degrees */
- x_i = dd->xreloctab[dd->width - 1 - x];
- y_i = dd->yreloctab[dd->height - 1 - y];
+ x_i = (dd->xreloctab) ? dd->xreloctab[dd->width - 1 - x] : (dd->width - 1 - x);
+ y_i = (dd->yreloctab) ? dd->yreloctab[dd->height - 1 - y] : (dd->height - 1 - y);
break;
case 2: /* 90 degrees */
- x_i = dd->xreloctab[y];
- y_i = dd->yreloctab[dd->height - 1 - x];
+ x_i = (dd->xreloctab) ? dd->xreloctab[y] : y;
+ y_i = (dd->yreloctab) ? dd->yreloctab[dd->height - 1 - x] : (dd->height - 1 - x);
break;
case 3: /* 270 degrees */
- x_i = dd->xreloctab[dd->width - 1 - y];
- y_i = dd->yreloctab[x];
+ x_i = (dd->xreloctab) ? dd->xreloctab[dd->width - 1 - y] : (dd->width - 1 - y);
+ y_i = (dd->yreloctab) ? dd->yreloctab[x] : x;
break;
}
@@ -228,7 +231,8 @@
}
} else {
int changed = 0;
- int idx_2 = ((x_i + y_i * (dd->width + dd->xcolgaps)) * (dd->depth << 1)) / 8;
+ int bitspercol = (dd->depth == 18) ? 24 : dd->depth; /* for speed reasons, align depth 18 to 24 bits in screen buffer */
+ int idx_2 = ((x_i + y_i * (dd->width + dd->xcolgaps)) * (bitspercol << 1)) >> 3;
int idx = idx_2 >> 1;
switch(dd->depth) {
@@ -274,6 +278,52 @@
changed = 1;
}
break;
+ case 18:
+ if ( dd->scrbuf[idx] != ((colour & 0x03F000L) >> 12) ) {
+ dd->scrbuf[idx] = ((colour & 0x03F000L) >> 12);
+ changed = 1;
+ }
+ if ( dd->scrbuf[idx+1] != ((colour & 0x000FC0L) >> 6) ) {
+ dd->scrbuf[idx+1] = ((colour & 0x000FC0L) >> 6);
+ changed = 1;
+ }
+ if ( dd->scrbuf[idx+2] != (colour & 0x00003FL) ) {
+ dd->scrbuf[idx+2] = (colour & 0x00003FL);
+ changed = 1;
+ }
+ break;
+ case 24:
+ if ( dd->scrbuf[idx] != ((colour & 0xFF0000L) >> 16) ) {
+ dd->scrbuf[idx] = ((colour & 0xFF0000L) >> 16);
+ changed = 1;
+ }
+ if ( dd->scrbuf[idx+1] != ((colour & 0x00FF00L) >> 8) ) {
+ dd->scrbuf[idx+1] = ((colour & 0x00FF00L) >> 8);
+ changed = 1;
+ }
+ if ( dd->scrbuf[idx+2] != (colour & 0x0000FFL) ) {
+ dd->scrbuf[idx+2] = (colour & 0x0000FFL);
+ changed = 1;
+ }
+ break;
+ case 32:
+ if ( dd->scrbuf[idx] != ((colour & 0xFF000000L) >> 24) ) {
+ dd->scrbuf[idx] = ((colour & 0xFF000000L) >> 24);
+ changed = 1;
+ }
+ if ( dd->scrbuf[idx+1] != ((colour & 0x00FF0000L) >> 16) ) {
+ dd->scrbuf[idx+1] = ((colour & 0x00FF0000L) >> 16);
+ changed = 1;
+ }
+ if ( dd->scrbuf[idx+2] != ((colour & 0x0000FF00L) >> 8) ) {
+ dd->scrbuf[idx+2] = ((colour & 0x0000FF00L) >> 8);
+ changed = 1;
+ }
+ if ( dd->scrbuf[idx+3] != (colour & 0x0000FFL) ) {
+ dd->scrbuf[idx+3] = (colour & 0x000000FFL);
+ changed = 1;
+ }
+ break;
}
if (changed && dd->scrbuf_chg) {
@@ -297,7 +347,7 @@
* \param dd device descriptor
* \param x x-position
* \param y y-position
- * \return hardware-depended grey-level or colour information at (x/y)
+ * \return hardware-dependent grey-level or colour information at (x/y)
*/
long sdtools_generic_getpixel (serdisp_t* dd, int x, int y) {
int x_i = 0, y_i = 0;
@@ -313,20 +363,20 @@
switch (dd->curr_rotate) {
case 0: /* 0 degrees */
- x_i = dd->xreloctab[x];
- y_i = dd->yreloctab[y];
+ x_i = (dd->xreloctab) ? dd->xreloctab[x] : x;
+ y_i = (dd->yreloctab) ? dd->yreloctab[y] : y;
break;
case 1: /* 180 degrees */
- x_i = dd->xreloctab[dd->width - 1 - x];
- y_i = dd->yreloctab[dd->height - 1 - y];
+ x_i = (dd->xreloctab) ? dd->xreloctab[dd->width - 1 - x] : (dd->width - 1 - x);
+ y_i = (dd->yreloctab) ? dd->yreloctab[dd->height - 1 - y] : (dd->height - 1 - y);
break;
case 2: /* 90 degrees */
- x_i = dd->xreloctab[y];
- y_i = dd->yreloctab[dd->height - 1 - x];
+ x_i = (dd->xreloctab) ? dd->xreloctab[y] : y;
+ y_i = (dd->yreloctab) ? dd->yreloctab[dd->height - 1 - x] : (dd->height - 1 - x);
break;
case 3: /* 270 degrees */
- x_i = dd->xreloctab[dd->width - 1 - y];
- y_i = dd->yreloctab[x];
+ x_i = (dd->xreloctab) ? dd->xreloctab[dd->width - 1 - y] : (dd->width - 1 - y);
+ y_i = (dd->yreloctab) ? dd->yreloctab[x] : x;
break;
}
@@ -345,7 +395,8 @@
value = (long)(value_byte >> ((y_i % pagediv)*dd->depth));
} else {
- int idx_2 = ((x_i + y_i * (dd->width + dd->xcolgaps)) * (dd->depth << 1)) / 8;
+ int bitspercol = (dd->depth == 18) ? 24 : dd->depth; /* for speed reasons, align depth 18 to 24 bits in screen buffer */
+ int idx_2 = ((x_i + y_i * (dd->width + dd->xcolgaps)) * (bitspercol << 1)) >> 3;
int idx = idx_2 >> 1;
@@ -364,6 +415,15 @@
case 16:
value = (long)((dd->scrbuf[idx] << 8) + dd->scrbuf[idx+1]);
break;
+ case 18:
+ value = (long)(((0x3F & dd->scrbuf[idx]) << 12) | ((0x3F & dd->scrbuf[idx+1]) << 6) | (0x3F & dd->scrbuf[idx+2]));
+ break;
+ case 24:
+ value = (long)((dd->scrbuf[idx] << 16) | (dd->scrbuf[idx+1] << 8) | dd->scrbuf[idx+2]);
+ break;
+ case 32:
+ value = (long)((dd->scrbuf[idx] << 24) | (dd->scrbuf[idx+1] << 16) | (dd->scrbuf[idx+2] << 8) | dd->scrbuf[idx+3]);
+ break;
}
}
@@ -378,7 +438,7 @@
* \param dd device descriptor
* \param x x-position
* \param y y-position
- * \param colour monochrome: 0: clear (white), <>0: set (black); else: grey value (dependend on display)
+ * \param colour monochrome: 0: clear (white), <>0: set (black); else: grey value (dependent on display)
*/
void sdtools_generic_setpixel_greyhoriz (serdisp_t* dd, int x, int y, long colour) {
int x_i = 0, y_i = 0, col;
@@ -396,20 +456,20 @@
switch (dd->curr_rotate) {
case 0: /* 0 degrees */
- x_i = dd->xreloctab[x];
- y_i = dd->yreloctab[y];
+ x_i = (dd->xreloctab) ? dd->xreloctab[x] : x;
+ y_i = (dd->yreloctab) ? dd->yreloctab[y] : y;
break;
case 1: /* 180 degrees */
- x_i = dd->xreloctab[dd->width - 1 - x];
- y_i = dd->yreloctab[dd->height - 1 - y];
+ x_i = (dd->xreloctab) ? dd->xreloctab[dd->width - 1 - x] : (dd->width - 1 - x);
+ y_i = (dd->yreloctab) ? dd->yreloctab[dd->height - 1 - y] : (dd->height - 1 - y);
break;
case 2: /* 90 degrees */
- x_i = dd->xreloctab[y];
- y_i = dd->yreloctab[dd->height - 1 - x];
+ x_i = (dd->xreloctab) ? dd->xreloctab[y] : y;
+ y_i = (dd->yreloctab) ? dd->yreloctab[dd->height - 1 - x] : (dd->height - 1 - x);
break;
case 3: /* 270 degrees */
- x_i = dd->xreloctab[dd->width - 1 - y];
- y_i = dd->yreloctab[x];
+ x_i = (dd->xreloctab) ? dd->xreloctab[dd->width - 1 - y] : (dd->width - 1 - y);
+ y_i = (dd->yreloctab) ? dd->yreloctab[x] : x;
break;
}
@@ -467,7 +527,7 @@
* \param dd device descriptor
* \param x x-position
* \param y y-position
- * \return hardware-depended grey-level or colour information at (x/y)
+ * \return hardware-dependent grey-level or colour information at (x/y)
*/
long sdtools_generic_getpixel_greyhoriz (serdisp_t* dd, int x, int y) {
int x_i = 0, y_i = 0, col;
@@ -484,20 +544,20 @@
switch (dd->curr_rotate) {
case 0: /* 0 degrees */
- x_i = dd->xreloctab[x];
- y_i = dd->yreloctab[y];
+ x_i = (dd->xreloctab) ? dd->xreloctab[x] : x;
+ y_i = (dd->yreloctab) ? dd->yreloctab[y] : y;
break;
case 1: /* 180 degrees */
- x_i = dd->xreloctab[dd->width - 1 - x];
- y_i = dd->yreloctab[dd->height - 1 - y];
+ x_i = (dd->xreloctab) ? dd->xreloctab[dd->width - 1 - x] : (dd->width - 1 - x);
+ y_i = (dd->yreloctab) ? dd->yreloctab[dd->height - 1 - y] : (dd->height - 1 - y);
break;
case 2: /* 90 degrees */
- x_i = dd->xreloctab[y];
- y_i = dd->yreloctab[dd->height - 1 - x];
+ x_i = (dd->xreloctab) ? dd->xreloctab[y] : y;
+ y_i = (dd->yreloctab) ? dd->yreloctab[dd->height - 1 - x] : (dd->height - 1 - x);
break;
case 3: /* 270 degrees */
- x_i = dd->xreloctab[dd->width - 1 - y];
- y_i = dd->yreloctab[x];
+ x_i = (dd->xreloctab) ? dd->xreloctab[dd->width - 1 - y] : (dd->width - 1 - y);
+ y_i = (dd->yreloctab) ? dd->yreloctab[x] : x;
break;
}
@@ -526,7 +586,7 @@
value = (value & mask) >> mask_shift;
}
- return (value);
+ return (value);
}
@@ -850,12 +910,28 @@
normval = 0;
else if (normval > MAX_CONTRASTSTEP)
normval = MAX_CONTRASTSTEP;
- /*
- (max - min) * cnorm + STEP/2
- chw = ---------------------------- + min ; STEP/2 corrects potential rounding error
- STEP
- */
- return ( ( (dd->max_contrast - dd->min_contrast) * normval + (MAX_CONTRASTSTEP >> 1)) / MAX_CONTRASTSTEP) + dd->min_contrast;
+
+ if (dd->mid_contrast != 0 && dd->mid_contrast > dd->min_contrast && dd->mid_contrast < dd->max_contrast) {
+ if (normval == (MAX_CONTRASTSTEP >> 1)) {
+ return dd->mid_contrast;
+ } else {
+ int mid_i = dd->mid_contrast - dd->min_contrast; /* shift [min ... mid ... max] to [0 ... mid' ... max'] */
+ int max_i = dd->max_contrast - dd->min_contrast;
+ /* expo-factor where normval => hwval = dd->mid_contrast */
+ /* formula: p = ln(max'/mid') / ln(2) */
+ double p = sdtools_log((double)max_i / (double)mid_i) / sdtools_log (2);
+
+ /* find hardware contrast value: hwval = min + max' * (normval/MAX_CONTRASTSTEP)^p */
+ return dd->min_contrast + (int)(max_i * (sdtools_pow( ((double)normval / (double)MAX_CONTRASTSTEP), p))+0.5);
+ }
+ } else {
+ /*
+ (max - min) * cnorm + STEP/2
+ chw = ---------------------------- + min ; STEP/2 corrects potential rounding error
+ STEP
+ */
+ return ( ( (dd->max_contrast - dd->min_contrast) * normval + (MAX_CONTRASTSTEP >> 1)) / MAX_CONTRASTSTEP) + dd->min_contrast;
+ }
}
@@ -870,17 +946,43 @@
*/
int sdtools_contrast_hw2norm(serdisp_t* dd, int hwval) {
if (!dd->max_contrast || (dd->min_contrast >= dd->max_contrast))
- return MAX_CONTRASTSTEP << 1;
+ return MAX_CONTRASTSTEP >> 1;
if (hwval < dd->min_contrast)
hwval = dd->min_contrast;
else if (hwval > dd->max_contrast)
hwval = dd->max_contrast;
- /*
- (chw - min) * STEP + STEP/2
- cnorm = --------------------------- ; STEP/2 corrects potential rounding error
- max-min
- */
- return ( (hwval - dd->min_contrast) * MAX_CONTRASTSTEP + (MAX_CONTRASTSTEP >> 1)) / (dd->max_contrast - dd->min_contrast);
+ if (dd->mid_contrast != 0 && dd->mid_contrast > dd->min_contrast && dd->mid_contrast < dd->max_contrast) {
+ if (hwval == dd->mid_contrast) {
+ return (MAX_CONTRASTSTEP >> 1);
+ } else {
+ int mid_i = dd->mid_contrast - dd->min_contrast; /* shift [min ... mid ... max] to [0 ... mid' ... max'] */
+ int max_i = dd->max_contrast - dd->min_contrast;
+ /* expo-factor where normval => dd->mid_contrast */
+ /* formula: p = ln(max'/mid') / ln(2) */
+ double p = sdtools_log((double)max_i / (double)mid_i) / sdtools_log (2);
+ int n = 0;
+ int curr_val;
+
+ /* the matching hwval is iterated, which avoid rounding errors. besides: this is no time critical function */
+ while(n <= MAX_CONTRASTSTEP) {
+ /* find hardware contrast value: c_hw = min + max' * (n/MAX_CONTRASTSTEP)^p */
+ curr_val = dd->min_contrast + (int)(max_i * (sdtools_pow( ((double)n / (double)MAX_CONTRASTSTEP), p))+0.5);
+ /* lookup if hwval matches current hw contrast value: if yes: normval is found */
+ if (hwval <= curr_val)
+ return n;
+ n++;
+ }
+ /* just for paranoia. code should never ever reach this line */
+ return MAX_CONTRASTSTEP >> 1;
+ }
+ } else {
+ /*
+ (chw - min) * STEP + STEP/2
+ cnorm = --------------------------- ; STEP/2 corrects potential rounding error
+ max-min
+ */
+ return ( (hwval - dd->min_contrast) * MAX_CONTRASTSTEP + (MAX_CONTRASTSTEP >> 1)) / (dd->max_contrast - dd->min_contrast);
+ }
}
@@ -970,3 +1072,254 @@
return ((num / 10) << 4) | (num % 10);
}
+
+/**
+ * \brief calculates bounding box containing changed display information (including x/ycolgaps!)
+ *
+ * \param dd device descriptor
+ * \param hor (valid only if depth < 8): \n
+ hor = 1: one byte == 1 to 4 pixels \n
+ hor = 0: pixels are organised in pages
+ * \param xt x top-left
+ * \param yt y top-left
+ * \param xb x bottom-left
+ * \param yb y bottom-left
+ * \retval 0 no changed display information found in current bounding box
+ * \retval 1 changes detected, new bbox calculated
+ * \retval -1 invalid values or display config: bbox returned == unchanged bbox or whole display area
+ *
+ * \since 1.97.9
+ */
+int sdtools_calc_bbox (serdisp_t* dd, int hor, int* xt, int* yt, int* xb, int* yb) {
+ /* initial algo by fen <fen@init-6.org> */
+ int found = 0;
+
+ int xt_curr, yt_curr;
+ int xb_curr, yb_curr;
+ int w_abs;
+ int h_abs;
+
+ int x = 0, y = 0;
+ int xstep = 1, ystep = 1;
+ int cols = 0; /* columns per line */
+ int col_div = 0;
+
+ /* scrbuf_bits_used != 8: not yet done */
+ if (!dd || !dd->scrbuf_chg || (!hor && (dd->depth > 8)) || dd->scrbuf_bits_used != 8) {
+ return -1;
+ }
+
+ w_abs = dd->width + dd->xcolgaps;
+ h_abs = dd->height + dd->ycolgaps;
+
+ /* auto init if no bounding box given at all */
+ if (dd && *xt == 0 && *yt == 0 && *xb == 0 && *yb == 0) {
+ *xb = w_abs - 1;
+ *yb = h_abs - 1;
+ }
+
+ /* invalid input bounding box */
+ if( *xt >= *xb || *yt >= *yb) {
+ return -1;
+ }
+
+ if (dd->depth < 8) {
+ col_div = 8 / dd->depth;
+ if (hor) {
+ xstep = col_div;
+ cols = (w_abs + col_div - 1) / col_div;
+ } else {
+ ystep = col_div;
+ cols = w_abs;
+ }
+ }
+
+ /* align starting point (eg: xstep = 8: *xt = [0, 7] -> 0; *xt = [8, 15] -> 8, a.s.o.) */
+ *xt = (*xt / xstep) * xstep;
+ *yt = (*yt / ystep) * ystep;
+
+ xt_curr = *xb;
+ yt_curr = *yb;
+ xb_curr = *xt;
+ yb_curr = *yt;
+
+ for (y = *yt; y <= *yb; y += ystep) {
+ for (x = *xt; x <= *xb; x += xstep) {
+ int isdirty = 0;
+ if (hor)
+ isdirty = dd->scrbuf_chg [ y * ((cols+col_div-1) / col_div) + ((x/col_div) / 8) ] & ( 1 << ( (x/col_div) % 8) );
+ else
+ isdirty = dd->scrbuf_chg [ ( (y/8) / ystep) * cols + x ] & ( 1 << ((y/8) % ystep));
+
+ if ( isdirty ) {
+ if (x < xt_curr) xt_curr = x;
+ if (x > xb_curr) xb_curr = x;
+ if (y < yt_curr) yt_curr = y;
+ if (y > yb_curr) yb_curr = y;
+ found = 1;
+ }
+ }
+ }
+
+ if (found) {
+ *xt = xt_curr;
+ *yt = yt_curr;
+ *xb = ((xb_curr / xstep) * xstep) + xstep - 1;
+ *yb = ((yb_curr / ystep) * ystep) + ystep - 1;
+ if (*xb >= w_abs) *xb = w_abs -1;
+ if (*yb >= h_abs) *yb = h_abs -1;
+ return 1;
+ }
+
+ return 0;
+}
+
+
+#define SD_EPSILON 0.000000000001
+#define SD_MAXITER 255
+
+static int sdtools_isinepsilon(double x) {
+ return (x >= 0.0 - SD_EPSILON && x <= 0.0 + SD_EPSILON) ? 1 : 0;
+}
+
+static double sdtools_abs( double x) {
+ return (x < 0.0) ? -x : x;
+}
+
+
+/**
+ * \brief calculates the logarithm of x to base y
+ *
+ * calculates the logarithm of x to base y in a simple way without requiring math.h nor libm.
+ *
+ * \attention
+ * this function is not optimised for speed and only usable and accurate for simple usages
+ * like calculating a grey value table or an expontential contrast table. \n
+ * this function cannot calculate logN(0, base) nor a result for x < 1.0 and base < 1.0.
+ * the result will simply be 0 which is incorrect.
+ * (because we don't have NaN of inf because we don't include math.h)
+ *
+ * \param x value
+ * \param base base of logarithm
+ * \return logarithm of x with base y
+ *
+ * \since 1.97.9
+ */
+double sdtools_logN (double x, double base) {
+ double result = 0.0;
+ double term;
+ int n = 0;
+
+ /* safety exit: result is INCORRECT in these cases! */
+ if (sdtools_isinepsilon(x) || (x < 1.0 && base < 1.0))
+ return 0.0;
+
+ /* x < 1 */
+ while (x < 1.0) {
+ result -= 1.0;
+ x *= base;
+ }
+ /* x >= base */
+ while (x >= base) {
+ result += 1.0;
+ x /= base;
+ }
+ /* else: result starts with 0.0 */
+
+ /* start with 1/2 */
+ term = 0.5;
+ x *= x;
+ while (n < SD_MAXITER && term > SD_EPSILON) {
+ if (x >= base) {
+ result += term;
+ x = x / base;
+ }
+ term *= 0.5;
+ x *= x;
+ n++;
+ }
+ return (result);
+}
+
+
+/**
+ * \brief calculates the natural logarithm of x
+ *
+ * calculates the natural logarithm of x in a simple way without requiring math.h nor libm.
+ *
+ * \attention
+ * this function is not optimised for speed and only usable and accurate for simple usages
+ * like calculating a grey value table or an expontential contrast table. \n
+ * this function cannot calculate log(0). the result will simply be 0 which is incorrect.
+ * (because we don't have NaN of inf because we don't include math.h)
+ *
+ * \param x value
+ * \return natural logarithm of x
+ *
+ * \since 1.97.9
+ */
+double sdtools_log(double x) {
+ /* ln(x) = log x to base e */
+ return sdtools_logN(x, 2.7182818284590452354);
+}
+
+
+/**
+ * \brief base-e exponential function
+ *
+ * calculates the value of e raised to the power of x without requiring math.h nor libm.
+ *
+ * \attention
+ * this function is not optimised for speed and only usable and accurate for simple usages
+ * like calculating a grey value table or an expontential contrast table.
+ *
+ * \param x value
+ * \return e raised to the power of x
+ *
+ * \since 1.97.9
+ */
+double sdtools_exp( double x) {
+ /* exp(x) = SUM [ x^n / n! ]; n in [0, infinity] */
+ long double fact=1.0; /* n! */
+ long double xpowi = 1.0; /* x^n */
+ long double term; /* x^n / n! */
+ long double sum = 1.0; /* init. with n=0 => 1.0 */
+ long double iterdiff = 0.0; /* difference between two iterations */
+ long double lastterm=x+2*SD_EPSILON; /* the first value of item will be x => start with x + 2*eps */
+ int n; /* iteration */
+
+ n = 1; /* sum has already been initialised with n=0 -> 1.0 */
+ do {
+ xpowi *= x;
+ fact *= n;
+ term = xpowi / fact;
+ if (n > 10 && iterdiff < sdtools_abs(lastterm - term))
+ return 0.0; /* iterations not converging: result = 0.0 */
+ iterdiff = sdtools_abs(lastterm - term);
+ sum += term;
+ lastterm = term;
+ n++;
+ } while (n < SD_MAXITER && iterdiff >= SD_EPSILON );
+ return (double)sum;
+}
+
+
+/**
+ * \brief power function
+ *
+ * calculates x raised to the power of y without requiring math.h nor libm.
+ *
+ * \attention
+ * this function is not optimised for speed and only usable and accurate for simple usages
+ * like calculating a grey value table or an expontential contrast table.
+ *
+ * \param x value
+ * \param y power
+ * \return x raised to the power of y
+ *
+ * \since 1.97.9
+ */
+double sdtools_pow( double x, double y) {
+ /* pow(x, y) = e^(y * ln(x)) */
+ return (sdtools_isinepsilon(x) ? 0.0 : sdtools_exp( y * sdtools_log(x)) );
+}
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/src/testserdisp.c
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -42,16 +42,18 @@
#include "serdisplib/serdisp.h"
+#include <sys/time.h>
+#if 0
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/time.h>
#else
#include <sys/resource.h>
#endif
-
+#endif
/* version information */
#define TESTSERDISP_VERSION_MAJOR 1
-#define TESTSERDISP_VERSION_MINOR 3
+#define TESTSERDISP_VERSION_MINOR 4
#define TESTSERDISP_VERSION_EXTRA
/*
@@ -85,9 +87,10 @@
int num = number;
- if (num < 0 && num > 999) return;
+ if (num < 0 && num > 9999) return;
- if (num >= 100) digits = 3;
+ if (num >= 1000) digits = 4;
+ else if (num >= 100) digits = 3;
else if (num >= 10) digits = 2;
else digits = 1;
@@ -223,6 +226,60 @@
}
+void draw_gradient(serdisp_t* dd, int type) { /* type: 0: red, 1: green, 2: blue */
+ int w = serdisp_getwidth(dd);
+ int h = serdisp_getheight(dd);
+ int i, j, stdgrad = 0;
+ double cmain, cothers, cotherbase;
+ long colour;
+
+ if (type > 3) {
+ stdgrad = 1;
+ type -= 3;
+ }
+
+ if (type == 0) {
+ for (i = 0; i < w ; i++) {
+ cmain = ( 255.0 / (w-1) ) * i;
+ for (j = 0; j < h; j++) {
+ colour = 0;
+ if (j < h/4)
+ colour = serdisp_pack2ARGB (0xFF, (byte)(cmain+0.5), (byte)(cmain+0.5), (byte)(cmain+0.5));
+ else if (j < h/2)
+ colour = serdisp_pack2ARGB (0xFF, (byte)(cmain+0.5), 0x00, 0x00);
+ else if (j < 3*h/4)
+ colour = serdisp_pack2ARGB (0xFF, 0x00, (byte)(cmain+0.5), 0x00);
+ else
+ colour = serdisp_pack2ARGB (0xFF, 0x00, 0x00, (byte)(cmain+0.5));
+ serdisp_setcolour(dd, i, j, colour);
+ }
+ }
+ } else {
+ for (j = 0; j < h; j++) {
+ cotherbase = ( 255.0 / (h-1) ) * j;
+ for (i = 0; i < w ; i++) {
+ cmain = ( 255.0 / (w-1) ) * i;
+ cothers = (stdgrad) ? ( cotherbase / (w-1) ) * i : cotherbase;
+
+ colour = 0;
+ switch (type) {
+ case 2: /* green */
+ colour = serdisp_pack2ARGB (0xFF, (byte)(cothers+0.5), (byte)(cmain+0.5), (byte)(cothers+0.5));
+ break;
+ case 3: /* blue */
+ colour = serdisp_pack2ARGB (0xFF, (byte)(cothers+0.5), (byte)(cothers+0.5), (byte)(cmain+0.5));
+ break;
+ default: /* red */
+ colour = serdisp_pack2ARGB (0xFF, (byte)(cmain+0.5), (byte)(cothers+0.5), (byte)(cothers+0.5));
+ break;
+ }
+ serdisp_setcolour(dd, i, j, colour);
+ }
+ }
+ }
+}
+
+
void shift_left(serdisp_t* dd, int count) {
int x, y, i;
long temp;
@@ -266,7 +323,7 @@
SERDISP_VERSION_GET_MAJOR(serdisp_getversioncode()),
SERDISP_VERSION_GET_MINOR(serdisp_getversioncode())
);
- fprintf(f, " (C) 2003-2008 by Wolfgang Astleitner\n");
+ fprintf(f, " (C) 2003-2010 by Wolfgang Astleitner\n");
fprintf(f, "\n");
@@ -448,6 +505,9 @@
}
if (SD_CS_ISDIRECTCOLOUR(dd)) {
printf ("rgbtest draw an RGB/CMYK testpattern\n");
+ printf ("gradient draws a colour gradient with four bars W,R,G,B\n");
+ printf ("gradient R|G|B draws a standard colour gradient with given main colour\n");
+ printf ("gradient r|g|b draws a colour gradient (different algorithm)\n");
}
if (serdisp_getoptiondescription(dd, "BACKLIGHT", &optiondesc) && (optiondesc.flag & SD_OPTIONFLAG_RW)) {
printf ("bg [1 | 0 | on | off] switch on/off background light\n");
@@ -564,6 +624,27 @@
printf (" | B | W | Y .. yellow \n");
printf (" ------------------------- K .. black \n\n");
serdisp_update(dd);
+ } else if(strncmp(buffer,"gradient", 8) == 0) {
+ char* idx = strchr(buffer, ' ');
+ char val;
+ int type = 0;
+
+ if (idx)
+ val = idx[1]; /* no out-of-bound check because switch will catch wrong input and default to ' ' */
+ else
+ val = ' ';
+
+ switch (val) {
+ case 'r': type = 1; break;
+ case 'g': type = 2; break;
+ case 'b': type = 3; break;
+ case 'R': type = 4; break;
+ case 'G': type = 5; break;
+ case 'B': type = 6; break;
+ default: type = 0;
+ }
+ draw_gradient(dd, type);
+ serdisp_update(dd);
} else if(strncmp(buffer,"sp", 2) == 0 || strncmp(buffer,"cp", 2) == 0) {
int px, py;
char temp[255];
@@ -602,7 +683,7 @@
px = 0; py = 0;
}
val = (strncmp(buffer, "s", 1) == 0) ? 1 :0;
- printf("pixel at (%d/%d): 0x%08lx\n", px, py, serdisp_getcolour(dd, px, py));
+ printf("pixel at (%d/%d): 0x%08x\n", px, py, (unsigned int)serdisp_getcolour(dd, px, py));
}
} else if(strncmp(buffer,"p", 1) == 0) {
int px, py, pattern;
@@ -910,12 +991,17 @@
diff_sec --;
}
- if (flag_measuretime && sdcd->debug_count) {
- int debug_count = sdcd->debug_count;
+ if (flag_measuretime) {
double time_needed = (double)diff_sec * 1000000.0 + (double)diff_usec;
- double time_per_write = (debug_count) ? (time_needed / (double)debug_count) : 0.0;
- printf("time needed: %2ds %03dms %03dus write() calls: %10d avg. time per write: %6.3fus\n",
- (int)(diff_sec), (int)(diff_usec/1000), (int)(diff_usec%1000), debug_count, time_per_write);
+ if (sdcd->debug_count) {
+ int debug_count = sdcd->debug_count;
+ double time_per_write = (debug_count) ? (time_needed / (double)debug_count) : 0.0;
+ printf("time needed: %2ds %03dms %03dus write() calls: %10d avg. time per write: %6.3fus\n",
+ (int)(diff_sec), (int)(diff_usec/1000), (int)(diff_usec%1000), debug_count, time_per_write);
+ } else {
+ printf("time needed: %2ds %03dms %03dus\n",
+ (int)(diff_sec), (int)(diff_usec/1000), (int)(diff_usec%1000));
+ }
}
}
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/tools/Makefile.in
^
|
@@ -1,5 +1,5 @@
# Makefile for project 'serdisplib', sub-directory tools/
-# (C) 2003-2008 by Wolfgang Astleitner
+# (C) 2003-2010 by Wolfgang Astleitner
VERSION=@PACKAGE_VERSION@
@@ -24,16 +24,15 @@
INSTALL_DATA = @INSTALL_DATA@
#CFLAGS=@CFLAGS@ -ansi -Wall -Wno-implicit -fPIC -I../include -I..
-CFLAGS=@CFLAGS@ -Wall -Wno-implicit -fPIC -I../include -I..
+#CFLAGS=@CFLAGS@ -Wall -Wno-implicit -fPIC -I../include -I..
+CFLAGS=@CFLAGS@ -Wall -fPIC -I../include -I..
LDFLAGS=@LDFLAGS@
-#LIBS=@LIBS@
-# start w/ empty libs-list
-LIBS=
+LIBS=@LIBS@
BINDIR=@bindir@
-OBJECTS= image.o
+OBJECTS=
PROGRAMS=
@@ -47,24 +46,19 @@
# link shared or static lib to executables
ifeq "@use_sharedlib@" "true"
LIB_SERDISP=-L$(LIB_DIR) -l$(LIB_NAME)
+ STATIC_LDFLAGS=
else
LIB_SERDISP=$(LIB_DIR)/$(LIB_STATIC)
-endif
-
-# link programs to shared libs only if libserdisp is linked statically
-ifeq "@has_libusb@" "true"
- ifneq "@use_sharedlib@" "true"
- LIBS+=@LIBUSB_LIBS@
- endif
+ STATIC_LDFLAGS=$(LDFLAGS)
endif
# only compile multidisplay when libgd is available
ifeq "@has_libgd_headers@" "true"
ifeq "@has_libgd_lib@" "true"
- OBJECTS+= multidisplay.o
PROGRAMS += multidisplay
- LIBS += -lgd
+ OBJ_MULTIDISPLAY = image.o multidisplay.o
+ OBJECTS += $(OBJ_MULTIDISPLAY)
# special case sun solaris
ifeq "@has_libgd_opt_sfw_headers@" "true"
@@ -73,6 +67,18 @@
endif
endif
+ifeq "@WITH_DRIVER_L4M@" "true"
+ PROGRAMS += l4m132c_tool
+ OBJ_L4M132C_TOOL = l4m132c_tool.o common.o
+ OBJECTS += $(OBJ_L4M132C_TOOL)
+endif
+
+ifeq "@WITH_DRIVER_ACOOLSDCM@" "true"
+ PROGRAMS += sdcmegtron_tool
+ OBJ_SDCMEGTRON_TOOL = sdcmegtron_tool.o common.o
+ OBJECTS += $(OBJ_SDCMEGTRON_TOOL)
+endif
+
#CFLAGS=-ansi -Wall -Wno-implicit -O2
#CFLAGS=-g -ansi -Wall -Wno-implicit -fPIC -O2 -I../serdisplib -I..
@@ -87,10 +93,16 @@
$(CC) $(CFLAGS) $(DEFINES) -c $(INCLUDES) $<
multidisplay: $(LIB_DIR)/$(LIB_STATIC) $(OBJECTS)
- $(CC) -o multidisplay $(OBJECTS) $(LIB_SERDISP) $(TARGET_LDFLAGS) $(LIBS)
+ $(CC) -o multidisplay $(OBJ_MULTIDISPLAY) $(LIB_SERDISP) $(STATIC_LDFLAGS) $(LIBS)
+
+l4m132c_tool: $(LIB_DIR)/$(LIB_STATIC) $(OBJECTS)
+ $(CC) -o l4m132c_tool $(OBJ_L4M132C_TOOL) $(LIB_SERDISP) $(STATIC_LDFLAGS)
+
+sdcmegtron_tool: $(LIB_DIR)/$(LIB_STATIC) $(OBJECTS)
+ $(CC) -o sdcmegtron_tool $(OBJ_SDCMEGTRON_TOOL) $(LIB_SERDISP) $(STATIC_LDFLAGS)
clean:
- /bin/rm -f $(OBJECTS)
+ /bin/rm -f *.o
/bin/rm -f *core* $(PROGRAMS)
distclean: clean
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/tools/common.c
^
|
@@ -0,0 +1,237 @@
+/** \file common.c
+ *
+ * \brief Common functions for simple tasks
+ * \date (C) 2009
+ * \author wolfgang astleitner (mrwastl@users.sourceforge.net)
+ */
+
+/*
+ *************************************************************************
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+#include "../config.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "common.h"
+#include "serdisplib/serdisp_tools.h"
+
+/* uint16_t, uint32_t, ... */
+#include <inttypes.h>
+
+/**
+ * \brief reads an uncompressed fixed size BMP image into a pre-allocated buffer
+ *
+ * \param bmpfile file name of BMP file to read
+ * \param imgbuffer pre-allocated image buffer (size: ((width/8) * height) * depth)
+ * \param width requested width of image (error if different)
+ * \param height requested height of image (error if different)
+ * \param depth requested depth of image (error if different)
+ *
+ * \retval 0 success
+ * \retval -1 error occurred (error message: sd_geterrormsg())
+ *
+ * \since 1.97.9
+ */
+int common_read_simplebmp(char* bmpfile, byte* imgbuffer, int width, int height, int depth) {
+ byte bmpheader[54]; /* no structure because of alignment and endian problems */
+ byte dummybuffer[8]; /* dummy place for reading alignment row data */
+ FILE* f = NULL;
+ int rc;
+ uint32_t w, h, compr, bpp, offset;
+ int rowsize_aligned = ((depth * width + 31 ) / 32 ) * 4; /* 32-bit dwords */
+ int rowsize = ((depth * width) / 8);
+ int row;
+
+ if ( (f = fopen(bmpfile, "rb")) == NULL) {
+ sd_error(SERDISP_EACCES, "%s(): unable to open file %s", __func__, bmpfile);
+ return -1;
+ }
+
+ /* nota bene: BMP header is little endian! */
+ rc = fread(bmpheader, 1, sizeof(bmpheader), f);
+
+ w = (bmpheader[21]<<24) + (bmpheader[20]<<16) + (bmpheader[19]<<8) + bmpheader[18];
+ h = (bmpheader[25]<<24) + (bmpheader[24]<<16) + (bmpheader[23]<<8) + bmpheader[22];
+ compr = (bmpheader[33]<<24) + (bmpheader[32]<<16) + (bmpheader[31]<<8) + bmpheader[30];
+ bpp = (bmpheader[29]<<8) + bmpheader[28];
+ offset = (bmpheader[13]<<24) + (bmpheader[12]<<16) + (bmpheader[11]<<8) + bmpheader[10];
+
+ if (rc != sizeof(bmpheader) || bmpheader[0] != 0x42 || bmpheader[1] != 0x4d ||
+ /* avoid out of bounds error when dummy reading into imgbuffer */
+ ((offset - sizeof(bmpheader)) > 20) || ( ((int)offset - sizeof(bmpheader)) < 0)
+ ) {
+ sd_error(SERDISP_ERUNTIME, "%s(): no valid BMP file: %s", __func__, bmpfile);
+ fclose(f);
+ return -1;
+ }
+
+
+ if (w != width || h != height || compr != 0 || bpp != depth || depth != 1) {
+ /* only depth == 1 supported at the moment */
+#if 0
+ if (depth == 1)
+#endif
+ sd_error(SERDISP_ERUNTIME,
+ "%s(): format of BMP %s must be: %d/%d, monochrome (1 bits/pixel), uncompressed",
+ __func__, bmpfile, width, height
+ );
+#if 0
+ else
+ sd_error(SERDISP_ERUNTIME,
+ "%s(): format of BMP %s must be: %d/%d, depth %d, uncompressed",
+ __func__, bmpfile, width, height, depth
+ );
+#endif
+ fclose(f);
+ return -1;
+ }
+
+ /* advance to offset of image data (dummy read) */
+ rc = fread(imgbuffer, 1, offset - sizeof(bmpheader), f);
+ if (rc != (offset - sizeof(bmpheader)) ) {
+ sd_error(SERDISP_ERUNTIME, "%s(): corrupt BMP file: %s", __func__, bmpfile);
+ fclose(f);
+ return -1;
+ }
+
+ /* read image data */
+ row = height - 1;
+ while (row >= 0) {
+ int rc2 = 0;
+ rc = fread(&(imgbuffer[row*rowsize]), 1, rowsize, f);
+ if (rc > 0 && rowsize_aligned > rowsize) {
+ rc2 = fread(dummybuffer, 1, rowsize_aligned - rowsize, f);
+ }
+ if ( (rc != rowsize) || (rc2 < 0)) {
+ sd_error(SERDISP_ERUNTIME, "%s(): corrupt BMP file: %s", __func__, bmpfile);
+ fclose(f);
+ return -1;
+ }
+ row --;
+ }
+
+ fclose(f);
+ return 0;
+}
+
+
+/**
+ * \brief writes an uncompressed BMP image to a file
+ *
+ * \param bmpfile file name of BMP file to write
+ * \param imgbuffer image buffer (size: ((width/8) * height) * depth)
+ * \param width width of image
+ * \param height height of image
+ * \param depth depth of image
+ * \param overwrite overwrite existing file (1) or return an error
+ *
+ * \retval 0 success
+ * \retval -1 error occurred (error message: sd_geterrormsg())
+ *
+ * \since 1.97.9
+ */
+int common_write_simplebmp (char* bmpfile, byte* imgbuffer, int width, int height, int depth, int overwrite) {
+ byte bmpheader[54 + (1 << depth)*4]; /* no structure because of alignment and endian problems */
+ byte dummybuffer[8]; /* dummy place for reading alignment row data */
+ FILE* f = NULL;
+ int rc;
+ uint32_t temp;
+ int rowsize_aligned = ((depth * width + 31 ) / 32 ) * 4; /* 32-bit dwords */
+ int rowsize = ((depth * width) / 8);
+ int row;
+
+ memset(bmpheader, 0, sizeof(bmpheader));
+ memset(dummybuffer, 0, sizeof(dummybuffer));
+
+ bmpheader[0] = 0x42; bmpheader[1] = 0x4d; /* magic ID 'BM' */
+ temp = sizeof(bmpheader) + rowsize * height; /* complete file size in bytes */
+ bmpheader[2] = temp & 0x000000FF; bmpheader[3] = (temp & 0x0000FF00) >> 8;
+ bmpheader[4] = (temp & 0x00FF0000) >> 16; bmpheader[5] = (temp & 0xFF000000) >> 24;
+ /* 6 - 9: reserved */
+ temp = sizeof(bmpheader); /* offset from beginning of file to bitmap data */
+ bmpheader[10] = temp & 0x000000FF; bmpheader[11] = (temp & 0x0000FF00) >> 8;
+ bmpheader[12] = (temp & 0x00FF0000) >> 16; bmpheader[13] = (temp & 0xFF000000) >> 24;
+ temp = 0x28; /* length of bitmap info header: 28h for windows BMPs */
+ bmpheader[14] = temp & 0x000000FF; bmpheader[15] = (temp & 0x0000FF00) >> 8;
+ bmpheader[16] = (temp & 0x00FF0000) >> 16; bmpheader[17] = (temp & 0xFF000000) >> 24;
+ temp = width; /* pixel width */
+ bmpheader[18] = temp & 0x000000FF; bmpheader[19] = (temp & 0x0000FF00) >> 8;
+ bmpheader[20] = (temp & 0x00FF0000) >> 16; bmpheader[21] = (temp & 0xFF000000) >> 24;
+ temp = height; /* pixel height */
+ bmpheader[22] = temp & 0x000000FF; bmpheader[23] = (temp & 0x0000FF00) >> 8;
+ bmpheader[24] = (temp & 0x00FF0000) >> 16; bmpheader[25] = (temp & 0xFF000000) >> 24;
+ temp = 1; /* number of planes, must be 1 */
+ bmpheader[26] = temp & 0x000000FF; bmpheader[27] = (temp & 0x0000FF00) >> 8;
+ temp = depth; /* bits per pixel */
+ bmpheader[28] = temp & 0x000000FF; bmpheader[29] = (temp & 0x0000FF00) >> 8;
+ /* 30 - 33: compression typ -> uncompressed = 0 */
+ temp = rowsize * height; /* size of bitmap data */
+ bmpheader[34] = temp & 0x000000FF; bmpheader[35] = (temp & 0x0000FF00) >> 8;
+ bmpheader[36] = (temp & 0x00FF0000) >> 16; bmpheader[37] = (temp & 0xFF000000) >> 24;
+ temp = 0x0B13; /* hor/vert resolution in pixel per meter (whatever this is for ...) */
+ bmpheader[38] = temp & 0x000000FF; bmpheader[39] = (temp & 0x0000FF00) >> 8;
+ bmpheader[40] = (temp & 0x00FF0000) >> 16; bmpheader[41] = (temp & 0xFF000000) >> 24;
+ bmpheader[42] = temp & 0x000000FF; bmpheader[43] = (temp & 0x0000FF00) >> 8;
+ bmpheader[44] = (temp & 0x00FF0000) >> 16; bmpheader[45] = (temp & 0xFF000000) >> 24;
+ temp = (1 << depth); /* number of colours in image */
+ bmpheader[46] = temp & 0x000000FF; bmpheader[47] = (temp & 0x0000FF00) >> 8;
+ bmpheader[48] = (temp & 0x00FF0000) >> 16; bmpheader[49] = (temp & 0xFF000000) >> 24;
+ temp = (1 << depth); /* number of important colours in image */
+ bmpheader[50] = temp & 0x000000FF; bmpheader[51] = (temp & 0x0000FF00) >> 8;
+ bmpheader[52] = (temp & 0x00FF0000) >> 16; bmpheader[53] = (temp & 0xFF000000) >> 24;
+ /* first colour == white */
+ bmpheader[54] = 0xFF; bmpheader[55] = 0xFF; bmpheader[56] = 0xFF; bmpheader[57] = 0x00;
+
+ if (!overwrite) {
+ /* test if file already exists */
+ if ( (f = fopen(bmpfile, "r")) ) {
+ fclose(f);
+ sd_error(SERDISP_EACCES, "%s(): file %s already exists and no permission to overwrite", __func__, bmpfile);
+ return -1;
+ }
+ }
+
+ if ( (f = fopen(bmpfile, "wb")) == NULL) {
+ sd_error(SERDISP_EACCES, "%s(): unable to open file %s", __func__, bmpfile);
+ return -1;
+ }
+
+ rc = fwrite(bmpheader, 1, sizeof(bmpheader), f);
+
+ /* read image data */
+ row = height - 1;
+ while (row >= 0) {
+ int rc2 = 0;
+ rc = fwrite(&(imgbuffer[row*rowsize]), 1, rowsize, f);
+ if (rc > 0 && rowsize_aligned > rowsize) {
+ rc2 = fwrite(dummybuffer, 1, rowsize_aligned - rowsize, f);
+ }
+ if ( (rc != rowsize) || (rc2 < 0)) {
+ sd_error(SERDISP_ERUNTIME, "%s(): error when writing BMP file: %s", __func__, bmpfile);
+ fclose(f);
+ return -1;
+ }
+ row --;
+ }
+
+ fclose(f);
+ return 0;
+}
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/tools/common.h
^
|
@@ -0,0 +1,68 @@
+/** \file common.h
+ *
+ * \brief Common functions for simple tasks
+ * \date (C) 2009
+ * \author wolfgang astleitner (mrwastl@users.sourceforge.net)
+ */
+
+/*
+ *************************************************************************
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+/** \addtogroup SERDISP_TOOLS_COMMON
+
+ \section INTRODUCTION Introduction
+ Functions for simple tasks (eg: reading and writing uncompressed BMPs)
+
+ * @{
+ */
+
+#ifndef SERDISP_TOOLS_COMMON_H
+#define SERDISP_TOOLS_COMMON_H
+
+#include "serdisplib/serdisp_control.h"
+#include "serdisplib/serdisp_messages.h"
+
+
+/* define 'byte' if not available yet */
+#ifndef byte
+ #define byte unsigned char
+#endif
+
+#ifndef BOOL
+ #define BOOL int
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/** \name BMP functions
+ */
+/*!@{*/
+ int common_read_simplebmp (char* bmpfile, byte* imgbuffer, int width, int height, int depth);
+ int common_write_simplebmp (char* bmpfile, byte* imgbuffer, int width, int height, int depth, int overwrite);
+/*!@}*/
+#ifdef __cplusplus
+ }
+#endif
+
+
+#endif /* SERDISP_TOOLS_COMMON_H */
+/*! @} */
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/tools/image.c
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2006 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -37,8 +37,15 @@
#include <strings.h>
#include "image.h"
+#include "serdisplib/serdisp_colour.h"
#include "serdisplib/serdisp_tools.h"
+/* internal typedef and functions */
+static int sdtim_readGLCDheader (FILE* fin, int* width, int* height, int* frames, long* delay);
+static gdImagePtr sdtim_readGLCDnextframe (FILE* fin, int width, int height);
+static void dithergrey(serdisp_t* dd, gdImagePtr im_in, gdImagePtr im_out, int colours, int sx, int sy, int w, int h);
+static int getGreyValue(gdImagePtr im, int x, int y);
+
/* *********************************
sdt_image_t* sdtim_readGLCDheader (fin)
@@ -53,24 +60,24 @@
int rv;
int hdrsize = 1*4 + 2*2;
byte buffer[hdrsize];
-
+
rv = fread( buffer, 1, hdrsize, fin);
-
+
if (rv < hdrsize) {
- sd_error(SERDISP_ERUNTIME, "sdt_createfromGLCD(): invalid image (%d bytes read but at least %d required)", rv, hdrsize);
+ sd_error(SERDISP_ERUNTIME, "%s(): invalid image (%d bytes read but at least %d required)", __func__, rv, hdrsize);
return 0;
}
-
+
if (strncmp((const char*)buffer, "GLC", sizeof(char)*3) != 0 ) {
- sd_error(SERDISP_ERUNTIME, "sdt_createfromGLCD(): unable to find image signature");
+ sd_error(SERDISP_ERUNTIME, "%s(): unable to find image signature", __func__);
return 0;
}
-
+
*width = (buffer[5]<<8) + buffer[4];
*height = (buffer[7]<<8) + buffer[6];
-
+
*delay = 250;
-
+
switch(buffer[3]) {
case 'D': /* single image */
*frames = 1;
@@ -78,18 +85,18 @@
case 'A': /* animated image */
hdrsize = 2 + 4;
rv = fread(buffer, 1, hdrsize, fin);
-
+
if (rv < hdrsize) {
- sd_error(SERDISP_ERUNTIME, "sdt_createfromGLCD(): invalid image (rv < hdrsize)");
+ sd_error(SERDISP_ERUNTIME, "%s(): invalid image (rv < hdrsize)", __func__);
return 0;
}
-
+
*frames = (buffer[1]<<8) + buffer[0];
*delay = (buffer[5]<<24) + (buffer[4]<<16) + (buffer[3]<<8) + buffer[2];
-
+
break;
default:
- sd_error(SERDISP_ERUNTIME, "sdt_createfromGLCD(): invalid image (signature GLCD or GLCA not found)");
+ sd_error(SERDISP_ERUNTIME, "%s(): invalid image (signature GLCD or GLCA not found)", __func__);
return 0;
}
@@ -105,15 +112,15 @@
int rv, x, y;
gdImagePtr im = 0;
int black, white;
-
+
if (! (buffer = (byte*)sdtools_malloc( height * ((width + 7)/8)) ) ) {
- sd_error(SERDISP_EMALLOC, "sdtim_readGLCDnextframe(): cannot allocate memory for buffer");
+ sd_error(SERDISP_EMALLOC, "%s(): cannot allocate memory for buffer", __func__);
return 0;
}
memset(buffer, 0, height * ((width + 7)/8));
rv = fread ( buffer, height * ((width + 7)/8), 1, fin);
-
+
im = gdImageCreate(width, height);
black = gdImageColorAllocate(im, 0,0,0);
white = gdImageColorAllocate(im, 255,255,255);
@@ -124,7 +131,7 @@
}
}
free(buffer);
- return im;
+ return im;
}
@@ -145,14 +152,18 @@
for (y = 0; y < h; y++) {
xslop = (7 * range) / 32;
dslop = range / 32;
-
+
for (x = 0; x < w; x++) {
i = getGreyValue(im_in, x+sx, y+sy);
i += xslop + yslop[x];
j = (i / t) *q;
if (j > range) j = range;
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ j = serdisp_lookupsdgrey(dd, serdisp_transsdgrey(dd, j));
+#else
j = serdisp_lookupgrey(dd, serdisp_transgrey(dd, j));
+#endif
gdImageSetPixel(im_out, x+sx, y+sy, gdImageColorClosest(im_out, j, j, j));
i = i - j; /* error i - j */
@@ -168,13 +179,6 @@
}
-
-
-
-
-
-
-
sdtim_frame_t* sdtim_loadimage (char* imagefile, int* frames, serdisp_t* dd, gdImagePtr template, int scalealgo, int flag_truecolour, int flag_dither) {
sdtim_frame_t* firstframe = 0;
sdtim_frame_t* prevframe = 0;
@@ -190,13 +194,13 @@
int aspect_w, aspect_h;
double fact_w = 1.0, fact_h = 1.0, fact;
-
+
int flag_imagetype = 0; /* 0: gd-processed image, 1: glcd */
int f;
fin = fopen(imagefile, "rb");
if (!fin) {
- sd_error(SERDISP_ERUNTIME, "sdtim_loadimage(): image file %s cannot be opened", imagefile);
+ sd_error(SERDISP_ERUNTIME, "%s(): image file %s cannot be opened", __func__, imagefile);
return 0;
}
@@ -227,8 +231,6 @@
sd_debug(2, "pixelaspect: %d%%\n", serdisp_getpixelaspect(dd));
-
-
/* 100 * w * ph w, h: amount of pixels
f = ------------- pw, ph: display area (normalised: px == 100)
h * pw f: pixel aspect ratio in percent
@@ -267,8 +269,7 @@
start_y = ( scaled_h < serdisp_getheight(dd) ) ? ((serdisp_getheight(dd) - scaled_h) >> 1) : 0;
break;
case 1:
- case 2:
-
+ case 2:
sd_debug(2, "sd_w: %d, sd_h: %d, asp_w: %d, asp_h: %d; fact_w: %f; fact_h: %f; fact: %f\n", serdisp_getwidth(dd), serdisp_getheight(dd), aspect_w, aspect_h, fact_w, fact_h, fact);
@@ -279,8 +280,6 @@
scaled_w = (int)( ((double)(orig_w) / fact) * ( (double)(serdisp_getwidth(dd)) / (double)aspect_w) );
scaled_h = (int)( ((double)(orig_h) / fact) * ( (double)(serdisp_getheight(dd)) / (double)aspect_h) );
-
-
/* clip potential rounding errors */
if (scaled_w > serdisp_getwidth(dd)) scaled_w = serdisp_getwidth(dd);
if (scaled_h > serdisp_getheight(dd)) scaled_h = serdisp_getheight(dd);
@@ -308,25 +307,24 @@
f = 0;
while (valid && (f < *frames)) {
sdtim_frame_t* currframe;
-
+
if (! (currframe = (sdtim_frame_t*)sdtools_malloc( sizeof(sdtim_frame_t)) ) ) {
sd_error(SERDISP_EMALLOC, "sdtim_loadimage(): cannot allocate another frame descriptor");
valid = 0;
break;
}
memset(currframe, 0, sizeof(sdtim_frame_t));
-
+
if (prevframe)
prevframe->next = currframe;
else
firstframe = currframe;
-
if (flag_truecolour)
currframe->image = gdImageCreateTrueColor(serdisp_getwidth(dd), serdisp_getheight(dd));
else {
currframe->image = gdImageCreate(serdisp_getwidth(dd), serdisp_getheight(dd));
- gdImagePaletteCopy(currframe->image, template);
+ gdImagePaletteCopy(currframe->image, template);
}
/* copy background filling from template */
gdImageCopy(
@@ -336,7 +334,6 @@
gdImageSX(currframe->image), gdImageSY(currframe->image)
);
-
currframe->delay = currdelay;
if (flag_imagetype == 0) { /* gd-processed single image */
@@ -359,7 +356,7 @@
scaled_w, scaled_h,
gdImageSX(im_frame), gdImageSY(im_frame)
);
-
+
gdImageDestroy(im_frame);
}
@@ -384,13 +381,16 @@
for (j = 0; j < gdImageSY(im_scaled); j++)
for (i = 0; i < gdImageSX(im_scaled); i++) {
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ grey = serdisp_lookupsdgrey(dd, serdisp_transsdgrey(dd, getGreyValue(im_scaled, i, j)));
+#else
grey = serdisp_lookupgrey(dd, serdisp_transgrey(dd, getGreyValue(im_scaled, i, j)));
+#endif
gdImageSetPixel(currframe->image, i, j, gdImageColorClosest(currframe->image, grey, grey, grey));
}
}
}
-
if (!flag_truecolour) {
int i;
sd_debug(2, "frame[%d] (picture): w/h: %d/%d totalcolours: %d\n", f, gdImageSX(currframe->image), gdImageSY(currframe->image), gdImageColorsTotal(currframe->image));
@@ -401,7 +401,6 @@
prevframe = currframe;
f++;
-
} /* while f */
gdImageDestroy(im_scaled);
@@ -424,3 +423,10 @@
}
+/* grey = .3 * r + .59 * g + .11 * b */
+/* enhancement: use (77*r + 150*g + 28*b) / 255 for better accuracy (thanks to michael reinelt for pointing this out)*/
+int getGreyValue(gdImagePtr im, int x, int y) {
+ int c = gdImageGetPixel(im, x, y);
+
+ return ( (77 * gdImageRed(im, c) + 150 * gdImageGreen(im, c) + 28 * gdImageBlue(im, c)) / 255);
+}
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/tools/image.h
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2006 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -32,7 +32,14 @@
#ifndef SERDISP_TOOLS_IMAGE_H
#define SERDISP_TOOLS_IMAGE_H
-#ifdef HAVE_GD_GD_H
+#ifdef HAVE_GD2_GD_H
+ #include "gd2/gd.h"
+ #include "gd2/gdfontt.h"
+ #include "gd2/gdfonts.h"
+ #include "gd2/gdfontmb.h"
+ #include "gd2/gdfontl.h"
+ #include "gd2/gdfontg.h"
+#elif defined(HAVE_GD_GD_H)
#include "gd/gd.h"
#include "gd/gdfontt.h"
#include "gd/gdfonts.h"
@@ -69,18 +76,14 @@
} sdtim_frame_t;
-
-
#ifdef __cplusplus
extern "C" {
#endif
sdtim_frame_t* sdtim_loadimage (char* imagefile, int* frames, serdisp_t* dd, gdImagePtr template, int scalealgo, int flag_truecolour, int flag_dither);
-
+
#ifdef __cplusplus
}
#endif
-
-
#endif /* SERDISP_TOOLS_IMAGE_H */
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/tools/l4m132c_tool.c
^
|
@@ -0,0 +1,348 @@
+/*
+ *************************************************************************
+ *
+ * l4m132c_tool.c
+ * tool for linux4media l4m132c display modules
+ *
+ *************************************************************************
+ *
+ * copyright (C) 2009-2010 wolfgang astleitner
+ * email mrwastl@users.sourceforge.net
+ *
+ *************************************************************************
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+#include "../config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+#if defined(__linux__)
+#include <getopt.h>
+#endif
+
+#include "common.h"
+#include "serdisplib/serdisp.h"
+
+/* uint16_t, uint32_t, ... */
+#include <inttypes.h>
+
+/* version information */
+#define L4M132CTOOL_VERSION_MAJOR 1
+#define L4M132CTOOL_VERSION_MINOR 0
+
+
+/* usage, help, ...
+ iserr: -1 ... print version information only
+ 0 ... print help/usage to stdout
+ 1 ... print error message + help/usage to stderr
+*/
+void print_usage(int iserr) {
+ FILE* f = (iserr > 0) ? stderr : stdout;
+
+ fprintf(f, " l4m132c_tool version %d.%d (using serdisplib version %d.%d)\n",
+ L4M132CTOOL_VERSION_MAJOR, L4M132CTOOL_VERSION_MINOR,
+ SERDISP_VERSION_GET_MAJOR(serdisp_getversioncode()),
+ SERDISP_VERSION_GET_MINOR(serdisp_getversioncode())
+ );
+ fprintf(f, " (C) 2009-2010 by Wolfgang Astleitner\n");
+
+ fprintf(f, "\n");
+
+ if (iserr == -1) return;
+
+ fprintf(f, "Usage: l4m132c_tool [<options>]\n\n");
+ fprintf(f, " Options: (default values in squared brackets)\n");
+ fprintf(f, " -p dev|port output device or port\n");
+ fprintf(f, " -t set date/time to local date/time\n");
+ fprintf(f, " -c value [5] contrast / brightness; value=[0, 10]\n");
+ fprintf(f, " -a \"HH:MM\" set alarm time\n");
+ fprintf(f, " -d \"%%6543210\" set alarm days (bit field, to be entered as hexadecimal or decimal)\n");
+ fprintf(f, " bit 6: saturday bit 5: friday\n");
+ fprintf(f, " bit 4: thursday bit 3: wednesday\n");
+ fprintf(f, " bit 2: tuesday bit 1: monday\n");
+ fprintf(f, " bit 0: sunday\n");
+ fprintf(f, " examples:\n");
+ fprintf(f, " -d 0x7F: %%1111111 -> all days\n");
+ fprintf(f, " -d 0x41: %%1000001 -> saturday and sunday\n");
+ fprintf(f, " -d 0: de-activate alarm\n");
+ fprintf(f, " -f imagefile change bootlogo (only uncompressed BMP with depth=1 and 128x64 are accepted)\n");
+ fprintf(f, " -v verbose (-v repeated: <= 2: log to syslog, >= 3: log to stderr, >= 5: log to stdout)\n");
+ fprintf(f, " -V version information\n");
+ fprintf(f, " \n");
+ fprintf(f, " Examples: \n");
+ fprintf(f, " l4m132c_tool -p \"/dev/hiddev0\" # show bootlogo\n");
+ fprintf(f, " l4m132c_tool -p \"/dev/hiddev0\" -t # set date/time\n");
+ fprintf(f, " l4m132c_tool -p \"/dev/hiddev0\" -f bootlogo.bmp # change bootlogo\n");
+ fprintf(f, " l4m132c_tool -p \"/dev/hiddev0\" -a \"23:30\" -d 0x7F # set alarm at 23:30, all days\n");
+ fprintf(f, " \n");
+}
+
+
+
+int main(int argc, char **argv) {
+ int ch;
+ char sdcdev[51] = "";
+
+ char* bootlogofile = (char*)0;
+
+ char optionstring[101] = "";
+
+ int flag_settime = 0;
+ int flag_alarmtime = 0;
+ int flag_alarmdays = 0;
+ int flag_setbootlogo = 0;
+ int flag_showbootlogo = 0;
+
+ int contrast = 5;
+
+ unsigned short alarm_days = 0;
+ unsigned char alarm_hour = 0;
+ unsigned char alarm_minute = 0;
+
+ int tmp_debuglevel = 0;
+
+ extern char *optarg;
+ extern int optind;
+ char* optstring = "p:ta:c:d:f:vVh";
+
+ byte imgbuffer[(128/8)*64];
+
+ serdisp_CONN_t* sdcd;
+ serdisp_t* dd = 0;
+
+ sd_setdebuglevel(SD_LVL_WARN);
+
+ while ((ch = getopt(argc, argv, optstring)) != -1) {
+ switch(ch) {
+ case 'h':
+ print_usage(0);
+ exit(0);
+ case 'p':
+ sdtools_strncpy(sdcdev, optarg, 50);
+ break;
+ case 't':
+ flag_settime = 1;
+ break;
+ case 'c':
+ {
+ char* tempptr;
+ int isvalidnumber = 0;
+
+ flag_settime = 1;
+ if (strncasecmp(optarg, "0x", 2) == 0) {
+ contrast = (int)strtol(optarg, &tempptr, 16);
+ } else {
+ contrast = (int)strtol(optarg, &tempptr, 10);
+ }
+
+ /* verify if optvalueptr contained a valid number */
+ isvalidnumber = ( (optarg == tempptr) || ( (*tempptr != '\0') ) ) ? 0 : 1;
+
+ if (!isvalidnumber || contrast < 0 || contrast > 10) {
+ fprintf(stderr, "Error: Invalid value for option -c: %s\n", optarg);
+ exit (1);
+ }
+ }
+ break;
+ case 'f':
+ {
+ int rc;
+
+ bootlogofile = (char*)sdtools_malloc(strlen(optarg)+2);
+ sdtools_strncpy(bootlogofile, optarg, strlen(optarg));
+ flag_setbootlogo = 1;
+ rc = common_read_simplebmp(bootlogofile, imgbuffer, 128, 64, 1);
+
+ if (rc != 0) {
+ fprintf(stderr, "Error: %s\n", sd_geterrormsg());
+ exit (1);
+ }
+ }
+ break;
+ case 'a':
+ {
+ char* tempptr;
+ long value;
+ int isvalidnumber;
+
+ flag_alarmtime = 1;
+
+ value = strtol(optarg, &tempptr, 10);
+
+ /* verify if optvalueptr contained a valid number */
+ isvalidnumber = /*( (optarg == tempptr) || (*/ (*tempptr != ':') /*) ) */ ? 0 : 1;
+
+ if (isvalidnumber) {
+ char* optarg_shift = tempptr+1;
+
+ alarm_hour = (unsigned char) value;
+
+ value = strtol(optarg_shift, &tempptr, 10);
+
+ /* verify if optvalueptr contained a valid number */
+ isvalidnumber = ( (optarg_shift == tempptr) || ( (*tempptr != '\0')) ) ? 0 : 1;
+ if (isvalidnumber) {
+ alarm_minute = (unsigned char) value;
+ }
+ }
+
+ if (!isvalidnumber) {
+ fprintf(stderr, "Error: Invalid value for option -a: %s\n", optarg);
+ exit (1);
+ }
+ }
+ break;
+ case 'd':
+ {
+ char* tempptr;
+ long value;
+ int isvalidnumber;
+
+ flag_alarmdays = 1;
+
+ if ( (strlen(optarg) == 3) && ( ( strncasecmp(optarg, "off", 3) == 0) || (strncasecmp(optarg, "all", 3) == 0) ) ) {
+ value = ( strncasecmp(optarg, "off", 3) == 0) ? 0 : 0x7F;
+ } else {
+ /* accept base 10 and base 16 values (base 16 if value starts with 0x or 0X) */
+ if (strncasecmp(optarg, "0x", 2) == 0) {
+ value = strtol(optarg, &tempptr, 16);
+ } else {
+ value = strtol(optarg, &tempptr, 10);
+ }
+
+ /* verify if optvalueptr contained a valid number */
+ isvalidnumber = ( (optarg == tempptr) || ( (*tempptr != '\0') ) ) ? 0 : 1;
+
+ if (!isvalidnumber) {
+ fprintf(stderr, "Error: Invalid value for option -d: %s\n", optarg);
+ exit (1);
+ }
+ }
+
+ alarm_days = (unsigned short) value;
+
+ /* if -d 0 (deactive alarm): no -a required */
+ if (alarm_days == 0) {
+ flag_alarmtime = 1;
+ }
+ }
+ break;
+ case 'v':
+ tmp_debuglevel++;
+ break;
+ case 'V':
+ print_usage(-1);
+ exit(0);
+ break;
+ }
+ }
+
+
+ if (tmp_debuglevel) {
+ if (tmp_debuglevel > 6) tmp_debuglevel = 6;
+ sd_setlogmedium( (tmp_debuglevel <= 2) ? SD_LOG_SYSLOG : ((tmp_debuglevel <= 4) ? SD_LOG_STDERR : SD_LOG_STDOUT));
+ if (tmp_debuglevel > 2) sd_setdebuglevel( (tmp_debuglevel % 2) ? 1 : 2);
+ else sd_setdebuglevel(tmp_debuglevel);
+ }
+
+ if (strlen(sdcdev) == 0) {
+ fprintf(stderr, "Error: -p devicename is missing (eg.: -p /dev/hiddev0)\n");
+ exit (1);
+ }
+
+ if (flag_setbootlogo && (flag_alarmtime || flag_alarmdays || flag_settime)) {
+ fprintf(stderr, "Error: Changing boot logo (-f) and setting alarm or time/date (-a, -d, -s) may not be used altogether\n");
+ exit (1);
+ }
+
+ /* if no flag given: show bootlogo */
+ if (! (flag_setbootlogo || flag_alarmtime || flag_alarmdays || flag_settime) ) {
+ flag_showbootlogo = 1;
+ }
+
+ if (flag_alarmdays ^ flag_alarmtime) {
+ fprintf(stderr, "Error: Both -a and -d are required for setting alarm\n");
+ exit (1);
+ }
+
+ if (alarm_hour > 23 || alarm_minute > 59 || alarm_days > 0x7f) {
+ fprintf(stderr, "Error: Alarm time or bit field for alarm days out of bounds\n");
+ exit (1);
+ }
+
+ sdcd = SDCONN_open(sdcdev);
+
+ if (sdcd == (serdisp_CONN_t*)0) {
+ fprintf(stderr, "Error: Unable to open %s, additional info: %s\n", sdcdev, sd_geterrormsg());
+ exit (1);
+ }
+
+ if (flag_settime || flag_alarmtime) {
+ snprintf(optionstring, 99, "POSTOFFMODE=1;ALARMHOUR=%02d;ALARMMINUTE=%02d;ALARMDAYS=0x%02x;RESMODE=1;CONTRAST=%d",alarm_hour, alarm_minute, alarm_days,contrast);
+ sd_debug(1, "optionstring: %s", optionstring);
+ } else if (flag_setbootlogo || flag_showbootlogo) {
+ snprintf(optionstring, 99, "RESMODE=1");
+ sd_debug(1, "optionstring: %s", optionstring);
+ }
+
+
+ dd = serdisp_init(sdcd, "L4M132C", optionstring);
+
+ if (!dd) {
+ fprintf(stderr, "Error: Unable to open L4M132C, additional info: %s\n", sd_geterrormsg());
+ exit(1);
+ }
+
+ if (flag_setbootlogo) {
+ int y, x, cols = 128/8;
+ byte data;
+ for (y = 0; y < dd->height; y++) {
+ uint32_t addr = 0x3400 + y*cols;
+ SDCONN_write(dd->sdcd, 0x21, 0);
+ SDCONN_write(dd->sdcd, (byte)((addr & 0xFF00)>>8), 0);
+ SDCONN_write(dd->sdcd, (byte)(addr & 0xFF), 0);
+ SDCONN_write(dd->sdcd, cols, 0);
+
+ for (x = 0; x < cols; x++) {
+ data = imgbuffer[y*cols + x];
+ SDCONN_write(dd->sdcd, data, 0);
+ }
+
+ SDCONN_commit(dd->sdcd);
+ }
+ }
+
+ if (flag_setbootlogo || flag_showbootlogo) {
+ SDCONN_write(dd->sdcd, 0x03, 0);
+ SDCONN_commit(dd->sdcd);
+ serdisp_close(dd);
+ } else {
+ serdisp_quit(dd);
+ }
+ return 0;
+}
+
|
[-]
[+]
|
Changed |
serdisplib-1.97.9.tar.bz2/tools/multidisplay.c
^
|
@@ -6,7 +6,7 @@
*
*************************************************************************
*
- * copyright (C) 2003-2008 wolfgang astleitner
+ * copyright (C) 2003-2010 wolfgang astleitner
* email mrwastl@users.sourceforge.net
*
*************************************************************************
@@ -39,7 +39,14 @@
#include <strings.h>
#include <unistd.h>
-#ifdef HAVE_GD_GD_H
+#ifdef HAVE_GD2_GD_H
+ #include "gd2/gd.h"
+ #include "gd2/gdfontt.h"
+ #include "gd2/gdfonts.h"
+ #include "gd2/gdfontmb.h"
+ #include "gd2/gdfontl.h"
+ #include "gd2/gdfontg.h"
+#elif defined(HAVE_GD_GD_H)
#include "gd/gd.h"
#include "gd/gdfontt.h"
#include "gd/gdfonts.h"
@@ -78,16 +85,6 @@
#define WHITE (colours-1)
#define BLACK (0)
-/* grey = .3 * r + .59 * g + .11 * b */
-/* enhancement: use (77*r + 150*g + 28*b) / 255 for better accuracy (thanks to michael reinelt for pointing this out)*/
-int getGreyValue(gdImagePtr im, int x, int y) {
- int c = gdImageGetPixel(im, x, y);
-
- return ( (77 * gdImageRed(im, c) + 150 * gdImageGreen(im, c) + 28 * gdImageBlue(im, c)) / 255);
-}
-
-
-
void drawstring(gdImagePtr im, gdFontPtr gdfont, int fgcolour, int bgcolour, int x, int y, unsigned char* str, int outline) {
/* int colours = gdImageColorsTotal(im);*/
@@ -135,7 +132,7 @@
SERDISP_VERSION_GET_MAJOR(serdisp_getversioncode()),
SERDISP_VERSION_GET_MINOR(serdisp_getversioncode())
);
- fprintf(f, " (C) 2003-2008 by Wolfgang Astleitner\n");
+ fprintf(f, " (C) 2003-2010 by Wolfgang Astleitner\n");
fprintf(f, "\n");
@@ -709,7 +706,11 @@
for (j = 0; j < gdImageSY(im); j++)
for (i = 0; i < gdImageSX(im); i++) {
c = gdImageGetPixel(im, i, j);
+#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
+ serdisp_setsdcol(dd, i, j, serdisp_pack2ARGB(0xFF, gdImageRed(im, c), gdImageGreen(im, c), gdImageBlue(im, c)));
+#else
serdisp_setcolour(dd, i, j, serdisp_pack2ARGB(0xFF, gdImageRed(im, c), gdImageGreen(im, c), gdImageBlue(im, c)));
+#endif
}
|
[-]
[+]
|
Added |
serdisplib-1.97.9.tar.bz2/tools/sdcmegtron_tool.c
^
|
@@ -0,0 +1,327 @@
+/*
+ *************************************************************************
+ *
+ * sdcmegtron_tool.c
+ * tool for SDC Megtron display modules
+ *
+ *************************************************************************
+ *
+ * copyright (C) 2009-2010 wolfgang astleitner
+ * email mrwastl@users.sourceforge.net
+ *
+ *************************************************************************
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA. Or, point your browser to
+ * http://www.gnu.org/copyleft/gpl.html
+ *************************************************************************
+ */
+
+#include "../config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+#if defined(__linux__)
+#include <getopt.h>
+#endif
+
+#include "common.h"
+#include "serdisplib/serdisp.h"
+#include "serdisplib/serdisp_connect_usb.h"
+
+#include "serdisplib/serdisp_fctptr.h"
+
+/* uint16_t, uint32_t, ... */
+#include <inttypes.h>
+
+/* version information */
+#define SDCMEGTRONTOOL_VERSION_MAJOR 1
+#define SDCMEGTRONTOOL_VERSION_MINOR 0
+
+/* default device */
+#define SDCMEGTRON_DEFAULTDEVICE "USB:152a/8380"
+
+#define USB_LCDAPI_REQUEST 0xA0
+#define USB_LCDCMD_READ_GFX 0x1D /* get the current GFX screen (3840 byte) */
+#define USB_LCDCMD_STOREBOOTLOGO 0x2B /* store/internaly transfer the current screen as startup image to flash */
+#define USB_LCDCMD_DRAWBOOTLOGO 0x2C /* draw stored image from flash to screen */
+#define USB_LCDCMD_READBOOTLOGO 0x2D /* read startup image data from flash (3840 byte) */
+#define USB_LCDCMD_RESET 0x10 /* reset module (also USB!) */
+
+
+/* usage, help, ...
+ iserr: -1 ... print version information only
+ 0 ... print help/usage to stdout
+ 1 ... print error message + help/usage to stderr
+*/
+void print_usage(int iserr) {
+ FILE* f = (iserr > 0) ? stderr : stdout;
+
+ fprintf(f, " sdcmegtron_tool version %d.%d (using serdisplib version %d.%d)\n",
+ SDCMEGTRONTOOL_VERSION_MAJOR, SDCMEGTRONTOOL_VERSION_MINOR,
+ SERDISP_VERSION_GET_MAJOR(serdisp_getversioncode()),
+ SERDISP_VERSION_GET_MINOR(serdisp_getversioncode())
+ );
+ fprintf(f, " (C) 2009-2010 by Wolfgang Astleitner\n");
+
+ fprintf(f, "\n");
+
+ if (iserr == -1) return;
+
+ fprintf(f, "Usage: sdcmegtron_tool [<options>]\n\n");
+ fprintf(f, " Options: (default values in squared brackets)\n");
+ fprintf(f, " -p dev output device (if not given: %s)\n", SDCMEGTRON_DEFAULTDEVICE);
+ fprintf(f, " -b brightness [255] brightness of background light, 0: turn off, value=[0, 255]\n");
+ fprintf(f, " -f imagefile change bootlogo (only uncompressed BMP with depth=1 and 240x128 are accepted)\n");
+ fprintf(f, " -l imagefile save current bootlogo\n");
+ fprintf(f, " -s imagefile save screenshot of current display content\n");
+ fprintf(f, " -y overwrite existing files (valid for options -l and -s)\n");
+ fprintf(f, " -r reset the display module\n");
+ fprintf(f, " -v verbose (-v repeated: <= 2: log to syslog, >= 3: log to stderr, >= 5: log to stdout)\n");
+ fprintf(f, " -V version information\n");
+ fprintf(f, " \n");
+ fprintf(f, " Examples: \n");
+ fprintf(f, " sdcmegtron_tool # show bootlogo using default device\n");
+ fprintf(f, " sdcmegtron_tool -p \"%s\" # show bootlogo\n", SDCMEGTRON_DEFAULTDEVICE);
+ fprintf(f, " sdcmegtron_tool -b 50 # show bootlogo and set background light to 50\n");
+ fprintf(f, " sdcmegtron_tool -f bootlogo.bmp # change bootlogo\n");
+ fprintf(f, " sdcmegtron_tool -l bootlogo.bmp # save current bootlogo, error if file already exists\n");
+ fprintf(f, " sdcmegtron_tool -y -l bootlogo.bmp # save current bootlogo, overwrite existing file\n");
+ fprintf(f, " sdcmegtron_tool -s screenshot.bmp # save screenshot, error if file already exists\n");
+ fprintf(f, " sdcmegtron_tool -y -s screenshot.bmp # save screenshot, overwrite existing file\n");
+ fprintf(f, " \n");
+}
+
+
+
+int main(int argc, char **argv) {
+ int ch;
+ char sdcdev[51] = "";
+
+ char* imagefile = (char*)0;
+
+ char optionstring[101] = "";
+
+ int flag_setbootlogo = 0;
+ int flag_showbootlogo = 0;
+ int flag_getbootlogo = 0;
+ int flag_getscreenshot = 0;
+ int flag_resetmodule = 0;
+ int flag_overwrite = 0;
+
+ int bglevel = 255;
+
+ int tmp_debuglevel = 0;
+
+ extern char *optarg;
+ extern int optind;
+ char* optstring = "p:b:f:l:s:yrvVh";
+
+ byte imgbuffer[(240/8)*128];
+
+ serdisp_CONN_t* sdcd;
+ serdisp_t* dd = 0;
+ serdisp_usbdev_t* usbitems = 0;
+
+ sd_setdebuglevel(SD_LVL_WARN);
+
+ while ((ch = getopt(argc, argv, optstring)) != -1) {
+ switch(ch) {
+ case 'h':
+ print_usage(0);
+ exit(0);
+ case 'p':
+ sdtools_strncpy(sdcdev, optarg, 50);
+ break;
+ case 'b':
+ {
+ char* tempptr;
+ int isvalidnumber = 0;
+
+ if (strncasecmp(optarg, "0x", 2) == 0) {
+ bglevel = (int)strtol(optarg, &tempptr, 16);
+ } else {
+ bglevel = (int)strtol(optarg, &tempptr, 10);
+ }
+
+ /* verify if optvalueptr contained a valid number */
+ isvalidnumber = ( (optarg == tempptr) || ( (*tempptr != '\0') ) ) ? 0 : 1;
+
+ if (!isvalidnumber || bglevel < 0 || bglevel > 255) {
+ fprintf(stderr, "Error: Invalid value for option -b: %s\n", optarg);
+ exit (1);
+ }
+ }
+ break;
+ case 'f':
+ {
+ imagefile = (char*)sdtools_malloc(strlen(optarg)+2);
+ sdtools_strncpy(imagefile, optarg, strlen(optarg));
+ flag_setbootlogo = 1;
+ }
+ break;
+ case 'l':
+ case 's':
+ {
+ if (imagefile) {
+ free(imagefile);
+ fprintf(stderr, "Error: Options -f, -l, and -s may not be combined\n");
+ exit (1);
+ }
+
+ imagefile = (char*)sdtools_malloc(strlen(optarg)+2);
+ sdtools_strncpy(imagefile, optarg, strlen(optarg));
+ if (ch == 'l')
+ flag_getbootlogo = 1;
+ else
+ flag_getscreenshot = 1;
+ }
+ break;
+ case 'y':
+ flag_overwrite = 1;
+ break;
+ case 'r':
+ flag_resetmodule = 1;
+ break;
+ case 'v':
+ tmp_debuglevel++;
+ break;
+ case 'V':
+ print_usage(-1);
+ exit(0);
+ break;
+ }
+ }
+
+
+ if (tmp_debuglevel) {
+ if (tmp_debuglevel > 6) tmp_debuglevel = 6;
+ sd_setlogmedium( (tmp_debuglevel <= 2) ? SD_LOG_SYSLOG : ((tmp_debuglevel <= 4) ? SD_LOG_STDERR : SD_LOG_STDOUT));
+ if (tmp_debuglevel > 2) sd_setdebuglevel( (tmp_debuglevel % 2) ? 1 : 2);
+ else sd_setdebuglevel(tmp_debuglevel);
+ }
+
+ if (strlen(sdcdev) == 0) {
+ sdtools_strncpy(sdcdev, SDCMEGTRON_DEFAULTDEVICE, 50);
+ }
+
+ if (flag_resetmodule && (flag_setbootlogo || flag_getbootlogo || flag_getscreenshot)) {
+ fprintf(stderr, "Error: Option -r (reset) may not be combined with bootlogo or screenshot operations\n");
+ if (imagefile) free(imagefile);
+ exit (1);
+ }
+
+ /* if no flag given: show bootlogo */
+ if (! (flag_setbootlogo || flag_setbootlogo || flag_getbootlogo || flag_getscreenshot) ) {
+ flag_showbootlogo = 1;
+ }
+
+ sdcd = SDCONN_open(sdcdev);
+
+ if (sdcd == (serdisp_CONN_t*)0) {
+ fprintf(stderr, "Error: Unable to open %s, additional info: %s\n", sdcdev, sd_geterrormsg());
+ exit (1);
+ }
+
+ if ( ! SDFCTPTR_checkavail(SDFCTPTR_LIBUSB) ) {
+ sd_error(SERDISP_ERUNTIME, "%s(): libusb is not loaded.", __func__);
+ exit (1);
+ }
+
+ snprintf(optionstring, 99, "BGLEVEL=%d",bglevel);
+ sd_debug(1, "optionstring: %s", optionstring);
+
+
+ dd = serdisp_init(sdcd, "SDCMEGTRON", optionstring);
+
+ if (!dd) {
+ fprintf(stderr, "Error: Unable to open SDCMEGTRON, additional info: %s\n", sd_geterrormsg());
+ exit(1);
+ }
+
+ usbitems = (serdisp_usbdev_t *)(dd->sdcd->extra);
+
+ if (flag_setbootlogo) {
+ int rc = common_read_simplebmp(imagefile, imgbuffer, 240, 128, 1);
+ if (rc != 0) {
+ fprintf(stderr, "Error: %s\n", sd_geterrormsg());
+ free(imagefile);
+ exit (1);
+ }
+
+ memcpy(dd->scrbuf, imgbuffer, sizeof(imgbuffer));
+ serdisp_rewrite(dd);
+
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, 1,
+ USB_LCDCMD_STOREBOOTLOGO, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'USB_LCDCMD_STOREBOOTLOGO' failed", __func__);
+ free(imagefile);
+ return -1;
+ }
+ }
+
+ if (flag_resetmodule) {
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, 1,
+ USB_LCDCMD_RESET, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'USB_LCDCMD_RESET' failed", __func__);
+ free(imagefile);
+ return -1;
+ }
+ free(imagefile);
+ serdisp_close(dd);
+ return 0;
+ }
+
+
+ if (flag_getbootlogo || flag_getscreenshot) {
+ int rc;
+ int usb_cmd = (flag_getbootlogo) ? USB_LCDCMD_READBOOTLOGO : USB_LCDCMD_READ_GFX;
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR|USB_ENDPOINT_IN, USB_LCDAPI_REQUEST, 0,
+ usb_cmd, (char*)imgbuffer, sizeof(imgbuffer) , usbitems->read_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request '%s' failed",
+ __func__, ((flag_getbootlogo) ? "USB_LCDCMD_READBOOTLOGO" : "USB_LCDCMD_READ_GFX")
+ );
+ free(imagefile);
+ return -1;
+ }
+ rc = common_write_simplebmp (imagefile, imgbuffer, 240, 128, 1, flag_overwrite);
+ if (rc != 0) {
+ fprintf(stderr, "Error: %s\n", sd_geterrormsg());
+ free(imagefile);
+ return -1;
+ }
+ }
+
+ if (flag_setbootlogo || flag_showbootlogo || flag_getbootlogo || flag_getscreenshot) {
+ if(fp_usb_control_msg(usbitems->usb_dev, USB_TYPE_VENDOR, USB_LCDAPI_REQUEST, 1,
+ USB_LCDCMD_DRAWBOOTLOGO, NULL, 0, usbitems->write_timeout) < 0) {
+ sd_error(SERDISP_ERUNTIME, "%s(): request 'USB_LCDCMD_DRAWBOOTLOGO' failed", __func__);
+ free(imagefile);
+ return -1;
+ }
+ serdisp_close(dd);
+ } else {
+ serdisp_quit(dd);
+ }
+ return 0;
+}
+
|