summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
Diffstat (limited to 'digital')
-rw-r--r--digital/io/src/path.c13
-rw-r--r--digital/io/src/simu.host.c14
-rw-r--r--digital/io/src/simu.host.h4
-rw-r--r--digital/io/src/test_path.c5
4 files changed, 36 insertions, 0 deletions
diff --git a/digital/io/src/path.c b/digital/io/src/path.c
index 959f299e..50724f59 100644
--- a/digital/io/src/path.c
+++ b/digital/io/src/path.c
@@ -26,9 +26,11 @@
#include "path.h"
#include "playground.h"
+#include "simu.host.h"
#include "modules/math/fixed/fixed.h"
#include "modules/utils/utils.h"
+#include "modules/host/mex.h"
/** Number of possible obstacles. */
#define PATH_OBSTACLES_NB 2
@@ -288,6 +290,17 @@ path_update (void)
path_compute_points ();
path_compute_arcs ();
path_dijkstra ();
+#if defined (HOST)
+ uint8_t len, i;
+ uint16_t points[PATH_POINTS_NB * 2];
+ len = 0;
+ for (i = 1; i != 0xff; i = path.points[i].next)
+ {
+ points[len++] = path.points[i].x;
+ points[len++] = path.points[i].y;
+ }
+ simu_send_path (len, points);
+#endif
}
/** Retrieve first path point coordinates. Return 0 on failure. */
diff --git a/digital/io/src/simu.host.c b/digital/io/src/simu.host.c
index 03eed76a..7a497bff 100644
--- a/digital/io/src/simu.host.c
+++ b/digital/io/src/simu.host.c
@@ -39,6 +39,7 @@ enum
MSG_SIMU_IO_COLOR = 0xb1,
MSG_SIMU_IO_SERVO = 0xb2,
MSG_SIMU_IO_SHARPS = 0xb3,
+ MSG_SIMU_IO_PATH = 0xb4,
};
/** Requested servo position. */
@@ -194,3 +195,16 @@ void
eeprom_clear_param (void)
{
}
+
+/** Send computed path. */
+void
+simu_send_path (uint8_t len, uint16_t *points)
+{
+ int i;
+ mex_msg_t *m;
+ m = mex_msg_new (MSG_SIMU_IO_PATH);
+ for (i = 0; i < len; i++)
+ mex_msg_push (m, "h", points[i]);
+ mex_node_send (m);
+}
+
diff --git a/digital/io/src/simu.host.h b/digital/io/src/simu.host.h
index efd3bb2a..91203fce 100644
--- a/digital/io/src/simu.host.h
+++ b/digital/io/src/simu.host.h
@@ -51,6 +51,10 @@ switch_get_color (void);
uint8_t
switch_get_jack (void);
+/** Send computed path. */
+void
+simu_send_path (uint8_t len, uint16_t *points);
+
#endif /* defined (HOST) */
#endif /* simu_host_h */
diff --git a/digital/io/src/test_path.c b/digital/io/src/test_path.c
index 0ec2beb6..3d25e0b7 100644
--- a/digital/io/src/test_path.c
+++ b/digital/io/src/test_path.c
@@ -47,3 +47,8 @@ main (void)
return 0;
}
+void
+simu_send_path (uint8_t len, uint16_t *points)
+{
+}
+