common/lcd.h

00001 /*
00002  * Copyright Ian Burnett 2005, 2006.
00003  *
00004  * This file is part of Ian's Interactive LCD controller (IILC).
00005  * 
00006  * IILC is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU General Public License as published by the Free
00008  * Software Foundation; either version 2 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * IILC is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00014  * for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with IILC; if not, write to the Free Software Foundation, Inc.,
00018  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
00019  */
00020 
00021 #if !defined(__LCD_H__)
00022 #define __LCD_H__
00023 
00024 /*
00025  * Drag in some common headers
00026  */
00027 
00028 #include <stdio.h>
00029 #include <stdlib.h>
00030 
00031 #if defined(_WIN32)
00032 #   define WIN32_LEAN_AND_MEAN
00033 #   include <windows.h>
00034 #   include "pthread_w32.h"
00035 #else
00036 #   include <unistd.h>
00037 #   include <pthread.h>
00038 #endif
00039 
00040 /*
00041  * Setup some common useful DLL linkage macros
00042  */
00043 
00044 #if defined(_WIN32)
00045 #   if defined(__cplusplus)
00046 #       define LCD_API extern "C" _declspec(dllexport)
00047 #   else
00048 #       define LCD_API _declspec(dllexport)
00049 #   endif
00050 #else
00051 #   if defined(__cplusplus)
00052 #       define LCD_API extern "C"
00053 #   else
00054 #       define LCD_API
00055 #   endif
00056 #endif
00057 
00058 /*
00059  * Our typedefs
00060  */
00061 
00062 /****************************************************************************
00063  *                                                                          *
00064  *                                                                          *
00065  *                                                                          *
00066  ****************************************************************************/
00067 
00068 
00069 typedef struct _tag_colour
00070 {
00071     unsigned char red;
00072     unsigned char green;
00073     unsigned char blue;
00074 
00075 } COLOUR, * LPCOLOUR;
00076 
00077 #define SET_COLOUR(c,r,g,b) c->red = (r); c->green = (g); c->blue = (b);
00078 
00079 
00080 /*
00081  * Useful way of suspending a process for a given number of milliseconds
00082  */
00083 
00084 #if defined(_WIN32)
00085 #   define SLEEP(x) Sleep(x)
00086 #else
00087 #   define SLEEP(x) usleep((x) * 1000)
00088 #endif
00089 
00090 
00091 
00092 #define IILC_ASSERT(x) if (!(x)) { \
00093     printf("Assertion '%s' failed in file %s:%d\n", #x, __FILE__, __LINE__); \
00094     abort(); }
00095 
00096 
00097 #define ERR_MEM_ALLOC_FAILED                        0x01
00098 #define ERR_MEM_FREE_FAILED                         0x02
00099 #define ERR_END_OF_PACKET                           0x03
00100 #define ERR_PACKET_FULL                             0x04
00101 #define ERR_BAD_PARAMETER                           0x05
00102 #define ERR_INVALID_DEVICE                          0x06
00103 #define ERR_INSUFFICIENT_DATA                       0x07
00104 #define ERR_BUFFER_TOO_SMALL                        0x08
00105 #define ERR_INVALID_CONFIG                          0x09
00106 #define ERR_OBJECT_NOT_FOUND                        0x0A
00107 #define ERR_NOT_IMPLEMENTED                         0x0B
00108 #define ERR_MUTEX_LOCK_FAILED                       0x0C
00109 #define ERR_MUTEX_UNLOCK_FAILED                     0x0D
00110 
00111 
00112 
00113 #endif /* __LCD_H__ */

Generated on Mon Jul 17 01:36:11 2006 for IILC by  doxygen 1.4.6