Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 16, 2024, 10:19:35 10:19


Login with username, password and session length


Pages: [1]
Print
Author Topic: Proton PDS - space efficiency for text in the code space?  (Read 8444 times)
0 Members and 1 Guest are viewing this topic.
Fannybo
Inactive

Offline Offline

Posts: 5

Thank You
-Given: 13
-Receive: 3


« 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
Device 18F4550
Xtal = 48
Optimiser_Level = 3
Dead_Code_Remove = On
Declare LCD_Type = Samsung
Dim USB_BUFFER As String * 11

Print At 0,0, "HELLO WORLD"
HSerOut ["HELLO WORLD"]
USB_BUFFER = "HELLO WORLD"

Include "font.inc"

====== 1404 bytes
Device 18F4550
Xtal = 48
Optimiser_Level = 3
Dead_Code_Remove = On
Declare LCD_Type = Samsung
Dim USB_BUFFER As String * 12

Print At 0,0, HELLO_WORLD
HSerOut [HELLO_WORLD]
USB_BUFFER = HELLO_WORLD

Include "font.inc"
HELLO_WORLD: CData "HELLO WORLD", 0

====== 1414 bytes
Device 18F4550
Xtal = 48
Optimiser_Level = 3
Dead_Code_Remove = On
Declare LCD_Type = Samsung
Dim USB_BUFFER As String * 12

Print At 0,0, CStr HELLO_WORLD
HSerOut [CStr HELLO_WORLD]
USB_BUFFER = CStr HELLO_WORLD

Include "font.inc"
HELLO_WORLD: CData "HELLO WORLD", 0
« Last Edit: July 23, 2013, 04:37:38 04:37 by Fannybo » Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4204


There is no evidence that I muted SoNsIvRi


« Reply #1 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
Xtal = 48

Optimiser_Level = 3
Dead_Code_Remove = On
Declare LCD_Type = Samsung
Dim USB_BUFFER As String * 11
Dim SourceString As String * 11 ' Create a String
SourceString = "HELLO WORLD" ' Load the string with uppercase characters

Print At 0,0, SourceString
HSerOut [SourceString]   
USB_BUFFER = SourceString
Include "font.inc"
Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
Fannybo
Inactive

Offline Offline

Posts: 5

Thank You
-Given: 13
-Receive: 3


« Reply #2 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.
 


Logged
FTL
Junior Member
**
Offline Offline

Posts: 83

Thank You
-Given: 170
-Receive: 33


« Reply #3 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.
Logged
gianmagna
Newbie
*
Offline Offline

Posts: 25

Thank You
-Given: 261
-Receive: 114


« Reply #4 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:
'***************************************************
'SubRoutine di scrittura delle funzioni
'In ingresso: funzione
'Visualizza sul display LCD 16x1 in formato di 2 x 8 byte
VISUALIZZA_FUNZIONE:
baseaddress = $6000
ADDRESS = baseaddress + ((funzione - 1) * 16)        'funzione is the string number
  Print $FE, 1                        ' Clear LCD
  DelayMS 30 '
  Print $FE, 2                  
  For zz = 0 To 7                     ' read the first 8 byte
  DATA_BYTE = CRead ADDRESS           '
  Print DATA_BYTE                     ' Display the character
  Inc ADDRESS                         ' Next character
  Next zz                             ' Close the loop
  Print $FE, $C0                      ' Point to line 2 of the LCD
  For zz = 0 To 7                     ' read the second 8 byte
  DATA_BYTE = CRead ADDRESS           ' Read each character from the CDATA string
  Print DATA_BYTE                     ' Display the character
  Inc ADDRESS                         ' Next character
  Next zz                             ' Close the loop
  Return
'****************************
'rest of program


'STRINGHE exact 16-byte strings
'************************
Org $6000  ; SPAGNOLO
'           "1234567890123456"
EST1: CData "01 ACNE         "
EST2: CData "02 ABDOMEN REDUC"
EST3: CData "03 ABDO. REAFIR."
EST4: CData "04 ANTIARRUGAS  "
EST5: CData "05 BRAZOS - MANO"      
EST6: CData "06 PERNAS - PIE "    
EST7: CData "07 CELULITIS    "
EST8: CData "08 CELU.COMPACTA"
EST9: CData "09 CEL.EDEMATOSA"
EST10:CData "10 CELUL. BLAND "
'
EST11:CData "11 CUPER        "
EST12:CData "12 DERMATITIS   "                
EST13:CData "13 DRENAJE      "
EST14:CData "14 ELASTIZANTE  "
EST15:CData "15 LIPOLITICAS  "
EST16:CData "16 PROBLEMA PIEL"
EST17:CData "17 REACTIVAR    "
EST18:CData "18 REAFIR. SENOS"
EST19:CData "19 RELAX        "  
EST20:CData "20 TONIF. GLUTEO"
'other strings            
I hope it can serve
gianmagna
« Last Edit: July 27, 2013, 10:54:06 22:54 by gianmagna » Logged
Fannybo
Inactive

Offline Offline

Posts: 5

Thank You
-Given: 13
-Receive: 3


« Reply #5 on: August 07, 2013, 05:04:02 17:04 »

@ gianmagna
@ FTL

Thanks for the tips.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC