summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build_keyboard.mk6
-rw-r--r--keyboards/ergodox/keymaps/jack/config.h2
-rw-r--r--keyboards/ergodox/keymaps/jack/keymap.c4
-rw-r--r--quantum/keymap.h4
-rwxr-xr-xquantum/light_ws2812.c137
-rwxr-xr-xquantum/light_ws2812.h7
-rw-r--r--quantum/quantum.c3
-rw-r--r--quantum/quantum.h4
8 files changed, 163 insertions, 4 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk
index 03a69b1464..cd9f44c7bd 100644
--- a/build_keyboard.mk
+++ b/build_keyboard.mk
@@ -169,6 +169,12 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
endif
+ifeq ($(strip $(PRINTING_ENABLE)), yes)
+ OPT_DEFS += -DPRINTING_ENABLE
+ SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
+ SRC += $(TMK_DIR)/protocol/serial_uart.c
+endif
+
ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
OPT_DEFS += $(SERIAL_DEFS)
diff --git a/keyboards/ergodox/keymaps/jack/config.h b/keyboards/ergodox/keymaps/jack/config.h
index 01ccfb3a2a..f0932084a0 100644
--- a/keyboards/ergodox/keymaps/jack/config.h
+++ b/keyboards/ergodox/keymaps/jack/config.h
@@ -6,7 +6,7 @@
/* ws2812 RGB LED */
#define RGB_DI_PIN D7
// #define RGBLIGHT_TIMER
-#define RGBLED_NUM 20 // Number of LEDs
+#define RGBLED_NUM 15 // Number of LEDs
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
diff --git a/keyboards/ergodox/keymaps/jack/keymap.c b/keyboards/ergodox/keymaps/jack/keymap.c
index 1dd5a76187..fabd27a618 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] = {
KC_NO, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_ENT,
MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT,
RGB_TOG, RGB_HUI,
- KC_PGUP,
+ RGB_MOD,
KC_PGDN, KC_SPC,KC_SPC
),
[SYMB] = KEYMAP(
@@ -90,7 +90,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
-
+
};
// Runs constantly in the background, in a loop.
diff --git a/quantum/keymap.h b/quantum/keymap.h
index 98ddfd0c53..41aa116228 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -174,6 +174,10 @@ enum quantum_keycodes {
// Right shift, close paren
KC_RSPC,
+ // Printing
+ PRINT_ON,
+ PRINT_OFF,
+
// always leave at the end
SAFE_RANGE
};
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c
index 401845e855..d38dac4c69 100755
--- a/quantum/light_ws2812.c
+++ b/quantum/light_ws2812.c
@@ -16,6 +16,122 @@
#include <util/delay.h>
#include "debug.h"
+#define RGBW_BB_TWI 1
+
+#ifdef RGBW_BB_TWI
+
+// Port for the I2C
+#define I2C_DDR DDRD
+#define I2C_PIN PIND
+#define I2C_PORT PORTD
+
+// Pins to be used in the bit banging
+#define I2C_CLK 0
+#define I2C_DAT 1
+
+#define I2C_DATA_HI()\
+I2C_DDR &= ~ (1 << I2C_DAT);\
+I2C_PORT |= (1 << I2C_DAT);
+#define I2C_DATA_LO()\
+I2C_DDR |= (1 << I2C_DAT);\
+I2C_PORT &= ~ (1 << I2C_DAT);
+
+#define I2C_CLOCK_HI()\
+I2C_DDR &= ~ (1 << I2C_CLK);\
+I2C_PORT |= (1 << I2C_CLK);
+#define I2C_CLOCK_LO()\
+I2C_DDR |= (1 << I2C_CLK);\
+I2C_PORT &= ~ (1 << I2C_CLK);
+
+#define I2C_DELAY 1
+
+void I2C_WriteBit(unsigned char c)
+{
+ if (c > 0)
+ {
+ I2C_DATA_HI();
+ }
+ else
+ {
+ I2C_DATA_LO();
+ }
+
+ I2C_CLOCK_HI();
+ _delay_us(I2C_DELAY);
+
+ I2C_CLOCK_LO();
+ _delay_us(I2C_DELAY);
+
+ if (c > 0)
+ {
+ I2C_DATA_LO();
+ }
+
+ _delay_us(I2C_DELAY);
+}
+
+// Inits bitbanging port, must be called before using the functions below
+//
+void I2C_Init()
+{
+ I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));
+
+ I2C_CLOCK_HI();
+ I2C_DATA_HI();
+
+ _delay_us(I2C_DELAY);
+}
+
+// Send a START Condition
+//
+void I2C_Start()
+{
+ // set both to high at the same time
+ I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));
+ _delay_us(I2C_DELAY);
+
+ I2C_DATA_LO();
+ _delay_us(I2C_DELAY);
+
+ I2C_CLOCK_LO();
+ _delay_us(I2C_DELAY);
+}
+
+// Send a STOP Condition
+//
+void I2C_Stop()
+{
+ I2C_CLOCK_HI();
+ _delay_us(I2C_DELAY);
+
+ I2C_DATA_HI();
+ _delay_us(I2C_DELAY);
+}
+
+// write a byte to the I2C slave device
+//
+unsigned char I2C_Write(unsigned char c)
+{
+ for (char i = 0; i < 8; i++)
+ {
+ I2C_WriteBit(c & 128);
+
+ c <<= 1;
+ }
+
+
+ I2C_WriteBit(0);
+ _delay_us(I2C_DELAY);
+ _delay_us(I2C_DELAY);
+
+ // _delay_us(I2C_DELAY);
+ //return I2C_ReadBit();
+ return 0;
+}
+
+
+#endif
+
// Setleds for standard RGB
void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds)
{
@@ -41,6 +157,25 @@ void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds)
_SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF));
+
+ #ifdef RGBW_BB_TWI
+ cli();
+ TWCR = 0;
+ I2C_Init();
+ I2C_Start();
+ I2C_Write(0x84);
+ uint16_t datlen = leds<<2;
+ uint8_t curbyte;
+ uint8_t * data = (uint8_t*)ledarray;
+ while (datlen--) {
+ curbyte=*data++;
+ I2C_Write(curbyte % 0x10);
+ }
+ I2C_Stop();
+ sei();
+ #endif
+
+
_delay_us(80);
}
@@ -123,7 +258,7 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
cli();
while (datlen--) {
- curbyte=*data++;
+ curbyte=(*data++) % 0x10;
asm volatile(
" ldi %0,8 \n\t"
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h
index 54eef22d9e..576c3bc483 100755
--- a/quantum/light_ws2812.h
+++ b/quantum/light_ws2812.h
@@ -16,6 +16,13 @@
#include <avr/io.h>
#include <avr/interrupt.h>
//#include "ws2812_config.h"
+#include "i2cmaster.h"
+
+#define LIGHT_I2C 1
+#define LIGHT_I2C_ADDR 0x84
+#define LIGHT_I2C_ADDR_WRITE ( (LIGHT_I2C_ADDR<<1) | I2C_WRITE )
+#define LIGHT_I2C_ADDR_READ ( (LIGHT_I2C_ADDR<<1) | I2C_READ )
+
/*
* Structure of the LED array
diff --git a/quantum/quantum.c b/quantum/quantum.c
index a16bd5443c..5fa5e66b32 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -129,6 +129,9 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef UCIS_ENABLE
process_ucis(keycode, record) &&
#endif
+ #ifdef PRINTING_ENABLE
+ process_printer(keycode, record) &&
+ #endif
true)) {
return false;
}
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 0c60466495..06a2e049dc 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -59,6 +59,10 @@ extern uint32_t default_layer_state;
#include "process_tap_dance.h"
+#ifdef PRINTING_ENABLE
+ #include "process_printer.h"
+#endif
+
#define SEND_STRING(str) send_string(PSTR(str))
void send_string(const char *str);