mikroC PRO for AVR 2008 Glcd proje_1

Başlatan ahmet2004, 29 Aralık 2008, 16:32:22

ahmet2004

mikroC PRO for AVR 2008 derleyicisi kullanılarak yapılmış(kendi kodu)
Glcd 128x64 ile grafik komutları kullanılmıştır.

İşlemci: ATmega16
Xtal:     16Mhz
Glcd:    KS0108

// ------------------------------------------------------
// GLCD Picture name: ataturk3a.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------

unsigned char const ataturk3a_bmp[1024] = {
   0, 73,  0, 42,128, 16, 66, 40,  1,148, 64, 37, 16,138, 64, 41,
 132, 32,148, 66, 16, 74,160, 10,160, 21,160, 74, 32,149, 64, 36,
 146, 72, 37,144, 74,160, 18,201, 36,146, 65, 24,196, 18,200, 37,
 200, 36,210, 40,194,169,212,162,232, 82,233,180,210,104,213,104,
 178,201,116,160, 90,225, 84,200,114,168,242,169,240,173,240,217,
 116,217,244, 89,244, 89,244,216,106,213,104,218,104,213,168,114,
 200,114,164,161,212, 33,196, 18,201,  4,170, 17, 40, 69, 50,137,
 100,146, 73,178,  9,228, 26,193, 42,208, 10,228, 18,201, 52,129,
   0,169,  4,161, 84, 10, 65, 40,149, 64,149,104,  5,210, 40, 69,
 170, 16,202, 53,136,101,146,108,  2,249,  4,106,149,104,133,122,
 129,124,131,120,198,185,236, 86,249,214,125,235,252,175,250,255,
 170,255,119,253, 95,246,127,219,254,111,251,190,235,255,186,237,
 255,170,255,237,191,247,221,255, 87,253,111,250, 95,251,238,187,
 255,173,255,213,127,235,255,173,255,181,255,215,125,247, 94,251,
 109,255,170,255,106,189,246, 91,173,118, 89,166, 89, 36,146, 64,
  10, 32,131, 42,  5,154,101,154,109,210, 45,218,101,154,109,146,
  16, 74,164, 18,201, 36,146, 77,160, 26,196, 42, 81,172,  2,249,
   6,233, 20,235, 20,234, 21,234, 21,234, 53,202,117,138,117,170,
 213,187, 84,207,117,254,183,221,255, 87,253, 87,254,171,127,234,
 191,237,183,251,223,109,247,191, 85,255,173,247,190,219,111,250,
 175,253, 87,254,171,255,218,111,247,189,215,255, 85,255,170,255,
 213,127,234,191,213,255,170,255, 85,255, 86,251, 93,175,245, 95,
 245, 91,174,245,187, 77,242,169, 86,161,196, 17,160,  5, 16, 74,
   0,169,  4, 80,  2, 72,  2,136,163, 84,171,221,102,153,110, 83,
  66, 41,148, 98, 21,200, 38,217,  2,252,  3,216, 39,216, 39,216,
  39,216,103,152,239, 18,237, 86,169,214, 91,228, 91,172,119,169,
 110,187, 94,235, 39,221,103, 26,111,151, 45,159, 37, 31,141, 87,
  14,171, 79,134, 27, 79, 21,175, 91,175,149,255,154,239, 85,223,
 102,155,239,  5,219,  6,171,  7,165, 71,150,131, 23,197, 39,210,
 135, 21,199, 19,198, 19,134, 83,133, 83,165,134,211,109,166,219,
 173,251,173,118,219,109,182,219,109,183,218,173,118,173,246,169,
 222,108, 22,106,183,  3,249,165, 80,171, 64,215,122,141,243, 93,
  65, 28,195, 56,133,122,133,114,140,115,136,119,136,247,  8,247,
   8,247, 42,213,110,177, 78,251, 37,218,109,182,107,182,219,173,
 123,173,215, 61,223, 53,222,123,173,126,213,250,111,249,190,235,
 189,246,221,122,223,106,253,174,245,254,171,255,254,171,255, 93,
 247, 93,246, 91,237,182,253,151,252, 55,218,126,171,253,186,237,
 222,117,190,235,126,181,223,106,191,109,151,254, 11,253, 15,246,
  11,189, 70,155, 77, 39,153,102,137,119,136,119,172, 87,250,223,
 106,255,213,126,213,126, 19, 46, 17, 31, 85, 10, 63,  9,182, 13,
  81, 12,227, 24,103,144,111,144,107, 20,235, 20,235, 20,235, 21,
 238, 51,204,119,153,102,189,211, 61,202,117,207,117,154,247, 90,
 173,247,170,127,168,247,168,215, 41,213, 58,197, 59,196,179, 73,
 230, 49,218,111,179, 77,243, 78,179,207, 98,143, 99,202, 71,227,
   5,243, 69,179, 73,114, 73,181, 90,101, 90,111, 16,127,136,115,
  24,167, 81,170, 85,170,117,142,113,158, 65,190, 65, 46,145,110,
 145,110, 81, 46,209, 14,241, 10,116, 11, 36, 18,  5, 34,  5,  0,
   1, 32,  4, 64,  0,  0,136,  1, 16,128,  2,  0, 17,  0, 68,  0,
   8,165, 82, 44,131,120,  6,233, 22,105,150,105,150,105,150,105,
 182, 75,245, 26,231, 58,213,174,117,171, 93, 42, 61,  7,188,  7,
  42,141,  6,163,  5, 74,  1, 34,129,  8, 33,134,  1,150, 37, 18,
  79, 49, 94, 43,244,191, 82,254, 82,252, 74,244, 78,242, 92,162,
 252,166,216,110,210,173,118,218,165,254, 85,238,181, 91,246, 75,
 125, 22,109, 18, 15, 32, 15, 32,  2, 41,  0, 20, 74,  1, 22,  1,
  66,  9,  2, 33,  2,  1, 16,  2,  0, 32,  1,  0,136,  0,  1, 32,
   2, 64,  0,  4,  0, 64,  8,  0,128,  0,  8,129,  0,  0,136,  0,
   0, 85, 40, 69,146, 41, 70, 49,142, 97, 30,161, 94, 33, 30, 33,
  30,  1, 46,  1,  7, 17,  1,  4, 17,  0,  4,  1, 16,  0,  2, 32,
   0, 74, 32,146,104, 22,169, 82,137, 52,139, 84, 10,  4, 66,  0,
   9,  0, 33,  0,  2,200,187,225,181,195,165,203,  5,163,133,195,
 133,194,135,193,  7,193,  7,161,  6,129,  3, 16,  3,  0,  1,  8,
   0,  1,  0, 16,  1, 32,  0,  0, 17,  0,  0, 18,  0,  0, 16,  2,
   0,  0, 18,  0,  0,  1,  8,  0,  1,  0,  8,  0, 16,  0,  0,  2,
   0, 16,  0,  2,  0,  8,  0,  0,  8,  0,  0,  8,  0,  0,  8,  0
};


