summaryrefslogtreecommitdiffstats
path: root/Kod
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2019-11-15 15:22:20 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2019-11-17 21:36:29 +0100
commit28f73daf8ded62734f9cdbb9db3fcc20d4183cfc (patch)
treed3eb7546f2a830b74571e1d94006209b6e8c22fe /Kod
parentb19ae6983f87076b986577f5534bcd20e3053dcb (diff)
downloadtfyy51-28f73daf8ded62734f9cdbb9db3fcc20d4183cfc.tar.gz
Add test for drawing display graphs
Diffstat (limited to 'Kod')
-rw-r--r--Kod/bilbana/yc4/display/text.m2
-rw-r--r--Kod/scripts/display_graphs.m69
2 files changed, 70 insertions, 1 deletions
diff --git a/Kod/bilbana/yc4/display/text.m b/Kod/bilbana/yc4/display/text.m
index e31ecc3..b6589d2 100644
--- a/Kod/bilbana/yc4/display/text.m
+++ b/Kod/bilbana/yc4/display/text.m
@@ -1,6 +1,6 @@
function [pkg] = text(x, y, justification, text)
arg1 = [mod(x, 256), x ./ 256, mod(y, 256), y ./ 256];
-arg2 = text;
+arg2 = strrep(text, '\n', '|');
arg3 = 0;
pkg = get_package(strjoin({'Z', justification}, ''), [arg1 double(arg2) arg3]);
diff --git a/Kod/scripts/display_graphs.m b/Kod/scripts/display_graphs.m
new file mode 100644
index 0000000..e579422
--- /dev/null
+++ b/Kod/scripts/display_graphs.m
@@ -0,0 +1,69 @@
+addpath display/ClientServerApp/Release
+cd display/ClientServerApp/Release
+!startServer
+cd ../../..
+
+display = struct;
+display.data = [];
+display.out = 0;
+display.shm = 0;
+display.shm_interp = struct;
+display.shm_interp.ack = 0;
+display.shm_interp.start_code = '';
+display.shm_interp.data = [];
+display.last_send = tic;
+display.send_interval = 0.5;
+
+graphs = struct;
+graphs.car1 = struct;
+graphs.car2 = struct;
+graphs.car1.lap_times = []; % Nx1
+graphs.car1.lap_deviation = std(graphs.car1.lap_times)
+graphs.car1.seg_times = []; % 9xM
+graphs.car2.lap_times = []; % Nx1
+graphs.car2.lap_deviation = std(graphs.car2.lap_times)
+graphs.car2.seg_times = []; % 9xM
+graphs.laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times))
+
+disp('Drawing frame');
+input();
+matlabclient(1, get_smallpackage([ ...
+ draw_single_line(32, 32, 32, 192), ...
+ continue_line(298, 192), ...
+ draw_single_line(28, 40, 32, 32), ...
+ continue_line(36, 40), ...
+ draw_single_line(298, 188, 298, 196) ...
+]));
+pause(0.2);
+
+disp('Drawing additional frames');
+input();
+matlabclient(1, get_smallpackage([ ...
+ draw_single_line(220, 0, 220, 80), ...
+ continue_line(0, 80), ...
+ draw_single_line(0, 208, 320, 208) ...
+]));
+pause(0.2);
+
+disp('Putting text');
+input();
+matlabclient(1, get_smallpackage([
+ put_text(304, 20, 'R', 'std: 0.15s'), ...
+ put_text(304, 40, 'R', 'mean: 12.4s'), ...
+ put_text(304, 60, 'R', 'target: 12.5s') ...
+]));
+pause(0.2);
+
+disp('Drawing buttons');
+input();
+matlabclient(1, get_smallpackage([ ...
+ define_touch_key(0 , 208, 107, 240, 51, 61, 'C', 'Knapp 1'), ...
+ define_touch_key(107, 208, 213, 240, 52, 62, 'C', 'Knapp 2'), ...
+ define_touch_key(213, 208, 320, 240, 53, 63, 'C', 'Knapp 3') ...
+]))
+pause(0.2);
+
+disp('');
+input();
+matlabclient(1, get_smallpackage([]))
+pause(0.2);