Announcement

Collapse
No announcement yet.

Neatly formatted append/write to a .txt file on uSD from keyboard output

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neatly formatted append/write to a .txt file on uSD from keyboard output

    So I am trying to append/write a slew of parameters at the time of inputting them from a keypad on the Gen4-uLCD-35DT to a .txt file on the uSD card.
    I'm trying to create a neat format so I would like each parameter to be on a newline.
    What I have currently looks like:

    func writeuSD (var n)
    str_GetW(&i, &d) ;
    hndl1 := file_Open("Config.txt", 'a');
    to (string); print(d);
    res := file_Seek(hndl1, 0x0000, 0x0005*n ) ;
    res := file_PutS(string, hndl1);
    res := file_Seek(hndl1, 0, 0) ;
    res := file_Close(hndl1) ;
    endfunc

    where 'i' is the keyboard response that I am then converting to decimal format. I set the argument 'n' being passed based upon which button was previously pressed.
    'N' can be anywhere between 0 and 150 or so as I have around 150 different parameters being set.
    I'll probably add a null terminator in there for the peripheral MCU that will be reading this file from the uSD as well.

    My problem is I can't really figure out how to correctly format the code and the .txt file such that each parameter is on a newline.
    A single parameter usually doesn't have consistent significant figures. For instance, the area factor can be entered in anywhere from 0.001 up to 999.999

    Is there a way to achieve this? I also don't really have a clear understanding of the hiword and loword for file_seek either.

    Regards,

    Justin
Working...
X