summaryrefslogtreecommitdiffstats
path: root/Kod/bilbana/yc4/display
diff options
context:
space:
mode:
Diffstat (limited to 'Kod/bilbana/yc4/display')
-rw-r--r--Kod/bilbana/yc4/display/define_touch_switch.m2
-rw-r--r--Kod/bilbana/yc4/display/get_num.m3
-rw-r--r--Kod/bilbana/yc4/display/get_package.m10
-rw-r--r--Kod/bilbana/yc4/display/get_response.m51
-rw-r--r--Kod/bilbana/yc4/display/get_smallpackage.m8
-rw-r--r--Kod/bilbana/yc4/display/send_data_to_display.m4
6 files changed, 69 insertions, 9 deletions
diff --git a/Kod/bilbana/yc4/display/define_touch_switch.m b/Kod/bilbana/yc4/display/define_touch_switch.m
index 47d3cd9..4dfc764 100644
--- a/Kod/bilbana/yc4/display/define_touch_switch.m
+++ b/Kod/bilbana/yc4/display/define_touch_switch.m
@@ -1,4 +1,4 @@
-function pkg = define_touch_key(x1, y1, x2, y2, down_code, up_code, just, text)
+function pkg = define_touch_switch(x1, y1, x2, y2, down_code, up_code, just, text)
arg_location = [get_bytes(x1), get_bytes(y1), get_bytes(x2), get_bytes(y2)];
arg_text = double(strjoin({just; text}, ''));
arg_null = 0;
diff --git a/Kod/bilbana/yc4/display/get_num.m b/Kod/bilbana/yc4/display/get_num.m
new file mode 100644
index 0000000..e90e0c7
--- /dev/null
+++ b/Kod/bilbana/yc4/display/get_num.m
@@ -0,0 +1,3 @@
+function num = get_num(bytes)
+num = bytes(1) + bytes(2) * 256;
+end \ No newline at end of file
diff --git a/Kod/bilbana/yc4/display/get_package.m b/Kod/bilbana/yc4/display/get_package.m
index 7c3a01e..efaf311 100644
--- a/Kod/bilbana/yc4/display/get_package.m
+++ b/Kod/bilbana/yc4/display/get_package.m
@@ -1,10 +1,4 @@
-function [pkg] = get_package(code, args)
- DC1 = 17;
+function pkg = get_package(code, args)
ESC = 27;
-
- data = [ESC, double(code), args];
- len = length(data);
- initStr = [DC1, len, data];
- bcc = mod(sum(initStr), 256);
- pkg = [initStr, bcc];
+ pkg = [ESC, double(code), args];
end
diff --git a/Kod/bilbana/yc4/display/get_response.m b/Kod/bilbana/yc4/display/get_response.m
new file mode 100644
index 0000000..1e3e6af
--- /dev/null
+++ b/Kod/bilbana/yc4/display/get_response.m
@@ -0,0 +1,51 @@
+function [ack, start_code, responses] = get_response(display_data)
+% GET RESPONSE
+% In-depth explanation
+% [flag, display_data] = matlabclient(2)
+
+ack = false;
+start_code = '';
+bcc = display_data(length(display_data));
+responses = [];
+
+pointer = 1;
+
+if display_data(pointer) == 6
+ ack = true;
+else
+ return
+end
+
+if pointer > length(display_data)
+ return
+end
+
+pointer = pointer + 1;
+if display_data(1) == 17
+ start_code = 'DC1';
+elseif display_data(1) == 18
+ start_code = 'DC2';
+end
+
+pointer = pointer + 1;
+% total length
+
+data = struct;
+while pointer < length(display_data) - 1 % last value is bcc
+ pointer = pointer + 1;
+ if display_data(pointer) ~= 27
+ % TODO: no ESC?
+ end
+ pointer = pointer + 1;
+ data.id = char(display_data(pointer));
+
+ pointer = pointer + 1;
+ data.length = display_data(pointer);
+ if data.id == 'A'
+ pointer = pointer + 1;
+ data.data = display_data(pointer);
+ else
+ pointer = pointer + data.length;
+ end
+ responses = [responses, data];
+end
diff --git a/Kod/bilbana/yc4/display/get_smallpackage.m b/Kod/bilbana/yc4/display/get_smallpackage.m
new file mode 100644
index 0000000..1c0835c
--- /dev/null
+++ b/Kod/bilbana/yc4/display/get_smallpackage.m
@@ -0,0 +1,8 @@
+function pkg = get_smallpackage(data)
+ DC1 = 17;
+
+ len = length(data);
+ initStr = [DC1, len, data];
+ bcc = mod(sum(initStr), 256);
+ pkg = [initStr, bcc];
+end
diff --git a/Kod/bilbana/yc4/display/send_data_to_display.m b/Kod/bilbana/yc4/display/send_data_to_display.m
index c5d70c7..50af84f 100644
--- a/Kod/bilbana/yc4/display/send_data_to_display.m
+++ b/Kod/bilbana/yc4/display/send_data_to_display.m
@@ -20,6 +20,10 @@ function [] = send_data_to_display()
%% SEND DATA
% disp('sending data');
% disp(display_data)
+
+ data = [];
+
+
matlabclient(1, display_data{1});
last_send = clock;
display_data(1) = [];