add *.bmp to ks108

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

Post Reply
mohandino
Posts: 22
Joined: Fri Jun 29, 2007 9:41 pm
Contact:

add *.bmp to ks108

Post by mohandino »

Hello benj,

Can you tell me how can i add the function ( in ks108 ) to send a *.bmp to the lcd ?

thanks

User avatar
Benj
Matrix Staff
Posts: 14929
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: add *.bmp to ks108

Post by Benj »

Hello

You could do this by converting the image to an array of bytes that you can then embed into your Flowcode program and read back at runtime to send to the display. You could also use methods such as using a SD card or USB... to send the image data to the embedded device.

mohandino
Posts: 22
Joined: Fri Jun 29, 2007 9:41 pm
Contact:

Re: add *.bmp to ks108

Post by mohandino »

Hi,

Is there any way to add the function like "loadimg" to the Custom_Code.c of the ks108 ?

ps : i'm a newbee in C code.

User avatar
Benj
Matrix Staff
Posts: 14929
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: add *.bmp to ks108

Post by Benj »

Hello

Yes it is possible to add the function to the C code. However the hard part is going to be getting the image data into the compiled program. PIC microcontrollers generally only like arrays of 256 bytes or less. AVRs are much better at handling large arrays so using an AVR might be an option. Otherwise you are forced to find a way to stream the data into the device as it is needed. Eg SD, USB.

I came across things like this by doing a google search for "PIC ks0108 bmp"

http://www.edaboard.com/ftopic49565.html

mohandino
Posts: 22
Joined: Fri Jun 29, 2007 9:41 pm
Contact:

Re: add *.bmp to ks108

Post by mohandino »

Benj wrote:Hello

Yes it is possible to add the function to the C code. However the hard part is going to be getting the image data into the compiled program. PIC microcontrollers generally only like arrays of 256 bytes or less. AVRs are much better at handling large arrays so using an AVR might be an option. Otherwise you are forced to find a way to stream the data into the device as it is needed. Eg SD, USB.

I came across things like this by doing a google search for "PIC ks0108 bmp"

http://www.edaboard.com/ftopic49565.html
Hello Benj,

I've modified the ks108 librairy .

But when flowcode compile, there's this error :

C:\LCD\test_flowcode\Test.c(783): error: total number of array elements can not exceed 0x100
C:\LCD\test_flowcode\Test.c(867): error: error in expression

the line concerned is :

Code: Select all

