12826 grafical lcd quistion
2007-06-10 by mailtofalcon
Yahoo Groups archive
Index last updated: 2026-04-28 22:41 UTC
Thread
2007-06-10 by mailtofalcon
hi i design a device which monitor the level of a huge tank with avr atmega8535 and show a historical trend for this level but i need now to make a graph for this level values can any one help me how to use the graphical lcd 12864 thanks
2007-06-11 by Zack Widup
It took me less than a minute to find the data sheet for this display using Google. It appears all the data to do this is in the data sheet. Isn't that what you're getting paid to do? Zack
On Sun, 10 Jun 2007, mailtofalcon wrote: > hi > i design a device which monitor the level of a huge tank with avr > atmega8535 and show a historical trend for this level but i need now > to make a graph for this level values can any one help me how to use > the graphical lcd 12864 > thanks >
2007-06-12 by Dao Viet Dung
Hi,
Check this link: http://www.8052.com/codelib/lcd12864.rar if it can help you.
Regards.
Dao
mailtofalcon <FALCONJET2002@HOTMAIL.COM> wrote: hi
i design a device which monitor the level of a huge tank with avr
atmega8535 and show a historical trend for this level but i need now
to make a graph for this level values can any one help me how to use
the graphical lcd 12864
thanks
[Non-text portions of this message have been removed]2007-06-12 by mikanradojevic
--- In AVR-Chat@yahoogroups.com, "mailtofalcon" <FALCONJET2002@...>
wrote:
>
> hi
> i design a device which monitor the level of a huge tank with avr
> atmega8535 and show a historical trend for this level but i need
now
> to make a graph for this level values can any one help me how to
use
> the graphical lcd 12864
> thanks
>
Hello,
I have some avr gcc code for 12864 graphics lcd. In general there
are two files: glcd.h & glcd.c.
I hope that it can help to You.
glcd.h :
//----------------------------------------------------
//
// glcd.h
//----------------------------------------------------
#ifndef LCD_H
#define LCD_H
#define LCD_PAUSE 3
#define sbi(port,bit) (port |= (1<<bit))
#define cbi(port,bit) (port &= ~(1<<bit))
#define LCD_TRIS DDRC
#define LCD_DATA PORTC
#define ENABLE PD7
#define RW PD4
#define DI PD5
#define RESET PD6
#define CS1 PB1
#define CS2 PB0
#define LEFT 0b01
#define RIGHT 0b10
#define BOTH 0b11
#define NONE 0b00
//---------------------------------------------------
void _lcd_enable ( void );
unsigned char _lcd_status( void );
void _lcd_reset( void );
void _lcd_delay ( void );
void _lcd_write_data ( unsigned char ch );
void _lcd_write_cmd ( unsigned char ch );
unsigned char _lcd_read ( void );
void _lcd_select ( unsigned char ctr );
//---------------------------------------------------
void _lcd_init ( void );
void _lcd_on ( void );
void _lcd_off ( void );
void _lcd_clear ( void );
void _lcd_putc ( unsigned char x,
unsigned char y,
unsigned char ch );
void _lcd_puts ( unsigned char x,
unsigned char y,
char *str );
void _lcd_setpixel ( unsigned char x,
unsigned char y );
void _lcd_clrpixel ( unsigned char x,
unsigned char y );
unsigned char _lcd_get_byte ( unsigned char x,
unsigned char y );
void _lcd_v_line( unsigned char x0,
unsigned char x1,
unsigned char y0 );
void _lcd_h_line( unsigned char y0,
unsigned char y1,
unsigned char x0 );
void _lcd_center_str( unsigned int x, char *str);
void _lcd_right_str( unsigned int x, char *str);
//---------------------------------------------------
#endif
//----------------------------------------------------
// E.O.F. glcd.h
//----------------------------------------------------
glcd.c:
//----------------------------------------------------
//
// glcd.c
//----------------------------------------------------
//----------------------------------------------------
#include "glcd.h"
//----------------------------------------------------
const char tab_font[] = {
0x00, 0x00, 0x00, 0x00, 0x00,// (space)0
0x00, 0x00, 0x5F, 0x00, 0x00,// ! 5
0x00, 0x07, 0x00, 0x07, 0x00,// " 10
0x14, 0x7F, 0x14, 0x7F, 0x14,// # 15
0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ 20
0x23, 0x13, 0x08, 0x64, 0x62,// % 25
0x36, 0x49, 0x55, 0x22, 0x50,// & 30
0x00, 0x05, 0x03, 0x00, 0x00,// ' 35
0x00, 0x1C, 0x22, 0x41, 0x00,// ( 40
0x00, 0x41, 0x22, 0x1C, 0x00,// ) 45
0x08, 0x2A, 0x1C, 0x2A, 0x08,// * 50
0x08, 0x08, 0x3E, 0x08, 0x08,// + 55
0x00, 0x50, 0x30, 0x00, 0x00,// , 60
0x08, 0x08, 0x08, 0x08, 0x08,// - 65
0x00, 0x30, 0x30, 0x00, 0x00,// . 70
0x20, 0x10, 0x08, 0x04, 0x02,// / 75
0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 80
0x00, 0x42, 0x7F, 0x40, 0x00,// 1 85
0x42, 0x61, 0x51, 0x49, 0x46,// 2 90
0x21, 0x41, 0x45, 0x4B, 0x31,// 3 95
0x18, 0x14, 0x12, 0x7F, 0x10,// 4 100
0x27, 0x45, 0x45, 0x45, 0x39,// 5 105
0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 110
0x01, 0x71, 0x09, 0x05, 0x03,// 7 115
0x36, 0x49, 0x49, 0x49, 0x36,// 8 120
0x06, 0x49, 0x49, 0x29, 0x1E,// 9 125
0x00, 0x36, 0x36, 0x00, 0x00,// : 130
0x00, 0x56, 0x36, 0x00, 0x00,// ; 135
0x00, 0x08, 0x14, 0x22, 0x41,// < 140
0x14, 0x14, 0x14, 0x14, 0x14,// = 145
0x41, 0x22, 0x14, 0x08, 0x00,// > 150
0x02, 0x01, 0x51, 0x09, 0x06,// ? 155
0x32, 0x49, 0x79, 0x41, 0x3E,// @ 160
0x7E, 0x11, 0x11, 0x11, 0x7E,// A 165
0x7F, 0x49, 0x49, 0x49, 0x36,// B 170
0x3E, 0x41, 0x41, 0x41, 0x22,// C 175
0x7F, 0x41, 0x41, 0x22, 0x1C,// D 180
0x7F, 0x49, 0x49, 0x49, 0x41,// E 185
0x7F, 0x09, 0x09, 0x01, 0x01,// F 190
0x3E, 0x41, 0x41, 0x51, 0x32,// G 195
0x7F, 0x08, 0x08, 0x08, 0x7F,// H 200
0x00, 0x41, 0x7F, 0x41, 0x00,// I 205
0x20, 0x40, 0x41, 0x3F, 0x01,// J 210
0x7F, 0x08, 0x14, 0x22, 0x41,// K 215
0x7F, 0x40, 0x40, 0x40, 0x40,// L 220
0x7F, 0x02, 0x04, 0x02, 0x7F,// M 225
0x7F, 0x04, 0x08, 0x10, 0x7F,// N 230
0x3E, 0x41, 0x41, 0x41, 0x3E,// O 235
0x7F, 0x09, 0x09, 0x09, 0x06,// P 240
0x3E, 0x41, 0x51, 0x21, 0x5E,// Q 245
0x7F, 0x09, 0x19, 0x29, 0x46,// R 250
0x46, 0x49, 0x49, 0x49, 0x31,// S 255
0x01, 0x01, 0x7F, 0x01, 0x01,// T 260
0x3F, 0x40, 0x40, 0x40, 0x3F,// U 265
0x1F, 0x20, 0x40, 0x20, 0x1F,// V 270
0x7F, 0x20, 0x18, 0x20, 0x7F,// W 275
0x63, 0x14, 0x08, 0x14, 0x63,// X 280
0x03, 0x04, 0x78, 0x04, 0x03,// Y 285
0x61, 0x51, 0x49, 0x45, 0x43,// Z 290
0x00, 0x00, 0x7F, 0x41, 0x41,// [
0x02, 0x04, 0x08, 0x10, 0x20,// "\"
0x41, 0x41, 0x7F, 0x00, 0x00,// ]
0x04, 0x02, 0x01, 0x02, 0x04,// ^
0x40, 0x40, 0x40, 0x40, 0x40,// _
0x00, 0x01, 0x02, 0x04, 0x00,// `
0x20, 0x54, 0x54, 0x54, 0x78,// a
0x7F, 0x48, 0x44, 0x44, 0x38,// b
0x38, 0x44, 0x44, 0x44, 0x20,// c
0x38, 0x44, 0x44, 0x48, 0x7F,// d
0x38, 0x54, 0x54, 0x54, 0x18,// e
0x08, 0x7E, 0x09, 0x01, 0x02,// f
0x08, 0x14, 0x54, 0x54, 0x3C,// g
0x7F, 0x08, 0x04, 0x04, 0x78,// h
0x00, 0x44, 0x7D, 0x40, 0x00,// i
0x20, 0x40, 0x44, 0x3D, 0x00,// j
0x00, 0x7F, 0x10, 0x28, 0x44,// k
0x00, 0x41, 0x7F, 0x40, 0x00,// l
0x7C, 0x04, 0x18, 0x04, 0x78,// m
0x7C, 0x08, 0x04, 0x04, 0x78,// n
0x38, 0x44, 0x44, 0x44, 0x38,// o
0x7C, 0x14, 0x14, 0x14, 0x08,// p
0x08, 0x14, 0x14, 0x18, 0x7C,// q
0x7C, 0x08, 0x04, 0x04, 0x08,// r
0x48, 0x54, 0x54, 0x54, 0x20,// s
0x04, 0x3F, 0x44, 0x40, 0x20,// t
0x3C, 0x40, 0x40, 0x20, 0x7C,// u
0x1C, 0x20, 0x40, 0x20, 0x1C,// v
0x3C, 0x40, 0x30, 0x40, 0x3C,// w
0x44, 0x28, 0x10, 0x28, 0x44,// x
0x0C, 0x50, 0x50, 0x50, 0x3C,// y
0x44, 0x64, 0x54, 0x4C, 0x44,// z
0x00, 0x08, 0x36, 0x41, 0x00,// {
0x00, 0x00, 0x7F, 0x00, 0x00,// |
0x00, 0x41, 0x36, 0x08, 0x00,// }
0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
};
//---------------------------------------------------
//---------------------------------------------------
//---------------------------------------------------
#define LCD_CMD_ON 0x3E
#define LCD_CMD_START 0xC0
#define LCD_CMD_SET_Y 0x40
#define LCD_CMD_SET_X 0xB8
//---------------------------------------------------
//---------------------------------------------------
void _lcd_enable( void )
{
_lcd_delay();
sbi( PORTD, ENABLE );
_lcd_delay();
cbi( PORTD, ENABLE );
_lcd_delay();
}
//---------------------------------------------------
//---------------------------------------------------
unsigned char _lcd_status( void )
{
unsigned char ddrc, status;
ddrc = DDRC;
PORTC = 0;
DDRC = 0x00;
cbi(PORTD,DI);
sbi(PORTC,RW);
_lcd_enable();
status = PINC;
DDRC = ddrc;
return ( status );
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_reset( void )
{
_lcd_delay();
sbi(PORTD,RESET);
_lcd_delay();
cbi(PORTD,RESET);
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_delay ( void )
{
unsigned int i;
for(i=0; i<350; i++);
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_write_data ( unsigned char ch )
{
sbi( PORTD, DI);
cbi( PORTD, RW);
PORTC = ch;
_lcd_enable();
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_write_cmd ( unsigned char ch )
{
cbi(PORTD, DI);
cbi(PORTD, RW);
PORTC=ch;
_lcd_enable();
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_select ( unsigned char ctr )
{
PORTB&=0xfc;
PORTB|=ctr;
_lcd_delay();
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_init ( void )
{
_lcd_reset();
cbi(PORTD, ENABLE); // LCD_E=0;
_lcd_delay();
_lcd_delay();
sbi(PORTD, RESET); // LCD_RST=1;
_lcd_off();
_lcd_clear();
_lcd_on();
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_on ( void )
{
_lcd_select( 1 );
_lcd_write_cmd( LCD_CMD_ON + 1 );
_lcd_select( 2 );
_lcd_write_cmd( LCD_CMD_ON + 1 );
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_off ( void )
{
_lcd_select( 1 );
_lcd_write_cmd( LCD_CMD_ON );
_lcd_select( 2 );
_lcd_write_cmd( LCD_CMD_ON );
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_clear ( void )
{
unsigned char x=0, y=0;
_lcd_select( 3 );
for( x=0; x<8; x++)
{
_lcd_write_cmd( LCD_CMD_SET_X + x );
_lcd_write_cmd( LCD_CMD_SET_Y + 0 );
for(y=0; y<64; y++)
{
_lcd_write_data( 0 );
}
}
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_putc ( unsigned char x,
unsigned char y,
unsigned char ch )
{
unsigned char i=0;
unsigned int f_pos=0;
f_pos = (ch-32)*5;
_lcd_select(3);
_lcd_write_cmd( LCD_CMD_SET_X + x );
for( i=0; i< 5; i++ )
{
if( y < 64 )
{
_lcd_select(2);
_lcd_write_cmd( LCD_CMD_SET_Y + y );
}
else
{
_lcd_select(1);
_lcd_write_cmd( LCD_CMD_SET_Y + y - 64 );
}
_lcd_write_data( tab_font[f_pos+i] );
y++;
}
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_puts ( unsigned char x,
unsigned char y,
char *str )
{
while( *str )
{
_lcd_putc( x, y, *str );
y+=5;
str++;
}
}
//---------------------------------------------------
//---------------------------------------------------
unsigned char _lcd_read ( void )
{
unsigned char data=0;
PORTC = 0;
DDRC = 0X00;
sbi(PORTD, DI);
sbi(PORTD, RW);
_lcd_enable();
data = PINC;
DDRC = 0XFF;
return( data );
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_setpixel ( unsigned char x,
unsigned char y )
{
unsigned char dat=0;
dat = _lcd_get_byte(x,y);
_lcd_select(2-(y>>6));
y%=64;
_lcd_write_cmd( LCD_CMD_SET_X + (x>>3) );
_lcd_write_cmd( LCD_CMD_SET_Y + y );
sbi( dat, x%8 );
_lcd_write_data( dat );
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_clrpixel ( unsigned char x,
unsigned char y )
{
unsigned char dat=0;
dat = _lcd_get_byte(x,y);
_lcd_select(2-(y>>6));
y%=64;
_lcd_write_cmd( LCD_CMD_SET_X + (x>>3) );
_lcd_write_cmd( LCD_CMD_SET_Y + y );
cbi( dat, x%8 );
_lcd_write_data( dat );
}
//---------------------------------------------------
//---------------------------------------------------
unsigned char _lcd_get_byte ( unsigned char x,
unsigned char y )
{
_lcd_select(2-(y>>6));
y%=64;
_lcd_write_cmd( LCD_CMD_SET_X + (x>>3) );
_lcd_write_cmd( LCD_CMD_SET_Y + y );
_lcd_read();
return( _lcd_read() );
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_h_line( unsigned char x0,
unsigned char y0,
unsigned char y1 )
{
for( y0=y0; y0<=y1; y0++)
_lcd_setpixel(x0,y0);
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_v_line( unsigned char x0,
unsigned char x1,
unsigned char y0 )
{
for(x0=x0 ; x0<=x1; x0++)
{
_lcd_setpixel(x0,y0);
}
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_center_str( unsigned int x, char *str)
{
unsigned char y;
y=(strlen(str)*5)/2;
if( y>63 )
y=63;
y=64-y;
_lcd_puts(x,y,str);
}
//---------------------------------------------------
//---------------------------------------------------
void _lcd_right_str( unsigned int x, char *str)
{
unsigned char y;
y=(strlen(str)*5);
if( y>127 )
y=127;
y=127-y;
_lcd_puts(x,y,str);
}
//----------------------------------------------------
//----------------------------------------------------
// E.O.F. glcd.h
//----------------------------------------------------