Title: Proton PDS - space efficiency for text in the code space? Post by: Fannybo on June 12, 2013, 06:22:41 18:22 Hello,
I am trying to determine what is the most efficient way, in terms of code space, for displaying multiple text menus on a GLCD. This is an example: Without CData --> 1390 bytes With CData and no CStr --> 1404 bytes With CData and CStr --> 1414 bytes So far what I have determined is that contrary to the guide Cdata + Cstr is the least efficient. I was wondering if I am missing something? Code: ====== 1390 bytes Title: Re: Proton Plus - GLCD and Cdata for space efficiency Post by: pickit2 on June 22, 2013, 01:26:13 13:26 Don't you mean your using PDS?
I get size down to 1370 Code: Device 18F4550 Title: Re: Proton Plus - GLCD and Cdata for space efficiency Post by: Fannybo on July 23, 2013, 04:36:10 04:36 Don't you mean your using PDS? Indeed, I meant PDS, thanks. I get size down to 1370 Hi pickit2, What you did is correct but you save space at the expense of some RAM. However this method is difficult to implement if you have multiple repeating text strings that exceed the available RAM space. What I am looking for, is the most efficient way to store lots of text in the Flash memory, hence without using external or internal EEPROM. Title: Re: Proton PDS - space efficiency for text in the code space? Post by: FTL on July 23, 2013, 08:57:11 20:57 If you need to store lots of text, you should be able to implement a compression algorithm that gets you 80%+ compression on the text with only a small code size increase.
Text is usually easy to pre-compress as there are lots of repeated words and strings. An example of an algorithm is to find the most common 128 words (or word sequences) in the text. Then replace each word with a single byte from 0-127. When you need to expand the text, any byte with a value less than 128 is used to reference a table of pointers to the beginning of the string for each word that was replaced. If you are lucky and have less than 256 unique words (not a big stretch in a menu system), the whole stored string can be a reference to entries in the lookup table. Alternatively, look into the LZW or similar compression algorithms. You can do the compression when you build the program and only the un-compress code needs to be in your program. LZW words in a similar way to what I described, but it dynamically looks for repeated bit strings as it does the compression, and stores the data needed to un-compress the data in the saved data stream. On second thought, this may not work well when you want to uncompress only a single string in the data. You need an algorithm that does the compression based on all of the data, but allows only a portion to be de-compressed at one time. Title: Re: Proton PDS - space efficiency for text in the code space? Post by: gianmagna on July 27, 2013, 10:52:02 22:52 hi Fannybo
use this system to have many strings ready, I put down the flash in locations that are not used by the program, es: $ 6000 and then with a routine of reading the control to the display I use a 16x1 LCD display ,obviously the compiler will tell you that you have a long program but at least I have the strings ready Code: '*************************************************** gianmagna Title: Re: Proton PDS - space efficiency for text in the code space? Post by: Fannybo on August 07, 2013, 05:04:02 17:04 @ gianmagna
@ FTL Thanks for the tips. |