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

Dependencies:   MODSERIAL

Dependents:   uLCD_4D_24PTU Drawing Program RoommateTracker_ScreenAndPhone ece4180_roommate_tracker_final

Revision:
2:ebe7029e2825
Parent:
0:e314f3b805ed
Child:
4:30010dda3b34
--- a/uLCD_4D_Picaso.h	Fri Mar 06 00:50:49 2015 +0000
+++ b/uLCD_4D_Picaso.h	Tue Mar 10 16:05:28 2015 +0000
@@ -18,172 +18,1237 @@
 #define LCD_USING_MODSERIAL 1
 
 #include "mbed.h"
-#include "Picaso_Types4D.h"
+#include "Picaso_enums.h"
 
 #if LCD_USING_MODSERIAL
 #include "MODSERIAL.h"
 #endif
 
+
+//Constant 4D Serial Commands
+// function call index definitions, generated by build of serial
+
+#define F_charheight 29
+#define F_charwidth 30
+#define F_bus_In -45
+#define F_bus_Out -46
+#define F_bus_Read -49
+#define F_bus_Set -47
+#define F_bus_Write -48
+#define F_file_Close -232
+#define F_file_Count 1
+#define F_file_Dir 2
+#define F_file_Erase 3
+#define F_file_Error -225
+#define F_file_Exec 4
+#define F_file_Exists 5
+#define F_file_FindFirst 6
+#define F_file_FindNext -229
+#define F_file_GetC -242
+#define F_file_GetS 7
+#define F_file_GetW -244
+#define F_file_Image -239
+#define F_file_Index -235
+#define F_file_LoadFunction 8
+#define F_file_LoadImageControl 9
+#define F_file_Mount -253
+#define F_file_Open 10
+#define F_file_PlayWAV 11
+#define F_file_PutC 31
+#define F_file_PutS 32
+#define F_file_PutW -243
+#define F_file_Read 12
+#define F_file_Rewind -248
+#define F_file_Run 13
+#define F_file_ScreenCapture -240
+#define F_file_Seek -234
+#define F_file_Size 14
+#define F_file_Tell 15
+#define F_file_Unmount -254
+#define F_file_Write 16
+#define F_gfx_BevelShadow -104
+#define F_gfx_BevelWidth -103
+#define F_gfx_BGcolour -92
+#define F_gfx_Button 17
+#define F_gfx_ChangeColour -76
+#define F_gfx_Circle -61
+#define F_gfx_CircleFilled -62
+#define F_gfx_Clipping -94
+#define F_gfx_ClipWindow -75
+#define F_gfx_Cls -51
+#define F_gfx_Contrast -100
+#define F_gfx_Ellipse -78
+#define F_gfx_EllipseFilled -79
+#define F_gfx_FrameDelay -97
+#define F_gfx_Get -90
+#define F_gfx_GetPixel -64
+#define F_gfx_Line -56
+#define F_gfx_LinePattern -101
+#define F_gfx_LineTo -54
+#define F_gfx_MoveTo -52
+#define F_gfx_Orbit 18
+#define F_gfx_OutlineColour -99
+#define F_gfx_Panel -81
+#define F_gfx_Polygon 19
+#define F_gfx_PolygonFilled 20
+#define F_gfx_Polyline 21
+#define F_gfx_PutPixel -63
+#define F_gfx_Rectangle -59
+#define F_gfx_RectangleFilled -60
+#define F_gfx_ScreenCopyPaste -83
+#define F_gfx_ScreenMode -98
+#define F_gfx_Set -50
+#define F_gfx_SetClipRegion -77
+#define F_gfx_Slider -82
+#define F_gfx_Transparency -96
+#define F_gfx_TransparentColour -95
+#define F_gfx_Triangle -65
+#define F_gfx_TriangleFilled -87
+#define F_img_ClearAttributes -187
+#define F_img_Darken -181
+#define F_img_Disable -180
+#define F_img_Enable -179
+#define F_img_GetWord -184
+#define F_img_Lighten -182
+#define F_img_SetAttributes -186
+#define F_img_SetPosition -178
+#define F_img_SetWord -183
+#define F_img_Show -185
+#define F_img_Touched -188
+#define F_media_Flush -118
+#define F_media_Image -117
+#define F_media_Init -119
+#define F_media_RdSector 22
+#define F_media_ReadByte -113
+#define F_media_ReadWord -114
+#define F_media_SetAdd -109
+#define F_media_SetSector -110
+#define F_media_Video -107
+#define F_media_VideoFrame -108
+#define F_media_WriteByte -115
+#define F_media_WriteWord -116
+#define F_media_WrSector 23
+#define F_mem_Free -220
+#define F_mem_Heap -221
+#define F_peekM 39
+#define F_pin_HI -42
+#define F_pin_LO -43
+#define F_pin_Read -44
+#define F_pin_Set -41
+#define F_pokeM 40
+#define F_putCH -2
+#define F_putstr 24
+#define F_snd_BufSize -258
+#define F_snd_Continue -261
+#define F_snd_Pause -260
+#define F_snd_Pitch -257
+#define F_snd_Playing -262
+#define F_snd_Stop -259
+#define F_snd_Volume -256
+#define F_sys_Sleep -197
+#define F_touch_DetectRegion -199
+#define F_touch_Get -201
+#define F_touch_Set -200
+#define F_txt_Attributes -38
+#define F_txt_BGcolour -26
+#define F_txt_Bold -34
+#define F_txt_FGcolour -25
+#define F_txt_FontID -27
+#define F_txt_Height -29
+#define F_txt_Inverse -36
+#define F_txt_Italic -35
+#define F_txt_MoveCursor -23
+#define F_txt_Opacity -33
+#define F_txt_Set -24
+#define F_txt_Underline -37
+#define F_txt_Width -28
+#define F_txt_Wrap -39
+#define F_txt_Xgap -30
+#define F_txt_Ygap -31
+#define F_file_CallFunction 25
+#define F_sys_GetModel 26
+#define F_sys_GetVersion 27
+#define F_sys_GetPmmC 28
+#define F_writeString 33
+#define F_readString 34
+#define F_blitComtoDisplay 35
+#define F_file_FindFirstRet 36
+#define F_file_FindNextRet 37
+#define F_setbaudWait 38
+
+
 class uLCD_4D_Picaso {
 	public:
 	
-	// Allowed serial interface baud rates.
-	enum BaudRate {
-        BAUD_110 = 0, BAUD_300, BAUD_600, BAUD_1200, BAUD_2400, BAUD_4800, BAUD_9600, BAUD_14400,
-        BAUD_19200, BAUD_31250, BAUD_38400, BAUD_56000, BAUD_57600, BAUD_115200, BAUD_128000,
-        BAUD_256000, BAUD_300000, BAUD_375000, BAUD_500000, BAUD_600000
-    };
-    
+    /**
+     * Class constructor
+     * @param tx Serial transmit pin.
+     * @param rx Serial receive pin.
+     * @param reset Reset GPIO pin.
+     */
 	uLCD_4D_Picaso(PinName tx, PinName rx, PinName reset);
+	
+	/**
+	 * Resets the LCD screen (takes 3 seconds).
+	 */
 	void LCD_reset();
 	
-	char file_GetC(WORD  Handle) ;
-	void blitComtoDisplay(WORD  X, WORD  Y, WORD  Width, WORD  Height, t4DByteArray  Pixels);
-	WORD bus_In(void);
-	void bus_Out(WORD Bits);
-	WORD bus_Read(void);
-	void bus_Set(WORD IOMap);
-	void bus_Write(WORD Bits);
-	void file_Unmount(void);
-	void gfx_Button(WORD  Up, WORD  x, WORD  y, WORD  buttonColour, WORD  txtColour, WORD  font, WORD  txtWidth, WORD  txtHeight, char *  text);
-	void gfx_ChangeColour(WORD  OldColor, WORD  NewColor);
-	void gfx_Circle(WORD  X, WORD  Y, WORD  Radius, WORD  Color);
-	void gfx_CircleFilled(WORD  X, WORD  Y, WORD  Radius, WORD  Color);
-	void gfx_Clipping(WORD  OnOff);
-	void gfx_ClipWindow(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2);
+	
+	// LCD text commands:
+	
+	/**
+	 * Prints single character to screen.
+	 * @param Character to be printed.
+	 */
+	void putCH(uint16_t Character);
+	
+	/**
+	 * Prints null-terminated string to screen.
+	 * @param InString String to be printed. Maximum length is 511 characters plus null.
+	 * @return Number of characters printed.
+	 */
+	uint16_t putStr(char *InString);
+	
+	/**
+	 * Moves text cursor to specified line and column (based on font size), with (0, 0) being the top-left corner.
+	 */
+	void txt_MoveCursor(uint16_t Line, uint16_t Column);
+	
+	/**
+	 * Sets text bold, italic, inverse, and underlined attributes.
+	 * @param Attribs Word containing attribute flags. OR attribute constants together to set multiple.
+	 * @return Previous text attribute word.
+	 */
+	Picaso::TextAttribute txt_Attributes(Picaso::TextAttribute Attribs);
+	
+	/**
+	 * Sets text inverse attribute.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Inverse(uint16_t Inverse);
+	
+	/**
+	 * Sets text italic attribute.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Italic(uint16_t Italic);
+	
+	/**
+	 * Sets text bold attribute.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Bold(uint16_t Bold);
+	
+	/**
+	 * Sets text underline attribute.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Underline(uint16_t Underline);
+	
+	/**
+	 * Sets text background color.
+	 * @return Previous color setting.
+	 */
+	Picaso::Color txt_BGcolour(Picaso::Color Color);
+	
+	/*
+	 * Sets text foreground color.
+	 * @return Previous color setting.
+	 */
+	Picaso::Color txt_FGcolour(Picaso::Color Color);
+	
+	/**
+	 * Sets text background opacity (i.e. whether background pixels are drawn).
+	 * @return Previous setting.
+	 */
+	Picaso::TextOpacity txt_Opacity(Picaso::TextOpacity TransparentOpaque);
+	
+	/**
+	 * Sets text font. Note that one can also pass a handle to a file with a font: see Picaso Serial Command Manual for more information.
+	 * @return Previous setting.
+	 */
+	Picaso::Font txt_FontID(Picaso::Font FontNumber);
+	
+	/**
+	 * Sets text font height.
+	 * @param Multiplier Font height as multiple of default.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Height(uint16_t Multiplier);
+	
+	/**
+	 * Sets text font width.
+	 * @param Multiplier Font width as multiple of default.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Width(uint16_t Multiplier);
+	
+	/**
+	 * Returns the height, in pixels, of a given character under the current font settings. If height is greater than 255, the returned value will be modulo 8.
+	 */
+	uint16_t charheight(char  TestChar);
+	
+	/**
+	 * Returns the width, in pixels, of a given character under the current font settings. If width is greater than 255, the returned value will be modulo 8.
+	 */
+	uint16_t charwidth(char  TestChar);
+	
+	/**
+	 * Sets the pixel position (from left side) at which text wraps around on right side.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Wrap(uint16_t  Position);
+	
+	/**
+	 * Sets gap, in pixels, between characters in the x-direction.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Xgap(uint16_t  Pixels);
+	
+	/**
+	 * Sets gap, in pixels, between characters in the y-direction.
+	 * @return Previous setting.
+	 */
+	uint16_t txt_Ygap(uint16_t  Pixels);
+	
+	/**
+	 * Sets one of several text attributes. Most attributes can be set by other functions.
+	 * @param Func Attribute to set.
+	 * @param Value Value to set parameter. See TextSetFunc definition for more information.
+	 */
+	void txt_Set(Picaso::TextSetFunc Func, uint16_t Value);
+	
+	
+	// LCD graphics commands:
+	
+	/**
+	 * Clears screen and sets several attributes (such as transparency, outline color, opacity, pen style, line patterning, 
+	 * text wrap position, text size, and origin) to their default values.
+	 */
 	void gfx_Cls(void);
-	void gfx_Ellipse(WORD  X, WORD  Y, WORD  Xrad, WORD  Yrad, WORD  Color);
-	void gfx_EllipseFilled(WORD  X, WORD  Y, WORD  Xrad, WORD  Yrad, WORD  Color);
-	void gfx_Line(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  Color);
-	void gfx_LineTo(WORD  X, WORD  Y);
-	void gfx_MoveTo(WORD  X, WORD  Y);
-	void gfx_Panel(WORD  Raised, WORD  X, WORD  Y, WORD  Width, WORD  Height, WORD  Color);
-	void gfx_Polygon(WORD  n, t4DWordArray  Xvalues, t4DWordArray  Yvalues, WORD  Color);
-	void gfx_PolygonFilled(WORD  n, t4DWordArray  Xvalues, t4DWordArray  Yvalues, WORD  Color);
-	void gfx_Polyline(WORD  n, t4DWordArray  Xvalues, t4DWordArray  Yvalues, WORD  Color);
-	void gfx_PutPixel(WORD  X, WORD  Y, WORD  Color);
-	void gfx_Rectangle(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  Color);
-	void gfx_RectangleFilled(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  Color);
-	void gfx_ScreenCopyPaste(WORD  Xs, WORD  Ys, WORD  Xd, WORD  Yd, WORD  Width, WORD  Height);
-	void gfx_Set(WORD  Func, WORD  Value);
+	
+	/**
+	 * Changes all pixels on the screen of OldColor to NewColor.
+	 */
+	void gfx_ChangeColour(uint16_t  OldColor, uint16_t  NewColor);
+	
+	/**
+	 * Draws pixel of color Color at (X, Y).
+	 */
+	void gfx_PutPixel(uint16_t  X, uint16_t  Y, Picaso::Color Color);
+	
+	/**
+	 * Returns current color of pixel at (X, Y).
+	 */
+	Picaso::Color gfx_GetPixel(uint16_t  X, uint16_t  Y);
+	
+	/**
+	 * Draws (unfilled) circle on screen.
+	 * @param X,Y Coordinates (in pixels) of circle's center.
+	 * @param Radius Radius of circle.
+	 * @param Color Color of circle.
+	 */
+	void gfx_Circle(uint16_t  X, uint16_t  Y, uint16_t  Radius, Picaso::Color Color);
+	
+	/**
+	 * Draws filled circle on screen.
+	 * @param X,Y Coordinates (in pixels) of circle's center.
+	 * @param Radius Radius of circle.
+	 * @param Color Color of circle.
+	 */
+	void gfx_CircleFilled(uint16_t  X, uint16_t  Y, uint16_t  Radius, Picaso::Color  Color);
+	
+	/**
+	 * Draws line from (X1, Y1) to (X2, Y2) with color Color
+	 */
+	void gfx_Line(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2, Picaso::Color Color);
+	
+	/**
+	 * Draws unfilled rectangle on screen.
+	 * @param X1,Y1 Coordinates of top-left corner of rectangle.
+	 * @param X2,Y2 Coordinates of bottom-right corner of rectangle.
+	 * @param Color of rectangle.
+	 */
+	void gfx_Rectangle(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, Picaso::Color Color);
+	
+	/**
+	 * Draws filled rectangle on screen.
+	 * @param X1,Y1 Coordinates of top-left corner of rectangle.
+	 * @param X2,Y2 Coordinates of bottom-right corner of rectangle.
+	 * @param Color of rectangle.
+	 */
+	void gfx_RectangleFilled(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, Picaso::Color Color);
+	
+	/**
+	 * Plots line between a sequence of points.
+	 * @param n Number of vertices.
+	 * @param Xvalues,Yvalues Arrays of size n containing the coordinates of each vertex.
+	 * @param Color Color of line.
+	 */
+	void gfx_Polyline(uint16_t  n, uint16_t*  Xvalues, uint16_t*  Yvalues, Picaso::Color Color);
+	
+	/**
+	 * Draws unfilled polygon on screen.
+	 * @param n Number of vertices.
+	 * @param Xvalues,Yvalues Arrays of size n contianing the coordinates of each vertex.
+	 * @param Color Color of polygon.
+	 */
+	void gfx_Polygon(uint16_t  n, uint16_t*  Xvalues, uint16_t*  Yvalues, Picaso::Color Color);
+	
+	/**
+	 * Draws filled polygon on screen.
+	 * @param n Number of vertices.
+	 * @param Xvalues,Yvalues Arrays of size n contianing the coordinates of each vertex.
+	 * @param Color Color of polygon.
+	 */
+	void gfx_PolygonFilled(uint16_t  n, uint16_t*  Xvalues, uint16_t*  Yvalues, Picaso::Color Color);
+	
+	/**
+	 * Draws unfilled triangle on screen.
+	 * @param X1,Y1 Coordinates of first vertex.
+	 * @param X2,Y2 Coordinates of second vertex.
+	 * @param X3,Y3 Coordinates of third vertex.
+	 * @param Color Color of triangle.
+	 */
+	void gfx_Triangle(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, uint16_t  X3, uint16_t  Y3, Picaso::Color Color);
+	
+	/**
+	 * Draws filled triangle on screen.
+	 * @param X1,Y1 Coordinates of first vertex.
+	 * @param X2,Y2 Coordinates of second vertex.
+	 * @param X3,Y3 Coordinates of third vertex.
+	 * @param Color Color of triangle.
+	 */
+	void gfx_TriangleFilled(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2, uint16_t  X3, uint16_t  Y3, Picaso::Color Color);
+	
+	/**
+	 * Draws ellipse on screen.
+	 * @param X,Y Coordinates of center of ellipse.
+	 * @param Xrad Ellipse's x-radius.
+	 * @param Yrad Ellipse's y-radius.
+	 * @param Color Color of ellipse.
+	 */
+	void gfx_Ellipse(uint16_t X, uint16_t Y, uint16_t Xrad, uint16_t Yrad, Picaso::Color Color);
+	
+	/**
+	 * Draws filled ellipse on screen.
+	 * @param X,Y Coordinates of center of ellipse.
+	 * @param Xrad Ellipse's x-radius.
+	 * @param Yrad Ellipse's y-radius.
+	 * @param Color Color of ellipse.
+	 */
+	void gfx_EllipseFilled(uint16_t X, uint16_t Y, uint16_t Xrad, uint16_t Yrad, Picaso::Color Color);
+	
+	
+	
+	
+	/**
+	 * Enables or disables clipping.
+	 * @param OnOff 0 = Off, 1 = On.
+	 */
+	void gfx_Clipping(uint16_t  OnOff);
+	
+	/**
+	 * Sets clipping window for graphics. Any objects and text will only be displayed within the window.
+	 * Clipping must first be enabled with the gfx_Clipping command.
+	 * @param X1, Y1 Coordinates of top left corner of window.
+	 * @param X2, Y2 Coordinates of bottom right corner of window.
+	 */
+	void gfx_ClipWindow(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2);
+	
+	/**
+	 * Forces clip window to include the last printed text or image.
+	 */
 	void gfx_SetClipRegion(void);
-	void gfx_Triangle(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  X3, WORD  Y3, WORD  Color);
-	void gfx_TriangleFilled(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  X3, WORD  Y3, WORD  Color);
-	void media_Image(WORD  X, WORD  Y);
-	void media_SetAdd(WORD  HiWord, WORD  LoWord);
-	void media_SetSector(WORD  HiWord, WORD  LoWord);
-	void media_Video(WORD  X, WORD  Y);
-	void media_VideoFrame(WORD  X, WORD  Y, WORD  Framenumber);
-	void setbaudWait(uLCD_4D_Picaso::BaudRate Newrate);
-	void snd_BufSize(WORD  Bufsize);
-	void snd_Continue(void);
-	void snd_Pause(void);
+	
+	
+	
+	
+	
+	/**
+	 * Draws line from the origin to (X, Y), using current object color and then moves the origin to the endpoint. This command is most useful when used with gfx_Orbit.
+	 */
+	void gfx_LineTo(uint16_t  X, uint16_t  Y);
+	
+	/**
+	 * Moves the origin to (X, Y).
+	 */
+	void gfx_MoveTo(uint16_t  X, uint16_t  Y);
+	
+	/**
+	 * Calculates the X and Y coordinates relative to the origin, given an angle and distance.
+	 * @param Angle Angle in degrees.
+	 * @param Distance Distance from origin in pixels.
+	 * @param Xdest Pointer to variable where calculated X value will be stored.
+	 * @param Ydest Pointer to variable where calculated Y value will be stored.
+	 * @return Returns 0.
+	 */
+	uint16_t gfx_Orbit(uint16_t Angle, uint16_t Distance, uint16_t* Xdest, uint16_t* Ydest);
+	
+	
+	/**
+	 * Draws button on screen.
+	 * @param Up Whether button appears raised (BUTTON_RAISED = 1) or depressed (BUTTON_DEPRESSED = 0).
+	 * @param x,y Coordinates of top left corner of button.
+	 * @param buttonColour Button color.
+	 * @param txtColour Text color.
+	 * @param font Text font ID.
+	 * @param txtWidth Text width, as multiple of default.
+	 * @param txtHeight Text height, as multiple of default.
+	 * @param text Null-terminated string with button text. May include newline characters for multiple lines of text in button.
+	 */
+	void 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);
+	
+	/**
+	 * 
+	 * @param Raised Panel appearance (raised or sunken).
+	 * @param X,Y Position of top-left corner of panel.
+	 * @param Width Panel width.
+	 * @param Height Panel height.
+	 * @param Color Panel color.
+	 */
+	void gfx_Panel(Picaso::PanelState Raised, uint16_t X, uint16_t Y, uint16_t Width, uint16_t  Height, Picaso::Color Color);
+	
+	/**
+	 * Draws horizontal or vertical slider bar on screen. If X2 - X1 > Y2 - Y1, slider is assumed to be horizontal. Otherwise, slider is assumed to be vertical.
+	 * @param Mode Slider appearance (sunken, raised, or hidden).
+	 * @param X1,Y1 Coordinates of top-left corner of slider.
+	 * @param X2,Y2 Coordinates of bottom-right corner of slider.
+	 * @param Color Color of slider bar.
+	 * @param Scale Sets scale of slider position: slider can have positions from 0 to Scale.
+	 * @param Position of slider thumb. If negative, the absolute value is taken.
+	 * @return ??--TODO
+	 */
+	uint16_t 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);
+	
+	/**
+	 * Sets depth of bevel shadow on buttons drawn.
+	 * @param Value Shadow depth in pixels (0-4).
+	 * @return Previous setting.
+	 */
+	uint16_t gfx_BevelShadow(uint16_t  Value);
+	
+	/**
+	 * Sets width of bevel on buttons drawn.
+	 * @param Value Shadow depth in pixels (0-15).
+	 * @return Previous setting.
+	 */
+	uint16_t gfx_BevelWidth(uint16_t  Value);
+	
+	/**
+	 * Copies a region of the screen and pastes it to another.
+	 * @param Xs,Ys Coordinates of top-left corner of region to be copied.
+	 * @param Xd,Yd Coordinates of top-left corner of destination region.
+	 * @param Width Width of region to be copied.
+	 * @param Height Height of region to be copied.
+	 */
+	void gfx_ScreenCopyPaste(uint16_t  Xs, uint16_t  Ys, uint16_t  Xd, uint16_t  Yd, uint16_t  Width, uint16_t  Height);
+	
+	/**
+	 * Sets the screen background color.
+	 * @return Previous background color.
+	 */
+	Picaso::Color gfx_BGcolour(Picaso::Color Color);
+	
+	
+	/**
+	 * Sets the outline color for rectangles and circles.
+	 * @return Previous outline color.
+	 */
+	Picaso::Color gfx_OutlineColour(Picaso::Color Color);
+	
+	/**
+	 * Sets display contrast or turns it on and off, depending on display model.
+	 * @param Contrast Constrast setting. For most displays, 0 = display off, non-zero = display on. See Serial Command Manual for exceptions.
+	 * @return Previous setting.
+	 */
+	uint16_t gfx_Contrast(uint16_t  Contrast);
+	
+	/**
+	 * Sets inter-frame delay, in milliseconds, for media_Video command.
+	 * @return Previous setting.
+	 */
+	uint16_t gfx_FrameDelay(uint16_t  Msec);
+	
+	/**
+	 * Sets line drawing pattern.
+	 * @param Pattern Word containing bit pattern; each set bit corresponds to a pixel turned off.
+	 * @return Previous pattern.
+	 */
+	uint16_t gfx_LinePattern(uint16_t  Pattern);
+	
+	/**
+	 * Sets screen mode (portait, landscape, and reversed).
+	 * @return Previous screen mode.
+	 */
+	Picaso::ScreenMode gfx_ScreenMode(Picaso::ScreenMode ScreenMode);
+	
+	/**
+	 * Turns transparency ON or OFF. Setting is reset to OFF after image or video command.
+	 * @return Previous setting.
+	 */
+	uint16_t gfx_Transparency(uint16_t OnOff);
+	
+	/**
+	 * Sets color to be made transparent.
+	 * @return Previous setting.
+	 */
+	Picaso::Color gfx_TransparentColour(Picaso::Color Color);
+	
+	/**
+	 * Sets one of several graphics attributes. Most attributes can be set by other functions.
+	 * @param Func Attribute to set.
+	 * @param Value Value to set parameter. See GFXSetFunc definition for more information.
+	 */
+	void gfx_Set(Picaso::GFXSetFunc Func, uint16_t Value);
+	
+	/**
+	 * Returns a graphics attribute.
+	 * @return Value of attribute. See GFXGetMode definition for more information.
+	 */
+	uint16_t gfx_Get(Picaso::GFXGetMode Mode);
+	
+	
+	// Media (SD card) commands:
+	
+	/**
+	 * Initializes SD card.
+	 * @return 1 if successful, 0 otherwise.
+	 */
+	uint16_t media_Init(void);
+	
+	/**
+	 * Sets media memory address to a non-sector-aligned byte address in the SD card.
+	 * @param HiWord Upper 2 bytes of address.
+	 * @param LoWord Lower 2 bytes of address.
+	 */
+	void media_SetAdd(uint16_t  HiWord, uint16_t  LoWord);
+	
+	/**
+	 * Sets media memory address to a sector in the SD card.
+	 * @param HiWord Upper 2 bytes of address.
+	 * @param LoWord Lower 2 bytes of address.
+	 */
+	void media_SetSector(uint16_t  HiWord, uint16_t  LoWord);
+	
+	/**
+	 * Reads sector of SD card at address previously set by media_SetSector. Afterwards, the sector address is incremented by one.
+	 * @param SectorIn Array to hold sector data (512 bytes).
+	 * @return 1 if successful, 0 if failed.
+	 */
+	uint16_t media_RdSector(char* SectorIn);
+	
+	/**
+	 * Writes sector of SD card at address previously set by media_SetSector. Afterwards, the sector address is incremented by one.
+	 * @param SectorOut Array with sector data to write (512 bytes).
+	 * @return 1 if successful, 0 if failed.
+	 */
+	uint16_t media_WrSector(char* SectorOut);
+	
+	/**
+	 * Reads byte from SD card at address previously set by media_SetAdd. Afterwards, the byte address is incremented by one.
+	 * @return Byte read (lower 8 bits of word returned).
+	 */
+	uint16_t media_ReadByte(void);
+	
+	/**
+	 * Writes byte to SD card at address previously set by media_SetAdd. Afterwards, the byte address is incremented by one.
+	 * @param Byte to write (in lower 8 bits of argument).
+	 * @return Nonzero if successful, 0 if failed.
+	 */
+	uint16_t media_WriteByte(uint16_t  Byte);
+	
+	/**
+	 * Reads word from SD card at address previously set by media_SetAdd. Afterwards, the byte address is incremented by one.
+	 * @return Word read.
+	 */
+	uint16_t media_ReadWord(void);
+	
+	/**
+	 * Writes byte to SD card at address previously set by media_SetAdd. Afterwards, the byte address is incremented by one.
+	 * @param Word to write.
+	 * @return Nonzero if successful, 0 if failed.
+	 */
+	uint16_t media_WriteWord(uint16_t  Word);
+	
+	/**
+	 * Finalizes writing to sector. This is automatically called if writing rolls over into the next sector.
+	 * @return Nonzero if successful, 0 of failed.
+	 */
+	uint16_t media_Flush(void);
+	
+	/**
+	 * Displays RAW image from SD card at at the address specified by one of the set address commands.
+	 * @param X,Y Coordinates of top left position of image on screen.
+	 */
+	void media_Image(uint16_t  X, uint16_t  Y);
+	
+	/**
+	 * Displays RAW video clip from SD card at at the address specified by one of the set address commands. All other processes on display are blocked until video is finished.
+	 * @param X,Y Coordinates of top left position of video on screen.
+	 */
+	void media_Video(uint16_t  X, uint16_t  Y);
+	
+	/**
+	 * Displays individual frame of RAW video clip from SD card at at the address specified by one of the set address commands.
+	 * @param X,Y Coordinates of top left position of frame on screen.
+	 * @param Framenumber Number of frame to be displayed.
+	 */
+	void media_VideoFrame(uint16_t  X, uint16_t  Y, uint16_t  Framenumber);
+	
+	
+	// File commands:
+	
+	/**
+	 * Returns most recent file operation error code.
+	 */
+	Picaso::FileError file_Error(void);
+	
+	/**
+	 * Returns the number of files that match the given (null-terminated) Filename string. In the string, '*' can represent any combination of allowable characters,
+	 * while '?' matches any single allowable character. Filenames must be 8.3 format.
+	 */
+	uint16_t file_Count(char * Filename);
+	
+	/**
+	 * Prints on the screen the names of files that match the given (null-terminated) Filename string. In the string, '*' can represent any combination of allowable characters,
+	 * while '?' matches any single allowable character. Filenames must be 8.3 format.
+	 * @return Number of matching files found.
+	 */
+	uint16_t file_Dir(char * Filename);
+	
+	/**
+	 * Prints on the screen the name of the first file that matches the given (null-terminated) Filename string. In the string, '*' can
+	 * represent any combination of allowable characters, while '?' matches any single allowable character. Filenames must be 8.3 format.
+	 * @return 1 if at least one matching file is found, 0 otherwise.
+	 */
+	uint16_t file_FindFirst(char *Filename);
+	
+	/**
+	 * Finds the name of the first file that matches the given (null-terminated) Filename string. In the string, '*' can
+	 * represent any combination of allowable characters, while '?' matches any single allowable character. Filenames must be 8.3 format.
+	 * @param Filename String containing filename pattern to be matched.
+	 * @param StringIn Character buffer to hold the returned filename. Returned string is not null-terminated.
+	 * @return Length of returned filename string.
+	 */
+	uint16_t file_FindFirstRet(char *Filename, char* StringIn);
+	
+	/**
+	 * Prints on the screen the name of the next file to match the pattern provided in a previous call to file_FindFirst or file_FindFirstRet.
+	 * @return 1 if at least one matching file is found, 0 otherwise.
+	 */
+	uint16_t file_FindNext(void);
+	
+	/**
+	 * Finds the name of the next file to match the pattern provided in a previous call to file_FindFirst or file_FindFirstRet.
+	 * @param StringIn Character buffer to hold the returned filename. Returned string is not null-terminated.
+	 * @return Length of returned filename string.
+	 */
+	uint16_t file_FindNextRet(char * StringIn);
+	
+	/**
+	 * Returns whether a file with a given (null-terminated) filename exists.
+	 * @return 1 if found, 0 if not.
+	 */
+	uint16_t file_Exists(char *Filename);
+	
+	/**
+	 * Opens file.
+	 * @param Filename Null-terminated string with name of file.
+	 * @param Mode 'r' for read, 'w' for write, 'a' for append.
+	 * @return File handle (if file exists).
+	 */
+	uint16_t file_Open(char * Filename, char  Mode);
+	
+	/**
+	 * Closes file.
+	 * @param Handle File handle.
+	 * @return 1 if successfully closed, 0 if not.
+	 */
+	uint16_t file_Close(uint16_t  Handle);
+	
+	/**
+	 * Reads bytes from file.
+	 * @param Data Buffer to contain data read.
+	 * @param Size Number of bytes to read.
+	 * @param Handle File handle.
+	 * @return Number of bytes read.
+	 */
+	uint16_t file_Read(char* Data, uint16_t Size, uint16_t Handle);
+	
+	/**
+	 * Sets internal file pointer to a specified position in a file.
+	 * @param Handle File handle.
+	 * @param HiWord Upper 16 bits of pointer.
+	 * @param LoWord Lower 16 bits of pointer.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t file_Seek(uint16_t  Handle, uint16_t  HiWord, uint16_t  LoWord);
+	
+	/**
+	 * Sets file pointer to a particular record within a file (e.g. a record size of 1000 and an index of 9 will set the pointer to position 9000).
+	 * @param Handle File handle.
+	 * @param HiSize Upper 16 bits of record size.
+	 * @param LoSize Lower 16 bits of record size.
+	 * @param Recordnum Index of desired record.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t file_Index(uint16_t  Handle, uint16_t  HiSize, uint16_t  LoSize, uint16_t  Recordnum);
+	
+	/**
+	 * Returns the current position of a file pointer.
+	 * @param Handle File handle.
+	 * @param HiWord Pointer to word in which to store the upper 16 bits of the returned pointer value.
+	 * @param LoWord Pointer to word in which to store the lower 16 bits of the returned pointer value.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t file_Tell(uint16_t  Handle, uint16_t *  HiWord, uint16_t *  LoWord);
+	
+	/**
+	 * Writes bytes to file.
+	 * @param Size Number of bytes to be written.
+	 * @param Source Array containing data to be written.
+	 * @param Handle File handle.
+	 * @return Number of bytes written.
+	 */
+	uint16_t file_Write(uint16_t  Size, char*  Source, uint16_t  Handle);
+	
+	/**
+	 * Returns the size of a file.
+	 * @param Handle File handle.
+	 * @param HiWord Pointer to variable in which to store the upper 16 bits of the returned file size.
+	 * @param LoWord Pointer to variable in which to store the lower 16 bits of the returned file size.
+	 * @return 1 if succesful, 0 if not.
+	 */
+	uint16_t file_Size(uint16_t  Handle, uint16_t *  HiWord, uint16_t *  LoWord);
+	
+	/**
+	 * Displays image from file on screen. If the file contains more than one image, each can be accessed with the file_Seek command.
+	 * @param X,Y coordinates of top-left corner of image on display.
+	 * @param Handle File handle.
+	 * @return File error code (see file_Error).
+	 */
+	uint16_t file_Image(uint16_t  X, uint16_t  Y, uint16_t  Handle);
+	
+	/**
+	 * Captures an area of the screen and writes it to a file.
+	 * @param X,Y Coordinates of top-left corner of area to be captured.
+	 * @param Width, Height Width and height of area to be captured.
+	 * @param Handle Handle of file to be written. Image is written at the current pointer location in the file, so multiple images can be captured to the same file.
+	 * @return 0 if successful.
+	 */
+	uint16_t file_ScreenCapture(uint16_t  X, uint16_t  Y, uint16_t  Width, uint16_t  Height, uint16_t  Handle);
+	
+	/**
+	 * Writes character to file.
+	 * @param Character Character to be written.
+	 * @param Handle File handle.
+	 * @return Number of bytes successfully written.
+	 */
+	uint16_t file_PutC(char  Character, uint16_t  Handle);
+	
+	/**
+	 * Reads character from file.
+	 */
+	char file_GetC(uint16_t  Handle);
+	
+	/**
+	 * Writes word (2 bytes) to file.
+	 * @return Number of bytes successfully written.
+	 */
+	uint16_t file_PutW(uint16_t  Word, uint16_t  Handle);
+	
+	/**
+	 * Reads word from file.
+	 */
+	uint16_t file_GetW(uint16_t  Handle);
+	
+	/**
+	 * Writes (null-terminated) string to file.
+	 * @return Number of characters written (excluding null character).
+	 */
+	uint16_t file_PutS(char * StringOut, uint16_t  Handle);
+	
+	/**
+	 * Reads line of text from file. Characters are read until a newline or eof is reached, or the specified maximum size is reached. Returned string is not null-terminated.
+	 * @param StringIn Character array in which to store read string.
+	 * @param Size maximum number of characters to be read.
+	 * @param Handle File handle.
+	 * @return Number of characters read.
+	 */
+	uint16_t file_GetS(char * StringIn, uint16_t  Size, uint16_t  Handle);
+	
+	/**
+	 * Deletes file from disk.
+	 * @param Filename Name of file to be erased.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t file_Erase(char * Filename);
+	
+	/**
+	 * Resets file pointer to beginning of file.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t file_Rewind(uint16_t  Handle);
+	
+	/**
+	 * Loads 4DGL function (.4FN) or program (.4XE) from file to memory.
+	 * @return Pointer/handle to loaded function.
+	 */
+	uint16_t file_LoadFunction(char *Filename);
+	
+	/**
+	 * Calls a previously-loaded function or program.
+	 * @param Handle Function handle previously returned by file_LoadFunction.
+	 * @param ArgCount Number of arguments passed to function (0-6).
+	 * @param Args array containing arguments to be passed to function.
+	 * @return Value returned by the "main" function.
+	 */
+	uint16_t file_CallFunction(uint16_t  Handle, uint16_t  ArgCount, uint16_t*  Args);
+	
+	/**
+	 * Runs a 4DGL program from a file. This is similar to file_Execute, but afterwards, all memory allocations are released (but not stack and global memory.
+	 * Prior to execution, strings may be loaded with the writeString command.
+	 * @param Filename Null-terminated string containing name of file containing program.
+	 * @param ArgCount Number of arguments to be passed to program.
+	 * @param Args Array of arguments to be passed to program.
+	 * @return Value returned by program.
+	 */
+	uint16_t file_Run(char *Filename, uint16_t  ArgCount, uint16_t*  Args);
+	
+	/**
+	 * Runs a 4DGL program from a file. This is similar to file_Run, except all memory allocations are retained.
+	 * Prior to execution, strings may be loaded with the writeString command.
+	 * @param Filename Null-terminated string containing name of file containing program.
+	 * @param ArgCount Number of arguments to be passed to program.
+	 * @param Args Array of arguments to be passed to program.
+	 * @return Value returned by program.
+	 */
+	uint16_t file_Exec(char *Filename, uint16_t  ArgCount, uint16_t*  Args);
+	
+	/**
+	 * Loads image control file and associated image file. See Serial Command Manual for more information.
+	 * @param Datname String containing control list filename (.dat).
+	 * @param GCIName String containing image filename (.gci).
+	 * @param Mode Mode of operation (0-2).
+	 */
+	uint16_t file_LoadImageControl(char *Datname, char *GCIName, uint16_t  Mode);
+	
+	/**
+	 * Mounts the FAT file system. This must be called before any other file commands.
+	 * @return Non-zero if successful, 0 otherwise.
+	 */
+	uint16_t file_Mount(void);
+	
+	/**
+	 * Unmounts the FAT file system.
+	 */
+	void file_Unmount(void);
+	
+	/**
+	 * Plays .wav audio file.
+	 * @return If successful, number of blocks to play. If not, an error code (see command manual).
+	 */
+	uint16_t file_PlayWAV(char * Filename);
+	
+	/**
+	 * Loads string to memory to be used by a 4DGL program/function.
+	 * @param Handle Pointer to location where string is to be loaded. Initial call should used 0; each subsequent call should use the pointer returned by the previous call.
+	 * @param StringOut Null-terminated string to be loaded.
+	 * @return Pointer to location where string has been loaded.
+	 */
+	uint16_t writeString(uint16_t  Handle, char * StringOut);
+	
+	/**
+	 * Reads string which has been written by a 4DGL program/function. The location is initially written with the writeString command, the pointer is passed to the program
+	 * (which can modify it), and the result is read with this function.
+	 * @param Handle Pointer to string location. This is the same value passed to writeString when the space was initially written.
+	 * @param StringIn Character array in which to store the returned string.
+	 * @return ??--TODO
+	 */
+	uint16_t readString(uint16_t  Handle, char * StringIn);
+	
+	
+	// Sound playback commands:
+	
+	/**
+	 * Sets sound playback volume.
+	 * @param Volume Volume setting (8-127). Any level outside the allowed range will be changed to the closest value within the range.
+	 */
+	void snd_Volume(uint16_t  Volume);
+	
+	/**
+	 * Sets playback sample rate.
+	 * @param Pitch Sample rate (4000-65535). A value of 0 will restore the original sample rate.
+	 */
+	uint16_t snd_Pitch(uint16_t  Pitch);
+	
+	/**
+	 * Sets memory chunk size for wavefile buffer.
+	 * @param Bufsize Buffer size: 0 -> 1024 bytes, 1 -> 2048 bytes, and 2 -> 4096 bytes.
+	 */
+	void snd_BufSize(uint16_t  Bufsize);
+	
+	/**
+	 * Stops sound that is playing, releasing buffers and closing open wav files.
+	 */
 	void snd_Stop(void);
