implemented displaying rotary counter (octal)
Stefan Schuermans

Stefan Schuermans commited on 2012-02-12 21:51:32
Showing 4 changed files, with 23 additions and 2 deletions.

... ...
@@ -22,6 +22,12 @@ void switches(void)
22 22
   lcd_chr(1, 8, switches_get_state(sw_center) ? 'C' : ' ');
23 23
   lcd_chr(1, 9, switches_get_state(sw_rot_a) ? 'a' : ' ');
24 24
   lcd_chr(1, 10, switches_get_state(sw_rot_b) ? 'b' : ' ');
25
+
26
+  unsigned int cnt = switches_get_rot_cnt();
27
+  lcd_chr(1, 12, '0' + (cnt >> 9 & 0x7));
28
+  lcd_chr(1, 13, '0' + (cnt >> 6 & 0x7));
29
+  lcd_chr(1, 14, '0' + (cnt >> 3 & 0x7));
30
+  lcd_chr(1, 15, '0' + (cnt & 0x7));
25 31
 }
26 32
 
27 33
 void delay(void)
... ...
@@ -13,3 +13,12 @@ int switches_get_state(t_switch sw)
13 13
   return switches_ptr[0] >> sw & 1;
14 14
 }
15 15
 
16
+/**
17
+ * @brief get rotation counter of rotary switch
18
+ * @return rotation counter
19
+ */
20
+unsigned int switches_get_rot_cnt(void)
21
+{
22
+  return switches_ptr[1];
23
+}
24
+
... ...
@@ -23,5 +23,11 @@ typedef enum e_switch {
23 23
  */
24 24
 int switches_get_state(t_switch sw);
25 25
 
26
+/**
27
+ * @brief get rotation counter of rotary switch
28
+ * @return rotation counter
29
+ */
30
+unsigned int switches_get_rot_cnt(void);
31
+
26 32
 #endif /* #ifndef SWITCHES_H */
27 33
 
... ...
@@ -28,7 +28,7 @@ BEGIN
28 28
         -- de-gray-code rotary inputs
29 29
         IF pin_i_switches.rot_b = '1' THEN
30 30
             IF pin_i_switches.rot_a = '1' THEN
31
-                n_sample <= "10";
31
+                n_sample <= "00";
32 32
             ELSE
33 33
                 n_sample <= "11";
34 34
             END IF;
... ...
@@ -36,7 +36,7 @@ BEGIN
36 36
             IF pin_i_switches.rot_a = '1' THEN
37 37
                 n_sample <= "01";
38 38
             ELSE
39
-                n_sample <= "00";
39
+                n_sample <= "10";
40 40
             END IF;
41 41
         END IF;
42 42
     END PROCESS p_sample;
43 43