4D systems Picaso uLCD 32PTU touch display library

Revision:
27:dbf79d116497
Parent:
26:c6a803706a42
--- a/Picaso_4DGL-32PTU_File.cpp	Wed Sep 28 12:41:32 2016 +0000
+++ b/Picaso_4DGL-32PTU_File.cpp	Thu Sep 29 19:40:53 2016 +0000
@@ -82,7 +82,7 @@
     writeCOMMAND(command, 2);
     short error = fileErrorResponse();
 #ifdef DEBUGMODE
-    pc.printf("\n\r DEBUG: FAT16 Error: %i\n\r", error);
+    //pc.printf("\n\r DEBUG: FAT16 Error: %i\n\r", error);
 #endif
     return error;
 }
@@ -507,8 +507,8 @@
 
     char command[4] = "";
     
-    command[0] = (FILE_TELL >> (8*1)) & 0xff;
-    command[1] = (FILE_TELL >> (8*0)) & 0xff;
+    command[0] = (FILE_SIZE >> (8*1)) & 0xff;
+    command[1] = (FILE_SIZE >> (8*0)) & 0xff;
     command[2] = (handle >> (8*1)) & 0xff;
     command[3] = (handle >> (8*0)) & 0xff;
     writeCOMMAND(command, 4);
@@ -579,6 +579,55 @@
     return success;
 }
 
+//**************************************************************************
+// This function reads a word (2 bytes) from the file, at the position indicated 
+// by the associated file-position pointer (set by the “File Seek” or “File Index” commands) 
+// and advances the pointer appropriately (incremented by 2). The file must be 
+// previously opened with 'r' (read) mode.
+//**************************************************************************
+short PICASO_4DGL :: file_GetW(short handle) {
+
+    char command[4] = "";
+    
+    command[0] = (FILE_GET_W >> (8*1)) & 0xff;
+    command[1] = (FILE_GET_W >> (8*0)) & 0xff;
+    command[2] = (handle >> (8*1)) & 0xff;
+    command[3] = (handle >> (8*0)) & 0xff;
+    writeCOMMAND(command, 4);
+    
+    short word = fileErrorResponse(); // get 2 bytes from file
+#ifdef DEBUGMODE
+    pc.printf("\n\r DEBUG: Read word = %i\n\r", word);
+#endif
+    return word;
+}
+
+//**************************************************************************
+// This function reads a line of text from a file at the current file position 
+// indicated by the associated file-position pointer (set by the “File Seek” 
+// or “File Index” commands) and advances the pointer appropriately. 
+// Characters are read until either a newline or an EOF is received or until 
+// the specified maximum "size" is reached. In all cases, the string is null 
+// terminated. The file must be previously opened with 'r' (read) mode.
+//**************************************************************************
+short PICASO_4DGL :: file_GetS(short size, short handle, char *str) {
+
+    char command[6] = "";
+    
+    command[0] = (FILE_GET_S >> (8*1)) & 0xff;
+    command[1] = (FILE_GET_S >> (8*0)) & 0xff;
+    command[2] = (size >> (8*1)) & 0xff;
+    command[3] = (size >> (8*0)) & 0xff;
+    command[4] = (handle >> (8*1)) & 0xff;
+    command[5] = (handle >> (8*0)) & 0xff;
+    writeCOMMAND(command, 6);
+    
+    short count = getFilenameResponse(str); // get specified count of bytes from file
+#ifdef DEBUGMODE
+    //pc.printf("\n\r DEBUG: Read %i bytes from %i\n\r", count, handle);
+#endif
+    return count;
+}
 
 
 
@@ -587,3 +636,4 @@
 
 
 
+