DISCLAIMER:
THIS IS EXPERIMENTAL SOFTWARE AND HARDWARE. USE AT YOUR OWN RISK. THE MAINTAINER(S) OF THESE PAGES AND THE DEVELOPER(S) OF SOFTWARE AND HARDWARE PRESENTED ON THESE PAGES CAN NOT BE HELD LIABLE UNDER ANY CIRCUMSTANCES FOR DAMAGE TO HARDWARE OR SOFTWARE, LOST DATA, OR OTHER DIRECT OR INDIRECT DAMAGE RESULTING FROM THE USE OF THIS SOFTWARE OR HARDWARE. IF YOU DO NOT AGREE TO THESE CONDITIONS, YOU ARE NOT PERMITTED TO USE OR FURTHER DISTRIBUTE THIS SOFTWARE OR TO USE ANY TEMPLATES FOR BUILDING HARDWARE PRESENTED HERE.
int
filehandles a structure ppd
(parallel port descriptor) is now used.serdisp_init()
now has an extra parameter that will be used in the future.
serdisp_parport.h
, PP_open()
, PP_close()
and PP_write()
where replaced through
serdisp_connect.h
, SDCONN_open()
, SDCONN_close()
and SDCONN_write()
serdisp_PP_t
was renamed to serdisp_CONN_t
serdisp_parport.h
is still existing and contains defines
that resemble the old names (but it is highly recommended to only use serdisp_connect.h)serdisp_quit()
should be used
for shutting down the output device (no more SDCONN_close(dd->sdcd);
)serdisp_getSDCONN()
should be used (but please NOT dd->sdcd
any more)OPTREX323
PCD8544
NOKIA7110
SED1565
ERICSSONT2X
or E///T2X
serdisp_connect.h
offers some functions for opening and closing output devices using a descriptor ('sdcd'
)./dev/parport0
).pros and cons:
+ not restricted to root-only (users qualified for eg. /dev/parport0 may control a display connected to it)
+ universal (usable with more unix-derivats)
- slower than direct I/O
+ faster
- root-only
- i386-compliant architectures only (*bsd-support planned)
either the functions provided by serdisp_connect.h
may be used or any other (non-serdisplib) function / code / ... that is returning either
a file handle which may be controlled using ioctl
-calls or direct I/O using outp
-calls.
to be able to use such a file handle together with serdisplib it has to to be imported using SDCONN_import_PP()
(only parallel port supported for now).
serdisp_CONN_t* SDCONN_open (const char sdcdev[]) opens a device for serdisplib sdcdev ...device name or port-number of device to open. format: protocol:device if no protocol given: defaulting to parport protocol is case insensitive! examples: /dev/parport0 (linux, ioctl) 0x378 (linux, direct IO) /dev/ppi0 (freebsd, ioctl) serraw:/dev/ttyS0 (serial device, ioctl, should be os-indepentend (POSIX)) SERRAW:/dev/ttyS0 (the same as above) SERPORT:/dev/ttyS0 (the same because SERPORT and SERRAW are aliases) serraw:0x3f8 (serial device, direct IO) parport:/dev/parport0 (linux, ioctl) returns a serdisp connect descriptor or (serdisp_CONN_t*)0 if operation was unsuccessful
void SDCONN_close (serdisp_CONN_t* sdcd) close the device occupied by serdisp sdcd ... serdisp connect descriptor
serdisp_CONN_t* SDCONN_import_PP (int directIO, int hport) import an existing, already opened parport device / port and create a sdcd struct out of it directIO ... 1: yes -> outp-calls, 0: no -> ioctl-calls hport ... if directIO: port (eg: 0x378), else: descriptor for parport dev returns a serdisp connect descriptor or (serdisp_CONN_t*)0 if operation was unsuccessful USE WITH CARE!!! all permissions and stuff like that must be ok before!! no checking for validity in here
NOTA BENE: only these functions should be used. no descriptor fields or internal functions should be accessed directly as these are subject to change.
serdisp_t* serdisp_init (serdisp_CONN_t* ppd, const char dispname[], const char extra[]) initialises a display. all capabilities and basic values are set sdcd ... output device handle dispname ... display name (supported displays: look at section supported displays) extra ... extra settings (will be used in the future. eg. for wiring or other non-standard settings) returns a display descriptorExample:
serdisp_t* dd; dd = serdisp_init(sdcd, "PCD8544", "");
void serdisp_close (serdisp_t* dd) close display but do NOT clear / switch off display. output device remains opened this function may for example be used for programs that want to output something and than exit, but without clearing the display (for this, SDCONN_close() shouldn't either be called) ATTENTION: this will NOT work as expected with serial port and ioctl (TxD will be set to low in any case -> so display will be w/o power) so the only solution would be a separate power supply when using ioctl but: directIO works as expected (TxD will NOT be reset after program exit) this is an operating system specific behaviour and canNOT be influenced (as it seems) dd ... display descriptor
void serdisp_quit (serdisp_t* dd) clear / switch off display and release output device dd ... display descriptor
int serdisp_reset (serdisp_t* dd) resets the displays (clears runtime_error flag , closes and reopens device) ATTENTION: will not work if device was imported using SDCONN_import_PP() dd ... display descriptor returns 1 if reset was successful or 0 if not
int serdisp_getwidth (serdisp_t* dd) get width of display dd ... display descriptor returns width of display
int serdisp_getheight (serdisp_t* dd) get height of display dd ... display descriptor returns height of display
int serdisp_getcolours (serdisp_t* dd) get amount of colours supported by display dd ... display descriptor returns the amount of supported colours
void serdisp_feature (serdisp_t* dd, int feature, int value) change a display feature dd ... display descriptor feature ... feature to change: FEATURE_CONTRAST .. change display contrast (value: 0-MAX_CONTRASTSTEP) FEATURE_BACKLIGHT .. 0: off, 1: on, 2: toggle FEATURE_REVERSE .. 0: normal display, 1: reversed display, 2: toggle FEATURE_ROTATE .. 0: normal, 1: bottom-up value ... value for option (see above)Examples:
serdisp_feature(dd, FEATURE_BACKLIGHT, FEATURE_TOGGLE); serdisp_feature(dd, CONTRAST, 5);
void serdisp_clearbuffer (serdisp_t* dd) resets the internal display-buffer that is used by serdisplib display will NOT be redrawn! dd ... display descriptor
void serdisp_clear (serdisp_t* dd) clear whole display dd ... display descriptor
void serdisp_update (serdisp_t* dd) update whole display dd ... display descriptor
void serdisp_rewrite (serdisp_t* dd) rewrite whole display dd ... display descriptor
void serdisp_blink (serdisp_t* dd, int what, int cnt, int delta) blink the display dd ... display descriptor what ... 0: blinking using backlight, 1: blinking using display reversing cnt ... how often should there be blinking delta ... delay between two blinking intervals
void serdisp_setpixel (serdisp_t* dd, int x, int y, int colour) changes a pixel in the display buffer dd ... display descriptor x ... x-position y ... y-position colour ... monochrome: 0: clear (white), <>0: set (black); else: up to 16m colours (dependend on display)
void serdisp_setpixels (serdisp_t* dd, int x, int y, int w, int h, byte* data) changes an area in the display buffer dd ... display descriptor x ... x-position top/left y ... y-position top/left w ... width of content h ... height of content data ... pixel/colour data (if display supports <= 256 colours: one byte == one pixel else: four byte == one pixel (this may change in the future) )example:
byte* data = .....; /* fill pixel/colour-data into 'data' .... .... /* draw a 5x5 area starting at position 5/10 */ serdisp_setpixels(dd, 5, 10, 5, 5, data);
int serdisp_getpixel (serdisp_t* dd, int x, int y) get colour of pixel at (x/y) dd ... display descriptor x ... x-position y ... y-position
serdisp_CONN_t* serdisp_getSDCONN (serdisp_t* dd) get serdisp connect descriptor used by the display dd ... display descriptor returns serdisp connect descriptor
fprintf()
for reporting debugging information, errors and warnings, instead of this, syslog is now used./var/log/messages
(or /var/adm/messages
depending on operating system used) may contain useful informations.
message and error handling is defined in serdisp_messages.h
:
int sd_runtime_error ()
returns 1 if a runtime error has occured
(display drawing is stopped after a runtime error and may be reset using serdisp_reset()
)
char* sd_geterrormsg () if an action was unsuccessful this function will return error information
SERDISP_VERSION_MAJOR
andSERDISP_VERSION_MINOR
contain major and minor version information for serdisplibSERDISP_VERSION_EXTRA
may be used for patched versions but will NOT be evaluated
serdisplib version codeexample:SERDISP_VERSION_CODE
is calculated using SERDISP_VERSION_MAJOR and SERDISP_VERSION_MINOR.SERDISP_VERSION_CODE(a,b)
calculates a valid serdisplib version code. together withSERDISP_VERSION(a,b)
SERDISP_VERSION_CODE
may be used for asserts
/* only include code if serdisplib is at least version 1.93 */ #if (SERDISP_VERSION_CODE >= SERDISP_VERSION(1,93)) ... #endif
#include <stdio.h> #include <stdlib.h> #include "serdisplib/serdisp_connect.h" #include "serdisplib/serdisp_control.h" #include "serdisplib/serdisp_messages.h" int main(int argc, char **argv) { char sdcdev[] = "/dev/parport0"; /* use parallel port */ /*char sdcdev[] = "serport:/dev/ttyS0";*/ /* use serial port */ char dispname[] = "PCD8544"; /* display name */ serdisp_CONN_t* sdcd; serdisp_t* dd = 0; int i; /* opening the output device */ sdcd = SDCONN_open(sdcdev); if (sdcd == (serdisp_CONN_t*)0) { fprintf(stderr, "Error opening %s, additional info: %s\n", sdcdev, sd_geterrormsg()); exit (1); } /* opening and initialising the display */ dd = serdisp_init(sdcd, dispname, ""); if (!dd) { SDCONN_close(sdcd); fprintf(stderr, "Error opening display %s, additional info: %s\n", dispname, sd_geterrormsg()); exit(1); } /* turning on backlight */ serdisp_feature(dd, FEATURE_BACKLIGHT, FEATURE_YES); /* clearing the display */ serdisp_clear(dd); /* draw a border (only internal display buffer is affected!!) */ for (i = 0; i < serdisp_getwidth(dd); i++) { serdisp_setpixel(dd, i, 0, 1); serdisp_setpixel(dd, i, serdisp_getheight(dd)-1, 1); } for (i = 1; i < serdisp_getheight(dd)-1; i++) { serdisp_setpixel(dd, 0, i, 1); serdisp_setpixel(dd, serdisp_getwidth(dd)-1, i, 1); } /* commit changes -> update the display using the internal display buffer */ serdisp_update(dd); /* wait 30 seconds */ sleep(30); /* shutdown display and release device*/ serdisp_quit(dd); return(0); }
open display, draw something, and exit without clearing display:
/* initialising, a.s.o.: see example above */ ... /* draw something */ ... /* release display without switching it off / clearing it */ serdisp_close(dd); exit(0);