Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
et:examples:sensor:demo [2010/11/09 15:57] 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> #include <homelab/module/segment_display.h>
 + 
 int main(void) int main(void)
 { {
- char t1[16],t2[16],t3[16];+ char t[16];
    
  lcd_alpha_init(LCD_ALPHA_DISP_ON);  lcd_alpha_init(LCD_ALPHA_DISP_ON);
  lcd_alpha_clear();  lcd_alpha_clear();
- lcd_alpha_write_string("Anduriplaadi demo");+ lcd_alpha_write_string("Andurite demo");
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
  segment_display_init();  segment_display_init();
-  +
- // Lõputu tsükkel+
  while (true)  while (true)
  {  {
- +  
- sprintf(t1, "%d\337C   ", thermistor_calculate_celsius(adc_get_average_value(2, 4))); +  
- sprintf(t2, "%d lx   ", adc_get_average_value(1, 4)); + 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)));
- sprintf(t3, "%d cm   ", ir_distance_calculate_cm(GP2Y0A21YK, adc_get_average_value(2, 4)); +
  lcd_alpha_goto_xy(0, 1);  lcd_alpha_goto_xy(0, 1);
- lcd_alpha_write_string(t1); + lcd_alpha_write_string(t); 
-  + 
- lcd_alpha_goto_xy(0, 5); +
- lcd_alpha_write_string(t2); +
- +
- lcd_alpha_goto_xy(0, 10); +
- lcd_alpha_write_string(t3); +
- +
  segment_display_write(adc_get_average_value(3, 4) * 10 / 1024);  segment_display_write(adc_get_average_value(3, 4) * 10 / 1024);
- +  sw_delay_ms(500);
  }  }
 } }
- 
 </code> </code>
et/examples/sensor/demo.1289318243.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