AES-2015 / Mbed 2 deprecated Nucleo_URobot

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
wanchp
Date:
Thu Nov 12 03:53:37 2015 +0000
Commit message:
example

Changed in this revision

PositionSetter.cpp Show annotated file Show diff for this revision Revisions of this file
PositionSetter.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/PositionSetter.cpp	Thu Nov 12 03:53:37 2015 +0000
@@ -0,0 +1,24 @@
+#include "PositionSetter.h"
+
+PositionSetter::PositionSetter() {
+    // when no arguments, set to default
+    // 3 axes (or motors )with 5 positions
+    NofAxes = 3;
+    NofPositions = 5;
+    // first allocate memory 
+    // for Position
+    Position =  (Degree **) malloc(sizeof(Degree *) * NofAxes);
+    for (int i = 0;  i < NofAxes; i++) { 
+        Position[i] = (Degree *) malloc(sizeof(Degree) * NofPositions);
+    }
+    // for Duration
+    Duration = (Time *) malloc(sizeof(Time) * NofPositions);
+    Write = (bool *) malloc (sizeof(bool) * NofPositions); 
+    for (int i = 0; i < NofPositions; i++) {
+        for (int j = 0; j < NofAxes; j++) {
+            Position[j][i] = (Degree) i*j;
+        } 
+        Duration[i] = (Time) i;
+        Write[i] = true;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PositionSetter.h	Thu Nov 12 03:53:37 2015 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+typedef  float Degree;
+typedef  float Time;
+struct Cartesian {float x, y,z;};
+
+class PositionSetter {
+    uint16_t NofAxes;
+    uint32_t NofPositions;
+    Degree **Position;
+    Time *Duration; 
+    bool *Write;
+    int cursor;
+public:
+    PositionSetter();
+    PositionSetter(Degree **);
+    Degree ReadCurrentPosition(uint16_t AxisNo);
+    Degree* ReadCurrentPosition(void);
+    Degree ReadNextPosition(uint16_t AxisNo);
+    Degree* ReadNextPosition(void);
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 12 03:53:37 2015 +0000
@@ -0,0 +1,24 @@
+#include "mbed.h"
+ 
+AnalogIn analog_value(A0);
+ 
+DigitalOut led(LED1);
+
+int main() {
+    float meas;
+    
+    printf("\nAnalogIn example\n");
+    
+    while(1) {
+        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
+        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
+        printf("measure = %.0f mV\n", meas);
+        if (meas > 2000) { // If the value is greater than 2V then switch the LED on
+          led = 1;
+        }
+        else {
+          led = 0;
+        }
+        wait(0.2); // 200 ms
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 12 03:53:37 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file