Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Adafruit-PWM-Servo-Driver MPU6050 RS300 mbed
Revision 14:522bb06f0f0d, committed 2013-02-21
- Comitter:
- syundo0730
- Date:
- Thu Feb 21 14:27:19 2013 +0000
- Parent:
- 13:711f74b2fa33
- Child:
- 15:e37a8c413e51
- Commit message:
- suicide
Changed in this revision
--- a/Motion.cpp Sun Feb 03 21:22:21 2013 +0000
+++ b/Motion.cpp Thu Feb 21 14:27:19 2013 +0000
@@ -2,12 +2,14 @@
#include "PWM.h"
extern Ticker tick;
-//PWM pwm;
+DigitalOut led1(LED1);
Motion::Motion(uint16_t** data, unsigned short int size_idx, unsigned char size_num)
{
pwm = new PWM();
+ led1 = 1;
+
m_data = data;
m_IDX_MAX = size_idx;
@@ -34,6 +36,7 @@
Motion::~Motion()
{
delete pwm;
+ led1 = 0;
}
void Motion::step()
@@ -46,6 +49,7 @@
m_idx = 0;
m_play = 0;
tick.detach();
+ //delete this;
}
}
--- a/Motions.cpp Sun Feb 03 21:22:21 2013 +0000
+++ b/Motions.cpp Thu Feb 21 14:27:19 2013 +0000
@@ -85,18 +85,29 @@
if (!playing) {
//serial.printf("start motion! id = %d \r\n", id);
inter = new Motion(motions[id], pose_size[id], servo_size);
- tick.attach(inter, &Motion::step, 0.02);
+ tick.attach(inter, &Motion::step, TIMESTEP);
playing = true;
}
}
+/*void Motions::setmotion(const int id)
+{
+ //if (inter == NULL) {
+ //serial.printf("start motion! id = %d \r\n", id);
+ inter = new Motion(motions[id], pose_size[id], servo_size);
+ tick.attach(inter, &Motion::step, TIMESTEP);
+ playing = true;
+ //}
+}*/
+
void Motions::control()
{
play();
- int id = comu->getid();
+ //int id = comu->getid();
//serial.printf("id: %d \r\n", id);
- if (checkid(id)) { //<- Misterious bug. Why is id starts from 48?
- setmotion(id);
- }
+ //if (checkid(id)) { //<- Misterious bug. Why is id starts from 48?
+ //setmotion(id);
+ setmotion(0);
+ //}
}
\ No newline at end of file
--- a/Motions.h Sun Feb 03 21:22:21 2013 +0000
+++ b/Motions.h Thu Feb 21 14:27:19 2013 +0000
@@ -6,6 +6,8 @@
#include "SCI.h"
#include <string>
+const float TIMESTEP = 0.02;
+
class Motions
{
public:
--- a/SCI.cpp Sun Feb 03 21:22:21 2013 +0000
+++ b/SCI.cpp Thu Feb 21 14:27:19 2013 +0000
@@ -30,7 +30,7 @@
char SCI::getc_wait()
{
while (!serial->readable()) {
- //serial->printf("waiting..");
+ serial->printf("waiting..");
}
char val = serial->getc();
return val;
--- a/main.cpp Sun Feb 03 21:22:21 2013 +0000
+++ b/main.cpp Thu Feb 21 14:27:19 2013 +0000
@@ -5,35 +5,12 @@
uint16_t data[0x2000] __attribute__((section("AHBSRAM1"))); //motion data area
Ticker tick; //Ticker for main control roop
-
int main(void)
{
- /*unsigned short int size_x = 25; //max about 25kb
- unsigned short int size_y = 5;
-
- uint16_t **array = new uint16_t*[size_x];
- for (int i = 0; i < size_y; ++i) {
- array[i] = new uint16_t[size_x];
- }
- for (int i = 0; i < size_y; ++i) {
- for (int j = 0; j < size_x; ++j) {
- array[i][j] = 900 + 200*i;
- }
- }
- for (int i = 0; i < size_y; ++i) {
- array[i][size_x - 1] = 50;
- }
-
- Motion inter0(array, size_y, size_x);*/
-
Motions motions(data);
- //motions.setmotion(0);
-
+ //motions.control();
while (1) {
motions.control();
- //if (!inter0.is_in_interrupt()) {
- //tick.attach(&inter0, &Motion::step, 0.02);
- //}
wait(0.05);
}
}
\ No newline at end of file