From 8155f8e8e6e565c67aacee6aed05127ab02b6b24 Mon Sep 17 00:00:00 2001
From: jp7g21 <jp7g21@soton.ac.uk>
Date: Sun, 14 Nov 2021 06:57:44 +0000
Subject: [PATCH] Added text command

---
 duck/duck.c       | 4 ++++
 libduck/libduck.c | 5 +++++
 libduck/libduck.h | 1 +
 3 files changed, 10 insertions(+)

diff --git a/duck/duck.c b/duck/duck.c
index c72638c..280eb9e 100644
--- a/duck/duck.c
+++ b/duck/duck.c
@@ -91,6 +91,10 @@ int main(int argc, char **argv)
 		    shake(MOTOR_2, numnods, -90, 0, 250);
 		    i++;
 	       }
+	  } else if (strcmp(argv[i], "print") == 0) {
+	       if (argv[i+1]) {
+		    duck_write_text(argv[i+1]);
+	       }
 	  }
      }
      if (read_mode) {
diff --git a/libduck/libduck.c b/libduck/libduck.c
index cb4e3ec..54c9caa 100644
--- a/libduck/libduck.c
+++ b/libduck/libduck.c
@@ -88,6 +88,11 @@ int duck_set_velocity(int motor, int deg_per_sec, int ms)
      return duck_printf("v %d %d %d\n", motor, deg_per_sec, ms);
 }
 
+int duck_write_text(const char *str)
+{
+     return duck_printf("t %s\n", str);
+}
+
 void read_duck_to_stdout(void)
 {
      while (1) {
diff --git a/libduck/libduck.h b/libduck/libduck.h
index 68e17cb..9ce0166 100644
--- a/libduck/libduck.h
+++ b/libduck/libduck.h
@@ -16,6 +16,7 @@ void configure_duck(void);
 int duck_set_position(int motor, int angle);
 int duck_delay(int ms);
 int duck_set_velocity(int motor, int deg_per_sec, int ms);
+int duck_write_text(const char *str);
 void read_duck_to_stdout(void);
 void close_duck(void);
 
-- 
GitLab