jar ming / Mbed 2 deprecated Gcodetest1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jarming
Date:
Wed May 14 10:34:11 2014 +0000
Commit message:
jhgjhgjkgkljgi

Changed in this revision

Gcode.cpp Show annotated file Show diff for this revision Revisions of this file
Gcode.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Gcode.cpp	Wed May 14 10:34:11 2014 +0000
@@ -0,0 +1,70 @@
+#include"Gcode.h"
+#include <string>
+using std::string;
+#include"mbed.h"
+Gcode::Gcode(const string& command, Serial* stream):command(command),m(0),g(0),stream(stream),add_nl(false)
+{
+    prepare_cached_values();
+    this->millimeters_of_travel = 0.0F;
+    this->accepted_by_module = false;
+}
+
+Gcode::Gcode(const Gcode& to_copy)
+{
+    
+    this->command.assign( to_copy.command );
+    this->millimeters_of_travel = to_copy.millimeters_of_travel;
+    this->has_m                 = to_copy.has_m;
+    this->has_g                 = to_copy.has_g;
+    this->m                     = to_copy.m;
+    this->g                     = to_copy.g;
+    this->add_nl                = to_copy.add_nl;
+    this->stream                = to_copy.stream;
+    this->accepted_by_module=false;
+    this->txt_after_ok.assign( to_copy.txt_after_ok );
+    
+}
+
+Gcode& Gcode::operator=(const Gcode& to_copy)
+{
+    if(this != &to_copy)
+    {
+        this->command.assign( to_copy.command );
+        this->millimeters_of_travel = to_copy.millimeters_of_travel;
+        this->has_m                 = to_copy.has_m;
+        this->has_g                 = to_copy.has_g;
+        this->m                     = to_copy.m;
+        this->g                     = to_copy.g;
+        this->add_nl                = to_copy.add_nl;
+        this->stream                = to_copy.stream;
+        this->txt_after_ok.assign( to_copy.txt_after_ok );
+    }    
+    this->accepted_by_module = false;
+    return *this;
+}
+
+
+
+bool Gcode::has_letter(char letter)
+{
+    for(std::string::iterator c = this->command.begin(); c != this->command.end(); c++)      //iterator  const_iterator not support  why?
+    {
+        if(*c == letter)
+        {
+            return true; 
+        }  
+    }
+    
+    return false;
+}
+
+// 
+float Gcode::get_float(char letter)
+{
+        
+    
+}
+void Gcode::prepare_cached_values(){
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Gcode.h	Wed May 14 10:34:11 2014 +0000
@@ -0,0 +1,41 @@
+
+
+
+#ifndef GCODE_H
+#define GCODE_H
+#include <string>
+using std::string;
+#include<stdlib.h>
+#include"mbed.h"
+
+// Object to represent a Gcode command
+class Gcode {
+    public:
+        Gcode(const string&, Serial*);
+        Gcode(const Gcode& to_copy);
+        
+        Gcode& operator= (const Gcode& to_copy);
+
+        bool   has_letter ( char letter );
+        float  get_float  ( char letter );
+ //       float  get_double ( char letter );
+        int    get_int    ( char letter );
+        int    get_num_args();
+        
+        void   prepare_cached_values();
+        void   mark_as_taken();
+        
+        string command;     
+           
+        bool has_m;
+        bool has_g;
+        unsigned int m;
+        unsigned int g;
+        Serial *stream;  
+            
+        bool add_nl;
+        string txt_after_ok;
+        bool accepted_by_module;
+        float millimeters_of_travel;
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 14 10:34:11 2014 +0000
@@ -0,0 +1,14 @@
+#include"mbed.h"
+#include"Gcode.h"
+Serial stream(USBTX, USBRX);
+DigitalOut myled(LED1);
+
+int main() {
+    while(1) {
+        stream.printf("hello world!\r\n");
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 14 10:34:11 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file