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

Discussion in 'Embedded Systems and Microcontrollers' started by roberty, May 12, 2012.

  1. roberty

    Thread Starter New Member

    Aug 18, 2010
    11
    0
    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...

    Code ( (Unknown Language)):
    1. #include <delay.h>
    2. #include <mega32.h>
    3. // Graphic LCD functions
    4. #include <glcd.h>
    5. // Font used for displaying text
    6. // on the graphic LCD
    7. #include <font5x7.h>
    8.    GLCDINIT_t glcd_init_data;
    9.   int i,j,p,a2d;
    10.   int k=0;
    11. int data[128];
    12. flash unsigned char picture1[]={
    13.  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,
    14.  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,
    15.  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    16.  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,
    17.  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,
    18. 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,
    19. 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,
    20. };
    21.  
    22.  
    23. // ADC interrupt service routine
    24. interrupt [ADC_INT] void adc_isr(void)
    25. {
    26. if (k<128)
    27.     {
    28.       k++;
    29.      data[k]=ADCW;
    30.       glcd_setpixel (k,data[k]);
    31.      ADCSRA|=1<<ADSC;
    32.      }
    33. }
    34.  
    35. void main(void)
    36. {
    37. PORTB=0x00;
    38. DDRB=0x00;
    39. // Graphic LCD initialization
    40. // The KS0108 connections are specified in the
    41. // Project|Configure|C Compiler|Libraries|Graphic LCD menu:
    42. // DB0 - PORTC Bit 0
    43. // DB1 - PORTC Bit 1
    44. // DB2 - PORTC Bit 2
    45. // DB3 - PORTC Bit 3
    46. // DB4 - PORTC Bit 4
    47. // DB5 - PORTC Bit 5
    48. // DB6 - PORTC Bit 6
    49. // DB7 - PORTC Bit 7
    50. // E - PORTD Bit 0
    51. // RD /WR - PORTB Bit 1
    52. // RS - PORTB Bit 2
    53. // /RST - PORTB Bit 3
    54. // CS1 - PORTD Bit 4
    55. // CS2 - PORTD Bit 5
    56. // Specify the current font for displaying text
    57. glcd_init_data.font=font5x7;
    58. // No function is used for reading
    59. // image data from external memory
    60. glcd_init_data.readxmem=NULL;
    61. // No function is used for writing
    62. // image data to external memory
    63. glcd_init_data.writexmem=NULL;
    64.  
    65. glcd_init(&glcd_init_data);
    66.  
    67. [COLOR="Red"]glcd_putimagef(0,0, picture1,GLCD_PUTCOPY);
    68. delay_ms(2000);[/COLOR]
    69.  
    70. while (1)
    71.       {  
    72.        
    73.         glcd_clear();
    74.       for (i=0;i<128;i+=2){
    75.       glcd_setpixel (64,i);
    76.       }
    77.       for (j=0;j<128;j+=2){
    78.       glcd_setpixel (j,32);
    79.       }
    80.       glcd_putcharxy( 1, 56, 'v');
    81.       glcd_putcharxy( 66, 56, 't');
    82.       glcd_putcharxy( 6, 56, '=');
    83.       glcd_putcharxy( 71, 56, '=');
    84.       selectch();
    85.       ADCSRA = 0b11100111;
    86.       ADMUX = 0b01100000;
    87.       SFIOR = 0x00;
    88.       a2d = ADCW;
    89.       p =  (1024 - (a2d))/16;
    90.       for( i=0;i<1024;i++){
    91.       for(j=0;j<=a2d ; j++)
    92.       glcd_setpixel (p,i);
    93.       }
    94.  
    95. for (i=0;i<127;i++){
    96. do{
    97. i=0;
    98. glcd_setpixel(i,p);
    99. delay_us(100);
    100. i++;
    101. if(i==128)
    102. i=0;
    103. }
    104. while(1);
    105. }
    106. }
    107. }
    108. ///////////// defination of selechch.
    109. void selectch (void)
    110. {
    111. do{
    112. //// first key for first channel
    113. if(PINB.0)
    114.    {
    115.     delay_ms(20);  
    116.     if(PINB.0)
    117.     {
    118.     glcd_outtextxyf (2,5,"SEL CH1");
    119.     delay_ms(400);
    120.     for(i=0;i<15;i++){
    121.     for(j=0;j<45;j++){
    122.     glcd_clrpixel (i,j);
    123.     }
    124.     }
    125.      ADMUX = 0b01100000;
    126.        while(PINB.0);  
    127.     }
    128.    }
    129. else
    130. /// secind key for second channel
    131.    if(PINB)
    132.    {
    133.     delay_ms(20);  
    134.     if(PINB)
    135.     {
    136.     glcd_outtextxyf (2,5,"SEL CH2");
    137.     delay_ms(400);
    138.     for(i=0;i<30;i++){
    139.     glcd_clrpixel (2,i);
    140.      ADMUX = 0b01100001;
    141.      }
    142.        while(PINB);  
    143.     }
    144.    }
    145.  else
    146.  ///// third key for both channel ((hamzaman ))
    147.    if(PINB)
    148.    {
    149.     delay_ms(20);  
    150.     if(PINB)
    151.     {
    152.     glcd_outtextxyf (2,5,"SEL CH1&2");
    153.     delay_ms(400);
    154.     for(i=0;i<35;i++){
    155.     glcd_clrpixel (2,i);
    156.     }
    157.     do{
    158.      ADMUX = 0b01100001;
    159.      delay_ms(10);
    160.      ADMUX = 0b01100000;
    161.      delay_ms(10);
    162.      }
    163.      while(1);
    164.      while(PINB);  
    165.     }
    166.    }
    167.    }
    168.    while(1);    
    169. }
    170.  
    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.
     
Loading...