unsigned char const SYMS[1024] = {
from my bmp file :

Code: Select all

unsigned char const SYMS[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,192,240, 16,176, 48, 32,176,112, 32,128,  0,  0,  0,  0,  0, 
 128,128,128,128,128,128,128,240, 56, 24,248,  8,200,  8, 48,  0, 
 192,128,128,128,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,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,192,192, 32, 32, 32, 16, 16, 16,  0,  8, 14, 
  31, 23, 33, 64,129,  2,  4, 15, 16,  8,  7,  1,123,  3,  3,  5, 
 121,225, 65, 64, 64, 64, 64, 65, 65,194,194,197, 67, 72, 82,113, 
  33, 63,188,128,  1, 31, 60, 32, 64, 64,128,128,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, 
 128,128, 64, 32,  0, 16,  0,  8,  8,  8,  8,  8,  8,200, 24,  8, 
   8,  8,104, 24, 24, 24, 48, 96,192,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,192,254,127,  0,  1,  0,  2,  4,  8, 16, 32, 64,128, 
 128, 64, 64, 32, 32, 17, 26, 12, 28, 36,196,  2,  3,  0,  0,224, 
  16,  8,196, 50, 40,  5,  5,194, 38, 64,160, 17,185,145,145,153, 
 129,146,148, 48,114,194,192,157,140, 26, 36, 68,  9,145,103,140, 
  56, 96,192,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 64, 48, 24,  4,194, 
  33, 16,  0,  4,  4,128,194, 64,  0, 32,  0,  2, 66, 76, 64,  0, 
   0,  1, 14, 48,  0,  1, 32,124, 15,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  1,  3,  2,  4,  4,  6,  4,  8, 24, 48, 32, 64, 
 192,128,  0,  0,  0,  0,  0,  0,  0,  0,  0,  3,  4, 16, 64,135, 
   8, 32,  7, 76, 80,168, 32,  0, 64,  2,  5,130,133,136,136, 16, 
  16, 24,136,140,134,  5, 67, 98,  8,  0,  4,140, 64, 33, 16,  7, 
   0,  0,  1,  3, 14, 24, 48,192,128,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,224, 28,  7,  1,128,112, 12,  3,128, 
 128,  0,112, 12, 66, 65, 64, 64,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,128,  0,224, 
 192,208,129,218, 38,  4,  0, 16, 48, 32, 64,192,128,  0,  0,  1, 
   6,  8,112, 16, 32,  0,  0,  1, 16,144,146,146,144,144,128,128, 
 128,  0,  0, 66, 66, 74, 72, 72, 73, 72, 64,  0,  0, 32, 32, 36, 
  36, 36, 36,100, 68, 64, 64, 64,  1, 63,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,255,129,  0,  0,  0,  0,  1,  0,  0,  0, 
  15, 96,128,  0,  0, 30, 32,128,  0,  3, 22, 12,112,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,128,  8,  2,  0,128,202, 
  47, 25,  7,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  2,  2,  2, 
   4,  4,  4,  4,  4,  0,  2,  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,  3,  2,  4,  0,  8,  0, 16, 16, 16, 
 224,  0,192, 17,148, 24,  0, 16, 17,  2,  4,140,136, 15,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,128,128, 64,  0, 96, 32, 56, 24,  9,141, 36, 36,  0,  5,  1, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  2,  0,  0,  0,  0,  4,  2,  5,  8,  2,  4,  0,  8,  4,  8, 
   1,  3, 24,  5, 24, 20, 16, 28,  0, 22,  0,  8,  1,  9,  0,  8, 
   8,  7,  8,  1,  4,  0,  7,  2,  3,  1,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 
};
my code to tranfert the *.bmp is :

Code: Select all

void loadimg(rom char *image) // moh


{
    char i,x,y;
    
    int z = 0;
    int len = 1024;
    while(z != len)            
    {

    for(i=0;i<8;i++){

        y = 0xB8 + i;
        MX_WriteData (y);  
        MX_WriteData (0x40);

        for(x=0;x<64;x++){
            if(z == len)
                break;
            MX_WriteData (*image);
            image++;
            z++;
        }

        y = 0xB8 + i;
        MX_WriteData (y);  
        MX_WriteData (0x40);

        for(x=0;x<64;x++){
            if(z == len)
                break;
            MX_WriteData (*image);
            image++;
            z++;
        }

        if(z == len)
            break;
    }
    if(z == len)
        break;
    
    }
}
Is someone can help me ?

thanks

User avatar
Benj
Matrix Staff
Posts: 14929
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: add *.bmp to ks108

Post by Benj »

Hello

PICmicro devices cannot handle arrays greater then 256 bytes in size. If your array is larger then this then you can split it into several small enough arrays and then simply switch to the next array once you have streamed the data from one. On an AVR or ARM the array size is not limited like this.

mohandino
Posts: 22
Joined: Fri Jun 29, 2007 9:41 pm
Contact:

Re: add *.bmp to ks108

Post by mohandino »

Benj wrote:Hello

PICmicro devices cannot handle arrays greater then 256 bytes in size. If your array is larger then this then you can split it into several small enough arrays and then simply switch to the next array once you have streamed the data from one. On an AVR or ARM the array size is not limited like this.
Hello,

My program is for a pic 16f877a. The code works for a pic 18f452. Have you got a explanation ?

thanks

User avatar
Benj
Matrix Staff
Posts: 14929
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: add *.bmp to ks108

Post by Benj »

Hello

The 18F devices can have larger arrays if they access their internal flash. This is essentially a huge array but you only get around 10,000 read/write operations before the flash becomes unusable. The 16F devices do not have the advanced features and as such the chip does not have direct read/write access to flash. This means you have to use RAM which has the 256 byte limitation.

Post Reply