12/12/2021 new version with 5 scripts:
this tool is a script running on pspad.
- first you have to install this script in pspad (in directory pspad/Script/VBScript) and to run "recompile scripts".
after, a menu Script is availabe with submenus:
- Scripts => B4R => "PROGMEM create"
- Scripts => B4R => "PROGMEM remove"
- Scripts => B4R => "PROGMEM Extract strings"
- Scripts => B4R => "Create Static.bas"
- Scripts => B4R => "Gzip => Static.bas"
- Scripts => B4R => "text => Static.bas"
Scripts description::
1) Scripts => B4R => "PROGMEM create"
move automatic of a project with strings in the code to a project with strings in PROGMEM
open with PSPad the project xxxx.B4R
after, on each line with a string to move we have to add a tag '<str1>, '<str2>, '<str2> to '<str15>
efter run the script B4R => PROGMEM Create
- a PROGMEM structure is added
- the first string on each lines highligted by a tag will be moved to a PROGMEM structure
- in code string is replaced
exemple of transfert:
- before:
Sub m6_authorization(index As Byte)
aWOT.res_println("<html>") '<str1>
aWOT.res_println("<head>") '<str1>
aWOT.res_println("<meta charset='utf-8'>") '<str1>
- after:
Sub m6_authorization(index As Byte)
P_get(1,0):aWOT.res_println1(P_buff) '<str1>
P_get(1,1):aWOT.res_println1(P_buff) '<str1>
P_get(1,2):aWOT.res_println1(P_buff) '<str1>
and in the back of the filr
#if C
#include <avr/pgmspace.h>
char strx[164];
const char str1_0[] PROGMEM = "<html>";
const char str1_1[] PROGMEM = "<head>";
const char str1_2[] PROGMEM = "<meta charset='utf-8'>";
const char str1_3[] PROGMEM = "<style>";
2) Scripts => B4R => "PROGMEM remove"
move of strings from PROGMEM to code
run the script B4R => PROGMEM Remove
it make inverse transfert
3) Scripts => B4R => "PROGMEM Extract strings"
extract strings from PROGMEM to a texte file
it is easy after to create several files with the texte of application, to store it in flash with LittleFS
run PROGMEM Extract
- a new file is created with all strings in PROGMEM, one string by line.
- it is easy after to create several file with strings divided by fonction
4) Scripts => B4R => "Create Static.bas"
Create a static file "static.bas empty
it is base to add PROGMEM content in text format like index.htm or in binary format like gzip files of pictures
run B4R => Create static.bas
5) Scripts => B4R => "Gzip => Static.bas"
Add gzip, png, jpg or others binary files in static.bas file in MROGMEM format
a file static.bas must be created and open and active in PSPad
this script open a dialog box to select a file and it is added in static.bas file under PROGMEM format
you can add several files one by one, 20 binary files max with this script
run B4R => gzip => static.bas
- the file is added in static.bas file, in a PROGMEM structure ready to use
- a function GetByte(table, index) is created/updated to read hte file byte by byte
- a function GetLength(Table) is created/updated to interrogate the length of file
6) Scripts => B4R => "text => Static.bas"
Add texte files in static.bas file in PROGMEM format
this script open a dialog box to select a text file and it is added in static.bas file under PROGMEM format
you can add several files one by one, 20 text files max with this script
run B4R => txt => static.bas
- the file is added in a static.bas file, in a PROGMEM structure for strings
- a function Getstring(table, index) is created/updated to read strings one by one and to push it in buffer P_buff
- a buffer P_buff is available to read a string after GetString
at end, we have a static.bas file and if we rename it in P.bas, it is ready to be integreted in a B4R project.
if you want an other name than P.bas, for PROGMEM used for stringss,you will have to do some small modifications on C code
- " b4r_p::_p_buff->data = strx;" if P_buff is in a module P.bas
- " b4r_static::_p_buff->data = strx;" if P_buff is in a module Static.bas
- " b4r_main::_p_buff->data = strx;" if P_buff is in main.bas file
for binary files, we have 2 functions:
- P.GetByte(table, index)
will give a byte stored in P.bas file
- P.Getlength(table)
will provide length of table
for text file, we have a function and strings will be available in a buffer
- P.Getstring(table, index)
will give a string pointed by table + index
- P.P_buff is the buffer where string is available
new file added on top of thread