diff options
| -rw-r--r-- | Kod/bilbana/yc4/main.m | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 052f59e..7fdf005 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -65,11 +65,16 @@ highToc = 0; %% DRAW DISPLAY matlabclient(1, get_smallpackage([ ... put_text(160, 30, 'C', 'Choose which car to drive'), ... - define_touch_switch(98 , 60 , 130, 90 , 11, 12, 'C', '1'), ... - define_touch_switch(102, 98 , 126, 122, 13, 14, 'C', 'M'), ... - define_touch_switch(190, 60 , 222, 90 , 21, 22, 'C', '2'), ... - define_touch_switch(194, 98 , 218, 122, 23, 61, 'C', 'M'), ... - define_touch_key( 272, 192, 304, 224, 31, 32, 'C', 'S') ... + define_touch_switch(98 , 60 , 130, 90 , 11, 12, 'C', '1'), ... % ACTIVATE TRACK 1 + define_touch_switch(102, 98 , 126, 122, 13, 14, 'C', 'M'), ... % MANUAL CONTROL TRACK 1 + define_touch_switch(190, 60 , 222, 90 , 21, 22, 'C', '2'), ... % ACTIVATE TRACK 2 + define_touch_switch(194, 98 , 218, 122, 23, 61, 'C', 'M'), ... % MANUAL CONTROL TRACK 2 + put_text(160, 120, 'C', '13.0'), ... % CURRENT REFERENCE TIME + define_touch_key( 98 , 110, 130, 140, 41, 42, 'C', '-'), ... % DECREASE REFERENCE TIME + define_touch_key( 190, 110, 220, 140, 43, 44, 'C', '+'), ... % INCREASE REFERENCE TIME + define_touch_key( 272, 192, 304, 224, 31, 32, 'C', 'S') ... % START BUTTON + %TODO CLEAR BUTTON + put_text() ])); %% CHECK DISPLAY BUTTONS @@ -77,18 +82,17 @@ display.last_check = tic; done = false; while 1 pause(0.1); - if toc(display.last_check) > 0.5 - display.last_check = tic; + if toc(display.last_check) > 0.4 % read internal mem from last send [display.out, display.shm] = matlabclient(2); [display.shm_interp.ack, display.shm_interp.start_code, display.shm_interp.data] = get_response(display.shm); % request internal mem matlabclient(1, hex2dec(['12'; '01'; '53'; '66'])); - if isempty(display.shm_interp.data) continue end + update_ref_time = false; for i = 1:length(display.shm_interp.data) disp(num2str(length(display.shm_interp.data))) data = display.shm_interp.data(i); @@ -111,11 +115,26 @@ while 1 car2.automatic = false; elseif data.data == 24 car2.automatic = true; + elseif data.data == 41 + % ignore + elseif data.data == 42 + ref_time = max(ref_time - 0.5, 12.0) + update_ref_time = true; + elseif data.data == 43 + % ignore + elseif data.data == 44 + ref_time = min(ref_time + 0.5, 15.0) + update_ref_time = true; end end if done == true break end + if update_ref_time == true + pause(0.4); + matlabclient(1, get_smallpackage(put_text(160, 120, 'C', num2str(ref_time, '%.1f')))); + end + display.last_check = tic; end end |
