Rev 328 | Go to most recent revision | Blame | Last modification | View Log | Download
#include ".\gmetr.h"
#define LCD_RS PIN_B1 // rizeni registru LCD displeje
#define LCD_E PIN_B0 // enable LCD displeje
#define LCD_DATA_LSB PIN_C4 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
#include "C:\library\CCS\lcd.c"
void main()
{
signed int16 stred;
signed int8 hodnota;
unsigned int8 i, offset;
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
lcd_init();
Delay_ms(100);
set_adc_channel(1);
LCD_gotoxy(1,1);
printf(lcd_putc,"Gmetr 0.1.2 Beta");
LCD_gotoxy(1,2);
printf(lcd_putc,"Kaklik@mlab.cz");
Delay_ms(500);
LCD_clr();
LCD_gotoxy(1,1);
printf(lcd_putc,"Clibration...");
stred = 0;
for(i=0;i<=127;i++)
{
Delay_ms(10);
stred = stred + read_adc();
}
stred = stred >> 7;
while(true)
{
hodnota = read_adc();
Delay_ms(50);
LCD_clr();
LCD_gotoxy(6,1);
printf(lcd_putc," %03ld ",(stred - hodnota));
if (hodnota > stred)
{
offset = hodnota - stred;
offset = (offset >> 5) + 8;
}
else
{
offset = stred - hodnota;
offset = offset >> 5;
}
LCD_gotoxy(offset,2);
printf(lcd_putc,"*");
}
}