From 6fe6d111bf563962e0d3cc2e4812b6d7959836a3 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 28 Feb 2016 22:52:30 +0200 Subject: [PATCH] Send the keyboard matrix over the serial link --- serial_link/system/system.c | 53 ++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/serial_link/system/system.c b/serial_link/system/system.c index c38bcd87d..68ccbdb45 100644 --- a/serial_link/system/system.c +++ b/serial_link/system/system.c @@ -29,6 +29,7 @@ SOFTWARE. #include "serial_link/protocol/byte_stuffer.h" #include "serial_link/protocol/transport.h" #include "serial_link/protocol/frame_router.h" +#include "matrix.h" #include #include "print.h" @@ -111,16 +112,17 @@ void send_data(uint8_t link, const uint8_t* data, uint16_t size) { static systime_t last_update = 0; typedef struct { - uint32_t test; -} test_object1_t; + matrix_row_t rows[MATRIX_ROWS]; +} matrix_object_t; +static matrix_object_t last_matrix = {}; -SLAVE_TO_MASTER_OBJECT(slave_to_master, test_object1_t); +SLAVE_TO_MASTER_OBJECT(keyboard_matrix, matrix_object_t); MASTER_TO_ALL_SLAVES_OBJECT(serial_link_connected, bool); remote_object_t* test_remote_objects[] = { REMOTE_OBJECT(serial_link_connected), - REMOTE_OBJECT(slave_to_master), + REMOTE_OBJECT(keyboard_matrix), }; void init_serial_link(void) { @@ -140,24 +142,42 @@ void serial_link_update(void) { if (current_time - last_update > 1000) { *begin_write_serial_link_connected() = true; end_write_serial_link_connected(); - test_object1_t* obj = begin_write_slave_to_master(); - obj->test = current_time; - end_write_slave_to_master(); - xprintf("writing %d\n", current_time); last_update = current_time; } - test_object1_t* obj = read_slave_to_master(0); - if (obj) { - xprintf("%d\n", obj->test); - } - obj = read_slave_to_master(1); - if (obj) { - xprintf("%d\n", obj->test); - } if (read_serial_link_connected()) { serial_link_connected = true; } + + matrix_object_t matrix; + bool changed = false; + for(uint8_t i=0;irows[i] = matrix.rows[i]; + } + end_write_keyboard_matrix(); + } + + matrix_object_t* m = read_keyboard_matrix(0); + if (m) { + xprintf("\nr/c 01234567\n"); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + xprintf("%X0: ", row); + for (int col = 0; col < MATRIX_COLS; col++) { + if (m->rows[row] & (1<