Remove custom ISSI lighting code (#22073)
* Remove CU75 custom lighting * Remove LFK78 custom lighting * Remove LFK87 custom lighting * Remove LFKPad custom lighting * Remove Mini1800 custom lighting * Remove SMK65 custom lighting * Remove LFK65-HS custom lighting * Remove LFKeyboards custom lighting * Remove Meira custom lighting
This commit is contained in:
parent
9c340077f6
commit
6424dadd37
98 changed files with 16 additions and 2929 deletions
|
@ -17,8 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#pragma once
|
||||
|
||||
#define BACKLIGHT_PWM_MAP {8, 16, 40, 55, 70, 128, 200, 255}
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
#include <avr/sfr_defs.h>
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "cu75.h"
|
||||
#include "debug.h"
|
||||
#include "../lfkeyboards/issi.h"
|
||||
#include "../lfkeyboards/TWIlib.h"
|
||||
#include "../lfkeyboards/lighting.h"
|
||||
#include <avr/wdt.h>
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float test_sound[][2] = SONG(STARTUP_SOUND);
|
||||
#include "audio.h"
|
||||
#endif
|
||||
|
||||
uint16_t click_hz = CLICK_HZ;
|
||||
|
@ -34,39 +27,12 @@ void matrix_init_kb(void)
|
|||
setPinOutput(C6);
|
||||
writePinLow(C6);
|
||||
#endif
|
||||
#ifdef ISSI_ENABLE
|
||||
issi_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void matrix_scan_kb(void)
|
||||
{
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
wdt_reset();
|
||||
#endif
|
||||
#ifdef ISSI_ENABLE
|
||||
// switch/underglow lighting update
|
||||
static uint32_t issi_device = 0;
|
||||
static uint32_t twi_last_ready = 0;
|
||||
if(twi_last_ready > 1000){
|
||||
// Its been way too long since the last ISSI update, reset the I2C bus and start again
|
||||
dprintf("TWI failed to recover, TWI re-init\n");
|
||||
twi_last_ready = 0;
|
||||
TWIInit();
|
||||
force_issi_refresh();
|
||||
}
|
||||
if(isTWIReady()){
|
||||
twi_last_ready = 0;
|
||||
// If the i2c bus is available, kick off the issi update, alternate between devices
|
||||
update_issi(issi_device, issi_device);
|
||||
if(issi_device){
|
||||
issi_device = 0;
|
||||
}else{
|
||||
issi_device = 3;
|
||||
}
|
||||
}else{
|
||||
twi_last_ready++;
|
||||
}
|
||||
#endif
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
@ -92,7 +58,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record)
|
|||
}
|
||||
if (keycode == QK_BOOT) {
|
||||
reset_keyboard_kb();
|
||||
} else {
|
||||
}
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
|
@ -105,11 +70,3 @@ void reset_keyboard_kb(void){
|
|||
#endif
|
||||
reset_keyboard();
|
||||
}
|
||||
|
||||
// LFK lighting info
|
||||
const uint8_t switch_matrices[] = {0, 1};
|
||||
const uint8_t rgb_matrices[] = {6, 7};
|
||||
const uint8_t rgb_sequence[] = {
|
||||
24, 23, 22, 21, 20, 19, 18, 17, 1, 2, 3, 4, 5,
|
||||
6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 9
|
||||
};
|
||||
|
|
|
@ -1,23 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "matrix.h"
|
||||
#include <avr/sfr_defs.h>
|
||||
|
||||
typedef struct RGB_Color {
|
||||
uint16_t red;
|
||||
uint16_t green;
|
||||
uint16_t blue;
|
||||
} RGB_Color;
|
||||
|
||||
typedef struct Layer_Info {
|
||||
uint32_t layer;
|
||||
uint32_t mask;
|
||||
RGB_Color color;
|
||||
} Layer_Info;
|
||||
|
||||
extern const uint32_t layer_count;
|
||||
extern const Layer_Info layer_info[];
|
||||
|
||||
#define CLICK_HZ 500
|
||||
#define CLICK_MS 2
|
||||
|
|
|
@ -13,30 +13,6 @@
|
|||
"rows": ["F1", "B7", "B3", "D2", "D3", "B2"]
|
||||
},
|
||||
"diode_direction": "COL2ROW",
|
||||
"backlight": {
|
||||
"driver": "custom",
|
||||
"levels": 8
|
||||
},
|
||||
"rgblight": {
|
||||
"driver": "custom",
|
||||
"hue_steps": 10,
|
||||
"led_count": 24,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "C7"
|
||||
},
|
||||
"processor": "atmega32u4",
|
||||
"bootloader": "atmel-dfu",
|
||||
"layouts": {
|
||||
|
|
|
@ -4,10 +4,5 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
|
|||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = yes # Disable keyboard backlight functionality
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
RGBLIGHT_ENABLE = yes # Disable RGB underlight
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
|
|
@ -4,10 +4,5 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
|||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes
|
||||
# BACKLIGHT_ENABLE = no # Disable keyboard backlight functionality
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
RGBLIGHT_ENABLE = no # Disable RGB underlight
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = no # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = yes # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
ifeq ($(strip $(ISSI_ENABLE)), yes)
|
||||
OPT_DEFS += -DISSI_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
|
||||
OPT_DEFS += -DWATCHDOG_ENABLE
|
||||
endif
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
# TODO: These boards need to be converted to RGB Matrix
|
||||
VPATH += keyboards/lfkeyboards
|
||||
SRC = TWIlib.c issi.c lighting.c
|
|
@ -1,296 +0,0 @@
|
|||
/*
|
||||
* TWIlib.c
|
||||
*
|
||||
* Created: 6/01/2014 10:41:33 PM
|
||||
* Author: Chris Herring
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "TWIlib.h"
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
|
||||
// Global transmit buffer
|
||||
volatile uint8_t *TWITransmitBuffer;
|
||||
// Global receive buffer
|
||||
volatile uint8_t TWIReceiveBuffer[RXMAXBUFLEN];
|
||||
// Buffer indexes
|
||||
volatile int TXBuffIndex; // Index of the transmit buffer. Is volatile, can change at any time.
|
||||
int RXBuffIndex; // Current index in the receive buffer
|
||||
// Buffer lengths
|
||||
int TXBuffLen; // The total length of the transmit buffer
|
||||
int RXBuffLen; // The total number of bytes to read (should be less than RXMAXBUFFLEN)
|
||||
|
||||
TWIInfoStruct TWIInfo;
|
||||
|
||||
void TWIInit(void)
|
||||
{
|
||||
TWIInfo.mode = Ready;
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWIInfo.repStart = 0;
|
||||
// Set pre-scalers (no pre-scaling)
|
||||
TWSR = 0;
|
||||
// Set bit rate
|
||||
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
|
||||
// Enable TWI and interrupt
|
||||
TWCR = (1 << TWIE) | (1 << TWEN);
|
||||
}
|
||||
|
||||
uint8_t isTWIReady(void)
|
||||
{
|
||||
if ( (TWIInfo.mode == Ready) | (TWIInfo.mode == RepeatedStartSent) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(TWIInfo.mode == Initializing){
|
||||
switch(TWIInfo.errorCode){
|
||||
case TWI_SUCCESS:
|
||||
case TWI_NO_RELEVANT_INFO:
|
||||
break;
|
||||
case TWI_LOST_ARBIT:
|
||||
case TWI_MT_DATA_NACK:
|
||||
// Some kind of I2C error, reset and re-init
|
||||
xprintf("I2C init error: %d\n", TWIInfo.errorCode);
|
||||
TWCR = (1 << TWINT)|(1 << TWSTO);
|
||||
TWIInit();
|
||||
break;
|
||||
default:
|
||||
xprintf("Other i2c init error: %d\n", TWIInfo.errorCode);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart, uint8_t blocking)
|
||||
{
|
||||
// Wait until ready
|
||||
while (!isTWIReady()) {_delay_us(1);}
|
||||
// Reset the I2C stuff
|
||||
TWCR = (1 << TWINT)|(1 << TWSTO);
|
||||
TWIInit();
|
||||
// Set repeated start mode
|
||||
TWIInfo.repStart = repStart;
|
||||
// Copy transmit info to global variables
|
||||
TWITransmitBuffer = (uint8_t *)TXdata;
|
||||
TXBuffLen = dataLen;
|
||||
TXBuffIndex = 0;
|
||||
|
||||
// If a repeated start has been sent, then devices are already listening for an address
|
||||
// and another start does not need to be sent.
|
||||
if (TWIInfo.mode == RepeatedStartSent)
|
||||
{
|
||||
TWIInfo.mode = Initializing;
|
||||
TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
|
||||
TWISendTransmit(); // Send the data
|
||||
}
|
||||
else // Otherwise, just send the normal start signal to begin transmission.
|
||||
{
|
||||
TWIInfo.mode = Initializing;
|
||||
TWISendStart();
|
||||
}
|
||||
if(blocking){
|
||||
// Wait until ready
|
||||
while (!isTWIReady()){_delay_us(1);}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// uint8_t TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart)
|
||||
// {
|
||||
// if (dataLen <= TXMAXBUFLEN)
|
||||
// {
|
||||
// // Wait until ready
|
||||
// while (!isTWIReady()) {_delay_us(1);}
|
||||
// // Set repeated start mode
|
||||
// TWIInfo.repStart = repStart;
|
||||
// // Copy data into the transmit buffer
|
||||
// uint8_t *data = (uint8_t *)TXdata;
|
||||
// for (int i = 0; i < dataLen; i++)
|
||||
// {
|
||||
// TWITransmitBuffer[i] = data[i];
|
||||
// }
|
||||
// // Copy transmit info to global variables
|
||||
// TXBuffLen = dataLen;
|
||||
// TXBuffIndex = 0;
|
||||
|
||||
// // If a repeated start has been sent, then devices are already listening for an address
|
||||
// // and another start does not need to be sent.
|
||||
// if (TWIInfo.mode == RepeatedStartSent)
|
||||
// {
|
||||
// TWIInfo.mode = Initializing;
|
||||
// TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
|
||||
// TWISendTransmit(); // Send the data
|
||||
// }
|
||||
// else // Otherwise, just send the normal start signal to begin transmission.
|
||||
// {
|
||||
// TWIInfo.mode = Initializing;
|
||||
// TWISendStart();
|
||||
// }
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 1; // return an error if data length is longer than buffer
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
uint8_t TWIReadData(uint8_t TWIaddr, uint8_t bytesToRead, uint8_t repStart)
|
||||
{
|
||||
// Check if number of bytes to read can fit in the RXbuffer
|
||||
if (bytesToRead < RXMAXBUFLEN)
|
||||
{
|
||||
// Reset buffer index and set RXBuffLen to the number of bytes to read
|
||||
RXBuffIndex = 0;
|
||||
RXBuffLen = bytesToRead;
|
||||
// Create the one value array for the address to be transmitted
|
||||
uint8_t TXdata[1];
|
||||
// Shift the address and AND a 1 into the read write bit (set to write mode)
|
||||
TXdata[0] = (TWIaddr << 1) | 0x01;
|
||||
// Use the TWITransmitData function to initialize the transfer and address the slave
|
||||
TWITransmitData(TXdata, 1, repStart, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
ISR (TWI_vect)
|
||||
{
|
||||
switch (TWI_STATUS)
|
||||
{
|
||||
// ----\/ ---- MASTER TRANSMITTER OR WRITING ADDRESS ----\/ ---- //
|
||||
case TWI_MT_SLAW_ACK: // SLA+W transmitted and ACK received
|
||||
// Set mode to Master Transmitter
|
||||
TWIInfo.mode = MasterTransmitter;
|
||||
case TWI_START_SENT: // Start condition has been transmitted
|
||||
case TWI_MT_DATA_ACK: // Data byte has been transmitted, ACK received
|
||||
if (TXBuffIndex < TXBuffLen) // If there is more data to send
|
||||
{
|
||||
TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendTransmit(); // Send the data
|
||||
}
|
||||
// This transmission is complete however do not release bus yet
|
||||
else if (TWIInfo.repStart)
|
||||
{
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWISendStart();
|
||||
}
|
||||
// All transmissions are complete, exit
|
||||
else
|
||||
{
|
||||
TWIInfo.mode = Ready;
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWISendStop();
|
||||
}
|
||||
break;
|
||||
|
||||
// ----\/ ---- MASTER RECEIVER ----\/ ---- //
|
||||
|
||||
case TWI_MR_SLAR_ACK: // SLA+R has been transmitted, ACK has been received
|
||||
// Switch to Master Receiver mode
|
||||
TWIInfo.mode = MasterReceiver;
|
||||
// If there is more than one byte to be read, receive data byte and return an ACK
|
||||
if (RXBuffIndex < RXBuffLen-1)
|
||||
{
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendACK();
|
||||
}
|
||||
// Otherwise when a data byte (the only data byte) is received, return NACK
|
||||
else
|
||||
{
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendNACK();
|
||||
}
|
||||
break;
|
||||
|
||||
case TWI_MR_DATA_ACK: // Data has been received, ACK has been transmitted.
|
||||
|
||||
/// -- HANDLE DATA BYTE --- ///
|
||||
TWIReceiveBuffer[RXBuffIndex++] = TWDR;
|
||||
// If there is more than one byte to be read, receive data byte and return an ACK
|
||||
if (RXBuffIndex < RXBuffLen-1)
|
||||
{
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendACK();
|
||||
}
|
||||
// Otherwise when a data byte (the only data byte) is received, return NACK
|
||||
else
|
||||
{
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendNACK();
|
||||
}
|
||||
break;
|
||||
|
||||
case TWI_MR_DATA_NACK: // Data byte has been received, NACK has been transmitted. End of transmission.
|
||||
|
||||
/// -- HANDLE DATA BYTE --- ///
|
||||
TWIReceiveBuffer[RXBuffIndex++] = TWDR;
|
||||
// This transmission is complete however do not release bus yet
|
||||
if (TWIInfo.repStart)
|
||||
{
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWISendStart();
|
||||
}
|
||||
// All transmissions are complete, exit
|
||||
else
|
||||
{
|
||||
TWIInfo.mode = Ready;
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWISendStop();
|
||||
}
|
||||
break;
|
||||
|
||||
// ----\/ ---- MT and MR common ----\/ ---- //
|
||||
|
||||
case TWI_MR_SLAR_NACK: // SLA+R transmitted, NACK received
|
||||
case TWI_MT_SLAW_NACK: // SLA+W transmitted, NACK received
|
||||
case TWI_MT_DATA_NACK: // Data byte has been transmitted, NACK received
|
||||
case TWI_LOST_ARBIT: // Arbitration has been lost
|
||||
// Return error and send stop and set mode to ready
|
||||
if (TWIInfo.repStart)
|
||||
{
|
||||
TWIInfo.errorCode = TWI_STATUS;
|
||||
TWISendStart();
|
||||
}
|
||||
// All transmissions are complete, exit
|
||||
else
|
||||
{
|
||||
TWIInfo.mode = Ready;
|
||||
TWIInfo.errorCode = TWI_STATUS;
|
||||
TWISendStop();
|
||||
}
|
||||
break;
|
||||
case TWI_REP_START_SENT: // Repeated start has been transmitted
|
||||
// Set the mode but DO NOT clear TWINT as the next data is not yet ready
|
||||
TWIInfo.mode = RepeatedStartSent;
|
||||
break;
|
||||
|
||||
// ----\/ ---- SLAVE RECEIVER ----\/ ---- //
|
||||
|
||||
// TODO IMPLEMENT SLAVE RECEIVER FUNCTIONALITY
|
||||
|
||||
// ----\/ ---- SLAVE TRANSMITTER ----\/ ---- //
|
||||
|
||||
// TODO IMPLEMENT SLAVE TRANSMITTER FUNCTIONALITY
|
||||
|
||||
// ----\/ ---- MISCELLANEOUS STATES ----\/ ---- //
|
||||
case TWI_NO_RELEVANT_INFO: // It is not really possible to get into this ISR on this condition
|
||||
// Rather, it is there to be manually set between operations
|
||||
break;
|
||||
case TWI_ILLEGAL_START_STOP: // Illegal START/STOP, abort and return error
|
||||
TWIInfo.errorCode = TWI_ILLEGAL_START_STOP;
|
||||
TWIInfo.mode = Ready;
|
||||
TWISendStop();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* TWIlib.h
|
||||
*
|
||||
* Created: 6/01/2014 10:38:42 PM
|
||||
* Author: Chris Herring
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TWILIB_H_
|
||||
#define TWILIB_H_
|
||||
// TWI bit rate
|
||||
#define TWI_FREQ 400000
|
||||
// Get TWI status
|
||||
#define TWI_STATUS (TWSR & 0xF8)
|
||||
// Transmit buffer length
|
||||
#define TXMAXBUFLEN 20
|
||||
// Receive buffer length
|
||||
#define RXMAXBUFLEN 20
|
||||
|
||||
typedef enum {
|
||||
Ready,
|
||||
Initializing,
|
||||
RepeatedStartSent,
|
||||
MasterTransmitter,
|
||||
MasterReceiver,
|
||||
SlaceTransmitter,
|
||||
SlaveReciever
|
||||
} TWIMode;
|
||||
|
||||
typedef struct TWIInfoStruct{
|
||||
TWIMode mode;
|
||||
uint8_t errorCode;
|
||||
uint8_t repStart;
|
||||
}TWIInfoStruct;
|
||||
|
||||
extern TWIInfoStruct TWIInfo;
|
||||
|
||||
// TWI Status Codes
|
||||
#define TWI_START_SENT 0x08 // Start sent
|
||||
#define TWI_REP_START_SENT 0x10 // Repeated Start sent
|
||||
// Master Transmitter Mode
|
||||
#define TWI_MT_SLAW_ACK 0x18 // SLA+W sent and ACK received
|
||||
#define TWI_MT_SLAW_NACK 0x20 // SLA+W sent and NACK received
|
||||
#define TWI_MT_DATA_ACK 0x28 // DATA sent and ACK received
|
||||
#define TWI_MT_DATA_NACK 0x30 // DATA sent and NACK received
|
||||
// Master Receiver Mode
|
||||
#define TWI_MR_SLAR_ACK 0x40 // SLA+R sent, ACK received
|
||||
#define TWI_MR_SLAR_NACK 0x48 // SLA+R sent, NACK received
|
||||
#define TWI_MR_DATA_ACK 0x50 // Data received, ACK returned
|
||||
#define TWI_MR_DATA_NACK 0x58 // Data received, NACK returned
|
||||
|
||||
// Miscellaneous States
|
||||
#define TWI_LOST_ARBIT 0x38 // Arbitration has been lost
|
||||
#define TWI_NO_RELEVANT_INFO 0xF8 // No relevant information available
|
||||
#define TWI_ILLEGAL_START_STOP 0x00 // Illegal START or STOP condition has been detected
|
||||
#define TWI_SUCCESS 0xFF // Successful transfer, this state is impossible from TWSR as bit2 is 0 and read only
|
||||
|
||||
|
||||
#define TWISendStart() (TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE)) // Send the START signal, enable interrupts and TWI, clear TWINT flag to resume transfer.
|
||||
#define TWISendStop() (TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN)|(1<<TWIE)) // Send the STOP signal, enable interrupts and TWI, clear TWINT flag.
|
||||
#define TWISendTransmit() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)) // Used to resume a transfer, clear TWINT and ensure that TWI and interrupts are enabled.
|
||||
#define TWISendACK() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)|(1<<TWEA)) // FOR MR mode. Resume a transfer, ensure that TWI and interrupts are enabled and respond with an ACK if the device is addressed as a slave or after it receives a byte.
|
||||
#define TWISendNACK() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)) // FOR MR mode. Resume a transfer, ensure that TWI and interrupts are enabled but DO NOT respond with an ACK if the device is addressed as a slave or after it receives a byte.
|
||||
|
||||
// Function declarations
|
||||
void TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart, uint8_t blocking);
|
||||
void TWIInit(void);
|
||||
uint8_t TWIReadData(uint8_t TWIaddr, uint8_t bytesToRead, uint8_t repStart);
|
||||
uint8_t isTWIReady(void);
|
||||
|
||||
#endif // TWICOMMS_H_
|
|
@ -1,244 +0,0 @@
|
|||
#ifdef ISSI_ENABLE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/sfr_defs.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/twi.h>
|
||||
#include "issi.h"
|
||||
#include "print.h"
|
||||
#include "TWIlib.h"
|
||||
|
||||
#define ISSI_ADDR_DEFAULT 0xE8
|
||||
|
||||
#define ISSI_REG_CONFIG 0x00
|
||||
#define ISSI_REG_CONFIG_PICTUREMODE 0x00
|
||||
#define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08
|
||||
|
||||
#define ISSI_CONF_PICTUREMODE 0x00
|
||||
#define ISSI_CONF_AUTOFRAMEMODE 0x04
|
||||
#define ISSI_CONF_AUDIOMODE 0x08
|
||||
|
||||
#define ISSI_REG_PICTUREFRAME 0x01
|
||||
|
||||
#define ISSI_REG_SHUTDOWN 0x0A
|
||||
#define ISSI_REG_AUDIOSYNC 0x06
|
||||
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
|
||||
uint8_t control[8][9] = {
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
};
|
||||
ISSIDeviceStruct *issi_devices[4] = {0, 0, 0, 0};
|
||||
|
||||
#ifndef cbi
|
||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||
#endif
|
||||
|
||||
#ifndef sbi
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
#define I2C_WRITE 0
|
||||
#define F_SCL 400000UL // SCL frequency
|
||||
#define Prescaler 1
|
||||
#define TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16 ) / 2)
|
||||
|
||||
uint8_t i2c_start(uint8_t address)
|
||||
{
|
||||
// reset TWI control register
|
||||
TWCR = 0;
|
||||
// transmit START condition
|
||||
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
|
||||
// wait for end of transmission
|
||||
while( !(TWCR & (1<<TWINT)) );
|
||||
|
||||
// check if the start condition was successfully transmitted
|
||||
if((TWSR & 0xF8) != TW_START){ return 1; }
|
||||
|
||||
// load slave address into data register
|
||||
TWDR = address;
|
||||
// start transmission of address
|
||||
TWCR = (1<<TWINT) | (1<<TWEN);
|
||||
// wait for end of transmission
|
||||
while( !(TWCR & (1<<TWINT)) );
|
||||
|
||||
// check if the device has acknowledged the READ / WRITE mode
|
||||
uint8_t twst = TW_STATUS & 0xF8;
|
||||
if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t i2c_write(uint8_t data)
|
||||
{
|
||||
// load data into data register
|
||||
TWDR = data;
|
||||
// start transmission of data
|
||||
TWCR = (1 << TWINT) | (1 << TWEN);
|
||||
// wait for end of transmission
|
||||
while (!(TWCR & (1 << TWINT)))
|
||||
;
|
||||
|
||||
if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length)
|
||||
{
|
||||
TWBR = (uint8_t)TWBR_val;
|
||||
if (i2c_start(address | I2C_WRITE))
|
||||
return 1;
|
||||
for (uint16_t i = 0; i < length; i++) {
|
||||
if (i2c_write(data[i]))
|
||||
return 1;
|
||||
}
|
||||
// transmit STOP condition
|
||||
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setFrame(uint8_t device, uint8_t frame)
|
||||
{
|
||||
static uint8_t current_frame = -1;
|
||||
if(current_frame != frame){
|
||||
uint8_t payload[] = {
|
||||
ISSI_ADDR_DEFAULT | device << 1,
|
||||
ISSI_COMMANDREGISTER,
|
||||
frame
|
||||
};
|
||||
TWITransmitData(payload, sizeof(payload), 0, 1);
|
||||
}
|
||||
// static uint8_t current_frame = 0xFF;
|
||||
// if(current_frame == frame){
|
||||
// // return;
|
||||
// }
|
||||
// uint8_t payload[2] = { ISSI_COMMANDREGISTER, frame };
|
||||
// i2c_transmit(ISSI_ADDR_DEFAULT | device << 1, payload, 2);
|
||||
// current_frame = frame;
|
||||
}
|
||||
|
||||
void writeRegister8(uint8_t device, uint8_t frame, uint8_t reg, uint8_t data)
|
||||
{
|
||||
// Set the frame
|
||||
setFrame(device, frame);
|
||||
|
||||
// Write to the register
|
||||
uint8_t payload[] = {
|
||||
ISSI_ADDR_DEFAULT | device << 1,
|
||||
reg,
|
||||
data
|
||||
};
|
||||
TWITransmitData(payload, sizeof(payload), 0, 1);
|
||||
}
|
||||
|
||||
void activateLED(uint8_t matrix, uint8_t cx, uint8_t cy, uint8_t pwm)
|
||||
{
|
||||
uint8_t device_addr = (matrix & 0x06) >> 1;
|
||||
ISSIDeviceStruct *device = issi_devices[device_addr];
|
||||
if(device == 0){
|
||||
return;
|
||||
}
|
||||
// xprintf("activeLED: %02X %02X %02X %02X\n", matrix, cy, cx, pwm);
|
||||
uint8_t x = cx - 1; // funciton takes 1 based counts, but we need 0...
|
||||
uint8_t y = cy - 1; // creating them once for less confusion
|
||||
uint8_t control_reg = (y << 1) | (matrix & 0x01);
|
||||
if(pwm == 0){
|
||||
cbi(device->led_ctrl[control_reg], x);
|
||||
cbi(device->led_blink_ctrl[control_reg], x);
|
||||
}else{
|
||||
sbi(device->led_ctrl[control_reg], x);
|
||||
sbi(device->led_blink_ctrl[control_reg], x);
|
||||
}
|
||||
uint8_t pwm_reg = 0;
|
||||
switch(matrix & 0x01){
|
||||
case 0:
|
||||
pwm_reg = 0x00;
|
||||
break;
|
||||
case 1:
|
||||
pwm_reg = 0x08;
|
||||
break;
|
||||
}
|
||||
pwm_reg += (y << 4) + x;
|
||||
device->led_pwm[pwm_reg] = pwm;
|
||||
device->led_dirty = 1;
|
||||
}
|
||||
|
||||
void update_issi(uint8_t device_addr, uint8_t blocking)
|
||||
{
|
||||
// This seems to take about 6ms
|
||||
ISSIDeviceStruct *device = issi_devices[device_addr];
|
||||
if(device != 0){
|
||||
if(device->fn_dirty){
|
||||
device->fn_dirty = 0;
|
||||
setFrame(device_addr, ISSI_BANK_FUNCTIONREG);
|
||||
TWITransmitData(&device->fn_device_addr, sizeof(device->fn_registers) + 2, 0, 1);
|
||||
}
|
||||
if(device->led_dirty){
|
||||
device->led_dirty = 0;
|
||||
setFrame(device_addr, 0);
|
||||
TWITransmitData(&device->led_device_addr, 0xB6, 0, blocking);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void issi_init(void)
|
||||
{
|
||||
TWIInit();
|
||||
for(uint8_t device_addr = 0; device_addr < 4; device_addr++){
|
||||
// If this device has been previously allocated, free it
|
||||
if(issi_devices[device_addr] != 0){
|
||||
free(issi_devices[device_addr]);
|
||||
}
|
||||
// Try to shutdown the device, if this fails skip this device
|
||||
writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x00);
|
||||
while (!isTWIReady()){_delay_us(1);}
|
||||
if(TWIInfo.errorCode != 0xFF){
|
||||
xprintf("ISSI init failed %d %02X %02X\n", device_addr, TWIInfo.mode, TWIInfo.errorCode);
|
||||
continue;
|
||||
}
|
||||
// Allocate the device structure - calloc zeros it for us
|
||||
ISSIDeviceStruct *device = (ISSIDeviceStruct *)calloc(sizeof(ISSIDeviceStruct) * 2, 1);
|
||||
issi_devices[device_addr] = device;
|
||||
device->fn_device_addr = ISSI_ADDR_DEFAULT | device_addr << 1;
|
||||
device->fn_register_addr = 0;
|
||||
device->led_device_addr = ISSI_ADDR_DEFAULT | device_addr << 1;
|
||||
device->led_register_addr = 0;
|
||||
// set dirty bits so that all of the buffered data is written out
|
||||
device->fn_dirty = 1;
|
||||
device->led_dirty = 1;
|
||||
update_issi(device_addr, 1);
|
||||
// Set the function register to picture mode
|
||||
// device->fn_reg[ISSI_REG_CONFIG] = ISSI_REG_CONFIG_PICTUREMODE;
|
||||
writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x01);
|
||||
}
|
||||
|
||||
// Shutdown and set all registers to 0
|
||||
// writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x00);
|
||||
// for(uint8_t bank = 0; bank <= 7; bank++){
|
||||
// for (uint8_t reg = 0x00; reg <= 0xB3; reg++) {
|
||||
// writeRegister8(device_addr, bank, reg, 0x00);
|
||||
// }
|
||||
// }
|
||||
// for (uint8_t reg = 0; reg <= 0x0C; reg++) {
|
||||
// writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, reg, 0x00);
|
||||
// }
|
||||
// writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE);
|
||||
// writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x01);
|
||||
// picture mode
|
||||
// writeRegister8(ISSI_BANK_FUNCTIONREG, 0x01, 0x01);
|
||||
|
||||
//Enable blink
|
||||
// writeRegister8(ISSI_BANK_FUNCTIONREG, 0x05, 0x48B);
|
||||
|
||||
//Enable Breath
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef ISSI_ENABLE
|
||||
|
||||
typedef struct ISSIDeviceStruct{
|
||||
uint8_t fn_dirty; // function registers need to be resent
|
||||
uint8_t fn_device_addr;
|
||||
uint8_t fn_register_addr;
|
||||
uint8_t fn_registers[13];
|
||||
uint8_t led_dirty; // LED data has changed and needs to be resent
|
||||
uint8_t led_device_addr;
|
||||
uint8_t led_register_addr;
|
||||
uint8_t led_ctrl[18];
|
||||
uint8_t led_blink_ctrl[18];
|
||||
uint8_t led_pwm[144];
|
||||
}ISSIDeviceStruct;
|
||||
|
||||
extern ISSIDeviceStruct *issi_devices[];
|
||||
|
||||
// Low level commands- 'device' is the 2-bit i2c id.
|
||||
void issi_init(void);
|
||||
void set_shutdown(uint8_t device, uint8_t shutdown);
|
||||
void writeRegister8(uint8_t device, uint8_t frame, uint8_t reg, uint8_t data);
|
||||
|
||||
// Higher level, no device is given, but it is calculated from 'matrix'
|
||||
// Each device has 2 blocks, max of 4 devices:
|
||||
// Device | Block = Matrix
|
||||
// 0 A 0
|
||||
// 0 B 1
|
||||
// 1 A 2
|
||||
// 1 B 3
|
||||
// 2 A 4
|
||||
// 2 B 5
|
||||
// 3 A 6
|
||||
// 3 B 7
|
||||
void activateLED(uint8_t matrix, uint8_t cx, uint8_t cy, uint8_t pwm);
|
||||
void update_issi(uint8_t device_addr, uint8_t blocking);
|
||||
|
||||
#endif
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#define BACKLIGHT_PWM_MAP {8, 16, 40, 55, 70, 128, 200, 255}
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
|
|
|
@ -13,28 +13,6 @@
|
|||
"rows": ["B0", "B3", "B2", "B1", "F5"]
|
||||
},
|
||||
"diode_direction": "COL2ROW",
|
||||
"backlight": {
|
||||
"levels": 8
|
||||
},
|
||||
"rgblight": {
|
||||
"hue_steps": 10,
|
||||
"led_count": 20,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "C7"
|
||||
},
|
||||
"processor": "atmega32u4",
|
||||
"bootloader": "atmel-dfu",
|
||||
"layouts": {
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
#include <avr/sfr_defs.h>
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "lfk65_hs.h"
|
||||
#include <avr/wdt.h>
|
||||
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t* record)
|
||||
{
|
||||
if (keycode == QK_BOOT) {
|
||||
reset_keyboard_kb();
|
||||
} else {
|
||||
}
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "matrix.h"
|
||||
#include <avr/sfr_defs.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void reset_keyboard_kb(void);
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
# Extra source files for IS3731 lighting
|
||||
SRC = TWIlib.c issi.c lighting.c
|
|
@ -17,8 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#pragma once
|
||||
|
||||
#define BACKLIGHT_PWM_MAP { 8, 16, 40, 55, 70, 128, 200, 255 }
|
||||
|
||||
#define AUDIO_PIN C6
|
||||
#define AUDIO_VOICES
|
||||
|
||||
|
|
|
@ -15,23 +15,6 @@ enum {
|
|||
|
||||
bool spam_space = false;
|
||||
|
||||
// {0x00000000, 0xFFFFFFFF, {0x0000, 0x0FFF, 0x0000}}, // base layer - green
|
||||
// {0x00000008, 0xFFFFFFF8, {0x07FF, 0x07FF, 0x0000}}, // CSGO layer - orange
|
||||
// {0x00000010, 0xFFFFFFF0, {0x0000, 0x0000, 0x0FFF}}, // function layer - blue
|
||||
// {0x00000020, 0xFFFFFFE0, {0x0FFF, 0x0000, 0x0FFF}}, // settings layer - magenta
|
||||
// {0xFFFFFFFF, 0xFFFFFFFF, {0x0FFF, 0x0FFF, 0x0FFF}}, // unknown layer - REQUIRED - white
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFFF, {0x0000, 0x0FFF, 0x0000}}, // base layer - green
|
||||
{0x00000002, 0xFFFFFFFE, {0x07FF, 0x07FF, 0x0000}}, // CSGO layer - orange
|
||||
{0x00000004, 0xFFFFFFFC, {0x0000, 0x0000, 0x0FFF}}, // function layer - blue
|
||||
{0x00000008, 0xFFFFFFE8, {0x0FFF, 0x0000, 0x0FFF}}, // settings layer - magenta
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0x0FFF, 0x0FFF, 0x0FFF}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap BASE: (Base Layer) Default Layer
|
||||
* ,---------. ,------------------------------------------------------------. ,---------.
|
||||
|
@ -55,7 +38,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
),
|
||||
|
||||
[CS_GO] = LAYOUT_split_rshift(
|
||||
_______, _______, QK_GESC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, F(0), _______,
|
||||
_______, _______, QK_GESC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, KC_LCTL, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
|
|
|
@ -1,34 +1,3 @@
|
|||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Disable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE = no # Enable RGB underlight
|
||||
SLEEP_LED_ENABLE = yes
|
||||
AUDIO_ENABLE = no
|
||||
TAP_DANCE_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = yes # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
||||
|
||||
# # Set the LFK78 hardware version. This is defined in rules.mk, but can be overidden here if desired
|
||||
# #
|
||||
# # RevB - first public release, uses atmega32u4, has audio, ISSI matrix split between RGB and backlight
|
||||
# # RevC/D - at90usb1286, no audio, ISSI device 0 is backlight, 4 is RGB
|
||||
# #
|
||||
# # Set to B, C or D
|
||||
# LFK_REV = D
|
||||
|
||||
# ifeq ($(LFK_REV), B)
|
||||
# MCU = atmega32u4
|
||||
# else
|
||||
# MCU = at90usb1286
|
||||
# endif
|
||||
# OPT_DEFS += -DLFK_REV_$(LFK_REV)
|
||||
# OPT_DEFS += -DUSB_PRODUCT=\"LFK_Rev$(LFK_REV)\"
|
||||
|
|
|
@ -6,16 +6,6 @@ enum keymap_layout {
|
|||
SETTINGS
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{ 0x00000000, 0xFFFFFFFF, { 0x0000, 0x0FFF, 0x0000 } }, // base layer - green
|
||||
{ 0x00000002, 0xFFFFFFFE, { 0x0000, 0x0000, 0x0FFF } }, // function layer - blue
|
||||
{ 0x00000004, 0xFFFFFFFC, { 0x0FFF, 0x0000, 0x0FFF } }, // settings layer - magenta
|
||||
{ 0xFFFFFFFF, 0xFFFFFFFF, { 0x0FFF, 0x0FFF, 0x0FFF } } // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,---------. ,------------------------------------------------------------. ,---------.
|
||||
|
|
|
@ -6,16 +6,6 @@ enum keymap_layout {
|
|||
SETTINGS
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{ 0x00000000, 0xFFFFFFFF, { 0x0000, 0x0FFF, 0x0000 } }, // base layer - green
|
||||
{ 0x00000002, 0xFFFFFFFE, { 0x0000, 0x0000, 0x0FFF } }, // function layer - blue
|
||||
{ 0x00000004, 0xFFFFFFFC, { 0x0FFF, 0x0000, 0x0FFF } }, // settings layer - magenta
|
||||
{ 0xFFFFFFFF, 0xFFFFFFFF, { 0x0FFF, 0x0FFF, 0x0FFF } } // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,---------. ,------------------------------------------------------------. ,---------.
|
||||
|
|
|
@ -6,16 +6,6 @@ enum keymap_layout {
|
|||
SETTINGS
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{ 0x00000000, 0xFFFFFFFF, { 0x0000, 0x0FFF, 0x0000 } }, // base layer - green
|
||||
{ 0x00000002, 0xFFFFFFFE, { 0x0000, 0x0000, 0x0FFF } }, // function layer - blue
|
||||
{ 0x00000004, 0xFFFFFFFC, { 0x0FFF, 0x0000, 0x0FFF } }, // settings layer - magenta
|
||||
{ 0xFFFFFFFF, 0xFFFFFFFF, { 0x0FFF, 0x0FFF, 0x0FFF } } // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,---------. ,------------------------------------------------------------. ,---------.
|
||||
|
|
|
@ -1,55 +1,19 @@
|
|||
#include "lfk78.h"
|
||||
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "issi.h"
|
||||
#include "TWIlib.h"
|
||||
#include "lighting.h"
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
# include "audio.h"
|
||||
#endif
|
||||
|
||||
uint16_t click_hz = CLICK_HZ;
|
||||
uint16_t click_time = CLICK_MS;
|
||||
uint8_t click_toggle = CLICK_ENABLED;
|
||||
|
||||
__attribute__((weak))
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{ 0x00000000, 0xFFFFFFFF, { 0x0000, 0x0FFF, 0x0000 } }, // base layer - green
|
||||
{ 0x00000002, 0xFFFFFFFE, { 0x0000, 0x0000, 0x0FFF } }, // function layer - blue
|
||||
{ 0x00000004, 0xFFFFFFFC, { 0x0FFF, 0x0000, 0x0FFF } }, // settings layer - magenta
|
||||
{ 0xFFFFFFFF, 0xFFFFFFFF, { 0x0FFF, 0x0FFF, 0x0FFF } } // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
matrix_init_user();
|
||||
|
||||
// Configure the Layer LED
|
||||
// Set up 16 bit PWM: Fast PWM, mode 14, inverted
|
||||
TCCR1A = _BV(COM1A1) | _BV(COM1A0) | _BV(COM1B1) | _BV(COM1B0) | _BV(COM1C1) | _BV(COM1C0) | _BV(WGM11);
|
||||
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10);
|
||||
ICR1 = 0xFFFF;
|
||||
// PWM values - 0xFFFF = off, 0x0000 = max
|
||||
OCR1A = 0x0FFF; // B5 - Red
|
||||
OCR1B = 0x0000; // B6 - Green
|
||||
OCR1C = 0x0000; // B7 - Blue
|
||||
// Set as output
|
||||
setPinOutput(B5);
|
||||
setPinOutput(B6);
|
||||
setPinOutput(B7);
|
||||
|
||||
#ifndef AUDIO_ENABLE
|
||||
// If we're not using the audio pin, drive it low
|
||||
setPinOutput(C6);
|
||||
writePinLow(C6);
|
||||
#endif
|
||||
|
||||
#ifdef ISSI_ENABLE
|
||||
issi_init();
|
||||
#endif
|
||||
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
// This is done after turning the layer LED red, if we're caught in a loop
|
||||
// we should get a flashing red light
|
||||
|
@ -62,54 +26,6 @@ void matrix_scan_kb(void) {
|
|||
wdt_reset();
|
||||
#endif
|
||||
|
||||
#ifdef ISSI_ENABLE
|
||||
// switch/underglow lighting update
|
||||
static uint32_t issi_device = 0;
|
||||
static uint32_t twi_last_ready = 0;
|
||||
|
||||
if (twi_last_ready > 1000) {
|
||||
// It's been way too long since the last ISSI update, reset the I2C bus and start again
|
||||
dprintf("TWI failed to recover, TWI re-init\n");
|
||||
twi_last_ready = 0;
|
||||
TWIInit();
|
||||
force_issi_refresh();
|
||||
}
|
||||
|
||||
if (isTWIReady()) {
|
||||
twi_last_ready = 0;
|
||||
// If the i2c bus is available, kick off the issi update, alternate between devices
|
||||
update_issi(issi_device, issi_device);
|
||||
|
||||
if (issi_device) {
|
||||
issi_device = 0;
|
||||
} else {
|
||||
issi_device = 3;
|
||||
}
|
||||
} else {
|
||||
twi_last_ready++;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Update layer indicator LED
|
||||
//
|
||||
// Not sure how else to reliably do this... TMK has the 'hook_layer_change'
|
||||
// but can't find QMK equiv
|
||||
static uint32_t layer_indicator = -1;
|
||||
|
||||
if (layer_indicator != layer_state) {
|
||||
for (uint32_t i = 0; ; i++) {
|
||||
// the layer_info list should end with layer 0xFFFFFFFF
|
||||
// it will break this out of the loop and define the unknown layer color
|
||||
if ((layer_info[i].layer == (layer_state & layer_info[i].mask)) || (layer_info[i].layer == 0xFFFFFFFF)) {
|
||||
OCR1A = layer_info[i].color.red;
|
||||
OCR1B = layer_info[i].color.green;
|
||||
OCR1C = layer_info[i].color.blue;
|
||||
layer_indicator = layer_state;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
|
@ -144,34 +60,5 @@ void reset_keyboard_kb(void) {
|
|||
wdt_reset();
|
||||
#endif
|
||||
|
||||
OCR1A = 0x0000; // B5 - Red
|
||||
OCR1B = 0x0FFF; // B6 - Green
|
||||
OCR1C = 0x0FFF; // B7 - Blue
|
||||
|
||||
reset_keyboard();
|
||||
}
|
||||
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
#ifdef ISSI_ENABLE
|
||||
# ifdef CAPSLOCK_LED
|
||||
if (led_state.caps_lock) {
|
||||
activateLED(0, 3, 7, 255);
|
||||
} else {
|
||||
activateLED(0, 3, 7, 0);
|
||||
}
|
||||
# endif // CAPSLOCK_LED
|
||||
#endif // ISS_ENABLE
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// LFK lighting info
|
||||
const uint8_t switch_matrices[] = { 0, 1 };
|
||||
const uint8_t rgb_matrices[] = { 6, 7 };
|
||||
const uint8_t rgb_sequence[] = {
|
||||
12, 11, 10, 9, 16, 32, 31, 30, 28, 25, 24, 22, 21,
|
||||
20, 19, 18, 17, 1, 2, 3, 4, 5, 6, 7, 8, 14, 13
|
||||
};
|
||||
|
|
|
@ -2,21 +2,6 @@
|
|||
|
||||
#include "quantum.h"
|
||||
|
||||
typedef struct RGB_Color {
|
||||
uint16_t red;
|
||||
uint16_t green;
|
||||
uint16_t blue;
|
||||
} RGB_Color;
|
||||
|
||||
typedef struct Layer_Info {
|
||||
uint32_t layer;
|
||||
uint32_t mask;
|
||||
RGB_Color color;
|
||||
} Layer_Info;
|
||||
|
||||
extern const uint32_t layer_count;
|
||||
extern const Layer_Info layer_info[];
|
||||
|
||||
#define CLICK_HZ 500
|
||||
#define CLICK_MS 2
|
||||
#define CLICK_ENABLED 0
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
# Extra source files for IS3731 lighting
|
||||
SRC += TWIlib.c issi.c lighting.c
|
||||
|
||||
ifeq ($(strip $(ISSI_ENABLE)), yes)
|
||||
OPT_DEFS += -DISSI_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
|
||||
OPT_DEFS += -DWATCHDOG_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(CAPSLOCK_LED)), yes)
|
||||
OPT_DEFS += -DCAPSLOCK_LED
|
||||
endif
|
||||
|
|
|
@ -13,30 +13,6 @@
|
|||
"rows": ["B0", "B1", "B2", "B3", "B4", "F0", "F1", "F4", "F5", "F6"]
|
||||
},
|
||||
"diode_direction": "COL2ROW",
|
||||
"backlight": {
|
||||
"driver": "custom",
|
||||
"levels": 8
|
||||
},
|
||||
"rgblight": {
|
||||
"driver": "custom",
|
||||
"hue_steps": 10,
|
||||
"led_count": 31,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "C7"
|
||||
},
|
||||
"processor": "atmega32u4",
|
||||
"bootloader": "atmel-dfu",
|
||||
"layouts": {
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#include "quantum.h"
|
||||
|
||||
// Maps switch LEDs from Row/Col to ISSI matrix.
|
||||
// Value breakdown:
|
||||
// Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
// / \ ISSI Col | ISSI Row |
|
||||
// matrix idx
|
||||
const uint8_t switch_leds[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12},
|
||||
{0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22},
|
||||
{0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32},
|
||||
{0x49, 0x48, 0x47, 0x45, 0x44, 0x43, 0x42, 0x41},
|
||||
{0x59, 0x58, 0x57, 0x56, 0x55, 0x51, 0xD6, 0xE5},
|
||||
{0x11, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93},
|
||||
{0x21, 0xA9, 0xA8, 0xA7, 0xA6, 0xA5, 0xA4, 0xA3},
|
||||
{0x31, 0xB9, 0xB8, 0xB7, 0xB6, 0xB5, 0xB3, 0x00},
|
||||
{0xC9, 0xC8, 0xC7, 0xC6, 0xC5, 0xC4, 0xC2, 0x00},
|
||||
{0xE4, 0xE3, 0xE2, 0xE1, 0x92, 0x91, 0xA2, 0xA1}
|
||||
};
|
|
@ -13,30 +13,6 @@
|
|||
"rows": ["D2", "D3", "D4", "D5", "D6"]
|
||||
},
|
||||
"diode_direction": "COL2ROW",
|
||||
"backlight": {
|
||||
"driver": "custom",
|
||||
"levels": 8
|
||||
},
|
||||
"rgblight": {
|
||||
"driver": "custom",
|
||||
"hue_steps": 10,
|
||||
"led_count": 27,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "C7"
|
||||
},
|
||||
"processor": "at90usb1286",
|
||||
"bootloader": "atmel-dfu",
|
||||
"layouts": {
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#include "quantum.h"
|
||||
|
||||
// Maps switch LEDs from Row/Col to ISSI matrix.
|
||||
// Value breakdown:
|
||||
// Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
// / \ ISSI Col | ISSI Row |
|
||||
// matrix idx
|
||||
const uint8_t switch_leds[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91},
|
||||
{0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0xA9, 0xA8, 0xA7, 0xA6, 0xA5, 0xA4, 0xA3, 0xA2, 0xA1},
|
||||
{0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0xB9, 0xB8, 0xB7, 0xB6, 0xB5, 0xB3, 0x00, 0x00, 0x00},
|
||||
{0x49, 0x48, 0x47, 0x00, 0x45, 0x44, 0x43, 0x42, 0x41, 0xC9, 0xC8, 0xC7, 0xC6, 0xC5, 0xC4, 0x00, 0xC2, 0x00},
|
||||
{0x59, 0x58, 0x57, 0x56, 0x55, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0xD6, 0xE5, 0xE4, 0xE3, 0xE2, 0xE1}
|
||||
};
|
|
@ -13,30 +13,6 @@
|
|||
"rows": ["D2", "D3", "D4", "D5", "D6"]
|
||||
},
|
||||
"diode_direction": "COL2ROW",
|
||||
"backlight": {
|
||||
"driver": "custom",
|
||||
"levels": 8
|
||||
},
|
||||
"rgblight": {
|
||||
"driver": "custom",
|
||||
"hue_steps": 10,
|
||||
"led_count": 27,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "C7"
|
||||
},
|
||||
"processor": "at90usb646",
|
||||
"bootloader": "atmel-dfu",
|
||||
"layouts": {
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#include "quantum.h"
|
||||
|
||||
// Maps switch LEDs from Row/Col to ISSI matrix.
|
||||
// Value breakdown:
|
||||
// Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
// / \ ISSI Col | ISSI Row |
|
||||
// matrix idx
|
||||
const uint8_t switch_leds[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91},
|
||||
{0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0xA9, 0xA8, 0xA7, 0xA6, 0xA5, 0xA4, 0xA3, 0xA2, 0xA1},
|
||||
{0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0xB9, 0xB8, 0xB7, 0xB6, 0xB5, 0xB3, 0x00, 0x00, 0x00},
|
||||
{0x49, 0x48, 0x47, 0x00, 0x45, 0x44, 0x43, 0x42, 0x41, 0xC9, 0xC8, 0xC7, 0xC6, 0xC5, 0xC4, 0x00, 0xC2, 0x00},
|
||||
{0x59, 0x58, 0x57, 0x56, 0x55, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0xD6, 0xE5, 0xE4, 0xE3, 0xE2, 0xE1}
|
||||
};
|
|
@ -7,13 +7,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
|
|||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable N-Key Rollover
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
CAPSLOCK_LED = no # Toggle back light LED of Caps Lock
|
||||
|
||||
DEFAULT_FOLDER = lfkeyboards/lfk78/revj
|
||||
|
|
|
@ -20,8 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define AUDIO_VOICES
|
||||
#define AUDIO_PIN C6
|
||||
|
||||
#define BACKLIGHT_PWM_MAP {2, 4, 8, 16, 40, 55, 70, 128, 200, 255}
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
|
|
|
@ -8,15 +8,5 @@
|
|||
"pid": "0x6060",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"backlight": {
|
||||
"driver": "custom",
|
||||
"levels": 10
|
||||
},
|
||||
"rgblight": {
|
||||
"driver": "custom"
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "F4"
|
||||
},
|
||||
"community_layouts": ["tkl_ansi", "tkl_iso"]
|
||||
}
|
||||
|
|
|
@ -13,17 +13,6 @@ enum {
|
|||
TD_ESC_FUNC = 0,
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFF8, {0x00, 0xFF, 0x00}}, // base layers (VANILLA, DEFAULT_WKL, DEFAULT_OSX) - green
|
||||
{0x00000008, 0xFFFFFFF8, {0x07FF, 0x07FF, 0x0000}}, // CSGO layer - orange
|
||||
{0x00000010, 0xFFFFFFF0, {0x0000, 0x0000, 0x0FFF}}, // function layer - blue
|
||||
{0x00000020, 0xFFFFFFE0, {0x0FFF, 0x0000, 0x0FFF}}, // settings layer - magenta
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0x0FFF, 0x0FFF, 0x0FFF}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,-----------------------------------------------------------------------------.
|
||||
|
|
|
@ -1,17 +1,2 @@
|
|||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = yes # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Disable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE = yes # Enable RGB underlight
|
||||
SLEEP_LED_ENABLE = yes
|
||||
TAP_DANCE_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = yes # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
|
|
@ -6,16 +6,6 @@ enum keymap_layout {
|
|||
SETTINGS, // 0x10
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFFF, {0x00, 0xFF, 0x00}}, // base layers - green
|
||||
{0x00000002, 0xFFFFFFFE, {0x00, 0x00, 0xFF}}, // function layer - blue
|
||||
{0x00000004, 0xFFFFFFFC, {0xFF, 0x00, 0xFF}}, // settings layer - magenta
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0xFF, 0xFF, 0xFF}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,-----------------------------------------------------------------------------.
|
||||
|
|
|
@ -1,13 +1 @@
|
|||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
AUDIO_ENABLE = yes # Audio output
|
||||
RGBLIGHT_ENABLE = yes # Enable RGB underlight
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
|
|
@ -6,16 +6,6 @@ enum keymap_layout {
|
|||
SETTINGS, // 0x10
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFFF, {0x00, 0x00, 0x00}}, // base layers - off
|
||||
{0x00000002, 0xFFFFFFFE, {0x00, 0x00, 0xFF}}, // function layer - blue
|
||||
{0x00000004, 0xFFFFFFFC, {0xFF, 0x00, 0xFF}}, // settings layer - magenta
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0xFF, 0xFF, 0xFF}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,-----------------------------------------------------------------------------.
|
||||
|
|
|
@ -1,16 +1 @@
|
|||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = yes # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE = yes # Enable RGB underlight
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
|
|
@ -6,16 +6,6 @@ enum keymap_layout {
|
|||
SETTINGS, // 0x04
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFFF, {0x00, 0x00, 0x00}}, // base layer - off
|
||||
{0x00000002, 0xFFFFFFFE, {0x00, 0x00, 0x7F}}, // function layer - blue
|
||||
{0x00000004, 0xFFFFFFFC, {0x7F, 0x00, 0x00}}, // settings layer - red
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0x0F, 0x0F, 0x0F}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,-----------------------------------------------------------------------------.
|
||||
|
|
|
@ -1,13 +1,2 @@
|
|||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
AUDIO_ENABLE = yes # Audio output
|
||||
RGBLIGHT_ENABLE = yes # Enable RGB underlight
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
AUDIO_ENABLE = yes
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
|
|
@ -1,42 +1,20 @@
|
|||
|
||||
#include <avr/sfr_defs.h>
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "lfk87.h"
|
||||
#include "issi.h"
|
||||
#include "TWIlib.h"
|
||||
#include "lighting.h"
|
||||
#include "debug.h"
|
||||
#include "quantum.h"
|
||||
#include <avr/wdt.h>
|
||||
|
||||
uint16_t click_hz = CLICK_HZ;
|
||||
uint16_t click_time = CLICK_MS;
|
||||
uint8_t click_toggle = CLICK_ENABLED;
|
||||
|
||||
__attribute__((weak))
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFFF, {0x00, 0xFF, 0x00}}, // base layers - green
|
||||
{0x00000002, 0xFFFFFFFE, {0x00, 0x00, 0xFF}}, // function layer - blue
|
||||
{0x00000004, 0xFFFFFFFC, {0xFF, 0x00, 0xFF}}, // settings layer - magenta
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0xFF, 0xFF, 0xFF}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
void matrix_init_kb(void)
|
||||
{
|
||||
// put your keyboard start-up code here
|
||||
// runs once when the firmware starts up
|
||||
matrix_init_user();
|
||||
set_rgb(31, 0x00, 0x00, 0x00); // Caps lock
|
||||
set_rgb(32, 0xFF, 0x00, 0x00); // Layer indicator, start red
|
||||
#ifndef AUDIO_ENABLE
|
||||
// If we're not using the audio pin, drive it low
|
||||
setPinOutput(C6);
|
||||
writePinLow(C6);
|
||||
#endif
|
||||
#ifdef ISSI_ENABLE
|
||||
issi_init();
|
||||
#endif
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
// This is done after turning the layer LED red, if we're caught in a loop
|
||||
// we should get a flashing red light
|
||||
|
@ -49,49 +27,10 @@ void matrix_scan_kb(void)
|
|||
#ifdef WATCHDOG_ENABLE
|
||||
wdt_reset();
|
||||
#endif
|
||||
#ifdef ISSI_ENABLE
|
||||
// switch/underglow lighting update
|
||||
static uint32_t issi_device = 0;
|
||||
static uint32_t twi_last_ready = 0;
|
||||
if(twi_last_ready > 1000){
|
||||
// Its been way too long since the last ISSI update, reset the I2C bus and start again
|
||||
twi_last_ready = 0;
|
||||
TWIInit();
|
||||
force_issi_refresh();
|
||||
}
|
||||
if(isTWIReady()){
|
||||
twi_last_ready = 0;
|
||||
// If the i2c bus is available, kick off the issi update, alternate between devices
|
||||
update_issi(issi_device, issi_device);
|
||||
if(issi_device){
|
||||
issi_device = 0;
|
||||
}else{
|
||||
issi_device = 3;
|
||||
}
|
||||
}else{
|
||||
twi_last_ready++;
|
||||
}
|
||||
#endif
|
||||
// Update layer indicator LED
|
||||
//
|
||||
// Not sure how else to reliably do this... TMK has the 'hook_layer_change'
|
||||
// but can't find QMK equiv
|
||||
static uint32_t layer_indicator = -1;
|
||||
if(layer_indicator != layer_state){
|
||||
for(uint32_t i=0;; i++){
|
||||
// the layer_info list should end with layer 0xFFFF
|
||||
// it will break this out of the loop and define the unknown layer color
|
||||
if((layer_info[i].layer == (layer_state & layer_info[i].mask)) || (layer_info[i].layer == 0xFFFFFFFF)){
|
||||
set_rgb(32, layer_info[i].color.red, layer_info[i].color.green, layer_info[i].color.blue);
|
||||
layer_indicator = layer_state;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
void click(uint16_t freq, uint16_t duration){
|
||||
void clicking_notes(uint16_t freq, uint16_t duration){
|
||||
#ifdef AUDIO_ENABLE
|
||||
if(freq >= 100 && freq <= 20000 && duration < 100){
|
||||
play_note(freq, 10);
|
||||
|
@ -106,11 +45,10 @@ void click(uint16_t freq, uint16_t duration){
|
|||
bool process_record_kb(uint16_t keycode, keyrecord_t* record)
|
||||
{
|
||||
if (click_toggle && record->event.pressed){
|
||||
click(click_hz, click_time);
|
||||
clicking_notes(click_hz, click_time);
|
||||
}
|
||||
if (keycode == QK_BOOT) {
|
||||
reset_keyboard_kb();
|
||||
} else {
|
||||
}
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
|
@ -121,35 +59,5 @@ void reset_keyboard_kb(void){
|
|||
wdt_disable();
|
||||
wdt_reset();
|
||||
#endif
|
||||
set_rgb(31, 0x00, 0xFF, 0xFF);
|
||||
set_rgb(32, 0x00, 0xFF, 0xFF);
|
||||
force_issi_refresh();
|
||||
reset_keyboard();
|
||||
}
|
||||
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
// Set capslock LED to Blue
|
||||
if (led_state.caps_lock) {
|
||||
set_rgb(31, 0x00, 0x00, 0x7F);
|
||||
} else{
|
||||
set_rgb(31, 0x00, 0x00, 0x00);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Lighting info, see lighting.h for details
|
||||
const uint8_t switch_matrices[] = {0, 1};
|
||||
const uint8_t rgb_matrices[] = {6, 7};
|
||||
|
||||
// RGB Map:
|
||||
// 27 29 10 9 8 7 6
|
||||
// 26 5
|
||||
// 25 4
|
||||
// 24 3
|
||||
// 23 22 21 20 14 15 11 1 2
|
||||
const uint8_t rgb_sequence[] = {
|
||||
27, 29, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 15, 14, 20, 21, 22, 23, 24, 25, 26
|
||||
};
|
||||
|
|
|
@ -1,27 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "matrix.h"
|
||||
#include <avr/sfr_defs.h>
|
||||
|
||||
typedef struct RGB_Color {
|
||||
uint16_t red;
|
||||
uint16_t green;
|
||||
uint16_t blue;
|
||||
} RGB_Color;
|
||||
|
||||
typedef struct Layer_Info {
|
||||
uint32_t layer;
|
||||
uint32_t mask;
|
||||
RGB_Color color;
|
||||
} Layer_Info;
|
||||
|
||||
extern const uint32_t layer_count;
|
||||
extern const Layer_Info layer_info[];
|
||||
|
||||
#define CLICK_HZ 500
|
||||
#define CLICK_MS 2
|
||||
#define CLICK_ENABLED 0
|
||||
|
||||
void reset_keyboard_kb(void);
|
||||
void click(uint16_t freq, uint16_t duration);
|
||||
void clicking_notes(uint16_t freq, uint16_t duration);
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
ifeq ($(strip $(ISSI_ENABLE)), yes)
|
||||
OPT_DEFS += -DISSI_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
|
||||
OPT_DEFS += -DWATCHDOG_ENABLE
|
||||
endif
|
||||
|
|
|
@ -6,22 +6,6 @@
|
|||
"rows": ["D2", "D3", "D4", "D5", "D6", "D7"]
|
||||
},
|
||||
"diode_direction": "COL2ROW",
|
||||
"rgblight": {
|
||||
"hue_steps": 10,
|
||||
"led_count": 25,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT_tkl_ansi": {
|
||||
"layout": [
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#include "quantum.h"
|
||||
|
||||
// Maps switch LEDs from Row/Col to ISSI matrix.
|
||||
// Value breakdown:
|
||||
// Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
// | | ISSI Col | ISSI Row |
|
||||
// / |
|
||||
// Device
|
||||
const uint8_t switch_leds[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{0x19, 0x00, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93},
|
||||
{0x92, 0x91, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0xA9, 0xA8, 0xA7, 0xA6, 0xA5, 0xA4},
|
||||
{0xA3, 0xA2, 0xA1, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0xB9, 0xB8, 0xB7, 0xB6, 0xB5},
|
||||
{0xB3, 0x49, 0x48, 0x47, 0x45, 0x44, 0x43, 0x42, 0x41, 0xC9, 0xC8, 0xC7, 0xC6, 0x00, 0x00, 0x00, 0x00},
|
||||
{0xC5, 0x00, 0xC4, 0xC2, 0x59, 0x58, 0x57, 0x56, 0x55, 0x51, 0xD6, 0xE5, 0xE4, 0x00, 0x00, 0xE3, 0x00},
|
||||
{0xE2, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
|
@ -6,22 +6,6 @@
|
|||
"rows": ["F2", "D7", "D6", "D5", "D4", "D3", "F3"]
|
||||
},
|
||||
"diode_direction": "COL2ROW",
|
||||
"rgblight": {
|
||||
"hue_steps": 10,
|
||||
"led_count": 24,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT_tkl_ansi": {
|
||||
"layout": [
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
#include "quantum.h"
|
||||
|
||||
// Maps switch LEDs from Row/Col to ISSI matrix.
|
||||
// Value breakdown:
|
||||
// Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
// | | ISSI Col | ISSI Row |
|
||||
// / |
|
||||
// Device
|
||||
const uint8_t switch_leds[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x99, 0x98, 0x97, 0x96, 0x00, 0x95, 0x94, 0x93},
|
||||
{0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0xA9, 0xA8, 0xA7, 0x00, 0xA6, 0xA5, 0xA4},
|
||||
{0xA2, 0xA1, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0xB9, 0xB8, 0xB7, 0xB6, 0xB5},
|
||||
{0x49, 0x48, 0x47, 0x45, 0x44, 0x43, 0x42, 0x41, 0xC9, 0xC8, 0xC7, 0xC6, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0xC4, 0xC2, 0x59, 0x58, 0x57, 0x56, 0x55, 0x51, 0xD6, 0xE5, 0xE4, 0x00, 0x00, 0xE3, 0x00},
|
||||
{0xB3, 0xC5, 0xE2, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x19, 0x92, 0x91, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
|
@ -8,15 +8,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
|
|||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable N-Key Rollover
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
AUDIO_ENABLE = yes # Audio output
|
||||
RGBLIGHT_ENABLE = yes # Enable RGB underlight
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
||||
# Extra source files for IS3731 lighting
|
||||
SRC += TWIlib.c issi.c lighting.c
|
||||
|
||||
DEFAULT_FOLDER = lfkeyboards/lfk78/revc
|
||||
|
|
|
@ -8,26 +8,6 @@
|
|||
"pid": "0x3231",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"rgblight": {
|
||||
"driver": "custom",
|
||||
"hue_steps": 10,
|
||||
"led_count": 28,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "C7"
|
||||
},
|
||||
"matrix_pins": {
|
||||
"cols": ["F1", "F0", "D4", "D6"],
|
||||
"rows": ["D5", "F4", "F6", "F7", "C7", "C6"]
|
||||
|
|
|
@ -56,18 +56,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
_______, _______, _______
|
||||
),
|
||||
};
|
||||
|
||||
const uint8_t number_leds[] = {8, 9, 10, 11, 12, 13, 15, 16, 17};
|
||||
const uint8_t number_leds_size = ARRAY_SIZE(number_leds);
|
||||
|
||||
bool led_update_user(led_t led_state) {
|
||||
for (uint8_t i = 0; i < number_leds_size; i++)
|
||||
if (led_state.num_lock)
|
||||
// set to whatever the other leds are doing
|
||||
// this is needed so that upon disabling num lock, the leds don't stay red
|
||||
rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), numer_leds[i]);
|
||||
else
|
||||
rgblight_setrgb_at(RGB_RED, numer_leds[i]); // set to red
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,9 @@
|
|||
#include "quantum.h"
|
||||
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "issi.h"
|
||||
#include "TWIlib.h"
|
||||
#include "lighting.h"
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
matrix_init_user();
|
||||
|
||||
#ifdef ISSI_ENABLE
|
||||
issi_init();
|
||||
#endif
|
||||
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
// This is done after turning the layer LED red, if we're caught in a loop
|
||||
// we should get a flashing red light
|
||||
|
@ -25,48 +16,5 @@ void matrix_scan_kb(void) {
|
|||
wdt_reset();
|
||||
#endif
|
||||
|
||||
#ifdef ISSI_ENABLE
|
||||
// switch/underglow lighting update
|
||||
static uint32_t issi_device = 0;
|
||||
static uint32_t twi_last_ready = 0;
|
||||
|
||||
if (twi_last_ready > 1000) {
|
||||
// It's been way too long since the last ISSI update, reset the I2C bus and start again
|
||||
dprintf("TWI failed to recover, TWI re-init\n");
|
||||
twi_last_ready = 0;
|
||||
TWIInit();
|
||||
force_issi_refresh();
|
||||
}
|
||||
|
||||
if (isTWIReady()) {
|
||||
twi_last_ready = 0;
|
||||
// If the i2c bus is available, kick off the issi update, alternate between devices
|
||||
update_issi(issi_device, issi_device);
|
||||
|
||||
if (issi_device) {
|
||||
issi_device = 0;
|
||||
} else {
|
||||
issi_device = 3;
|
||||
}
|
||||
} else {
|
||||
twi_last_ready++;
|
||||
}
|
||||
#endif
|
||||
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
// LFK lighting info
|
||||
const uint8_t rgb_matrices[] = { 0, 1 };
|
||||
const uint8_t rgb_sequence[] = {
|
||||
32, 1, 2, 3,
|
||||
31, 30, 5, 6,
|
||||
28, 27, 7,
|
||||
17, 18, 9, 8,
|
||||
19, 21, 11,
|
||||
22, 14, 12,
|
||||
16, 26,
|
||||
4, 25,
|
||||
13, 24,
|
||||
20
|
||||
};
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
ifeq ($(strip $(ISSI_ENABLE)), yes)
|
||||
OPT_DEFS += -DISSI_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
|
||||
OPT_DEFS += -DWATCHDOG_ENABLE
|
||||
endif
|
||||
|
|
|
@ -7,12 +7,5 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
|
|||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = no # Enable N-Key Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't installed this must be disabled
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan() isn't run every 250ms
|
||||
|
||||
SRC = TWIlib.c issi.c lighting.c
|
||||
|
|
|
@ -1,158 +0,0 @@
|
|||
#ifdef ISSI_ENABLE
|
||||
|
||||
|
||||
#include <avr/sfr_defs.h>
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "quantum.h"
|
||||
// #include "lfk87.h"
|
||||
#include "issi.h"
|
||||
#include "TWIlib.h"
|
||||
#include "lighting.h"
|
||||
#include "debug.h"
|
||||
#include "rgblight.h"
|
||||
|
||||
|
||||
extern rgblight_config_t rgblight_config; // Declared in rgblight.c
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
const uint8_t backlight_pwm_map[BACKLIGHT_LEVELS] = BACKLIGHT_PWM_MAP;
|
||||
#endif
|
||||
|
||||
// RGB# to ISSI matrix, this is the same across all revisions
|
||||
const uint8_t rgb_leds[][3][2] = {
|
||||
{{0, 0}, {0, 0}, {0, 0}},
|
||||
{{1, 1}, {2, 3}, {2, 4}}, // RGB1/RGB17
|
||||
{{2, 1}, {2, 2}, {3, 4}}, // RGB2/RGB18
|
||||
{{3, 1}, {3, 2}, {3, 3}}, // RGB3/RGB19
|
||||
{{4, 1}, {4, 2}, {4, 3}}, // RGB4/RGB20
|
||||
{{5, 1}, {5, 2}, {5, 3}}, // RGB5/RGB21
|
||||
{{6, 1}, {6, 2}, {6, 3}}, // RGB6/RGB22
|
||||
{{7, 1}, {7, 2}, {7, 3}}, // RGB6/RGB23
|
||||
{{8, 1}, {8, 2}, {8, 3}}, // RGB8/RGB24
|
||||
{{1, 9}, {1, 8}, {1, 7}}, // RGB9/RGB25
|
||||
{{2, 9}, {2, 8}, {2, 7}}, // RGB10/RGB26
|
||||
{{3, 9}, {3, 8}, {3, 7}}, // RGB11/RGB27
|
||||
{{4, 9}, {4, 8}, {4, 7}}, // RGB12/RGB28
|
||||
{{5, 9}, {5, 8}, {5, 7}}, // RGB13/RGB29
|
||||
{{6, 9}, {6, 8}, {6, 7}}, // RGB14/RGB30
|
||||
{{7, 9}, {7, 8}, {6, 6}}, // RGB15/RGB31
|
||||
{{8, 9}, {7, 7}, {7, 6}} // RGB16/RGB32
|
||||
};
|
||||
|
||||
void set_rgb(uint8_t rgb_led, uint8_t red, uint8_t green, uint8_t blue){
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
uint8_t matrix = rgb_matrices[0];
|
||||
if(rgb_led >= 17){
|
||||
matrix = rgb_matrices[1];
|
||||
rgb_led -= 16;
|
||||
}
|
||||
if(rgb_leds[rgb_led][0][1] != 0){
|
||||
activateLED(matrix, rgb_leds[rgb_led][0][0], rgb_leds[rgb_led][0][1], red);
|
||||
}
|
||||
if(rgb_leds[rgb_led][1][1] != 0){
|
||||
activateLED(matrix, rgb_leds[rgb_led][1][0], rgb_leds[rgb_led][1][1], green);
|
||||
}
|
||||
if(rgb_leds[rgb_led][2][1] != 0){
|
||||
activateLED(matrix, rgb_leds[rgb_led][2][0], rgb_leds[rgb_led][2][1], blue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void backlight_set(uint8_t level){
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
uint8_t pwm_value = 0;
|
||||
if(level >= BACKLIGHT_LEVELS){
|
||||
level = BACKLIGHT_LEVELS;
|
||||
}
|
||||
if(level > 0){
|
||||
pwm_value = backlight_pwm_map[level-1];
|
||||
}
|
||||
for(int x = 1; x <= 9; x++){
|
||||
for(int y = 1; y <= 9; y++){
|
||||
activateLED(switch_matrices[0], x, y, pwm_value);
|
||||
activateLED(switch_matrices[1], x, y, pwm_value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_underglow(uint8_t red, uint8_t green, uint8_t blue){
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
for(uint8_t x = 1; x <= 32; x++){
|
||||
set_rgb(x, red, green, blue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void rgblight_set(void) {
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
for(uint8_t i = 0; (i < sizeof(rgb_sequence)) && (i < RGBLED_NUM); i++){
|
||||
if(rgblight_config.enable){
|
||||
set_rgb(rgb_sequence[i], led[i].r, led[i].g, led[i].b);
|
||||
}else{
|
||||
set_rgb(rgb_sequence[i], 0, 0, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_backlight_by_keymap(uint8_t col, uint8_t row){
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
uint8_t lookup_value = switch_leds[row][col];
|
||||
uint8_t matrix = switch_matrices[0];
|
||||
if(lookup_value & 0x80){
|
||||
matrix = switch_matrices[1];
|
||||
}
|
||||
issi_devices[0]->led_dirty = 1;
|
||||
uint8_t led_col = (lookup_value & 0x70) >> 4;
|
||||
uint8_t led_row = lookup_value & 0x0F;
|
||||
activateLED(matrix, led_col, led_row, 255);
|
||||
#endif
|
||||
}
|
||||
|
||||
void force_issi_refresh(void){
|
||||
#ifdef ISSI_ENABLE
|
||||
issi_devices[0]->led_dirty = true;
|
||||
update_issi(0, true);
|
||||
issi_devices[3]->led_dirty = true;
|
||||
update_issi(3, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void led_test(void){
|
||||
#ifdef ISSI_ENABLE
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
// This test take a long time to run, disable the WTD until its complete
|
||||
wdt_disable();
|
||||
#endif
|
||||
backlight_set(0);
|
||||
set_underglow(0, 0, 0);
|
||||
force_issi_refresh();
|
||||
set_underglow(0, 0, 0);
|
||||
for(uint8_t x = 0; x < sizeof(rgb_sequence); x++){
|
||||
set_rgb(rgb_sequence[x], 255, 0, 0);
|
||||
force_issi_refresh();
|
||||
_delay_ms(250);
|
||||
set_rgb(rgb_sequence[x], 0, 255, 0);
|
||||
force_issi_refresh();
|
||||
_delay_ms(250);
|
||||
set_rgb(rgb_sequence[x], 0, 0, 255);
|
||||
force_issi_refresh();
|
||||
_delay_ms(250);
|
||||
set_rgb(rgb_sequence[x], 0, 0, 0);
|
||||
force_issi_refresh();
|
||||
}
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
wdt_enable(WDTO_250MS);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void backlight_init_ports(void){
|
||||
issi_init();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
// rgb_sequence[RGBLED_NUM]
|
||||
//
|
||||
// Array used for sequential lighting effects.
|
||||
//
|
||||
// Example LFK78 RevC+ RGB Map:
|
||||
// 27 29 10 9 8 7 6
|
||||
// 26 5
|
||||
// 25 4
|
||||
// 24 3
|
||||
// 23 22 21 20 14 15 11 1 2
|
||||
//
|
||||
// const uint8_t rgb_sequence[] = {
|
||||
// 27, 29, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
|
||||
// 11, 15, 14, 20, 21, 22, 23, 24, 25, 26
|
||||
// };
|
||||
extern const uint8_t rgb_sequence[RGBLED_NUM];
|
||||
|
||||
// switch_matrices[]
|
||||
//
|
||||
// The ISSI matrices for switch backlighting
|
||||
//
|
||||
// Example LFK78 RevC+ - ISSI Device 0, banks 0 and 1:
|
||||
// switch_matrices[] = {0, 1};
|
||||
extern const uint8_t switch_matrices[];
|
||||
|
||||
// rgb_matrices[]
|
||||
// The ISSI matrices for RGB Underglow
|
||||
//
|
||||
// Example LFK78 RevC+ - ISSI Device 3, banks 0 and 1:
|
||||
// rgb_matrices[] = {6, 7};
|
||||
extern const uint8_t rgb_matrices[];
|
||||
|
||||
// switch_leds[MATRIX_ROWS][MATRIX_COLS]
|
||||
// Maps switch LEDs from Row/Col to ISSI matrix.
|
||||
// Value breakdown:
|
||||
// Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
// | | ISSI Col | ISSI Row |
|
||||
// | |
|
||||
// Device
|
||||
extern const uint8_t switch_leds[MATRIX_ROWS][MATRIX_COLS];
|
||||
|
||||
void led_test(void);
|
||||
void force_issi_refresh(void);
|
||||
void set_backlight(uint8_t level);
|
||||
void set_underglow(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void set_rgb(uint8_t rgb_led, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void set_backlight_by_keymap(uint8_t col, uint8_t row);
|
|
@ -20,8 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define AUDIO_VOICES
|
||||
#define AUDIO_PIN C6
|
||||
|
||||
#define BACKLIGHT_PWM_MAP {2, 4, 8, 16, 40, 55, 70, 128, 200, 255}
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
|
|
|
@ -13,30 +13,6 @@
|
|||
"rows": ["D7", "E1", "F2", "F0", "F1"]
|
||||
},
|
||||
"diode_direction": "COL2ROW",
|
||||
"backlight": {
|
||||
"driver": "custom",
|
||||
"levels": 10
|
||||
},
|
||||
"rgblight": {
|
||||
"driver": "custom",
|
||||
"hue_steps": 10,
|
||||
"led_count": 26,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "F4"
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT": {
|
||||
"layout": [
|
||||
|
|
|
@ -12,16 +12,6 @@ enum {
|
|||
TD_SPC_SPAM
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFFF, {0x00, 0xFF, 0x00}}, // base layers - green
|
||||
{0x00000002, 0xFFFFFFFE, {0x00, 0x00, 0xFF}}, // function layer - blue
|
||||
{0x00000004, 0xFFFFFFFC, {0xFF, 0x00, 0xFF}}, // settings layer - magenta
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0xFF, 0xFF, 0xFF}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,-----------------------------------------------------------------------------.
|
||||
|
|
|
@ -6,16 +6,6 @@ enum keymap_layout {
|
|||
SETTINGS, // 0x10
|
||||
};
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFFF, {0x00, 0xFF, 0x00}}, // base layers - green
|
||||
{0x00000002, 0xFFFFFFFE, {0x00, 0x00, 0xFF}}, // function layer - blue
|
||||
{0x00000004, 0xFFFFFFFC, {0xFF, 0x00, 0xFF}}, // settings layer - magenta
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0xFF, 0xFF, 0xFF}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap VANILLA: (Base Layer) Default Layer
|
||||
* ,-----------------------------------------------------------------------------.
|
||||
|
|
|
@ -1,47 +1,22 @@
|
|||
|
||||
#include <avr/sfr_defs.h>
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "mini1800.h"
|
||||
#include "issi.h"
|
||||
#include "TWIlib.h"
|
||||
#include "lighting.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "quantum.h"
|
||||
#include <avr/wdt.h>
|
||||
|
||||
uint16_t click_hz = CLICK_HZ;
|
||||
uint16_t click_time = CLICK_MS;
|
||||
uint8_t click_toggle = CLICK_ENABLED;
|
||||
float my_song[][2] = SONG(ZELDA_PUZZLE);
|
||||
|
||||
// Colors of the layer indicator LED
|
||||
// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer
|
||||
__attribute__((weak))
|
||||
const Layer_Info layer_info[] = {
|
||||
// Layer Mask Red Green Blue
|
||||
{0x00000000, 0xFFFFFFFF, {0x00, 0xFF, 0x00}}, // base layers - green
|
||||
{0x00000002, 0xFFFFFFFE, {0x00, 0x00, 0xFF}}, // function layer - blue
|
||||
{0x00000004, 0xFFFFFFFC, {0xFF, 0x00, 0xFF}}, // settings layer - magenta
|
||||
{0xFFFFFFFF, 0xFFFFFFFF, {0xFF, 0xFF, 0xFF}}, // unknown layer - REQUIRED - white
|
||||
};
|
||||
|
||||
void matrix_init_kb(void)
|
||||
{
|
||||
// put your keyboard start-up code here
|
||||
// runs once when the firmware starts up
|
||||
matrix_init_user();
|
||||
set_rgb(31, 0x00, 0x00, 0x00); // Caps lock
|
||||
set_rgb(32, 0xFF, 0x00, 0x00); // Layer indicator, start red
|
||||
#ifndef AUDIO_ENABLE
|
||||
// If we're not using the audio pin, drive it low
|
||||
setPinOutput(C6);
|
||||
writePinLow(C6);
|
||||
#endif
|
||||
_delay_ms(500);
|
||||
#ifdef ISSI_ENABLE
|
||||
issi_init();
|
||||
#endif
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
// This is done after turning the layer LED red, if we're caught in a loop
|
||||
// we should get a flashing red light
|
||||
|
@ -54,45 +29,6 @@ void matrix_scan_kb(void)
|
|||
#ifdef WATCHDOG_ENABLE
|
||||
wdt_reset();
|
||||
#endif
|
||||
#ifdef ISSI_ENABLE
|
||||
// switch/underglow lighting update
|
||||
static uint32_t issi_device = 0;
|
||||
static uint32_t twi_last_ready = 0;
|
||||
if(twi_last_ready > 1000){
|
||||
// Its been way too long since the last ISSI update, reset the I2C bus and start again
|
||||
twi_last_ready = 0;
|
||||
TWIInit();
|
||||
force_issi_refresh();
|
||||
}
|
||||
if(isTWIReady()){
|
||||
twi_last_ready = 0;
|
||||
// If the i2c bus is available, kick off the issi update, alternate between devices
|
||||
update_issi(issi_device, issi_device);
|
||||
if(issi_device){
|
||||
issi_device = 0;
|
||||
}else{
|
||||
issi_device = 3;
|
||||
}
|
||||
}else{
|
||||
twi_last_ready++;
|
||||
}
|
||||
#endif
|
||||
// Update layer indicator LED
|
||||
//
|
||||
// Not sure how else to reliably do this... TMK has the 'hook_layer_change'
|
||||
// but can't find QMK equiv
|
||||
static uint32_t layer_indicator = -1;
|
||||
if(layer_indicator != layer_state){
|
||||
for(uint32_t i=0;; i++){
|
||||
// the layer_info list should end with layer 0xFFFF
|
||||
// it will break this out of the loop and define the unknown layer color
|
||||
if((layer_info[i].layer == (layer_state & layer_info[i].mask)) || (layer_info[i].layer == 0xFFFFFFFF)){
|
||||
set_rgb(32, layer_info[i].color.red, layer_info[i].color.green, layer_info[i].color.blue);
|
||||
layer_indicator = layer_state;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
|
@ -115,7 +51,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record)
|
|||
}
|
||||
if (keycode == QK_BOOT) {
|
||||
reset_keyboard_kb();
|
||||
} else {
|
||||
}
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
|
@ -126,49 +61,5 @@ void reset_keyboard_kb(void){
|
|||
wdt_disable();
|
||||
wdt_reset();
|
||||
#endif
|
||||
set_rgb(31, 0x00, 0xFF, 0xFF);
|
||||
set_rgb(32, 0x00, 0xFF, 0xFF);
|
||||
force_issi_refresh();
|
||||
reset_keyboard();
|
||||
}
|
||||
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
// Set capslock LED to Blue
|
||||
if (led_state.caps_lock) {
|
||||
set_rgb(31, 0x00, 0x00, 0x7F);
|
||||
} else{
|
||||
set_rgb(31, 0x00, 0x00, 0x00);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Lighting info, see lighting.h for details
|
||||
const uint8_t switch_matrices[] = {0, 1};
|
||||
const uint8_t rgb_matrices[] = {6, 7};
|
||||
|
||||
// RGB Map:
|
||||
// 27 29 10 9 8 7 6
|
||||
// 26 5
|
||||
// 25 4
|
||||
// 24 3
|
||||
// 23 22 21 20 14 15 11 1 2
|
||||
const uint8_t rgb_sequence[] = {
|
||||
30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 15, 16
|
||||
};
|
||||
|
||||
// Maps switch LEDs from Row/Col to ISSI matrix.
|
||||
// Value breakdown:
|
||||
// Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
// | | ISSI Col | ISSI Row |
|
||||
// / |
|
||||
// Device
|
||||
const uint8_t switch_leds[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x99, 0x98, 0x97, 0x96, 0x00, 0x95, 0x94, 0x93, 0x92, 0x91},
|
||||
{0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0xA9, 0xA8, 0xA7, 0xA6, 0xA5, 0xB6, 0xA4, 0xA3, 0xA2, 0xA1},
|
||||
{0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0xB9, 0xB8, 0xB7, 0x00, 0x00, 0x00, 0xB5, 0xB3, 0x49, 0x48},
|
||||
{0x47, 0x00, 0x45, 0x44, 0x43, 0x42, 0x41, 0xC9, 0xC8, 0xC7, 0xC6, 0xC5, 0xC4, 0x00, 0xC2, 0x59, 0x58, 0x57, 0x56},
|
||||
{0x55, 0x51, 0xD6, 0x00, 0x00, 0xE5, 0x00, 0x00, 0x00, 0x00, 0xE4, 0xE3, 0xE2, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
|
|
|
@ -1,22 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "matrix.h"
|
||||
#include <avr/sfr_defs.h>
|
||||
|
||||
typedef struct RGB_Color {
|
||||
uint16_t red;
|
||||
uint16_t green;
|
||||
uint16_t blue;
|
||||
} RGB_Color;
|
||||
|
||||
typedef struct Layer_Info {
|
||||
uint32_t layer;
|
||||
uint32_t mask;
|
||||
RGB_Color color;
|
||||
} Layer_Info;
|
||||
|
||||
extern const uint32_t layer_count;
|
||||
extern const Layer_Info layer_info[];
|
||||
#include "quantum.h"
|
||||
|
||||
#define CLICK_HZ 500
|
||||
#define CLICK_MS 2
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
ifeq ($(strip $(ISSI_ENABLE)), yes)
|
||||
OPT_DEFS += -DISSI_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
|
||||
OPT_DEFS += -DWATCHDOG_ENABLE
|
||||
endif
|
||||
|
|
|
@ -7,13 +7,5 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
|
|||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable N-Key Rollover
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = yes # Audio output
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = yes # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
||||
# Extra source files for IS3731 lighting
|
||||
SRC = TWIlib.c issi.c lighting.c
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
ifeq ($(strip $(ISSI_ENABLE)), yes)
|
||||
OPT_DEFS += -DISSI_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
|
||||
OPT_DEFS += -DWATCHDOG_ENABLE
|
||||
endif
|
||||
|
|
|
@ -7,13 +7,5 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
|
|||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable N-Key Rollover
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = yes # Audio output
|
||||
SLEEP_LED_ENABLE = yes
|
||||
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = yes # Resets keyboard if matrix_scan isn't run every 250ms
|
||||
|
||||
# Extra source files for IS3731 lighting
|
||||
SRC = TWIlib.c issi.c lighting.c
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
|
||||
ISSI_ENABLE = no # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms
|
|
@ -1,8 +0,0 @@
|
|||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
|
||||
ISSI_ENABLE = no # If the I2C pullup resistors aren't install this must be disabled
|
||||
WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms
|
|
@ -1,7 +1,3 @@
|
|||
ifeq ($(strip $(ISSI_ENABLE)), yes)
|
||||
OPT_DEFS += -DISSI_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
|
||||
OPT_DEFS += -DWATCHDOG_ENABLE
|
||||
endif
|
||||
|
|
|
@ -30,8 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define AUDIO_VOICES
|
||||
#define AUDIO_PIN C6
|
||||
|
||||
#define BACKLIGHT_PWM_MAP {8, 16, 40, 55, 70, 128, 200, 255}
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
|
|
|
@ -2,29 +2,6 @@
|
|||
"usb": {
|
||||
"pid": "0x565B"
|
||||
},
|
||||
"backlight": {
|
||||
"levels": 8
|
||||
},
|
||||
"rgblight": {
|
||||
"driver": "custom",
|
||||
"hue_steps": 10,
|
||||
"led_count": 20,
|
||||
"animations": {
|
||||
"breathing": true,
|
||||
"rainbow_mood": true,
|
||||
"rainbow_swirl": true,
|
||||
"snake": true,
|
||||
"knight": true,
|
||||
"christmas": true,
|
||||
"static_gradient": true,
|
||||
"rgb_test": true,
|
||||
"alternating": true,
|
||||
"twinkle": true
|
||||
}
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "C7"
|
||||
},
|
||||
"processor": "at90usb646",
|
||||
"bootloader": "atmel-dfu",
|
||||
"layout_aliases": {
|
||||
|
|
|
@ -12,14 +12,8 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <avr/sfr_defs.h>
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "revb.h"
|
||||
#include "debug.h"
|
||||
#include "issi.h"
|
||||
#include "TWIlib.h"
|
||||
#include "lighting.h"
|
||||
#include <avr/wdt.h>
|
||||
|
||||
uint16_t click_hz = CLICK_HZ;
|
||||
uint16_t click_time = CLICK_MS;
|
||||
|
@ -40,10 +34,6 @@ void matrix_init_kb(void)
|
|||
setPinOutput(C6);
|
||||
writePinLow(C6);
|
||||
#endif
|
||||
|
||||
#ifdef ISSI_ENABLE
|
||||
issi_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void matrix_scan_kb(void)
|
||||
|
@ -75,7 +65,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record)
|
|||
}
|
||||
if (keycode == QK_BOOT) {
|
||||
reset_keyboard_kb();
|
||||
} else {
|
||||
}
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
|
@ -88,27 +77,3 @@ void reset_keyboard_kb(void){
|
|||
#endif
|
||||
reset_keyboard();
|
||||
}
|
||||
|
||||
// LFK lighting info
|
||||
const uint8_t switch_matrices[] = {0, 1};
|
||||
const uint8_t rgb_matrices[] = {6, 7};
|
||||
// const uint8_t rgb_sequence[] = {
|
||||
// 14, 24, 23, 22, 21, 20, 19, 18, 26, 25, 28, 29,
|
||||
// 30, 31, 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
|
||||
// };
|
||||
const uint8_t rgb_sequence[] = {
|
||||
25, 28, 29,
|
||||
30, 31, 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
|
||||
};
|
||||
// Maps switch LEDs from Row/Col to ISSI matrix.
|
||||
// Value breakdown:
|
||||
// Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
// / \ ISSI Col | ISSI Row |
|
||||
// matrix idx
|
||||
// const uint8_t switch_leds[MATRIX_ROWS][MATRIX_COLS] =
|
||||
// KEYMAP(
|
||||
// 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91,
|
||||
// 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0xA9, 0xA8, 0xA7, 0xA6, 0xA5, 0xA4, 0xA3, 0xA2, 0xA1,
|
||||
// 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0xB9, 0xB8, 0xB7, 0xB6, 0xB5, 0xB3,
|
||||
// 0x49, 0x48, 0x47, 0x45, 0x44, 0x43, 0x42, 0x41, 0xC9, 0xC8, 0xC7, 0xC6, 0xC5, 0xC4, 0xC2,
|
||||
// 0x59, 0x58, 0x57, 0x56, 0x55, 0x51, 0xD6, 0xE5, 0xE4, 0xE3, 0xE2, 0xE1);
|
||||
|
|
|
@ -15,23 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "matrix.h"
|
||||
#include <avr/sfr_defs.h>
|
||||
|
||||
typedef struct RGB_Color {
|
||||
uint16_t red;
|
||||
uint16_t green;
|
||||
uint16_t blue;
|
||||
} RGB_Color;
|
||||
|
||||
typedef struct Layer_Info {
|
||||
uint32_t layer;
|
||||
uint32_t mask;
|
||||
RGB_Color color;
|
||||
} Layer_Info;
|
||||
|
||||
extern const uint32_t layer_count;
|
||||
extern const Layer_Info layer_info[];
|
||||
|
||||
#define CLICK_HZ 500
|
||||
#define CLICK_MS 2
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
|
||||
# Extra source files for IS3731 lighting
|
||||
SRC += TWIlib.c issi.c lighting.c
|
|
@ -4,10 +4,6 @@
|
|||
},
|
||||
"processor": "atmega32u4",
|
||||
"bootloader": "halfkay",
|
||||
"rgblight": {
|
||||
"driver": "custom",
|
||||
"led_count": 28
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT_65_ansi": {
|
||||
"layout": [
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
RGBLIGHT_ENABLE = no # TODO: Enable keyboard RGB underglow
|
|
@ -1,300 +0,0 @@
|
|||
/*
|
||||
* TWIlib.c
|
||||
*
|
||||
* Created: 6/01/2014 10:41:33 PM
|
||||
* Author: Chris Herring
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "TWIlib.h"
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
|
||||
// Global transmit buffer
|
||||
volatile uint8_t *TWITransmitBuffer;
|
||||
// Global receive buffer
|
||||
volatile uint8_t TWIReceiveBuffer[RXMAXBUFLEN];
|
||||
// Buffer indexes
|
||||
volatile int TXBuffIndex; // Index of the transmit buffer. Is volatile, can change at any time.
|
||||
int RXBuffIndex; // Current index in the receive buffer
|
||||
// Buffer lengths
|
||||
int TXBuffLen; // The total length of the transmit buffer
|
||||
int RXBuffLen; // The total number of bytes to read (should be less than RXMAXBUFFLEN)
|
||||
|
||||
TWIInfoStruct TWIInfo;
|
||||
|
||||
void TWIInit(void)
|
||||
{
|
||||
TWIInfo.mode = Ready;
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWIInfo.repStart = 0;
|
||||
// Set pre-scalers (no pre-scaling)
|
||||
TWSR = 0;
|
||||
// Set bit rate
|
||||
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
|
||||
// Enable TWI and interrupt
|
||||
TWCR = (1 << TWIE) | (1 << TWEN);
|
||||
}
|
||||
|
||||
uint8_t isTWIReady(void)
|
||||
{
|
||||
if ( (TWIInfo.mode == Ready) | (TWIInfo.mode == RepeatedStartSent) )
|
||||
{
|
||||
|
||||
// xprintf("i2c ready\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(TWIInfo.mode == Initializing){
|
||||
switch(TWIInfo.errorCode){
|
||||
case TWI_SUCCESS:
|
||||
break;
|
||||
case TWI_NO_RELEVANT_INFO:
|
||||
|
||||
break;
|
||||
case TWI_LOST_ARBIT:
|
||||
case TWI_MT_DATA_NACK:
|
||||
// Some kind of I2C error, reset and re-init
|
||||
xprintf("I2C init error: %d\n", TWIInfo.errorCode);
|
||||
TWCR = (1 << TWINT)|(1 << TWSTO);
|
||||
TWIInit();
|
||||
break;
|
||||
default:
|
||||
xprintf("Other i2c init error: %d\n", TWIInfo.errorCode);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart, uint8_t blocking)
|
||||
{
|
||||
// Wait until ready
|
||||
while (!isTWIReady()) {_delay_us(1);}
|
||||
// Reset the I2C stuff
|
||||
TWCR = (1 << TWINT)|(1 << TWSTO);
|
||||
TWIInit();
|
||||
// Set repeated start mode
|
||||
TWIInfo.repStart = repStart;
|
||||
// Copy transmit info to global variables
|
||||
TWITransmitBuffer = (uint8_t *)TXdata;
|
||||
TXBuffLen = dataLen;
|
||||
TXBuffIndex = 0;
|
||||
|
||||
// If a repeated start has been sent, then devices are already listening for an address
|
||||
// and another start does not need to be sent.
|
||||
if (TWIInfo.mode == RepeatedStartSent)
|
||||
{
|
||||
TWIInfo.mode = Initializing;
|
||||
TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
|
||||
TWISendTransmit(); // Send the data
|
||||
}
|
||||
else // Otherwise, just send the normal start signal to begin transmission.
|
||||
{
|
||||
TWIInfo.mode = Initializing;
|
||||
TWISendStart();
|
||||
}
|
||||
if(blocking){
|
||||
// Wait until ready
|
||||
while (!isTWIReady()){_delay_us(1);}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// uint8_t TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart)
|
||||
// {
|
||||
// if (dataLen <= TXMAXBUFLEN)
|
||||
// {
|
||||
// // Wait until ready
|
||||
// while (!isTWIReady()) {_delay_us(1);}
|
||||
// // Set repeated start mode
|
||||
// TWIInfo.repStart = repStart;
|
||||
// // Copy data into the transmit buffer
|
||||
// uint8_t *data = (uint8_t *)TXdata;
|
||||
// for (int i = 0; i < dataLen; i++)
|
||||
// {
|
||||
// TWITransmitBuffer[i] = data[i];
|
||||
// }
|
||||
// // Copy transmit info to global variables
|
||||
// TXBuffLen = dataLen;
|
||||
// TXBuffIndex = 0;
|
||||
|
||||
// // If a repeated start has been sent, then devices are already listening for an address
|
||||
// // and another start does not need to be sent.
|
||||
// if (TWIInfo.mode == RepeatedStartSent)
|
||||
// {
|
||||
// TWIInfo.mode = Initializing;
|
||||
// TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
|
||||
// TWISendTransmit(); // Send the data
|
||||
// }
|
||||
// else // Otherwise, just send the normal start signal to begin transmission.
|
||||
// {
|
||||
// TWIInfo.mode = Initializing;
|
||||
// TWISendStart();
|
||||
// }
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 1; // return an error if data length is longer than buffer
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
uint8_t TWIReadData(uint8_t TWIaddr, uint8_t bytesToRead, uint8_t repStart)
|
||||
{
|
||||
// Check if number of bytes to read can fit in the RXbuffer
|
||||
if (bytesToRead < RXMAXBUFLEN)
|
||||
{
|
||||
// Reset buffer index and set RXBuffLen to the number of bytes to read
|
||||
RXBuffIndex = 0;
|
||||
RXBuffLen = bytesToRead;
|
||||
// Create the one value array for the address to be transmitted
|
||||
uint8_t TXdata[1];
|
||||
// Shift the address and AND a 1 into the read write bit (set to write mode)
|
||||
TXdata[0] = (TWIaddr << 1) | 0x01;
|
||||
// Use the TWITransmitData function to initialize the transfer and address the slave
|
||||
TWITransmitData(TXdata, 1, repStart, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
ISR (TWI_vect)
|
||||
{
|
||||
switch (TWI_STATUS)
|
||||
{
|
||||
// ----\/ ---- MASTER TRANSMITTER OR WRITING ADDRESS ----\/ ---- //
|
||||
case TWI_MT_SLAW_ACK: // SLA+W transmitted and ACK received
|
||||
// Set mode to Master Transmitter
|
||||
TWIInfo.mode = MasterTransmitter;
|
||||
case TWI_START_SENT: // Start condition has been transmitted
|
||||
case TWI_MT_DATA_ACK: // Data byte has been transmitted, ACK received
|
||||
if (TXBuffIndex < TXBuffLen) // If there is more data to send
|
||||
{
|
||||
TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendTransmit(); // Send the data
|
||||
}
|
||||
// This transmission is complete however do not release bus yet
|
||||
else if (TWIInfo.repStart)
|
||||
{
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWISendStart();
|
||||
}
|
||||
// All transmissions are complete, exit
|
||||
else
|
||||
{
|
||||
TWIInfo.mode = Ready;
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWISendStop();
|
||||
}
|
||||
break;
|
||||
|
||||
// ----\/ ---- MASTER RECEIVER ----\/ ---- //
|
||||
|
||||
case TWI_MR_SLAR_ACK: // SLA+R has been transmitted, ACK has been received
|
||||
// Switch to Master Receiver mode
|
||||
TWIInfo.mode = MasterReceiver;
|
||||
// If there is more than one byte to be read, receive data byte and return an ACK
|
||||
if (RXBuffIndex < RXBuffLen-1)
|
||||
{
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendACK();
|
||||
}
|
||||
// Otherwise when a data byte (the only data byte) is received, return NACK
|
||||
else
|
||||
{
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendNACK();
|
||||
}
|
||||
break;
|
||||
|
||||
case TWI_MR_DATA_ACK: // Data has been received, ACK has been transmitted.
|
||||
|
||||
/// -- HANDLE DATA BYTE --- ///
|
||||
TWIReceiveBuffer[RXBuffIndex++] = TWDR;
|
||||
// If there is more than one byte to be read, receive data byte and return an ACK
|
||||
if (RXBuffIndex < RXBuffLen-1)
|
||||
{
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendACK();
|
||||
}
|
||||
// Otherwise when a data byte (the only data byte) is received, return NACK
|
||||
else
|
||||
{
|
||||
TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
|
||||
TWISendNACK();
|
||||
}
|
||||
break;
|
||||
|
||||
case TWI_MR_DATA_NACK: // Data byte has been received, NACK has been transmitted. End of transmission.
|
||||
|
||||
/// -- HANDLE DATA BYTE --- ///
|
||||
TWIReceiveBuffer[RXBuffIndex++] = TWDR;
|
||||
// This transmission is complete however do not release bus yet
|
||||
if (TWIInfo.repStart)
|
||||
{
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWISendStart();
|
||||
}
|
||||
// All transmissions are complete, exit
|
||||
else
|
||||
{
|
||||
TWIInfo.mode = Ready;
|
||||
TWIInfo.errorCode = 0xFF;
|
||||
TWISendStop();
|
||||
}
|
||||
break;
|
||||
|
||||
// ----\/ ---- MT and MR common ----\/ ---- //
|
||||
|
||||
case TWI_MR_SLAR_NACK: // SLA+R transmitted, NACK received
|
||||
case TWI_MT_SLAW_NACK: // SLA+W transmitted, NACK received
|
||||
case TWI_MT_DATA_NACK: // Data byte has been transmitted, NACK received
|
||||
case TWI_LOST_ARBIT: // Arbitration has been lost
|
||||
// Return error and send stop and set mode to ready
|
||||
if (TWIInfo.repStart)
|
||||
{
|
||||
TWIInfo.errorCode = TWI_STATUS;
|
||||
TWISendStart();
|
||||
}
|
||||
// All transmissions are complete, exit
|
||||
else
|
||||
{
|
||||
TWIInfo.mode = Ready;
|
||||
TWIInfo.errorCode = TWI_STATUS;
|
||||
TWISendStop();
|
||||
}
|
||||
break;
|
||||
case TWI_REP_START_SENT: // Repeated start has been transmitted
|
||||
// Set the mode but DO NOT clear TWINT as the next data is not yet ready
|
||||
TWIInfo.mode = RepeatedStartSent;
|
||||
break;
|
||||
|
||||
// ----\/ ---- SLAVE RECEIVER ----\/ ---- //
|
||||
|
||||
// TODO IMPLEMENT SLAVE RECEIVER FUNCTIONALITY
|
||||
|
||||
// ----\/ ---- SLAVE TRANSMITTER ----\/ ---- //
|
||||
|
||||
// TODO IMPLEMENT SLAVE TRANSMITTER FUNCTIONALITY
|
||||
|
||||
// ----\/ ---- MISCELLANEOUS STATES ----\/ ---- //
|
||||
case TWI_NO_RELEVANT_INFO: // It is not really possible to get into this ISR on this condition
|
||||
// Rather, it is there to be manually set between operations
|
||||
break;
|
||||
case TWI_ILLEGAL_START_STOP: // Illegal START/STOP, abort and return error
|
||||
TWIInfo.errorCode = TWI_ILLEGAL_START_STOP;
|
||||
TWIInfo.mode = Ready;
|
||||
TWISendStop();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* TWIlib.h
|
||||
*
|
||||
* Created: 6/01/2014 10:38:42 PM
|
||||
* Author: Chris Herring
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TWILIB_H_
|
||||
#define TWILIB_H_
|
||||
// TWI bit rate
|
||||
#define TWI_FREQ 400000
|
||||
// Get TWI status
|
||||
#define TWI_STATUS (TWSR & 0xF8)
|
||||
// Transmit buffer length
|
||||
#define TXMAXBUFLEN 20
|
||||
// Receive buffer length
|
||||
#define RXMAXBUFLEN 20
|
||||
|
||||
typedef enum {
|
||||
Ready,
|
||||
Initializing,
|
||||
RepeatedStartSent,
|
||||
MasterTransmitter,
|
||||
MasterReceiver,
|
||||
SlaceTransmitter,
|
||||
SlaveReciever
|
||||
} TWIMode;
|
||||
|
||||
typedef struct TWIInfoStruct{
|
||||
TWIMode mode;
|
||||
uint8_t errorCode;
|
||||
uint8_t repStart;
|
||||
}TWIInfoStruct;
|
||||
|
||||
extern TWIInfoStruct TWIInfo;
|
||||
|
||||
// TWI Status Codes
|
||||
#define TWI_START_SENT 0x08 // Start sent
|
||||
#define TWI_REP_START_SENT 0x10 // Repeated Start sent
|
||||
// Master Transmitter Mode
|
||||
#define TWI_MT_SLAW_ACK 0x18 // SLA+W sent and ACK received
|
||||
#define TWI_MT_SLAW_NACK 0x20 // SLA+W sent and NACK received
|
||||
#define TWI_MT_DATA_ACK 0x28 // DATA sent and ACK received
|
||||
#define TWI_MT_DATA_NACK 0x30 // DATA sent and NACK received
|
||||
// Master Receiver Mode
|
||||
#define TWI_MR_SLAR_ACK 0x40 // SLA+R sent, ACK received
|
||||
#define TWI_MR_SLAR_NACK 0x48 // SLA+R sent, NACK received
|
||||
#define TWI_MR_DATA_ACK 0x50 // Data received, ACK returned
|
||||
#define TWI_MR_DATA_NACK 0x58 // Data received, NACK returned
|
||||
|
||||
// Miscellaneous States
|
||||
#define TWI_LOST_ARBIT 0x38 // Arbitration has been lost
|
||||
#define TWI_NO_RELEVANT_INFO 0xF8 // No relevant information available
|
||||
#define TWI_ILLEGAL_START_STOP 0x00 // Illegal START or STOP condition has been detected
|
||||
#define TWI_SUCCESS 0xFF // Successful transfer, this state is impossible from TWSR as bit2 is 0 and read only
|
||||
|
||||
|
||||
#define TWISendStart() (TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE)) // Send the START signal, enable interrupts and TWI, clear TWINT flag to resume transfer.
|
||||
#define TWISendStop() (TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN)|(1<<TWIE)) // Send the STOP signal, enable interrupts and TWI, clear TWINT flag.
|
||||
#define TWISendTransmit() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)) // Used to resume a transfer, clear TWINT and ensure that TWI and interrupts are enabled.
|
||||
#define TWISendACK() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)|(1<<TWEA)) // FOR MR mode. Resume a transfer, ensure that TWI and interrupts are enabled and respond with an ACK if the device is addressed as a slave or after it receives a byte.
|
||||
#define TWISendNACK() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)) // FOR MR mode. Resume a transfer, ensure that TWI and interrupts are enabled but DO NOT respond with an ACK if the device is addressed as a slave or after it receives a byte.
|
||||
|
||||
// Function declarations
|
||||
void TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart, uint8_t blocking);
|
||||
void TWIInit(void);
|
||||
uint8_t TWIReadData(uint8_t TWIaddr, uint8_t bytesToRead, uint8_t repStart);
|
||||
uint8_t isTWIReady(void);
|
||||
|
||||
#endif // TWICOMMS_H_
|
|
@ -21,5 +21,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
/* key matrix size */
|
||||
#define MATRIX_ROWS 4
|
||||
#define MATRIX_COLS 12
|
||||
|
||||
#define BACKLIGHT_PWM_MAP {2, 4, 8, 16, 40, 55, 70, 128, 200, 255}
|
||||
|
|
|
@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
// Column pins to demux in LSB order
|
||||
#define MATRIX_COL_PINS { C7, B7, B6, C6, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN }
|
||||
#define MATRIX_COL_PINS_SCANNED { C7, B7, B6, C6 }
|
||||
#define LED_EN_PIN D2
|
||||
|
||||
#define AUDIO_PIN B5
|
||||
#define AUDIO_VOICES
|
||||
|
|
|
@ -8,16 +8,6 @@
|
|||
"pid": "0x6061",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"backlight": {
|
||||
"driver": "custom",
|
||||
"levels": 10
|
||||
},
|
||||
"rgblight": {
|
||||
"led_count": 15
|
||||
},
|
||||
"ws2812": {
|
||||
"pin": "D3"
|
||||
},
|
||||
"processor": "atmega32u4",
|
||||
"bootloader": "caterina",
|
||||
"layout_aliases": {
|
||||
|
|
|
@ -1,286 +0,0 @@
|
|||
#ifdef ISSI_ENABLE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/sfr_defs.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/twi.h>
|
||||
#include "issi.h"
|
||||
#include "print.h"
|
||||
#include "TWIlib.h"
|
||||
|
||||
#define ISSI_ADDR_DEFAULT 0xE8
|
||||
|
||||
#define ISSI_REG_CONFIG 0x00
|
||||
#define ISSI_REG_CONFIG_PICTUREMODE 0x00
|
||||
#define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08
|
||||
|
||||
#define ISSI_CONF_PICTUREMODE 0x00
|
||||
#define ISSI_CONF_AUTOFRAMEMODE 0x04
|
||||
#define ISSI_CONF_AUDIOMODE 0x08
|
||||
|
||||
#define ISSI_REG_PICTUREFRAME 0x01
|
||||
|
||||
#define ISSI_REG_SHUTDOWN 0x0A
|
||||
#define ISSI_REG_AUDIOSYNC 0x06
|
||||
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
|
||||
uint8_t control[8][9] = {
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
};
|
||||
ISSIDeviceStruct *issi_devices[4] = {0, 0, 0, 0};
|
||||
|
||||
#ifndef cbi
|
||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||
#endif
|
||||
|
||||
#ifndef sbi
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
#define I2C_WRITE 0
|
||||
#define F_SCL 400000UL // SCL frequency
|
||||
#define Prescaler 1
|
||||
#define TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16 ) / 2)
|
||||
|
||||
uint8_t i2c_start(uint8_t address)
|
||||
{
|
||||
// reset TWI control register
|
||||
TWCR = 0;
|
||||
// transmit START condition
|
||||
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
|
||||
// wait for end of transmission
|
||||
while( !(TWCR & (1<<TWINT)) );
|
||||
|
||||
// check if the start condition was successfully transmitted
|
||||
if((TWSR & 0xF8) != TW_START){ return 1; }
|
||||
|
||||
// load slave address into data register
|
||||
TWDR = address;
|
||||
// start transmission of address
|
||||
TWCR = (1<<TWINT) | (1<<TWEN);
|
||||
// wait for end of transmission
|
||||
while( !(TWCR & (1<<TWINT)) );
|
||||
|
||||
// check if the device has acknowledged the READ / WRITE mode
|
||||
uint8_t twst = TW_STATUS & 0xF8;
|
||||
if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t i2c_write(uint8_t data)
|
||||
{
|
||||
// load data into data register
|
||||
TWDR = data;
|
||||
// start transmission of data
|
||||
TWCR = (1 << TWINT) | (1 << TWEN);
|
||||
// wait for end of transmission
|
||||
while (!(TWCR & (1 << TWINT)))
|
||||
;
|
||||
|
||||
if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length)
|
||||
{
|
||||
TWBR = (uint8_t)TWBR_val;
|
||||
if (i2c_start(address | I2C_WRITE))
|
||||
return 1;
|
||||
for (uint16_t i = 0; i < length; i++) {
|
||||
if (i2c_write(data[i]))
|
||||
return 1;
|
||||
}
|
||||
// transmit STOP condition
|
||||
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setFrame(uint8_t device, uint8_t frame)
|
||||
{
|
||||
static uint8_t current_frame = -1;
|
||||
if(current_frame != frame){
|
||||
uint8_t payload[] = {
|
||||
ISSI_ADDR_DEFAULT | device << 1,
|
||||
ISSI_COMMANDREGISTER,
|
||||
frame
|
||||
};
|
||||
TWITransmitData(payload, sizeof(payload), 0, 1);
|
||||
}
|
||||
// static uint8_t current_frame = 0xFF;
|
||||
// if(current_frame == frame){
|
||||
// // return;
|
||||
// }
|
||||
// uint8_t payload[2] = { ISSI_COMMANDREGISTER, frame };
|
||||
// i2c_transmit(ISSI_ADDR_DEFAULT | device << 1, payload, 2);
|
||||
// current_frame = frame;
|
||||
}
|
||||
|
||||
void writeRegister8(uint8_t device, uint8_t frame, uint8_t reg, uint8_t data)
|
||||
{
|
||||
// Set the frame
|
||||
setFrame(device, frame);
|
||||
|
||||
// Write to the register
|
||||
uint8_t payload[] = {
|
||||
ISSI_ADDR_DEFAULT | device << 1,
|
||||
reg,
|
||||
data
|
||||
};
|
||||
TWITransmitData(payload, sizeof(payload), 0, 1);
|
||||
}
|
||||
|
||||
// void activateLED(uint8_t matrix, uint8_t cx, uint8_t cy, uint8_t pwm)
|
||||
// {
|
||||
// xprintf("activeLED: %02X %02X %02X %02X\n", matrix, cy, cx, pwm);
|
||||
// uint8_t x = cx - 1; // funciton takes 1 based counts, but we need 0...
|
||||
// uint8_t y = cy - 1; // creating them once for less confusion
|
||||
// if(pwm == 0){
|
||||
// cbi(control[matrix][y], x);
|
||||
// }else{
|
||||
// sbi(control[matrix][y], x);
|
||||
// }
|
||||
// uint8_t device = (matrix & 0x06) >> 1;
|
||||
// uint8_t control_reg = (y << 1) | (matrix & 0x01);
|
||||
// uint8_t pwm_reg = 0;
|
||||
// switch(matrix & 0x01){
|
||||
// case 0:
|
||||
// pwm_reg = 0x24;
|
||||
// break;
|
||||
// case 1:
|
||||
// pwm_reg = 0x2C;
|
||||
// break;
|
||||
// }
|
||||
// pwm_reg += (y << 4) + x;
|
||||
// xprintf(" device: %02X\n", device);
|
||||
// xprintf(" control: %02X %02X\n", control_reg, control[matrix][y]);
|
||||
// xprintf(" pwm: %02X %02X\n", pwm_reg, pwm);
|
||||
// writeRegister8(device, 0, control_reg, control[matrix][y]);
|
||||
// writeRegister8(device, 0, control_reg + 0x12, control[matrix][y]);
|
||||
// writeRegister8(device, 0, pwm_reg, pwm);
|
||||
// }
|
||||
|
||||
void activateLED(uint8_t matrix, uint8_t cx, uint8_t cy, uint8_t pwm)
|
||||
{
|
||||
uint8_t device_addr = (matrix & 0x06) >> 1;
|
||||
ISSIDeviceStruct *device = issi_devices[device_addr];
|
||||
if(device == 0){
|
||||
return;
|
||||
}
|
||||
// xprintf("activeLED: %02X %02X %02X %02X\n", matrix, cy, cx, pwm);
|
||||
uint8_t x = cx - 1; // funciton takes 1 based counts, but we need 0...
|
||||
uint8_t y = cy - 1; // creating them once for less confusion
|
||||
uint8_t control_reg = (y << 1) | (matrix & 0x01);
|
||||
if(pwm == 0){
|
||||
cbi(device->led_ctrl[control_reg], x);
|
||||
cbi(device->led_blink_ctrl[control_reg], x);
|
||||
}else{
|
||||
sbi(device->led_ctrl[control_reg], x);
|
||||
sbi(device->led_blink_ctrl[control_reg], x);
|
||||
}
|
||||
uint8_t pwm_reg = 0;
|
||||
switch(matrix & 0x01){
|
||||
case 0:
|
||||
pwm_reg = 0x00;
|
||||
break;
|
||||
case 1:
|
||||
pwm_reg = 0x08;
|
||||
break;
|
||||
}
|
||||
pwm_reg += (y << 4) + x;
|
||||
// xprintf(" device_addr: %02X\n", device_addr);
|
||||
// xprintf(" control: %02X %02X\n", control_reg, control[matrix][y]);
|
||||
// xprintf(" pwm: %02X %02X\n", pwm_reg, pwm);
|
||||
// writeRegister8(device_addr, 0, control_reg, control[matrix][y]);
|
||||
device->led_pwm[pwm_reg] = pwm;
|
||||
device->led_dirty = 1;
|
||||
|
||||
// writeRegister8(device_addr, 0, control_reg + 0x12, control[matrix][y]);
|
||||
// writeRegister8(device_addr, 0, pwm_reg, pwm);
|
||||
}
|
||||
|
||||
void update_issi(uint8_t device_addr, uint8_t blocking)
|
||||
{
|
||||
// This seems to take about 6ms
|
||||
ISSIDeviceStruct *device = issi_devices[device_addr];
|
||||
if(device != 0){
|
||||
if(device->fn_dirty){
|
||||
device->fn_dirty = 0;
|
||||
setFrame(device_addr, ISSI_BANK_FUNCTIONREG);
|
||||
TWITransmitData(&device->fn_device_addr, sizeof(device->fn_registers) + 2, 0, 1);
|
||||
}
|
||||
if(device->led_dirty){
|
||||
device->led_dirty = 0;
|
||||
setFrame(device_addr, 0);
|
||||
TWITransmitData(&device->led_device_addr, 0xB6, 0, blocking);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void issi_init(void)
|
||||
{
|
||||
// Set LED_EN/SDB high to enable the chip
|
||||
xprintf("Enabing SDB on pin: %d\n", LED_EN_PIN);
|
||||
_SFR_IO8((LED_EN_PIN >> 4) + 1) &= ~_BV(LED_EN_PIN & 0xF); // IN
|
||||
_SFR_IO8((LED_EN_PIN >> 4) + 2) |= _BV(LED_EN_PIN & 0xF); // HI
|
||||
TWIInit();
|
||||
for(uint8_t device_addr = 0; device_addr < 4; device_addr++){
|
||||
xprintf("ISSI Init device: %d\n", device_addr);
|
||||
// If this device has been previously allocated, free it
|
||||
if(issi_devices[device_addr] != 0){
|
||||
free(issi_devices[device_addr]);
|
||||
}
|
||||
// Try to shutdown the device, if this fails skip this device
|
||||
writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x00);
|
||||
while (!isTWIReady()){_delay_us(1);}
|
||||
if(TWIInfo.errorCode != 0xFF){
|
||||
xprintf("ISSI init failed %d %02X %02X\n", device_addr, TWIInfo.mode, TWIInfo.errorCode);
|
||||
continue;
|
||||
}
|
||||
// Allocate the device structure - calloc zeros it for us
|
||||
ISSIDeviceStruct *device = (ISSIDeviceStruct *)calloc(sizeof(ISSIDeviceStruct) * 2, 1);
|
||||
issi_devices[device_addr] = device;
|
||||
device->fn_device_addr = ISSI_ADDR_DEFAULT | device_addr << 1;
|
||||
device->fn_register_addr = 0;
|
||||
device->led_device_addr = ISSI_ADDR_DEFAULT | device_addr << 1;
|
||||
device->led_register_addr = 0;
|
||||
// set dirty bits so that all of the buffered data is written out
|
||||
device->fn_dirty = 1;
|
||||
device->led_dirty = 1;
|
||||
update_issi(device_addr, 1);
|
||||
// Set the function register to picture mode
|
||||
// device->fn_reg[ISSI_REG_CONFIG] = ISSI_REG_CONFIG_PICTUREMODE;
|
||||
writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x01);
|
||||
}
|
||||
|
||||
// Shutdown and set all registers to 0
|
||||
// writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x00);
|
||||
// for(uint8_t bank = 0; bank <= 7; bank++){
|
||||
// for (uint8_t reg = 0x00; reg <= 0xB3; reg++) {
|
||||
// writeRegister8(device_addr, bank, reg, 0x00);
|
||||
// }
|
||||
// }
|
||||
// for (uint8_t reg = 0; reg <= 0x0C; reg++) {
|
||||
// writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, reg, 0x00);
|
||||
// }
|
||||
// writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE);
|
||||
// writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x01);
|
||||
// picture mode
|
||||
// writeRegister8(ISSI_BANK_FUNCTIONREG, 0x01, 0x01);
|
||||
|
||||
//Enable blink
|
||||
// writeRegister8(ISSI_BANK_FUNCTIONREG, 0x05, 0x48B);
|
||||
|
||||
//Enable Breath
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef ISSI_ENABLE
|
||||
|
||||
typedef struct ISSIDeviceStruct{
|
||||
uint8_t fn_dirty; // function registers need to be resent
|
||||
uint8_t fn_device_addr;
|
||||
uint8_t fn_register_addr;
|
||||
uint8_t fn_registers[13];
|
||||
uint8_t led_dirty; // LED data has changed and needs to be resent
|
||||
uint8_t led_device_addr;
|
||||
uint8_t led_register_addr;
|
||||
uint8_t led_ctrl[18];
|
||||
uint8_t led_blink_ctrl[18];
|
||||
uint8_t led_pwm[144];
|
||||
}ISSIDeviceStruct;
|
||||
|
||||
extern ISSIDeviceStruct *issi_devices[];
|
||||
|
||||
// Low level commands- 'device' is the 2-bit i2c id.
|
||||
void issi_init(void);
|
||||
void set_shutdown(uint8_t device, uint8_t shutdown);
|
||||
void writeRegister8(uint8_t device, uint8_t frame, uint8_t reg, uint8_t data);
|
||||
|
||||
// Higher level, no device is given, but it is calculated from 'matrix'
|
||||
// Each device has 2 blocks, max of 4 devices:
|
||||
// Device | Block = Matrix
|
||||
// 0 A 0
|
||||
// 0 B 1
|
||||
// 1 A 2
|
||||
// 1 B 3
|
||||
// 2 A 4
|
||||
// 2 B 5
|
||||
// 3 A 6
|
||||
// 3 B 7
|
||||
void activateLED(uint8_t matrix, uint8_t cx, uint8_t cy, uint8_t pwm);
|
||||
void update_issi(uint8_t device_addr, uint8_t blocking);
|
||||
|
||||
#endif
|
|
@ -14,7 +14,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "lighting.h"
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
//Following line allows macro to read current RGB settings
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "lighting.h"
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
// Following line allows macro to read current RGB settings
|
||||
|
|
|
@ -268,15 +268,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
return false;
|
||||
break;
|
||||
case BL_TOGG:
|
||||
#ifdef ISSI_ENABLE
|
||||
if (record->event.pressed) {
|
||||
print("Enabling backlight\n");
|
||||
issi_init();
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
break;
|
||||
case BL_STEP:
|
||||
if (record->event.pressed) {
|
||||
print("Stepping backlight\n");
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
AUDIO_ENABLE = yes # Audio output on port C6
|
||||
LTO_ENABLE = yes # -4-7k
|
||||
MOUSEKEY_ENABLE = no # Mouse keys(-47kb)
|
||||
ISSI_ENABLE = no
|
||||
BACKLIGHT_ENABLE = no
|
|
@ -14,7 +14,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "lighting.h"
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
//Following line allows macro to read current RGB settings
|
||||
|
@ -189,15 +188,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
return false;
|
||||
break;
|
||||
case BL_TOGG:
|
||||
#ifdef ISSI_ENABLE
|
||||
if (record->event.pressed) {
|
||||
print("Enabling backlight\n");
|
||||
issi_init();
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
break;
|
||||
case BL_STEP:
|
||||
if (record->event.pressed) {
|
||||
print("Stepping backlight\n");
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
#ifdef ISSI_ENABLE
|
||||
|
||||
|
||||
#include <avr/sfr_defs.h>
|
||||
#include <avr/timer_avr.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "meira.h"
|
||||
#include "issi.h"
|
||||
#include "TWIlib.h"
|
||||
#include "lighting.h"
|
||||
#include "debug.h"
|
||||
#include "audio.h"
|
||||
|
||||
|
||||
const uint8_t backlight_pwm_map[BACKLIGHT_LEVELS] = BACKLIGHT_PWM_MAP;
|
||||
|
||||
const uint8_t switch_matrices[] = {0, 1};
|
||||
|
||||
void backlight_set(uint8_t level){
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
uint8_t pwm_value = 0;
|
||||
if(level >= BACKLIGHT_LEVELS){
|
||||
level = BACKLIGHT_LEVELS;
|
||||
}
|
||||
if(level > 0){
|
||||
pwm_value = backlight_pwm_map[level-1];
|
||||
}
|
||||
xprintf("BACKLIGHT_LEVELS: %d\n", BACKLIGHT_LEVELS);
|
||||
xprintf("backlight_set level: %d pwm: %d\n", level, pwm_value);
|
||||
for(int x = 1; x <= 9; x++){
|
||||
for(int y = 1; y <= 9; y++){
|
||||
activateLED(switch_matrices[0], x, y, pwm_value);
|
||||
activateLED(switch_matrices[1], x, y, pwm_value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void set_backlight_by_keymap(uint8_t col, uint8_t row){
|
||||
// dprintf("LED: %02X, %d %d %d\n", lookup_value, matrix, led_col, led_row);
|
||||
// activateLED(matrix, led_col, led_row, 255);
|
||||
}
|
||||
|
||||
void force_issi_refresh(void){
|
||||
issi_devices[0]->led_dirty = true;
|
||||
update_issi(0, true);
|
||||
issi_devices[3]->led_dirty = true;
|
||||
update_issi(3, true);
|
||||
}
|
||||
|
||||
void led_test(void){
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
// This test take a long time to run, disable the WTD until its complete
|
||||
wdt_disable();
|
||||
#endif
|
||||
backlight_set(0);
|
||||
force_issi_refresh();
|
||||
// for(uint8_t x = 0; x < sizeof(rgb_sequence); x++){
|
||||
// set_rgb(rgb_sequence[x], 255, 0, 0);
|
||||
// force_issi_refresh();
|
||||
// _delay_ms(250);
|
||||
// set_rgb(rgb_sequence[x], 0, 255, 0);
|
||||
// force_issi_refresh();
|
||||
// _delay_ms(250);
|
||||
// set_rgb(rgb_sequence[x], 0, 0, 255);
|
||||
// force_issi_refresh();
|
||||
// _delay_ms(250);
|
||||
// set_rgb(rgb_sequence[x], 0, 0, 0);
|
||||
// force_issi_refresh();
|
||||
// }
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
wdt_enable(WDTO_250MS);
|
||||
#endif
|
||||
}
|
||||
|
||||
void backlight_init_ports(void){
|
||||
xprintf("backlight_init_ports\n");
|
||||
issi_init();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
void led_test(void);
|
||||
void force_issi_refresh(void);
|
||||
void set_backlight(uint8_t level);
|
||||
void set_backlight_by_keymap(uint8_t col, uint8_t row);
|
|
@ -19,18 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
/*
|
||||
* scan matrix
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#if defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#endif
|
||||
#include "matrix.h"
|
||||
#include "meira.h"
|
||||
#include "wait.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
#include "config.h"
|
||||
#include "timer.h"
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
|
|
|
@ -14,24 +14,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "meira.h"
|
||||
#include "issi.h"
|
||||
#include "TWIlib.h"
|
||||
#include "lighting.h"
|
||||
#include "quantum.h"
|
||||
|
||||
extern void backlight_set(uint8_t level);
|
||||
|
||||
void matrix_init_kb(void)
|
||||
{
|
||||
debug_enable=true;
|
||||
print("meira matrix_init_kb\n");
|
||||
|
||||
#ifdef ISSI_ENABLE
|
||||
issi_init();
|
||||
#endif
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
backlight_set(5);
|
||||
#endif
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
// This is done after turning the layer LED red, if we're caught in a loop
|
||||
// we should get a flashing red light
|
||||
|
@ -47,30 +35,6 @@ void matrix_scan_kb(void)
|
|||
{
|
||||
#ifdef WATCHDOG_ENABLE
|
||||
wdt_reset();
|
||||
#endif
|
||||
#ifdef ISSI_ENABLE
|
||||
// switch/underglow lighting update
|
||||
static uint32_t issi_device = 0;
|
||||
static uint32_t twi_last_ready = 0;
|
||||
if(twi_last_ready > 1000){
|
||||
// Its been way too long since the last ISSI update, reset the I2C bus and start again
|
||||
xprintf("TWI failed to recover, TWI re-init\n");
|
||||
twi_last_ready = 0;
|
||||
TWIInit();
|
||||
force_issi_refresh();
|
||||
}
|
||||
if(isTWIReady()){
|
||||
twi_last_ready = 0;
|
||||
// If the i2c bus is available, kick off the issi update, alternate between devices
|
||||
update_issi(issi_device, issi_device);
|
||||
if(issi_device){
|
||||
issi_device = 0;
|
||||
}else{
|
||||
issi_device = 3;
|
||||
}
|
||||
}else{
|
||||
twi_last_ready++;
|
||||
}
|
||||
#endif
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
@ -80,9 +44,8 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
|||
// set_backlight_by_keymap(record->event.key.col, record->event.key.row);
|
||||
if (keycode == QK_BOOT) {
|
||||
reset_keyboard_kb();
|
||||
} else {
|
||||
}
|
||||
return process_record_user(keycode, record);
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
|
||||
void reset_keyboard_kb(void){
|
||||
|
|
|
@ -16,6 +16,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "issi.h"
|
||||
|
||||
void reset_keyboard_kb(void);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
SRC += matrix.c TWIlib.c issi.c lighting.c
|
||||
|
||||
#ifeq ($(strip $(ISSI_ENABLE)), yes)
|
||||
# OPT_DEFS += -DISSI_ENABLE
|
||||
#endif
|
||||
|
||||
#ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
|
||||
# OPT_DEFS += -DWATCHDOG_ENABLE
|
||||
#endif
|
|
@ -33,8 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define MATRIX_COL_PINS { B1, B3, B2, B6, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN }
|
||||
#define MATRIX_COL_PINS_SCANNED { B1, B3, B2, B6 }
|
||||
|
||||
#define LED_EN_PIN D2
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
|
|
|
@ -7,11 +7,11 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
|
|||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = no # Enable N-Key Rollover
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality, also set ISSI_ENABLE below for Meira
|
||||
ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
|
||||
CUSTOM_MATRIX = yes
|
||||
SRC += matrix.c
|
||||
|
||||
DEFAULT_FOLDER = woodkeys/meira/promicro
|
||||
|
|
Loading…
Reference in a new issue