-	void snd_Volume(WORD  Volume);
-	void touch_DetectRegion(WORD  X1, WORD  Y1, WORD  X2, WORD  Y2);
-	void touch_Set(WORD  Mode);
-	void txt_MoveCursor(WORD  Line, WORD  Column);
-	void txt_Set(WORD  Func, WORD  Value);
-	WORD charheight(char  TestChar);
-	WORD charwidth(char  TestChar);
-	WORD file_CallFunction(WORD  Handle, WORD  ArgCount, t4DWordArray  Args);
-	WORD file_Close(WORD  Handle);
-	WORD file_Count(char * Filename);
-	WORD file_Dir(char * Filename);
-	WORD file_Erase(char * Filename);
-	WORD file_Error(void);
-	WORD file_Exec(char *Filename, WORD  ArgCount, t4DWordArray  Args);
-	WORD file_Exists(char *Filename);
-	WORD file_FindFirst(char *Filename);
-	WORD file_FindFirstRet(char *Filename, char * StringIn);
-	WORD file_FindNext(void);
-	WORD file_FindNextRet(char * StringIn);
-	WORD file_GetS(char * StringIn, WORD  Size, WORD  Handle);
-	WORD file_GetW(WORD  Handle);
-	WORD file_Image(WORD  X, WORD  Y, WORD  Handle);
-	WORD file_Index(WORD  Handle, WORD  HiSize, WORD  LoSize, WORD  Recordnum);
-	WORD file_LoadFunction(char *Filename);
-	WORD file_LoadImageControl(char *Datname, char *GCIName, WORD  Mode);
-	WORD file_Mount(void);
-	WORD file_Open(char * Filename, char  Mode);
-	WORD file_PlayWAV(char * Filename);
-	WORD file_PutC(char  Character, WORD  Handle);
-	WORD file_PutS(char * StringOut, WORD  Handle);
-	WORD file_PutW(WORD  Word, WORD  Handle);
-	WORD file_Read(t4DByteArray  Data, WORD  Size, WORD  Handle);
-	WORD file_Rewind(WORD  Handle);
-	WORD file_Run(char *Filename, WORD  ArgCount, t4DWordArray  Args);
-	WORD file_ScreenCapture(WORD  X, WORD  Y, WORD  Width, WORD  Height, WORD  Handle);
-	WORD file_Seek(WORD  Handle, WORD  HiWord, WORD  LoWord);
-	WORD file_Size(WORD  Handle, WORD *  HiWord, WORD *  LoWord);
-	WORD file_Tell(WORD  Handle, WORD *  HiWord, WORD *  LoWord);
-	WORD file_Write(WORD  Size, t4DByteArray  Source, WORD  Handle);
-	WORD gfx_BevelShadow(WORD  Value);
-	WORD gfx_BevelWidth(WORD  Value);
-	WORD gfx_BGcolour(WORD  Color);
-	WORD gfx_Contrast(WORD  Contrast);
-	WORD gfx_FrameDelay(WORD  Msec);
-	WORD gfx_Get(WORD  Mode);
-	WORD gfx_GetPixel(WORD  X, WORD  Y);
-	WORD gfx_LinePattern(WORD  Pattern);
-	WORD gfx_Orbit(WORD  Angle, WORD  Distance, WORD *  Xdest, WORD *  Ydest);
-	WORD gfx_OutlineColour(WORD  Color);
-	WORD gfx_ScreenMode(WORD  ScreenMode);
-	WORD gfx_Slider(WORD  Mode, WORD  X1, WORD  Y1, WORD  X2, WORD  Y2, WORD  Color, WORD  Scale, WORD  Value);
-	WORD gfx_Transparency(WORD  OnOff);
-	WORD gfx_TransparentColour(WORD  Color);
-	WORD img_ClearAttributes(WORD  Handle, WORD  Index, WORD  Value);
-	WORD img_Darken(WORD  Handle, WORD  Index);
-	WORD img_Disable(WORD  Handle, WORD  Index);
-	WORD img_Enable(WORD  Handle, WORD  Index);
-	WORD img_GetWord(WORD  Handle, WORD  Index, WORD  Offset );
-	WORD img_Lighten(WORD  Handle, WORD  Index);
-	WORD img_SetAttributes(WORD  Handle, WORD  Index, WORD  Value);
-	WORD img_SetPosition(WORD  Handle, WORD  Index, WORD  Xpos, WORD  Ypos);
-	WORD img_SetWord(WORD  Handle, WORD  Index, WORD  Offset , WORD  Word);
-	WORD img_Show(WORD  Handle, WORD  Index);
-	WORD img_Touched(WORD  Handle, WORD  Index);
-	WORD media_Flush(void);
-	WORD media_Init(void);
-	WORD media_RdSector(t4DSector  SectorIn);
-	WORD media_ReadByte(void);
-	WORD media_ReadWord(void);
-	WORD media_WriteByte(WORD  Byte);
-	WORD media_WriteWord(WORD  Word);
-	WORD media_WrSector(t4DSector  SectorOut);
-	WORD mem_Free(WORD  Handle);
-	WORD mem_Heap(void);
-	WORD peekM(WORD  Address) ;
-	void pokeM(WORD  Address, WORD  WordValue) ;
-	WORD pin_HI(WORD Pin);
-	WORD pin_LO(WORD Pin);
-	WORD pin_Read(WORD Pin);
-	WORD pin_Set(WORD Mode, WORD Pin);
-	void putCH(WORD  WordChar);
-	WORD putStr(char *InString);
-	WORD readString(WORD  Handle, char * StringIn);
-	WORD snd_Pitch(WORD  Pitch);
-	WORD snd_Playing(void);
-	WORD sys_GetModel(char *ModelStr);
-	WORD sys_GetPmmC(void);
-	WORD sys_GetVersion(void);
-	WORD sys_Sleep(WORD  Units);
-	WORD touch_Get(WORD  Mode);
-	WORD txt_Attributes(WORD  Attribs);
-	WORD txt_BGcolour(WORD  Color);
-	WORD txt_Bold(WORD  Bold);
-	WORD txt_FGcolour(WORD  Color);
-	WORD txt_FontID(WORD  FontNumber);
-	WORD txt_Height(WORD  Multiplier);
-	WORD txt_Inverse(WORD  Inverse);
-	WORD txt_Italic(WORD  Italic);
-	WORD txt_Opacity(WORD  TransparentOpaque);
-	WORD txt_Underline(WORD  Underline);
-	WORD txt_Width(WORD  Multiplier);
-	WORD txt_Wrap(WORD  Position);
-	WORD txt_Xgap(WORD  Pixels);
-	WORD txt_Ygap(WORD  Pixels);
-	WORD writeString(WORD  Handle, char * StringOut);
+	
+	/**
+	 * Pauses sound playback.
+	 */
+	void snd_Pause(void);
+	
+	/**
+	 * Continues any paused sound.
+	 */
+	void snd_Continue(void);
+	
+	/**
+	 * Returns 0 if file has finished playing; otherwise, returns number of 512 byte blocks remaining.
+	 */
+	uint16_t snd_Playing(void);
+	
+	
+	/**
+	 * Specifies region on screen where touches will be detected.
+	 * @param X1,Y1 Coordinates of top-left corner of region.
+	 * @param X2,Y2 Coordinates of bottom-right corner of region.
+	 */
+	void touch_DetectRegion(uint16_t  X1, uint16_t  Y1, uint16_t  X2, uint16_t  Y2);
+	
+	/**
+	 * Sets touchscreen mode.
+	 * @param Mode 0 -> enable touch screen; 1 -> disable touch screen; 2 -> reset touch detect region to full screen. The Picaso::Touch enum also provides the constants.
+	 */
+	void touch_Set(uint16_t  Mode);
+	
+	/**
+	 * Get status of touch screen.
+	 * @param Mode 0 -> get state of touch screen; 1 -> get x coordinate of touch; 2 -> get y coordinate of touch. The Picaso::Touch enum also provides the constants.
+	 * @return In modes 1 and 2, the requested coordinate. In mode 0: 0 -> invalid or no touch; 1 -> press; 2 -> release; 3 -> moving. The Picaso::Touch enum also provides the constants.
+	 */
+	uint16_t touch_Get(uint16_t  Mode);
+	
+	/**
+	 * Sets position of image to be displayed. An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list.
+	 * @param Xpos,Ypos Coordinates of top-left corner of image.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t img_SetPosition(uint16_t  Handle, uint16_t  Index, uint16_t  Xpos, uint16_t  Ypos);
+	
+	/**
+	 * Enables image in list so that it can be displayed with the img_Show command. An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list. -1 or Picaso::ALL selects all images in list.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t img_Enable(uint16_t  Handle, uint16_t  Index);
+	
+	/**
+	 * Disables image from being displayed. An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list. -1 or Picaso::ALL selects all images in list.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t img_Disable(uint16_t  Handle, uint16_t  Index);
+	
+	/**
+	 * Darkens image (call before img_Show). This effect will be reset when img_Show is called a second time.
+	 * An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list. -1 or Picaso::ALL selects all images in list.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t img_Darken(uint16_t  Handle, uint16_t  Index);
+	
+	/**
+	 * Lightens image (call before img_Show). This effect will be reset when img_Show is called a second time.
+	 * An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list. -1 or Picaso::ALL selects all images in list.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t img_Lighten(uint16_t  Handle, uint16_t  Index);
+	
+	/**
+	 * Lightens image (call before img_Show). This effect will be reset when img_Show is called a second time.
+	 * An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list.
+	 * @param Offset Offset of word to write. Note that some parameters are read-only.
+	 * @param Word Word to be written. See Picaso::ImageControlOffset definition or serial command manual for more information.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t img_SetWord(uint16_t  Handle, uint16_t  Index, Picaso::ImageControlOffset Offset, uint16_t  Word);
+	
+	/**
+	 * Reads an image parameter. An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list.
+	 * @param Offset Offset of word to be read.
+	 * @return The word that is read.
+	 */
+	uint16_t img_GetWord(uint16_t  Handle, uint16_t  Index, Picaso::ImageControlOffset Offset);
+	
+	/**
+	 * Displays image from list. An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list.
+	 * @return Nonzero if successful, 0 if not.
+	 */
+	uint16_t img_Show(uint16_t  Handle, uint16_t  Index);
+	
+	/**
+	 * Sets one or more image attribute flags. An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list.
+	 * @param Value Mask of bits to be set. OR together multiple attribute flags to set multiple.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t img_SetAttributes(uint16_t  Handle, uint16_t  Index, Picaso::ImageAttribute Value);
+	
+	/**
+	 * Clears one or more image attribute flags. An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list.
+	 * @param Value Mask of bits to be cleared. OR together multiple attribute flags to clear multiple.
+	 * @return 1 if successful, 0 if not.
+	 */
+	uint16_t img_ClearAttributes(uint16_t  Handle, uint16_t  Index, Picaso::ImageAttribute Value);
+	
+	/**
+	 * Returns whether an image has been touched. An image control must have already been created with the file_LoadImageControl command.
+	 * @param Handle Pointer to image list.
+	 * @param Index Index of image in list.
+	 * @return Image index if touched, -1 if not. If -1 is passed as index, returns index of an image if it is touched.
+	 */
+	uint16_t img_Touched(uint16_t  Handle, uint16_t  Index);
+	
+	/**
+	 * Performs block image transfer onto screen.
+	 * @param X,Y Coordinates of top-left corner of location where image is to be displayed.
+	 * @param Width,Height Width and height of image to be displayed.
+	 * @param Pixels Array of bytes containing pixel data. Each pixel is 16-bits of color information (see Picaso::Color).
+	 */
+	void blitComtoDisplay(uint16_t  X, uint16_t  Y, uint16_t  Width, uint16_t  Height, char*  Pixels);
+	
+	
+	// System commands:
+	
+	/**
+	 * Releases memory block.
+	 * @param Handle Pointer to memory block.
+	 * @return Nonzero if successful, 0 if not.
+	 */
+	uint16_t mem_Free(uint16_t  Handle);
+	
+	/**
+	 * Returns byte size of lergest available memory chunk on the heap.
+	 */
+	uint16_t mem_Heap(void);
+	
+	/**
+	 * Returns contents of memory address. Addresses can be calculated with pointers and offsets, and Picaso::MemAddresses and Picaso::MemOffsets also have some useful values.
+	 */
+	uint16_t peekM(uint16_t  Address) ;
+	
+	/**
+	 * Writes word to memory address. Addresses can be calculated with pointers and offsets, and Picaso::MemAddresses and Picaso::MemOffsets also have some useful values.
+	 */
+	void pokeM(uint16_t  Address, uint16_t  WordValue) ;
+	
+	/**
+	 * Returns display model name as unterminated string.
+	 * @param ModelStr Array of characters in which to store returned string.
+	 * @return Number of characters in returned string.
+	 */
+	uint16_t sys_GetModel(char *ModelStr);
+	
+	/**
+	 * Returns version of the SPE (Serial Programming Environment) installed on the display.
+	 */
+	uint16_t sys_GetVersion(void);
+	
+	/**
+	 * Returns version of the PmmC (firmware) installed on the display.
+	 */
+	uint16_t sys_GetPmmC(void);
+	
+	/**
+	 * Puts display and processor in low-power state for specified period of time.
+	 * @param Units If 1-65535, sleeps for that many units of time (each unit is approximately 1 second). If 0, sleeps forever (needs to be reset).
+	 */
+	uint16_t sys_Sleep(uint16_t  Units);
+	
+	
+	// I/O commands:
+	
+	/**
+	 * Returns value of bus pins (in lower 8 bits of returned value).
+	 */
+	uint16_t bus_In(void);
+	
+	/**
+	 * Sets value of bus pins. Bus pins must first be set to output.
+	 * @param Bits Value to write to pins in lower 8 bits. Upper 8 bits are ignored.
+	 */
+	void bus_Out(uint16_t Bits);
+	
+	/**
+	 * Reads bus pins. The BUS_RD pin is set low, pins are set after a 50ns delay, and finally the BUS_RD pin is set high again.
+	 */
+	uint16_t bus_Read(void);
+	
+	/**
+	 * Sets directions of bus pins.
+	 * Lower 8 bits contain pin directions. 1 -> input, 0 -> output. Upper 8 bits are ignored.
+	 */
+	void bus_Set(uint16_t IOMap);
+	
+	/**
+	 * Writes to bus. Bus pins must first be set to output. Lower 8 bits of argument are written to pins, and then the BUS_WR pin is brought low for approximately 50ns.
+	 */
+	void bus_Write(uint16_t Bits);
+	
+	/**
+	 * Sets a pin high. If the pin is not already an output, it is made an output.
+	 * @return 1 if the pin number was legal.
+	 */
+	uint16_t pin_HI(Picaso::Pin Pin);
+	
+	/**
+	 * Sets a pin low. If the pin is not already an output, it is made an output.
+	 * @return 1 if the pin number was legal.
+	 */
+	uint16_t pin_LO(Picaso::Pin Pin);
+	
+	/**
+	 * Reads a pin.
+	 */
+	uint16_t pin_Read(Picaso::Pin Pin);
+	
+	/**
+	 * Sets a pin as an input or an output.
+	 * @param Mode 1 or Picaso::INPUT for input, 0 or Picaso::OUTPUT for output.
+	 * @param Pin Pin to be set.
+	 * @return 1 if pin number is legal.
+	 */
+	uint16_t pin_Set(uint16_t Mode, Picaso::Pin Pin);
+	
+	
+	
+	// Serial communication command:
+	
+	/**
+	 * Set baud rate of serial interface with display.
+	 */
+	void setbaudWait(Picaso::BaudRate Newrate);
+	
+	
 
 	private:
 	
