PDA

View Full Version : filling an array



Beginner
- 10th August 2010, 09:42
I'm trying to place images on a 128*64 display.

the output of my picture converter looks like (yes these are empty):

00, 00, 00, 00, 00, 00, 00, 00
00, 00, 00, 00, 00, 00, 00, 00
00, 00, 00, 00, 00, 00, 00, 00

is there a way i can place those directly into an array (p) like this?



p1=[00, 00, 00, 00, 00, 00, 00, 00]
p2=[00, 00, 00, 00, 00, 00, 00, 00]


Thanks in advance. I'm using Microcode Studio as editor.

Beginner
- 10th August 2010, 12:34
I also found a CDATA command, but unfortunately i cannot use this in PicbasicPro?

Is it possible to use the lookup command to fill arrays?

Thanks in advance.

mackrackit
- 10th August 2010, 16:01
Welcome to the forum.

Yes a lookup table can be used. The best I can do at the moment is point you to an example that has a string and comma seperated values being put into an arrary.
http://www.picbasic.co.uk/forum/content.php?r=178-USB-CDC-Communications-for-Dummies!

But how do you plan on building the table with data?

Beginner
- 11th August 2010, 13:20
I'm currently using a FOR loop to build the data.
Just checking the byte position, and then switching lines and left/right.



logopart1:
for logo = 0 to 255
lookup logo, [255,255,255,10,10, etc] ,L
next
gosub placeandcontroldata
return


This works, but I cannot easily import pictures into the code this way...

mackrackit
- 11th August 2010, 13:31
This works, but I cannot easily import pictures into the code this way...
I guess I do not understand exactly what you are trying to do.
Is the picture being sent to the MCU via serial? Or are you hard coding it. or something else?

Beginner
- 11th August 2010, 13:42
I'm making the pictures with a program like Bitmap2LCD, which comes into an .h file.
I try to import these pictures into my code (copy-paste), and then putting them on the screen of an 128*64 LCD through a databyte. But I cannot get the whole 1024 bytes on the screen with 1 command.

Acetronics2
- 11th August 2010, 14:19
I'm making the pictures with a program like Bitmap2LCD, which comes into an .h file.
I try to import these pictures into my code (copy-paste), and then putting them on the screen of an 128*64 LCD through a databyte. But I cannot get the whole 1024 bytes on the screen with 1 command.

Ok,

let's make it simple ...

Open Mikroelektronika ( MKBasicPro - Free edition i.e) Tool " GLCD Bitmap convertor " ...

you get THAT in your Clipboard :



// ------------------------------------------------------
// GLCD Picture name: truck.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------
unsigned char const truck_bmp[1024] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,
128, 64, 64, 64, 64, 64, 64, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,160,160,160, 96,224,224, 96, 96, 96, 32, 0, 32, 32, 32,
32, 32, 32, 32, 32, 32, 0, 0, 64, 64, 64, 0,128, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,254, 0, 1, 1, 1, 1, 1,253,253,253,253,
1, 1, 1, 1, 1, 1,253,253,253,253, 1, 1, 1, 1,253,253,
253,253,249,241,225,193,129,193,225,249,253,253,25 3,253,253, 1,
1, 1, 1,253,253,253,253,221,221,221, 29, 17, 1,255, 1, 1,
1, 1, 0,254, 1,168, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 16,224, 24, 36,132, 0, 2,130, 5, 81, 68,112,
160,192, 96, 96, 32, 0,128,128,192,192,192, 64, 0, 0, 0, 0,
0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 63, 96, 96, 96,224, 96, 96,127,127,127,127,
124,124,124,124, 96, 96,127,127,127,127, 96, 96, 96, 96,127,127,
127,127, 97,103,111,127,127,111,103, 99, 97,127,127,127,127, 96,
96, 96, 96,127,127,127,127,125,125,125,124,116, 96,127, 64, 64,
64,160, 96,252,246, 1, 14, 6, 6, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 66,114, 60, 32, 16, 16, 0, 4, 2, 3, 2,
0, 0, 0, 4, 4, 4, 4, 20, 16, 16, 16, 16, 16, 9, 9, 41,
112, 32, 67, 5,240,126,174,128, 56, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
1, 1,127,127,127,127,255,255,247,251,123,191, 95, 93,125,189,
189, 63, 93, 89,177,115,243,229,207, 27, 63,119,255,207,191,255,
255,255,255,255,255,255,255,127,127,127,127,127,12 7,127,127,255,
255,255,127,127,125,120,120,120,120,120,248,120,12 0,120,120,120,
120,248,248,224,135, 0, 0, 0, 0, 0, 0, 0, 0,128,240,248,
120,188,220, 92,252, 28, 28, 60, 92, 92, 60,120,248,248, 96,192,
143,168,216,136, 49, 68, 72, 2,160, 96, 0, 0, 0, 0, 0, 0,
0, 0, 0,128,192,248,248,248,248,252,254,254,254,254,254, 254,
254,254,254,254,254,255,255,255,255,255,246,239,20 8,246,174,173,
169,128,209,208,224,247,249,255,255,252,220,240,12 7,255,223,255,
255,255,255,255,255,254,254,255,255,255,255,255,25 5,255,254,255,
255,255,255,255,255,255,254,254,254,254,254,254,25 4,254,254,254,
254,254,254,254,255,255,255,255,255,255,254,255,19 0,255,255,253,
240,239,221,223,254,168,136,170,196,208,228,230,24 8,127,126,156,
216,224,240,240,242,242,240,177, 32, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 3, 3, 3, 7, 7, 7, 7, 7, 15,
15, 15, 7, 15, 15, 15, 7, 7, 15, 14, 15, 13, 15, 47, 43, 43,
43, 43, 43, 47,111,239,255,253,253,255,254,255,255,255,255,255 ,
191,191,239,239,239,191,255,191,255,255,255,255,25 5,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,
255,255,255,255,127,127,127,127,255,255,191,191,19 1,191,255,254,
255,253,255,255,255,251,255,255,255,127,125, 63, 31, 31, 31, 31,
31, 31, 63, 15, 15, 7, 7, 3, 3, 3, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 3, 3, 3, 11, 11, 11, 11, 7, 3, 14, 6, 6,
6, 2, 18, 19, 19, 3, 23, 21, 21, 17, 1, 19, 19, 3, 6, 6,
14, 15, 15, 7, 15, 15, 15, 11, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};


