aboutsummaryrefslogtreecommitdiff
path: root/keyboards/dichotomy/dichotomy.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/dichotomy/dichotomy.c')
-rwxr-xr-xkeyboards/dichotomy/dichotomy.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/keyboards/dichotomy/dichotomy.c b/keyboards/dichotomy/dichotomy.c
new file mode 100755
index 000000000..41e12090c
--- /dev/null
+++ b/keyboards/dichotomy/dichotomy.c
@@ -0,0 +1,89 @@
1#include "dichotomy.h"
2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void pointing_device_task(void){
8 /*report_mouse_t currentReport = {};
9 SERIAL_UART_INIT();
10 uint32_t timeout = 0;
11
12 //the m character requests the RF slave to send the mouse report
13 SERIAL_UART_DATA = 'm';
14
15 //trust the external inputs completely, erase old data
16 uint8_t uart_data[5] = {0};
17
18 //there are 10 bytes corresponding to 10 columns, and an end byte
19 for (uint8_t i = 0; i < 5; i++) {
20 //wait for the serial data, timeout if it's been too long
21 //this only happened in testing with a loose wire, but does no
22 //harm to leave it in here
23 while(!SERIAL_UART_RXD_PRESENT){
24 timeout++;
25 if (timeout > 10000){
26 xprintf("\r\nTIMED OUT");
27 break;
28 }
29 }
30 xprintf("\r\nGOT DATA for %d",i);
31 uart_data[i] = SERIAL_UART_DATA;
32 }
33
34 //check for the end packet, bytes 1-4 are movement and scroll
35 //but byte 5 has bits 0-3 for the scroll button state
36 //(1000 if pressed, 0000 if not) and bits 4-7 are always 1
37 //We can use this to verify the report sent properly.
38 if (uart_data[4] == 0x0F || uart_data[4] == 0x8F)
39 {
40 xprintf("\r\nREQUESTED MOUSE, RECEIVED %i, %i, %i, %i, %i",uart_data[0],uart_data[1],uart_data[2],uart_data[3],uart_data[4]);
41 currentReport = pointing_device_get_report();
42 //shifting and transferring the info to the mouse report varaible
43 //mouseReport.x = 127 max -127 min
44 currentReport.x = (int8_t) uart_data[0];
45 //mouseReport.y = 127 max -127 min
46 currentReport.y = (int8_t) uart_data[1];
47 //mouseReport.v = 127 max -127 min (scroll vertical)
48 currentReport.v = (int8_t) uart_data[2];
49 //mouseReport.h = 127 max -127 min (scroll horizontal)
50 currentReport.h = (int8_t) uart_data[3];
51 //mouseReport.buttons = 0x31 max (bitmask for mouse buttons 1-5) 0x00 min
52 //mouse buttons 1 and 2 are handled by the keymap, but not 3
53 if (uart_data[4] == 0x0F) { //then 3 is not pressed
54 currentReport.buttons &= ~MOUSE_BTN3; //MOUSE_BTN3 is def in report.h
55 } else { //3 must be pressed
56 currentReport.buttons |= MOUSE_BTN3;
57 }
58 pointing_device_set_report(currentReport);
59 } else {
60 xprintf("\r\nRequested packet, data 4 was %d",uart_data[4]);
61 }*/
62 pointing_device_send();
63}
64
65void led_init(void) {
66 DDRD |= (1<<1);
67 PORTD |= (1<<1);
68 DDRF |= (1<<4) | (1<<5);
69 PORTF |= (1<<4) | (1<<5);
70}
71
72
73void matrix_init_kb(void) {
74 // put your keyboard start-up code here
75 // runs once when the firmware starts up
76 matrix_init_user();
77 uart_init();
78 led_init();
79}
80
81void matrix_scan_kb(void) {
82 // put your looping keyboard code here
83 // runs every cycle (a lot)
84 matrix_scan_user();
85}
86
87void led_set_kb(uint8_t usb_led) {
88
89}