summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-11-22 01:50:55 +0100
committerJack Humbert <jack.humb@gmail.com>2016-11-22 01:50:55 +0100
commit664c0a036b3d7c3ed39f4a7a78d97f4a9cc7d20c (patch)
treee6cb0a7fb1c5c882fe394fd251680e0c88df323c /quantum
parent27ebacb15d39046713bd87e06c1157b1ffab6aaf (diff)
downloadqmk_firmware-664c0a036b3d7c3ed39f4a7a78d97f4a9cc7d20c.tar.gz
qmk_firmware-664c0a036b3d7c3ed39f4a7a78d97f4a9cc7d20c.tar.xz
cleaning up new code
Diffstat (limited to 'quantum')
-rwxr-xr-xquantum/light_ws2812.h2
-rw-r--r--quantum/quantum.c40
-rw-r--r--quantum/quantum.h5
3 files changed, 46 insertions, 1 deletions
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h
index 0bef93d5e..9498e550e 100755
--- a/quantum/light_ws2812.h
+++ b/quantum/light_ws2812.h
@@ -16,7 +16,7 @@
#include <avr/io.h>
#include <avr/interrupt.h>
//#include "ws2812_config.h"
-#include "i2cmaster.h"
+//#include "i2cmaster.h"
#define LIGHT_I2C 1
#define LIGHT_I2C_ADDR 0x84
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 9fd9a6ef7..8b2fefef6 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -802,6 +802,46 @@ void backlight_set(uint8_t level)
#endif // backlight
+// Functions for spitting out values
+//
+
+void send_dword(uint32_t number) { // this might not actually work
+ uint16_t word = (number >> 16);
+ send_word(word);
+ send_word(number & 0xFFFFUL);
+}
+
+void send_word(uint16_t number) {
+ uint8_t byte = number >> 8;
+ send_byte(byte);
+ send_byte(number & 0xFF);
+}
+
+void send_byte(uint8_t number) {
+ uint8_t nibble = number >> 4;
+ send_nibble(nibble);
+ send_nibble(number & 0xF);
+}
+
+void send_nibble(uint8_t number) {
+ switch (number) {
+ case 0:
+ register_code(KC_0);
+ unregister_code(KC_0);
+ break;
+ case 1 ... 9:
+ register_code(KC_1 + (number - 1));
+ unregister_code(KC_1 + (number - 1));
+ break;
+ case 0xA ... 0xF:
+ register_code(KC_A + (number - 0xA));
+ unregister_code(KC_A + (number - 0xA));
+ break;
+ }
+}
+
+
+
__attribute__ ((weak))
void led_set_user(uint8_t usb_led) {
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 06a2e049d..3d35f11fa 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -110,6 +110,11 @@ void breathing_speed_dec(uint8_t value);
#endif
#endif
+void send_dword(uint32_t number);
+void send_word(uint16_t number);
+void send_byte(uint8_t number);
+void send_nibble(uint8_t number);
+
void led_set_user(uint8_t usb_led);
void led_set_kb(uint8_t usb_led);