first publish

Dependents:   CleaningMachine_Betago CleaningMachine_Betago clean_V1 CleaningM-Palm ... more

Files at this revision

API Documentation at this revision

Comitter:
icyzkungz
Date:
Mon Feb 15 17:45:25 2016 +0000
Commit message:
first publish

Changed in this revision

Debug.cpp Show annotated file Show diff for this revision Revisions of this file
Debug.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 26532a4397da Debug.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Debug.cpp	Mon Feb 15 17:45:25 2016 +0000
@@ -0,0 +1,119 @@
+#include "Debug.h"
+
+
+Debug::Debug(PinName tx, PinName rx) : debug(tx, rx)
+{
+    debug.baud(115200);
+    scan_input_data = 9999;
+    change = false;
+    first_time = true;
+
+    debug.printf("****************\n*  Debug Mode  *\n****************\n");
+}
+
+int Debug::ScanInputData(int save)
+{
+    float temp;
+    debug.scanf("%f",&temp);
+    if(save==1) {
+        scan_input_data = temp;
+        return scan_input_data;
+    } else if(save==0) return temp;
+}
+
+int Debug::ScanInputDataInLoop()
+{
+    float temp;
+    debug.scanf("%f",&temp);
+    scan_input_data_loop = temp;
+    return scan_input_data_loop;
+}
+
+void Debug::PrintListMode()
+{
+    debug.printf("\n\n1) \n");
+    debug.printf("2) \n");
+    debug.printf("3) \n");
+}
+
+/*int Debug::Mode()
+{
+    //return 0 for 1-time
+    //return 1 for more than 1-time loop
+
+    int temp;
+    int num = (int)scan_input_data;
+
+    switch((int)scan_input_data) {
+        case 1 :
+            debug.printf("Case 1 : Return 0 \n");
+            return 0;
+
+        case 2 :
+            debug.printf("Case 2 : Loop of Loop \n");
+
+            return 1;
+
+        case 3 :
+            debug.printf("Case 3 : \n");
+            return 0;
+
+        default :
+            debug.printf("Invalid Input\n");
+            return 0;
+    }
+
+}*/
+
+/*int Debug::SelectMode(int option)
+{
+    if(option == 1) {
+        do {
+            temp = Mode1();
+            PrintAll(temp);
+        } while(temp!=9999);
+    }
+
+    else if(option == 2) {
+        do {
+            if(first_time==false) {
+                temp = Mode2();
+                PrintAll(temp);
+            } else {
+                temp = Mode2();
+                if(temp!=0) first_time = false;
+            }
+
+            if(temp==9999) first_time = true;
+        } while(temp!=9999);
+    }
+    setChange();
+}*/
+
+int Debug::Mode1()
+{
+    debug.printf("Mode 1 : Input data\n");
+    return ScanInputData(1);
+}
+
+int Debug::Mode2()
+{
+    if(change == false) {
+        debug.printf("Mode 2 : \n1) Left \n2) Right\n");
+        temp_state = ScanInputData(0);
+        if(temp_state==1||temp_state==2)
+            change = true;
+        else return 0;
+    } else {
+        if(temp_state == 1) {
+            debug.printf("Input Left : ");
+            return ScanInputData(1);
+
+        } else if(temp_state == 2) {
+            debug.printf("Input Right : ");
+            return ScanInputData(1);
+        }
+    }
+
+
+}
diff -r 000000000000 -r 26532a4397da Debug.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Debug.h	Mon Feb 15 17:45:25 2016 +0000
@@ -0,0 +1,52 @@
+#ifndef DEBUG_H
+#define DEBUG_H
+#include "mbed.h"
+#include "pinconfig.h"
+
+class Debug
+{
+private:
+    Serial debug;
+    float scan_input_data;
+    float scan_input_data_loop;
+    bool change;
+    int temp_state;
+    bool first_time;
+
+    //bool mode[40]; //Dont forget to change elements : 'false' = do nothing in loop, 'true' = do something in loop
+    //int temp_mode_data[40];
+
+public:
+    Debug(PinName, PinName);
+    int ScanInputData(int);        //return int in case of want to check what the input data is
+    int ScanInputDataInLoop();  //return int in case of want to check what the input data is
+    int Mode();
+
+    //Mode
+    int SelectMode(int);
+    int Mode1();
+    int Mode2();
+
+    //Print
+    void PrintListMode();
+    void PrintExit() {
+        debug.printf("Exit From Debug Mode\n\n");
+    }
+    void PrintAll(float num) {
+        debug.printf("Data is %f\n",num);
+    }
+
+
+    //set
+    void setChange() {
+        change=false;
+    }
+
+
+    //get
+    float getScanInputData() {
+        return scan_input_data;
+    }
+};
+
+#endif
\ No newline at end of file