forked from jinschoi/SphereBot
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from tgolla/TouchscreenV2
Touchscreen Prerelease v1.9
- Loading branch information
Showing
26 changed files
with
14,995 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"sketch": "SphereBot.ino", | ||
"board": "arduino:avr:mega", | ||
"port": "COM6", | ||
"port": "COM3", | ||
"configuration": "cpu=atmega2560" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/* | ||
AlphabeticSDFileList.h - Library for listing SD files in a directory on alphabetic order. | ||
Created by Terence F. Golla, April 17, 2022 | ||
Released into the public domain. | ||
*/ | ||
|
||
#include "AlphabeticSDFileList.h" | ||
|
||
AlphabeticSDFileList::AlphabeticSDFileList() { } | ||
|
||
void AlphabeticSDFileList::Begin(SdFat &SdFat, char *directory, bool contiguous) | ||
{ | ||
AlphabeticSDFileList::SD = &SdFat; | ||
AlphabeticSDFileList::contiguous = contiguous; | ||
AlphabeticSDFileList::directory = directory; | ||
|
||
strcpy(first, ""); | ||
strcpy(last, ""); | ||
strcpy(current, ""); | ||
|
||
char filename[DEFAULT_FILE_NAME_SIZE]; | ||
|
||
File directoryFile = SD->open(directory); | ||
|
||
while (true) { | ||
File file = directoryFile.openNextFile(); | ||
|
||
if (!file) { | ||
// no more files | ||
break; | ||
} | ||
|
||
file.getName(filename, DEFAULT_FILE_NAME_SIZE); | ||
|
||
if (!file.isDirectory()) { | ||
if (strcmp(first, "") == 0) { | ||
strcpy(first, filename); | ||
} | ||
else { | ||
if (strcmp(filename, first) < 0) { | ||
strcpy(first, filename); | ||
} | ||
else { | ||
if (strcmp(filename, last) > 0) { | ||
strcpy(last, filename); | ||
} | ||
} | ||
} | ||
} | ||
|
||
file.close(); | ||
} | ||
} | ||
|
||
char* AlphabeticSDFileList::First() | ||
{ | ||
return first; | ||
} | ||
|
||
char* AlphabeticSDFileList::Last() | ||
{ | ||
return last; | ||
} | ||
|
||
char* AlphabeticSDFileList::Current() | ||
{ | ||
return current; | ||
} | ||
|
||
char* AlphabeticSDFileList::Previous() | ||
{ | ||
char filename[DEFAULT_FILE_NAME_SIZE]; | ||
char previous[DEFAULT_FILE_NAME_SIZE]; | ||
|
||
strcpy(previous, ""); | ||
|
||
if (strcmp(current, "") == 0) | ||
strcpy(current, "\x7F"); | ||
|
||
File directoryFile = SD->open(directory); | ||
|
||
while (true) { | ||
File file = directoryFile.openNextFile(); | ||
|
||
if (!file) { | ||
// no more files | ||
break; | ||
} | ||
|
||
file.getName(filename, DEFAULT_FILE_NAME_SIZE); | ||
|
||
if (!file.isDirectory()) { | ||
if (strcmp(filename, current) < 0) { | ||
if (strcmp(previous, "") == 0) { | ||
strcpy(previous, filename); | ||
} | ||
else { | ||
if (strcmp(filename, previous) > 0) { | ||
strcpy(previous, filename); | ||
} | ||
} | ||
} | ||
} | ||
|
||
file.close(); | ||
} | ||
|
||
if (contiguous && strcmp(previous, "") == 0) | ||
strcpy(previous, last); | ||
|
||
strcpy(current, previous); | ||
return current; | ||
} | ||
|
||
char* AlphabeticSDFileList::Next() | ||
{ | ||
char filename[DEFAULT_FILE_NAME_SIZE]; | ||
char next[DEFAULT_FILE_NAME_SIZE]; | ||
|
||
strcpy(next, ""); | ||
|
||
File directoryFile = SD->open(directory); | ||
|
||
while (true) { | ||
File file = directoryFile.openNextFile(); | ||
|
||
if (!file) { | ||
// no more files | ||
break; | ||
} | ||
|
||
file.getName(filename, DEFAULT_FILE_NAME_SIZE); | ||
|
||
if (!file.isDirectory()) { | ||
if (strcmp(filename, current) > 0) { | ||
if (strcmp(next, "") == 0) { | ||
strcpy(next, filename); | ||
} | ||
else { | ||
if (strcmp(filename, next) < 0) { | ||
strcpy(next, filename); | ||
} | ||
} | ||
} | ||
} | ||
|
||
file.close(); | ||
} | ||
|
||
if (contiguous && strcmp(next, "") == 0) | ||
strcpy(next, first); | ||
|
||
strcpy(current, next); | ||
return current; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
AlphabeticSDFileList.h - Library for listing SD files in a directory on alphabetic order. | ||
Created by Terence F. Golla, April 17, 2022 | ||
Released into the public domain. | ||
*/ | ||
|
||
#ifndef AlphabeticSDFileList_h | ||
#define AlphabeticSDFileList_h | ||
|
||
#include <Arduino.h> | ||
#include <SdFat.h> // SD card & FAT filesystem library. | ||
|
||
#define DEFAULT_FILE_NAME_SIZE 32 | ||
|
||
class AlphabeticSDFileList | ||
{ | ||
public: | ||
AlphabeticSDFileList(); | ||
void Begin(SdFat &SD, char *directory, bool contiguous); | ||
char* First(); | ||
char* Last(); | ||
char* Current(); | ||
char* Previous(); | ||
char* Next(); | ||
private: | ||
SdFat *SD; | ||
char first[DEFAULT_FILE_NAME_SIZE]; | ||
char last[DEFAULT_FILE_NAME_SIZE]; | ||
char current[DEFAULT_FILE_NAME_SIZE]; | ||
bool contiguous; | ||
char* directory; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.