Workshop 1

Dependencies:   PM2_Libary

Revision:
8:49f2b6a515ac
Parent:
7:dc463bf54be6
Child:
9:c5e1e1facb02
diff -r dc463bf54be6 -r 49f2b6a515ac main.cpp
--- a/main.cpp	Sat Mar 13 16:51:00 2021 +0100
+++ b/main.cpp	Sat Mar 13 16:53:22 2021 +0100
@@ -1,12 +1,10 @@
 #include "mbed.h"
 #include "platform/mbed_thread.h"
-#include "string"
 
 using namespace std::chrono;
 
 InterruptIn    user_button(USER_BUTTON);
 DigitalOut     led(LED1);
-BufferedSerial pc(USBTX, USBRX);
 
 bool           executeMainTask = false;
 Timer          user_button_timer, loop_timer;
@@ -18,9 +16,6 @@
 AnalogIn       analogIn(PA_0);
 float          dist = 0.0f;
 
-float          floatNumber = 0.003713f;
-int            integerNumber = 777;
-
 int main()
 {
     user_button.fall(&button_fall);
@@ -37,17 +32,7 @@
 
             dist = analogIn.read()*3.3f;
             
-            // printf("Measval: %d\r\n", (static_cast<int>(dist * 1000)));
-
-            string msg_str = to_string((static_cast<int>(dist * 1e6)));
-            msg_str.append(";");
-            msg_str.append(to_string((static_cast<int>(floatNumber * 1e6))));
-            msg_str.append(";");
-            msg_str.append(to_string(integerNumber));
-            msg_str.append(";\r\n");
-            char msg[msg_str.length() + 1];
-            strcpy(msg, msg_str.c_str());
-            pc.write(msg, sizeof(msg));
+            printf("Measval: %d\r\n", (static_cast<int>(dist * 1000)));
 
             /* visual feedback that the main task is executed */
             led = !led;