Differences

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

Link to this comparison view

Next revision
Previous revision
et:examples:sensor:demo [2010/11/09 15:22] – tekitatud raivo.sellet:examples:sensor:demo [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
 <code c> <code c>
-// 
 #include <stdio.h> #include <stdio.h>
 +#include <homelab/delay.h>
 #include <homelab/adc.h> #include <homelab/adc.h>
 #include <homelab/module/sensors.h> #include <homelab/module/sensors.h>
 #include <homelab/module/lcd_alpha.h> #include <homelab/module/lcd_alpha.h>
 +#include <homelab/module/segment_display.h>
    
-// 
-// Põhiprogramm 
-// 
 int main(void) int main(void)
 { {
- unsigned short value; + char t[16];
- signed short temperature;  +
- char text[16];+
    
- // LCD ekraani seadistamine 
  lcd_alpha_init(LCD_ALPHA_DISP_ON);  lcd_alpha_init(LCD_ALPHA_DISP_ON);
-  
- // LCD ekraani puhastamine 
  lcd_alpha_clear();  lcd_alpha_clear();
-  + lcd_alpha_write_string("Andurite demo");
- // Programmi nimi +
- lcd_alpha_write_string("Termomeeter"); +
-  +
- // ADC muunduri seadistamine+
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
-  + segment_display_init(); 
- // Lõputu tsükkel+
  while (true)  while (true)
  {  {
- value = adc_get_average_value(2, 4); 
- sprintf(text, "%d\337C   ", thermistor_calculate_celsius(value)); 
    
- // Teksti kuvamine LCD teise rea alguses+  
 + sprintf(t, "%d\337C %dlx %dcm", thermistor_calculate_celsius(adc_get_average_value(2, 4)),adc_get_average_value(1, 4), ir_distance_calculate_cm(GP2Y0A21YK, adc_get_average_value(0, 4)));
  lcd_alpha_goto_xy(0, 1);  lcd_alpha_goto_xy(0, 1);
- lcd_alpha_write_string(text); + lcd_alpha_write_string(t); 
 +  
 + segment_display_write(adc_get_average_value(3, 4) * 10 / 1024); 
 +  sw_delay_ms(500);
  }  }
 } }
 </code> </code>
et/examples/sensor/demo.1289316172.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
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