question about showing a picture on GLCD (( avr and codevision))

Thread Starter

roberty

Joined Aug 18, 2010
11
hi every one

this program that is writen by myself has a problem that i cant solve it...

if you have some experience in working whit GLCD's you know that an image can be converted to a BMP format file and then by using the " flash " datatype we can show that image on the glcd....

ok...i write my programms in codevision 2.05.3 and as you know this version has a lot of functions to work whit GLCDs.
here is the code...

Rich (BB code):
#include <delay.h> 
#include <mega32.h>
// Graphic LCD functions
#include <glcd.h>
// Font used for displaying text
// on the graphic LCD
#include <font5x7.h>
   GLCDINIT_t glcd_init_data;
  int i,j,p,a2d;
  int k=0;
int data[128];
flash unsigned char picture1[]={
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x40,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x10,0x20,0x20,0x20,0x2C,0x1C,0x04,0x04,0x05,0x05,0x00,0x00,0x04,0x04,0x04,0x04,0x05,0x05,0x06,0x04,0x04,0x04,0x02,0x04,0x04,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x06,0x05,0x05,0x04,0x05,0x07,0x04,0x14,0x05,0x00,0x03,0x00,0x00,0x00,0x20,0x20,0x10,0x09,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x02,0x04,0x04,0x04,0x06,0x05,0x05,0x05,0x07,0x00,0x00,0x20,0x20,0x10,0x09,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x14,0x14,0x04,0x04,0x02,0x03,0x05,0x06,0x04,0x04,0x05,0x05,0x06,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x02,0x04,0x04,0x04,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x20,0x20,0x20,0xA0,0x20,0x20,0x20,0x28,0x00,0x00,0x00,0x10,0xA8,0x20,0x20,0x21,0x28,0x20,0x28,0xA8,0x28,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x02,0x00,0x80,0x48,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x88,0x20,0x20,0xA0,0x28,0x20,0x20,0x21,0x20,0x2C,0x00,0x00,0x00,0x00,0x20,0x20,0x22,0x20,0x20,0x28,0x28,0x28,0x30,0x20,0x20,0x00,0x1C,0x00,0x00,0x00,0x00,0xA8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};


// ADC interrupt service routine
interrupt [ADC_INT] void adc_isr(void)
{
if (k<128)
    {
      k++;
     data[k]=ADCW;
      glcd_setpixel (k,data[k]); 
     ADCSRA|=1<<ADSC;
     }
}

void main(void)
{
PORTB=0x00;
DDRB=0x00;
// Graphic LCD initialization
// The KS0108 connections are specified in the
// Project|Configure|C Compiler|Libraries|Graphic LCD menu:
// DB0 - PORTC Bit 0
// DB1 - PORTC Bit 1
// DB2 - PORTC Bit 2
// DB3 - PORTC Bit 3
// DB4 - PORTC Bit 4
// DB5 - PORTC Bit 5
// DB6 - PORTC Bit 6
// DB7 - PORTC Bit 7
// E - PORTD Bit 0
// RD /WR - PORTB Bit 1
// RS - PORTB Bit 2
// /RST - PORTB Bit 3
// CS1 - PORTD Bit 4
// CS2 - PORTD Bit 5
// Specify the current font for displaying text
glcd_init_data.font=font5x7;
// No function is used for reading
// image data from external memory
glcd_init_data.readxmem=NULL;
// No function is used for writing
// image data to external memory
glcd_init_data.writexmem=NULL;

glcd_init(&glcd_init_data);

glcd_putimagef(0,0, picture1,GLCD_PUTCOPY);
delay_ms(2000);

while (1)
      {  
        
        glcd_clear();
      for (i=0;i<128;i+=2){
      glcd_setpixel (64,i);
      }
      for (j=0;j<128;j+=2){
      glcd_setpixel (j,32);
      } 
      glcd_putcharxy( 1, 56, 'v'); 
      glcd_putcharxy( 66, 56, 't');
      glcd_putcharxy( 6, 56, '='); 
      glcd_putcharxy( 71, 56, '=');
      selectch();
      ADCSRA = 0b11100111;
      ADMUX = 0b01100000;
      SFIOR = 0x00;
      a2d = ADCW; 
      p =  (1024 - (a2d))/16;
      for( i=0;i<1024;i++){
      for(j=0;j<=a2d ; j++)
      glcd_setpixel (p,i);
      }

for (i=0;i<127;i++){
do{
i=0;
glcd_setpixel(i,p);
delay_us(100);
i++;
if(i==128)
i=0;
}
while(1);
}
}
}
///////////// defination of selechch.
void selectch (void)
{
do{
//// first key for first channel
if(PINB.0) 
   { 
    delay_ms(20);   
    if(PINB.0) 
    { 
    glcd_outtextxyf (2,5,"SEL CH1");
    delay_ms(400);
    for(i=0;i<15;i++){
    for(j=0;j<45;j++){
    glcd_clrpixel (i,j);
    }
    }
     ADMUX = 0b01100000;
       while(PINB.0);   
    } 
   }
else
/// secind key for second channel
   if(PINB) 
   { 
    delay_ms(20);   
    if(PINB) 
    { 
    glcd_outtextxyf (2,5,"SEL CH2");
    delay_ms(400);
    for(i=0;i<30;i++){
    glcd_clrpixel (2,i);
     ADMUX = 0b01100001;
     }
       while(PINB);   
    } 
   }
 else 
 ///// third key for both channel ((hamzaman ))
   if(PINB) 
   { 
    delay_ms(20);   
    if(PINB) 
    {
    glcd_outtextxyf (2,5,"SEL CH1&2");
    delay_ms(400);
    for(i=0;i<35;i++){
    glcd_clrpixel (2,i);
    }
    do{
     ADMUX = 0b01100001; 
     delay_ms(10);
     ADMUX = 0b01100000;
     delay_ms(10);
     }
     while(1);
     while(PINB);   
    } 
   } 
   }
   while(1);    
}
the problem is shown whit red color.

when i use this function i dont know why but nothing shows on the glcd...!!

so i wanted to ask you if you had some similar experience in sending a picture to your glcd whit this metod.... how can i send that " flash" variables and see my picture on glcd...?

is there anything wrong whit my code...?
remember that the code above is just a pice of my programm.

thanks for the help.
 
Top