Driver for 4D Systems LCD screen with Picaso processor. Ported from 4D Systems Picaso Serial Linux Library

Dependencies:   MODSERIAL

Dependents:   Lab4_Demo_Game 4180_Final_Project

Fork of uLCD_4D_Picaso by Andrew McRae

Revision:
2:ebe7029e2825
Parent:
1:1e8da43647e9
Child:
4:30010dda3b34
diff -r 1e8da43647e9 -r ebe7029e2825 uLCD_4D_Picaso.cpp
--- a/uLCD_4D_Picaso.cpp	Fri Mar 06 00:50:49 2015 +0000
+++ b/uLCD_4D_Picaso.cpp	Tue Mar 10 16:05:28 2015 +0000
@@ -13,8 +13,7 @@
 #include <math.h>
 #include <ctype.h>
 
-#include "Picaso_Types4D.h"		// defines data types used by the 4D Routines
-#include "Picaso_const4D.h"		// defines for 4dgl constants, generated by conversion of 4DGL constants to target language
+#include "Picaso_enums.h"
 #include "uLCD_4D_Picaso.h"
 
 //Error types
@@ -86,8 +85,8 @@
     return;
 }
 
-void uLCD_4D_Picaso::WriteWords(WORD * Source, int Size) {
- 	WORD wk ;
+void uLCD_4D_Picaso::WriteWords(uint16_t * Source, int Size) {
+ 	uint16_t wk ;
 	int i ;
 	for (i = 0; i < Size; i++)
 	{
@@ -143,7 +142,7 @@
 }
 
 
-WORD uLCD_4D_Picaso::GetWord(void) {
+uint16_t uLCD_4D_Picaso::GetWord(void) {
  	char readx[2];
     getbytes(readx, 2);
 	return readx[0] << 8 | readx[1];
@@ -158,12 +157,12 @@
 	return;
 }
 
-WORD uLCD_4D_Picaso::GetAckResp(void) {
+uint16_t uLCD_4D_Picaso::GetAckResp(void) {
 	GetAck();
 	return GetWord();
 }
 
-WORD uLCD_4D_Picaso::WaitForAck(void) {
+uint16_t uLCD_4D_Picaso::WaitForAck(void) {
     int saveTimeout = TimeLimit4D;
 
     // check once per minute
@@ -178,7 +177,7 @@
     return GetWord();
 }
 
-WORD uLCD_4D_Picaso::GetAckRes2Words(WORD * word1, WORD * word2) {
+uint16_t uLCD_4D_Picaso::GetAckRes2Words(uint16_t * word1, uint16_t * word2) {
 	int Result;
 	GetAck();
 	Result = GetWord();
@@ -187,13 +186,13 @@
 	return Result;
 }
 
-void uLCD_4D_Picaso::GetAck2Words(WORD * word1, WORD * word2) {
+void uLCD_4D_Picaso::GetAck2Words(uint16_t * word1, uint16_t * word2) {
 	GetAck();
 	*word1 = GetWord();
 	*word2 = GetWord();
 }
 
-WORD uLCD_4D_Picaso::GetAckResSector(t4DSector Sector) {
+uint16_t uLCD_4D_Picaso::GetAckResSector(char* Sector) {
 	int Result;
 	GetAck();
 	Result = GetWord();
@@ -201,7 +200,7 @@
 	return Result;
 }
 
-WORD uLCD_4D_Picaso::GetAckResStr(char * OutStr) {
+uint16_t uLCD_4D_Picaso::GetAckResStr(char * OutStr) {
 	int Result;
 	GetAck();
 	Result = GetWord();
@@ -209,7 +208,7 @@
 	return Result;
 }
 
-WORD uLCD_4D_Picaso::GetAckResData(t4DByteArray OutData, WORD size) {
+uint16_t uLCD_4D_Picaso::GetAckResData(char* OutData, uint16_t size) {
 	int Result;
 	GetAck();
 	Result = GetWord();
@@ -218,30 +217,30 @@
 }
 
 
-void uLCD_4D_Picaso::SetThisBaudrate(uLCD_4D_Picaso::BaudRate Newrate) {
+void uLCD_4D_Picaso::SetThisBaudrate(Picaso::BaudRate Newrate) {
     int nBaud;
 
     switch (Newrate) {
-	    case     BAUD_110:       nBaud =    110; break;
-	    case     BAUD_300:       nBaud =    300; break;
-	    case     BAUD_600:       nBaud =    600; break;
-	    case    BAUD_1200:       nBaud =   1200; break;
-	    case    BAUD_2400:       nBaud =   2400; break;
-	    case    BAUD_4800:       nBaud =   4800; break;
-	    case    BAUD_9600:       nBaud =   9600; break;
-	    case   BAUD_14400:       nBaud =  14400; break;
-	    case   BAUD_19200:       nBaud =  19200; break;
-	    case   BAUD_31250:       nBaud =  31250; break;
-	    case   BAUD_38400:       nBaud =  38400; break;
-	    case   BAUD_56000:       nBaud =  56000; break;
-	    case   BAUD_57600:       nBaud =  57600; break;
-	    case  BAUD_115200:       nBaud = 115200; break;
-	    case  BAUD_128000:       nBaud = 133929; break;
-	    case  BAUD_256000:       nBaud = 281250; break;
-	    case  BAUD_300000:       nBaud = 312500; break;
-	    case  BAUD_375000:       nBaud = 401786; break;
-	    case  BAUD_500000:       nBaud = 562500; break;
-	    case  BAUD_600000:       nBaud = 703125; break;
+	    case     Picaso::BAUD_110:       nBaud =    110; break;
+	    case     Picaso::BAUD_300:       nBaud =    300; break;
+	    case     Picaso::BAUD_600:       nBaud =    600; break;
+	    case    Picaso::BAUD_1200:       nBaud =   1200; break;
+	    case    Picaso::BAUD_2400:       nBaud =   2400; break;
+	    case    Picaso::BAUD_4800:       nBaud =   4800; break;
+	    case    Picaso::BAUD_9600:       nBaud =   9600; break;
+	    case   Picaso::BAUD_14400:       nBaud =  14400; break;
+	    case   Picaso::BAUD_19200:       nBaud =  19200; break;
+	    case   Picaso::BAUD_31250:       nBaud =  31250; break;
+	    case   Picaso::BAUD_38400:       nBaud =  38400; break;
+	    case   Picaso::BAUD_56000:       nBaud =  56000; break;
+	    case   Picaso::BAUD_57600:       nBaud =  57600; break;
+	    case  Picaso::BAUD_115200:       nBaud = 115200; break;
+	    case  Picaso::BAUD_128000:       nBaud = 133929; break;
+	    case  Picaso::BAUD_256000:       nBaud = 281250; break;
+	    case  Picaso::BAUD_300000:       nBaud = 312500; break;
+	    case  Picaso::BAUD_375000:       nBaud = 401786; break;
+	    case  Picaso::BAUD_500000:       nBaud = 562500; break;
+	    case  Picaso::BAUD_600000:       nBaud = 703125; break;
 
 	    default:
 	    	nBaud = 9600 ;
@@ -267,7 +266,7 @@
  * Starts of 4D Compound Routines
 */
 
-WORD uLCD_4D_Picaso::bus_In()
+uint16_t uLCD_4D_Picaso::bus_In()
 {
   char  towrite[2] ;
 
@@ -277,7 +276,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::bus_Out(WORD  Bits)
+void uLCD_4D_Picaso::bus_Out(uint16_t  Bits)
 {
   char  towrite[4] ;
 
@@ -289,7 +288,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::bus_Read()
+uint16_t uLCD_4D_Picaso::bus_Read()
 {
   char  towrite[2] ;
 
@@ -299,7 +298,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::bus_Set(WORD  IOMap)
+void uLCD_4D_Picaso::bus_Set(uint16_t  IOMap)
 {
   char  towrite[4] ;
 
@@ -311,7 +310,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::bus_Write(WORD  Bits)
+void uLCD_4D_Picaso::bus_Write(uint16_t  Bits)
 {
   char  towrite[4] ;
 
@@ -323,7 +322,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::charheight(char  TestChar)
+uint16_t uLCD_4D_Picaso::charheight(char  TestChar)
 {
   char  towrite[3] ;
 
@@ -334,7 +333,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::charwidth(char  TestChar)
+uint16_t uLCD_4D_Picaso::charwidth(char  TestChar)
 {
   char  towrite[3] ;
 
@@ -345,7 +344,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Close(WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_Close(uint16_t  Handle)
 {
   char  towrite[4] ;
 
@@ -357,7 +356,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Count(char*  Filename)
+uint16_t uLCD_4D_Picaso::file_Count(char*  Filename)
 {
   char  towrite[2] ;
 
@@ -368,7 +367,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Dir(char*  Filename)
+uint16_t uLCD_4D_Picaso::file_Dir(char*  Filename)
 {
   char  towrite[2] ;
 
@@ -379,7 +378,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Erase(char*  Filename)
+uint16_t uLCD_4D_Picaso::file_Erase(char*  Filename)
 {
   char  towrite[2] ;
 
@@ -390,17 +389,17 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Error()
+Picaso::FileError uLCD_4D_Picaso::file_Error()
 {
   char  towrite[2] ;
 
   towrite[0]= F_file_Error >> 8 ;
   towrite[1]= F_file_Error & 0xFF;
-  WriteBytes(towrite, 2) ;
-  return GetAckResp() ;
+  WriteBytes(towrite, 2);
+  return (Picaso::FileError) GetAckResp();
 }
 
-WORD uLCD_4D_Picaso::file_Exec(char*  Filename, WORD  ArgCount, t4DWordArray  Args)
+uint16_t uLCD_4D_Picaso::file_Exec(char*  Filename, uint16_t  ArgCount, uint16_t*  Args)
 {
   char  towrite[2] ;
 
@@ -415,7 +414,7 @@
   return WaitForAck() ;
 }
 
-WORD uLCD_4D_Picaso::file_Exists(char*  Filename)
+uint16_t uLCD_4D_Picaso::file_Exists(char*  Filename)
 {
   char  towrite[2] ;
 
@@ -426,7 +425,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_FindFirst(char*  Filename)
+uint16_t uLCD_4D_Picaso::file_FindFirst(char*  Filename)
 {
   char  towrite[2] ;
 
@@ -437,7 +436,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_FindNext()
+uint16_t uLCD_4D_Picaso::file_FindNext()
 {
   char  towrite[2] ;
   towrite[0]= F_file_FindNext >> 8 ;
@@ -446,7 +445,7 @@
   return GetAckResp() ;
 }
 
-char uLCD_4D_Picaso::file_GetC(WORD  Handle)
+char uLCD_4D_Picaso::file_GetC(uint16_t  Handle)
 {
   char  towrite[4] ;
   towrite[0]= F_file_GetC >> 8 ;
@@ -457,7 +456,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_GetS(char*  StringIn, WORD  Size, WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_GetS(char*  StringIn, uint16_t  Size, uint16_t  Handle)
 {
   char  towrite[6] ;
   towrite[0]= F_file_GetS >> 8 ;
@@ -470,7 +469,7 @@
   return GetAckResStr(StringIn) ;
 }
 
-WORD uLCD_4D_Picaso::file_GetW(WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_GetW(uint16_t  Handle)
 {
   char  towrite[4] ;
   towrite[0]= F_file_GetW >> 8 ;
@@ -481,7 +480,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Image(WORD  X, WORD  Y, WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_Image(uint16_t  X, uint16_t  Y, uint16_t  Handle)
 {
   char  towrite[8] ;
   towrite[0]= F_file_Image >> 8 ;
@@ -496,7 +495,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Index(WORD  Handle, WORD  HiSize, WORD  LoSize, WORD  Recordnum)
+uint16_t uLCD_4D_Picaso::file_Index(uint16_t  Handle, uint16_t  HiSize, uint16_t  LoSize, uint16_t  Recordnum)
 {
   char  towrite[10] ;
   towrite[0]= F_file_Index >> 8 ;
@@ -513,7 +512,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_LoadFunction(char*  Filename)
+uint16_t uLCD_4D_Picaso::file_LoadFunction(char*  Filename)
 {
   char  towrite[2] ;
   towrite[0]= F_file_LoadFunction >> 8 ;
@@ -523,7 +522,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_LoadImageControl(char*  Datname, char*  GCIName, WORD  Mode)
+uint16_t uLCD_4D_Picaso::file_LoadImageControl(char*  Datname, char*  GCIName, uint16_t  Mode)
 {
   char  towrite[2] ;
   towrite[0]= F_file_LoadImageControl >> 8 ;
@@ -537,7 +536,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Mount()
+uint16_t uLCD_4D_Picaso::file_Mount()
 {
   char  towrite[2] ;
   towrite[0]= F_file_Mount >> 8 ;
@@ -546,7 +545,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Open(char*  Filename, char  Mode)
+uint16_t uLCD_4D_Picaso::file_Open(char*  Filename, char  Mode)
 {
   char  towrite[2] ;
   towrite[0]= F_file_Open >> 8 ;
@@ -558,7 +557,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_PlayWAV(char*  Filename)
+uint16_t uLCD_4D_Picaso::file_PlayWAV(char*  Filename)
 {
   char  towrite[2] ;
   towrite[0]= F_file_PlayWAV >> 8 ;
@@ -568,7 +567,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_PutC(char Character, WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_PutC(char Character, uint16_t  Handle)
 {
   char  towrite[5] ;
   towrite[0]= F_file_PutC >> 8 ;
@@ -580,7 +579,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_PutS(char *  StringOut, WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_PutS(char *  StringOut, uint16_t  Handle)
 {
   char  towrite[2] ;
   towrite[0]= F_file_PutS >> 8 ;
@@ -593,7 +592,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_PutW(WORD  Word, WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_PutW(uint16_t  Word, uint16_t  Handle)
 {
   char  towrite[6] ;
   towrite[0]= F_file_PutW >> 8 ;
@@ -606,7 +605,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Read(t4DByteArray  Data, WORD  Size, WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_Read(char*  Data, uint16_t  Size, uint16_t  Handle)
 {
   char  towrite[6] ;
   towrite[0]= F_file_Read >> 8 ;
@@ -619,7 +618,7 @@
   return GetAckResData(Data,Size) ;
 }
 
-WORD uLCD_4D_Picaso::file_Rewind(WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_Rewind(uint16_t  Handle)
 {
   char  towrite[4] ;
   towrite[0]= F_file_Rewind >> 8 ;
@@ -630,7 +629,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Run(char *  Filename, WORD  ArgCount, t4DWordArray  Args)
+uint16_t uLCD_4D_Picaso::file_Run(char *  Filename, uint16_t  ArgCount, uint16_t*  Args)
 {
   char  towrite[2] ;
   towrite[0]= F_file_Run >> 8 ;
@@ -644,7 +643,7 @@
   return WaitForAck() ;
 }
 
-WORD uLCD_4D_Picaso::file_ScreenCapture(WORD  X, WORD  Y, WORD  Width, WORD  Height, WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_ScreenCapture(uint16_t  X, uint16_t  Y, uint16_t  Width, uint16_t  Height, uint16_t  Handle)
 {
   char  towrite[12] ;
   towrite[0]= F_file_ScreenCapture >> 8 ;
@@ -663,7 +662,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Seek(WORD  Handle, WORD  HiWord, WORD  LoWord)
+uint16_t uLCD_4D_Picaso::file_Seek(uint16_t  Handle, uint16_t  HiWord, uint16_t  LoWord)
 {
   char  towrite[8] ;
   towrite[0]= F_file_Seek >> 8 ;
@@ -678,7 +677,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_Size(WORD  Handle, WORD *  HiWord, WORD *  LoWord)
+uint16_t uLCD_4D_Picaso::file_Size(uint16_t  Handle, uint16_t *  HiWord, uint16_t *  LoWord)
 {
   char  towrite[4] ;
   towrite[0]= F_file_Size >> 8 ;
@@ -689,7 +688,7 @@
   return GetAckRes2Words(HiWord,LoWord) ;
 }
 
-WORD uLCD_4D_Picaso::file_Tell(WORD  Handle, WORD *  HiWord, WORD *  LoWord)
+uint16_t uLCD_4D_Picaso::file_Tell(uint16_t  Handle, uint16_t *  HiWord, uint16_t *  LoWord)
 {
   char  towrite[4] ;
   towrite[0]= F_file_Tell >> 8 ;
@@ -710,7 +709,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::file_Write(WORD  Size, t4DByteArray  Source, WORD  Handle)
+uint16_t uLCD_4D_Picaso::file_Write(uint16_t  Size, char*  Source, uint16_t  Handle)
 {
   char  towrite[4] ;
   towrite[0]= F_file_Write >> 8 ;
@@ -725,7 +724,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_BevelShadow(WORD  Value)
+uint16_t uLCD_4D_Picaso::gfx_BevelShadow(uint16_t  Value)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_BevelShadow >> 8 ;
@@ -736,7 +735,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_BevelWidth(WORD  Value)
+uint16_t uLCD_4D_Picaso::gfx_BevelWidth(uint16_t  Value)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_BevelWidth >> 8 ;
@@ -747,7 +746,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_BGcolour(WORD  Color)
+Picaso::Color uLCD_4D_Picaso::gfx_BGcolour(Picaso::Color Color)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_BGcolour >> 8 ;
@@ -755,10 +754,10 @@
   towrite[2]= Color >> 8 ;
   towrite[3]= Color ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::Color) GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::gfx_Button(WORD  Up, WORD  x, WORD  y, WORD  buttonColour, WORD  txtColour, WORD  font, WORD  txtWidth, WORD  txtHeight, char *   text)
+void uLCD_4D_Picaso::gfx_Button(Picaso::ButtonState Up, uint16_t  x, uint16_t  y, Picaso::Color buttonColour, Picaso::Color txtColour, Picaso::Font font, uint16_t  txtWidth, uint16_t  txtHeight, char *   text)
 {
   char  towrite[18] ;
   towrite[0]= F_gfx_Button >> 8 ;
@@ -784,7 +783,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_ChangeColour(WORD  OldColor, WORD  NewColor)
+void uLCD_4D_Picaso::gfx_ChangeColour(uint16_t  OldColor, uint16_t  NewColor)
 {
   char  towrite[6] ;
 
@@ -798,7 +797,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_Circle(WORD  X, WORD  Y, WORD  Radius, WORD  Color)
+void uLCD_4D_Picaso::gfx_Circle(uint16_t  X, uint16_t  Y, uint16_t  Radius, Picaso::Color Color)
 {
   char  towrite[10] ;
 
@@ -816,7 +815,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_CircleFilled(WORD  X, WORD  Y, WORD  Radius, WORD  Color)
+void uLCD_4D_Picaso::gfx_CircleFilled(uint16_t  X, uint16_t  Y, uint16_t  Radius, Picaso::Color Color)
 {
   char  towrite[10] ;
 
@@ -834,7 +833,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_Clipping(WORD  OnOff)
+void uLCD_4D_Picaso::gfx_Clipping(uint16_t  OnOff)
 {
   char  towrite[4] ;
 
@@ -846,7 +845,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_ClipWindow(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2)
+void uLCD_4D_Picaso::gfx_ClipWindow(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2)
 {
   char  towrite[10] ;
 
@@ -873,7 +872,7 @@
   GetAck();
 }
 
-WORD uLCD_4D_Picaso::gfx_Contrast(WORD  Contrast)
+uint16_t uLCD_4D_Picaso::gfx_Contrast(uint16_t  Contrast)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_Contrast >> 8 ;
@@ -884,7 +883,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::gfx_Ellipse(WORD  X, WORD  Y, WORD  Xrad, WORD  Yrad, WORD  Color)
+void uLCD_4D_Picaso::gfx_Ellipse(uint16_t  X, uint16_t  Y, uint16_t  Xrad, uint16_t  Yrad, Picaso::Color Color)
 {
   char  towrite[12] ;
   towrite[0]= F_gfx_Ellipse >> 8 ;
@@ -903,7 +902,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_EllipseFilled(WORD  X, WORD  Y, WORD  Xrad, WORD  Yrad, WORD  Color)
+void uLCD_4D_Picaso::gfx_EllipseFilled(uint16_t  X, uint16_t  Y, uint16_t  Xrad, uint16_t  Yrad, Picaso::Color Color)
 {
   char  towrite[12] ;
   towrite[0]= F_gfx_EllipseFilled >> 8 ;
@@ -922,7 +921,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_FrameDelay(WORD  Msec)
+uint16_t uLCD_4D_Picaso::gfx_FrameDelay(uint16_t  Msec)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_FrameDelay >> 8 ;
@@ -933,7 +932,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_Get(WORD  Mode)
+uint16_t uLCD_4D_Picaso::gfx_Get(Picaso::GFXGetMode  Mode)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_Get >> 8 ;
@@ -944,7 +943,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_GetPixel(WORD  X, WORD  Y)
+Picaso::Color uLCD_4D_Picaso::gfx_GetPixel(uint16_t  X, uint16_t  Y)
 {
   char  towrite[6] ;
   towrite[0]= F_gfx_GetPixel >> 8 ;
@@ -954,10 +953,10 @@
   towrite[4]= Y >> 8 ;
   towrite[5]= Y ;
   WriteBytes(towrite, 6) ;
-  return GetAckResp() ;
+  return (Picaso::Color) GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::gfx_Line(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  Color)
+void uLCD_4D_Picaso::gfx_Line(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, Picaso::Color Color)
 {
   char  towrite[12] ;
   towrite[0]= F_gfx_Line >> 8 ;
@@ -976,7 +975,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_LinePattern(WORD  Pattern)
+uint16_t uLCD_4D_Picaso::gfx_LinePattern(uint16_t  Pattern)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_LinePattern >> 8 ;
@@ -987,7 +986,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::gfx_LineTo(WORD  X, WORD  Y)
+void uLCD_4D_Picaso::gfx_LineTo(uint16_t  X, uint16_t  Y)
 {
   char  towrite[6] ;
   towrite[0]= F_gfx_LineTo >> 8 ;
@@ -1000,7 +999,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_MoveTo(WORD  X, WORD  Y)
+void uLCD_4D_Picaso::gfx_MoveTo(uint16_t  X, uint16_t  Y)
 {
   char  towrite[6] ;
   towrite[0]= F_gfx_MoveTo >> 8 ;
@@ -1013,7 +1012,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_Orbit(WORD  Angle, WORD  Distance, WORD *  Xdest, WORD *  Ydest)
+uint16_t uLCD_4D_Picaso::gfx_Orbit(uint16_t  Angle, uint16_t  Distance, uint16_t *  Xdest, uint16_t *  Ydest)
 {
   char  towrite[6] ;
   towrite[0]= F_gfx_Orbit >> 8 ;
@@ -1027,18 +1026,17 @@
   return 0 ;
 }
 
-WORD uLCD_4D_Picaso::gfx_OutlineColour(WORD  Color)
-{
+Picaso::Color uLCD_4D_Picaso::gfx_OutlineColour(Picaso::Color Color) {
   char  towrite[4] ;
   towrite[0]= F_gfx_OutlineColour >> 8 ;
   towrite[1]= F_gfx_OutlineColour ;
   towrite[2]= Color >> 8 ;
   towrite[3]= Color ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::Color) GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::gfx_Panel(WORD  Raised, WORD  X, WORD  Y, WORD  Width, WORD  Height, WORD  Color)
+void uLCD_4D_Picaso::gfx_Panel(Picaso::PanelState Raised, uint16_t  X, uint16_t  Y, uint16_t  Width, uint16_t  Height, Picaso::Color Color)
 {
   char  towrite[14] ;
   towrite[0]= F_gfx_Panel >> 8 ;
@@ -1059,7 +1057,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_Polygon(WORD  n, t4DWordArray  Xvalues, t4DWordArray  Yvalues, WORD  Color)
+void uLCD_4D_Picaso::gfx_Polygon(uint16_t  n, uint16_t*  Xvalues, uint16_t*  Yvalues, Picaso::Color Color)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_Polygon >> 8 ;
@@ -1075,7 +1073,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_PolygonFilled(WORD  n, t4DWordArray  Xvalues, t4DWordArray  Yvalues, WORD  Color)
+void uLCD_4D_Picaso::gfx_PolygonFilled(uint16_t  n, uint16_t*  Xvalues, uint16_t*  Yvalues, Picaso::Color Color)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_PolygonFilled >> 8 ;
@@ -1091,7 +1089,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_Polyline(WORD  n, t4DWordArray  Xvalues, t4DWordArray  Yvalues, WORD  Color)
+void uLCD_4D_Picaso::gfx_Polyline(uint16_t  n, uint16_t*  Xvalues, uint16_t*  Yvalues, Picaso::Color Color)
 {
   char  towrite[4] ;
   towrite[0]= F_gfx_Polyline >> 8 ;
@@ -1107,7 +1105,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_PutPixel(WORD  X, WORD  Y, WORD  Color)
+void uLCD_4D_Picaso::gfx_PutPixel(uint16_t  X, uint16_t  Y, Picaso::Color Color)
 {
   char  towrite[8] ;
   towrite[0]= F_gfx_PutPixel >> 8 ;
@@ -1122,7 +1120,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_Rectangle(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  Color)
+void uLCD_4D_Picaso::gfx_Rectangle(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, Picaso::Color Color)
 {
   char  towrite[12] ;
   towrite[0]= F_gfx_Rectangle >> 8 ;
@@ -1141,7 +1139,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_RectangleFilled(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  Color)
+void uLCD_4D_Picaso::gfx_RectangleFilled(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, Picaso::Color Color)
 {
   char  towrite[12] ;
   towrite[0]= F_gfx_RectangleFilled >> 8 ;
@@ -1160,7 +1158,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_ScreenCopyPaste(WORD  Xs, WORD  Ys, WORD  Xd, WORD  Yd, WORD  Width, WORD  Height)
+void uLCD_4D_Picaso::gfx_ScreenCopyPaste(uint16_t  Xs, uint16_t  Ys, uint16_t  Xd, uint16_t  Yd, uint16_t  Width, uint16_t  Height)
 {
   char  towrite[14] ;
   towrite[0]= F_gfx_ScreenCopyPaste >> 8 ;
@@ -1181,7 +1179,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_ScreenMode(WORD  ScreenMode)
+Picaso::ScreenMode uLCD_4D_Picaso::gfx_ScreenMode(Picaso::ScreenMode ScreenMode)
 {
   char  towrite[4] ;
 
@@ -1190,10 +1188,10 @@
   towrite[2]= ScreenMode >> 8 ;
   towrite[3]= ScreenMode ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::ScreenMode) GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::gfx_Set(WORD  Func, WORD  Value)
+void uLCD_4D_Picaso::gfx_Set(Picaso::GFXSetFunc Func, uint16_t  Value)
 {
   char  towrite[6] ;
 
@@ -1217,7 +1215,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_Slider(WORD  Mode, WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  Color, WORD  Scale, WORD  Value)
+uint16_t uLCD_4D_Picaso::gfx_Slider(Picaso::SliderState Mode, uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, Picaso::Color Color, uint16_t  Scale, uint16_t  Value)
 {
   char  towrite[18] ;
 
@@ -1243,7 +1241,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_Transparency(WORD  OnOff)
+uint16_t uLCD_4D_Picaso::gfx_Transparency(uint16_t  OnOff)
 {
   char  towrite[4] ;
 
@@ -1255,7 +1253,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::gfx_TransparentColour(WORD  Color)
+Picaso::Color uLCD_4D_Picaso::gfx_TransparentColour(Picaso::Color Color)
 {
   char  towrite[4] ;
 
@@ -1264,10 +1262,10 @@
   towrite[2]= Color >> 8 ;
   towrite[3]= Color ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::Color) GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::gfx_Triangle(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  X3, WORD  Y3, WORD  Color)
+void uLCD_4D_Picaso::gfx_Triangle(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, uint16_t  X3, uint16_t  Y3, Picaso::Color Color)
 {
   char  towrite[16] ;
 
@@ -1291,7 +1289,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::gfx_TriangleFilled(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  X3, WORD  Y3, WORD  Color)
+void uLCD_4D_Picaso::gfx_TriangleFilled(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, uint16_t  X3, uint16_t  Y3, Picaso::Color Color)
 {
   char  towrite[16] ;
   towrite[0]= F_gfx_TriangleFilled >> 8 ;
@@ -1314,7 +1312,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::img_ClearAttributes(WORD  Handle, WORD  Index, WORD  Value)
+uint16_t uLCD_4D_Picaso::img_ClearAttributes(uint16_t  Handle, uint16_t  Index, Picaso::ImageAttribute Value)
 {
   char  towrite[8] ;
   towrite[0]= F_img_ClearAttributes >> 8 ;
@@ -1329,7 +1327,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_Darken(WORD  Handle, WORD  Index)
+uint16_t uLCD_4D_Picaso::img_Darken(uint16_t  Handle, uint16_t  Index)
 {
   char  towrite[6] ;
   towrite[0]= F_img_Darken >> 8 ;
@@ -1342,7 +1340,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_Disable(WORD  Handle, WORD  Index)
+uint16_t uLCD_4D_Picaso::img_Disable(uint16_t  Handle, uint16_t  Index)
 {
   char  towrite[6] ;
   towrite[0]= F_img_Disable >> 8 ;
@@ -1355,7 +1353,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_Enable(WORD  Handle, WORD  Index)
+uint16_t uLCD_4D_Picaso::img_Enable(uint16_t  Handle, uint16_t  Index)
 {
   char  towrite[6] ;
   towrite[0]= F_img_Enable >> 8 ;
@@ -1368,7 +1366,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_GetWord(WORD  Handle, WORD  Index, WORD  Offset )
+uint16_t uLCD_4D_Picaso::img_GetWord(uint16_t  Handle, uint16_t  Index, Picaso::ImageControlOffset Offset )
 {
   char  towrite[8] ;
   towrite[0]= F_img_GetWord >> 8 ;
@@ -1383,7 +1381,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_Lighten(WORD  Handle, WORD  Index)
+uint16_t uLCD_4D_Picaso::img_Lighten(uint16_t  Handle, uint16_t  Index)
 {
   char  towrite[6] ;
   towrite[0]= F_img_Lighten >> 8 ;
@@ -1396,7 +1394,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_SetAttributes(WORD  Handle, WORD  Index, WORD  Value)
+uint16_t uLCD_4D_Picaso::img_SetAttributes(uint16_t  Handle, uint16_t  Index, Picaso::ImageAttribute Value)
 {
   char  towrite[8] ;
 
@@ -1412,7 +1410,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_SetPosition(WORD  Handle, WORD  Index, WORD  Xpos, WORD  Ypos)
+uint16_t uLCD_4D_Picaso::img_SetPosition(uint16_t  Handle, uint16_t  Index, uint16_t  Xpos, uint16_t  Ypos)
 {
   char  towrite[10] ;
 
@@ -1430,7 +1428,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_SetWord(WORD  Handle, WORD  Index, WORD  Offset , WORD  Word)
+uint16_t uLCD_4D_Picaso::img_SetWord(uint16_t  Handle, uint16_t  Index, Picaso::ImageControlOffset Offset , uint16_t  Word)
 {
   char  towrite[10] ;
 
@@ -1448,7 +1446,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_Show(WORD  Handle, WORD  Index)
+uint16_t uLCD_4D_Picaso::img_Show(uint16_t  Handle, uint16_t  Index)
 {
   char  towrite[6] ;
   towrite[0]= F_img_Show >> 8 ;
@@ -1461,7 +1459,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::img_Touched(WORD  Handle, WORD  Index)
+uint16_t uLCD_4D_Picaso::img_Touched(uint16_t  Handle, uint16_t  Index)
 {
   char  towrite[6] ;
   towrite[0]= F_img_Touched >> 8 ;
@@ -1474,7 +1472,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::media_Flush()
+uint16_t uLCD_4D_Picaso::media_Flush()
 {
   char  towrite[2] ;
   towrite[0]= F_media_Flush >> 8 ;
@@ -1483,7 +1481,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::media_Image(WORD  X, WORD  Y)
+void uLCD_4D_Picaso::media_Image(uint16_t  X, uint16_t  Y)
 {
   char  towrite[6] ;
 
@@ -1497,7 +1495,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::media_Init()
+uint16_t uLCD_4D_Picaso::media_Init()
 {
   char  towrite[2] ;
 
@@ -1507,7 +1505,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::media_RdSector(t4DSector  SectorIn)
+uint16_t uLCD_4D_Picaso::media_RdSector(char*  SectorIn)
 {
   char  towrite[2] ;
 
@@ -1517,7 +1515,7 @@
   return GetAckResSector(SectorIn) ;
 }
 
-WORD uLCD_4D_Picaso::media_ReadByte()
+uint16_t uLCD_4D_Picaso::media_ReadByte()
 {
   char  towrite[2] ;
   towrite[0]= F_media_ReadByte >> 8 ;
@@ -1526,7 +1524,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::media_ReadWord()
+uint16_t uLCD_4D_Picaso::media_ReadWord()
 {
   char  towrite[2] ;
   towrite[0]= F_media_ReadWord >> 8 ;
@@ -1535,7 +1533,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::media_SetAdd(WORD  HiWord, WORD  LoWord)
+void uLCD_4D_Picaso::media_SetAdd(uint16_t  HiWord, uint16_t  LoWord)
 {
   char  towrite[6] ;
 
@@ -1549,7 +1547,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::media_SetSector(WORD  HiWord, WORD  LoWord)
+void uLCD_4D_Picaso::media_SetSector(uint16_t  HiWord, uint16_t  LoWord)
 {
   char  towrite[6] ;
 
@@ -1563,7 +1561,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::media_Video(WORD  X, WORD  Y)
+void uLCD_4D_Picaso::media_Video(uint16_t  X, uint16_t  Y)
 {
   char  towrite[6] ;
 
@@ -1577,7 +1575,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::media_VideoFrame(WORD  X, WORD  Y, WORD  Framenumber)
+void uLCD_4D_Picaso::media_VideoFrame(uint16_t  X, uint16_t  Y, uint16_t  Framenumber)
 {
   char  towrite[8] ;
 
@@ -1593,7 +1591,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::media_WriteByte(WORD  Byte)
+uint16_t uLCD_4D_Picaso::media_WriteByte(uint16_t  Byte)
 {
   char  towrite[4] ;
 
@@ -1605,7 +1603,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::media_WriteWord(WORD  Word)
+uint16_t uLCD_4D_Picaso::media_WriteWord(uint16_t  Word)
 {
   char  towrite[4] ;
 
@@ -1617,7 +1615,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::media_WrSector(t4DSector  SectorOut)
+uint16_t uLCD_4D_Picaso::media_WrSector(char*  SectorOut)
 {
   char  towrite[2] ;
 
@@ -1628,7 +1626,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::mem_Free(WORD  Handle)
+uint16_t uLCD_4D_Picaso::mem_Free(uint16_t  Handle)
 {
   char  towrite[4] ;
 
@@ -1640,7 +1638,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::mem_Heap()
+uint16_t uLCD_4D_Picaso::mem_Heap()
 {
   char  towrite[2] ;
 
@@ -1650,7 +1648,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::peekM(WORD  Address)
+uint16_t uLCD_4D_Picaso::peekM(uint16_t  Address)
 {
   char  towrite[4] ;
 
@@ -1662,7 +1660,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::pin_HI(WORD  Pin)
+uint16_t uLCD_4D_Picaso::pin_HI(Picaso::Pin Pin)
 {
   char  towrite[4] ;
 
@@ -1674,7 +1672,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::pin_LO(WORD  Pin)
+uint16_t uLCD_4D_Picaso::pin_LO(Picaso::Pin Pin)
 {
   char  towrite[4] ;
 
@@ -1686,7 +1684,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::pin_Read(WORD  Pin)
+uint16_t uLCD_4D_Picaso::pin_Read(Picaso::Pin Pin)
 {
   char  towrite[4] ;
 
@@ -1698,7 +1696,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::pin_Set(WORD  Mode, WORD  Pin)
+uint16_t uLCD_4D_Picaso::pin_Set(uint16_t  Mode, Picaso::Pin Pin)
 {
   char  towrite[6] ;
 
@@ -1712,7 +1710,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::pokeM(WORD  Address, WORD  WordValue)
+void uLCD_4D_Picaso::pokeM(uint16_t  Address, uint16_t  WordValue)
 {
   char  towrite[6] ;
 
@@ -1726,7 +1724,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::putCH(WORD  WordChar)
+void uLCD_4D_Picaso::putCH(uint16_t  WordChar)
 {
   char  towrite[4] ;
 
@@ -1738,7 +1736,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::putStr(char *  InString)
+uint16_t uLCD_4D_Picaso::putStr(char *  InString)
 {
   char  towrite[2] ;
 
@@ -1749,7 +1747,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::snd_BufSize(WORD  Bufsize)
+void uLCD_4D_Picaso::snd_BufSize(uint16_t  Bufsize)
 {
   char  towrite[4] ;
 
@@ -1781,7 +1779,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::snd_Pitch(WORD  Pitch)
+uint16_t uLCD_4D_Picaso::snd_Pitch(uint16_t  Pitch)
 {
   char  towrite[4] ;
 
@@ -1793,7 +1791,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::snd_Playing()
+uint16_t uLCD_4D_Picaso::snd_Playing()
 {
   char  towrite[2] ;
 
@@ -1813,7 +1811,7 @@
   GetAck() ;
 }
 
-void uLCD_4D_Picaso::snd_Volume(WORD  Volume)
+void uLCD_4D_Picaso::snd_Volume(uint16_t  Volume)
 {
   char  towrite[4] ;
 
@@ -1825,7 +1823,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::sys_Sleep(WORD  Units)
+uint16_t uLCD_4D_Picaso::sys_Sleep(uint16_t  Units)
 {
   char  towrite[4] ;
 
@@ -1837,7 +1835,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::touch_DetectRegion(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2)
+void uLCD_4D_Picaso::touch_DetectRegion(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2)
 {
   char  towrite[10] ;
 
@@ -1855,7 +1853,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::touch_Get(WORD  Mode)
+uint16_t uLCD_4D_Picaso::touch_Get(uint16_t  Mode)
 {
   char  towrite[4] ;
 
@@ -1867,7 +1865,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::touch_Set(WORD  Mode)
+void uLCD_4D_Picaso::touch_Set(uint16_t  Mode)
 {
   char  towrite[4] ;
 
@@ -1879,7 +1877,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Attributes(WORD  Attribs)
+Picaso::TextAttribute uLCD_4D_Picaso::txt_Attributes(Picaso::TextAttribute Attribs)
 {
   char  towrite[4] ;
 
@@ -1888,10 +1886,10 @@
   towrite[2]= Attribs >> 8 ;
   towrite[3]= Attribs ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::TextAttribute) GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_BGcolour(WORD  Color)
+Picaso::Color uLCD_4D_Picaso::txt_BGcolour(Picaso::Color Color)
 {
   char  towrite[4] ;
 
@@ -1900,10 +1898,10 @@
   towrite[2]= Color >> 8 ;
   towrite[3]= Color ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::Color) GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Bold(WORD  Bold)
+uint16_t uLCD_4D_Picaso::txt_Bold(uint16_t  Bold)
 {
   char  towrite[4] ;
 
@@ -1915,7 +1913,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_FGcolour(WORD  Color)
+Picaso::Color uLCD_4D_Picaso::txt_FGcolour(Picaso::Color Color)
 {
   char  towrite[4] ;
 
@@ -1924,10 +1922,10 @@
   towrite[2]= Color >> 8 ;
   towrite[3]= Color ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::Color) GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_FontID(WORD  FontNumber)
+Picaso::Font uLCD_4D_Picaso::txt_FontID(Picaso::Font FontNumber)
 {
   char  towrite[4] ;
 
@@ -1936,10 +1934,10 @@
   towrite[2]= FontNumber >> 8 ;
   towrite[3]= FontNumber ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::Font) GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Height(WORD  Multiplier)
+uint16_t uLCD_4D_Picaso::txt_Height(uint16_t  Multiplier)
 {
   char  towrite[4] ;
 
@@ -1951,7 +1949,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Inverse(WORD  Inverse)
+uint16_t uLCD_4D_Picaso::txt_Inverse(uint16_t  Inverse)
 {
   char  towrite[4] ;
 
@@ -1963,7 +1961,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Italic(WORD  Italic)
+uint16_t uLCD_4D_Picaso::txt_Italic(uint16_t  Italic)
 {
   char  towrite[4] ;
 
@@ -1975,7 +1973,7 @@
   return GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::txt_MoveCursor(WORD  Line, WORD  Column)
+void uLCD_4D_Picaso::txt_MoveCursor(uint16_t  Line, uint16_t  Column)
 {
   char  towrite[6] ;
 
@@ -1989,7 +1987,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Opacity(WORD  TransparentOpaque)
+Picaso::TextOpacity uLCD_4D_Picaso::txt_Opacity(Picaso::TextOpacity TransparentOpaque)
 {
   char  towrite[4] ;
 
@@ -1998,10 +1996,10 @@
   towrite[2]= TransparentOpaque >> 8 ;
   towrite[3]= TransparentOpaque ;
   WriteBytes(towrite, 4) ;
-  return GetAckResp() ;
+  return (Picaso::TextOpacity) GetAckResp() ;
 }
 
-void uLCD_4D_Picaso::txt_Set(WORD  Func, WORD  Value)
+void uLCD_4D_Picaso::txt_Set(Picaso::TextSetFunc Func, uint16_t  Value)
 {
   char  towrite[6] ;
 
@@ -2015,7 +2013,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Underline(WORD  Underline)
+uint16_t uLCD_4D_Picaso::txt_Underline(uint16_t  Underline)
 {
   char  towrite[4] ;
 
@@ -2027,7 +2025,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Width(WORD  Multiplier)
+uint16_t uLCD_4D_Picaso::txt_Width(uint16_t  Multiplier)
 {
   char  towrite[4] ;
 
@@ -2039,7 +2037,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Wrap(WORD  Position)
+uint16_t uLCD_4D_Picaso::txt_Wrap(uint16_t  Position)
 {
   char  towrite[4] ;
 
@@ -2051,7 +2049,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Xgap(WORD  Pixels)
+uint16_t uLCD_4D_Picaso::txt_Xgap(uint16_t  Pixels)
 {
   char  towrite[4] ;
 
@@ -2063,7 +2061,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::txt_Ygap(WORD  Pixels)
+uint16_t uLCD_4D_Picaso::txt_Ygap(uint16_t  Pixels)
 {
   char  towrite[4] ;
 
@@ -2075,7 +2073,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::file_CallFunction(WORD  Handle, WORD  ArgCount, t4DWordArray  Args)
+uint16_t uLCD_4D_Picaso::file_CallFunction(uint16_t  Handle, uint16_t  ArgCount, uint16_t*  Args)
 {
   char  towrite[6] ;
 
@@ -2090,7 +2088,7 @@
   return WaitForAck() ;
 }
 
-WORD uLCD_4D_Picaso::sys_GetModel(char *  ModelStr)
+uint16_t uLCD_4D_Picaso::sys_GetModel(char *  ModelStr)
 {
   char  towrite[2] ;
 
@@ -2100,7 +2098,7 @@
   return GetAckResStr(ModelStr) ;
 }
 
-WORD uLCD_4D_Picaso::sys_GetVersion()
+uint16_t uLCD_4D_Picaso::sys_GetVersion()
 {
   char  towrite[2] ;
 
@@ -2110,7 +2108,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::sys_GetPmmC()
+uint16_t uLCD_4D_Picaso::sys_GetPmmC()
 {
   char  towrite[2] ;
 
@@ -2120,7 +2118,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::writeString(WORD  Handle, char *  StringOut)
+uint16_t uLCD_4D_Picaso::writeString(uint16_t  Handle, char *  StringOut)
 {
   char  towrite[4] ;
 
@@ -2133,7 +2131,7 @@
   return GetAckResp() ;
 }
 
-WORD uLCD_4D_Picaso::readString(WORD  Handle, char *  StringIn)
+uint16_t uLCD_4D_Picaso::readString(uint16_t  Handle, char *  StringIn)
 {
   char  towrite[4] ;
 
@@ -2145,7 +2143,7 @@
   return GetAckResStr(StringIn) ;
 }
 
-void uLCD_4D_Picaso::blitComtoDisplay(WORD  X, WORD  Y, WORD  Width, WORD  Height, t4DByteArray  Pixels)
+void uLCD_4D_Picaso::blitComtoDisplay(uint16_t  X, uint16_t  Y, uint16_t  Width, uint16_t  Height, char*  Pixels)
 {
   char  towrite[10] ;
 
@@ -2164,7 +2162,7 @@
   GetAck() ;
 }
 
-WORD uLCD_4D_Picaso::file_FindFirstRet(char *  Filename, char *  StringIn)
+uint16_t uLCD_4D_Picaso::file_FindFirstRet(char *  Filename, char *  StringIn)
 {
   char  towrite[2] ;
 
@@ -2175,7 +2173,7 @@
   return GetAckResStr(StringIn) ;
 }
 
-WORD uLCD_4D_Picaso::file_FindNextRet(char *  StringIn)
+uint16_t uLCD_4D_Picaso::file_FindNextRet(char *  StringIn)
 {
   char  towrite[2] ;
 
@@ -2185,7 +2183,7 @@
   return GetAckResStr(StringIn) ;
 }
 
-void uLCD_4D_Picaso::setbaudWait(uLCD_4D_Picaso::BaudRate Newrate)
+void uLCD_4D_Picaso::setbaudWait(Picaso::BaudRate Newrate)
 {
   char  towrite[4] ;