working with power limit

master
Jack Humbert 2016-10-16 16:03:33 -04:00
parent b8679bbe04
commit 5f91fb4136
8 changed files with 163 additions and 4 deletions

View File

@ -169,6 +169,12 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
endif 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) ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
OPT_DEFS += $(SERIAL_DEFS) OPT_DEFS += $(SERIAL_DEFS)

View File

@ -6,7 +6,7 @@
/* ws2812 RGB LED */ /* ws2812 RGB LED */
#define RGB_DI_PIN D7 #define RGB_DI_PIN D7
// #define RGBLIGHT_TIMER // #define RGBLIGHT_TIMER
#define RGBLED_NUM 20 // Number of LEDs #define RGBLED_NUM 15 // Number of LEDs
#define RGBLIGHT_HUE_STEP 8 #define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8 #define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8 #define RGBLIGHT_VAL_STEP 8

View File

@ -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, KC_NO, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_ENT,
MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT, MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT,
RGB_TOG, RGB_HUI, RGB_TOG, RGB_HUI,
KC_PGUP, RGB_MOD,
KC_PGDN, KC_SPC,KC_SPC KC_PGDN, KC_SPC,KC_SPC
), ),
[SYMB] = KEYMAP( [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. // Runs just one time when the keyboard initializes.
void matrix_init_user(void) { void matrix_init_user(void) {
}; };
// Runs constantly in the background, in a loop. // Runs constantly in the background, in a loop.

View File

@ -174,6 +174,10 @@ enum quantum_keycodes {
// Right shift, close paren // Right shift, close paren
KC_RSPC, KC_RSPC,
// Printing
PRINT_ON,
PRINT_OFF,
// always leave at the end // always leave at the end
SAFE_RANGE SAFE_RANGE
}; };

View File

@ -16,6 +16,122 @@
#include <util/delay.h> #include <util/delay.h>
#include "debug.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 // Setleds for standard RGB
void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) 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); _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)); 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); _delay_us(80);
} }
@ -123,7 +258,7 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
cli(); cli();
while (datlen--) { while (datlen--) {
curbyte=*data++; curbyte=(*data++) % 0x10;
asm volatile( asm volatile(
" ldi %0,8 \n\t" " ldi %0,8 \n\t"

View File

@ -16,6 +16,13 @@
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
//#include "ws2812_config.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 * Structure of the LED array

View File

@ -128,6 +128,9 @@ bool process_record_quantum(keyrecord_t *record) {
#endif #endif
#ifdef UCIS_ENABLE #ifdef UCIS_ENABLE
process_ucis(keycode, record) && process_ucis(keycode, record) &&
#endif
#ifdef PRINTING_ENABLE
process_printer(keycode, record) &&
#endif #endif
true)) { true)) {
return false; return false;

View File

@ -59,6 +59,10 @@ extern uint32_t default_layer_state;
#include "process_tap_dance.h" #include "process_tap_dance.h"
#ifdef PRINTING_ENABLE
#include "process_printer.h"
#endif
#define SEND_STRING(str) send_string(PSTR(str)) #define SEND_STRING(str) send_string(PSTR(str))
void send_string(const char *str); void send_string(const char *str);