PDA

View Full Version : how to implement DIM AS CODE



lordfrank1
- 13th June 2015, 23:09
hello,

i am trying to write code for my 5*5*5 led cube. this is a test setup before i start building my 8*8*8 RGB led cube to avoid any errors in the final project.
i am of course using shift register to extend the amount of outputs, however the electronics itself are not the problem since i am struggeling with the code.
i already did get the shout command working and also used array's bud the downside of that is that they are stored as variabels.
so i was looking for a method to store the data in the flash memory of the pic, i found the following command: DIM ...... AS CODE in the documentation.
it is able to do exactly what i want. bud the documentation doesn't tell me how to implement it. i would like to store 8bit values, so it should look a bid like this:

%10000000
%11000000
%11100000

i want to store data tables that the program needs to walk trough one by one. the problem is how can i write this kind of data table to the flash memory with the DIM .... AS CODE command?

thanks in advance

Demon
- 14th June 2015, 02:13
DIM is BASIC, this forum is for PIC BASIC.

From the manual:

4.5. Arrays
Variable arrays can be created in a similar manner to variables.
Label VAR Size[Number of elements]

Label is any identifier, excluding keywords, as described above. Size is BIT, BYTE or WORD. Number of elements is how many array locations is desired. Some examples of creating arrays are:

sharks var byte[10]
fish var bit[8]

Robert

Demon
- 14th June 2015, 02:25
I bet you're using PROTON PIC:
http://www.picbasic.nl/indexes_uk.htm

Try here:
http://www.protonbasic.co.uk/forum.php

Robert

lordfrank1
- 14th June 2015, 12:39
thanks for the response. i didn't know there was a diffrence to be honest. is there a big difference between the two?

Demon
- 14th June 2015, 19:38
Can't say, I'm not familiar with Proton.

But BASIC is BASIC so it can't be very different.

Art
- 19th June 2015, 07:19
That would be a lookup table in PBP.

Art
- 20th June 2015, 08:11
and you’d generate patterns like that on the fly



pattern var byte
i var byte
displayram var byte[8]

pattern = %11111111

for i = 0 to 7
pattern = pattern << 1
displayram[7-i] = pattern
next i