4D systems Picaso uLCD 32PTU touch display library

Revision:
22:cea582ea74c1
Parent:
21:ea68a8a3cea4
Child:
23:dd2c28fa4dfd
--- a/Picaso_4DGL-32PTU_File.cpp	Mon Sep 26 13:41:22 2016 +0000
+++ b/Picaso_4DGL-32PTU_File.cpp	Tue Sep 27 08:48:08 2016 +0000
@@ -86,6 +86,126 @@
     return error;
 }
 
+//**************************************************************************
+// Returns number of files found that match the criteria.
+// The wild card character '*' matches up with any combination of allowable
+// characters and '?' matches up with any single allowable character.
+//**************************************************************************
+short PICASO_4DGL :: file_Count(char *filename) {
+    
+    int size = 3 + strlen(filename);
+    int i, k, j = 2;
+    char *command;
+    command = (char *)malloc(sizeof(char) * size);
+    for(i = 0; i < size; i++) command[i] = 0;
+    
+    command[0] = (FILE_COUNT >> (8*1)) & 0xff;
+    command[1] = (FILE_COUNT >> (8*0)) & 0xff;
+    for (k = 0; k < size-1; k++) command[j++] = filename[k];
+    command[j] = 0;
+    
+    writeCOMMAND(command, size);
+    short success = fileCountResponse();
+    free(command);
+#ifdef DEBUGMODE
+    pc.printf("\n\r DEBUG: %s count = %i\n\r", filename, success);
+#endif
+    return success;
+}
+
+//**************************************************************************
+// Lists the stream of file names that agree with the search key on the Display Screen.
+// Returns number of files found that match the criteria.
+// The wild card character '*' matches up with any combination of allowable characters
+// and '?' matches up with any single allowable character.
+// 
+// Note: “Find First File and Report” and “Find Next File and Report” are
+// recommended alternatives in order to return the responses.
+//**************************************************************************
+short PICASO_4DGL :: file_Dir(char *filename) {
+    
+    int size = 3 + strlen(filename);
+    int i, k, j = 2;
+    char *command;
+    command = (char *)malloc(sizeof(char) * size);
+    for(i = 0; i < size; i++) command[i] = 0;
+    
+    command[0] = (FILE_DIR >> (8*1)) & 0xff;
+    command[1] = (FILE_DIR >> (8*0)) & 0xff;
+    for (k = 0; k < size-1; k++) command[j++] = filename[k];
+    command[j] = 0;
+    
+    writeCOMMAND(command, size);
+    short success = fileCountResponse();
+    free(command);
+#ifdef DEBUGMODE
+    pc.printf("\n\r DEBUG: %s count = %i\n\r", filename, success);
+#endif
+    return success;
+}
+
+//**************************************************************************
+// Returns true if at least 1 file exists that satisfies the file argument.
+// Wildcards are usually used so if the “Find First File” command returns true,
+// further tests can be made using the “Find Next File” command to find all 
+// the files that match the wildcard class. 
+// Note that the filename is printed on the screen.
+// 
+// Note: “Find First File and Report” and “Find Next File and Report” are
+// recommended alternatives in order to return the responses.
+//**************************************************************************
+void PICASO_4DGL :: file_FindFirst(char *filename) {
+    
+    int size = 3 + strlen(filename);
+    int i, k, j = 2;
+    char *command;
+    command = (char *)malloc(sizeof(char) * size);
+    for(i = 0; i < size; i++) command[i] = 0;
+    
+    command[0] = (FILE_FIRST >> (8*1)) & 0xff;
+    command[1] = (FILE_FIRST >> (8*0)) & 0xff;
+    for (k = 0; k < size-1; k++) command[j++] = filename[k];
+    command[j] = 0;
+    
+    writeCOMMAND(command, size);
+    bool success = writeSectorResponse(3);
+    free(command);
+#ifdef DEBUGMODE
+    pc.printf("\n\r DEBUG: %s count = %s\n\r", filename, success ? " true" : "false");
+#endif
+}
+
+//**************************************************************************
+// The Find First File and Report command returns the length of the filename
+// and the filename if at least 1 file exists that matches the criteria.
+// 
+// Wildcards are usually used so if Find First File and Report command
+// returns the stringlength and filename, further tests can be made using
+// “Find Next File” or “Find Next File and Report” commands to find all the files
+// that match the wildcard class.
+//**************************************************************************
+char *PICASO_4DGL :: file_FindFirstRet(char *name) {
+    
+    int size = 3 + strlen(name);
+    int i, k, j = 2;
+    char *command;
+    command = (char *)malloc(sizeof(char) * size);
+    for(i = 0; i < size; i++) command[i] = 0;
+    
+    command[0] = (FILE_FIRST_RET >> (8*1)) & 0xff;
+    command[1] = (FILE_FIRST_RET >> (8*0)) & 0xff;
+    for (k = 0; k < size-1; k++) command[j++] = name[k];
+    command[j] = 0;
+    
+    writeCOMMAND(command, size);
+    char filename[FILENAME_LENGTH]; // create filename array
+    
+    free(command);
+#ifdef DEBUGMODE
+    pc.printf("\n\r DEBUG: %s count = %s\n\r", filename, success ? " true" : "false");
+#endif
+    return filename;
+}