Rihards Balass / 4DGL-mbed-32PTU
Revision:
12:29f5ad896382
Parent:
11:3ebd2263f3e9
Child:
13:1a0800957412
diff -r 3ebd2263f3e9 -r 29f5ad896382 Picaso_4DGL-32PTU.h
--- a/Picaso_4DGL-32PTU.h	Tue Sep 13 11:37:04 2016 +0000
+++ b/Picaso_4DGL-32PTU.h	Wed Sep 14 13:27:37 2016 +0000
@@ -22,18 +22,22 @@
 #define DEBUGMODE 1
 #endif
 
+#ifndef DEMO
+#define DEMO 1
+#endif
+
 // functions
 #define CHECK_BIT(var,pos) ((var) & (1<<(pos))) // to check if required bit is set
 
 // Common WAIT value in millisecond
-#define TEMPO 1
+#define TEMPO       1
+#define MAX_WAIT    10
 
-// Main Functions values
-#define CLS                 0xFFCD
+// Main commands
 #define BAUDRATE            0x0026
 #define ORIENTATION         0xFF9E
 
-// text functions values
+// text commands
 #define TEXT_BG_COLOR       0xFFE6
 #define SET_FONT            0xFFE5
 #define PUT_CHAR            0xFFFE
@@ -51,7 +55,7 @@
 #define TEXT_UNDERLINE      0xFFDB
 #define TEXT_ATTRIBUTES     0xFFDA
 
-// graphics functions values
+// graphics commands
 #define CHANGE_COLOR        0xFFB4
 #define DRAW_CIRCLE         0xFFC3
 #define CIRCLE_FILLED       0xFFC2
@@ -87,8 +91,14 @@
 #define TRANSPARENT_COLOR   0xFFA1
 #define SET_GRAPHICS        0xFFCE
 #define GET_GRAPHICS        0xFFA6
+#define CLS                 0xFFCD
 
-
+// media commands
+#define MEDIA_INIT          0xFF89
+#define MEDIA_SET_ADD       0xFF93
+#define MEDIA_SET_SECTOR    0xFF92
+#define MEDIA_READ_SECTOR   0x0016
+#define MEDIA_WRITE_SECTOR  0x0017
 
 
 // Screen answers
@@ -181,9 +191,11 @@
 #define font2           2
 #define font3           3
 // Receive buffer length
-#define RXBUFLEN        32
+#define RXBUFLEN        525
+#define BUFFER_SIZE     512
 // 3D states
 #define DEPRESSED   0
+#define RECESSED    0
 #define INDENTED    0
 #define RAISED      1
 #define HIDDEN      2
@@ -214,19 +226,24 @@
     PICASO_4DGL(PinName tx, PinName rx, PinName rst); // LCD serial construnctor
     int index; // received response from screen
     short Xdest, Ydest;
-    char response[];
+    char buffer[];
     char rxBuf[];
+    char currentFont; // stores current used font
+    char currentMode; // stores current orientation
     
 // General Commands
     void rxCallback();
-    void getResponse(int); // wait for LCD response
-    void calculateOrbitResponse(); // wait for LCD response
+    bool getResponse(int); // wait for LCD response
+    bool calculateOrbitResponse(); // wait for LCD response
     short getGraphicsResponse(); // wait for LCD response
+    short mediaInitResponse(); // response from mediaInit command
+    bool readSectorResponse(int); // response from mediaInit command
     void reset(); // reset screen
     void baudrate(long); // set baudrate
-    void mainDemo(); // play demo with text based functions
+    void mainDemo(); // play demo with main functions
     void textDemo(); // play demo with text based functions
-    void graphicsDemo(); // play demo with text based functions
+    void graphicsDemo(); // play demo with graphics based functions
+    void mediaDemo(); // play demo with media based functions
 
 // Graphics Commands
     void cls(); // clear screen
@@ -267,6 +284,13 @@
     void setGraphics(short, short); // set graphics parameters
     short getGraphics(short); // get graphics parameters
     
+// Media Commands
+    short media_Init(); // initialise memory card
+    bool media_SetAdd(int); // set byte address
+    bool media_SetSector(int); // set sector address
+    bool media_ReadSector(); // read sector
+    bool media_WriteSector(char *); // write sector
+
 // Texts Commands
     void setFont(char); // set desired font from embedded fonts
     char moveCursor(short, short); // move cursot to a specific location
@@ -286,9 +310,6 @@
     void textUnderline(short); // set text to underline
     void textAttributes(short); // set 4 attributes (bold, italic, inverse, underline)
 
-// Text data
-    char currentFont; // stores current used font
-    char currentOrientation; // stores current orientation
     
 protected :