PDA

View Full Version : how much space it takes up



longpole001
- 29th April 2014, 02:14
Hi guys , I am fighting a space problem with program memory of the chip at 128k.

several part of the program require GLCD to show strings menus which are currently formed as multi lookup tables
I have an external sd card setup , for other uses.

I also have fonts but as they need to be shown as digits they are loaded and need to be displayed very quickly else it slow the display or jumps

am thinking i can write a hex file of the strings with some form of lookup to load them it would be nice to know how much space i am likly to save off the chip

currently the menus " lookup list has 40chrs x 5 lines
There are currently 45 menu groups of this nature

would it only be about 9k ?? or would it be more

regards

Sheldon






for gl_k = 0 to 4
for gl_i = 0 to 39

if Menu_Select = 1 then gosub Menu_1 ' Main Menu
if Menu_Select = 2 then gosub Menu_2 ' ANOTHER Menu ETC
gosub put_char
gl_x = gl_x + 6
next gl_i
gl_i = 0
next gl_k
gl_k = 0

gosub Menu_lines

return

' =============== Main System Menu - Menu_1_0 ===============================

Menu_1:
' |------- max 36 chrs wide ---------|
if gl_k = 0 then lookup gl_i,[" MAIN SYSTEM MENU "],g_char ' Menu header gl_y 8
' ==============================
if gl_k = 1 then
gl_y = 16
lookup gl_i,[" 1. SELECT NEW EVENT "],g_char ' option 1 gl_y 24
endif
if gl_k = 2 then lookup gl_i,[" 2. SYSTEM SETUP "],g_char ' option 2 gl_y 32
if gl_k = 3 then lookup gl_i,[" 3. System Information "],g_char ' option 3 gl_y 40
if gl_k = 4 then lookup gl_i,[" (press SETUP to exit) "],g_char ' option 4 gl_y 56

gl_x1 = 40 ' underline the Menu Header
gl_x2 = 195
return

HenrikOlsson
- 29th April 2014, 07:26
Hi Sheldon,

Why not just try it and find out?

Compile the program, note the size. Add or remove a single character from one of your LOOKUP statements and compile it again, note the difference. That's how much space each character takes.

As far as I can see each character, when used in a LOOKUP statment, "occupies" two bytes when compiled for a 18F device and one word when compiled for a 10,12 and 16F devices. Each occurrence of LOOKUP seems to add ~44 bytes for 18F parts and 17 words for 10, 12 and 16F parts (plus the characters of course).

So, if you have 45 menu groups, each consisting of 5 LOOKUP statements with 40 characters each I count to (45*5*44) + (45*5*40*2) = 27900 bytes.

/Henrik.

pedja089
- 29th April 2014, 08:21
http://www.picbasic.co.uk/forum/showthread.php?t=2418&p=69166#post69166

longpole001
- 29th April 2014, 09:46
cheers guys , that helps , ill try removing as well , truth is ill have to do it , i have so much further to go , and 128k is getting to be a small space. good thing i only have 240x64 glcd , so far , i have plans to go for 240 x128 later , but 18F is not going to get me there i dont think

pedja089
- 29th April 2014, 10:23
What about FT800 (http://www.ftdichip.com/Products/Modules/VM800B.html)?
You also can try to create menus dynamically. Create routine, that will draw menu based on number of items etc...
Remove space's, create routine to set X address of LCD based on does your text left aligned or center. Print row number only once, or create sub that print option numbers and title.
Then you need just to store strings few numbers and strings in flash.

longpole001
- 29th April 2014, 12:42
since i have a small 2gig sd card available of which i use about 100mb , i was looking to rewrite the menu routines i have just to store the lookup table data as the first step , since the menus are not as time sensitive as the large / medium fonts for the digits , some other chrs can be moved to SD as they dont need the speed as much in my app , i am hoping that it will free up about 40- 50k if i can write it well ,
this seem like the easy road to take.

changing chips is not the option i want to go to as the pcb is made , also since i have done all this code in PBP3 i prefer a chip that it supports , than redoing it using another language unless i really need to .

But i am finding the more i do and want to achieve PBP limited to 18f chips which at best is 128k.

i have looked at the ARM chips , for thier pricing,speed, RAm & program size space , and predone boards for prototyping

i have found that MIkrobasic supports the the ARM processors , so although i would need to learn the scripting of Mikrobasic , i would be as bad as having to relearn C and i could likly use a lot of the routines already done in pbp with only a small amount of changes MIkrobasic also supports PIC32 as well ???

i do like PBP , but its very limiting on larger project it seems

see how i go making a hex file of the menu items and see
knowing what i have , is there a some routines anyone has found that can be used for an example

the sd card is setup using the fat 16 with SDFS.bas code

cheers

sheldon