Merhaba Arkadaşlar Hiç Bir Şekilde Yazdıramıyorum problem nerede acaba :'( !
#include <18F8722.h>
#device ADC=10
#device *=16
#use delay (internal=16M)
#include <HDM64GS12.c> // HDM64GS12.c dosyası programa ekleniyor
#include <graphics.c> // graphics.c dosyası programa ekleniyor
char yazi1[]="GAZI"; // Karakter dizisi tanımlanıyor
char yazi2[]="UNIVERSITY"; // Karakter dizisi tanımlanıyor
int i,x1,y1,x2,y2;
/********* ANA PROGRAM FONKSİYONU********/
void main ( )
{
setup_psp(PSP_DISABLED); // PSP birimi devre dışı
setup_timer_1(T1_DISABLED); // T1 zamanlayıcısı devre dışı
setup_timer_2(T2_DISABLED,0,1); // T2 zamanlayıcısı devre dışı
setup_adc_ports(NO_ANALOGS); // ANALOG giriş yok
setup_adc(ADC_OFF); // ADC birimi devre dışı
setup_CCP1(CCP_OFF); // CCP1 birimi devre dışı
setup_CCP2(CCP_OFF); // CCP2 birimi devre dışı
glcd_init(ON); // Grafik LCD hazırlanıyor ve ekran siliniyor
while(1)
{
glcd_init(ON); // Ekran siliniyor
glcd_text57(39, 5, yazi1, 2, ON); // GLCD'de yazı yazdırılıyor
glcd_text57(5, 30, yazi2, 2, ON); // GLCD'de yazı yazdırılıyor
delay_ms(2000);
glcd_init(ON); // Ekran siliniyor
x1=5;
y1=5;
x2=100;
y2=5;
for(i=0;i<6;i++)
{
glcd_line(x1, y1, x2, y2, ON); // GLCD'de Çizgi çizdiriliyor
y2=y1+=10; // y2=y1=y2+10; anlamında
x2-=10; // x2=x2-10; anlamında
delay_ms(1000);
}
glcd_init(ON); // Ekran siliniyor
x1=y1=10;
for (i=0;i<120;i++)
{
glcd_pixel(x1,y1,ON); // Ekranda istenen pikseller aktif yapılıyor
y1=x1++; // y1=x1+1; anlamında
delay_ms(50);
}
glcd_init(ON); // Ekran siliniyor
y2=60;
x1=5;
for (i=0;i<8;i++)
{
glcd_bar(x1, 0, x1, y2, 10, ON); // GLCD'de çubuk çizdiriliyor
delay_ms(1000);
x1+=15; // x1=x1+15; anlamında
y2-=5; // y2=y2-5; anlamında
}
glcd_init(ON); // Ekran siliniyor
for(i=0;i<=30;i=i+5)
{
glcd_circle(60, 30, i, NO, ON); // GLCD'de Daire çizdiriliyor
delay_ms(1000);
}
glcd_init(ON); // Ekran siliniyor
x1=5;
y1=5;
x2=120;
y2=63;
for(i=0;i<6;i++)
{
glcd_rect(x1, y1, x2, y2, NO, ON); // GLCD'de dikdötrgen çizdiriliyor
y1=x1+=5; // y1=x1+5; anlamında
x2-=5; // x2=x2-5; anlamında
y2-=5; // y2=y2-5; anlamında
delay_ms(500);
}
}
}
Hata, şema, foto ?
RESİMLER EKTEDİR RAMU
(http://s2.postimg.cc/mgyd5s4ut/lcd_1.jpg) (http://postimg.cc/image/mgyd5s4ut/)
(http://s30.postimg.cc/5y53q2v19/lcd_2.jpg) (http://postimg.cc/image/5y53q2v19/)
(http://s9.postimg.cc/vnc42vcor/lcd_3.jpg) (http://postimg.cc/image/vnc42vcor/)
#include <HDM64GS12.c> // HDM64GS12.c dosyası programa ekleniyor
kullandığın lcd kütüphanesinide eklesen iyi olur,
ccsc versiyonlarda kütüphane değişikliği yapabiliyor.
aşağıdaki gibi ise (sadece bir bölümünü aldım)
// Purpose: Write a byte of data to the specified chip
// Inputs: 1) chipSelect - which chip to write the data to
// 2) data - the byte of data to write
void glcd_writeByte(int1 side, BYTE data)
{
set_tris_d(0x00);
output_low(GLCD_RW); // Set for writing
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
delay_us(1);
output_d(data); // Put the data on the port
delay_us(1);
output_high(GLCD_E); // Pulse the enable pin
delay_us(1);
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
}
Burada gördüğün gibi
data portu 0-7 sıralı olarak glcdnin 0-7 data pinlerine bağlanmalı
ve direk 8 bitlik bir port glcd data pinleri için kullanılmalı,
farklı bir port kullanılacaksa yukarıdaki fonksiyonda gerekli değişiklik yapılmalı,
şimdilik gördüğüm bu oldu.
#ifndef HDM64GS12
#define HDM64GS12
#ifndef GLCD_WIDTH
#define GLCD_WIDTH 128
#endif
#ifndef GLCD_CS1
#define GLCD_CS1 PIN_D1 // Chip Selection 1
#endif
#ifndef GLCD_CS2
#define GLCD_CS2 PIN_D2 // Chip Selection 2
#endif
#ifndef GLCD_DI
#define GLCD_DI PIN_D5 // Data or Instruction input
#endif
#ifndef GLCD_RW
#define GLCD_RW PIN_D4 // Read/Write
#endif
#ifndef GLCD_E
#define GLCD_E PIN_D6 // Enable
#endif
#ifndef GLCD_RST
#define GLCD_RST PIN_D3 // Reset
#endif
#define GLCD_LEFT 0
#define GLCD_RIGHT 1
#ifndef ON
#define ON 1
#endif
#ifndef OFF
#define OFF 0
#endif
/////////////////////////////////////////////////////////////////////////
// Function Prototypes
/////////////////////////////////////////////////////////////////////////
void glcd_init(int1 mode);
void glcd_pixel(int8 x, int8 y, int1 color);
void glcd_fillScreen(int1 color);
void glcd_writeByte(int1 side, BYTE data);
BYTE glcd_readByte(int1 side);
void glcd_update();
/////////////////////////////////////////////////////////////////////////
#ifdef FAST_GLCD
struct
{
int8 left[512];
int8 right[512];
} displayData;
#endif
// Purpose: Initialize the LCD.
// Call before using any other LCD function.
// Inputs: OFF - Turns the LCD off
// ON - Turns the LCD on
void glcd_init(int1 mode)
{
// Initialze some pins
output_high(GLCD_RST);
output_low(GLCD_E);
output_low(GLCD_CS1);
output_low(GLCD_CS2);
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0xC0); // Specify first RAM line at the top
glcd_writeByte(GLCD_RIGHT, 0xC0); // of the screen
glcd_writeByte(GLCD_LEFT, 0x40); // Set the column address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, 0xB8); // Set the page address to 0
glcd_writeByte(GLCD_RIGHT, 0xB8);
if(mode == ON)
{
glcd_writeByte(GLCD_LEFT, 0x3F); // Turn the display on
glcd_writeByte(GLCD_RIGHT, 0x3F);
}
else
{
glcd_writeByte(GLCD_LEFT, 0x3E); // Turn the display off
glcd_writeByte(GLCD_RIGHT, 0x3E);
}
glcd_fillScreen(OFF); // Clear the display
#ifdef FAST_GLCD
glcd_update();
#endif
}
// Purpose: Update the LCD with data from the display arrays
#ifdef FAST_GLCD
void glcd_update()
{
int8 i, j;
int8 *p1, *p2;
p1 = displayData.left;
p2 = displayData.right;
// Loop through the vertical pages
for(i = 0; i < 8; ++i)
{
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0x40); // Set horizontal address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, i | 0xB8); // Set page address
glcd_writeByte(GLCD_RIGHT, i | 0xB8);
output_high(GLCD_DI); // Set for data
// Loop through the horizontal sections
for(j = 0; j < 64; ++j)
{
glcd_writeByte(GLCD_LEFT, *p1++); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, *p2++); // Turn pixels on or off
}
}
}
#endif
// Purpose: Turn a pixel on a graphic LCD on or off
// Inputs: 1) x - the x coordinate of the pixel
// 2) y - the y coordinate of the pixel
// 3) color - ON or OFF
void glcd_pixel(int8 x, int8 y, int1 color)
#ifdef FAST_GLCD
{
int8* p;
int16 temp;
temp = y/8;
temp *= 64;
temp += x;
if(x > 63)
{
p = displayData.right + temp - 64;
}
else
{
p = displayData.left + temp;
}
if(color)
{
bit_set(*p, y%8);
}
else
{
bit_clear(*p, y%8);
}
}
#else
{
BYTE data;
int1 side = GLCD_LEFT; // Stores which chip to use on the LCD
if(x > 63) // Check for first or second display area
{
x -= 64;
side = GLCD_RIGHT;
}
output_low(GLCD_DI); // Set for instruction
bit_clear(x,7); // Clear the MSB. Part of an instruction code
bit_set(x,6); // Set bit 6. Also part of an instruction code
glcd_writeByte(side, x); // Set the horizontal address
glcd_writeByte(side, (y/8 & 0xBF) | 0xB8); // Set the vertical page address
output_high(GLCD_DI); // Set for data
glcd_readByte(side); // Need two reads to get data
data = glcd_readByte(side); // at new address
if(color == ON)
bit_set(data, y%8); // Turn the pixel on
else // or
bit_clear(data, y%8); // turn the pixel off
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(side, x); // Set the horizontal address
output_high(GLCD_DI); // Set for data
glcd_writeByte(side, data); // Write the pixel data
}
#endif
// Purpose: Fill the LCD screen with the passed in color
// Inputs: ON - turn all the pixels on
// OFF - turn all the pixels off
void glcd_fillScreen(int1 color)
#ifdef FAST_GLCD
{
int8 data;
int8 *p1, *p2;
int16 i;
p1 = displayData.left;
p2 = displayData.right;
data = 0xFF * color;
for(i=0; i<512; ++i)
{
*p1++ = data;
*p2++ = data;
}
}
#else
{
int8 i, j;
// Loop through the vertical pages
for(i = 0; i < 8; ++i)
{
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0b01000000); // Set horizontal address to 0
glcd_writeByte(GLCD_RIGHT, 0b01000000);
glcd_writeByte(GLCD_LEFT, i | 0b10111000);// Set page address
glcd_writeByte(GLCD_RIGHT, i | 0b10111000);
output_high(GLCD_DI); // Set for data
// Loop through the horizontal sections
for(j = 0; j < 64; ++j)
{
glcd_writeByte(GLCD_LEFT, 0xFF*color); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, 0xFF*color); // Turn pixels on or off
}
}
}
#endif
// Purpose: Write a byte of data to the specified chip
// Inputs: 1) chipSelect - which chip to write the data to
// 2) data - the byte of data to write
void glcd_writeByte(int1 side, BYTE data)
{
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
output_low(GLCD_RW); // Set for writing
output_d(data); // Put the data on the port
delay_cycles(1);
output_high(GLCD_E); // Pulse the enable pin
delay_cycles(5);
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
}
// Purpose: Reads a byte of data from the specified chip
// Ouputs: A byte of data read from the chip
BYTE glcd_readByte(int1 side)
{
BYTE data; // Stores the data read from the LCD
set_tris_d(0xFF); // Set port d to input
output_high(GLCD_RW); // Set for reading
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
delay_cycles(1);
output_high(GLCD_E); // Pulse the enable pin
delay_cycles(4);
data = input_d(); // Get the data from the display's output register
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
return data; // Return the read data
}
#endif
Bahsettiğim gibi glcd_writeByte
ve birde glcd_readByte
fonksiyonlarında
glcd data için kullanacağın portu seçmelisin,
yani
output_d(data) > output_C(data)
data=input_d() > data = input_C()
olarak değiştirilecek,
(tris de değiştirilecek)
şimdi glcd data için portC yi kullanmış olduk
tüm port pinleri
PORTC0 GLCDdata0 a sırayla PORTC7 GLCDdata7 ye
gelecek şekilde bağlanacak.
PORTC için değiştirilirse şöyle olacak;
void glcd_writeByte(int1 side, BYTE data)
{
set_tris_C(0x00); // POTRC ÇIKIŞ YAP
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
output_low(GLCD_RW); // Set for writing
output_C(data); // Put the data on the port
delay_cycles(1);
output_high(GLCD_E); // Pulse the enable pin
delay_cycles(5);
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
}
// Purpose: Reads a byte of data from the specified chip
// Ouputs: A byte of data read from the chip
BYTE glcd_readByte(int1 side)
{
BYTE data; // Stores the data read from the LCD
set_tris_C(0xFF); // Set port C to input
output_high(GLCD_RW); // Set for reading
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
delay_cycles(1);
output_high(GLCD_E); // Pulse the enable pin
delay_cycles(4);
data = input_C(); // Get the data from the display's output register
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
return data; // Return the read data
}
Gerekli değişiklikleri yapıp dene sonuca bakalım.
RAMU yalnız şunu belirtmek istiyorum sadece isis üzerinde çalıştırmıyorum şu an kurulu hazır devre var onun üzerinde çalışıyorum
Bu değişikliği yapmadığın müddetçe çalışması mümkün değil,
isis gerçek farketmez.
Ramu portları C'ye aktarmam imkansız şu an tamamlanmış bir kit üzerinde çalışıyorum
Bu kütüphane bu bağlantı ile glcdyi çalıştıramazsın,
2x16 lcd için flex_lcd.c kütüphanesi var
bunun gibi flex glcd kütüphanesi bulubilirsen veya
yazabilirsen halihazırdaki bağlantın ile çalıştırabilirsin,
çok zor bir değişiklik değil.
Yani sağlaman gereken şu;
yukarıda gösterdiğim write ve read fonksiyonlarında
misal write da
data değişkeni içindeki 8 bitlik bilgiyi
orijinal kütüphanede output_d(data)
şeklinde direk bir porta göndermeyeceksin
tek tek 0-7 bitlerini kendi seçtiğin dağınık bağlı olan mcu pinlerine tek tek vereceksin
geri kalan kısmı aynı kalacak
//output_C(data); // lcd data portuna bilgiyi gönder > değişecek
delay_cycles(1); //>>>>>>>devamı aynı
output_high(GLCD_E); // Pulse the enable pin
Ramu İncelermisin Düzenledim Bu şekilde Yalnız Yine Çalışmıyor !
#ifndef HDM64GS12
#define HDM64GS12
#ifndef GLCD_WIDTH
#define GLCD_WIDTH 128
#endif
#ifndef GLCD_CS1
#define GLCD_CS1 PIN_D1 // Chip Selection 1
#endif
#ifndef GLCD_CS2
#define GLCD_CS2 PIN_D2 // Chip Selection 2
#endif
#ifndef GLCD_DI
#define GLCD_DI PIN_D5 // Data or Instruction input
#endif
#ifndef GLCD_RW
#define GLCD_RW PIN_D4 // Read/Write
#endif
#ifndef GLCD_E
#define GLCD_E PIN_D6 // Enable
#endif
#ifndef GLCD_RST
#define GLCD_RST PIN_D3 // Reset
#endif
#define GLCD_LEFT 0
#define GLCD_RIGHT 1
#ifndef ON
#define ON 1
#endif
#ifndef OFF
#define OFF 0
#endif
union {
unsigned char byteb;
struct {
unsigned byt0:1;
unsigned byt1:1;
unsigned byt2:1;
unsigned byt3:1;
unsigned byt4:1;
unsigned byt5:1;
unsigned byt6:1;
unsigned byt7:1;
};
}bytbbits;
union {
unsigned char berke;
struct {
unsigned ber0:1;
unsigned ber1:1;
unsigned ber2:1;
unsigned ber3:1;
unsigned ber4:1;
unsigned ber5:1;
unsigned ber6:1;
unsigned ber7:1;
};
}bytberke;
void PYOLLA(void){
output_bit( PIN_H0,bytbbits.byt0);
output_bit( PIN_E2,bytbbits.byt1);
output_bit( PIN_E3,bytbbits.byt2);
output_bit( PIN_E4,bytbbits.byt3);
output_bit( PIN_E5,bytbbits.byt4);
output_bit( PIN_E6,bytbbits.byt5);
output_bit( PIN_E7,bytbbits.byt6);
output_bit( PIN_D0,bytbbits.byt7);
}
void PYOLLA2(void){
bytbbits.byt0=input(PIN_H0);
bytbbits.byt1=input(PIN_E2);
bytbbits.byt2=input(PIN_E3);
bytbbits.byt3=input(PIN_E4);
bytbbits.byt4=input(PIN_E5);
bytbbits.byt5=input(PIN_E6);
bytbbits.byt6=input(PIN_E7);
bytbbits.byt7=input(PIN_D0);
}
/////////////////////////////////////////////////////////////////////////
// Function Prototypes
/////////////////////////////////////////////////////////////////////////
void glcd_init(int1 mode);
void glcd_pixel(int8 x, int8 y, int1 color);
void glcd_fillScreen(int1 color);
void glcd_writeByte(int1 side, BYTE data);
BYTE glcd_readByte(int1 side);
void glcd_update();
/////////////////////////////////////////////////////////////////////////
#ifdef FAST_GLCD
struct
{
int8 left[512];
int8 right[512];
} displayData;
#endif
// Purpose: Initialize the LCD.
// Call before using any other LCD function.
// Inputs: OFF - Turns the LCD off
// ON - Turns the LCD on
void glcd_init(int1 mode)
{
// Initialze some pins
output_high(GLCD_RST);
output_low(GLCD_E);
output_low(GLCD_CS1);
output_low(GLCD_CS2);
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0xC0); // Specify first RAM line at the top
glcd_writeByte(GLCD_RIGHT, 0xC0); // of the screen
glcd_writeByte(GLCD_LEFT, 0x40); // Set the column address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, 0xB8); // Set the page address to 0
glcd_writeByte(GLCD_RIGHT, 0xB8);
if(mode == ON)
{
glcd_writeByte(GLCD_LEFT, 0x3F); // Turn the display on
glcd_writeByte(GLCD_RIGHT, 0x3F);
}
else
{
glcd_writeByte(GLCD_LEFT, 0x3E); // Turn the display off
glcd_writeByte(GLCD_RIGHT, 0x3E);
}
glcd_fillScreen(OFF); // Clear the display
#ifdef FAST_GLCD
glcd_update();
#endif
}
// Purpose: Update the LCD with data from the display arrays
#ifdef FAST_GLCD
void glcd_update()
{
int8 i, j;
int8 *p1, *p2;
p1 = displayData.left;
p2 = displayData.right;
// Loop through the vertical pages
for(i = 0; i < 8; ++i)
{
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0x40); // Set horizontal address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, i | 0xB8); // Set page address
glcd_writeByte(GLCD_RIGHT, i | 0xB8);
output_high(GLCD_DI); // Set for data
// Loop through the horizontal sections
for(j = 0; j < 64; ++j)
{
glcd_writeByte(GLCD_LEFT,*p1++); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT,*p2++); // Turn pixels on or off
}
}
}
#endif
// Purpose: Turn a pixel on a graphic LCD on or off
// Inputs: 1) x - the x coordinate of the pixel
// 2) y - the y coordinate of the pixel
// 3) color - ON or OFF
void glcd_pixel(int8 x, int8 y, int1 color)
#ifdef FAST_GLCD
{
int8* p;
int16 temp;
temp = y/8;
temp *= 64;
temp += x;
if(x > 63)
{
p = displayData.right + temp - 64;
}
else
{
p = displayData.left + temp;
}
if(color)
{
bit_set(*p, y%8);
}
else
{
bit_clear(*p, y%8);
}
}
#else
{
BYTE data;
int1 side = GLCD_LEFT; // Stores which chip to use on the LCD
if(x > 63) // Check for first or second display area
{
x -= 64;
side = GLCD_RIGHT;
}
output_low(GLCD_DI); // Set for instruction
bit_clear(x,7); // Clear the MSB. Part of an instruction code
bit_set(x,6); // Set bit 6. Also part of an instruction code
glcd_writeByte(side, x); // Set the horizontal address
glcd_writeByte(side, (y/8 & 0xBF) | 0xB8); // Set the vertical page address
output_high(GLCD_DI); // Set for data
glcd_readByte(side); // Need two reads to get data
data = glcd_readByte(side); // at new address
if(color == ON)
bit_set(data, y%8); // Turn the pixel on
else // or
bit_clear(data, y%8); // turn the pixel off
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(side, x); // Set the horizontal address
output_high(GLCD_DI); // Set for data
glcd_writeByte(side, data); // Write the pixel data
}
#endif
// Purpose: Fill the LCD screen with the passed in color
// Inputs: ON - turn all the pixels on
// OFF - turn all the pixels off
void glcd_fillScreen(int1 color)
#ifdef FAST_GLCD
{
int8 data;
int8 *p1, *p2;
int16 i;
p1 = displayData.left;
p2 = displayData.right;
data = 0xFF * color;
for(i=0; i<512; ++i)
{
*p1++ = data;
*p2++ = data;
}
}
#else
{
int8 i, j;
// Loop through the vertical pages
for(i = 0; i < 8; ++i)
{
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0b01000000); // Set horizontal address to 0
glcd_writeByte(GLCD_RIGHT, 0b01000000);
glcd_writeByte(GLCD_LEFT, i | 0b10111000);// Set page address
glcd_writeByte(GLCD_RIGHT, i | 0b10111000);
output_high(GLCD_DI); // Set for data
// Loop through the horizontal sections
for(j = 0; j < 64; ++j)
{
glcd_writeByte(GLCD_LEFT, 0xFF*color); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, 0xFF*color); // Turn pixels on or off
}
}
}
#endif
// Purpose: Write a byte of data to the specified chip
// Inputs: 1) chipSelect - which chip to write the data to
// 2) data - the byte of data to write
void glcd_writeByte(int1 side, BYTE data)
{
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
output_low(GLCD_RW); // Set for writing
bytbbits.byteb=data;
PYOLLA();
// output_c(bytberke.berke);
delay_us(10);//1
output_high(GLCD_E); // Pulse the enable pin
delay_us(10);//1
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
}
// Purpose: Reads a byte of data from the specified chip
// Ouputs: A byte of data read from the chip
unsigned BYTE glcd_readByte(int1 side)
{
BYTE data; // Stores the data read from the LCD
//set_tris_c(0xFF); // Set port d to input
set_tris_H(0b00000001);
set_tris_E(0b11111100);
set_tris_D(0b00000001);
output_high(GLCD_RW); // Set for reading
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_high(GLCD_CS1);
delay_us(10);//1
output_high(GLCD_E); // Pulse the enable pin
delay_us(10);//1
//bytberke.berke = input_c(); //gd yazdı
PYOLLA2();
data=bytbbits.byteb;
//data = input_c(); // Get the data from the display's output register
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
return data; // Return the read data
}
#endif
Değişikliği glcd kütüphanesinde belirttiğim foksiyonlarda yapman gerekiyor.
mesaj birleştirme:: 16 Kasım 2014, 19:44:08
#include <HDM64GS12.c> // HDM64GS12.c dosyası programa ekleniyor
bu kütüphane içindeki data gönderme ve alma kısımları değişecek yani.
mesaj birleştirme:: 16 Kasım 2014, 19:46:24
#include <graphics.c> // graphics.c dosyası programa ekleniyor
bu kütüphane ile sorunumuz yok, bir değişiklik yapılmayacak bu kütüphanede,
bunun içinde sadece dikdörtgen daire vs. çizme fonksiyonları var.
#ifndef GLCD_C
#define GLCD_C
#ifndef GLCD_WIDTH
#define GLCD_WIDTH 128 // Used for text wrapping by glcd_text57 function
#endif
#define ON 1
#define OFF 0
#define YES 1
#define NO 0
#ifndef GLCD_CS1
#define GLCD_CS1 PIN_D1 // Chip Selection 1
#endif
#ifndef GLCD_CS2
#define GLCD_CS2 PIN_D2 // Chip Selection 2
#endif
#ifndef GLCD_DI
#define GLCD_DI PIN_D5 // Data or Instruction input
#endif
#ifndef GLCD_RW
#define GLCD_RW PIN_D4 // Read/Write
#endif
#ifndef GLCD_E
#define GLCD_E PIN_D6 // Enable
#endif
#ifndef GLCD_RST
#define GLCD_RST PIN_D3 // Reset
#endif
BYTE glcd_readByte(BYTE chip);
void glcd_writeByte(BYTE chip, BYTE data);
void glcd_fillScreen(int1 color);
const BYTE TEXT[51][5] ={0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
0x00, 0x00, 0x5F, 0x00, 0x00, // !
0x00, 0x03, 0x00, 0x03, 0x00, // "
0x14, 0x3E, 0x14, 0x3E, 0x14, // #
0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
0x43, 0x33, 0x08, 0x66, 0x61, // %
0x36, 0x49, 0x55, 0x22, 0x50, // &
0x00, 0x05, 0x03, 0x00, 0x00, // '
0x00, 0x1C, 0x22, 0x41, 0x00, // (
0x00, 0x41, 0x22, 0x1C, 0x00, // )
0x14, 0x08, 0x3E, 0x08, 0x14, // *
0x08, 0x08, 0x3E, 0x08, 0x08, // +
0x00, 0x50, 0x30, 0x00, 0x00, // ,
0x08, 0x08, 0x08, 0x08, 0x08, // -
0x00, 0x60, 0x60, 0x00, 0x00, // .
0x20, 0x10, 0x08, 0x04, 0x02, // /
0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
0x04, 0x02, 0x7F, 0x00, 0x00, // 1
0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x22, 0x41, 0x49, 0x49, 0x36, // 3
0x18, 0x14, 0x12, 0x7F, 0x10, // 4
0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x3E, 0x49, 0x49, 0x49, 0x32, // 6
0x01, 0x01, 0x71, 0x09, 0x07, // 7
0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x26, 0x49, 0x49, 0x49, 0x3E, // 9
0x00, 0x36, 0x36, 0x00, 0x00, // :
0x00, 0x56, 0x36, 0x00, 0x00, // ;
0x08, 0x14, 0x22, 0x41, 0x00, // <
0x14, 0x14, 0x14, 0x14, 0x14, // =
0x00, 0x41, 0x22, 0x14, 0x08, // >
0x02, 0x01, 0x51, 0x09, 0x06, // ?
0x3E, 0x41, 0x59, 0x55, 0x5E, // @
0x7E, 0x09, 0x09, 0x09, 0x7E, // A
0x7F, 0x49, 0x49, 0x49, 0x36, // B
0x3E, 0x41, 0x41, 0x41, 0x22, // C
0x7F, 0x41, 0x41, 0x41, 0x3E, // D
0x7F, 0x49, 0x49, 0x49, 0x41, // E
0x7F, 0x09, 0x09, 0x09, 0x01, // F
0x3E, 0x41, 0x41, 0x49, 0x3A, // G
0x7F, 0x08, 0x08, 0x08, 0x7F, // H
0x00, 0x41, 0x7F, 0x41, 0x00, // I
0x30, 0x40, 0x40, 0x40, 0x3F, // J
0x7F, 0x08, 0x14, 0x22, 0x41, // K
0x7F, 0x40, 0x40, 0x40, 0x40, // L
0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
0x7F, 0x02, 0x04, 0x08, 0x7F, // N
0x3E, 0x41, 0x41, 0x41, 0x3E, // O
0x7F, 0x09, 0x09, 0x09, 0x06, // P
0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
0x7F, 0x09, 0x09, 0x09, 0x76};// R
const BYTE TEXT2[44][5]={0x26, 0x49, 0x49, 0x49, 0x32, // S
0x01, 0x01, 0x7F, 0x01, 0x01, // T
0x3F, 0x40, 0x40, 0x40, 0x3F, // U
0x1F, 0x20, 0x40, 0x20, 0x1F, // V
0x7F, 0x20, 0x10, 0x20, 0x7F, // W
0x41, 0x22, 0x1C, 0x22, 0x41, // X
0x07, 0x08, 0x70, 0x08, 0x07, // Y
0x61, 0x51, 0x49, 0x45, 0x43, // Z
0x00, 0x7F, 0x41, 0x00, 0x00, // [
0x02, 0x04, 0x08, 0x10, 0x20, // \
0x00, 0x00, 0x41, 0x7F, 0x00, // ]
0x04, 0x02, 0x01, 0x02, 0x04, // ^
0x40, 0x40, 0x40, 0x40, 0x40, // _
0x00, 0x01, 0x02, 0x04, 0x00, // `
0x20, 0x54, 0x54, 0x54, 0x78, // a
0x7F, 0x44, 0x44, 0x44, 0x38, // b
0x38, 0x44, 0x44, 0x44, 0x44, // c
0x38, 0x44, 0x44, 0x44, 0x7F, // d
0x38, 0x54, 0x54, 0x54, 0x18, // e
0x04, 0x04, 0x7E, 0x05, 0x05, // f
0x08, 0x54, 0x54, 0x54, 0x3C, // g
0x7F, 0x08, 0x04, 0x04, 0x78, // h
0x00, 0x44, 0x7D, 0x40, 0x00, // i
0x20, 0x40, 0x44, 0x3D, 0x00, // j
0x7F, 0x10, 0x28, 0x44, 0x00, // k
0x00, 0x41, 0x7F, 0x40, 0x00, // l
0x7C, 0x04, 0x78, 0x04, 0x78, // m
0x7C, 0x08, 0x04, 0x04, 0x78, // n
0x38, 0x44, 0x44, 0x44, 0x38, // o
0x7C, 0x14, 0x14, 0x14, 0x08, // p
0x08, 0x14, 0x14, 0x14, 0x7C, // q
0x00, 0x7C, 0x08, 0x04, 0x04, // r
0x48, 0x54, 0x54, 0x54, 0x20, // s
0x04, 0x04, 0x3F, 0x44, 0x44, // 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, 0x41, // {
0x00, 0x00, 0x7F, 0x00, 0x00, // |
0x41, 0x41, 0x36, 0x08, 0x00, // }
0x02, 0x01, 0x02, 0x04, 0x02};// ~
// Purpose: Initialize a graphic LCD. This must be called before any
// other glcd function is used.
// Inputs: The initialization mode
// OFF - Turns the LCD off
// ON - Turns the LCD on
// Date: 5/28/2003
void glcd_init(int1 mode)
{
// Initialze some pins
output_high(GLCD_RST);
output_low(GLCD_E);
output_low(GLCD_CS1);
output_low(GLCD_CS2);
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_CS1, 0xC0); // Specify first RAM line at the top
glcd_writeByte(GLCD_CS2, 0xC0); // of the screen
glcd_writeByte(GLCD_CS1, 0x40); // Set the column address to 0
glcd_writeByte(GLCD_CS2, 0x40);
glcd_writeByte(GLCD_CS1, 0xB8); // Set the page address to 0
glcd_writeByte(GLCD_CS2, 0xB8);
if(mode == ON)
{
glcd_writeByte(GLCD_CS1, 0x3F); // Turn the display on
glcd_writeByte(GLCD_CS2, 0x3F);
}
else
{
glcd_writeByte(GLCD_CS1, 0x3E); // Turn the display off
glcd_writeByte(GLCD_CS2, 0x3E);
}
glcd_fillScreen(OFF); // Clear the display
}
// Purpose: Turn a pixel on a graphic LCD on or off
// Inputs: x - the x coordinate of the pixel
// y - the y coordinate of the pixel
// color - ON or OFF
// Output: 1 if coordinate out of range, 0 if in range
void glcd_pixel(int x, int y, int1 color)
{
BYTE data;
BYTE chip = GLCD_CS1; // Stores which chip to use on the LCD
if(x > 63) // Check for first or second display area
{
x -= 64;
chip = GLCD_CS2;
}
output_low(GLCD_DI); // Set for instruction
bit_clear(x,7); // Clear the MSB. Part of an instruction code
bit_set(x,6); // Set bit 6. Also part of an instruction code
glcd_writeByte(chip, x); // Set the horizontal address
glcd_writeByte(chip, (y/8 & 0b10111111) | 0b10111000); // Set the vertical page address
output_high(GLCD_DI); // Set for data
data = glcd_readByte(chip);
if(color == ON)
bit_set(data, y%8); // Turn the pixel on
else // or
bit_clear(data, y%8); // turn the pixel off
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(chip, x); // Set the horizontal address
output_high(GLCD_DI); // Set for data
glcd_writeByte(chip, data); // Write the pixel data
}
// Purpose: Draw a line on a graphic LCD using Bresenham's
// line drawing algorithm
// Inputs: (x1, y1) - the start coordinate
// (x2, y2) - the end coordinate
// color - ON or OFF
// Dependencies: glcd_pixel()
void glcd_line(int x1, int y1, int x2, int y2, int1 color)
{
signed int x, y, addx, addy, dx, dy;
signed long P;
int i;
dx = abs((signed int)(x2 - x1));
dy = abs((signed int)(y2 - y1));
x = x1;
y = y1;
if(x1 > x2)
addx = -1;
else
addx = 1;
if(y1 > y2)
addy = -1;
else
addy = 1;
if(dx >= dy)
{
P = 2*dy - dx;
for(i=0; i<=dx; ++i)
{
glcd_pixel(x, y, color);
if(P < 0)
{
P += 2*dy;
x += addx;
}
else
{
P += 2*dy - 2*dx;
x += addx;
y += addy;
}
}
}
else
{
P = 2*dx - dy;
for(i=0; i<=dy; ++i)
{
glcd_pixel(x, y, color);
if(P < 0)
{
P += 2*dx;
y += addy;
}
else
{
P += 2*dx - 2*dy;
x += addx;
y += addy;
}
}
}
}
// Purpose: Draw a rectangle on a graphic LCD
// Inputs: (x1, y1) - the start coordinate
// (x2, y2) - the end coordinate
// fill - YES or NO
// color - ON or OFF
// Dependencies: glcd_pixel(), glcd_line()
void glcd_rect(int x1, int y1, int x2, int y2, int fill, int1 color)
{
if(fill)
{
int y, ymax; // Find the y min and max
if(y1 < y2)
{
y = y1;
ymax = y2;
}
else
{
y = y2;
ymax = y1;
}
for(; y<=ymax; ++y) // Draw lines to fill the rectangle
glcd_line(x1, y, x2, y, color);
}
else
{
glcd_line(x1, y1, x2, y1, color); // Draw the 4 sides
glcd_line(x1, y2, x2, y2, color);
glcd_line(x1, y1, x1, y2, color);
glcd_line(x2, y1, x2, y2, color);
}
}
// Purpose: Draw a bar (wide line) on a graphic LCD
// Inputs: (x1, y1) - the start coordinate
// (x2, y2) - the end coordinate
// width - The number of pixels wide
// color - ON or OFF
void glcd_bar(int x1, int y1, int x2, int y2, int width, int1 color)
{
signed int x, y, addx, addy, j;
signed long P, dx, dy, c1, c2;
int i;
dx = abs((signed int)(x2 - x1));
dy = abs((signed int)(y2 - y1));
x = x1;
y = y1;
c1 = -dx*x1 - dy*y1;
c2 = -dx*x2 - dy*y2;
if(x1 > x2)
{
addx = -1;
c1 = -dx*x2 - dy*y2;
c2 = -dx*x1 - dy*y1;
}
else
addx = 1;
if(y1 > y2)
{
addy = -1;
c1 = -dx*x2 - dy*y2;
c2 = -dx*x1 - dy*y1;
}
else
addy = 1;
if(dx >= dy)
{
P = 2*dy - dx;
for(i=0; i<=dx; ++i)
{
for(j=-(width/2); j<width/2+width%2; ++j)
{
if(dx*x+dy*(y+j)+c1 >= 0 && dx*x+dy*(y+j)+c2 <=0)
glcd_pixel(x, y+j, color);
}
if(P < 0)
{
P += 2*dy;
x += addx;
}
else
{
P += 2*dy - 2*dx;
x += addx;
y += addy;
}
}
}
else
{
P = 2*dx - dy;
for(i=0; i<=dy; ++i)
{
if(P < 0)
{
P += 2*dx;
y += addy;
}
else
{
P += 2*dx - 2*dy;
x += addx;
y += addy;
}
for(j=-(width/2); j<width/2+width%2; ++j)
{
if(dx*x+dy*(y+j)+c1 >= 0 && dx*x+dy*(y+j)+c2 <=0)
glcd_pixel(x+j, y, color);
}
}
}
}
// Purpose: Draw a circle on a graphic LCD
// Inputs: (x,y) - the center of the circle
// radius - the radius of the circle
// fill - YES or NO
// color - ON or OFF
void glcd_circle(int x, int y, int radius, int1 fill, int1 color)
{
signed int a, b, P;
a = 0;
b = radius;
P = 1 - radius;
do
{
if(fill)
{
glcd_line(x-a, y+b, x+a, y+b, color);
glcd_line(x-a, y-b, x+a, y-b, color);
glcd_line(x-b, y+a, x+b, y+a, color);
glcd_line(x-b, y-a, x+b, y-a, color);
}
else
{
glcd_pixel(a+x, b+y, color);
glcd_pixel(b+x, a+y, color);
glcd_pixel(x-a, b+y, color);
glcd_pixel(x-b, a+y, color);
glcd_pixel(b+x, y-a, color);
glcd_pixel(a+x, y-b, color);
glcd_pixel(x-a, y-b, color);
glcd_pixel(x-b, y-a, color);
}
if(P < 0)
P+= 3 + 2*a++;
else
P+= 5 + 2*(a++ - b--);
} while(a <= b);
}
// Purpose: Write text on a graphic LCD
// Inputs: (x,y) - The upper left coordinate of the first letter
// textptr - A pointer to an array of text to display
// size - The size of the text: 1 = 5x7, 2 = 10x14, ...
// color - ON or OFF
void glcd_text57(int x, int y, char* textptr, int size, int1 color)
{
int i, j, k, l, m; // Loop counters
BYTE pixelData[5]; // Stores character data
for(i=0; textptr[i] != '\0'; ++i, ++x) // Loop through the passed string
{
if(textptr[i] < 'S') // Checks if the letter is in the first text array
memcpy(pixelData, TEXT[textptr[i]-' '], 5);
else if(textptr[i] <= '~') // Check if the letter is in the second array
memcpy(pixelData, TEXT2[textptr[i]-'S'], 5);
else
memcpy(pixelData, TEXT[0], 5); // Default to space
if(x+5*size >= GLCD_WIDTH) // Performs character wrapping
{
x = 0; // Set x at far left position
y += 7*size + 1; // Set y at next position down
}
for(j=0; j<5; ++j, x+=size) // Loop through character byte data
{
for(k=0; k<7*size; ++k) // Loop through the vertical pixels
{
if(bit_test(pixelData[j], k)) // Check if the pixel should be set
{
for(l=0; l<size; ++l) // The next two loops change the
{ // character's size
for(m=0; m<size; ++m)
{
glcd_pixel(x+m, y+k*size+l, color); // Draws the pixel
}
}
}
}
}
}
}
// Purpose: Fill the LCD screen with the passed in color.
// Works much faster than drawing a rectangle to fill the screen.
// Inputs: ON - turn all the pixels on
// OFF - turn all the pixels off
// Dependencies: glcd_writeByte()
void glcd_fillScreen(int1 color)
{
int i, j;
// Loop through the vertical pages
for(i = 0; i < 8; ++i)
{
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_CS1, 0b01000000); // Set horizontal address to 0
glcd_writeByte(GLCD_CS2, 0b01000000);
glcd_writeByte(GLCD_CS1, i | 0b10111000); // Set page address
glcd_writeByte(GLCD_CS2, i | 0b10111000);
output_high(GLCD_DI); // Set for data
// Loop through the horizontal sections
for(j = 0; j < 64; ++j)
{
glcd_writeByte(GLCD_CS1, 0xFF*color); // Turn pixels on or off
glcd_writeByte(GLCD_CS2, 0xFF*color); // Turn pixels on or off
}
}
}
// Purpose: Write a byte of data to the specified chip
// Inputs: chipSelect - which chip to write the data to
// data - the byte of data to write
void glcd_writeByte(char chip, BYTE data)
{
if(chip == GLCD_CS1) // Choose which chip to write to
output_high(GLCD_CS1);
else
output_high(GLCD_CS2);
output_low(GLCD_RW); // Set for writing
output_d(data); // Put the data on the port
output_high(GLCD_E); // Pulse the enable pin
delay_us(2);
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
}
// Purpose: Reads a byte of data from the specified chip
// Ouputs: A byte of data read from the chip
BYTE glcd_readByte(BYTE chip)
{
BYTE data;
// Stores the data read from the LCD
if(chip == GLCD_CS1) // Choose which chip to read from
output_high(GLCD_CS1);
else
output_high(GLCD_CS2);
input_d(); // Set port d to input
output_high(GLCD_RW); // Set for reading
output_high(GLCD_E); // Pulse the enable pin
delay_us(2);
output_low(GLCD_E);
delay_us(2);
output_high(GLCD_E); // Pulse the enable pin
delay_us(2);
data = input_d(); // Get the data from the display's output register
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
return data; // Return the read data
}
#endif
Pardon değişiklikleri zaten gerekli kütüphanede yapmışsın,
istersen isis çizimini gönder bende deneyeyim.
RAMU Karıştı iyice hangisinde yapmışım anlamadım ;D
10 nolu mesajındaki gibi birşeyler yapmak lazım.
Ben ilk bakışta onu main sandım.
Ramu acaba ana programın içerisindemi yanlışlık var isis şeması sadece gönderdiğim şekilde var ben sürekli kitin üzerinde çalışıyorum isiste denemedim
Programı derlemeden isiste denemeden herşeyi görmek zor,
oturup şemayı çizmekle uğraşamayacağım için
göndermeni istedim.
Bakmak lazım heryerde hata olabilir,
donanımda da sıkıntı olabilir,
kit üzerinde bağlantının şemada verdiğin gibi olduğuna emin misin,
yani aslında beslemeden başla gidebildiğin yere kadar hata olabilir,
hepsi başımıza geliyor.
Ramu isis çizimini yapıyorum göndereceğim 15dk.
Ramu Problem çözüldü 10. mesajdaki duzenlemem ile sorun çözülmüş aslında Ana programda sorun varmış çok yordu ama şu anda gayet sağlıklı çalışıyor yardımların için teşekkürler.
(http://s2.postimg.cc/whnfzshd1/IMG_20141117_100824.jpg) (http://postimg.cc/image/whnfzshd1/)
Hayırlı olsun.
Mersi Bütün milletimize .
Aslında bütün milletlerede faydalı olabilir,
kütüphanenin bu halini "az biraz flex_glcd" diye
konu açıp paylaşabiliriz,
bu şekilde pinleri dağınık bağlayıp kullanmak isteyenler vardır.
Tam flex glcd yede çevrilerek paylaşılabilir,
yani data pinlerinide diğer pinler gibi define ile anımlayıp kullanılabilecek hale getirip paylaşılabilir.