diff options
| -rw-r--r-- | Kod/bilbana/yc4/main.m | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 851681a..baf1914 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -35,6 +35,7 @@ tocs = []; %% MAIN LOOP while 1 + tic; %% PRE-LOOP if strcmp(get(hf,'currentcharacter'),'q') close(hf) @@ -52,22 +53,27 @@ while 1 if car1.new_check_point == true % beep; if car1.lap ~= 0 - car1.seg_times(car1.lap, car1.segment) = -1; % TODO + car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); end car1.segment = car1.segment + 1; + car1.seg_tic = tic; elseif car1.new_lap == true % beep; if car1.lap == 0 % dont save time for first lap car1.segment = 1; car1.lap = car1.lap + 1; + car1.seg_tic = tic; + car1.lap_tic = tic; continue; end - car1.seg_times(car1.lap, car1.segment) = -1; % TODO - car1.lap_times(car1.lap) = -1; % TODO - - display_data = [display_data, put_text(100, 32, L, strjoin({num2str(car1.lap), get_time_as_string(car1.lap_times(car1.lap))}, ' '))]; + car1.seg_times(car1.lap, car1.segment) = toc(car1.seg_tic); + car1.seg_tic = tic; + car1.lap_times(car1.lap) = toc(car1.lap_tic); + car1.lap_tic = tic; + display_data = [display_data, put_text(100, 32, L, strjoin({num2str(car1.lap), get_time_as_string(car1.lap_times(car1.lap))}, ' '))]; + car1.segment = 1; car1.lap = car1.lap + 1; end @@ -76,19 +82,24 @@ while 1 if car2.new_check_point == true % beep; if car2.lap ~= 0 - car2.seg_times(car2.lap, car2.segment) = -1; % TODO + car2.seg_times(car2.lap, car2.segment) = toc(car2.seg_tic); end car2.segment = car2.segment + 1; + car2.seg_tic = tic; elseif car2.new_lap == true - % beep; + beep; if car2.lap == 0 % dont save time for first lap car2.segment = 1; car2.lap = car2.lap + 1; + car2.seg_tic = tic; + car2.lap_tic = tic; continue; end - car2.seg_times(car2.lap, car2.segment) = -1; % TODO - car2.lap_times(car2.lap) = -1; % TODO + car2.seg_times(car2.lap, car2.segment) = toc(car2.seg_tic); + car2.seg_tic = tic; + car2.lap_times(car2.lap) = toc(car2.lap_tic); + car2.lap_tic = tic; display_data = [display_data, put_text(120, 32, L, strjoin({num2str(car2.lap), get_time_as_string(car2.lap_times(car2.lap))}, ' '))]; @@ -115,10 +126,9 @@ while 1 %% DISPLAY %% END OF LOOP - tocs(end + 1) = toc; pause(0.1) - tic; - send_data_to_display(); + tocs(end + 1) = toc; + send_data_to_display(); end %% END OF PROGRAM |
