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:encoder [2015/02/26 13:10] raivo.sellet:examples:sensor:encoder [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-~~PB~~+<pagebreak>
 ====== Kooder ====== ====== Kooder ======
  
Line 44: Line 44:
 // Koodrite arv // Koodrite arv
 #define NUM_ENCODERS 2 #define NUM_ENCODERS 2
-// Koodri pulside arvu määramine sekundis+ 
 +// Koodri pulsside arvu määramine sekundis
 #define ENCODER_TICKS (F_CPU / 8 / 256) #define ENCODER_TICKS (F_CPU / 8 / 256)
  
Line 81: Line 82:
 void encoder_init(unsigned char index) void encoder_init(unsigned char index)
 { {
- // Viigud sisendistamine väljundiks+ // Viigu sisendiks seadistamine koos pull-up takistite lubamisega
  pin_setup_input_with_pullup(encoder_pins[index]);  pin_setup_input_with_pullup(encoder_pins[index]);
   
Line 104: Line 105:
 } }
  
-// Valitud kooderi nullimine+// Valitud koodri nullimine
 void encoder_reset_pulses(unsigned char index) void encoder_reset_pulses(unsigned char index)
 {  {
Line 112: Line 113:
 } }
  
-// Koodri pulside arvu loendamine+// Koodri pulsside arvu loendamine
 unsigned short encoder_get_pulses(unsigned char index) unsigned short encoder_get_pulses(unsigned char index)
 {  {
Line 136: Line 137:
  char text[16];  char text[16];
  
- // Nupu seadmistamine+ // Nupu seadistamine
  pin_setup_input_with_pullup(S2);  pin_setup_input_with_pullup(S2);
  
Line 153: Line 154:
      
  // Lõputu tsükkel   // Lõputu tsükkel
- while (true)+ while (1)
  {  {
  pulses = encoder_get_pulses(1);  pulses = encoder_get_pulses(1);
   
  // Teksti moodustamine.  // Teksti moodustamine.
- sprintf(text, "Pulsse: %d",pulses);+ sprintf(text, "Pulsse: %5d",pulses);
     
  lcd_gfx_goto_char_xy(0, 3);  lcd_gfx_goto_char_xy(0, 3);
  lcd_gfx_write_string(text);  lcd_gfx_write_string(text);
  
- // Nupp S2 alla vajutatud ?+ // Nupp S2 alla vajutatud?
  if(button_read(S2))  if(button_read(S2))
  {  {
et/examples/sensor/encoder.1424956211.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