// Glcd module connections
char GLCD_DataPort at PORTC;
char GLCD_DataPort_Direction at DDRC;

sbit GLCD_CS1 at PORTD.B2;
sbit GLCD_CS2 at PORTD.B3;
sbit GLCD_RS  at PORTD.B4;
sbit GLCD_RW  at PORTD.B5;
sbit GLCD_EN  at PORTD.B6;
sbit GLCD_RST at PORTD.B7;

sbit GLCD_CS1_Direction at DDRD.B2;
sbit GLCD_CS2_Direction at DDRD.B3;
sbit GLCD_RS_Direction  at DDRD.B4;
sbit GLCD_RW_Direction  at DDRD.B5;
sbit GLCD_EN_Direction  at DDRD.B6;
sbit GLCD_RST_Direction at DDRD.B7;
// End Glcd module connections

void delay2S(){                             // 2 seconds delay function
  Delay_ms(2000);
}

void main() {
  unsigned short ii;
  char *someText;

  Glcd_Init();                              // Initialize GLCD
  Glcd_Fill(0x00);                          // Clear GLCD

  while(1) {
    Glcd_Image(ataturk3a_bmp);                  // Draw image
    delay2S(); delay2S();

    Glcd_Fill(0x00);                        // Clear GLCD

    Glcd_Box(62,40,124,56,1);               // Draw box
    Glcd_Rectangle(5,5,84,35,1);            // Draw rectangle
    Glcd_Line(0, 0, 127, 63, 1);            // Draw line
    delay2S();

    for(ii = 5; ii < 60; ii+=5 ){           // Draw horizontal and vertical lines
      Delay_ms(250);
      Glcd_V_Line(2, 54, ii, 1);
      Glcd_H_Line(2, 120, ii, 1);
    }

    delay2S();

    Glcd_Fill(0x00);                        // Clear GLCD

    Glcd_Set_Font(Character8x7, 8, 7, 32);  // Choose font, see __Lib_GLCDFonts.c in Uses folder
    Glcd_Write_Text("picproje", 1, 7, 2);     // Write string

    for (ii = 1; ii <= 10; ii++)            // Draw circles
      Glcd_Circle(63,32, 3*ii, 1);
    delay2S();

    Glcd_Box(12,20, 70,57, 2);              // Draw box
    delay2S();

    Glcd_Fill(0xFF);                        // Fill GLCD

    Glcd_Set_Font(Character8x7, 8, 7, 32);  // Change font
    someText = "8x7 Font";
    Glcd_Write_Text(someText, 5, 0, 2);     // Write string
    delay2S();

    Glcd_Set_Font(System3x5, 3, 5, 32);     // Change font
    someText = "3X5 CAPITAL";
    Glcd_Write_Text(someText, 60, 2, 2);    // Write string
    delay2S();

    Glcd_Set_Font(font5x7, 5, 7, 32);       // Change font
    someText = "5x7 Font";
    Glcd_Write_Text(someText, 5, 4, 2);     // Write string
    delay2S();

    Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32); // Change font
    someText = "5x7 Font (v2)";
    Glcd_Write_Text(someText, 50, 6, 2);     // Write string
    delay2S();
  }
}