1,4 → 1,4 |
#include "D:\KAKLIK\programy\PIC_C\mereni\gmetr\gmetr.h" |
#include ".\gmetr.h" |
|
#define LCD_RS PIN_B1 // rizeni registru LCD displeje |
#define LCD_E PIN_B0 // enable LCD displeje |
9,9 → 9,10 |
|
void main() |
{ |
signed int16 stred; |
signed int16 hodnota; |
|
signed int16 stred; |
signed int8 hodnota; |
unsigned int8 i, offset; |
|
setup_adc_ports(ALL_ANALOG); |
setup_adc(ADC_CLOCK_DIV_2); |
setup_spi(FALSE); |
22,28 → 23,43 |
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); |
stred = read_adc(); |
|
|
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 = stred - read_adc(); |
Delay_ms(100); |
LCD_gotoxy(1,1); |
printf(lcd_putc," "); |
if (hodnota<0) |
hodnota = read_adc(); |
Delay_ms(50); |
LCD_clr(); |
LCD_gotoxy(6,1); |
printf(lcd_putc," %03ld ",(stred - hodnota)); |
if (hodnota >= stred) |
{ |
LCD_gotoxy(5,2); |
printf(lcd_putc," %03ld ",hodnota); |
LCD_gotoxy(8-hodnota,1); |
printf(lcd_putc,"*",hodnota); |
offset = hodnota - stred; |
offset = (offset >> 5) + 8; |
} |
else |
{ |
LCD_gotoxy(6,2); |
printf(lcd_putc," %03ld ",hodnota); |
LCD_gotoxy(8-hodnota,1); |
printf(lcd_putc,"*",hodnota); |
offset = stred - hodnota; |
offset = offset >> 5; |
} |
LCD_gotoxy(offset,2); |
printf(lcd_putc,"*"); |
} |
} |