Example of using threads to run different actions happening at the same time.
Fork of Fa2018-es200-1121-3321-thread-example-rockem by
Diff: main.cpp
- Revision:
- 3:68bba10e81aa
- Parent:
- 2:2710cfd7bc6a
- Child:
- 4:6ccbc7542ddc
--- a/main.cpp Sun Oct 14 21:58:10 2018 +0000
+++ b/main.cpp Sun Oct 14 22:00:35 2018 +0000
@@ -49,12 +49,11 @@
-
+/**
+ * Callback for executing a simple motor action. When sw1 is high,
+ * the motor turns forward, otherwise the motor turns off.
+ */
void m_callback(void){
- /**
- Callback for executing a simple motor action. When sw1 is high,
- the motor turns forward, otherwise the motor turns off.
- */
printf("m_thread running\n");
while(1) {
if (sw1.read()){
@@ -71,12 +70,11 @@
-
+/**
+ * Simple callback for servo motion. When sw2 is high, the servo steps right,
+ * otherwise it steps left. If it hits the ends it stays there.
+ */
void s1_callback(void){
- /**
- Simple callback for servo motion. When sw2 is high, the servo steps right,
- otherwise it steps left. If it hits the ends it stays there.
- */
printf("s1_thread running\n");
while(1){
if (sw2.read()){
