diff options
author | Jack Humbert <jack.humb@gmail.com> | 2016-10-16 16:03:33 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2016-10-16 16:03:33 -0400 |
commit | 5f91fb413624781ac79db641549b9e08753c04b5 (patch) | |
tree | ab94b44cdc5c501ac6d9bcba920dd9a5141a7963 | |
parent | b8679bbe045a2285d6ab6bbc420121b26f516b9a (diff) | |
download | qmk_firmware-5f91fb413624781ac79db641549b9e08753c04b5.tar.gz qmk_firmware-5f91fb413624781ac79db641549b9e08753c04b5.zip |
working with power limit
-rw-r--r-- | build_keyboard.mk | 6 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/jack/config.h | 2 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/jack/keymap.c | 4 | ||||
-rw-r--r-- | quantum/keymap.h | 4 | ||||
-rwxr-xr-x | quantum/light_ws2812.c | 137 | ||||
-rwxr-xr-x | quantum/light_ws2812.h | 7 | ||||
-rw-r--r-- | quantum/quantum.c | 3 | ||||
-rw-r--r-- | quantum/quantum.h | 4 |
8 files changed, 163 insertions, 4 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index 03a69b146..cd9f44c7b 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
@@ -169,6 +169,12 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | |||
169 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c | 169 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c |
170 | endif | 170 | endif |
171 | 171 | ||
172 | ifeq ($(strip $(PRINTING_ENABLE)), yes) | ||
173 | OPT_DEFS += -DPRINTING_ENABLE | ||
174 | SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c | ||
175 | SRC += $(TMK_DIR)/protocol/serial_uart.c | ||
176 | endif | ||
177 | |||
172 | ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) | 178 | ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) |
173 | SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) | 179 | SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) |
174 | OPT_DEFS += $(SERIAL_DEFS) | 180 | OPT_DEFS += $(SERIAL_DEFS) |
diff --git a/keyboards/ergodox/keymaps/jack/config.h b/keyboards/ergodox/keymaps/jack/config.h index 01ccfb3a2..f0932084a 100644 --- a/keyboards/ergodox/keymaps/jack/config.h +++ b/keyboards/ergodox/keymaps/jack/config.h | |||
@@ -6,7 +6,7 @@ | |||
6 | /* ws2812 RGB LED */ | 6 | /* ws2812 RGB LED */ |
7 | #define RGB_DI_PIN D7 | 7 | #define RGB_DI_PIN D7 |
8 | // #define RGBLIGHT_TIMER | 8 | // #define RGBLIGHT_TIMER |
9 | #define RGBLED_NUM 20 // Number of LEDs | 9 | #define RGBLED_NUM 15 // Number of LEDs |
10 | #define RGBLIGHT_HUE_STEP 8 | 10 | #define RGBLIGHT_HUE_STEP 8 |
11 | #define RGBLIGHT_SAT_STEP 8 | 11 | #define RGBLIGHT_SAT_STEP 8 |
12 | #define RGBLIGHT_VAL_STEP 8 | 12 | #define RGBLIGHT_VAL_STEP 8 |
diff --git a/keyboards/ergodox/keymaps/jack/keymap.c b/keyboards/ergodox/keymaps/jack/keymap.c index 1dd5a7618..fabd27a61 100644 --- a/keyboards/ergodox/keymaps/jack/keymap.c +++ b/keyboards/ergodox/keymaps/jack/keymap.c | |||
@@ -25,7 +25,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
25 | KC_NO, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_ENT, | 25 | KC_NO, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_ENT, |
26 | MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT, | 26 | MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT, |
27 | RGB_TOG, RGB_HUI, | 27 | RGB_TOG, RGB_HUI, |
28 | KC_PGUP, | 28 | RGB_MOD, |
29 | KC_PGDN, KC_SPC,KC_SPC | 29 | KC_PGDN, KC_SPC,KC_SPC |
30 | ), | 30 | ), |
31 | [SYMB] = KEYMAP( | 31 | [SYMB] = KEYMAP( |
@@ -90,7 +90,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
90 | 90 | ||
91 | // Runs just one time when the keyboard initializes. | 91 | // Runs just one time when the keyboard initializes. |
92 | void matrix_init_user(void) { | 92 | void matrix_init_user(void) { |
93 | 93 | ||
94 | }; | 94 | }; |
95 | 95 | ||
96 | // Runs constantly in the background, in a loop. | 96 | // Runs constantly in the background, in a loop. |
diff --git a/quantum/keymap.h b/quantum/keymap.h index 98ddfd0c5..41aa11622 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h | |||
@@ -174,6 +174,10 @@ enum quantum_keycodes { | |||
174 | // Right shift, close paren | 174 | // Right shift, close paren |
175 | KC_RSPC, | 175 | KC_RSPC, |
176 | 176 | ||
177 | // Printing | ||
178 | PRINT_ON, | ||
179 | PRINT_OFF, | ||
180 | |||
177 | // always leave at the end | 181 | // always leave at the end |
178 | SAFE_RANGE | 182 | SAFE_RANGE |
179 | }; | 183 | }; |
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c index 401845e85..d38dac4c6 100755 --- a/quantum/light_ws2812.c +++ b/quantum/light_ws2812.c | |||
@@ -16,6 +16,122 @@ | |||
16 | #include <util/delay.h> | 16 | #include <util/delay.h> |
17 | #include "debug.h" | 17 | #include "debug.h" |
18 | 18 | ||
19 | #define RGBW_BB_TWI 1 | ||
20 | |||
21 | #ifdef RGBW_BB_TWI | ||
22 | |||
23 | // Port for the I2C | ||
24 | #define I2C_DDR DDRD | ||
25 | #define I2C_PIN PIND | ||
26 | #define I2C_PORT PORTD | ||
27 | |||
28 | // Pins to be used in the bit banging | ||
29 | #define I2C_CLK 0 | ||
30 | #define I2C_DAT 1 | ||
31 | |||
32 | #define I2C_DATA_HI()\ | ||
33 | I2C_DDR &= ~ (1 << I2C_DAT);\ | ||
34 | I2C_PORT |= (1 << I2C_DAT); | ||
35 | #define I2C_DATA_LO()\ | ||
36 | I2C_DDR |= (1 << I2C_DAT);\ | ||
37 | I2C_PORT &= ~ (1 << I2C_DAT); | ||
38 | |||
39 | #define I2C_CLOCK_HI()\ | ||
40 | I2C_DDR &= ~ (1 << I2C_CLK);\ | ||
41 | I2C_PORT |= (1 << I2C_CLK); | ||
42 | #define I2C_CLOCK_LO()\ | ||
43 | I2C_DDR |= (1 << I2C_CLK);\ | ||
44 | I2C_PORT &= ~ (1 << I2C_CLK); | ||
45 | |||
46 | #define I2C_DELAY 1 | ||
47 | |||
48 | void I2C_WriteBit(unsigned char c) | ||
49 | { | ||
50 | if (c > 0) | ||
51 | { | ||
52 | I2C_DATA_HI(); | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | I2C_DATA_LO(); | ||
57 | } | ||
58 | |||
59 | I2C_CLOCK_HI(); | ||
60 | _delay_us(I2C_DELAY); | ||
61 | |||
62 | I2C_CLOCK_LO(); | ||
63 | _delay_us(I2C_DELAY); | ||
64 | |||
65 | if (c > 0) | ||
66 | { | ||
67 | I2C_DATA_LO(); | ||
68 | } | ||
69 | |||
70 | _delay_us(I2C_DELAY); | ||
71 | } | ||
72 | |||
73 | // Inits bitbanging port, must be called before using the functions below | ||
74 | // | ||
75 | void I2C_Init() | ||
76 | { | ||
77 | I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | ||
78 | |||
79 | I2C_CLOCK_HI(); | ||
80 | I2C_DATA_HI(); | ||
81 | |||
82 | _delay_us(I2C_DELAY); | ||
83 | } | ||
84 | |||
85 | // Send a START Condition | ||
86 | // | ||
87 | void I2C_Start() | ||
88 | { | ||
89 | // set both to high at the same time | ||
90 | I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | ||
91 | _delay_us(I2C_DELAY); | ||
92 | |||
93 | I2C_DATA_LO(); | ||
94 | _delay_us(I2C_DELAY); | ||
95 | |||
96 | I2C_CLOCK_LO(); | ||
97 | _delay_us(I2C_DELAY); | ||
98 | } | ||
99 | |||
100 | // Send a STOP Condition | ||
101 | // | ||
102 | void I2C_Stop() | ||
103 | { | ||
104 | I2C_CLOCK_HI(); | ||
105 | _delay_us(I2C_DELAY); | ||
106 | |||
107 | I2C_DATA_HI(); | ||
108 | _delay_us(I2C_DELAY); | ||
109 | } | ||
110 | |||
111 | // write a byte to the I2C slave device | ||
112 | // | ||
113 | unsigned char I2C_Write(unsigned char c) | ||
114 | { | ||
115 | for (char i = 0; i < 8; i++) | ||
116 | { | ||
117 | I2C_WriteBit(c & 128); | ||
118 | |||
119 | c <<= 1; | ||
120 | } | ||
121 | |||
122 | |||
123 | I2C_WriteBit(0); | ||
124 | _delay_us(I2C_DELAY); | ||
125 | _delay_us(I2C_DELAY); | ||
126 | |||
127 | // _delay_us(I2C_DELAY); | ||
128 | //return I2C_ReadBit(); | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | |||
133 | #endif | ||
134 | |||
19 | // Setleds for standard RGB | 135 | // Setleds for standard RGB |
20 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) | 136 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) |
21 | { | 137 | { |
@@ -41,6 +157,25 @@ void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | |||
41 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); | 157 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); |
42 | 158 | ||
43 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); | 159 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); |
160 | |||
161 | #ifdef RGBW_BB_TWI | ||
162 | cli(); | ||
163 | TWCR = 0; | ||
164 | I2C_Init(); | ||
165 | I2C_Start(); | ||
166 | I2C_Write(0x84); | ||
167 | uint16_t datlen = leds<<2; | ||
168 | uint8_t curbyte; | ||
169 | uint8_t * data = (uint8_t*)ledarray; | ||
170 | while (datlen--) { | ||
171 | curbyte=*data++; | ||
172 | I2C_Write(curbyte % 0x10); | ||
173 | } | ||
174 | I2C_Stop(); | ||
175 | sei(); | ||
176 | #endif | ||
177 | |||
178 | |||
44 | _delay_us(80); | 179 | _delay_us(80); |
45 | } | 180 | } |
46 | 181 | ||
@@ -123,7 +258,7 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi) | |||
123 | cli(); | 258 | cli(); |
124 | 259 | ||
125 | while (datlen--) { | 260 | while (datlen--) { |
126 | curbyte=*data++; | 261 | curbyte=(*data++) % 0x10; |
127 | 262 | ||
128 | asm volatile( | 263 | asm volatile( |
129 | " ldi %0,8 \n\t" | 264 | " ldi %0,8 \n\t" |
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h index 54eef22d9..576c3bc48 100755 --- a/quantum/light_ws2812.h +++ b/quantum/light_ws2812.h | |||
@@ -16,6 +16,13 @@ | |||
16 | #include <avr/io.h> | 16 | #include <avr/io.h> |
17 | #include <avr/interrupt.h> | 17 | #include <avr/interrupt.h> |
18 | //#include "ws2812_config.h" | 18 | //#include "ws2812_config.h" |
19 | #include "i2cmaster.h" | ||
20 | |||
21 | #define LIGHT_I2C 1 | ||
22 | #define LIGHT_I2C_ADDR 0x84 | ||
23 | #define LIGHT_I2C_ADDR_WRITE ( (LIGHT_I2C_ADDR<<1) | I2C_WRITE ) | ||
24 | #define LIGHT_I2C_ADDR_READ ( (LIGHT_I2C_ADDR<<1) | I2C_READ ) | ||
25 | |||
19 | 26 | ||
20 | /* | 27 | /* |
21 | * Structure of the LED array | 28 | * Structure of the LED array |
diff --git a/quantum/quantum.c b/quantum/quantum.c index a16bd5443..5fa5e66b3 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -129,6 +129,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
129 | #ifdef UCIS_ENABLE | 129 | #ifdef UCIS_ENABLE |
130 | process_ucis(keycode, record) && | 130 | process_ucis(keycode, record) && |
131 | #endif | 131 | #endif |
132 | #ifdef PRINTING_ENABLE | ||
133 | process_printer(keycode, record) && | ||
134 | #endif | ||
132 | true)) { | 135 | true)) { |
133 | return false; | 136 | return false; |
134 | } | 137 | } |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 0c6046649..06a2e049d 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -59,6 +59,10 @@ extern uint32_t default_layer_state; | |||
59 | 59 | ||
60 | #include "process_tap_dance.h" | 60 | #include "process_tap_dance.h" |
61 | 61 | ||
62 | #ifdef PRINTING_ENABLE | ||
63 | #include "process_printer.h" | ||
64 | #endif | ||
65 | |||
62 | #define SEND_STRING(str) send_string(PSTR(str)) | 66 | #define SEND_STRING(str) send_string(PSTR(str)) |
63 | void send_string(const char *str); | 67 | void send_string(const char *str); |
64 | 68 | ||