mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 19:36:26 +02:00
[ES] Added showFile function
Signed-óff-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -113,6 +113,9 @@ unsigned char font[95][6] =
|
|||||||
{ 0x10, 0x08, 0x08, 0x10, 0x08, 0x00 } // ~
|
{ 0x10, 0x08, 0x08, 0x10, 0x08, 0x00 } // ~
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// tmp vars
|
||||||
|
int readStringLength = 0;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
@ -147,16 +150,16 @@ void setup()
|
|||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// write my data
|
// write my data
|
||||||
printString(9, 33, "Jim");
|
printString(9, 33, "Jim", 3);
|
||||||
printString(19, 21, "Martens");
|
printString(19, 21, "Martens", 7);
|
||||||
printString(29, 21, "6420323");
|
printString(29, 21, "6420323", 7);
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
resetBuffer();
|
resetBuffer();
|
||||||
delay(5000);
|
delay(5000);
|
||||||
// write his data
|
// write his data
|
||||||
printString(9, 21, "Joachim");
|
printString(9, 21, "Joachim", 7);
|
||||||
printString(19, 6, "Schmidberger");
|
printString(19, 6, "Schmidberger", 12);
|
||||||
printString(29, 21, "6536496");
|
printString(29, 21, "6536496", 7);
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
resetBuffer();
|
resetBuffer();
|
||||||
delay(5000);
|
delay(5000);
|
||||||
@ -330,6 +333,8 @@ const char* readString(File file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readStringLength = i;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -372,3 +377,27 @@ void handleCommand(String command)
|
|||||||
showFile(parameter);
|
showFile(parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the given file.
|
||||||
|
*
|
||||||
|
* @param String fileName
|
||||||
|
*/
|
||||||
|
void showFile(String fileName)
|
||||||
|
{
|
||||||
|
bool isTextFile = false;
|
||||||
|
int extPos = fileName.indexOf('.');
|
||||||
|
String ext = fileName.substring(extPos + 1);
|
||||||
|
isTextFile = (ext == "txt");
|
||||||
|
|
||||||
|
if (SD.exists(fileName)) {
|
||||||
|
File file = SD.open(fileName);
|
||||||
|
if (isTextFile) {
|
||||||
|
const char* text = readString(file);
|
||||||
|
printString(0, 0, text, readStringLength);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO handle image file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user