then, Modify it as is ...



; ------------------------------------------------------
; GLCD Picture name: truck.bmp
; GLCD Model: KS0108 128x64
; ------------------------------------------------------
POKECODE @ Startadress,_

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,_

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,_

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,
128, 64, 64, 64, 64, 64, 64, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,_

32, 32,160,160,160, 96,224,224, 96, 96, 96, 32, 0, 32, 32, 32,
32, 32, 32, 32, 32, 32, 0, 0, 64, 64, 64, 0,128, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,_

0, 0, 0, 0, 0,254, 0, 1, 1, 1, 1, 1,253,253,253,253,
1, 1, 1, 1, 1, 1,253,253,253,253, 1, 1, 1, 1,253,253,
253,253,249,241,225,193,129,193,225,249,253,253,25 3,253,253, 1,
1, 1, 1,253,253,253,253,221,221,221, 29, 17, 1,255, 1, 1,_

1, 1, 0,254, 1,168, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 16,224, 24, 36,132, 0, 2,130, 5, 81, 68,112,
160,192, 96, 96, 32, 0,128,128,192,192,192, 64, 0, 0, 0, 0,
0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,_

0, 0, 0, 0, 0, 63, 96, 96, 96,224, 96, 96,127,127,127,127,
124,124,124,124, 96, 96,127,127,127,127, 96, 96, 96, 96,127,127,
127,127, 97,103,111,127,127,111,103, 99, 97,127,127,127,127, 96,
96, 96, 96,127,127,127,127,125,125,125,124,116, 96,127, 64, 64,_

64,160, 96,252,246, 1, 14, 6, 6, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 66,114, 60, 32, 16, 16, 0, 4, 2, 3, 2,
0, 0, 0, 4, 4, 4, 4, 20, 16, 16, 16, 16, 16, 9, 9, 41,
112, 32, 67, 5,240,126,174,128, 56, 0, 0, 0, 0, 0, 0, 0,_

0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
1, 1,127,127,127,127,255,255,247,251,123,191, 95, 93,125,189,
189, 63, 93, 89,177,115,243,229,207, 27, 63,119,255,207,191,255,
255,255,255,255,255,255,255,127,127,127,127,127,12 7,127,127,255,_

255,255,127,127,125,120,120,120,120,120,248,120,12 0,120,120,120,
120,248,248,224,135, 0, 0, 0, 0, 0, 0, 0, 0,128,240,248,
120,188,220, 92,252, 28, 28, 60, 92, 92, 60,120,248,248, 96,192,
143,168,216,136, 49, 68, 72, 2,160, 96, 0, 0, 0, 0, 0, 0,_

0, 0, 0,128,192,248,248,248,248,252,254,254,254,254,254, 254,
254,254,254,254,254,255,255,255,255,255,246,239,20 8,246,174,173,
169,128,209,208,224,247,249,255,255,252,220,240,12 7,255,223,255,
255,255,255,255,255,254,254,255,255,255,255,255,25 5,255,254,255,_

255,255,255,255,255,255,254,254,254,254,254,254,25 4,254,254,254,
254,254,254,254,255,255,255,255,255,255,254,255,19 0,255,255,253,
240,239,221,223,254,168,136,170,196,208,228,230,24 8,127,126,156,
216,224,240,240,242,242,240,177, 32, 0, 0, 0, 0, 0, 0, 0,_

0, 0, 0, 1, 1, 1, 1, 3, 3, 3, 7, 7, 7, 7, 7, 15,
15, 15, 7, 15, 15, 15, 7, 7, 15, 14, 15, 13, 15, 47, 43, 43,
43, 43, 43, 47,111,239,255,253,253,255,254,255,255,255,255,255 ,
191,191,239,239,239,191,255,191,255,255,255,255,25 5,255,255,255,_

255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,
255,255,255,255,127,127,127,127,255,255,191,191,19 1,191,255,254,
255,253,255,255,255,251,255,255,255,127,125, 63, 31, 31, 31, 31,
31, 31, 63, 15, 15, 7, 7, 3, 3, 3, 0, 0, 0, 0, 0, 0,_

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,_

1, 1, 1, 1, 3, 3, 3, 11, 11, 11, 11, 7, 3, 14, 6, 6,
6, 2, 18, 19, 19, 3, 23, 21, 21, 17, 1, 19, 19, 3, 6, 6,
14, 15, 15, 7, 15, 15, 15, 11, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;


note the code extender "_" that must appear every 256 characters or less.

so, once every 64 values ( 4 lines ) make it easy to do ...

You retrieve your values with a




FOR pointer = 0 to 1024
PEEKCODE ( Startadress + pointer ), value
GoSub GLCDPrint_sub ;
Next Pointer
.
.
.



Isn't it simple ??? ;)

BUT ... remember it is YOU to write the " GLCDPrint_sub " as PBP do not have a GLCD library ...

Alain