Shifting Data
oodes
Posts: 131
Hello Guys ,
I'm a bit of a newby so this might be a simple question for some of you I hope. Im reading data from a text file on a SD card and displaying it on an LCD and also the PST. The Data stream is 40 characters long. I have 2 text files and I choose which one to open and read by the state of a pin. If my pin is 0 I open " Bibliog.txt" and read in the first 40 characters and display it.
But I want it so that when I push the button again (active low) I read in the following 40 characters (40-79) of the text file. Do I need to shift the address >>40 times?? Apologies for the poor code , i'm a bit of a virgin
x := sdfat.popen(string("Bibliog.txt"), "r")
if x <> 0
lcd.move(1,1)
lcd.str(string("File Not Found"))
repeat
sdfat.pread(@data1,40)
sdfat.pclose
lcd.move(1,1)
lcd.str(string("Bibliog.txt"))
delay
lcd.clear
lcd.move(1,1)
lcd.str(@data1)
pst.Start(115_200)
pst.Str(@data1)
delay
lcd.clear
repeat
if INA[11]==0 ' My push button connected here
???????????????? 'here's my problem
DAT
data1 long "Bibliog.txt",0
data2 long "Cheats.txt",0
I'm a bit of a newby so this might be a simple question for some of you I hope. Im reading data from a text file on a SD card and displaying it on an LCD and also the PST. The Data stream is 40 characters long. I have 2 text files and I choose which one to open and read by the state of a pin. If my pin is 0 I open " Bibliog.txt" and read in the first 40 characters and display it.
But I want it so that when I push the button again (active low) I read in the following 40 characters (40-79) of the text file. Do I need to shift the address >>40 times?? Apologies for the poor code , i'm a bit of a virgin
x := sdfat.popen(string("Bibliog.txt"), "r")
if x <> 0
lcd.move(1,1)
lcd.str(string("File Not Found"))
repeat
sdfat.pread(@data1,40)
sdfat.pclose
lcd.move(1,1)
lcd.str(string("Bibliog.txt"))
delay
lcd.clear
lcd.move(1,1)
lcd.str(@data1)
pst.Start(115_200)
pst.Str(@data1)
delay
lcd.clear
repeat
if INA[11]==0 ' My push button connected here
???????????????? 'here's my problem
DAT
data1 long "Bibliog.txt",0
data2 long "Cheats.txt",0
Comments
Hello Guys ,
I'm a bit of a newby so this might be a simple question for some of you I hope. Im reading data from a text file on a SD card and displaying it on an LCD and also the PST. The Data stream is 40 characters long. I have 2 text files and I choose which one to open and read by the state of a pin. If my pin is 0 I open " Bibliog.txt" and read in the first 40 characters and display it.
But I want it so that when I push the button again (active low) I read in the following 40 characters (40-79) of the text file. Do I need to shift the address >>40 times?? Apologies for the poor code , i'm a bit of a virgin
I ask because, if it's only 2 groups of 40 characters x 2 files, then you could just read in all 4 strings of 40 bytes during initialization and select which one you want to display. How big are these files (how many 40 byte entries)? How you implement this depends a lot on that. For example, if you have a 64K byte EEPROM, you could read both files into fixed locations in the EEPROM, then access the entries randomly very easily. If these files could be large, maybe you could use one of the SD card drivers that supports more than one file open at a time (for reading) and just open both of them and read 40 bytes at a time from both selecting which one you want each time the button is pushed.
Basically I just read the first 40 bytes of whatever file is open and display it on the LCD and PST. If I push the button again ,clear the LCD read the next 40 bytes and display, and if pushed again the next 40 and so on. I'm just unsure how to structure the code