[an error occurred while processing this directive]
Ответ: не прав см. код
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено s-shev 17 сентября 2003 г. 19:22
В ответ на: Гы!!! отправлено bzx 17 сентября 2003 г. 19:20

#include "lcd.h"

static unsigned char msg_buf[LCD_WIDTH+1];

void lcd_init(void)
{
LCD_LED=1;
lcd_clear(); //clear
lcd_cmd(0x0E); //lcd ON cursor ON blink OFF
lcd_cmd(0x3C); //8 bit
}
void put_val_t(char f)
{
char buf[LCD_WIDTH+1], i;
sprintf(buf,"T=%2d C",f);
for(i=0;i lcd_puts(msg_buf);
}
void put_val_f(float f)
{
char buf[LCD_WIDTH+1], i;
sprintf(buf,"f=%10.6f GHz",f);
for(i=0;i lcd_puts(msg_buf);
}
void put_val_u(float f)
{
char buf[LCD_WIDTH+1], i;
sprintf(buf,"U=%5.3f V",f);
for(i=0;i lcd_puts(msg_buf);
}
/* write a string of chars to the LCD */
void lcd_puts(unsigned char *s)
{
while(*s)
lcd_data(*s++);
}
/* send a command to the LCD */
void lcd_cmd(unsigned char c)
{
LCD_WAIT; // may check LCD busy flag, or just delay a little, depending on lcd.h
LCD_RS=0;
LCD_RW=0;
LCD_DATA = c;
LCD_STROBE();
}
/* send data to the LCD */
void lcd_data(unsigned char c)
{
LCD_WAIT; // may check LCD busy flag, or just delay a little, depending on lcd.h

LCD_DATA = 0;
LCD_RS = 1;

LCD_DATA = c;
LCD_STROBE();

LCD_RS = 0;
}

void LCD_STROBE(void)
{
LCD_EN = 1;
NOP();
NOP();
LCD_EN = 0;
}

char LCD_STROBE_READ(void)
{
char value;
LCD_EN = 1;
NOP();
NOP();
value=LCD_DATA_PORT;
LCD_EN = 0;
return value;
}
unsigned char lcd_read_cmd_nowait(void)
{
unsigned char c, readc;

LCD_DATA_TRIS = INPUT_DATA;

LCD_RW = 1; // Read LCD
NOP(); // short propagation delay
NOP(); // short propagation delay

readc=LCD_STROBE_READ();
c = readc;
LCD_RW = 0; // Return to default mode of writing LCD
LCD_DATA_TRIS = OUTPUT_DATA; // Return to default mode of writing LCD

return(c);
}
void lcd_check_busy(void) // Return when the LCD is no longer busy, or we've waiting long enough!
{
// To avoid hanging forever in event there's a bad or
// missing LCD on hardware. Will just run SLOW, but still run.
unsigned int retry;
unsigned char c;

for (retry=1000; retry-- > 0; ) {
c = lcd_read_cmd_nowait();
if (0==(c&0x80)) break; // Check busy bit. If zero, no longer busy
}
}
void put_val_test(float f,char j)
{
char buf[LCD_WIDTH+1], i;
sprintf(buf,"Test Stage %d ",j);
for(i=0;i lcd_goto(MESSAGE_LINE);
lcd_puts(msg_buf);
lcd_goto(SW_LINE);
sprintf(buf,"U=%5.3f V",f);
for(i=0;i lcd_puts(msg_buf);
}
void put_val_err(float f,char j)
{
char buf[LCD_WIDTH+1], i;
sprintf(buf,"Test Stage %d ",j);
for(i=0;i lcd_goto(MESSAGE_LINE);
lcd_puts(msg_buf);
lcd_goto(SW_LINE);
sprintf(buf,"ERR U=%5.3f V",f);
for(i=0;i lcd_puts(msg_buf);
}

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru