working with power limit
This commit is contained in:
parent
b8679bbe04
commit
5f91fb4136
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -128,6 +128,9 @@ bool process_record_quantum(keyrecord_t *record) {
|
|||
#endif
|
||||
#ifdef UCIS_ENABLE
|
||||
process_ucis(keycode, record) &&
|
||||
#endif
|
||||
#ifdef PRINTING_ENABLE
|
||||
process_printer(keycode, record) &&
|
||||
#endif
|
||||
true)) {
|
||||
return false;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue