I was working on an Eink display that loads hexadecimal image values from the SD Card.
I have the files in an .INO file as below and the program loads up the pic1[] when I need to display.
unsigned char pic1[]= {
0x22, 0x11, 0x11, 0x21, 0x32, 0x33, 0x43, 0x44, 0x44, 0x44, 0x44, 0x54,
0x54, 0x55, 0xa7, 0x89, 0x67, 0x55, 0x45, 0x55, 0x55, 0x55, 0x56, 0x56,
0x65, 0x65, 0x66, 0x87, 0x87, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
0x88, 0x88, 0x88, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, 0x87, 0x87, 0x87,
0x77, 0x87, 0x77, 0x77, 0x77, 0x87, 0x77, 0x77, 0x78, 0x77, 0x78, 0x77,
0x77, 0x88, 0xa8, 0xaa, 0x8a, 0x67, 0x45, 0x44, 0x44, 0x44, 0x44, 0x44..........}
But since the file is very large, I have to save the file as .txt on an SD Card and load up the image later bit by bit.
I saved one hexadecimal value per line as a .txt file as below
0x22
0x11
0x11
0x21
0x32 ....
......
I was able to load up the array using the function Stream.readBytesUntil('New Line")
String[h] =Myfile.readBytesUntil('\n');
If I try to convert this String to a character array, I get an error saying
"cannot convert 'String' to 'void' for argument '1' to 'void memset(void*, int, size_t)'"**
Here is my code.
#include <SD.h>
const int chipSelect = 5; //CS for SD Card
String arrayOfChars[5000]; //The String
int i=0;
char disp[500]; // Initialized character array
void setup()
{
// SD Card initializtion
strip_0.begin();
Serial.begin(9600);
Serial.print("Initializing SD Card....");
if(!SD.begin(chipSelect))
{
Serial.println("Card failed, or not Present");
return;
}
Serial.println("Card Initialized");
//Open File data2.txt
File dataFile = SD.open("/data2.txt");
if(dataFile)
{
Serial.println("data2.txt");
while(dataFile.available())
{
arrayOfChars[i] = dataFile.readStringUntil('\n'); // Read the charcters until you get a new string
i++;
}
////To check what is being stored in arrayOfChars[i])
for(int i=0;i<10;i++)
{
Serial.println(arrayOfChars[i]);
delay(3000);
}
arrayOfChars.toCharArray(disp,9240);
//To check what is being stored after conversion
for(int i=0;i<10;i++)
{
Serial.println(arrayOfChars[i]);
delay(3000);
}
dataFile.close();
}
else
{
Serial.println("File does not exist or named wrong");
}
}
void loop()
{
}