14
14
15
15
char buffer [8 ];
16
16
17
-
18
- // ESOS_USER_TASK(demoLEDsAndSwitches) {
19
- // ESOS_TASK_BEGIN();
20
- // while(1){
21
- // esos_uiF14_flashLED3(500); //heartbeat always blinking
22
- // // RPG controls LED2
23
- // if (esos_uiF14_isRPGTurning()){
24
- // esos_uiF14_turnLED2Off();
25
- // }
26
- // if (esos_uiF14_isRPGTurningSlow()){
27
- // esos_uiF14_turnLED2On();
28
- // }
29
- // if (esos_uiF14_isRPGTurningMedium()){
30
- // esos_uiF14_flashLED2(500);
31
- // }
32
- // if (esos_uiF14_isRPGTurningFast()){
33
- // esos_uiF14_flashLED2(100);
34
- // }
35
- // //switch on RPG (SW3) controls whether SW1 or SW2 controls LED1
36
- // if (esos_uiF14_isSW3Released()){
37
- // if (esos_uiF14_isSW1Pressed()){
38
- // esos_uiF14_turnLED1On();
39
- // } else if (esos_uiF14_isSW1Released()){
40
- // esos_uiF14_turnLED1Off();
41
- // }
42
- // if (esos_uiF14_isSW1DoublePressed()){
43
- // int k;
44
- // for (k = 0; k<3; k++){
45
- // esos_uiF14_turnLED1On();
46
- // ESOS_TASK_WAIT_TICKS(150);
47
- // esos_uiF14_turnLED1Off();
48
- // ESOS_TASK_WAIT_TICKS(150);
49
- // }
50
- // }
51
- // }else if(esos_uiF14_isSW3Pressed()){
52
- // if (esos_uiF14_isSW2Pressed()){
53
- // esos_uiF14_turnLED1On();
54
- // } else if (esos_uiF14_isSW2Released()){
55
- // esos_uiF14_turnLED1Off();
56
- // }
57
- // if (esos_uiF14_isSW2DoublePressed()){
58
- // int m;
59
- // for (m = 0; m<3; m++){
60
- // esos_uiF14_turnLED1On();
61
- // ESOS_TASK_WAIT_TICKS(150);
62
- // esos_uiF14_turnLED1Off();
63
- // ESOS_TASK_WAIT_TICKS(150);
64
- // }
65
- // }
66
- // }
67
- // }
68
- // ESOS_TASK_END();
69
- // }
70
-
71
-
72
- /*ESOS_USER_TASK(drawDisplay) {
17
+ ESOS_USER_TASK (drawDisplay ) {
73
18
ESOS_TASK_BEGIN ();
74
- //initDataXfer();
75
- //format for below... var name from enum above, actual var name, T/F changeable, label
76
- //SPECIFY_VAR(u16_DOUBLE_PRESS_UPPER_MS_NDX, _st_esos_uiF14Data.u16_doublePressUpperMs, TRUE, "%u", "Upper double press time limit");
77
- //SPECIFY_VAR(u16_RPG_SLOW_MS_NDX, _st_esos_uiF14Data.u16_RPGNotMovingToSlowPeriodMs, TRUE, "%u", "Time in ms between RPG clicks -not moving to slow");
78
- //SPECIFY_VAR(u16_RPG_MEDIUM_MS_NDX, _st_esos_uiF14Data.u16_RPGSlowToMediumPeriodMs, TRUE, "%u", "Time in ms between RPG clicks -slow to medium");
79
- //SPECIFY_VAR(u16_RPG_FAST_MS_NDX, _st_esos_uiF14Data.u16_RPGMediumToFastPeriodMs, TRUE, "%u", "Time in ms between RPG clicks -medium to fast");
80
- //SPECIFY_VAR(u16_RPG_PERIOD_NDX, _st_esos_uiF14Data.u16_RPGPeriodMs, FALSE, "%u", "Time between clicks in ms");
81
- //SPECIFY_VAR(U16_RPG_VALUE_NDX, _st_esos_uiF14Data.i16_RPGCounter, FALSE, "%u", "Current RPG Counter");
82
19
while (1 ){
83
20
84
- memset(&buffer, 0, sizeof(buffer)); // clear out the input buffer
85
-
21
+ ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM ();
86
22
if (esos_uiF14_isSW1Pressed ()){ESOS_TASK_WAIT_ON_SEND_STRING ("\nSw1 is Pushed " );}
87
23
if (esos_uiF14_isSW1Released ()){ESOS_TASK_WAIT_ON_SEND_STRING ("Sw1 is Released" );}
88
24
if (esos_uiF14_isSW1DoublePressed ()){ESOS_TASK_WAIT_ON_SEND_STRING ("Sw1 is Double Pressed\n" );
89
- ESOS_TASK_WAIT_TICKS(300);
90
25
} else {ESOS_TASK_WAIT_ON_SEND_STRING ("Sw1 is NOT Double Pressed\n" );}
91
26
if (esos_uiF14_isSW2Pressed ()){ESOS_TASK_WAIT_ON_SEND_STRING ("Sw2 is Pushed " );}
92
27
if (esos_uiF14_isSW2Released ()){ESOS_TASK_WAIT_ON_SEND_STRING ("Sw2 is Released" );}
93
28
if (esos_uiF14_isSW2DoublePressed ()){ESOS_TASK_WAIT_ON_SEND_STRING ("Sw2 is Double Pressed\n" );
94
- ESOS_TASK_WAIT_TICKS(300);
95
29
} else {ESOS_TASK_WAIT_ON_SEND_STRING ("Sw2 is NOT Double Pressed\n" );}
96
30
if (esos_uiF14_isSW3Pressed ()){ESOS_TASK_WAIT_ON_SEND_STRING ("Sw3 is Pushed " );}
97
31
if (esos_uiF14_isSW3Released ()){ESOS_TASK_WAIT_ON_SEND_STRING ("Sw3 is Released" );}
98
32
if (esos_uiF14_isSW3DoublePressed ()){ESOS_TASK_WAIT_ON_SEND_STRING ("Sw3 is Double Pressed\n\n" );
99
- ESOS_TASK_WAIT_TICKS(300);
100
33
} else {ESOS_TASK_WAIT_ON_SEND_STRING ("Sw3 is NOT Double Pressed\n\n" );}
101
34
102
35
if (esos_uiF14_isRPGTurning ()) {
@@ -116,80 +49,75 @@ char buffer[8];
116
49
} else {
117
50
ESOS_TASK_WAIT_ON_SEND_STRING ("RPG is Not Turning" );
118
51
}
119
- ESOS_TASK_WAIT_TICKS(50);
120
- ESOS_TASK_WAIT_ON_SEND_STRING("\n\n\n\n\n\n\n\n"); //these newlines clear the screen and allow overwrite
121
- //!!! THE FOLLOWING SHOULD BE TREATED AS PSEUDOCODE UNTIL WE CAN PUT THIS ON A BOARD !!!
122
- ESOS_TASK_WAIT_ON_SEND_STRING( "+-------Configuration-------+\n\
123
- | 1). Double Press Speed |\n\
124
- | 2). RPG Speeds |\n\
125
- | |\n\
126
- +---------------------------+\n\
127
- \n\
128
- > "
129
- );
130
-
131
- ESOS_TASK_WAIT_ON_GET_STRING(&buffer);
132
-
52
+ ESOS_TASK_WAIT_ON_SEND_STRING ("\n\n\n\n\n\n" );
133
53
134
- // hoo baby this is a nasty switch case
135
- // BUFFER WILL PROBABLY NEED SOME PROCESSING HERE
136
- switch(buffer[0]) {
137
-
138
- case "1":
139
- ESOS_TASK_WAIT_ON_SEND_STRING("Enter threshold for double press detection (in ms)\n\
140
- > "
141
- );
142
- memset(&buffer, 0, sizeof(buffer));
143
- ESOS_TASK_WAIT_ON_GET_STRING(&buffer);
144
- // SET THRESHOLD (needs setter function)
54
+ ESOS_TASK_SIGNAL_AVAILABLE_OUT_COMM ();
55
+ ESOS_TASK_WAIT_TICKS (250 );
56
+ }
57
+ ESOS_TASK_END ();
58
+ }
145
59
146
- case "2":
147
- ESOS_TASK_WAIT_ON_SEND_STRING( "+----RPG Speed Thresholds---+\n\
148
- | 1). Slow |\n\
149
- | 2). Medium |\n\
150
- | 3). Fast |\n\
151
- +---------------------------+\n\
152
- \n\
153
- > "
154
- );
155
- memset(&buffer, 0, sizeof(buffer));
156
- ESOS_TASK_WAIT_ON_GET_STRING(&buffer);
60
+
61
+ ESOS_USER_TASK (demoLEDsAndSwitches ) {
62
+ ESOS_TASK_BEGIN ();
63
+ while (1 ){
64
+ esos_uiF14_flashLED3 (500 );
157
65
158
- // oh hell yeah nested switch case
159
- switch(buffer[0]) {
160
- case "1":
161
- ESOS_TASK_WAIT_ON_SEND_STRING("Enter threshold for turning the RPG slowly\n\
162
- > "
163
- );
164
- memset(&buffer, 0, sizeof(buffer));
165
- ESOS_TASK_WAIT_ON_GET_STRING(&buffer);
166
- // SET THRESHOLD (needs setter function)
167
- case "2":
168
- ESOS_TASK_WAIT_ON_SEND_STRING("Enter threshold for turning the RPG ...mediumly\n\
169
- > "
170
- );
171
- memset(&buffer, 0, sizeof(buffer));
172
- ESOS_TASK_WAIT_ON_GET_STRING(&buffer);
173
- // SET THRESHOLD (needs setter function)
174
- case "3":
175
- ESOS_TASK_WAIT_ON_SEND_STRING("Enter threshold for turning the RPG ...fastly\n\
176
- > "
177
- );
178
- memset(&buffer, 0, sizeof(buffer));
179
- ESOS_TASK_WAIT_ON_GET_STRING(&buffer);
180
- // SET THRESHOLD (needs setter function)
181
- }
66
+ // RPG controls LED2
67
+ if (esos_uiF14_isRPGTurning ()){
68
+ esos_uiF14_turnLED2Off ();
69
+ }
70
+ if (esos_uiF14_isRPGTurningSlow ()){
71
+ esos_uiF14_turnLED2On ();
72
+ }
73
+ if (esos_uiF14_isRPGTurningMedium ()){
74
+ esos_uiF14_flashLED2 (500 );
75
+ }
76
+ if (esos_uiF14_isRPGTurningFast ()){
77
+ esos_uiF14_flashLED2 (100 );
78
+ }
79
+ //switch on RPG (SW3) controls whether SW1 or SW2 controls LED1
80
+ if (esos_uiF14_isSW3Released ()){
81
+ if (esos_uiF14_isSW1Pressed ()){
82
+ esos_uiF14_turnLED1On ();
83
+ } else if (esos_uiF14_isSW1Released ()){
84
+ esos_uiF14_turnLED1Off ();
85
+ }
86
+ if (esos_uiF14_isSW1DoublePressed ()){
87
+ int k ;
88
+ for (k = 0 ; k < 3 ; k ++ ){
89
+ esos_uiF14_turnLED1On ();
90
+ ESOS_TASK_WAIT_TICKS (150 );
91
+ esos_uiF14_turnLED1Off ();
92
+ ESOS_TASK_WAIT_TICKS (150 );
93
+ }
94
+ }
95
+ }else if (esos_uiF14_isSW3Pressed ()){
96
+ if (esos_uiF14_isSW2Pressed ()){
97
+ esos_uiF14_turnLED1On ();
98
+ } else if (esos_uiF14_isSW2Released ()){
99
+ esos_uiF14_turnLED1Off ();
100
+ }
101
+ if (esos_uiF14_isSW2DoublePressed ()){
102
+ int m ;
103
+ for (m = 0 ; m < 3 ; m ++ ){
104
+ esos_uiF14_turnLED1On ();
105
+ ESOS_TASK_WAIT_TICKS (150 );
106
+ esos_uiF14_turnLED1Off ();
107
+ ESOS_TASK_WAIT_TICKS (150 );
108
+ }
182
109
}
183
110
}
111
+ ESOS_TASK_YIELD ();
112
+ }
184
113
ESOS_TASK_END ();
185
- }*/
114
+ }
115
+
186
116
187
117
ESOS_USER_TASK (menu ) {
188
118
ESOS_TASK_BEGIN ();
189
119
190
120
for (;;) {
191
- printf ("\n\nHere's the beginning\n" );
192
-
193
121
ledflashing :
194
122
195
123
ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM ();
@@ -226,8 +154,8 @@ ESOS_USER_TASK(menu) {
226
154
ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM ();
227
155
ESOS_TASK_WAIT_ON_SEND_STRING ("Pick switch double press limit \n" );
228
156
ESOS_TASK_WAIT_ON_SEND_STRING ("1 -> 250 ms \n" );
229
- ESOS_TASK_WAIT_ON_SEND_STRING ("2 -> 500 ms \n" );
230
- ESOS_TASK_WAIT_ON_SEND_STRING ("3 -> 1000 ms \n" );
157
+ ESOS_TASK_WAIT_ON_SEND_STRING ("2 -> 400 ms \n" );
158
+ ESOS_TASK_WAIT_ON_SEND_STRING ("3 -> 600 ms \n" );
231
159
ESOS_TASK_WAIT_ON_SEND_STRING ("9 -> Configure RPG \n" );
232
160
ESOS_TASK_WAIT_ON_SEND_STRING ("Choice: " );
233
161
ESOS_TASK_SIGNAL_AVAILABLE_OUT_COMM ();
@@ -242,12 +170,12 @@ ESOS_USER_TASK(menu) {
242
170
243
171
if (buffer [0 ] == '1' ) {
244
172
//We're not required to have functions which modify the
245
- //double press bound, so just set the value direcyly
173
+ //double press bound, so just set the value directly
246
174
esos_uiF14_setDoublePressPeriod (250 );
247
175
} else if (buffer [0 ] == '2' ) {
248
- esos_uiF14_setDoublePressPeriod (500 );
176
+ esos_uiF14_setDoublePressPeriod (400 );
249
177
} else if (buffer [0 ] == '3' ) {
250
- esos_uiF14_setDoublePressPeriod (1000 );
178
+ esos_uiF14_setDoublePressPeriod (600 );
251
179
} else if (buffer [0 ] == '9' ) {
252
180
goto switchconfig ;
253
181
}
@@ -263,9 +191,7 @@ ESOS_USER_TASK(menu) {
263
191
void user_init (void ){
264
192
config_esos_uiF14 ();
265
193
esos_RegisterTask (menu );
194
+ esos_RegisterTask (demoLEDsAndSwitches );
195
+ esos_RegisterTask (drawDisplay );
266
196
267
- esos_uiF14_flashLED3 (500 );
268
-
269
- // esos_RegisterTask(demoLEDsAndSwitches);
270
- //esos_RegisterTask(drawDisplay);
271
197
}
0 commit comments