respected
Joined: 16 May 2006 Posts: 95
|
|
Posted: Fri Mar 16, 2012 2:44 pm |
|
|
https://rapidshare.com/files/716677538/HMG2864-P13.pdf
it is datasheet
Code: |
glcdserial.c
//Speed
#define Speed 8 //4,8,20
//Pinout
#define SDO PIN_B5 // RD0 pin-19 pin-13 Serial data
#define SCL PIN_B4 //lcdport.4 // RD1 pin-20 pin-05 Serial clock
#define DC PIN_B3 //lcdport.5 // RD2 pin-21 pin-04 Data or Command mode
#define RST PIN_B2 //lcdport.6 // RD4 pin-23 pin-14 LCD Reset
#define CS PIN_B1 //lcdport.7 // RD3 pin-22 pin-02 LCD Chip select
//Styles
#define None 0x00
#define Strike 0x10
#define DblStrike 0x24
#define Underline 0x80
#define Overline 0x01
//Prototypes
#define bitset(var,bitno) (var|=1<<bitno);
#define bitclr(var,bitno) (var&=~(1<<bitno));
void CLS(void);
void LCD_Init(void);
void SendBuff(void);
void LCD_Reset(void);
void ClearBuff(void);
void SendByte(unsigned char data);
void LCDCircle(char x0, char y0, char radius);
unsigned char bitchk(unsigned char var,char bitno);
void SetPixel(unsigned char top, unsigned char left);
void LCD_Send(unsigned char cmd, unsigned char type);
void LCDRect(char x0, char y0, char width, char height);
void LCDImage(rom unsigned char *image,char left, char top);
void LCDLine(char top0, char left0, char top1, char left1);
void LCDCube(char Sq0T,char Sq0L,char Sq1T,char Sq1L,char width, char height);
void LCDChar(unsigned char letter,unsigned char font,unsigned char style,unsigned char top, unsigned char left);
void LCDString(rom unsigned char *str,unsigned char font,unsigned char style,unsigned char top, unsigned char left);
unsigned char ScreenBuff[8][96];
byte const Font5x7[98][5] = {
{ 0x00,0x00,0x00,0x00,0x00 }, // 20 space
{ 0x00,0x00,0x5f,0x00,0x00 }, // 21 !
{ 0x00,0x07,0x00,0x07,0x00 }, // 22 "
{ 0x14,0x7f,0x14,0x7f,0x14 }, // 23 #
{ 0x24,0x2a,0x7f,0x2a,0x12 }, // 24 $
{ 0x23,0x13,0x08,0x64,0x62 }, // 25 %
{ 0x36,0x49,0x55,0x22,0x50 }, // 26 &
{ 0x00,0x05,0x03,0x00,0x00 }, // 27 '
{ 0x00,0x1c,0x22,0x41,0x00 }, // 28 (
{ 0x00,0x41,0x22,0x1c,0x00 }, // 29 )
{ 0x14,0x08,0x3e,0x08,0x14 }, // 2a *
{ 0x08,0x08,0x3e,0x08,0x08 }, // 2b +
{ 0x00,0x50,0x30,0x00,0x00 }, // 2c ,
{ 0x08,0x08,0x08,0x08,0x08 }, // 2d -
{ 0x00,0x60,0x60,0x00,0x00 }, // 2e .
{ 0x20,0x10,0x08,0x04,0x02 }, // 2f /
{ 0x3e,0x51,0x49,0x45,0x3e }, // 30 0
{ 0x00,0x42,0x7f,0x40,0x00 }, // 31 1
{ 0x42,0x61,0x51,0x49,0x46 }, // 32 2
{ 0x21,0x41,0x45,0x4b,0x31 }, // 33 3
{ 0x18,0x14,0x12,0x7f,0x10 }, // 34 4
{ 0x27,0x45,0x45,0x45,0x39 }, // 35 5
{ 0x3c,0x4a,0x49,0x49,0x30 }, // 36 6
{ 0x01,0x71,0x09,0x05,0x03 }, // 37 7
{ 0x36,0x49,0x49,0x49,0x36 }, // 38 8
{ 0x06,0x49,0x49,0x29,0x1e }, // 39 9
{ 0x00,0x36,0x36,0x00,0x00 }, // 3a :
{ 0x00,0x56,0x36,0x00,0x00 }, // 3b ;
{ 0x08,0x14,0x22,0x41,0x00 }, // 3c <
{ 0x14,0x14,0x14,0x14,0x14 }, // 3d =
{ 0x00,0x41,0x22,0x14,0x08 }, // 3e >
{ 0x02,0x01,0x51,0x09,0x06 }, // 3f ?
{ 0x32,0x49,0x79,0x41,0x3e }, // 40 @
{ 0x7e,0x11,0x11,0x11,0x7e }, // 41 A
{ 0x7f,0x49,0x49,0x49,0x36 }, // 42 B
{ 0x3e,0x41,0x41,0x41,0x22 }, // 43 C
{ 0x7f,0x41,0x41,0x22,0x1c }, // 44 D
{ 0x7f,0x49,0x49,0x49,0x41 }, // 45 E
{ 0x7f,0x09,0x09,0x09,0x01 }, // 46 F
{ 0x3e,0x41,0x49,0x49,0x7a }, // 47 G
{ 0x7f,0x08,0x08,0x08,0x7f }, // 48 H
{ 0x00,0x41,0x7f,0x41,0x00 }, // 49 I
{ 0x20,0x40,0x41,0x3f,0x01 }, // 4a J
{ 0x7f,0x08,0x14,0x22,0x41 }, // 4b K
{ 0x7f,0x40,0x40,0x40,0x40 }, // 4c L
{ 0x7f,0x02,0x0c,0x02,0x7f }, // 4d M
{ 0x7f,0x04,0x08,0x10,0x7f }, // 4e N
{ 0x3e,0x41,0x41,0x41,0x3e }, // 4f O
{ 0x7f,0x09,0x09,0x09,0x06 }, // 50 P
{ 0x3e,0x41,0x51,0x21,0x5e }, // 51 Q
{ 0x7f,0x09,0x19,0x29,0x46 }, // 52 R
{ 0x46,0x49,0x49,0x49,0x31 }, // 53 S
{ 0x01,0x01,0x7f,0x01,0x01 }, // 54 T
{ 0x3f,0x40,0x40,0x40,0x3f }, // 55 U
{ 0x1f,0x20,0x40,0x20,0x1f }, // 56 V
{ 0x3f,0x40,0x38,0x40,0x3f }, // 57 W
{ 0x63,0x14,0x08,0x14,0x63 }, // 58 X
{ 0x07,0x08,0x70,0x08,0x07 }, // 59 Y
{ 0x61,0x51,0x49,0x45,0x43 }, // 5a Z
{ 0x00,0x7f,0x41,0x41,0x00 }, // 5b [
{ 0x02,0x04,0x08,0x10,0x20 }, // 5c 55
{ 0x00,0x41,0x41,0x7f,0x00 }, // 5d ]
{ 0x04,0x02,0x01,0x02,0x04 }, // 5e ^
{ 0x40,0x40,0x40,0x40,0x40 }, // 5f _
{ 0x00,0x01,0x02,0x04,0x00 }, // 60 `
{ 0x20,0x54,0x54,0x54,0x78 }, // 61 a
{ 0x7f,0x48,0x44,0x44,0x38 }, // 62 b
{ 0x38,0x44,0x44,0x44,0x20 }, // 63 c
{ 0x38,0x44,0x44,0x48,0x7f }, // 64 d
{ 0x38,0x54,0x54,0x54,0x18 }, // 65 e
{ 0x08,0x7e,0x09,0x01,0x02 }, // 66 f
{ 0x0c,0x52,0x52,0x52,0x3e }, // 67 g
{ 0x7f,0x08,0x04,0x04,0x78 }, // 68 h
{ 0x00,0x44,0x7d,0x40,0x00 }, // 69 i
{ 0x20,0x40,0x44,0x3d,0x00 }, // 6a j
{ 0x7f,0x10,0x28,0x44,0x00 }, // 6b k
{ 0x00,0x41,0x7f,0x40,0x00 }, // 6c l
{ 0x7c,0x04,0x18,0x04,0x78 }, // 6d m
{ 0x7c,0x08,0x04,0x04,0x78 }, // 6e n
{ 0x38,0x44,0x44,0x44,0x38 }, // 6f o
{ 0x7c,0x14,0x14,0x14,0x08 }, // 70 p
{ 0x08,0x14,0x14,0x18,0x7c }, // 71 q
{ 0x7c,0x08,0x04,0x04,0x08 }, // 72 r
{ 0x48,0x54,0x54,0x54,0x20 }, // 73 s
{ 0x04,0x3f,0x44,0x40,0x20 }, // 74 t
{ 0x3c,0x40,0x40,0x20,0x7c }, // 75 u
{ 0x1c,0x20,0x40,0x20,0x1c }, // 76 v
{ 0x3c,0x40,0x30,0x40,0x3c }, // 77 w
{ 0x44,0x28,0x10,0x28,0x44 }, // 78 x
{ 0x0c,0x50,0x50,0x50,0x3c }, // 79 y
{ 0x44,0x64,0x54,0x4c,0x44 }, // 7a z
{ 0x00,0x08,0x36,0x41,0x00 }, // 7b {
{ 0x00,0x00,0x7f,0x00,0x00 }, // 7c |
{ 0x00,0x41,0x36,0x08,0x00 }, // 7d }
{ 0x10,0x08,0x08,0x10,0x08 }, // 7e ~
{ 0x78,0x46,0x41,0x46,0x78 }, // 7f ¦
{ 0x18,0x3C,0x7E,0xDB,0x99 } //Custom Arrow // Now ASCII: 128
};
byte const Font8x8[98][8] =
{
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 32
{ 0x00,0x00,0x00,0x5F,0x5F,0x00,0x00,0x00 }, // ASCII - 33
{ 0x00,0x00,0x03,0x07,0x00,0x07,0x03,0x00 }, // ASCII - 34
{ 0x00,0x10,0x74,0x1C,0x77,0x1C,0x17,0x04 }, // ASCII - 35
{ 0x00,0x24,0x2E,0x2A,0x7F,0x2A,0x3A,0x10 }, // ASCII - 36
{ 0x00,0x4C,0x6A,0x76,0x1A,0x6A,0x56,0x33 }, // ASCII - 37
{ 0x00,0x30,0x7A,0x4F,0x5D,0x37,0x7A,0x48 }, // ASCII - 38
{ 0x00,0x00,0x04,0x07,0x03,0x00,0x00,0x00 }, // ASCII - 39
{ 0x00,0x00,0x00,0x1C,0x3E,0x63,0x41,0x00 }, // ASCII - 40
{ 0x00,0x00,0x41,0x63,0x3E,0x1C,0x00,0x00 }, // ASCII - 41
{ 0x00,0x08,0x2A,0x3E,0x1C,0x3E,0x2A,0x08 }, // ASCII - 42
{ 0x00,0x08,0x08,0x3E,0x3E,0x08,0x08,0x00 }, // ASCII - 43
{ 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00 }, // ASCII - 44
{ 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00 }, // ASCII - 45
{ 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00 }, // ASCII - 46
{ 0x00,0x60,0x30,0x18,0x0C,0x06,0x03,0x01 }, // ASCII - 47
{ 0x00,0x1C,0x3E,0x61,0x43,0x3E,0x1C,0x00 }, // ASCII - 48
{ 0x00,0x00,0x44,0x7F,0x7F,0x40,0x00,0x00 }, // ASCII - 49
{ 0x00,0x46,0x67,0x71,0x59,0x4F,0x66,0x00 }, // ASCII - 50
{ 0x00,0x22,0x63,0x49,0x4D,0x7F,0x32,0x00 }, // ASCII - 51
{ 0x00,0x18,0x1C,0x52,0x7F,0x7F,0x50,0x00 }, // ASCII - 52
{ 0x00,0x2F,0x6F,0x45,0x45,0x7D,0x39,0x00 }, // ASCII - 53
{ 0x00,0x3C,0x7E,0x4B,0x49,0x79,0x30,0x00 }, // ASCII - 54
{ 0x00,0x07,0x43,0x71,0x7D,0x0F,0x03,0x00 }, // ASCII - 55
{ 0x00,0x36,0x7F,0x4D,0x59,0x7F,0x36,0x00 }, // ASCII - 56
{ 0x00,0x06,0x4F,0x49,0x69,0x3F,0x1E,0x00 }, // ASCII - 57
{ 0x00,0x00,0x00,0x66,0x66,0x00,0x00,0x00 }, // ASCII - 58
{ 0x00,0x00,0x00,0x66,0x66,0x00,0x00,0x00 }, // ASCII - 59
{ 0x00,0x00,0x08,0x1C,0x36,0x63,0x41,0x00 }, // ASCII - 60
{ 0x00,0x14,0x14,0x14,0x14,0x14,0x14,0x00 }, // ASCII - 61
{ 0x00,0x00,0x41,0x63,0x36,0x1C,0x08,0x00 }, // ASCII - 62
{ 0x00,0x02,0x07,0x51,0x59,0x0F,0x06,0x00 }, // ASCII - 63
{ 0x00,0x3E,0x41,0x5D,0x55,0x5D,0x51,0x1E }, // ASCII - 64
{ 0x00,0x40,0x70,0x1D,0x17,0x1F,0x78,0x60 }, // ASCII - 65
{ 0x00,0x41,0x7F,0x7F,0x49,0x4F,0x7E,0x30 }, // ASCII - 66
{ 0x00,0x1C,0x3E,0x63,0x41,0x41,0x42,0x27 }, // ASCII - 67
{ 0x00,0x41,0x7F,0x7F,0x41,0x63,0x3E,0x1C }, // ASCII - 68
{ 0x00,0x41,0x7F,0x7F,0x49,0x5D,0x41,0x63 }, // ASCII - 69
{ 0x00,0x41,0x7F,0x7F,0x49,0x1D,0x01,0x03 }, // ASCII - 70
{ 0x00,0x1C,0x3E,0x63,0x41,0x51,0x72,0x77 }, // ASCII - 71
{ 0x00,0x7F,0x7F,0x08,0x08,0x7F,0x7F,0x00 }, // ASCII - 72
{ 0x00,0x00,0x41,0x7F,0x7F,0x41,0x00,0x00 }, // ASCII - 73
{ 0x00,0x30,0x70,0x41,0x41,0x7F,0x3F,0x01 }, // ASCII - 74
{ 0x00,0x7F,0x7F,0x08,0x1C,0x77,0x63,0x41 }, // ASCII - 75
{ 0x00,0x41,0x7F,0x7F,0x41,0x40,0x60,0x70 }, // ASCII - 76
{ 0x00,0x7F,0x7E,0x0C,0x18,0x0C,0x7E,0x7F }, // ASCII - 77
{ 0x00,0x7F,0x7E,0x0C,0x18,0x30,0x7F,0x7F }, // ASCII - 78
{ 0x00,0x1C,0x3E,0x63,0x41,0x63,0x3E,0x1C }, // ASCII - 79
{ 0x00,0x41,0x7F,0x7F,0x49,0x09,0x0F,0x06 }, // ASCII - 80
{ 0x00,0x1C,0x3E,0x63,0x51,0x63,0x3E,0x1C }, // ASCII - 81
{ 0x00,0x7F,0x7F,0x09,0x19,0x7F,0x66,0x40 }, // ASCII - 82
{ 0x00,0x66,0x6F,0x4D,0x59,0x7B,0x33,0x00 }, // ASCII - 83
{ 0x00,0x03,0x41,0x7F,0x7F,0x41,0x03,0x00 }, // ASCII - 84
{ 0x00,0x3F,0x7F,0x40,0x40,0x40,0x7F,0x3F }, // ASCII - 85
{ 0x00,0x03,0x0F,0x3D,0x70,0x1D,0x07,0x01 }, // ASCII - 86
{ 0x00,0x0F,0x7F,0x30,0x1C,0x30,0x7F,0x0F }, // ASCII - 87
{ 0x00,0x63,0x77,0x1C,0x1C,0x77,0x63,0x00 }, // ASCII - 88
{ 0x01,0x03,0x47,0x7C,0x78,0x47,0x03,0x01 }, // ASCII - 89
{ 0x00,0x67,0x73,0x59,0x4D,0x67,0x73,0x00 }, // ASCII - 90
{ 0x00,0x00,0x00,0x7F,0x7F,0x41,0x41,0x00 }, // ASCII - 91
{ 0x00,0x01,0x03,0x06,0x0C,0x18,0x30,0x60 }, // ASCII - 92
{ 0x00,0x00,0x41,0x41,0x7F,0x7F,0x00,0x00 }, // ASCII - 93
{ 0x00,0x00,0x04,0x06,0x03,0x06,0x04,0x00 }, // ASCII - 94
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 95
{ 0x00,0x00,0x01,0x03,0x06,0x04,0x00,0x00 }, // ASCII - 96
{ 0x00,0x68,0x6C,0x54,0x54,0x3C,0x78,0x40 }, // ASCII - 97
{ 0x00,0x41,0x7F,0x3F,0x6C,0x44,0x7C,0x38 }, // ASCII - 98
{ 0x00,0x38,0x7C,0x44,0x44,0x6C,0x2C,0x00 }, // ASCII - 99
{ 0x00,0x38,0x7C,0x44,0x49,0x3F,0x7F,0x40 }, // ASCII - 100
{ 0x00,0x38,0x7C,0x54,0x54,0x5C,0x58,0x00 }, // ASCII - 101
{ 0x00,0x00,0x48,0x7E,0x7F,0x49,0x0B,0x02 }, // ASCII - 102
{ 0x00,0x48,0x7C,0x34,0x34,0x2C,0x68,0x44 }, // ASCII - 103
{ 0x00,0x41,0x7F,0x7F,0x08,0x04,0x7C,0x78 }, // ASCII - 104
{ 0x00,0x00,0x44,0x7D,0x7D,0x40,0x00,0x00 }, // ASCII - 105
{ 0x00,0x60,0x60,0x04,0x7D,0x7D,0x00,0x00 }, // ASCII - 106
{ 0x00,0x41,0x7F,0x7F,0x10,0x78,0x6C,0x44 }, // ASCII - 107
{ 0x00,0x00,0x41,0x7F,0x7F,0x40,0x00,0x00 }, // ASCII - 108
{ 0x00,0x7C,0x7C,0x0C,0x78,0x0C,0x7C,0x78 }, // ASCII - 109
{ 0x00,0x44,0x7C,0x7C,0x08,0x04,0x7C,0x78 }, // ASCII - 110
{ 0x00,0x38,0x7C,0x44,0x44,0x7C,0x38,0x00 }, // ASCII - 111
{ 0x00,0x04,0x7C,0x78,0x24,0x24,0x3C,0x18 }, // ASCII - 112
{ 0x00,0x18,0x3C,0x24,0x24,0x78,0x7C,0x00 }, // ASCII - 113
{ 0x00,0x44,0x7C,0x78,0x4C,0x04,0x1C,0x18 }, // ASCII - 114
{ 0x00,0x48,0x5C,0x5C,0x74,0x74,0x24,0x00 }, // ASCII - 115
{ 0x00,0x00,0x04,0x3E,0x7F,0x44,0x24,0x00 }, // ASCII - 116
{ 0x00,0x3C,0x7C,0x40,0x40,0x3C,0x7C,0x40 }, // ASCII - 117
{ 0x00,0x04,0x1C,0x3C,0x60,0x30,0x1C,0x04 }, // ASCII - 118
{ 0x00,0x1C,0x7C,0x30,0x1C,0x30,0x7C,0x1C }, // ASCII - 119
{ 0x00,0x44,0x6C,0x3C,0x10,0x78,0x6C,0x44 }, // ASCII - 120
{ 0x00,0x44,0x4C,0x1C,0x70,0x64,0x1C,0x0C }, // ASCII - 121
{ 0x00,0x4C,0x64,0x74,0x5C,0x4C,0x64,0x00 }, // ASCII - 122
{ 0x00,0x08,0x08,0x3E,0x77,0x41,0x41,0x00 }, // ASCII - 123
{ 0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,0x00 }, // ASCII - 124
{ 0x00,0x41,0x41,0x77,0x3E,0x08,0x08,0x00 }, // ASCII - 125
{ 0x00,0x02,0x01,0x01,0x03,0x02,0x02,0x01 }, // ASCII - 126
{ 0x00,0x60,0x78,0x4E,0x47,0x5E,0x78,0x60 }, // ASCII - 127
{ 0x18,0x3C,0x7E,0xDB,0x99,0x18,0x18,0x18 } //Custom Arrow // Now ASCII: 128
};
unsigned char myMS;
//Prototypes
void LCD_Init(void){
/*
4 MHz = 1000 Cycles
8 MHz = 2000 Cycles
20 MHz = 5000 Cycles
*/
switch(Speed){
case 4:
myMS = 1;
break;
case 8:
myMS = 2;
break;
case 20:
myMS = 5;
break;
}
//LCD_TRIS = 0x00;
//bitset(LCD_TRIS,BTN);
output_high(DC);//(LCD_LATCH,DC);
output_high(RST); // reset chip during 250ms
delay_ms(100); // works with less.....
output_low(RST );
delay_ms(100);
output_high(RST); // reset chip during 250ms
delay_ms(100);
LCD_Send(0xE2,0); // software reset
delay_ms(10);
LCD_Send(0xA2,0); // lcd bias (1/9 0xA2 - 1/7 0xA3)
LCD_Send(0xA0,0); // <ADC select> (0xA1 reverse lcd - 0xA0 select normal) yatay mirror
LCD_Send(0xC8,0); // common output normal (0xC8 reverse) c0 normal ekranın mirror unu alıyor.
LCD_Send(0xA8,0);
LCD_Send(0xA7,0); // lcd in normal display mode (0xA7 negative mode) 0xA6 pozitif mode
LCD_Send(0xA4,0);
LCD_Send(0x24,0); // set internal ra/rb 0x24
LCD_Send(0x81,0); // set contrast
LCD_Send(0x1A,0);
LCD_Send(0x2F,0); // power control set value
delay_ms(40);
LCD_Send(0x40,0); // start line set
LCD_Send(0xAF,0); // lcd on
}
void cls(void){
char page,x;
for (page=0; page<9; page++) // 9 page
{
LCD_Send ((0xB0| page),0); // page address ie:0xB0,0xB1,...,0xB7
LCD_Send(0x10,0); // most 4 bit column address command 0001 0011
LCD_Send(0x00,0); // least 4 bit column address command 0000 0011
for (x=129; x>0; x--) // 96 column
{ LCD_Send(0x00,1);}
}
}
void SendByte(unsigned char data){
char x;
for(x=0;x<8;x++){
output_low(SCL);// bitclr(LCD_LATCH,SCL);
output_low(SDO);// bitclr(LCD_LATCH,SDO);
if(data & 0x80)
output_high(SDO);// bitset(LCD_LATCH,SDO);
output_high(SCL);//bitset(LCD_LATCH,SCL);
data <<= 1;
}
}
void LCD_Send(unsigned char cmd, unsigned char type){
if(type){
output_high(DC);//bitset(LCD_LATCH,DC);
} else {
output_low(DC);// bitclr(LCD_LATCH,DC);
}
output_low(CS);//bitclr(LCD_LATCH,CS);
SendByte(cmd);
output_high(CS);// bitset(LCD_LATCH,CS);
}
void LCD_Reset(void){
output_high(RST);//bitset(LCD_LATCH,CS);
Delay_MS(100);
output_low(RST);//bitset(LCD_LATCH,RST);
Delay_MS(100);
output_high(RST);
Delay_MS(100);
}
void LCDChar(unsigned char letter,unsigned char font,unsigned char style,unsigned char top, unsigned char left){
unsigned char myData,x;
unsigned char leftH,leftL;
top += 0xB0;
left += 18;
leftH = (left >> 4) | 0x10 ;
leftL = left & 0x0F ;
LCD_Send(top,0); //Page 0 (0xBx (x = page))
LCD_Send(leftH,0); //Column Upper Nybble (0x1x) (x = upper Nybble)
LCD_Send(leftL,0); //Column Lower Nybble (0x0x) (x = upper Nybble)
letter -= 0x20;
if(font){
for(x=0;x<8;x++){
myData = Font8x8[letter][x] | style;
LCD_Send(myData,1);
}
} else {
for(x=0;x<5;x++){
myData = Font5x7[letter][x] | style;
LCD_Send(myData,1);
}
}
LCD_Send((0|style),1); //Spacer
}
void LCDString(char *str,unsigned char font,unsigned char style,unsigned char top, unsigned char left){
while(*str != 0){
LCDChar(*str++, font, style, top, left);
if(font)
left += 9;
else
left += 6;
}
}
void LCDImage(rom unsigned char *image,char top, char left){
unsigned char widthLoop, heightLoop;
unsigned char leftH, leftL;
unsigned char width, height;
width = *image++;
height = *image++;
height /= 8;
top += 0xB0;
LCD_Send(top,0);
left += 18;
leftH = (left >> 4) | 0x10 ;
leftL = left & 0x0F ;
for(heightLoop=0;heightLoop<height;heightLoop++){
LCD_Send(top,0);
LCD_Send(leftH,0);
LCD_Send(leftL,0);
for(widthLoop=0;widthLoop<width;widthLoop++){
LCD_Send(*image++,1);
}
top++;
}
}
/*
4 MHz = 1000 Cycles
8 MHz = 2000 Cycles
20 MHz = 5000 Cycles
*/
unsigned char bitchk(unsigned char var,char bitno){
unsigned char tmp;
tmp = var & (1<<bitno);
return tmp;
}
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
void SetPixel(unsigned char top, unsigned char left){
unsigned char x,y,z;
if (left>128) return;
if (top>64) return; //check for illegal addresses
x = top / 8;
z = top % 8;
y=1<<z;
ScreenBuff[x][left] |= y; //set the bit;
}
void SendBuff(void){
unsigned char widthLoop, heightLoop;
unsigned char leftH, leftL;
unsigned char width, height;
unsigned char top, left;
top = 0;
left = 0;
width = 128;
height = 8;
top += 0xB0;
left += 18;
leftH = (left >> 4) | 0x10 ;
leftL = left & 0x0F ;
for(heightLoop=0;heightLoop<height;heightLoop++){
LCD_Send(top,0);
LCD_Send(leftH,0);
LCD_Send(leftL,0);
for(widthLoop=0;widthLoop<width;widthLoop++){
LCD_Send(ScreenBuff[heightLoop][widthLoop],1);
}
top++;
}
}
void ClearBuff(void){
unsigned char x,y;
for(x=0;x<8;x++)
for(y=0;y<96;y++)
ScreenBuff[x][y] = 0;
}
void LCDLine(char top0, char left0, char top1, char left1) {
signed int dy;
signed int dx;
int stepx, stepy;
dy = left1 - left0;
dx = top1 - top0;
if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
dy <<= 1; // dy is now 2*dy
dx <<= 1; // dx is now 2*dx
SetPixel(top0, left0);
if (dx > dy) {
signed int fraction = dy - (dx >> 1); // same as 2*dy - dx
while (top0 != top1) {
if (fraction >= 0) {
left0 += stepy;
fraction -= dx; // same as fraction -= 2*dx
}
top0 += stepx;
fraction += dy; // same as fraction -= 2*dy
SetPixel(top0, left0);
}
} else {
signed int fraction = dx - (dy >> 1);
while (left0 != left1) {
if (fraction >= 0) {
top0 += stepx;
fraction -= dy;
}
left0 += stepy;
fraction += dx;
SetPixel(top0, left0);
}
}
}
void LCDCircle(char x0, char y0, char radius) {
//x0 = center
//y0 = left
signed int f ;
int ddF_x;
int ddF_y;
int x;
int y;
f = 1 - radius;
ddF_x = 0;
ddF_y = -2 * radius;
x = 0;
y = radius;
SetPixel(x0, y0 + radius);
SetPixel(x0, y0 - radius);
SetPixel(x0 + radius, y0);
SetPixel(x0 - radius, y0);
while(x < y) {
if(f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x + 1;
SetPixel(x0 + x, y0 + y);
SetPixel(x0 - x, y0 + y);
SetPixel(x0 + x, y0 - y);
SetPixel(x0 - x, y0 - y);
SetPixel(x0 + y, y0 + x);
SetPixel(x0 - y, y0 + x);
SetPixel(x0 + y, y0 - x);
SetPixel(x0 - y, y0 - x);
}
}
void LCDRect(char x0, char y0, char width, char height) {
LCDLine(x0, y0, x0, y0+width);
LCDLine(x0, y0, x0+height, y0);
LCDLine(x0+height, y0, x0+height, y0+width);
LCDLine(x0, y0+width, x0+height, y0+width);
}
void LCDCube(char Sq0T,char Sq0L,char Sq1T,char Sq1L,char width, char height) {
unsigned char x,y;
unsigned char a,b;
x = Sq0L + width;
y = Sq1L + width;
a = Sq0T + height;
b = Sq1T + height;
LCDRect(Sq0T,Sq0L,width,height);
LCDRect(Sq1T,Sq1L,width,height);
LCDLine(Sq0T,Sq0L,Sq1T,Sq1L);
LCDLine(Sq0T,x,Sq1T,y);
LCDLine(a,Sq0L,b,Sq1L);
LCDLine(a,x,b,y);
} |
pic code :
Code: |
#include <18F26J50.h>
#fuses INTRC, NOWDT,NODEBUG,NOPROTECT,NOFCMEN,NOWPCFG,NOWPDIS,NOSTVREN,NOCPUDIV
#use delay(clock=4M)
#include <glcdserial.c>
void main() {
LCD_Init();
cls();
delay_ms(100);
while(true){
LCDChar(77,1,0,1,0);
LCDChar(78,1,0,1,8);
}
}
|
This code than write. MN appears on the screen.
i want to use glcd_text57() |
|