Is there an easy way of writing a (fixed) string into a table rather than using up RAM?
I've written a number of programs that use a number of 74HC595 shift registers connected to seven segment LED displays that are then written to in order to display text and numerals.
I've been using tables which have the numeric values required for the various segments to be lit in order to display the correct characters, and hence the messages, but this is rather hard work if a message needs to be changed.
Here is an example of one of the 'message' tables I'm using.
I had an idea that I could improve on this by creating an 'Alphabet' table and then finding the ascii character of each letter of a string and then looking this up in the 'alphabet' in order to find the code to pass to the 74HC595 display.
Similar to this:
TableAlphabetAsByte255'Space255'!255'"255'#255'$255'%255'&255' '198'(240')255'*255'+255' '191'-127'.255'/192'0249'1164'2176'3153'4146'5130'6248'7128'8144'9255':255';255'<183'=255'>255'?255'@136'A128'B198'C192'D134'E142'F194'G137'H207'I241'J137'K199'L200'M200'N192'O140'P152'Q206'R146'S135'T193'U193'V193'W137'X145'Y164'Z198'(255'\240')255'^247'_255''163'a131'b167'c161'd134'E142'f144'g139'h239'i241'j139'k207'l171'm171'n163'o140'p152'q175'r146's135't227'u227'v227'w137'x145'y164'z198'{255'|240'}255'~EndTableDimMyFirstMessageAsString*20LetMyFirstMessage="12F1840 Display test"LetStringLen=Len(MyFirstMessage)ForStringPos=1toStringLenLetPrintChr=Asc(MyFirstMessage,StringPos)IfPrintChr>31ThenIfPrintChr<127ThenLetPrintChr=PrintChr-31ElseLetPrintChr=255EndIfElseLetPrintChr=255EndIfIfEndMessage=1ThenExitForEndIfReadTableAlphabet,PrintChr,DigitLetD_Lat=0'Start output data latchShiftData(Digit)LetD_Lat=1'End output data latchWaitLoop(CharDelay)NextStringPos
All this works, and it is much much easier to update the 'messages', but the string arrays take up some ram and I'd rather put them into a table if possible.
Is there some method of doing so that I'm not aware of?
Hmm... I'm guessing that the converters are included with SynWrite? Or Windows only?
Still, you got me thinking.
If anyone else is wanting to do such a thing on a Mac, I've written a very poor AppleScript which will produce a Table from a text input.
I've saved it as an AppleScript Application which should run on a Mac once downloaded. I've placed the Application here to share it.
Edit: If you are intending to use this on a Mac, you might want to add:
tell me to activate
to the top of the code (I've added it below).
This makes the dialog box jump to the frontmost when started so it doesn't get hidden if started by another Application.
Here is the code:
tellmetoactivatesettheResponsetodisplaydialog"Convert text to GCB table"defaultanswer""withiconnotebuttons{"Cancel","Continue"}defaultbutton"Continue"setstuffto(textreturnedoftheResponse)setstuff_ascii_htmlto"Table TableName As Byte"&returnrepeatwithcfrom1tothecountofstuffsetstuff_ascii_htmltostuff_ascii_html&((ASCIInumberof(charactercofstuff))astext)if((ASCIInumberof(charactercofstuff))=32)thensetstuff_ascii_htmltostuff_ascii_html&" 'Space"&returnelsesetstuff_ascii_htmltostuff_ascii_html&" '"&(charactercofstuff)&returnendifendrepeatsetstuff_ascii_htmltostuff_ascii_html&"End Table"displaydialog(stuffastext)&return&return&"Copy this:"defaultanswerstuff_ascii_htmlasstring
Many thanks for your suggestion there. I hadn't thought of doing it that way until you mentioned it.
I've now gone from 58.2% RAM used to just 14%. The ROM usage is of course relatively unchanged as the strings have to be stored in ROM before being loaded into RAM so a net gain in my book.
Much better, thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can't find the converters in the MacOS installation?
Still, I have to say I'm sat here feeling a little smug now as I've managed to add my script to the menu in Geany so I can invoke it from within the IDE.
The command for opening the Application from Geany (and presumably other Mac editors too) is rather convoluted as if you are not careful, it attempts to open a directory as an executeable file. This is the command I'm using:
Clearly the "/Users/Mark/" section requires editing to reflect the location you stored the Application on your hard drive, but you will hopefully get the idea.
It is saving me some work and the 'two-table-tango' to convert from human readable table to the numeric code required to display it on a seven segment display driven by cascaded 74HC595s is working a treat too.
Chuffed to bits!
Last edit: mkstevo 2019-03-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had difficulty making sense of the converters. I think they might initiate the "Awk" command to perform the text to table transformations, but I couldn't see how.
Having written my script for macOS, I needed something similar for Windows as I really missed having access to it. I've had time today to create something similar using AutoHotKey. This can certainly be added to the Geany "Build" commands, and I don't doubt it could also be included into SynWrite too.
It is an AutoHotKey compiled executable, so should run without any need to install AutoHotKey.
Sadly, it never became clear to me that the functionality did that. I had interpreted it from the thread as being for adding menus with sub menus, not for 'plain' text tables as well.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's over my head. I never had problems really with tables.
Though I never used tables for strings I never saw it a problem to use the table to add to a string un til complete. I would have used markers or length of string.
Anyway it's all got too complicated with all the rc releases.
it's more often than windows
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As you might tell, I use a lot of tables. My main reason is that I can do a sort of reverse lookup from the value (character) in one table and cross reference it to the value in another table (value required to illuminate the elements of a seven segment display to show that character). Holding these in a table allows me to scroll a long sentence along a four 'digit' seven segment display easily by increasing the index. I can also perform animation in a similar way. Being able to update the character values in that table simply means I can quickly change the messages shown on the LED display.
Although it took me most of Monday afternoon to get my little script working, and I don't really need it now thanks to the table 'string' functions added in the latest releases, I probably will still use my script(s) for creating tables. It formats the data into a table like structure, with the byte values represented individually - that helps me visualise that they are stored as individual bytes within the memory of the device. Daft I know, but it helps me to think!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What would be nice would be an easy way to define unused chrs to a few lines of binary.
more understanding of glcd charsets and how to predefine...in a table?
I don't think I explained that well.
Is there an option to use a table for special definable charsor would they need plotting-pset?
Last edit: stan cartwright 2021-04-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there an easy way of writing a (fixed) string into a table rather than using up RAM?
I've written a number of programs that use a number of 74HC595 shift registers connected to seven segment LED displays that are then written to in order to display text and numerals.
I've been using tables which have the numeric values required for the various segments to be lit in order to display the correct characters, and hence the messages, but this is rather hard work if a message needs to be changed.
Here is an example of one of the 'message' tables I'm using.
I had an idea that I could improve on this by creating an 'Alphabet' table and then finding the ascii character of each letter of a string and then looking this up in the 'alphabet' in order to find the code to pass to the 74HC595 display.
Similar to this:
All this works, and it is much much easier to update the 'messages', but the string arrays take up some ram and I'd rather put them into a table if possible.
Is there some method of doing so that I'm not aware of?
I tried:
But that didn't work.
Use the Converter(s). This (the converter) can take am external file of strings it would create the tables for automatically.
Use the Converter(s). This (the converter) can take am external file of strings it would create the tables for automatically.
Hmm... I'm guessing that the converters are included with SynWrite? Or Windows only?
Still, you got me thinking.
If anyone else is wanting to do such a thing on a Mac, I've written a very poor AppleScript which will produce a Table from a text input.
I've saved it as an AppleScript Application which should run on a Mac once downloaded. I've placed the Application here to share it.
Edit: If you are intending to use this on a Mac, you might want to add:
tell me to activate
to the top of the code (I've added it below).
This makes the dialog box jump to the frontmost when started so it doesn't get hidden if started by another Application.
Here is the code:
Here is the output generated:
Certainly a lot faster than I was doing things!
Last edit: mkstevo 2019-03-14
Many thanks for your suggestion there. I hadn't thought of doing it that way until you mentioned it.
I've now gone from 58.2% RAM used to just 14%. The ROM usage is of course relatively unchanged as the strings have to be stored in ROM before being loaded into RAM so a net gain in my book.
Much better, thanks again.
Converters use the native operating system capabilities. You can use AppleScript or an OS Specific version of AWK or GAWK.
So, you could take your little app and integrate. :-)
But, you have a good method already. :-)
I can't find the converters in the MacOS installation?
Still, I have to say I'm sat here feeling a little smug now as I've managed to add my script to the menu in Geany so I can invoke it from within the IDE.
The command for opening the Application from Geany (and presumably other Mac editors too) is rather convoluted as if you are not careful, it attempts to open a directory as an executeable file. This is the command I'm using:
/Users/Mark/GreatCowBasic/GCB_Text_To_Table.app/Contents/MacOS/applet
Clearly the "/Users/Mark/" section requires editing to reflect the location you stored the Application on your hard drive, but you will hopefully get the idea.
It is saving me some work and the 'two-table-tango' to convert from human readable table to the numeric code required to display it on a seven segment display driven by cascaded 74HC595s is working a treat too.
Chuffed to bits!
Last edit: mkstevo 2019-03-14
create a folder called converters below greatcowbasi folder. Then, either use the Windows files or have a look in the help to create the ini file etc. Also, see https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/converters/
I bet you are chuffed!
I had difficulty making sense of the converters. I think they might initiate the "Awk" command to perform the text to table transformations, but I couldn't see how.
Having written my script for macOS, I needed something similar for Windows as I really missed having access to it. I've had time today to create something similar using AutoHotKey. This can certainly be added to the Geany "Build" commands, and I don't doubt it could also be included into SynWrite too.
It is an AutoHotKey compiled executable, so should run without any need to install AutoHotKey.
With the new compiler. Just put the strings in the table between quotes.
So I can write:
Which would be converted to:
Giving the same table functionality?
I've seen the thread on tables, but thought it was concentrated on multi-level menus and so dismissed it as not relevant.
Last edit: mkstevo 2021-04-05
yep...
to...
Thanks.
That would have saved me an afternoon of work had I understood what was going on!
Ah well, it's a learning curve isn't it...
Things are moving all the time. RC releases have lots and lots of new capabilities.
Sadly, it never became clear to me that the functionality did that. I had interpreted it from the thread as being for adding menus with sub menus, not for 'plain' text tables as well.
I posted a lot of examples today.
You are correct that the tables can now be easily made into a menu system, but, we added escape chararcters and much more. 😃
It's over my head. I never had problems really with tables.
Though I never used tables for strings I never saw it a problem to use the table to add to a string un til complete. I would have used markers or length of string.
Anyway it's all got too complicated with all the rc releases.
it's more often than windows
It called Development. No RC releases means a static tool chain. No development means no new chips. no new capabilities and no fixes.
And, hopefully, the software gets better. :-)
As you might tell, I use a lot of tables. My main reason is that I can do a sort of reverse lookup from the value (character) in one table and cross reference it to the value in another table (value required to illuminate the elements of a seven segment display to show that character). Holding these in a table allows me to scroll a long sentence along a four 'digit' seven segment display easily by increasing the index. I can also perform animation in a similar way. Being able to update the character values in that table simply means I can quickly change the messages shown on the LED display.
Although it took me most of Monday afternoon to get my little script working, and I don't really need it now thanks to the table 'string' functions added in the latest releases, I probably will still use my script(s) for creating tables. It formats the data into a table like structure, with the byte values represented individually - that helps me visualise that they are stored as individual bytes within the memory of the device. Daft I know, but it helps me to think!
What would be nice would be an easy way to define unused chrs to a few lines of binary.
more understanding of glcd charsets and how to predefine...in a table?
I don't think I explained that well.
Is there an option to use a table for special definable charsor would they need plotting-pset?
Last edit: stan cartwright 2021-04-06
@Stan. Create a new thread to discuss GLCD character creation.