|
|
View previous topic :: View next topic |
Author |
Message |
Konrad
Joined: 15 Sep 2003 Posts: 34
|
Samsung KS0108 |
Posted: Mon Nov 17, 2003 3:33 pm |
|
|
I am messing with a KS0108 display. I have not had time to finish my code at the moment, but this mostly works. When I implement more functions I will post them. I thought I would post it as when I searched for example code here I couldn't find any.
// lcd.c for
// Samsung KS0108
#byte PORTA= 0x0F80
#byte PORTB= 0x0F81
#byte PORTC= 0x0F82
#byte PORTD= 0x0F83
//board specific definitins for pins
#define lcd_enable PIN_C0 //Enable pin on LCD
#define lcd_cmd PIN_C1 //Data/Command Pin 4 on LCD
#define lcd_rw PIN_C2 //Read/Write Pin 5 on LCD
#define lcd_cs1 PIN_B1 //ChipSelect1 Pin 15 on LCD
#define lcd_cs2 PIN_B2 //ChipSelect2 Pin 16 on LCD
#define lcd_rst PIN_C5 //Reset Pin 17 on LCD
#byte lcd_data = PORTD //ensure PORTD is declared as a byte
#use fast_io(D)
#define LCD_LEFT 1
#define LCD_RIGHT 0
void lcd_init(void);
void lcd_write(int1 half);
void lcd_gotoxy(int8 x, int8 y);
void lcd_clrscr(void);
void lcd_newline(void);
CHAR CONST fonts[470]= { //dec ascii
0x00,0x00,0x4F,0x00,0x00, //33 !
0x00,0x07,0x00,0x07,0x00, //34 "
0x14,0x7F,0x14,0x7F,0x14, //35 #
0x24,0x2A,0x7F,0x2A,0x12, //36 $
0x23,0x13,0x08,0x64,0x62, //37 %
0x36,0x49,0x55,0x22,0x50, //38 &
0x00,0x05,0x03,0x00,0x00, //39 '
0x1C,0x22,0x41,0x00,0x00, //40 (
0x00,0x00,0x41,0x22,0x1C, //41 )
0x14,0x08,0x3E,0x08,0x14, //42 *
0x08,0x08,0x3E,0x08,0x08, //43 +
0x00,0x50,0x30,0x00,0x00, //44 ,
0x08,0x08,0x08,0x08,0x08, //45 -
0x00,0x60,0x60,0x00,0x00, //46 .
0x20,0x10,0x08,0x04,0x02, //47 /
0x3E,0x51,0x49,0x45,0x3E, //48 0
0x00,0x42,0x7F,0x40,0x00, //49 1
0x42,0x61,0x51,0x49,0x46, //50 2
0x21,0x41,0x45,0x4B,0x31, //51 3
0x18,0x14,0x12,0x7F,0x10, //52 4
0x27,0x45,0x45,0x45,0x39, //53 5
0x3C,0x4A,0x49,0x49,0x30, //54 6
0x01,0x71,0x09,0x05,0x03, //55 7
0x36,0x49,0x49,0x49,0x36, //56 8
0x06,0x49,0x49,0x49,0x3E, //57 9
0x00,0x36,0x36,0x00,0x00, //58 :
0x00,0x56,0x36,0x00,0x00, //59 ;
0x08,0x14,0x22,0x41,0x00, //60 <
0x14,0x14,0x14,0x14,0x14, //61 =
0x00,0x41,0x22,0x14,0x08, //62 >
0x02,0x01,0x51,0x09,0x06, //63 ?
0x32,0x49,0x79,0x41,0x3E, //64 @
0x7E,0x11,0x11,0x11,0x7E, //65 A
0x7F,0x49,0x49,0x49,0x36, //66 B
0x3E,0x41,0x41,0x41,0x22, //67 C
0x7F,0x41,0x41,0x22,0x1C, //68 D
0x7F,0x49,0x49,0x49,0x41, //69 E
0x7F,0x09,0x09,0x09,0x01, //70 F
0x3E,0x41,0x49,0x49,0x7A, //71 G
0x7F,0x08,0x08,0x08,0x7F, //72 H
0x00,0x41,0x7F,0x41,0x00, //73 I
0x20,0x40,0x41,0x3F,0x01, //74 J
0x7F,0x08,0x14,0x22,0x41, //75 K
0x7F,0x40,0x40,0x40,0x40, //76 L
0x7F,0x02,0x0C,0x02,0x7F, //77 M
0x7F,0x04,0x08,0x10,0x7F, //78 N
0x3E,0x41,0x41,0x41,0x3E, //79 O
0x7F,0x09,0x09,0x09,0x06, //80 P
0x3E,0x41,0x51,0x21,0x5E, //81 Q
0x7F,0x09,0x19,0x29,0x46, //82 R
0x46,0x49,0x49,0x49,0x31, //83 S
0x01,0x01,0x7F,0x01,0x01, //84 T
0x3F,0x40,0x40,0x40,0x3F, //85 U
0x1F,0x20,0x40,0x20,0x1F, //86 V
0x3F,0x40,0x38,0x40,0x3F, //87 W
0x63,0x14,0x08,0x14,0x63, //88 X
0x07,0x08,0x70,0x08,0x07, //89 Y
0x61,0x51,0x49,0x45,0x43, //90 Z
0x7F,0x41,0x41,0x00,0x00, //91 [
0x02,0x04,0x08,0x10,0x20, //92 \
0x00,0x00,0x41,0x41,0x7F, //93 ]
0x04,0x02,0x01,0x02,0x04, //94 ^
0x40,0x40,0x40,0x40,0x40, //95 _
0x00,0x01,0x02,0x04,0x00, //96 `
0x20,0x54,0x54,0x54,0x78, //97 a
0x7F,0x48,0x44,0x44,0x38, //98 b
0x38,0x44,0x44,0x44,0x20, //99 c
0x38,0x44,0x44,0x48,0x7F, //100 d
0x38,0x54,0x54,0x54,0x18, //101 e
0x08,0x7E,0x09,0x01,0x02, //102 f
0x0C,0x52,0x52,0x52,0x3E, //103 g
0x7F,0x08,0x04,0x04,0x78, //104 h
0x00,0x44,0x7D,0x40,0x00, //105 i
0x00,0x20,0x40,0x44,0x3D, //106 j
0x7F,0x10,0x28,0x44,0x00, //107 k
0x00,0x41,0x7F,0x40,0x00, //108 l
0x7C,0x04,0x18,0x04,0x78, //109 m
0x7C,0x08,0x04,0x04,0x78, //110 n
0x38,0x44,0x44,0x44,0x38, //111 o
0x7C,0x14,0x14,0x14,0x08, //112 p
0x08,0x14,0x14,0x18,0x7C, //113 q
0x7C,0x08,0x04,0x04,0x08, //114 r
0x48,0x54,0x54,0x54,0x20, //115 s
0x04,0x3F,0x44,0x40,0x20, //116 t
0x3C,0x40,0x40,0x20,0x7C, //117 u
0x1C,0x20,0x40,0x20,0x1C, //118 v
0x3C,0x40,0x30,0x40,0x3C, //119 w
0x44,0x28,0x10,0x28,0x44, //120 x
0x0C,0x50,0x50,0x50,0x3C, //121 y
0x44,0x64,0x54,0x4C,0x44, //122 z
0x08,0x36,0x41,0x00,0x00, //123 {
0x00,0x00,0x7F,0x00,0x00, //124 |
0x00,0x00,0x41,0x36,0x08, //125 }
0x00,0x08,0x04,0x08,0x04 //126 ~
};
//position on LCD, x = 0 - 127, y = 0 - 7
int8 x_position, y_position;
#define CS1_MAX_X 63 //chip 1 x range 0 - 63
#define CS2_MAX_X 127 //chip 1 x range 64 - 127
#define DISPLAY_ON 0x3F //LCD Display ON
#define DISPLAY_OFF 0x3E //LCD Display OFF
#define SET_X 0x40 //LCD SET X command, add x - 0 to 63
#define SET_Y 0xB8 //LCD SET Y command, add y - 0 to 7
#define SET_RAM_0 0xC0 //LCD RAM, used for scrolling add x - 0 to 63
void lcd_init(void)
{
//init LCD lines
set_tris_d(0x00);
lcd_data = 0x00;
output_high(lcd_cmd);
output_low(lcd_rw);
output_low(lcd_enable);
output_low(lcd_cs1);
output_low(lcd_cs2);
//reset LCD
output_high(lcd_rst);
delay_us(10);
output_low(lcd_rst);
delay_us(5);
output_high(lcd_rst);
delay_us(10);
//command mode
output_low(lcd_cmd);
lcd_data = DISPLAY_OFF;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_data = SET_RAM_0;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_gotoxy(0,0);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
x_position = 0;
y_position = 0;
return;
}
void lcd_write(int1 half)
{
if(half)
{
output_high(lcd_cs1);
output_low(lcd_cs2);
}
else
{
output_low(lcd_cs1);
output_high(lcd_cs2);
}
delay_us(2);
output_high(lcd_enable);
delay_us(2);
output_low(lcd_enable);
delay_us(2);
return;
}
void lcd_clrscr(void)
{
int8 x,y;
output_low(lcd_cmd);
lcd_data = DISPLAY_OFF;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(y=0; y<8; y++)
{
output_low(lcd_cmd);
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(x=0; x<64; x++)
{
lcd_data = 0;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
}
}
output_low(lcd_cmd);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
lcd_gotoxy(0,0);
return;
}
void lcd_putc( char c)
{
int16 index,count;
int8 x;
switch (c)
{
case '\f' :
lcd_clrscr();
break;
case '\n' :
lcd_newline();
break;
default :
//check there is space to print
if((x_position + 5) < CS2_MAX_X)
{ //print character
index = (int16)(c - 33) * 5;
for(x=0; x<5; x++)
{
lcd_data = fonts[index++];
if(++x_position > CS1_MAX_X)
{
lcd_write(LCD_RIGHT);
}
else
{
lcd_write(LCD_LEFT);
}
}
}
//check there is space to print
if((x_position < CS2_MAX_X)
{ //print space
lcd_data = 0x00;
if(++x_position > CS1_MAX_X)
{
lcd_write(LCD_RIGHT);
}
else
{
lcd_write(LCD_LEFT);
}
}
break;
}
return;
}
int8 lcd_read_byte( void )
{
}
void lcd_gotoxy( int8 x, int8 y)
{
output_low(lcd_cmd);
if(x > 63)
{
x = x - 63;
lcd_data = SET_X + x;
lcd_write(LCD_RIGHT);
lcd_data = SET_X;
lcd_write(LCD_LEFT);
}
else
{
lcd_data = SET_X + x;
lcd_write(LCD_LEFT);
lcd_data = SET_X;
lcd_write(LCD_RIGHT);
}
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
return;
}
void lcd_newline(void)
{
output_low(lcd_cmd);
lcd_data = SET_X;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_data = SET_Y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
return;
} |
|
|
me Guest
|
better code |
Posted: Fri Nov 21, 2003 2:31 pm |
|
|
#include "bmp.c" //chr const bmp[1024] ~ picture in format (8 x 128) x 8
// visit www.compsys1.com/workbench
#byte PORTA= 0x0F80
#byte PORTB= 0x0F81
#byte PORTC= 0x0F82
#byte PORTD= 0x0F83
// the screen is built
//chip 1 chip 2
//1 - > 64 1 - > 64
//::----:: ::----:: byte byte
//::----:: ::----:: " "
//::----:: ::----:: " "
//::----:: ::----:: " "
//
//::----:: ::----::
//::----:: ::----::
//::----:: ::----::
//::----:: ::----::
//etc, 8 horizontal lines
//board specific definitions for pins
#define lcd_enable PIN_C0 //Enable pin on LCD
#define lcd_cmd PIN_C1 //Data/Command Pin 4 on LCD
#define lcd_rw PIN_C2 //Read/Write Pin 5 on LCD
#define lcd_cs1 PIN_B1 //ChipSelect1 Pin 15 on LCD
#define lcd_cs2 PIN_B2 //ChipSelect2 Pin 16 on LCD
#define lcd_rst PIN_C5 //Reset Pin 17 on LCD
#byte lcd_data = PORTD //ensure PORTD is declared as a byte
#use fast_io(D)
#define LCD_LEFT 1
#define LCD_RIGHT 0
void lcd_init(void);
void lcd_write(int1 half);
void lcd_gotoxy(int8 x, int8 y);
void lcd_clrscr(void);
void lcd_newline(void);
void lcd_load_bmp(void);
CHAR CONST fonts[475]= { //dec ascii
0x00,0x00,0x00,0x00,0x00, //32 <Space>
0x00,0x00,0x4F,0x00,0x00, //33 !
0x00,0x07,0x00,0x07,0x00, //34 "
0x14,0x7F,0x14,0x7F,0x14, //35 #
0x24,0x2A,0x7F,0x2A,0x12, //36 $
0x23,0x13,0x08,0x64,0x62, //37 %
0x36,0x49,0x55,0x22,0x50, //38 &
0x00,0x05,0x03,0x00,0x00, //39 '
0x1C,0x22,0x41,0x00,0x00, //40 (
0x00,0x00,0x41,0x22,0x1C, //41 )
0x14,0x08,0x3E,0x08,0x14, //42 *
0x08,0x08,0x3E,0x08,0x08, //43 +
0x00,0x50,0x30,0x00,0x00, //44 ,
0x08,0x08,0x08,0x08,0x08, //45 -
0x00,0x60,0x60,0x00,0x00, //46 .
0x20,0x10,0x08,0x04,0x02, //47 /
0x3E,0x51,0x49,0x45,0x3E, //48 0
0x00,0x42,0x7F,0x40,0x00, //49 1
0x42,0x61,0x51,0x49,0x46, //50 2
0x21,0x41,0x45,0x4B,0x31, //51 3
0x18,0x14,0x12,0x7F,0x10, //52 4
0x27,0x45,0x45,0x45,0x39, //53 5
0x3C,0x4A,0x49,0x49,0x30, //54 6
0x01,0x71,0x09,0x05,0x03, //55 7
0x36,0x49,0x49,0x49,0x36, //56 8
0x06,0x49,0x49,0x49,0x3E, //57 9
0x00,0x36,0x36,0x00,0x00, //58 :
0x00,0x56,0x36,0x00,0x00, //59 ;
0x08,0x14,0x22,0x41,0x00, //60 <
0x14,0x14,0x14,0x14,0x14, //61 =
0x00,0x41,0x22,0x14,0x08, //62 >
0x02,0x01,0x51,0x09,0x06, //63 ?
0x32,0x49,0x79,0x41,0x3E, //64 @
0x7E,0x11,0x11,0x11,0x7E, //65 A
0x7F,0x49,0x49,0x49,0x36, //66 B
0x3E,0x41,0x41,0x41,0x22, //67 C
0x7F,0x41,0x41,0x22,0x1C, //68 D
0x7F,0x49,0x49,0x49,0x41, //69 E
0x7F,0x09,0x09,0x09,0x01, //70 F
0x3E,0x41,0x49,0x49,0x7A, //71 G
0x7F,0x08,0x08,0x08,0x7F, //72 H
0x00,0x41,0x7F,0x41,0x00, //73 I
0x20,0x40,0x41,0x3F,0x01, //74 J
0x7F,0x08,0x14,0x22,0x41, //75 K
0x7F,0x40,0x40,0x40,0x40, //76 L
0x7F,0x02,0x0C,0x02,0x7F, //77 M
0x7F,0x04,0x08,0x10,0x7F, //78 N
0x3E,0x41,0x41,0x41,0x3E, //79 O
0x7F,0x09,0x09,0x09,0x06, //80 P
0x3E,0x41,0x51,0x21,0x5E, //81 Q
0x7F,0x09,0x19,0x29,0x46, //82 R
0x46,0x49,0x49,0x49,0x31, //83 S
0x01,0x01,0x7F,0x01,0x01, //84 T
0x3F,0x40,0x40,0x40,0x3F, //85 U
0x1F,0x20,0x40,0x20,0x1F, //86 V
0x3F,0x40,0x38,0x40,0x3F, //87 W
0x63,0x14,0x08,0x14,0x63, //88 X
0x07,0x08,0x70,0x08,0x07, //89 Y
0x61,0x51,0x49,0x45,0x43, //90 Z
0x7F,0x41,0x41,0x00,0x00, //91 [
0x02,0x04,0x08,0x10,0x20, //92 \
0x00,0x00,0x41,0x41,0x7F, //93 ]
0x04,0x02,0x01,0x02,0x04, //94 ^
0x40,0x40,0x40,0x40,0x40, //95 _
0x00,0x01,0x02,0x04,0x00, //96 `
0x20,0x54,0x54,0x54,0x78, //97 a
0x7F,0x48,0x44,0x44,0x38, //98 b
0x38,0x44,0x44,0x44,0x20, //99 c
0x38,0x44,0x44,0x48,0x7F, //100 d
0x38,0x54,0x54,0x54,0x18, //101 e
0x08,0x7E,0x09,0x01,0x02, //102 f
0x0C,0x52,0x52,0x52,0x3E, //103 g
0x7F,0x08,0x04,0x04,0x78, //104 h
0x00,0x44,0x7D,0x40,0x00, //105 i
0x00,0x20,0x40,0x44,0x3D, //106 j
0x7F,0x10,0x28,0x44,0x00, //107 k
0x00,0x41,0x7F,0x40,0x00, //108 l
0x7C,0x04,0x18,0x04,0x78, //109 m
0x7C,0x08,0x04,0x04,0x78, //110 n
0x38,0x44,0x44,0x44,0x38, //111 o
0x7C,0x14,0x14,0x14,0x08, //112 p
0x08,0x14,0x14,0x18,0x7C, //113 q
0x7C,0x08,0x04,0x04,0x08, //114 r
0x48,0x54,0x54,0x54,0x20, //115 s
0x04,0x3F,0x44,0x40,0x20, //116 t
0x3C,0x40,0x40,0x20,0x7C, //117 u
0x1C,0x20,0x40,0x20,0x1C, //118 v
0x3C,0x40,0x30,0x40,0x3C, //119 w
0x44,0x28,0x10,0x28,0x44, //120 x
0x0C,0x50,0x50,0x50,0x3C, //121 y
0x44,0x64,0x54,0x4C,0x44, //122 z
0x08,0x36,0x41,0x00,0x00, //123 {
0x00,0x00,0x7F,0x00,0x00, //124 |
0x00,0x00,0x41,0x36,0x08, //125 }
0x00,0x08,0x04,0x08,0x04 //126 ~
};
//position on LCD, x = 0 - 127, y = 0 - 7
int8 x_position, y_position;
#define CS1_MAX_X 63 //chip 1 x range 0 - 63
#define CS2_MAX_X 127 //chip 1 x range 64 - 127
#define DISPLAY_ON 0x3F //LCD Display ON
#define DISPLAY_OFF 0x3E //LCD Display OFF
#define SET_X 0x40 //LCD SET X command, add x - 0 to 63
#define SET_Y 0xB8 //LCD SET Y command, add y - 0 to 7
#define SET_RAM_0 0xC0 //LCD RAM, used for scrolling add x - 0 to 63
void lcd_init(void)
{
//init LCD lines
set_tris_d(0x00);
lcd_data = 0x00;
output_high(lcd_cmd);
output_low(lcd_rw);
output_low(lcd_enable);
output_low(lcd_cs1);
output_low(lcd_cs2);
//reset LCD
output_high(lcd_rst);
delay_us(10);
output_low(lcd_rst);
delay_us(5);
output_high(lcd_rst);
delay_us(10);
//command mode
output_low(lcd_cmd);
lcd_data = DISPLAY_OFF;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_data = SET_RAM_0;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_gotoxy(0,0);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
x_position = 0;
y_position = 0;
return;
}
void lcd_write(int1 half)
{
if(half)
{
output_high(lcd_cs1);
output_low(lcd_cs2);
}
else
{
output_low(lcd_cs1);
output_high(lcd_cs2);
}
delay_us(2);
output_high(lcd_enable);
delay_us(2);
output_low(lcd_enable);
delay_us(2);
return;
}
void lcd_clrscr(void)
{
int8 x,y;
output_low(lcd_cmd);
lcd_data = DISPLAY_OFF;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(y=0; y<8; y++)
{
output_low(lcd_cmd);
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(x=0; x<64; x++)
{
lcd_data = 0;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
}
}
output_low(lcd_cmd);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
lcd_gotoxy(0,0);
return;
}
void lcd_putc( char c)
{
int16 index,count;
int8 x;
switch (c)
{
case '\f' :
lcd_clrscr();
break;
case '\n' :
lcd_newline();
break;
default :
//check there is space to print
if((x_position + 5) < CS2_MAX_X)
{ //print character
index = (int16)(c - 32) * 5;
for(x=0; x<5; x++)
{
lcd_data = fonts[index++];
if(x_position > CS1_MAX_X)
{
lcd_write(LCD_RIGHT);
}
else
{
lcd_write(LCD_LEFT);
}
x_position++;
}
}
if((x_position + 1) < CS2_MAX_X)
{
lcd_data = 0x00;
if(x_position > CS1_MAX_X)
{
lcd_write(LCD_RIGHT);
}
else
{
lcd_write(LCD_LEFT);
}
x_position++;
}
break;
}
return;
}
int8 lcd_read_byte( void )
{
}
void lcd_gotoxy( int8 x, int8 y)
{
x_position = x;
y_position = y;
output_low(lcd_cmd);
if(x > 63)
{
x = x - 63;
lcd_data = SET_X + x;
lcd_write(LCD_RIGHT);
lcd_data = SET_X;
lcd_write(LCD_LEFT);
}
else
{
lcd_data = SET_X + x;
lcd_write(LCD_LEFT);
lcd_data = SET_X;
lcd_write(LCD_RIGHT);
}
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
return;
}
void lcd_newline(void)
{
x_position = 0;
if(y_position < 7) //check for last line
{
y_position ++;
output_low(lcd_cmd);
lcd_data = SET_X;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_data = SET_Y + y_position;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
}
return;
}
void lcd_load_bmp(void)
{
int8 x,y;
int16 ptr=0;
// output_low(lcd_cmd);
// lcd_data = DISPLAY_OFF;
// lcd_write(LCD_LEFT);
// lcd_write(LCD_RIGHT);
// output_high(lcd_cmd);
for(y=0; y<8; y++)
{
output_low(lcd_cmd);
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(x=0; x<64; x++)
{
lcd_data = bmp[ptr++];
lcd_write(LCD_LEFT);
}
for(x=0; x<64; x++)
{
lcd_data = bmp[ptr++];
lcd_write(LCD_RIGHT);
}
}
output_low(lcd_cmd);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
lcd_gotoxy(0,0);
return;
} |
|
|
Guest
|
|
Posted: Mon Nov 24, 2003 1:33 pm |
|
|
I can't get this code to compile. The structure fonts is to big. What processor were you guys using. My CCS says structures casn only go up to 256. Let me know.. TTY |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 24, 2003 1:35 pm |
|
|
From the addresses of the ports, I would say that this is probably an 18 series pic. |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Tue Nov 25, 2003 10:08 pm |
|
|
Hey "me" can you post the bmp.c so I can try it out. I went to that site. Cool stuff but could not find the file.. Thanx .. TTY |
|
|
Konrad
Joined: 15 Sep 2003 Posts: 34
|
BMP file |
Posted: Thu Nov 27, 2003 5:26 pm |
|
|
This file must contain 1024 char's
My own logo is here, so I have not posted a full array.
From the site I have previously posted,
download and run glipic, and add the appropriate header & footer.
I till have not had time ti finish this code, but I plan to post graphical plotting similar to borland turbo c or quickc.
const char bmp[1024] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x80,
0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x00,0x00,0x80,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,0x80,0xc0,0xf0,0xf8,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x00,0x00,0x00
}; |
|
|
Konrad
Joined: 15 Sep 2003 Posts: 34
|
update |
Posted: Tue Feb 14, 2006 12:59 pm |
|
|
visit
http://www.compsys1.com/workbench/
I have not done much work since, I found out that actually ccs glcd example is actually for the KS0108, though they didn't say so
hope this helps
ps both drivers will work at the same time i.e. use mine for the bitmap (it is quicker) and the ccs driver for plotting or large fonts etc |
|
|
Guest
|
|
Posted: Fri Dec 15, 2006 4:55 am |
|
|
Where is the main program ?
Is this just the driver ?
How can i write say PICMICRO Forum on the display
could you just do an example |
|
|
BOB_SANTANA
Joined: 16 Oct 2006 Posts: 110 Location: HOVE, EAST SUSSEX
|
|
Posted: Sun Dec 17, 2006 7:22 am |
|
|
Here is an Example of writting text
to make the text smaller just change the 2 in the glcd_text57 () to 1 to get 5x7
Code: |
#include <16F877.h>
#ORG 0x1F00,0x1FFF {} // use boot loader for the 8k 16F877
#device *=16
#fuses xt,NOWDT,noprotect,nolvp,put,BROWNOUT
#use delay(clock=4000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7,ERRORS,stream=PC) // Jumpers: 8 to 11, 7 to 1
#case
#zero_ram
#include <string.h>
#include <glcd.c>
#include <math.h>
void main()
{
char Heading_Text[] = " CCS FORUM", Second_Line[] = "is the best";
char Third_Line[] = "Place to", fouth_Line[] ="get Support";
char Next_Msg1[] = "People are ", Next_Msg2[] ="always";
char Next_Msg3[] ="Very",Next_Msg4[] ="Helpful";
glcd_init(ON); // Must initialize the LCD
do{
glcd_text57(5,0, Heading_Text, 2, ON);
glcd_text57(5,16, Second_Line, 2, ON);
glcd_text57(25,32, Third_Line, 2, ON);
glcd_text57(0,48, fouth_Line, 2, ON);
delay_ms(1000);
glcd_init(OFF);
delay_ms(150);
glcd_init(ON);
glcd_text57(5,0, Next_Msg1, 2, ON);
glcd_text57(30,16, Next_Msg2, 2, ON);
glcd_text57(30,32,Next_Msg3 , 2, ON);
glcd_text57(25,48,Next_Msg4 , 2, ON);
delay_ms(1000);
glcd_init(OFF);
glcd_init(ON);
} while (TRUE);
}
|
_________________ BOB_Santana |
|
|
Guest
|
|
Posted: Sun Dec 17, 2006 12:49 pm |
|
|
Thanks Bob
For your example
i now understand howto send text (Thanks very much)
Now if its not too much can you please explain to me how to send values
like example say the value of int value = 100
How do i display this as i can't seems to understand the
displayVoltage(value1); is used to display the value |
|
|
BOB_SANTANA
Joined: 16 Oct 2006 Posts: 110 Location: HOVE, EAST SUSSEX
|
|
Posted: Sun Dec 17, 2006 5:28 pm |
|
|
Hi here is a program example for you to display number
i program just counts from 0-200
BTW i still haven't figured how to clear the screen without having to use
glcd_init(OFF)
for example with this program you would notice that i really only have to clear the data after the =sign so if there is anyone out there i hope they can help i am still learning like you sorry
Code: |
#include <string.h>
#include <glcd.c>
#include <math.h>
void displayVoltage(int8 data) {
char voltValue[9]; // Stores the converted number
sprintf(voltValue, "%u",data); // Converts number to text
voltValue[4] = '\0'; // Limit shown digits to 3
glcd_text57(90, 20, voltValue, 2, ON); // Write the new number
}
void main()
{
int8 data=0;
char Dis_Data[] ="DATA = :",CLR_Data[] =" ";
do{
glcd_init(ON); // Must initialize the LCD
glcd_text57(0,20,Dis_Data, 2, ON);
displayVoltage(data);
delay_ms(100);
data++;
if (data ==200)
data=0;
glcd_text57(90, 20, CLR_Data, 2, ON); //This has not effect WHY?
glcd_init(OFF);
} while (TRUE);
}
|
_________________ BOB_Santana |
|
|
Guest
|
|
Posted: Mon Dec 18, 2006 4:06 am |
|
|
Thanks Bob
I do hope someone would explain it to me its driving me mad here |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Dec 18, 2006 5:52 am |
|
|
Code: | glcd_text57(90, 20, CLR_Data, 2, ON); //This has not effect WHY?
| This line does not clear the graphics at the indicated locations because the character draw routines are optimized for speed. Only the visible pixels of the character will be drawn, a space character has no visible pixels and nothing will be drawn.
Clear the desired area using glcd_bar() or clear the whole screen with glcd_fillScreen(). |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Dec 18, 2006 5:54 am |
|
|
Anonymous wrote: | I do hope someone would explain it to me its driving me mad here | What is the part you don't understand? Study the contents of glcd.c, all available functions are explained there. |
|
|
Guest
|
|
Posted: Mon Dec 18, 2006 1:24 pm |
|
|
Its the part of clearing the lcd without having to clear everthing
Cheers |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|