aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/api
diff options
context:
space:
mode:
authorcbbrowne <cbbrowne@cbbrowne.tor.int-afilias.info>2016-11-29 12:20:26 -0500
committercbbrowne <cbbrowne@cbbrowne.tor.int-afilias.info>2016-11-29 12:20:26 -0500
commitff1b563e851858a291ac226bc7e31055c7da6618 (patch)
tree8367dd5ef812baf644e1c54ba900dab3f042f0fa /quantum/api
parent5776f39667c82e1053b46fd12d8c6faa5b5acf81 (diff)
parent81ea909467c8a5bfbd803c58e685c5de74dbc249 (diff)
downloadfirmware-ff1b563e851858a291ac226bc7e31055c7da6618.tar.gz
firmware-ff1b563e851858a291ac226bc7e31055c7da6618.tar.bz2
firmware-ff1b563e851858a291ac226bc7e31055c7da6618.zip
Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'quantum/api')
-rw-r--r--quantum/api/api_sysex.c29
-rw-r--r--quantum/api/api_sysex.h10
2 files changed, 39 insertions, 0 deletions
diff --git a/quantum/api/api_sysex.c b/quantum/api/api_sysex.c
new file mode 100644
index 000000000..a4a554e76
--- /dev/null
+++ b/quantum/api/api_sysex.c
@@ -0,0 +1,29 @@
+#include "api_sysex.h"
+
+void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint16_t length) {
+ // SEND_STRING("\nTX: ");
+ // for (uint8_t i = 0; i < length; i++) {
+ // send_byte(bytes[i]);
+ // SEND_STRING(" ");
+ // }
+ uint8_t * precode = malloc(sizeof(uint8_t) * (length + 2));
+ precode[0] = message_type;
+ precode[1] = data_type;
+ memcpy(precode + 2, bytes, length);
+ uint8_t * encoded = malloc(sizeof(uint8_t) * (sysex_encoded_length(length + 2)));
+ uint16_t encoded_length = sysex_encode(encoded, precode, length + 2);
+ uint8_t * array = malloc(sizeof(uint8_t) * (encoded_length + 5));
+ array[0] = 0xF0;
+ array[1] = 0x00;
+ array[2] = 0x00;
+ array[3] = 0x00;
+ array[encoded_length + 4] = 0xF7;
+ memcpy(array + 4, encoded, encoded_length);
+ midi_send_array(&midi_device, encoded_length + 5, array);
+
+ // SEND_STRING("\nTD: ");
+ // for (uint8_t i = 0; i < encoded_length + 5; i++) {
+ // send_byte(array[i]);
+ // SEND_STRING(" ");
+ // }
+} \ No newline at end of file
diff --git a/quantum/api/api_sysex.h b/quantum/api/api_sysex.h
new file mode 100644
index 000000000..b947b60e5
--- /dev/null
+++ b/quantum/api/api_sysex.h
@@ -0,0 +1,10 @@
+#ifndef _API_SYSEX_H_
+#define _API_SYSEX_H_
+
+#include "api.h"
+
+void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint16_t length);
+
+#define SEND_BYTES(mt, dt, b, l) send_bytes_sysex(mt, dt, b, l)
+
+#endif \ No newline at end of file