From 3f20ff26d0c0082d5fe5a90474545eb440c7ddfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Wed, 20 Nov 2019 18:12:39 +0100 Subject: Add scenes for lap_graph and segment_bars --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 54 ++++++++++++++++++++++ Kod/bilbana/yc4/display/scenes/draw_segment_bars.m | 54 ++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 Kod/bilbana/yc4/display/scenes/draw_lap_graph.m create mode 100644 Kod/bilbana/yc4/display/scenes/draw_segment_bars.m (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m new file mode 100644 index 0000000..7d9e341 --- /dev/null +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -0,0 +1,54 @@ +function [] = draw_lap_graph(car1_laptimes, car2_laptimes, ref_time) +if isempty(car1_laptimes) + car1_laptimes = car2_laptimes; + car2_laptimes = []; +end + +laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); + +pause(0.2); +matlabclient(1, get_smallpackage(clear_display())); +pause(0.2); + +matlabclient(1, get_smallpackage(put_text(105, 8, 'C', 'Varvtider'))) +pause(0.2); + +matlabclient(1, get_smallpackage([ ... + key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... + key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... + key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ... +])); +pause(0.2); + +matlabclient(1, get_smallpackage([ ... + draw_line(20, 24, 20, 200), ... % y-axis + continue_line(304, 200), ... % x-axis + draw_line(16, 32, 20, 24), ... % arrow on y, left part + continue_line(24, 32), ... % arrow on y, right part + draw_line(304, 196, 304, 204) ... % line on x +])); +pause(0.2); + +matlabclient(1, get_smallpackage([ ... + draw_line(190, 0, 190, 70), ... + continue_line(320, 70) ... +])); +pause(0.2); + +matlabclient(1, get_smallpackage(save_display_to_clipboard())); + +%% +matlabclient(1, get_smallpackage(draw_line(20, 103, 320, 103))); +matlabclient(1, get_smallpackage(draw_line(20, 135, 320, 135))); +matlabclient(1, get_smallpackage(draw_line(20, 167, 320, 167))); + +matlabclient(1, ) + +%% +matlabclient(1, get_smallpackage([ + put_text(304, 10, 'R', 'std: x.xxs'), ... + put_text(304, 30, 'R', 'mean: xx.xs'), ... + put_text(304, 50, 'R', 'target: xx.xs') ... +])); +pause(0.2); +end diff --git a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m new file mode 100644 index 0000000..fe750a7 --- /dev/null +++ b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m @@ -0,0 +1,54 @@ +function [] = draw_segment_bars(values1, values2) +pause(0.2); +matlabclient(1, get_smallpackage(clear_display())); +pause(0.2); + +matlabclient(1, get_smallpackage(put_text(160, 8, 'C', 'Genomsnittlig tid per segment'))) +pause(0.2); + +% input(''); +matlabclient(1, get_smallpackage([ ... + key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... + key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... + key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ... +])); +pause(0.2); + +matlabclient(1, get_smallpackage([ ... + draw_line(20, 24, 20, 200), ... % y-axis + continue_line(304, 200), ... % x-axis + draw_line(16, 32, 20, 24), ... % arrow on y, left part + continue_line(24, 32), ... % arrow on y, right part + draw_line(304, 196, 304, 204) ... % line on x +])); +pause(0.2); + +[bars, max_val, min_y, max_height] = get_bars_from_values(values1, values2); + +for bar = bars + matlabclient(1, get_smallpackage(fill_area(bar.x_lo, bar.y_lo, bar.x_hi, bar.y_hi))); + pause(0.2); +end + +for i = 0:8 + x = 16+13 + 10 + 30*i; + matlabclient(1, get_smallpackage(put_text(x, 204, 'C', num2str(i + 1)))); + pause(0.2); +end + +matlabclient(1, get_smallpackage(put_text(9, 25, 'C', 's'))); +pause(0.2); + +% matlabclient(1, get_smallpackage(set_line_pattern(2))) +% pause(0.2); +for i = 1:floor(max_val) + x = 20; + y = min_y - round(max_height * (i/max_val)); + matlabclient(1, get_smallpackage([draw_line(x, y, 320, y), ... + put_text(x-6, y-2, 'C', num2str(i))])); + pause(0.2); +end +% matlabclient(1, get_smallpackage(set_line_pattern(1))) +% pause(0.2); +end + -- cgit v1.2.1 From 4f252cf07c3b5482d78e595aa6cbca33d9e713ab Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 22 Nov 2019 10:27:47 +0100 Subject: Make working --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index 7d9e341..67f2d75 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -4,7 +4,7 @@ if isempty(car1_laptimes) car2_laptimes = []; end -laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); +% laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); pause(0.2); matlabclient(1, get_smallpackage(clear_display())); @@ -41,8 +41,7 @@ matlabclient(1, get_smallpackage(save_display_to_clipboard())); matlabclient(1, get_smallpackage(draw_line(20, 103, 320, 103))); matlabclient(1, get_smallpackage(draw_line(20, 135, 320, 135))); matlabclient(1, get_smallpackage(draw_line(20, 167, 320, 167))); - -matlabclient(1, ) +pause(0.2); %% matlabclient(1, get_smallpackage([ -- cgit v1.2.1 From 81beac81fff0c32924f359e0da84990242dfc678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 22 Nov 2019 12:52:56 +0100 Subject: Add work done on lap-graph (and fixes on bar-graph) --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 55 ++++++++++++++-------- Kod/bilbana/yc4/display/scenes/draw_segment_bars.m | 8 +--- 2 files changed, 37 insertions(+), 26 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index 67f2d75..3c33ffb 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -10,7 +10,7 @@ pause(0.2); matlabclient(1, get_smallpackage(clear_display())); pause(0.2); -matlabclient(1, get_smallpackage(put_text(105, 8, 'C', 'Varvtider'))) +matlabclient(1, get_smallpackage(put_text(160, 8, 'C', 'Varvtider'))) pause(0.2); matlabclient(1, get_smallpackage([ ... @@ -21,33 +21,50 @@ matlabclient(1, get_smallpackage([ ... pause(0.2); matlabclient(1, get_smallpackage([ ... - draw_line(20, 24, 20, 200), ... % y-axis - continue_line(304, 200), ... % x-axis + draw_line(20, 24, 20, 144), ... % y-axis + put_text(9, 25, 'C', 's'), ... % label y-axis + continue_line(304, 144), ... % x-axis draw_line(16, 32, 20, 24), ... % arrow on y, left part continue_line(24, 32), ... % arrow on y, right part - draw_line(304, 196, 304, 204) ... % line on x + draw_line(304, 140, 304, 148) ... % line on x ])); pause(0.2); +y = 166; +margin_top = 6; matlabclient(1, get_smallpackage([ ... - draw_line(190, 0, 190, 70), ... - continue_line(320, 70) ... + draw_line(0, y, 320, y), ... + put_text(53 , y + margin_top, 'C', 'target'), ... + put_text(160, y + margin_top, 'C', 'mean'), ... + put_text(266, y + margin_top, 'C', 'std') ... ])); pause(0.2); -matlabclient(1, get_smallpackage(save_display_to_clipboard())); - -%% -matlabclient(1, get_smallpackage(draw_line(20, 103, 320, 103))); -matlabclient(1, get_smallpackage(draw_line(20, 135, 320, 135))); -matlabclient(1, get_smallpackage(draw_line(20, 167, 320, 167))); -pause(0.2); - -%% -matlabclient(1, get_smallpackage([ - put_text(304, 10, 'R', 'std: x.xxs'), ... - put_text(304, 30, 'R', 'mean: xx.xs'), ... - put_text(304, 50, 'R', 'target: xx.xs') ... +line = 12; +matlabclient(1, get_smallpackage([ ... + put_text(6 , y + 3 + margin_top + line*1, 'L', '1'), ... + put_text(6 , y + 3 + margin_top + line*2, 'L', '2'), ... + put_text(53 , y + 2 + margin_top + line*1, 'C', 'xx.x'), ... + put_text(53 , y + 2 + margin_top + line*2, 'C', 'xx.x'), ... + put_text(160, y + 2 + margin_top + line*1, 'C', 'xx.x'), ... + put_text(160, y + 2 + margin_top + line*2, 'C', 'xx.x'), ... + put_text(266, y + 2 + margin_top + line*1, 'C', 'x.xx'), ... + put_text(266, y + 2 + margin_top + line*2, 'C', 'x.xx'), ... ])); pause(0.2); + +times = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]; +for i = 0:(length(times)-1) + x = 28 + i*10; + y = 144 - round(100 * (times(i+1) / max(times))); + matlabclient(1, get_smallpackage([ ... + set_point_size(3, 3), ... + point(x, y), ... + set_point_size(1, 1), ... + draw_line(x, 144-2, x, 144+2) ... + ])); + pause(0.15); +end + +% matlabclient(1, get_smallpackage(save_display_to_clipboard())); end diff --git a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m index fe750a7..d778323 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m +++ b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m @@ -16,6 +16,7 @@ pause(0.2); matlabclient(1, get_smallpackage([ ... draw_line(20, 24, 20, 200), ... % y-axis + put_text(9, 25, 'C', 's'), ... % label y-axis continue_line(304, 200), ... % x-axis draw_line(16, 32, 20, 24), ... % arrow on y, left part continue_line(24, 32), ... % arrow on y, right part @@ -36,11 +37,6 @@ for i = 0:8 pause(0.2); end -matlabclient(1, get_smallpackage(put_text(9, 25, 'C', 's'))); -pause(0.2); - -% matlabclient(1, get_smallpackage(set_line_pattern(2))) -% pause(0.2); for i = 1:floor(max_val) x = 20; y = min_y - round(max_height * (i/max_val)); @@ -48,7 +44,5 @@ for i = 1:floor(max_val) put_text(x-6, y-2, 'C', num2str(i))])); pause(0.2); end -% matlabclient(1, get_smallpackage(set_line_pattern(1))) -% pause(0.2); end -- cgit v1.2.1 From fd263fa24277daa3dc6ffb163edc9879c3e62e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 23 Nov 2019 21:41:15 +0100 Subject: fix indents --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 64 ++++++++++++------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index 3c33ffb..139b18f 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -1,7 +1,7 @@ function [] = draw_lap_graph(car1_laptimes, car2_laptimes, ref_time) if isempty(car1_laptimes) - car1_laptimes = car2_laptimes; - car2_laptimes = []; + car1_laptimes = car2_laptimes; + car2_laptimes = []; end % laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); @@ -14,56 +14,56 @@ matlabclient(1, get_smallpackage(put_text(160, 8, 'C', 'Varvtider'))) pause(0.2); matlabclient(1, get_smallpackage([ ... - key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... - key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... - key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ... + key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... + key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... + key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ... ])); pause(0.2); matlabclient(1, get_smallpackage([ ... - draw_line(20, 24, 20, 144), ... % y-axis - put_text(9, 25, 'C', 's'), ... % label y-axis - continue_line(304, 144), ... % x-axis - draw_line(16, 32, 20, 24), ... % arrow on y, left part - continue_line(24, 32), ... % arrow on y, right part - draw_line(304, 140, 304, 148) ... % line on x + draw_line(20, 24, 20, 144), ... % y-axis + put_text(9, 25, 'C', 's'), ... % label y-axis + continue_line(304, 144), ... % x-axis + draw_line(16, 32, 20, 24), ... % arrow on y, left part + continue_line(24, 32), ... % arrow on y, right part + draw_line(304, 140, 304, 148) ... % line on x ])); pause(0.2); y = 166; margin_top = 6; matlabclient(1, get_smallpackage([ ... - draw_line(0, y, 320, y), ... - put_text(53 , y + margin_top, 'C', 'target'), ... - put_text(160, y + margin_top, 'C', 'mean'), ... - put_text(266, y + margin_top, 'C', 'std') ... + draw_line(0, y, 320, y), ... + put_text(53 , y + margin_top, 'C', 'target'), ... + put_text(160, y + margin_top, 'C', 'mean'), ... + put_text(266, y + margin_top, 'C', 'std') ... ])); pause(0.2); line = 12; matlabclient(1, get_smallpackage([ ... - put_text(6 , y + 3 + margin_top + line*1, 'L', '1'), ... - put_text(6 , y + 3 + margin_top + line*2, 'L', '2'), ... - put_text(53 , y + 2 + margin_top + line*1, 'C', 'xx.x'), ... - put_text(53 , y + 2 + margin_top + line*2, 'C', 'xx.x'), ... - put_text(160, y + 2 + margin_top + line*1, 'C', 'xx.x'), ... - put_text(160, y + 2 + margin_top + line*2, 'C', 'xx.x'), ... - put_text(266, y + 2 + margin_top + line*1, 'C', 'x.xx'), ... - put_text(266, y + 2 + margin_top + line*2, 'C', 'x.xx'), ... + put_text(6 , y + 3 + margin_top + line*1, 'L', '1'), ... + put_text(6 , y + 3 + margin_top + line*2, 'L', '2'), ... + put_text(53 , y + 2 + margin_top + line*1, 'C', 'xx.x'), ... + put_text(53 , y + 2 + margin_top + line*2, 'C', 'xx.x'), ... + put_text(160, y + 2 + margin_top + line*1, 'C', 'xx.x'), ... + put_text(160, y + 2 + margin_top + line*2, 'C', 'xx.x'), ... + put_text(266, y + 2 + margin_top + line*1, 'C', 'x.xx'), ... + put_text(266, y + 2 + margin_top + line*2, 'C', 'x.xx'), ... ])); pause(0.2); times = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]; for i = 0:(length(times)-1) - x = 28 + i*10; - y = 144 - round(100 * (times(i+1) / max(times))); - matlabclient(1, get_smallpackage([ ... - set_point_size(3, 3), ... - point(x, y), ... - set_point_size(1, 1), ... - draw_line(x, 144-2, x, 144+2) ... - ])); - pause(0.15); +x = 28 + i*10; +y = 144 - round(100 * (times(i+1) / max(times))); +matlabclient(1, get_smallpackage([ ... + set_point_size(3, 3), ... + point(x, y), ... + set_point_size(1, 1), ... + draw_line(x, 144-2, x, 144+2) ... +])); +pause(0.15); end % matlabclient(1, get_smallpackage(save_display_to_clipboard())); -- cgit v1.2.1 From 49f712d1a24fba77a1f775af2333855849ddd87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 23 Nov 2019 21:43:32 +0100 Subject: fix indents --- Kod/bilbana/yc4/display/scenes/draw_segment_bars.m | 50 +++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m index d778323..f2703b2 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m +++ b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m @@ -1,48 +1,50 @@ function [] = draw_segment_bars(values1, values2) -pause(0.2); +dt = 0.2; + +pause(dt); matlabclient(1, get_smallpackage(clear_display())); -pause(0.2); +pause(dt); matlabclient(1, get_smallpackage(put_text(160, 8, 'C', 'Genomsnittlig tid per segment'))) -pause(0.2); +pause(dt); % input(''); matlabclient(1, get_smallpackage([ ... - key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... - key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... - key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ... + key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... + key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... + key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ... ])); -pause(0.2); +pause(dt); matlabclient(1, get_smallpackage([ ... - draw_line(20, 24, 20, 200), ... % y-axis - put_text(9, 25, 'C', 's'), ... % label y-axis - continue_line(304, 200), ... % x-axis - draw_line(16, 32, 20, 24), ... % arrow on y, left part - continue_line(24, 32), ... % arrow on y, right part - draw_line(304, 196, 304, 204) ... % line on x + draw_line(20, 24, 20, 200), ... % y-axis + put_text(9, 25, 'C', 's'), ... % label y-axis + continue_line(304, 200), ... % x-axis + draw_line(16, 32, 20, 24), ... % arrow on y, left part + continue_line(24, 32), ... % arrow on y, right part + draw_line(304, 196, 304, 204) ... % line on x ])); -pause(0.2); +pause(dt); [bars, max_val, min_y, max_height] = get_bars_from_values(values1, values2); for bar = bars - matlabclient(1, get_smallpackage(fill_area(bar.x_lo, bar.y_lo, bar.x_hi, bar.y_hi))); - pause(0.2); + matlabclient(1, get_smallpackage(fill_area(bar.x_lo, bar.y_lo, bar.x_hi, bar.y_hi))); + pause(dt); end for i = 0:8 - x = 16+13 + 10 + 30*i; - matlabclient(1, get_smallpackage(put_text(x, 204, 'C', num2str(i + 1)))); - pause(0.2); + x = 16+13 + 10 + 30*i; + matlabclient(1, get_smallpackage(put_text(x, 204, 'C', num2str(i + 1)))); + pause(dt); end for i = 1:floor(max_val) - x = 20; - y = min_y - round(max_height * (i/max_val)); - matlabclient(1, get_smallpackage([draw_line(x, y, 320, y), ... - put_text(x-6, y-2, 'C', num2str(i))])); - pause(0.2); + x = 20; + y = min_y - round(max_height * (i/max_val)); + matlabclient(1, get_smallpackage([draw_line(x, y, 320, y), ... + put_text(x-6, y-2, 'C', num2str(i))])); + pause(dt); end end -- cgit v1.2.1 From 81cf6bfafcb7b3f09a2627e57bb540b803d55df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 23 Nov 2019 21:47:47 +0100 Subject: Group packages together --- Kod/bilbana/yc4/display/scenes/draw_segment_bars.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m index f2703b2..4aaf42f 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m +++ b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m @@ -1,5 +1,6 @@ function [] = draw_segment_bars(values1, values2) -dt = 0.2; +dt = 0.2; % delay for display +queue = []; % internal queue for packages to send to display pause(dt); matlabclient(1, get_smallpackage(clear_display())); @@ -35,8 +36,12 @@ end for i = 0:8 x = 16+13 + 10 + 30*i; - matlabclient(1, get_smallpackage(put_text(x, 204, 'C', num2str(i + 1)))); - pause(dt); + queue = [queue put_text(x, 204, 'C', num2str(i + 1))] + if i == 4 or i == 8 + matlabclient(1, get_smallpackage(queue)); + queue = []; + pause(dt); + end end for i = 1:floor(max_val) -- cgit v1.2.1 From 78ce5f87fbc4b538a159f4f7fc4663475a135186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 23 Nov 2019 21:48:10 +0100 Subject: Fix indents --- Kod/bilbana/yc4/display/scenes/draw_segment_bars.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m index 4aaf42f..f34aa04 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m +++ b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m @@ -47,8 +47,10 @@ end for i = 1:floor(max_val) x = 20; y = min_y - round(max_height * (i/max_val)); - matlabclient(1, get_smallpackage([draw_line(x, y, 320, y), ... - put_text(x-6, y-2, 'C', num2str(i))])); + matlabclient(1, get_smallpackage([... + draw_line(x, y, 320, y), ... + put_text(x-6, y-2, 'C', num2str(i))... + ])); pause(dt); end end -- cgit v1.2.1 From f43db367ecbc2fe0bf2f787e085ed76edbe44898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 23 Nov 2019 21:48:47 +0100 Subject: Add dt parameter --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index 139b18f..704dee0 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -1,4 +1,6 @@ function [] = draw_lap_graph(car1_laptimes, car2_laptimes, ref_time) +dt = 0.2; % delay for display + if isempty(car1_laptimes) car1_laptimes = car2_laptimes; car2_laptimes = []; @@ -6,19 +8,19 @@ end % laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); -pause(0.2); +pause(dt); matlabclient(1, get_smallpackage(clear_display())); -pause(0.2); +pause(dt); matlabclient(1, get_smallpackage(put_text(160, 8, 'C', 'Varvtider'))) -pause(0.2); +pause(dt); matlabclient(1, get_smallpackage([ ... key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ... ])); -pause(0.2); +pause(dt); matlabclient(1, get_smallpackage([ ... draw_line(20, 24, 20, 144), ... % y-axis @@ -28,7 +30,7 @@ matlabclient(1, get_smallpackage([ ... continue_line(24, 32), ... % arrow on y, right part draw_line(304, 140, 304, 148) ... % line on x ])); -pause(0.2); +pause(dt); y = 166; margin_top = 6; @@ -38,7 +40,7 @@ matlabclient(1, get_smallpackage([ ... put_text(160, y + margin_top, 'C', 'mean'), ... put_text(266, y + margin_top, 'C', 'std') ... ])); -pause(0.2); +pause(dt); line = 12; matlabclient(1, get_smallpackage([ ... @@ -51,7 +53,7 @@ matlabclient(1, get_smallpackage([ ... put_text(266, y + 2 + margin_top + line*1, 'C', 'x.xx'), ... put_text(266, y + 2 + margin_top + line*2, 'C', 'x.xx'), ... ])); -pause(0.2); +pause(dt); times = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]; for i = 0:(length(times)-1) -- cgit v1.2.1 From fb66785644345d64ac27f53a8ba9b356b363b1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 23 Nov 2019 22:01:16 +0100 Subject: Strip empty values from laps --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index 704dee0..ec7d6dc 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -6,6 +6,24 @@ if isempty(car1_laptimes) car2_laptimes = []; end + +%% strip empty values +tmp = []; +for i = 1:length(car1_laptimes) + if car1_laptimes(i) ~= 0 + tmp = [tmp car1_laptimes(i)]; + end +end +car1_laptimes = tmp; + +tmp = []; +for i = 1:length(car2_laptimes) + if car2_laptimes(i) ~= 0 + tmp = [tmp car2_laptimes(i)]; + end +end +car2_laptimes = tmp; + % laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); pause(dt); -- cgit v1.2.1 From 457b052ca449b0653368c81e4218b20d76cd515a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 23 Nov 2019 22:02:03 +0100 Subject: Use calculated values for ref, mean and std --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index ec7d6dc..8c7a5d0 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -64,12 +64,12 @@ line = 12; matlabclient(1, get_smallpackage([ ... put_text(6 , y + 3 + margin_top + line*1, 'L', '1'), ... put_text(6 , y + 3 + margin_top + line*2, 'L', '2'), ... - put_text(53 , y + 2 + margin_top + line*1, 'C', 'xx.x'), ... - put_text(53 , y + 2 + margin_top + line*2, 'C', 'xx.x'), ... - put_text(160, y + 2 + margin_top + line*1, 'C', 'xx.x'), ... - put_text(160, y + 2 + margin_top + line*2, 'C', 'xx.x'), ... - put_text(266, y + 2 + margin_top + line*1, 'C', 'x.xx'), ... - put_text(266, y + 2 + margin_top + line*2, 'C', 'x.xx'), ... + put_text(53 , y + 2 + margin_top + line*1, 'C', num2str(ref_time)), ... + put_text(53 , y + 2 + margin_top + line*2, 'C', num2str(ref_time)), ... + put_text(160, y + 2 + margin_top + line*1, 'C', num2str(mean(car1_laptimes), 1)), ... + put_text(160, y + 2 + margin_top + line*2, 'C', num2str(mean(car2_laptimes), 1), ... + put_text(266, y + 2 + margin_top + line*1, 'C', num2str(std(car1_laptimes), 2)), ... + put_text(266, y + 2 + margin_top + line*2, 'C', num2str(std(car2_laptimes), 2)), ... ])); pause(dt); -- cgit v1.2.1 From d195a43eef3817d6a1f926725eeaba6770345c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 23 Nov 2019 23:05:05 +0100 Subject: more work --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 157 ++++++++++++++++-------- 1 file changed, 105 insertions(+), 52 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index 8c7a5d0..68cfecf 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -1,11 +1,28 @@ -function [] = draw_lap_graph(car1_laptimes, car2_laptimes, ref_time) +function [] = draw_lap_graph(car1_laptimes, car2_laptimes, ref_time, change_car) dt = 0.2; % delay for display -if isempty(car1_laptimes) - car1_laptimes = car2_laptimes; - car2_laptimes = []; +% don't have to re-draw static elements, just the graphs +persistent in_clipboard; +if is_empty(in_clipboard) + in_clipboard = false; end +% draw the other car every time the function is called if the change_car flag is set +% this value is ignored if only one set of lap times are given +persistent current_car; +if is_empty(current_car) + % first call to function + current_car = 1; +else + % switch current_car + if change_car + if current_car == 1 + current_car = 2; + else + current_car = 1; + end + end +end %% strip empty values tmp = []; @@ -24,67 +41,103 @@ for i = 1:length(car2_laptimes) end car2_laptimes = tmp; -% laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); - pause(dt); matlabclient(1, get_smallpackage(clear_display())); pause(dt); -matlabclient(1, get_smallpackage(put_text(160, 8, 'C', 'Varvtider'))) -pause(dt); +% laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); +if ~(in_clipboard) + matlabclient(1, get_smallpackage([ ... + put_text(160, 8, 'C', 'Varvtider'), ... + key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... + key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... + key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta'), ... + key(300, 0 , 320, 24 , 70, 71, 'C', 'Byt bil') ... + ])); + pause(dt); -matlabclient(1, get_smallpackage([ ... - key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... - key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... - key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ... -])); -pause(dt); + matlabclient(1, get_smallpackage([ ... + draw_line(20, 24, 20, 144), ... % y-axis + put_text(9, 25, 'C', 's'), ... % label y-axis + continue_line(304, 144), ... % x-axis + draw_line(16, 32, 20, 24), ... % arrow on y, left part + continue_line(24, 32), ... % arrow on y, right part + draw_line(304, 140, 304, 148) ... % line on x + ])); + pause(dt); -matlabclient(1, get_smallpackage([ ... - draw_line(20, 24, 20, 144), ... % y-axis - put_text(9, 25, 'C', 's'), ... % label y-axis - continue_line(304, 144), ... % x-axis - draw_line(16, 32, 20, 24), ... % arrow on y, left part - continue_line(24, 32), ... % arrow on y, right part - draw_line(304, 140, 304, 148) ... % line on x -])); -pause(dt); + y = 166; + margin_top = 6; + matlabclient(1, get_smallpackage([ ... + draw_line(0, y, 320, y), ... + put_text(53 , y + margin_top, 'C', 'target'), ... + put_text(160, y + margin_top, 'C', 'mean'), ... + put_text(266, y + margin_top, 'C', 'std') ... + ])); + pause(dt); -y = 166; -margin_top = 6; -matlabclient(1, get_smallpackage([ ... - draw_line(0, y, 320, y), ... - put_text(53 , y + margin_top, 'C', 'target'), ... - put_text(160, y + margin_top, 'C', 'mean'), ... - put_text(266, y + margin_top, 'C', 'std') ... -])); -pause(dt); + car1 = struct; + car1.avg = '--.-' + car1.dev = '-.--' + if ~isempty(car1_laptimes) + car1.avg = num2str(mean(car1_laptimes), 1); + car1.dev = num2str(std(car1_laptimes), 2); + end + car2 = struct; + car2.avg = '--.-' + car2.dev = '-.--' + if ~isempty(car2_laptimes) + car2.avg = num2str(mean(car2_laptimes), 1); + car2.dev = num2str(std(car2_laptimes), 2); + end -line = 12; -matlabclient(1, get_smallpackage([ ... - put_text(6 , y + 3 + margin_top + line*1, 'L', '1'), ... - put_text(6 , y + 3 + margin_top + line*2, 'L', '2'), ... - put_text(53 , y + 2 + margin_top + line*1, 'C', num2str(ref_time)), ... - put_text(53 , y + 2 + margin_top + line*2, 'C', num2str(ref_time)), ... - put_text(160, y + 2 + margin_top + line*1, 'C', num2str(mean(car1_laptimes), 1)), ... - put_text(160, y + 2 + margin_top + line*2, 'C', num2str(mean(car2_laptimes), 1), ... - put_text(266, y + 2 + margin_top + line*1, 'C', num2str(std(car1_laptimes), 2)), ... - put_text(266, y + 2 + margin_top + line*2, 'C', num2str(std(car2_laptimes), 2)), ... -])); -pause(dt); + line = 12; + matlabclient(1, get_smallpackage([ ... + put_text(6 , y + 3 + margin_top + line*1, 'L', '1'), ... + put_text(6 , y + 3 + margin_top + line*2, 'L', '2'), ... + put_text(53 , y + 2 + margin_top + line*1, 'C', num2str(ref_time)), ... + put_text(53 , y + 2 + margin_top + line*2, 'C', num2str(ref_time)), ... + put_text(160, y + 2 + margin_top + line*1, 'C', car1.avg)), ... + put_text(160, y + 2 + margin_top + line*2, 'C', car2.avg)), ... + put_text(266, y + 2 + margin_top + line*1, 'C', car1.dev)), ... + put_text(266, y + 2 + margin_top + line*2, 'C', car2.dev)), ... + ])); + pause(dt); + + matlabclient(1, get_smallpackage(save_display_to_clipboard())); + pause(dt); +else + matlabclient(1, get_smallpackage(restore_display_from_clipboard())); + pause(dt); +end + +times = []; +car = 0; +if current_car == 1 && ~isempty(car1_laptimes) + times = car1_laptimes; + car = 1; +elseif current_car == 2 && ~isempty(car2_laptimes) + times = car2_laptimes; + car = 2; +elseif ~isempty(car1_laptimes) + times = car1_laptimes; + car = 1; +elseif ~isempty(car2_laptimes) + times = car2_laptimes; + car = 2 +else + % not supposed to get here +end -times = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]; for i = 0:(length(times)-1) -x = 28 + i*10; -y = 144 - round(100 * (times(i+1) / max(times))); -matlabclient(1, get_smallpackage([ ... + x = 28 + i*10; + y = 144 - round(100 * (times(i+1) / max(times))); + matlabclient(1, get_smallpackage([ ... set_point_size(3, 3), ... point(x, y), ... set_point_size(1, 1), ... draw_line(x, 144-2, x, 144+2) ... -])); -pause(0.15); + ])); + pause(dt); end - -% matlabclient(1, get_smallpackage(save_display_to_clipboard())); end -- cgit v1.2.1 From e9c9b820042ddc6848c508bc43702efe7391b950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 24 Nov 2019 15:06:03 +0100 Subject: Draw points according to lap_times --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 47 ++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index 68cfecf..8323dad 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -8,7 +8,7 @@ if is_empty(in_clipboard) end % draw the other car every time the function is called if the change_car flag is set -% this value is ignored if only one set of lap times are given +% (this value is ignored if only one set of lap times are given) persistent current_car; if is_empty(current_car) % first call to function @@ -45,7 +45,7 @@ pause(dt); matlabclient(1, get_smallpackage(clear_display())); pause(dt); -% laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times)); +%% DRAW STATICS (OR COPY STATICS FROM CLIPBOARD) if ~(in_clipboard) matlabclient(1, get_smallpackage([ ... put_text(160, 8, 'C', 'Varvtider'), ... @@ -111,7 +111,24 @@ else pause(dt); end +%% DRAW GRAPH FOR CAR + +laps = -1 +% want to keep the same scale in x-axis for both cars so set laps to max of both +laps = max(length(car1_laptimes), length(car2_laptimes)) % TODO check if max([]) == 0 +x_min = 20; +dx_max = 260; +% x[lap] = x_min + (dx_max * (i / laps))) + +y_min_val = ref_time - 1.5; % val for lowest y +y_max_val = ref_time + 1.5; % val for highest y +y_min = 144; +dy_max = -50; +y_mid = y_min + (dy_max) +% y[lap] = clamp(y_min, y_mid + (dy_max * (lap[i] / ref_time)), y_min + 2*dy_max) + times = []; +% choose which lap-times to graph car = 0; if current_car == 1 && ~isempty(car1_laptimes) times = car1_laptimes; @@ -119,6 +136,7 @@ if current_car == 1 && ~isempty(car1_laptimes) elseif current_car == 2 && ~isempty(car2_laptimes) times = car2_laptimes; car = 2; +% ignore current_car and choose the only carn_laptimes that exist elseif ~isempty(car1_laptimes) times = car1_laptimes; car = 1; @@ -129,9 +147,12 @@ else % not supposed to get here end -for i = 0:(length(times)-1) - x = 28 + i*10; - y = 144 - round(100 * (times(i+1) / max(times))); +for i = 1:(length(times)) + x = round(x_min + (dx_max * (i/laps))); + y = clamp(y_min, ... + round(y_mid + (dy_max * (times(i) / ref_time))), ... + y_min + 2*dy_max ... + ); matlabclient(1, get_smallpackage([ ... set_point_size(3, 3), ... point(x, y), ... @@ -140,4 +161,20 @@ for i = 0:(length(times)-1) ])); pause(dt); end +max_lap_nums = 9; +d_lap = floor(laps/max_lap_nums) + 1; +% examples: +% laps = 8 + % d_lap = floor(8/9) + 1 = 0 + 1 = 1 +% laps = 10 + % d_lap = floor(10/9) + 1 = 1 + 1 = 2 +for i = 1:(length(times)) + if mod(i, d_lap) == 0 + x = round(x_min + (dx_max * (i/laps))); + y = y_min + 4; + matlabclient(1, get_smallpackage([ ... + put_text(x, y, 'C', num2str(i)) ... + ])); + end +end end -- cgit v1.2.1 From 28de2319217341f7dd2ce8b8ecc091328a60eeaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 25 Nov 2019 10:24:03 +0100 Subject: std -> stdev --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index 8323dad..b67b6f0 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -24,7 +24,7 @@ else end end -%% strip empty values +%% STRIP EMPTY VALUES tmp = []; for i = 1:length(car1_laptimes) if car1_laptimes(i) ~= 0 @@ -72,7 +72,7 @@ if ~(in_clipboard) draw_line(0, y, 320, y), ... put_text(53 , y + margin_top, 'C', 'target'), ... put_text(160, y + margin_top, 'C', 'mean'), ... - put_text(266, y + margin_top, 'C', 'std') ... + put_text(266, y + margin_top, 'C', 'stdev') ... ])); pause(dt); -- cgit v1.2.1 From 2246ff7466c252dff4e22ed894dee3f152f0f4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 25 Nov 2019 12:34:32 +0100 Subject: Changes - Add semicolons - Fix clamp - Fix syntax - Make testing (somewhat) modular --- Kod/bilbana/yc4/display/scenes/draw_lap_graph.m | 43 ++++++++++++---------- Kod/bilbana/yc4/display/scenes/draw_segment_bars.m | 4 +- 2 files changed, 25 insertions(+), 22 deletions(-) (limited to 'Kod/bilbana/yc4/display/scenes') diff --git a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m index b67b6f0..ebee57e 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m +++ b/Kod/bilbana/yc4/display/scenes/draw_lap_graph.m @@ -3,18 +3,19 @@ dt = 0.2; % delay for display % don't have to re-draw static elements, just the graphs persistent in_clipboard; -if is_empty(in_clipboard) +if isempty(in_clipboard) in_clipboard = false; end % draw the other car every time the function is called if the change_car flag is set % (this value is ignored if only one set of lap times are given) persistent current_car; -if is_empty(current_car) +if isempty(current_car) % first call to function current_car = 1; else % switch current_car + disp('switching current car'); if change_car if current_car == 1 current_car = 2; @@ -52,7 +53,7 @@ if ~(in_clipboard) key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ... key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ... key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta'), ... - key(300, 0 , 320, 24 , 70, 71, 'C', 'Byt bil') ... + key(260, 0 , 320, 24 , 70, 71, 'C', 'Byt bil') ... ])); pause(dt); @@ -77,17 +78,17 @@ if ~(in_clipboard) pause(dt); car1 = struct; - car1.avg = '--.-' - car1.dev = '-.--' + car1.avg = '--.-'; + car1.dev = '-.--'; if ~isempty(car1_laptimes) - car1.avg = num2str(mean(car1_laptimes), 1); + car1.avg = num2str(mean(car1_laptimes), 3); car1.dev = num2str(std(car1_laptimes), 2); end car2 = struct; - car2.avg = '--.-' - car2.dev = '-.--' + car2.avg = '--.-'; + car2.dev = '-.--'; if ~isempty(car2_laptimes) - car2.avg = num2str(mean(car2_laptimes), 1); + car2.avg = num2str(mean(car2_laptimes), 3); car2.dev = num2str(std(car2_laptimes), 2); end @@ -97,10 +98,10 @@ if ~(in_clipboard) put_text(6 , y + 3 + margin_top + line*2, 'L', '2'), ... put_text(53 , y + 2 + margin_top + line*1, 'C', num2str(ref_time)), ... put_text(53 , y + 2 + margin_top + line*2, 'C', num2str(ref_time)), ... - put_text(160, y + 2 + margin_top + line*1, 'C', car1.avg)), ... - put_text(160, y + 2 + margin_top + line*2, 'C', car2.avg)), ... - put_text(266, y + 2 + margin_top + line*1, 'C', car1.dev)), ... - put_text(266, y + 2 + margin_top + line*2, 'C', car2.dev)), ... + put_text(160, y + 2 + margin_top + line*1, 'C', car1.avg), ... + put_text(160, y + 2 + margin_top + line*2, 'C', car2.avg), ... + put_text(266, y + 2 + margin_top + line*1, 'C', car1.dev), ... + put_text(266, y + 2 + margin_top + line*2, 'C', car2.dev), ... ])); pause(dt); @@ -113,9 +114,9 @@ end %% DRAW GRAPH FOR CAR -laps = -1 +laps = -1; % want to keep the same scale in x-axis for both cars so set laps to max of both -laps = max(length(car1_laptimes), length(car2_laptimes)) % TODO check if max([]) == 0 +laps = max(length(car1_laptimes), length(car2_laptimes)); % TODO check if max([]) == 0 x_min = 20; dx_max = 260; % x[lap] = x_min + (dx_max * (i / laps))) @@ -124,7 +125,8 @@ y_min_val = ref_time - 1.5; % val for lowest y y_max_val = ref_time + 1.5; % val for highest y y_min = 144; dy_max = -50; -y_mid = y_min + (dy_max) +max_diff_val = 1; +y_mid = y_min + (dy_max); % y[lap] = clamp(y_min, y_mid + (dy_max * (lap[i] / ref_time)), y_min + 2*dy_max) times = []; @@ -142,16 +144,16 @@ elseif ~isempty(car1_laptimes) car = 1; elseif ~isempty(car2_laptimes) times = car2_laptimes; - car = 2 + car = 2; else % not supposed to get here end for i = 1:(length(times)) x = round(x_min + (dx_max * (i/laps))); - y = clamp(y_min, ... - round(y_mid + (dy_max * (times(i) / ref_time))), ... - y_min + 2*dy_max ... + y = clamp(round(y_mid + dy_max), ... + round(y_mid + (dy_max * ((times(i) - ref_time) / max_diff_val))), ... + round(y_mid - dy_max) ... ); matlabclient(1, get_smallpackage([ ... set_point_size(3, 3), ... @@ -175,6 +177,7 @@ for i = 1:(length(times)) matlabclient(1, get_smallpackage([ ... put_text(x, y, 'C', num2str(i)) ... ])); + pause(dt); end end end diff --git a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m index f34aa04..6df2dab 100644 --- a/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m +++ b/Kod/bilbana/yc4/display/scenes/draw_segment_bars.m @@ -36,8 +36,8 @@ end for i = 0:8 x = 16+13 + 10 + 30*i; - queue = [queue put_text(x, 204, 'C', num2str(i + 1))] - if i == 4 or i == 8 + queue = [queue put_text(x, 204, 'C', num2str(i + 1))]; + if i == 4 || i == 8 matlabclient(1, get_smallpackage(queue)); queue = []; pause(dt); -- cgit v1.2.1