This shows you the differences between two versions of the page.
| et:examples:sensor:thermistor:lcd_gfx [2010/11/02 23:33] – tekitatud raivo.sell | et:examples:sensor:thermistor:lcd_gfx [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | // | ||
| + | // Põhiprogramm | ||
| + | // | ||
| + | int main(void) | ||
| + | { | ||
| + | unsigned short value; | ||
| + | signed short temperature; | ||
| + | char text[16]; | ||
| + | |||
| + | // LCD ekraani seadistamine | ||
| + | lcd_gfx_init(); | ||
| + | lcd_gfx_clear(); | ||
| + | |||
| + | // Taustavalgustuse tööle lülitamine | ||
| + | lcd_gfx_backlight(true); | ||
| + | |||
| + | // Programmi nime kuvamine | ||
| + | lcd_gfx_goto_char_xy(1, | ||
| + | lcd_gfx_write_string(" | ||
| + | |||
| + | | ||
| + | // ADC muunduri seadistamine | ||
| + | adc_init(ADC_REF_AVCC, | ||
| + | |||
| + | // Lõputu tsükkel | ||
| + | while (true) | ||
| + | { | ||
| + | // Termistori pinge 4-kordselt ümardatud väärtuse lugemine | ||
| + | value = adc_get_average_value(1, | ||
| + | |||
| + | // ADC väärtuse kraadideks ümberarvutamine | ||
| + | temperature = thermistor_calculate_celsius(value); | ||
| + | |||
| + | // Temperatuuri tekstiks teisendamine | ||
| + | // Kraadi märgi kuvamiseks on oktaalarv 337 | ||
| + | sprintf(text, | ||
| + | |||
| + | // Teksti kuvamine LCD teise rea alguses | ||
| + | lcd_gfx_goto_char_xy(1, | ||
| + | | ||
| + | |||
| + | } | ||
| + | } | ||
| + | </ | ||