@@ -198,30 +1263,28 @@
 	
 	void WriteBytes(char* psOutput, int count);
 	void WriteChars(char* psOutput);
-	void WriteWords(WORD* source, int count);
+	void WriteWords(uint16_t* source, int count);
 	int ReadSerPort(char *psData, int iMax);
 	void getbytes(char *data, int size);
 	void GetAck();
-	WORD GetWord();
+	uint16_t GetWord();
 	void getString(char *outStr, int strLen);
-	WORD GetAckResp();
-	WORD WaitForAck();
-	WORD GetAckRes2Words(WORD * word1, WORD * word2);
-	void GetAck2Words(WORD * word1, WORD * word2);
-	WORD GetAckResSector(t4DSector Sector);
-	WORD GetAckResStr(char * OutStr);
-	WORD GetAckResData(t4DByteArray OutData, WORD size);
-	void SetThisBaudrate(uLCD_4D_Picaso::BaudRate NewRate);
+	uint16_t GetAckResp();
+	uint16_t WaitForAck();
+	uint16_t GetAckRes2Words(uint16_t * word1, uint16_t * word2);
+	void GetAck2Words(uint16_t * word1, uint16_t * word2);
+	uint16_t GetAckResSector(char* Sector);
+	uint16_t GetAckResStr(char * OutStr);
+	uint16_t GetAckResData(char* OutData, uint16_t size);
+	void SetThisBaudrate(Picaso::BaudRate NewRate);
 	
 	void LCD_wait_ms(int ms);
 	void rxFlush();
 	
-	// 4D Global variables
 	int Error4D ;  			// Error indicator,  used and set by Intrinsic routines
 	int TimeLimit4D;		// time limit in ms for total serial command duration, 2000 (2 seconds) should be adequate for most commands
 	                        // assuming a reasonable baud rate AND low latency AND 0 for the Serial Delay Parameter
 	                        // temporary increase might be required for very long (bitmap write, large image file opens)
-	                        // or indeterminate (eg file_exec, file_run, file_callFunction)  commands// Error callback. Set to NULL if no callback is required. i.e. all errors will be handled in your code
-
+	                        // or indeterminate (eg file_exec, file_run, file_callFunction)  commands
 };
 #endif
\ No newline at end of file