Here it is....not fully completed yet...
I cannot post the entire code as it exceeds the max characters allowed, so here is the part on reading the card and converting the read data.
I will also post how I write to the card.
//******************** Initialize the SPI ******************************************************************//
SPI.begin(52); // initialize the bus for a device on pin 52, This is the SPI Flash for the text.
SPI.begin(53); // initialize the bus for a device on pin 53, This is the SD card.
//******************************** Initialize the LCD screen ************************************************//
CTE_LCD.SPI_Flash_init(FLASH_CS_PIN);
myGLCD.InitLCD();
myGLCD.clrScr();
// **************** LCD background colors, text colors, text background color *****************//
myGLCD.setColor(0, 0, 0); // for all the draw fill and print commands
myGLCD.setBackColor(R, G, B); // background for all the draw fill and print commands
myGLCD.fillScr(R, G, B); // fill the screen color
//***************************** Define the pin for storage on the SD card and read the data on the card ************************************//
CTE_LCD.Put_Text("Initializing SD card...", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
//Serial.print("Initializing SD card...");
delay(1500);
pinMode(SS, OUTPUT);
if (!SD.begin(chipSelect)) {
CTE_LCD.Put_Text("Initialization failed !", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
CTE_LCD.Put_Text("Check card or configuration", VFO_B_HOR, VFO_B_VERT + 29, BVS_74);
//Serial.println("initialization failed!");
delay(1500);
return;
}
CTE_LCD.Put_Text("Initialization done. ", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
//Serial.println("initialization done.");
delay(3000);
VFO_A_Stored = SD.open("VFO_A.TXT");
if (VFO_A_Stored) {
CTE_LCD.Put_Text("Reading VFO_A.TXT", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
//Serial.println("Reading VFO_A.TXT:");
while (VFO_A_Stored.available()) {
Vfa_Mill = VFO_A_Stored.parseInt();
Vfa_Hthou = VFO_A_Stored.parseInt();
Vfa_Tthou = VFO_A_Stored.parseInt();
Vfa_thou = VFO_A_Stored.parseInt();
Vfa_hun = VFO_A_Stored.parseInt();
Vfa_ten = VFO_A_Stored.parseInt();
Vfa_one = VFO_A_Stored.parseInt();
Vfa_end = VFO_A_Stored.parseInt(); // dummy read to terminate parseInt(), without it it returns all zeros for some reason.
delay(75);
//(VFO_A_Stored.read());
//Serial.write(VFO_A_Stored.read());
}
VFO_A_Stored.close();
CTE_LCD.Put_Text("Reading VFO_A.TXT....... Done", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
} else {
delay(1500);
CTE_LCD.Put_Text("Error opening VFO_A.TXT ", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
//Serial.println("Error opening VFO_A.TXT");
}
VFO_B_Stored = SD.open("VFO_B.TXT");
if (VFO_B_Stored) {
CTE_LCD.Put_Text("Reading VFO_B.TXT", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
Serial.println("Reading VFO_B.TXT:");
while (VFO_B_Stored.available()) {
delay(75);
(VFO_B_Stored.read());
//Serial.write(VFO_B_Stored.read());
}
VFO_B_Stored.close();
CTE_LCD.Put_Text("Reading VFO_B.TXT....... Done", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
} else {
delay(1500);
CTE_LCD.Put_Text("Error opening VFO_B.TXT ", VFO_A_HOR, VFO_A_VERT + 29, BVS_74);
//Serial.println("Error opening VFO_B.TXT");
delay(1500);
}
//------------------------ Convert the values stored on the SD card --------------------------------------------------//
/* Notes:
The values stored on the SD card are in text format, seperated by commas.
These values are read as individual integers by the "parseInt" command.....and placed in a string "VFO_A_Stored_Freq".
From there the string "VFO_A_Stored_Freq" is converted to a char array "char VFO_A_Read[8]"...
and finally handed to the atoi (char to integer) command "rx=atoi(VfO_A_Read)".
*/
if (ForceFreq == 1) {
String VFO_A_Stored_Freq = ( String(Vfa_Mill) + String(Vfa_Hthou) + String(Vfa_Tthou) + String(Vfa_thou) + String(Vfa_hun) + String(Vfa_ten) + String(Vfa_one) );
char VfO_A_Read[8];
VFO_A_Stored_Freq.toCharArray(VfO_A_Read, 8);
rx = atoi(VfO_A_Read);
//Serial.print("Stored-RX =");
//Serial.println(rx);
}