perçin
Üye
#include "C:\Documents and Settings\perçin\Belgelerim\ccs c cod\240_128_glcd.h"
#include <t6963c_2.c> //
#include <graphics.c>
#fuses NOWDT,HS, NOPUT, PROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
#use delay(clock=20000000)
int adc = 0, adc_old =0;
#inline
void logo()
{
char giris1[] = "DENEME";
char giris2[] = "IRFAN PERCIN";
char giris3[] = "irfanpercin........";
glcd_text57(12,12,giris2, 3, ON);
glcd_text57(62,45,giris1, 3, ON);
delay_ms(1000);
glcd_box(10,10,230,80, ON); //dolgu koyu renk
glcd_text57(12, 12,giris2, 3, Off);
glcd_text57(62,45,giris1, 3, Off);
delay_ms(1000);
//glcd_box(10,10,230,80, Off); //dolgu açık renk
glcd_square(10,95,220,110, on); // bar
glcd_text57(42, 98,giris3, 1, ON);
glcd_pixel(239,127,on); //
glcd_pixel(1,127,on); //
glcd_pixel(1,1,on); // köşelere tek nota pixel test
glcd_pixel(239,1,on); //
}
#inline
void adcd ()
{
int digit[4];
set_adc_channel(1);
adc = read_adc();
// clear_screen(); //sadece adc gör
for(;
{
glcd_text57(100,118, digit,1, ON);
adc = read_adc();
if(adc != adc_old)
{
glcd_text57(100, 118, digit,1, OFF);
}
adc_old = adc;
sprintf(digit, "%03u",adc);
glcd_square(95,115,120,127, on);
}
}
#inline
void main()
{
setup_adc( ADC_CLOCK_INTERNAL);
setup_adc_ports( AN0 );
delay_ms(10);
set_tris_c(0x00); // graphic lcd control lines all output
glcd_init(); //Initialization
glcd_WriteByte(2, (LCDModeSet|LCDMode_XOR)); //XOR-Mode ..................( ??????)
glcd_WriteByte(1, (LCDDispMode|LCDDisp_TXT|LCDDisp_GRH)); //Text and Graphic-Mode
delay_ms(1);
logo();
adcd();
}
/*
driwer t6963c-2
/////////////////////////////////////////////////////////////////////////
//// ////
//// Connections are as follows: ////
//// /CE - - C3 ////
//// /WR - - C4 ////
//// /RD - - C5 ////
//// C/D - - C6 ////
//// /RST- - C7 ////
//// DATA0-7 - - PORTD0-7 ////
//// LCD's FS is tied low (FS = 0 is 8x8 font) ////
//// ////
/////////////////////////////////////////////////////////////////////////
#ifndef GLCD_COL
#define GLCD_COL 240 // Used for text wrapping by glcd_text57 function and sanity check
#endif
#ifndef GLCD_ROW
#define GLCD_ROW 128 // Used for text wrapping by glcd_text57 function and sanity check
#endif
#define set_tris_lcd(x) set_tris_d(x)
#define ON 1
#define OFF 0
#define YES 1
#define NO 0
//TRIS DataBus=x, note:control bus (PORTC) always outputs
const int16 TextHome=0x0EE2; //0x0780 (240*64)/8=1920-->0x0780 ( **240*127 için 3810=0EE2)
const int8 TextArea=0x003C; //(orjinali=0x001E how many bytes before a new line (30 bytes))
const int16 GraphicsHome=0x0000;
const int8 GraphicsArea=0x003c; //(orjinali=0x001E how many bytes before a new line (30 bytes) (60 byt için 003c))
const int8 AutoModeWrite = 0xB0; //DataAutoWrite
//const int8 AutoModeRead = 0xB1; //DataAutoRead
const int8 AutoModeReset = 0xB2; //Auto reset
const int8 LCDModeSet = 0x80; // send this OR'd with the following
//const int8 LCDMode_OR = 0b0000;
const int8 LCDMode_XOR = 0b0001;
//const int8 LCDMode_AND = 0b0010; //0b0010
// const int8 LCDMode_TA = 0b0100; // TEXT ATTRIBUTE mode.
const int8 LCDMode_RAM = 0b1000; // 1=CG RAM, 0=internal CG ROM
//const int8 LCDSetCursorPtr = 0x21; // cursor address
// const int8 LCDSetCursorSize = 0xA0; // 1 line cursor
const int8 LCDDispMode = 0x90; // send this OR'd with the following
//const int8 LCDDisp_BLK = 0b0011; //0b0011 Blink Cursor
// const int8 LCDDisp_CUR = 0b0010; // Add Cursor
const int8 LCDDisp_TXT = 0b0100; //Text-OK,Graphic-NG
const int8 LCDDisp_GRH = 0b1000; //Text-NG,Graphic-OK
const int8 LCDBitSet = 0xF8;
const int8 LCDBitReset = 0xF0;
struct lcd_pin_def //Struct type bitfield
{
int1 unused1 :1; // C0
int1 unused2 :1; // C1
int1 unused3 :1; // C2
int1 ce :1; // C3 Chip enable active low
int1 w_bar :1; // C4 Write bar active low
int1 r_bar :1; // C5 Read bar active low
int1 cd :1; // C6 Command/Data BAR 1=command 0=data
int1 reset_bar :1; // C7 Reset active low
int8 data :8; // PortD=Data bus(address=8)
};
struct lcd_pin_def LCD;
#byte LCD = 7 // portC address=7 on 16F877A
//Prototyping
int glcd_ReadByte(void);
void glcd_WriteByte(int1 cd, int data);
void glcd_WriteByteAuto(int data);
void glcd_WriteCmd2(int16 data, int cmd);
void glcd_WriteCmd1(int data, int cmd);
void glcd_gotoxy(int x, int y, int1 text);
void glcd_init(void)
{
int16 counter;
set_tris_lcd(0x00); //TRIS DATA bus(PORT D),note:control bus always outputs
LCD.ce=0; //INITIAL STATES OF CONTROL PINS
LCD.w_bar=1; //
LCD.r_bar=1; //
LCD.cd=1; // command
LCD.reset_bar=0; // perform a reset
delay_us(10); // delay for a reset
LCD.reset_bar = 1; // run
// Set up the graphics and text areas
glcd_WriteCmd2(TextHome, 0x40); //TextHomeAddress Set
glcd_WriteCmd2(TextArea, 0x41); //TextArea column Set
glcd_WriteCmd2(GraphicsHome, 0x42); //GraphicHomeAddress Set
glcd_WriteCmd2(GraphicsArea, 0x43); //GraphicArea column Set
// set AddressPointer to 0
glcd_WriteCmd2(0x0000, 0x24); //Set AddressPointer to 0
// Clear all RAM of LCD (8k)
glcd_WriteByte(1, AutoModeWrite); //Set Data Auto Write
for (counter = 0; counter < 0x1fff; counter++) //0x1fff=8191 bytes
{
glcd_WriteByteAuto(0); // sıfır ile her şeyi doldurmak
}
glcd_WriteByte(1, AutoModeReset);
}
void glcd_WriteByte(int1 cd, int data) //Normal "modunda komut veya veri" olarak PORTD'ye yazın.
{
int status = 0, temp = 0;
set_tris_lcd(0xff); // All inputs
LCD.ce = 1;
LCD.w_bar = 1;
LCD.r_bar= 1;
LCD.cd = 1;//defaults
while (status != 0x03) { // is LCD busy?
LCD.r_bar= 0;
LCD.ce = 0; //After 150ns read the data on D0-7
#asm nop #endasm
temp = LCD.data;
LCD.ce = 1;
LCD.r_bar = 1;
status = temp & 0x03; //Masking
}
set_tris_lcd(0x00); // All outputs
LCD.cd = cd; // Command/Data bar (1=command 0=data)
LCD.data = data; // Put data on data bus
LCD.ce = 0;
LCD.r_bar = 1; // not read
LCD.w_bar = 0; // write
LCD.ce = 1;
LCD.w_bar = 1; // release
}
void glcd_WriteByteAuto(int data) //Write PORTD as data in "Auto" mode.
{
int status = 0, temp = 0; // WHEN Auto mode,the status bits ARE DIFFERENT BITS THAN NORMAL MODE
set_tris_lcd(0xff); // All inputs
LCD.ce = 1;
LCD.w_bar = 1;
LCD.r_bar = 1;
LCD.cd = 1; // defaults
while (status != 0x08) { // is LCD busy? Checking STA3!
LCD.r_bar = 0;
LCD.ce =0; //After 150ns read the data on D0-7
#asm nop #endasm
temp = LCD.data;
LCD.ce = 1;
LCD.r_bar = 1;
status = temp & 0x08; //Masking
}
set_tris_lcd(0x00); // All outputs
LCD.cd = 0; // This is always data
LCD.data = data; // Put data on data bus
LCD.ce = 0;
LCD.r_bar = 1; // not read
LCD.w_bar = 0; // write
LCD.ce = 1;
LCD.w_bar = 1; // release
}
void glcd_WriteCmd1(int data, int cmd)
{
glcd_WriteByte(0, data);
glcd_WriteByte(1, cmd);
}
void glcd_WriteCmd2(int16 data, int cmd)
{
glcd_WriteByte(0, data & 0xff); //masking,LSB Set
glcd_WriteByte(0, data>>8); //shift right 8bir,MSB Set
glcd_WriteByte(1, cmd);
}
int glcd_ReadByte(void)
{
int data = 0, status = 0, temp = 0;
set_tris_lcd(0xff); // All inputs
LCD.ce = 1;
LCD.w_bar = 1;
LCD.r_bar = 1;
LCD.cd = 1; // defaults
#asm nop #endasm
while (status != 0x03) { // is LCD busy?
LCD.r_bar = 0;
LCD.ce = 0;
temp = LCD.data;
LCD.ce = 1;
LCD.r_bar = 1;
status = temp & 0x03; //Masking
}
LCD.cd = 0; // Command/Data bar
LCD.ce = 0;
LCD.r_bar = 0; // read
/////////////////////////////////////////////////////////
#asm nop #endasm // THIS PAUSE IS VERY NESSESARY !!!//
/////////////////////////////////////////////////////////
data = LCD.data;
LCD.r_bar = 1;
LCD.ce = 1;
LCD.cd = 1;
return data; // Return the read data
}
void glcd_putc(char c)
{
glcd_WriteCmd1(c - 0x20, 0xc0); //c-0x20=Transfer from Ascii Code, Data Write UP.
}
void glcd_gotoxy(int x, int y, int1 text) { // sets memory location to screen location x, y
// location 1,1 is upper left corner;
// text = 1 (text area), text = 0 (graphics area)
int16 location, home;
int line;
if (!text) {
home = GraphicsHome;
line = GraphicsArea;
}
else {
home = TextHome;
line = TextArea;
}
location = home + (((int16)y - 1) * line) + x - 1;
glcd_WriteCmd2(location, 0x24);
}
Void clear_screen(void){ //very simular to the glcd_init(void)
int16 counter;
// set address to 0
glcd_WriteCmd2(0x0000, 0x24); //Set AddressPointer to 0
// Clear all RAM of LCD (8k)
glcd_WriteByte(1, AutoModeWrite); //Set Data Auto Write
for (counter = 0; counter < 0x1fff; counter++) //0x1fff=8191 bytes
{
glcd_WriteByteAuto(0); // fill everything with zeros
}
glcd_WriteByte(1, AutoModeReset);
}
unsigned int8 i; //General Purpouse variable
// glcd_pixel8(x,y,px8) sets 8 pixels in line.
void glcd_pixel8(unsigned int8 x, unsigned int8 y, int8 pixel8){
unsigned int8 x_H;
x_H = (x / 8);
glcd_gotoxy(x_H+1,y,0);
glcd_WriteCmd1(pixel8,0xc0); //Write data and increament
}
// glcd_pixel(x,y,c) sets pixel x,y with c color // tek nota için
void glcd_pixel(unsigned int8 x, unsigned int8 y, int1 c){
unsigned int8 x_H;
unsigned int8 x_L=0;
x_H = (x / 8);
x_L = 7 - (x - 8*x_H);
glcd_gotoxy(x_H+1,y,0);
if(c){
glcd_WriteCmd1(1,(LCDBitSet|x_L));
} else {
glcd_WriteCmd1(1,(LCDBitReset|x_L));
}
}
// glcd_line(x0,y0, x1,y1, c) puts line from (x0, y0) to (x1, y1) with c color
//#separate
void glcd_line(signed int16 x0, signed int16 y0,
signed int16 x1, signed int16 y1 , int1 c){
int16 x;
int16 y;
unsigned int16 n;
int1 m_case;
x=abs(x1-x0);
y=abs(y1-y0);
if (y > x){
n=(y1-y0);
m_case=1;
} else {
n=(x1-x0);
m_case=0;
}
for(i=0 ; i<=n ; i++){
if (m_case){
y=i + y0;
x=(y*(x1-x0))/(y1-y0) + x0;
} else {
x=i + x0;
y=(x*(y1-y0))/(x1-x0) + y0;
}
glcd_pixel(x, y,c);
}
}
// glcd_square(x0,y0,x1,y1, c) sets square .............................. kare yapmak için
void glcd_square( unsigned int8 x0, unsigned int8 y0,
unsigned int8 x1, unsigned int8 y1 , int1 c)
{
glcd_line(x0,y0, x1,y0, c);
glcd_line(x1,y0, x1,y1, c);
glcd_line(x0,y1, x1,y1, c);
glcd_line(x0,y0, x0,y1, c);
}
// glcd_box(x0,y0,x1,y1, c)..............................................dolgu yapmak için
void glcd_box( unsigned int8 x0, unsigned int8 y0,
unsigned int8 x1, unsigned int8 y1 , int1 c)
{
unsigned int8 x;
unsigned int8 y;
for(y=y0; y<=y1;y++)
{
for(x=x0; x<=x1;x++)
{
if((!(x%8)) && ((x1-x)>8))
{
glcd_pixel8(x,y,0xFF*c); //Aynı zamanda 8 piksel yazmak için
x +=7 ;
} else {
glcd_pixel(x,y,c);
}
}
}
}
//glcd_image8 (*Pic, x, y, size_x, size_y)..............................resim basmak için
void glcd_image8(int8 *pic_px, unsigned int8 x, unsigned int8 y,
unsigned int8 size_x, unsigned int8 size_y)
{
unsigned int8 px_y;
unsigned int8 px_x;
unsigned int8 px=0;
for(px_y=y; px_y<(y+size_y); px_y++)
{
for(px_x=x; px_x<(x+size_x); px_x+=8)
{
glcd_pixel8(px_x, px_y, *(pic_px+px));
px+=1;
}
}
}
*/
#include <t6963c_2.c> //
#include <graphics.c>
#fuses NOWDT,HS, NOPUT, PROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
#use delay(clock=20000000)
int adc = 0, adc_old =0;
#inline
void logo()
{
char giris1[] = "DENEME";
char giris2[] = "IRFAN PERCIN";
char giris3[] = "irfanpercin........";
glcd_text57(12,12,giris2, 3, ON);
glcd_text57(62,45,giris1, 3, ON);
delay_ms(1000);
glcd_box(10,10,230,80, ON); //dolgu koyu renk
glcd_text57(12, 12,giris2, 3, Off);
glcd_text57(62,45,giris1, 3, Off);
delay_ms(1000);
//glcd_box(10,10,230,80, Off); //dolgu açık renk
glcd_square(10,95,220,110, on); // bar
glcd_text57(42, 98,giris3, 1, ON);
glcd_pixel(239,127,on); //
glcd_pixel(1,127,on); //
glcd_pixel(1,1,on); // köşelere tek nota pixel test
glcd_pixel(239,1,on); //
}
#inline
void adcd ()
{
int digit[4];
set_adc_channel(1);
adc = read_adc();
// clear_screen(); //sadece adc gör
for(;
{
glcd_text57(100,118, digit,1, ON);
adc = read_adc();
if(adc != adc_old)
{
glcd_text57(100, 118, digit,1, OFF);
}
adc_old = adc;
sprintf(digit, "%03u",adc);
glcd_square(95,115,120,127, on);
}
}
#inline
void main()
{
setup_adc( ADC_CLOCK_INTERNAL);
setup_adc_ports( AN0 );
delay_ms(10);
set_tris_c(0x00); // graphic lcd control lines all output
glcd_init(); //Initialization
glcd_WriteByte(2, (LCDModeSet|LCDMode_XOR)); //XOR-Mode ..................( ??????)
glcd_WriteByte(1, (LCDDispMode|LCDDisp_TXT|LCDDisp_GRH)); //Text and Graphic-Mode
delay_ms(1);
logo();
adcd();
}
/*
driwer t6963c-2
/////////////////////////////////////////////////////////////////////////
//// ////
//// Connections are as follows: ////
//// /CE - - C3 ////
//// /WR - - C4 ////
//// /RD - - C5 ////
//// C/D - - C6 ////
//// /RST- - C7 ////
//// DATA0-7 - - PORTD0-7 ////
//// LCD's FS is tied low (FS = 0 is 8x8 font) ////
//// ////
/////////////////////////////////////////////////////////////////////////
#ifndef GLCD_COL
#define GLCD_COL 240 // Used for text wrapping by glcd_text57 function and sanity check
#endif
#ifndef GLCD_ROW
#define GLCD_ROW 128 // Used for text wrapping by glcd_text57 function and sanity check
#endif
#define set_tris_lcd(x) set_tris_d(x)
#define ON 1
#define OFF 0
#define YES 1
#define NO 0
//TRIS DataBus=x, note:control bus (PORTC) always outputs
const int16 TextHome=0x0EE2; //0x0780 (240*64)/8=1920-->0x0780 ( **240*127 için 3810=0EE2)
const int8 TextArea=0x003C; //(orjinali=0x001E how many bytes before a new line (30 bytes))
const int16 GraphicsHome=0x0000;
const int8 GraphicsArea=0x003c; //(orjinali=0x001E how many bytes before a new line (30 bytes) (60 byt için 003c))
const int8 AutoModeWrite = 0xB0; //DataAutoWrite
//const int8 AutoModeRead = 0xB1; //DataAutoRead
const int8 AutoModeReset = 0xB2; //Auto reset
const int8 LCDModeSet = 0x80; // send this OR'd with the following
//const int8 LCDMode_OR = 0b0000;
const int8 LCDMode_XOR = 0b0001;
//const int8 LCDMode_AND = 0b0010; //0b0010
// const int8 LCDMode_TA = 0b0100; // TEXT ATTRIBUTE mode.
const int8 LCDMode_RAM = 0b1000; // 1=CG RAM, 0=internal CG ROM
//const int8 LCDSetCursorPtr = 0x21; // cursor address
// const int8 LCDSetCursorSize = 0xA0; // 1 line cursor
const int8 LCDDispMode = 0x90; // send this OR'd with the following
//const int8 LCDDisp_BLK = 0b0011; //0b0011 Blink Cursor
// const int8 LCDDisp_CUR = 0b0010; // Add Cursor
const int8 LCDDisp_TXT = 0b0100; //Text-OK,Graphic-NG
const int8 LCDDisp_GRH = 0b1000; //Text-NG,Graphic-OK
const int8 LCDBitSet = 0xF8;
const int8 LCDBitReset = 0xF0;
struct lcd_pin_def //Struct type bitfield
{
int1 unused1 :1; // C0
int1 unused2 :1; // C1
int1 unused3 :1; // C2
int1 ce :1; // C3 Chip enable active low
int1 w_bar :1; // C4 Write bar active low
int1 r_bar :1; // C5 Read bar active low
int1 cd :1; // C6 Command/Data BAR 1=command 0=data
int1 reset_bar :1; // C7 Reset active low
int8 data :8; // PortD=Data bus(address=8)
};
struct lcd_pin_def LCD;
#byte LCD = 7 // portC address=7 on 16F877A
//Prototyping
int glcd_ReadByte(void);
void glcd_WriteByte(int1 cd, int data);
void glcd_WriteByteAuto(int data);
void glcd_WriteCmd2(int16 data, int cmd);
void glcd_WriteCmd1(int data, int cmd);
void glcd_gotoxy(int x, int y, int1 text);
void glcd_init(void)
{
int16 counter;
set_tris_lcd(0x00); //TRIS DATA bus(PORT D),note:control bus always outputs
LCD.ce=0; //INITIAL STATES OF CONTROL PINS
LCD.w_bar=1; //
LCD.r_bar=1; //
LCD.cd=1; // command
LCD.reset_bar=0; // perform a reset
delay_us(10); // delay for a reset
LCD.reset_bar = 1; // run
// Set up the graphics and text areas
glcd_WriteCmd2(TextHome, 0x40); //TextHomeAddress Set
glcd_WriteCmd2(TextArea, 0x41); //TextArea column Set
glcd_WriteCmd2(GraphicsHome, 0x42); //GraphicHomeAddress Set
glcd_WriteCmd2(GraphicsArea, 0x43); //GraphicArea column Set
// set AddressPointer to 0
glcd_WriteCmd2(0x0000, 0x24); //Set AddressPointer to 0
// Clear all RAM of LCD (8k)
glcd_WriteByte(1, AutoModeWrite); //Set Data Auto Write
for (counter = 0; counter < 0x1fff; counter++) //0x1fff=8191 bytes
{
glcd_WriteByteAuto(0); // sıfır ile her şeyi doldurmak
}
glcd_WriteByte(1, AutoModeReset);
}
void glcd_WriteByte(int1 cd, int data) //Normal "modunda komut veya veri" olarak PORTD'ye yazın.
{
int status = 0, temp = 0;
set_tris_lcd(0xff); // All inputs
LCD.ce = 1;
LCD.w_bar = 1;
LCD.r_bar= 1;
LCD.cd = 1;//defaults
while (status != 0x03) { // is LCD busy?
LCD.r_bar= 0;
LCD.ce = 0; //After 150ns read the data on D0-7
#asm nop #endasm
temp = LCD.data;
LCD.ce = 1;
LCD.r_bar = 1;
status = temp & 0x03; //Masking
}
set_tris_lcd(0x00); // All outputs
LCD.cd = cd; // Command/Data bar (1=command 0=data)
LCD.data = data; // Put data on data bus
LCD.ce = 0;
LCD.r_bar = 1; // not read
LCD.w_bar = 0; // write
LCD.ce = 1;
LCD.w_bar = 1; // release
}
void glcd_WriteByteAuto(int data) //Write PORTD as data in "Auto" mode.
{
int status = 0, temp = 0; // WHEN Auto mode,the status bits ARE DIFFERENT BITS THAN NORMAL MODE
set_tris_lcd(0xff); // All inputs
LCD.ce = 1;
LCD.w_bar = 1;
LCD.r_bar = 1;
LCD.cd = 1; // defaults
while (status != 0x08) { // is LCD busy? Checking STA3!
LCD.r_bar = 0;
LCD.ce =0; //After 150ns read the data on D0-7
#asm nop #endasm
temp = LCD.data;
LCD.ce = 1;
LCD.r_bar = 1;
status = temp & 0x08; //Masking
}
set_tris_lcd(0x00); // All outputs
LCD.cd = 0; // This is always data
LCD.data = data; // Put data on data bus
LCD.ce = 0;
LCD.r_bar = 1; // not read
LCD.w_bar = 0; // write
LCD.ce = 1;
LCD.w_bar = 1; // release
}
void glcd_WriteCmd1(int data, int cmd)
{
glcd_WriteByte(0, data);
glcd_WriteByte(1, cmd);
}
void glcd_WriteCmd2(int16 data, int cmd)
{
glcd_WriteByte(0, data & 0xff); //masking,LSB Set
glcd_WriteByte(0, data>>8); //shift right 8bir,MSB Set
glcd_WriteByte(1, cmd);
}
int glcd_ReadByte(void)
{
int data = 0, status = 0, temp = 0;
set_tris_lcd(0xff); // All inputs
LCD.ce = 1;
LCD.w_bar = 1;
LCD.r_bar = 1;
LCD.cd = 1; // defaults
#asm nop #endasm
while (status != 0x03) { // is LCD busy?
LCD.r_bar = 0;
LCD.ce = 0;
temp = LCD.data;
LCD.ce = 1;
LCD.r_bar = 1;
status = temp & 0x03; //Masking
}
LCD.cd = 0; // Command/Data bar
LCD.ce = 0;
LCD.r_bar = 0; // read
/////////////////////////////////////////////////////////
#asm nop #endasm // THIS PAUSE IS VERY NESSESARY !!!//
/////////////////////////////////////////////////////////
data = LCD.data;
LCD.r_bar = 1;
LCD.ce = 1;
LCD.cd = 1;
return data; // Return the read data
}
void glcd_putc(char c)
{
glcd_WriteCmd1(c - 0x20, 0xc0); //c-0x20=Transfer from Ascii Code, Data Write UP.
}
void glcd_gotoxy(int x, int y, int1 text) { // sets memory location to screen location x, y
// location 1,1 is upper left corner;
// text = 1 (text area), text = 0 (graphics area)
int16 location, home;
int line;
if (!text) {
home = GraphicsHome;
line = GraphicsArea;
}
else {
home = TextHome;
line = TextArea;
}
location = home + (((int16)y - 1) * line) + x - 1;
glcd_WriteCmd2(location, 0x24);
}
Void clear_screen(void){ //very simular to the glcd_init(void)
int16 counter;
// set address to 0
glcd_WriteCmd2(0x0000, 0x24); //Set AddressPointer to 0
// Clear all RAM of LCD (8k)
glcd_WriteByte(1, AutoModeWrite); //Set Data Auto Write
for (counter = 0; counter < 0x1fff; counter++) //0x1fff=8191 bytes
{
glcd_WriteByteAuto(0); // fill everything with zeros
}
glcd_WriteByte(1, AutoModeReset);
}
unsigned int8 i; //General Purpouse variable
// glcd_pixel8(x,y,px8) sets 8 pixels in line.
void glcd_pixel8(unsigned int8 x, unsigned int8 y, int8 pixel8){
unsigned int8 x_H;
x_H = (x / 8);
glcd_gotoxy(x_H+1,y,0);
glcd_WriteCmd1(pixel8,0xc0); //Write data and increament
}
// glcd_pixel(x,y,c) sets pixel x,y with c color // tek nota için
void glcd_pixel(unsigned int8 x, unsigned int8 y, int1 c){
unsigned int8 x_H;
unsigned int8 x_L=0;
x_H = (x / 8);
x_L = 7 - (x - 8*x_H);
glcd_gotoxy(x_H+1,y,0);
if(c){
glcd_WriteCmd1(1,(LCDBitSet|x_L));
} else {
glcd_WriteCmd1(1,(LCDBitReset|x_L));
}
}
// glcd_line(x0,y0, x1,y1, c) puts line from (x0, y0) to (x1, y1) with c color
//#separate
void glcd_line(signed int16 x0, signed int16 y0,
signed int16 x1, signed int16 y1 , int1 c){
int16 x;
int16 y;
unsigned int16 n;
int1 m_case;
x=abs(x1-x0);
y=abs(y1-y0);
if (y > x){
n=(y1-y0);
m_case=1;
} else {
n=(x1-x0);
m_case=0;
}
for(i=0 ; i<=n ; i++){
if (m_case){
y=i + y0;
x=(y*(x1-x0))/(y1-y0) + x0;
} else {
x=i + x0;
y=(x*(y1-y0))/(x1-x0) + y0;
}
glcd_pixel(x, y,c);
}
}
// glcd_square(x0,y0,x1,y1, c) sets square .............................. kare yapmak için
void glcd_square( unsigned int8 x0, unsigned int8 y0,
unsigned int8 x1, unsigned int8 y1 , int1 c)
{
glcd_line(x0,y0, x1,y0, c);
glcd_line(x1,y0, x1,y1, c);
glcd_line(x0,y1, x1,y1, c);
glcd_line(x0,y0, x0,y1, c);
}
// glcd_box(x0,y0,x1,y1, c)..............................................dolgu yapmak için
void glcd_box( unsigned int8 x0, unsigned int8 y0,
unsigned int8 x1, unsigned int8 y1 , int1 c)
{
unsigned int8 x;
unsigned int8 y;
for(y=y0; y<=y1;y++)
{
for(x=x0; x<=x1;x++)
{
if((!(x%8)) && ((x1-x)>8))
{
glcd_pixel8(x,y,0xFF*c); //Aynı zamanda 8 piksel yazmak için
x +=7 ;
} else {
glcd_pixel(x,y,c);
}
}
}
}
//glcd_image8 (*Pic, x, y, size_x, size_y)..............................resim basmak için
void glcd_image8(int8 *pic_px, unsigned int8 x, unsigned int8 y,
unsigned int8 size_x, unsigned int8 size_y)
{
unsigned int8 px_y;
unsigned int8 px_x;
unsigned int8 px=0;
for(px_y=y; px_y<(y+size_y); px_y++)
{
for(px_x=x; px_x<(x+size_x); px_x+=8)
{
glcd_pixel8(px_x, px_y, *(pic_px+px));
px+=1;
}
}
}
*/
Moderatör tarafında düzenlendi: