Differences

This shows you the differences between two versions of the page.

Link to this comparison view

et:examples:sensor:thermistor:lcd_gfx [2010/11/02 23:33] – tekitatud raivo.sellet:examples:sensor:thermistor:lcd_gfx [2020/07/20 12:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +<code c>
  
 +#include <stdio.h>
 +#include <homelab/adc.h>
 +#include <homelab/module/sensors.h>
 +#include <homelab/module/lcd_gfx.h>
 + 
 +//
 +// 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, 1);
 +    lcd_gfx_write_string("Termomeeter");
 +
 +  
 +    // ADC muunduri seadistamine
 +    adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
 + 
 +    // Lõputu tsükkel
 +    while (true)
 +    {
 +        // Termistori pinge 4-kordselt ümardatud väärtuse lugemine
 +        value = adc_get_average_value(1, 4);
 + 
 +        // ADC väärtuse kraadideks ümberarvutamine
 +        temperature = thermistor_calculate_celsius(value);
 + 
 +        // Temperatuuri tekstiks teisendamine
 +        // Kraadi märgi kuvamiseks on oktaalarv 337
 +        sprintf(text, "%d\50 C   ", temperature);
 + 
 +        // Teksti kuvamine LCD teise rea alguses
 +        lcd_gfx_goto_char_xy(1, 2);
 +       lcd_gfx_write_string(text);
 +
 +    }
 +}
 +</code>
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0