1
0
Fork 0

Merge branch 'master' into minidox

This commit is contained in:
That-Canadian 2017-07-14 21:35:50 -04:00
commit 6c9b69a4b6
46 changed files with 2224 additions and 266 deletions

1
.gitignore vendored
View file

@ -23,6 +23,7 @@ quantum/version.h
CMakeLists.txt
.DS_STORE
/util/wsl_downloaded
/util/win_downloaded
# Eclipse/PyCharm/Other IDE Settings
.cproject

View file

@ -1,11 +1,9 @@
#ifdef SSD1306OLED
#include "ssd1306.h"
#include "config.h"
#include "i2c.h"
#include <string.h>
#include "print.h"
#include "lets_split.h"
#include "glcdfont.c"
#ifdef ADAFRUIT_BLE_ENABLE
#include "adafruit_ble.h"
@ -14,18 +12,7 @@
#include "lufa.h"
#endif
#include "sendchar.h"
#include "pincontrol.h"
//assign the right code to your layers
#define _BASE 0
#define _LOWER 8
#define _RAISE 16
#define _FNLAYER 64
#define _NUMLAY 128
#define _NLOWER 136
#define _NFNLAYER 192
#define _MOUSECURSOR 256
#define _ADJUST 65560
#include "timer.h"
// Set this to 1 to help diagnose early startup problems
// when testing power-on with ble. Turn it off otherwise,
@ -33,26 +20,6 @@
// with the matrix scan, causing keys to drop.
#define DEBUG_TO_SCREEN 0
// Controls the SSD1306 128x32 OLED display via i2c
#define i2cAddress 0x3C
#define DisplayHeight 32
#define DisplayWidth 128
#define FontHeight 8
#define FontWidth 6
#define MatrixRows (DisplayHeight / FontHeight)
#define MatrixCols (DisplayWidth / FontWidth)
struct CharacterMatrix {
uint8_t display[MatrixRows][MatrixCols];
uint8_t *cursor;
bool dirty;
};
static struct CharacterMatrix display;
//static uint16_t last_battery_update;
//static uint32_t vbat;
//#define BatteryUpdateInterval 10000 /* milliseconds */
@ -62,54 +29,13 @@ static uint8_t displaying;
#endif
static uint16_t last_flush;
enum ssd1306_cmds {
DisplayOff = 0xAE,
DisplayOn = 0xAF,
SetContrast = 0x81,
DisplayAllOnResume = 0xA4,
DisplayAllOn = 0xA5,
NormalDisplay = 0xA6,
InvertDisplay = 0xA7,
SetDisplayOffset = 0xD3,
SetComPins = 0xda,
SetVComDetect = 0xdb,
SetDisplayClockDiv = 0xD5,
SetPreCharge = 0xd9,
SetMultiPlex = 0xa8,
SetLowColumn = 0x00,
SetHighColumn = 0x10,
SetStartLine = 0x40,
SetMemoryMode = 0x20,
ColumnAddr = 0x21,
PageAddr = 0x22,
ComScanInc = 0xc0,
ComScanDec = 0xc8,
SegRemap = 0xa0,
SetChargePump = 0x8d,
ExternalVcc = 0x01,
SwitchCapVcc = 0x02,
ActivateScroll = 0x2f,
DeActivateScroll = 0x2e,
SetVerticalScrollArea = 0xa3,
RightHorizontalScroll = 0x26,
LeftHorizontalScroll = 0x27,
VerticalAndRightHorizontalScroll = 0x29,
VerticalAndLeftHorizontalScroll = 0x2a,
};
// Write command sequence.
// Returns true on success.
static inline bool _send_cmd1(uint8_t cmd) {
bool res = false;
if (i2c_start_write(i2cAddress)) {
xprintf("failed to start write to %d\n", i2cAddress);
if (i2c_start_write(SSD1306_ADDRESS)) {
xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
goto done;
}
@ -154,8 +80,6 @@ static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) {
#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;}
#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;}
static void matrix_clear(struct CharacterMatrix *matrix);
static void clear_display(void) {
matrix_clear(&display);
@ -164,7 +88,7 @@ static void clear_display(void) {
send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1);
send_cmd3(ColumnAddr, 0, DisplayWidth - 1);
if (i2c_start_write(i2cAddress)) {
if (i2c_start_write(SSD1306_ADDRESS)) {
goto done;
}
if (i2c_master_write(0x40)) {
@ -210,14 +134,17 @@ bool iota_gfx_init(void) {
send_cmd2(SetChargePump, 0x14 /* Enable */);
send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
/// Flips the display orientation 0 degrees
send_cmd1(SegRemap | 0x1);
send_cmd1(ComScanDec);
/*
#ifdef OLED_ROTATE180
// the following Flip the display orientation 180 degrees
send_cmd1(SegRemap);
send_cmd1(ComScanInc);
// end flip */
#endif
#ifndef OLED_ROTATE180
// Flips the display orientation 0 degrees
send_cmd1(SegRemap | 0x1);
send_cmd1(ComScanDec);
#endif
send_cmd2(SetComPins, 0x2);
send_cmd2(SetContrast, 0x8f);
send_cmd2(SetPreCharge, 0xf1);
@ -263,7 +190,7 @@ done:
return success;
}
static void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
*matrix->cursor = c;
++matrix->cursor;
@ -276,7 +203,7 @@ static void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
}
}
static void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
matrix->dirty = true;
if (c == '\n') {
@ -297,7 +224,7 @@ void iota_gfx_write_char(uint8_t c) {
matrix_write_char(&display, c);
}
static void matrix_write(struct CharacterMatrix *matrix, const char *data) {
void matrix_write(struct CharacterMatrix *matrix, const char *data) {
const char *end = data + strlen(data);
while (data < end) {
matrix_write_char(matrix, *data);
@ -309,7 +236,7 @@ void iota_gfx_write(const char *data) {
matrix_write(&display, data);
}
static void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
while (true) {
uint8_t c = pgm_read_byte(data);
if (c == 0) {
@ -324,7 +251,7 @@ void iota_gfx_write_P(const char *data) {
matrix_write_P(&display, data);
}
static void matrix_clear(struct CharacterMatrix *matrix) {
void matrix_clear(struct CharacterMatrix *matrix) {
memset(matrix->display, ' ', sizeof(matrix->display));
matrix->cursor = &matrix->display[0][0];
matrix->dirty = true;
@ -334,7 +261,7 @@ void iota_gfx_clear_screen(void) {
matrix_clear(&display);
}
static void matrix_render(struct CharacterMatrix *matrix) {
void matrix_render(struct CharacterMatrix *matrix) {
last_flush = timer_read();
iota_gfx_on();
#if DEBUG_TO_SCREEN
@ -345,7 +272,7 @@ static void matrix_render(struct CharacterMatrix *matrix) {
send_cmd3(PageAddr, 0, MatrixRows - 1);
send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
if (i2c_start_write(i2cAddress)) {
if (i2c_start_write(SSD1306_ADDRESS)) {
goto done;
}
if (i2c_master_write(0x40)) {
@ -380,84 +307,12 @@ void iota_gfx_flush(void) {
matrix_render(&display);
}
static void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}
static void render_status_info(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
}
#endif
struct CharacterMatrix matrix;
matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("USB: "));
#ifdef PROTOCOL_LUFA
switch (USB_DeviceState) {
case DEVICE_STATE_Unattached:
matrix_write_P(&matrix, PSTR("Unattached"));
break;
case DEVICE_STATE_Suspended:
matrix_write_P(&matrix, PSTR("Suspended"));
break;
case DEVICE_STATE_Configured:
matrix_write_P(&matrix, PSTR("Connected"));
break;
case DEVICE_STATE_Powered:
matrix_write_P(&matrix, PSTR("Powered"));
break;
case DEVICE_STATE_Default:
matrix_write_P(&matrix, PSTR("Default"));
break;
case DEVICE_STATE_Addressed:
matrix_write_P(&matrix, PSTR("Addressed"));
break;
default:
matrix_write_P(&matrix, PSTR("Invalid"));
}
#endif
// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
char buf[40];
snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
matrix_write_P(&matrix, PSTR("\n\nLayer: "));
switch (layer_state) {
case _BASE:
matrix_write_P(&matrix, PSTR("Default"));
break;
case _RAISE:
matrix_write_P(&matrix, PSTR("Raise"));
break;
case _LOWER:
matrix_write_P(&matrix, PSTR("Lower"));
break;
case _ADJUST:
matrix_write_P(&matrix, PSTR("ADJUST"));
break;
default:
matrix_write(&matrix, buf);
}
// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
__attribute__ ((weak))
void iota_gfx_task_user(void) {
}
void iota_gfx_task(void) {
render_status_info();
iota_gfx_task_user();
if (display.dirty) {
iota_gfx_flush();

View file

@ -3,6 +3,71 @@
#include <stdbool.h>
#include <stdio.h>
#include "pincontrol.h"
#include "config.h"
enum ssd1306_cmds {
DisplayOff = 0xAE,
DisplayOn = 0xAF,
SetContrast = 0x81,
DisplayAllOnResume = 0xA4,
DisplayAllOn = 0xA5,
NormalDisplay = 0xA6,
InvertDisplay = 0xA7,
SetDisplayOffset = 0xD3,
SetComPins = 0xda,
SetVComDetect = 0xdb,
SetDisplayClockDiv = 0xD5,
SetPreCharge = 0xd9,
SetMultiPlex = 0xa8,
SetLowColumn = 0x00,
SetHighColumn = 0x10,
SetStartLine = 0x40,
SetMemoryMode = 0x20,
ColumnAddr = 0x21,
PageAddr = 0x22,
ComScanInc = 0xc0,
ComScanDec = 0xc8,
SegRemap = 0xa0,
SetChargePump = 0x8d,
ExternalVcc = 0x01,
SwitchCapVcc = 0x02,
ActivateScroll = 0x2f,
DeActivateScroll = 0x2e,
SetVerticalScrollArea = 0xa3,
RightHorizontalScroll = 0x26,
LeftHorizontalScroll = 0x27,
VerticalAndRightHorizontalScroll = 0x29,
VerticalAndLeftHorizontalScroll = 0x2a,
};
// Controls the SSD1306 128x32 OLED display via i2c
#ifndef SSD1306_ADDRESS
#define SSD1306_ADDRESS 0x3C
#endif
#define DisplayHeight 32
#define DisplayWidth 128
#define FontHeight 8
#define FontWidth 6
#define MatrixRows (DisplayHeight / FontHeight)
#define MatrixCols (DisplayWidth / FontWidth)
struct CharacterMatrix {
uint8_t display[MatrixRows][MatrixCols];
uint8_t *cursor;
bool dirty;
};
struct CharacterMatrix display;
bool iota_gfx_init(void);
void iota_gfx_task(void);
@ -14,4 +79,15 @@ void iota_gfx_write(const char *data);
void iota_gfx_write_P(const char *data);
void iota_gfx_clear_screen(void);
void iota_gfx_task_user(void);
void matrix_clear(struct CharacterMatrix *matrix);
void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
void matrix_write(struct CharacterMatrix *matrix, const char *data);
void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
void matrix_render(struct CharacterMatrix *matrix);
#endif

View file

@ -0,0 +1,5 @@
SUBPROJECT_DEFAULT = ver2
ifndef MAKEFILE_INCLUDED
include ../../Makefile
endif

83
keyboards/hadron/config.h Normal file
View file

@ -0,0 +1,83 @@
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include "config_common.h"
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6060
#define MANUFACTURER ishtob
#define PRODUCT Hadron Keyboard
#define DESCRIPTION A cherry ML ortholinear keyboard
//#define AUDIO_VOICES
//#define BACKLIGHT_PIN B7
/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
/* number of backlight levels */
//#define BACKLIGHT_LEVELS 3
/* Set 0 if debouncing isn't needed */
#define DEBOUNCING_DELAY 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
#ifdef SUBPROJECT_ver0
#include "ver0/config.h"
#endif
#ifdef SUBPROJECT_ver2
#include "ver2/config.h"
#endif
#endif

26
keyboards/hadron/hadron.c Normal file
View file

@ -0,0 +1,26 @@
#include "hadron.h"
void matrix_init_kb(void) {
matrix_init_user();
}
void matrix_scan_kb(void) {
// put your looping keyboard code here
// runs every cycle (a lot)
matrix_scan_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
return process_record_user(keycode, record);
}
void led_set_kb(uint8_t usb_led) {
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
led_set_user(usb_led);
}

30
keyboards/hadron/hadron.h Normal file
View file

@ -0,0 +1,30 @@
#ifndef HADRON_H
#define HADRON_H
#ifdef SUBPROJECT_ver0
#include "ver0.h"
#endif
#ifdef SUBPROJECT_ver2
#include "ver2.h"
#endif
#include "quantum.h"
#define KEYMAP( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, \
K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4D, K4E \
) \
{ \
{ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, KC_NO, KC_NO, KC_NO }, \
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \
{ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \
{ K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \
{ K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4D, K4E } \
}
#endif

166
keyboards/hadron/i2c.c Normal file
View file

@ -0,0 +1,166 @@
#include <util/twi.h>
#include <avr/io.h>
#include <stdlib.h>
#include <avr/interrupt.h>
#include <util/twi.h>
#include <stdbool.h>
#include "i2c.h"
#ifdef USE_I2C
// Limits the amount of we wait for any one i2c transaction.
// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
// 9 bits, a single transaction will take around 90μs to complete.
//
// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit
// poll loop takes at least 8 clock cycles to execute
#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8
#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)
volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
static volatile uint8_t slave_buffer_pos;
static volatile bool slave_has_register_set = false;
// Wait for an i2c operation to finish
inline static
void i2c_delay(void) {
uint16_t lim = 0;
while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
lim++;
// easier way, but will wait slightly longer
// _delay_us(100);
}
// Setup twi to run at 100kHz
void i2c_master_init(void) {
// no prescaler
TWSR = 0;
// Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.
// Check datasheets for more info.
TWBR = ((F_CPU/SCL_CLOCK)-16)/2;
}
// Start a transaction with the given i2c slave address. The direction of the
// transfer is set with I2C_READ and I2C_WRITE.
// returns: 0 => success
// 1 => error
uint8_t i2c_master_start(uint8_t address) {
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
i2c_delay();
// check that we started successfully
if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
return 1;
// send device address
TWDR = address;
TWCR = (1<<TWINT) | (1<<TWEN);
i2c_delay();
if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
return 1; // slave did not acknowledge
else
return 0; // success
}
// Finish the i2c transaction.
void i2c_master_stop(void) {
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
uint16_t lim = 0;
while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
lim++;
}
// Write one byte to the i2c slave.
// returns 0 => slave ACK
// 1 => slave NACK
uint8_t i2c_master_write(uint8_t data) {
TWDR = data;
TWCR = (1<<TWINT) | (1<<TWEN);
i2c_delay();
// check if the slave acknowledged us
return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
}
// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
// if ack=0 the acknowledge bit is not set.
// returns: byte read from i2c device
uint8_t i2c_master_read(int ack) {
TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
i2c_delay();
return TWDR;
}
void i2c_reset_state(void) {
TWCR = 0;
}
void i2c_slave_init(uint8_t address) {
TWAR = address << 0; // slave i2c address
// TWEN - twi enable
// TWEA - enable address acknowledgement
// TWINT - twi interrupt flag
// TWIE - enable the twi interrupt
TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
}
ISR(TWI_vect);
ISR(TWI_vect) {
uint8_t ack = 1;
switch(TW_STATUS) {
case TW_SR_SLA_ACK:
// this device has been addressed as a slave receiver
slave_has_register_set = false;
break;
case TW_SR_DATA_ACK:
// this device has received data as a slave receiver
// The first byte that we receive in this transaction sets the location
// of the read/write location of the slaves memory that it exposes over
// i2c. After that, bytes will be written at slave_buffer_pos, incrementing
// slave_buffer_pos after each write.
if(!slave_has_register_set) {
slave_buffer_pos = TWDR;
// don't acknowledge the master if this memory loctaion is out of bounds
if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {
ack = 0;
slave_buffer_pos = 0;
}
slave_has_register_set = true;
} else {
i2c_slave_buffer[slave_buffer_pos] = TWDR;
BUFFER_POS_INC();
}
break;
case TW_ST_SLA_ACK:
case TW_ST_DATA_ACK:
// master has addressed this device as a slave transmitter and is
// requesting data.
TWDR = i2c_slave_buffer[slave_buffer_pos];
BUFFER_POS_INC();
break;
case TW_BUS_ERROR: // something went wrong, reset twi state
TWCR = 0;
default:
break;
}
// Reset everything, so we are ready for the next TWI interrupt
TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
}
#endif

49
keyboards/hadron/i2c.h Normal file
View file

@ -0,0 +1,49 @@
#ifndef I2C_H
#define I2C_H
#include <stdint.h>
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#define I2C_READ 1
#define I2C_WRITE 0
#define I2C_ACK 1
#define I2C_NACK 0
#define SLAVE_BUFFER_SIZE 0x10
// i2c SCL clock frequency
#define SCL_CLOCK 800000L
extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
void i2c_master_init(void);
uint8_t i2c_master_start(uint8_t address);
void i2c_master_stop(void);
uint8_t i2c_master_write(uint8_t data);
uint8_t i2c_master_read(int);
void i2c_reset_state(void);
void i2c_slave_init(uint8_t address);
static inline unsigned char i2c_start_read(unsigned char addr) {
return i2c_master_start((addr << 1) | I2C_READ);
}
static inline unsigned char i2c_start_write(unsigned char addr) {
return i2c_master_start((addr << 1) | I2C_WRITE);
}
// from SSD1306 scrips
extern unsigned char i2c_rep_start(unsigned char addr);
extern void i2c_start_wait(unsigned char addr);
extern unsigned char i2c_readAck(void);
extern unsigned char i2c_readNak(void);
extern unsigned char i2c_read(unsigned char ack);
#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
#endif

View file

@ -0,0 +1,26 @@
# Build Options
# change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = no # Audio output on port C6
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
ONEHAND_ENABLE = no # Enable one-hand typing
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
ifndef QUANTUM_DIR
include ../../../../Makefile
endif

View file

@ -0,0 +1,21 @@
#ifndef CONFIG_USER_H
#define CONFIG_USER_H
#include "../../config.h"
#define LEADER_TIMEOUT 300
//#define BACKLIGHT_BREATHING
#define PREVENT_STUCK_MODIFIERS
#define USE_I2C
#define SSD1306OLED
#define OLED_ROTATE180
/* ws2812 RGB LED*/
#define RGB_DI_PIN D4
#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 14 // Number of LEDs
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
#endif

View file

@ -0,0 +1,496 @@
#include "hadron.h"
#include "bootloader.h"
#include "action_layer.h"
#include "eeconfig.h"
#include "LUFA/Drivers/Peripheral/TWI.h"
#ifdef AUDIO_ENABLE
#include "audio.h"
#endif
#ifdef USE_I2C
#include "i2c.h"
#endif
#ifdef SSD1306OLED
#include "ssd1306.h"
#endif
extern keymap_config_t keymap_config;
//Following line allows macro to read current RGB settings
extern rgblight_config_t rgblight_config;
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _QWERTY 0
#define _COLEMAK 1
#define _DVORAK 2
#define _LOWER 3
#define _RAISE 4
#define _MOUSECURSOR 8
#define _ADJUST 16
enum preonic_keycodes {
QWERTY = SAFE_RANGE,
COLEMAK,
DVORAK,
LOWER,
RAISE,
BACKLIT,
RGBLED_TOGGLE,
RGBLED_STEP_MODE,
RGBLED_INCREASE_HUE,
RGBLED_DECREASE_HUE,
RGBLED_INCREASE_SAT,
RGBLED_DECREASE_SAT,
RGBLED_INCREASE_VAL,
RGBLED_DECREASE_VAL,
};
enum macro_keycodes {
KC_DEMOMACRO,
};
// Fillers to make layering more clear
#define _______ KC_TRNS
#define XXXXXXX KC_NO
// Custom macros
#define CTL_ESC CTL_T(KC_ESC) // Tap for Esc, hold for Ctrl
#define CTL_TTAB CTL_T(KC_TAB) // Tap for Esc, hold for Ctrl
#define CTL_ENT CTL_T(KC_ENT) // Tap for Enter, hold for Ctrl
#define SFT_ENT SFT_T(KC_ENT) // Tap for Enter, hold for Shift
// Requires KC_TRNS/_______ for the trigger key in the destination layer
#define LT_MC(kc) LT(_MOUSECURSOR, kc) // L-ayer T-ap M-ouse C-ursor
#define LT_RAI(kc) LT(_RAISE, kc) // L-ayer T-ap to Raise
#define DEMOMACRO M(KC_DEMOMACRO) // Sample for macros
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Qwerty
* ,------+------+------+------+------+------------------------------------------------.
* | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | DEL |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | Tab | Q | W | E | R | T | 7 | 8 | 9 | Y | U | I | O | P | Bksp |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | CAPS | A | S | D | F | G | 4 | 5 | 6 | H | J | K | L | ;/Nav| ' |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | 1 | 2 | 3 | N | M | , | . | / |Ctl/Et|
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
* `--------------------------------------------------------------------------------------------------------'
*/
[_QWERTY] = KEYMAP(
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_P7, KC_P8, KC_P9, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_P4, KC_P5, KC_P6, KC_H, KC_J, KC_K, KC_L,LT_MC(KC_SCLN), KC_QUOT, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_P1, KC_P2, KC_P3, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, CTL_ENT, \
KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT,KC_DOWN, KC_UP, KC_RGHT \
),
/* Colemak
* ,------+------+------+------+------+------------------------------------------------.
* | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | 0 | - |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | Tab | Q | W | F | P | G | 7 | 8 | 9 | J | L | U | Y | ; | Bksp |
* |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
* | CAPS | A | R | S | T | D | 4 | 5 | 6 | H | N | E | I | O | ' |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | 1 | 2 | 3 | K | M | , | . | / |Ctl/Et|
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
* `--------------------------------------------------------------------------------------------------------'
*/
[_COLEMAK] = KEYMAP(
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_P7, KC_P8, KC_P9, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
KC_LCTRL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_P4, KC_P5, KC_P6, KC_H, KC_N, KC_E, KC_I, LT_MC(KC_O), KC_QUOT, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_P1, KC_P2, KC_P3, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, CTL_ENT, \
KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
),
/* Dvorak
* ,------+------+------+------+------+------------------------------------------------.
* | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | Tab | " | , | . | P | Y | 7 | 8 | 9 | F | G | C | R | L | Bksp |
* |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
* | Esc | A | O | E | U | I | 4 | 5 | 6 | D | H | T | N | S | / |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| ; | Q | J | K | X | 1 | 2 | 3 | B | M | W | V | Z |Ctl/Et|
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
* `--------------------------------------------------------------------------------------------------------'
*/
[_DVORAK] = KEYMAP(
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_P7, KC_P8, KC_P9, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_P4, KC_P5, KC_P6, KC_D, KC_H, KC_T, KC_N, LT_MC(KC_S), KC_SLSH, \
KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_P1, KC_P2, KC_P3, KC_B, KC_M, KC_W, KC_V, KC_Z, CTL_ENT, \
KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
),
/* Lower
* ,------+------+------+------+------+------------------------------------------------.
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | ~ | ! | @ | # | $ | % | | | | ^ | & | * | ( | ) | Del |
* |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
* | | F1 | F2 | F3 | F4 | F5 | | | | F6 | _ | + | { | } | | |
* |------+------+------+------+------+------|------+------+------+------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | | | | F12 |ISO ~ |ISO | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | Next | Vol- | Vol+ | Play |
* `--------------------------------------------------------------------------------------------------------'
*/
[_LOWER] = KEYMAP(
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, _______, KC_F6, KC_UNDS, KC_PLUS, KC_LBRC, KC_RBRC, KC_PIPE, \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, KC_F12,S(KC_NUHS),S(KC_NUBS),_______,_______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
),
/* Raise
* ,------+------+------+------+------+------------------------------------------------.
* | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | ` | 1 | 2 | 3 | 4 | 5 | | | | 6 | 7 | 8 | 9 | 0 | Del |
* |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | | | | F6 | - | = | [ | ] | \ |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | | | | F12 |ISO # |ISO / | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | Next | Vol- | Vol+ | Play |
* `--------------------------------------------------------------------------------------------------------'
*/
[_RAISE] = KEYMAP(
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, _______, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
_______, _______, _______, _______, _______, KC_SPC, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
),
/* Mouse Layer (semi-col)
* ,------+------+------+------+------+------------------------------------------------.
* | ACCL0| ACCL1| ACCL2| | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | | | | | | | | | Home | Wh_Up| WHL_L| M_Up | WHL_R| Macro| |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | End | Wh_Dn| M_Lft| M_Dn | M_Rt | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | BTN2 | BTN3 | BTN4 | BTN5 | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | BTN1 | | | | BTN1 | | | | | |
* `--------------------------------------------------------------------------------------------------------'
*/
[_MOUSECURSOR] = KEYMAP(
KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGUP, KC_WH_L, KC_MS_U, KC_WH_R,DEMOMACRO,_______, \
_______, _______, _______, _______, _______, _______, _______, _______, KC_END , KC_PGDN, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, \
_______, _______, _______, _______, _______, KC_BTN1, _______, _______, _______, KC_BTN1, _______, _______, _______, _______, _______ \
),
/* Adjust (Lower + Raise)
* ,------+------+------+------+------+------------------------------------------------.
* | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | Reset|RGB TG|RGB ST|RGBH -|RGBH +|RGBS -|RGBS +|RGBV -|RGBV +| | | | | | Del |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | |Aud on|Audoff|AGnorm| | | |AGswap|Qwerty|Colemk| | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | |Voice-|Voice+|Mus on|Musoff| | | | | | | | BL + |BL ST |BL TG |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | | | | |
* `--------------------------------------------------------------------------------------------------------'
*/
[_ADJUST] = KEYMAP(
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
RESET, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, KC_DEL, \
_______, _______, _______, AU_ON, AU_OFF, AG_NORM, _______, _______, _______, AG_SWAP, QWERTY, COLEMAK, _______, _______, _______, \
_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, BL_DEC, BL_INC, BL_STEP, BL_TOGG, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______\
)
};
#ifdef AUDIO_ENABLE
float tone_startup[][2] = SONG(STARTUP_SOUND);
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
#endif
// define variables for reactive RGB
bool RGB_INIT = false;
bool TOG_STATUS = false;
int RGB_current_mode;
void persistant_default_layer_set(uint16_t default_layer) {
eeconfig_update_default_layer(default_layer);
default_layer_set(default_layer);
}
void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
rgblight_mode(RGB_current_mode);
layer_on(layer3);
} else {
layer_off(layer3);
}
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case QWERTY:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
#endif
persistant_default_layer_set(1UL<<_QWERTY);
}
return false;
break;
case COLEMAK:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_colemak, false, 0);
#endif
persistant_default_layer_set(1UL<<_COLEMAK);
}
return false;
break;
case LOWER:
if (record->event.pressed) {
//not sure how to have keyboard check mode and set it to a variable, so my work around
//uses another variable that would be set to true after the first time a reactive key is pressed.
if (RGB_INIT) {} else {
RGB_current_mode = rgblight_config.mode;
RGB_INIT = true;
}
if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
} else {
TOG_STATUS = !TOG_STATUS;
rgblight_mode(16);
}
layer_on(_LOWER);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
} else {
rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
TOG_STATUS = false;
layer_off(_LOWER);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case RAISE:
if (record->event.pressed) {
//not sure how to have keyboard check mode and set it to a variable, so my work around
//uses another variable that would be set to true after the first time a reactive key is pressed.
if (RGB_INIT) {} else {
RGB_current_mode = rgblight_config.mode;
RGB_INIT = true;
}
if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
} else {
TOG_STATUS = !TOG_STATUS;
rgblight_mode(15);
}
layer_on(_RAISE);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
} else {
rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
layer_off(_RAISE);
TOG_STATUS = false;
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case BACKLIT:
if (record->event.pressed) {
register_code(KC_RSFT);
#ifdef BACKLIGHT_ENABLE
backlight_step();
#endif
} else {
unregister_code(KC_RSFT);
}
return false;
break;
case RGB_MOD:
//led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
if (record->event.pressed) {
rgblight_mode(RGB_current_mode);
rgblight_step();
RGB_current_mode = rgblight_config.mode;
}
return false;
break;
}
return true;
}
void matrix_init_user(void) {
#ifdef USE_I2C
i2c_master_init();
#ifdef SSD1306OLED
// calls code for the SSD1306 OLED
_delay_ms(400);
TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
iota_gfx_init(); // turns on the display
#endif
#endif
#ifdef AUDIO_ENABLE
startup_user();
#endif
}
void matrix_scan_user(void) {
#ifdef SSD1306OLED
iota_gfx_task(); // this is what updates the display continuously
#endif
}
#ifdef AUDIO_ENABLE
void startup_user()
{
_delay_ms(20); // gets rid of tick
PLAY_NOTE_ARRAY(tone_startup, false, 0);
}
void shutdown_user()
{cc
PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
_delay_ms(150);
stop_all_notes();
}
void music_on_user(void)
{
music_scale_user();
}
void music_scale_user(void)
{
PLAY_NOTE_ARRAY(music_scale, false, 0);
}
#endif
/*
* Macro definition
*/
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
switch (id) {
case KC_DEMOMACRO:
if (record->event.pressed){
return MACRO (I(1), T(H),T(E),T(L), T(L), T(O), T(SPACE), T(W), T(O), T(R), T(L), T(D), END);
}
}
return MACRO_NONE;
}
void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}
//assign the right code to your layers for OLED display
#define L_BASE 0
#define L_LOWER 8
#define L_RAISE 16
#define L_FNLAYER 64
#define L_NUMLAY 128
#define L_NLOWER 136
#define L_NFNLAYER 192
#define L_MOUSECURSOR 256
#define L_ADJUST 65560
void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
}
#endif
struct CharacterMatrix matrix;
matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("USB: "));
#ifdef PROTOCOL_LUFA
switch (USB_DeviceState) {
case DEVICE_STATE_Unattached:
matrix_write_P(&matrix, PSTR("Unattached"));
break;
case DEVICE_STATE_Suspended:
matrix_write_P(&matrix, PSTR("Suspended"));
break;
case DEVICE_STATE_Configured:
matrix_write_P(&matrix, PSTR("Connected"));
break;
case DEVICE_STATE_Powered:
matrix_write_P(&matrix, PSTR("Powered"));
break;
case DEVICE_STATE_Default:
matrix_write_P(&matrix, PSTR("Default"));
break;
case DEVICE_STATE_Addressed:
matrix_write_P(&matrix, PSTR("Addressed"));
break;
default:
matrix_write_P(&matrix, PSTR("Invalid"));
}
#endif
// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
char buf[40];
snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
matrix_write_P(&matrix, PSTR("\n\nLayer: "));
switch (layer_state) {
case L_BASE:
matrix_write_P(&matrix, PSTR("Default"));
break;
case L_RAISE:
matrix_write_P(&matrix, PSTR("Raise"));
break;
case L_LOWER:
matrix_write_P(&matrix, PSTR("Lower"));
break;
case L_ADJUST:
matrix_write_P(&matrix, PSTR("ADJUST"));
break;
default:
matrix_write(&matrix, buf);
}
// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
}

View file

@ -0,0 +1,2 @@
# The Default Planck Layout

View file

@ -0,0 +1,23 @@
# How to add your own keymap
Folders can be named however you'd like (will be approved upon merging), or should follow the format with a preceding `_`:
_[ISO 3166-1 alpha-2 code*]_[layout variant]_[layout name/author]
\* See full list: https://en.wikipedia.org/wiki/ISO_3166-1#Officially_assigned_code_elements
and contain the following files:
* `keymap.c`
* `readme.md` *recommended*
* `config.h` *optional*, found automatically when compiling
* `Makefile` *optional*, found automatically when compling
When adding your keymap to this list, keep it organised alphabetically (select list, edit->sort lines), and use this format:
* **folder_name** description
# List of Planck keymaps
* **default** default Planck layout
* **cbbrowne** cbbrowne's Planck layout

View file

@ -0,0 +1,26 @@
# Build Options
# change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # 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 # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
MIDI_ENABLE = yes # MIDI controls
AUDIO_ENABLE = no # Audio output on port C6
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
ONEHAND_ENABLE = no # Enable one-hand typing
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
ifndef QUANTUM_DIR
include ../../../../Makefile
endif

View file

@ -0,0 +1,21 @@
#ifndef CONFIG_USER_H
#define CONFIG_USER_H
#include "../../config.h"
#define LEADER_TIMEOUT 300
//#define BACKLIGHT_BREATHING
#define PREVENT_STUCK_MODIFIERS
#define USE_I2C
#define SSD1306OLED
#define OLED_ROTATE180
/* ws2812 RGB LED*/
#define RGB_DI_PIN D4
#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 14 // Number of LEDs
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
#endif

View file

@ -0,0 +1,505 @@
#include "hadron.h"
#include "bootloader.h"
#include "action_layer.h"
#include "eeconfig.h"
#include "LUFA/Drivers/Peripheral/TWI.h"
#ifdef AUDIO_ENABLE
#include "audio.h"
#endif
#ifdef USE_I2C
#include "i2c.h"
#endif
#ifdef SSD1306OLED
#include "ssd1306.h"
#endif
extern keymap_config_t keymap_config;
//Following line allows macro to read current RGB settings
extern rgblight_config_t rgblight_config;
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _QWERTY 0
#define _LOWER 3
#define _RAISE 4
#define _FNLAYER 6
#define _NUMLAY 7
#define _MOUSECURSOR 8
#define _ADJUST 16
enum preonic_keycodes {
QWERTY = SAFE_RANGE,
COLEMAK,
DVORAK,
LOWER,
RAISE,
BACKLIT,
RGBLED_TOGGLE,
RGBLED_STEP_MODE,
RGBLED_INCREASE_HUE,
RGBLED_DECREASE_HUE,
RGBLED_INCREASE_SAT,
RGBLED_DECREASE_SAT,
RGBLED_INCREASE_VAL,
RGBLED_DECREASE_VAL,
};
enum macro_keycodes {
KC_DEMOMACRO,
};
// Fillers to make layering more clear
#define _______ KC_TRNS
#define XXXXXXX KC_NO
// Custom macros
#define CTL_ESC CTL_T(KC_ESC) // Tap for Esc, hold for Ctrl
#define CTL_TTAB CTL_T(KC_TAB) // Tap for Esc, hold for Ctrl
#define CTL_ENT CTL_T(KC_ENT) // Tap for Enter, hold for Ctrl
#define SFT_ENT SFT_T(KC_ENT) // Tap for Enter, hold for Shift
// Requires KC_TRNS/_______ for the trigger key in the destination layer
#define LT_FN(kc) LT(_FNLAYER, kc) // L-ayer T-ap Function Layer
#define LT_MC(kc) LT(_MOUSECURSOR, kc) // L-ayer T-ap M-ouse C-ursor
#define LT_RAI(kc) LT(_RAISE, kc) // L-ayer T-ap to Raise
#define TG_NUMLAY TG(_NUMLAY) //Toggle for layer _NUMLAY
#define DEMOMACRO M(KC_DEMOMACRO) // My login macros
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Qwerty
* ,------+------+------+------+------+------------------------------------------------.
* | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | 7 | 8 | 9 |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | CAPS | A | S | D | F | G | H | J | K | L | ; |Enter | 4 | 5 | 6 |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | N | M | , | . | / | = | 1 | 2 | 3 |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | ~ | Ctrl | Alt | GUI |Lower |Space |Space |Raise | RAlt | Ins | Del |NumLay| 0 | . | ENT |
* `--------------------------------------------------------------------------------------------------------'
*/
[_QWERTY] = KEYMAP(
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,\
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, KC_P7, KC_P8, KC_P9, \
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT_MC(KC_SCLN), CTL_ENT, KC_P4, KC_P5, KC_P6, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_EQL, KC_P1, KC_P2, KC_P3, \
KC_GRV, KC_RCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_RALT, KC_INS, KC_DEL, TG_NUMLAY, KC_P0, KC_PDOT, KC_PENT \
),
/* Lower
* ,-----------------------------------------------------------------------------------.
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | ~ | \ | | | |
* |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
* | CAPS | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | [ | ] | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | Next | Vol- | Vol+ | Play | | | |
* `--------------------------------------------------------------------------------------------------------'
*/
[_LOWER] = KEYMAP(
KC_ESC, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_GRV, KC_BSLS, _______, _______, _______, \
KC_CAPS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_EQL, KC_LBRC, KC_RBRC, KC_PIPE, _______, _______, _______, \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS), S(KC_NUBS), KC_LCBR, KC_RCBR, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, _______, _______\
),
/* Raise
* ,-----------------------------------------------------------------------------------.
* | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | ~ | \ | | | |
* |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
* | | A | Up | D | PrSc | | 4 | 5 | 6 | * | : | ' | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | Lt | Dn | Rt | Mute | | 1 | 2 | 3 | Up | / | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | |Space | 0 | | Left | Down | Right| | | | |
* `--------------------------------------------------------------------------------------------------------'
*/
[_RAISE] = KEYMAP(
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PLUS, KC_BSLS, _______, _______, _______, \
_______, KC_A, KC_UP, KC_D, KC_PSCR, _______, KC_4, KC_5, KC_6, KC_PAST, KC_COLN, KC_QUOT, _______, _______, _______, \
_______, KC_LEFT, KC_DOWN, KC_RIGHT, KC__MUTE, _______, KC_1, KC_2, KC_3, KC_UP, KC_SLSH, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, KC_SPC, KC_0, _______, KC_LEFT, KC_DOWN, KC_RIGHT, _______, _______, _______, _______ \
),
/* FN layer on Esc key
* ,-----------------------------------------------------------------------------------.
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | | ! | @ | # | $ | % | ^ | & | * | ( | ) | + | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | F1 | F2 | F3 | F4 | F5 | F6 | _ | = | [ | ] | ' | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | { | } | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | Next | Vol- | Vol+ | Play | | | |
* `--------------------------------------------------------------------------------------------------------'
*/
[_FNLAYER] = KEYMAP(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,\
_______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PLUS, _______, _______, _______, \
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_EQL, KC_LBRC, KC_RBRC, KC_QUOT, _______, _______, _______, \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS), S(KC_NUBS), KC_LCBR, KC_RCBR, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, _______, _______ \
),
/* Num Layer
* ,-----------------------------------------------------------------------------------.
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | | | | | | | | | | | | | F7 | F8 | F9 |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | | F4 | F5 | F6 |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | | | Up | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | Exit | Left | Down | Rght |
* `--------------------------------------------------------------------------------------------------------'
*/
[_NUMLAY] = KEYMAP(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,\
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_HOME, KC_PGUP, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, KC_END, KC_PGDN, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PMNS, KC_UP, KC_PPLS, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RIGHT \
),
/* Mouse Layer (semi-col)
* ,-----------------------------------------------------------------------------------.
* | |ACCL0| ACCL1| ACCL2 | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | | | | | | Home | Wh_Up| WHL_L| M_Up | WHL_R| | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | End | Wh_Dn| M_Lft| M_Dn | M_Rt | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | BTN2 | BTN3 | BTN4 | BTN5 | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | BTN1 | | | | BTN1 | | | | | |
* `--------------------------------------------------------------------------------------------------------'
*/
[_MOUSECURSOR] = KEYMAP(
_______, KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______,\
_______, _______, _______, _______, _______, KC_HOME, KC_PGUP, KC_WH_L, KC_MS_U, KC_WH_R, DEMOMACRO, _______, _______, _______, _______, \
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_END , KC_PGDN, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, _______, _______, _______, \
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, _______, _______, _______ \
),
/* Adjust (Lower + Raise)
* ,-----------------------------------------------------------------------------------.
* | Reset| | | | | | | | | VolD | VolU | Mute |
* |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
* | |RGB TG|RGB ST|RGBH -|RGBH +|RGBS -|RGBS +|RGBV -|RGBV +| | | Del | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty| | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | BL + |BL ST |BLSTEP| BL TG| | | |
* |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | | | | |
* `--------------------------------------------------------------------------------------------------------'
*/
[_ADJUST] = KEYMAP(
RESET, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_VOLD, KC_VOLU, KC_MUTE, \
_______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, KC_DEL, _______, _______, _______, \
_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, _______, _______, _______, _______, _______, _______, _______, \
_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, BL_DEC, BL_INC, BL_STEP, BL_TOGG, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
)
};
#ifdef AUDIO_ENABLE
float tone_startup[][2] = SONG(STARTUP_SOUND);
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
#endif
// define variables for reactive RGB
bool RGB_INIT = false;
bool TOG_STATUS = false;
bool NUMLAY_STATUS = false;
int RGB_current_mode;
void persistant_default_layer_set(uint16_t default_layer) {
eeconfig_update_default_layer(default_layer);
default_layer_set(default_layer);
}
void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
rgblight_mode(RGB_current_mode);
layer_on(layer3);
} else {
layer_off(layer3);
}
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case QWERTY:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
#endif
persistant_default_layer_set(1UL<<_QWERTY);
}
return false;
break;
case LOWER:
if (record->event.pressed) {
//not sure how to have keyboard check mode and set it to a variable, so my work around
//uses another variable that would be set to true after the first time a reactive key is pressed.
if (RGB_INIT) {} else {
RGB_current_mode = rgblight_config.mode;
RGB_INIT = true;
}
if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
} else {
TOG_STATUS = !TOG_STATUS;
rgblight_mode(16);
}
layer_on(_LOWER);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
} else {
rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
TOG_STATUS = false;
layer_off(_LOWER);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case RAISE:
if (record->event.pressed) {
//not sure how to have keyboard check mode and set it to a variable, so my work around
//uses another variable that would be set to true after the first time a reactive key is pressed.
if (RGB_INIT) {} else {
RGB_current_mode = rgblight_config.mode;
RGB_INIT = true;
}
if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
} else {
TOG_STATUS = !TOG_STATUS;
rgblight_mode(15);
}
layer_on(_RAISE);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
} else {
rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
layer_off(_RAISE);
TOG_STATUS = false;
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case BACKLIT:
if (record->event.pressed) {
register_code(KC_RSFT);
#ifdef BACKLIGHT_ENABLE
backlight_step();
#endif
} else {
unregister_code(KC_RSFT);
}
return false;
break;
//my attempt for RGB layer lock indication via changing the mode, still have to figure out how to not have other keypress not override this mode
case TG_NUMLAY:
if (record->event.pressed) {
if (RGB_INIT) {} else {
RGB_current_mode = rgblight_config.mode;
RGB_INIT = true;
}
NUMLAY_STATUS = !NUMLAY_STATUS;
if (NUMLAY_STATUS) {
rgblight_mode(4);
layer_on(_NUMLAY);
} else {
rgblight_mode(RGB_current_mode);
layer_off(_NUMLAY); }
}
return false;
break;
case RGB_MOD:
//led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
if (record->event.pressed) {
rgblight_mode(RGB_current_mode);
rgblight_step();
RGB_current_mode = rgblight_config.mode;
}
return false;
break;
}
return true;
}
void matrix_init_user(void) {
#ifdef USE_I2C
i2c_master_init();
#ifdef SSD1306OLED
// calls code for the SSD1306 OLED
_delay_ms(400);
TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
iota_gfx_init(); // turns on the display
#endif
#endif
#ifdef AUDIO_ENABLE
startup_user();
#endif
}
void matrix_scan_user(void) {
#ifdef SSD1306OLED
iota_gfx_task(); // this is what updates the display continuously
#endif
}
#ifdef AUDIO_ENABLE
void startup_user()
{
_delay_ms(20); // gets rid of tick
PLAY_NOTE_ARRAY(tone_startup, false, 0);
}
void shutdown_user()
{cc
PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
_delay_ms(150);
stop_all_notes();
}
void music_on_user(void)
{
music_scale_user();
}
void music_scale_user(void)
{
PLAY_NOTE_ARRAY(music_scale, false, 0);
}
#endif
/*
* Macro definition
*/
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
switch (id) {
case KC_DEMOMACRO:
if (record->event.pressed){
return MACRO (I(1), T(H),T(E),T(L), T(L), T(O), T(SPACE), T(W), T(O), T(R), T(L), T(D), END);
}
}
return MACRO_NONE;
}
void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}
//assign the right code to your layers for OLED display
#define L_BASE 0
#define L_LOWER 8
#define L_RAISE 16
#define L_FNLAYER 64
#define L_NUMLAY 128
#define L_NLOWER 136
#define L_NFNLAYER 192
#define L_MOUSECURSOR 256
#define L_ADJUST 65560
void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
}
#endif
struct CharacterMatrix matrix;
matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("USB: "));
#ifdef PROTOCOL_LUFA
switch (USB_DeviceState) {
case DEVICE_STATE_Unattached:
matrix_write_P(&matrix, PSTR("Unattached"));
break;
case DEVICE_STATE_Suspended:
matrix_write_P(&matrix, PSTR("Suspended"));
break;
case DEVICE_STATE_Configured:
matrix_write_P(&matrix, PSTR("Connected"));
break;
case DEVICE_STATE_Powered:
matrix_write_P(&matrix, PSTR("Powered"));
break;
case DEVICE_STATE_Default:
matrix_write_P(&matrix, PSTR("Default"));
break;
case DEVICE_STATE_Addressed:
matrix_write_P(&matrix, PSTR("Addressed"));
break;
default:
matrix_write_P(&matrix, PSTR("Invalid"));
}
#endif
// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
char buf[40];
snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
matrix_write_P(&matrix, PSTR("\n\nLayer: "));
switch (layer_state) {
case L_BASE:
matrix_write_P(&matrix, PSTR("Default"));
break;
case L_RAISE:
matrix_write_P(&matrix, PSTR("Raise"));
break;
case L_LOWER:
matrix_write_P(&matrix, PSTR("Lower"));
break;
case L_ADJUST:
matrix_write_P(&matrix, PSTR("ADJUST"));
break;
default:
matrix_write(&matrix, buf);
}
// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
}

View file

@ -0,0 +1,2 @@
# The Default Planck Layout

66
keyboards/hadron/out.txt Normal file
View file

@ -0,0 +1,66 @@
-------- begin --------
avr-gcc.exe (AVR_8_bit_GNU_Toolchain_3.5.0_1662) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling: ../../keyboards/planck/planck.c [OK]
Compiling: ../../keyboards/planck/keymaps/experimental/keymap.c [WARNINGS]
|
| ../../keyboards/planck/keymaps/experimental/keymap.c: In function 'action_get_macro':
| ../../keyboards/planck/keymaps/experimental/keymap.c:227:17: warning: implicit declaration of function 'breathing_speed_set' [-Wimplicit-function-declaration]
| breathing_speed_set(2);
| ^
| ../../keyboards/planck/keymaps/experimental/keymap.c:228:17: warning: implicit declaration of function 'breathing_pulse' [-Wimplicit-function-declaration]
| breathing_pulse();
| ^
|
Compiling: ../../quantum/quantum.c [OK]
Compiling: ../../quantum/keymap.c [OK]
Compiling: ../../quantum/keycode_config.c [OK]
Compiling: ../../quantum/matrix.c [OK]
Compiling: ../../quantum/audio/audio.c [OK]
Compiling: ../../quantum/audio/voices.c [OK]
Compiling: ../../quantum/audio/luts.c [OK]
Compiling: ../../tmk_core/protocol/lufa/lufa.c [OK]
Compiling: ../../tmk_core/protocol/lufa/descriptor.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDParser.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/ConfigDescriptors.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/DeviceStandardReq.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Events.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/HostStandardReq.c [OK]
Compiling: ../../tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBTask.c [OK]
Compiling: ../../tmk_core/common/host.c [OK]
Compiling: ../../tmk_core/common/keyboard.c [OK]
Compiling: ../../tmk_core/common/action.c [OK]
Compiling: ../../tmk_core/common/action_tapping.c [OK]
Compiling: ../../tmk_core/common/action_macro.c [OK]
Compiling: ../../tmk_core/common/action_layer.c [OK]
Compiling: ../../tmk_core/common/action_util.c [OK]
Compiling: ../../tmk_core/common/print.c [OK]
Compiling: ../../tmk_core/common/debug.c [OK]
Compiling: ../../tmk_core/common/util.c [OK]
Compiling: ../../tmk_core/common/avr/suspend.c [OK]
Assembling: ../../tmk_core/common/avr/xprintf.S [OK]
Compiling: ../../tmk_core/common/avr/timer.c [OK]
Compiling: ../../tmk_core/common/avr/bootloader.c [OK]
Compiling: ../../tmk_core/common/magic.c [OK]
Compiling: ../../tmk_core/common/avr/eeconfig.c [OK]
Compiling: ../../tmk_core/common/mousekey.c [OK]
Compiling: ../../tmk_core/common/command.c [OK]
Compiling: ../../tmk_core/common/backlight.c [OK]
Linking: .build/planck_experimental.elf [ERRORS]
|
| .build/obj_planck_experimental/keyboards/planck/keymaps/experimental/keymap.o: In function `action_get_macro':
| C:\Users\Fred Wales\Documents\Programming\qmk_firmware\keyboards\planck/../../keyboards/planck/keymaps/experimental/keymap.c:240: undefined reference to `breathing_speed_set'
| C:\Users\Fred Wales\Documents\Programming\qmk_firmware\keyboards\planck/../../keyboards/planck/keymaps/experimental/keymap.c:241: undefined reference to `breathing_pulse'
| collect2.exe: error: ld returned 1 exit status
|

View file

@ -0,0 +1 @@

72
keyboards/hadron/rules.mk Normal file
View file

@ -0,0 +1,72 @@
# MCU name
#MCU = at90usb1287
MCU = atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 16000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=512
# Build Options
# change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically
#
BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
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 ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality
MIDI_ENABLE ?= no # MIDI controls
AUDIO_ENABLE ?= no # Audio output on port C6
UNICODE_ENABLE ?= no # Unicode
BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight.
API_SYSEX_ENABLE = yes
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
SRC = i2c.c \
ssd1306.c

View file

@ -0,0 +1,3 @@
ifndef MAKEFILE_INCLUDED
include ../../../Makefile
endif

View file

@ -0,0 +1,35 @@
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VER0_CONFIG_H
#define VER0_CONFIG_H
#include "../config.h"
/* USB Device descriptor parameter */
#define DEVICE_VER 0x0001
/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 15
/* Hadron Ver0 PCB default pin-out */
#define MATRIX_ROW_PINS { D7, E6, B4, B5, B6 }
#define MATRIX_COL_PINS { F6, F7, C6, C7, F5, F4, F1, F0, D2, D3, D5, B3, B2, B1, B0 }
#define UNUSED_PINS
#endif

View file

@ -0,0 +1,5 @@
#AUDIO_ENABLE ?= yes # Audio output on port C6
ifndef QUANTUM_DIR
include ../../../Makefile
endif

View file

@ -0,0 +1 @@
#include "ver0.h"

View file

@ -0,0 +1,6 @@
#ifndef VER0_H
#define VER0_H
#include "../hadron.h"
#endif

View file

@ -0,0 +1,3 @@
ifndef MAKEFILE_INCLUDED
include ../../../Makefile
endif

View file

@ -0,0 +1,35 @@
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VER2_CONFIG_H
#define VER2_CONFIG_H
#include "../config.h"
/* USB Device descriptor parameter */
#define DEVICE_VER 0x0002
/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 15
/* Hadron Ver0 PCB default pin-out */
#define MATRIX_ROW_PINS { D7, E6, B4, B5, B6 }
#define MATRIX_COL_PINS { F6, F7, D6, C7, F5, F4, F1, F0, D2, D3, D5, B3, B2, B1, B0 }
#define UNUSED_PINS
#endif

View file

@ -0,0 +1,5 @@
#AUDIO_ENABLE ?= yes # Audio output on port C6
ifndef QUANTUM_DIR
include ../../../Makefile
endif

View file

@ -0,0 +1 @@
#include "ver2.h"

View file

@ -0,0 +1,6 @@
#ifndef VER2_H
#define VER2_H
#include "../hadron.h"
#endif

View file

@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FLIP_HALF
#define SSD1306OLED
//#define OLED_ROTATE180
#define PREVENT_STUCK_MODIFIERS

View file

@ -357,3 +357,91 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
return MACRO_NONE;
}
void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}
//assign the right code to your layers for OLED display
#define L_BASE 0
#define L_LOWER 8
#define L_RAISE 16
#define L_FNLAYER 64
#define L_NUMLAY 128
#define L_NLOWER 136
#define L_NFNLAYER 192
#define L_MOUSECURSOR 256
#define L_ADJUST 65560
void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
}
#endif
struct CharacterMatrix matrix;
matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("USB: "));
#ifdef PROTOCOL_LUFA
switch (USB_DeviceState) {
case DEVICE_STATE_Unattached:
matrix_write_P(&matrix, PSTR("Unattached"));
break;
case DEVICE_STATE_Suspended:
matrix_write_P(&matrix, PSTR("Suspended"));
break;
case DEVICE_STATE_Configured:
matrix_write_P(&matrix, PSTR("Connected"));
break;
case DEVICE_STATE_Powered:
matrix_write_P(&matrix, PSTR("Powered"));
break;
case DEVICE_STATE_Default:
matrix_write_P(&matrix, PSTR("Default"));
break;
case DEVICE_STATE_Addressed:
matrix_write_P(&matrix, PSTR("Addressed"));
break;
default:
matrix_write_P(&matrix, PSTR("Invalid"));
}
#endif
// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
char buf[40];
snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
matrix_write_P(&matrix, PSTR("\n\nLayer: "));
switch (layer_state) {
case L_BASE:
matrix_write_P(&matrix, PSTR("Default"));
break;
case L_RAISE:
matrix_write_P(&matrix, PSTR("Raise"));
break;
case L_LOWER:
matrix_write_P(&matrix, PSTR("Lower"));
break;
case L_ADJUST:
matrix_write_P(&matrix, PSTR("ADJUST"));
break;
default:
matrix_write(&matrix, buf);
}
// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
}

View file

@ -0,0 +1,3 @@
#include "../../config.h"
#define BACKLIGHT_BREATHING

View file

@ -5,10 +5,11 @@
#include "command.h"
#define _MA 0
#define _FL 1
#define _AR 2
#define _LO 3
#define _UL 4
#define _GA 1
#define _FL 2
#define _AR 3
#define _LO 4
#define _UL 5
#define TRNS KC_TRNS
#define trigger_time 400
@ -29,6 +30,15 @@
#define LSHIFT OSM(MOD_LSFT)
#define SPACE LT(_AR, KC_SPC)
#define MACRO_BREATH_TOGGLE 13
#define MACRO_BREATH_SPEED_INC 14
#define MACRO_BREATH_SPEED_DEC 15
#define MACRO_BREATH_DEFAULT 16
#define M_BRTOG M(MACRO_BREATH_TOGGLE)
#define M_BSPDU M(MACRO_BREATH_SPEED_INC)
#define M_BSPDD M(MACRO_BREATH_SPEED_DEC)
#define M_BDFLT M(MACRO_BREATH_DEFAULT)
static uint16_t key_timer;
enum emoticons {
@ -60,25 +70,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap _FL: Function Layer
* ,----------------------------------------------------------------.
* |~` | F1|F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |Prsc|
* |~` | F1|F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|Reset |Prsc|
* |----------------------------------------------------------------|
* | |MbL|MsU|MbR| | | | | | | | | | |_LO |
* |----------------------------------------------------------------|
* | |MsL|MsD|MsR| | | | | | | | | |Hme |
* | |MsL|MsD|MsR| |_GA| | | | | | | |Hme |
* |----------------------------------------------------------------|
* | | | | | | | | | |VoU|VoD|Mut| |MwU|End |
* | | |BL-|BL+|BL |BR-|BR+|BR | |VoU|VoD|Mut| |MwU|End |
* |----------------------------------------------------------------|
* | | | | | | | |MwL|MwD|MwR |
* `----------------------------------------------------------------'
*/
[_FL] = KEYMAP_ANSI(
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, TRNS, KC_PSCR, \
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, RESET, KC_PSCR, \
TRNS, KC_BTN1, KC_MS_U, KC_BTN2, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TO(_LO), \
TRNS, KC_MS_L, KC_MS_D, KC_MS_R, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KC_HOME, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KC_VOLD, KC_VOLU, KC_MUTE, TRNS, KC_WH_U, KC_END, \
TRNS, KC_MS_L, KC_MS_D, KC_MS_R, TRNS, TG(_GA), TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KC_HOME, \
TRNS, TRNS, BL_DEC, BL_INC, BL_TOGG, M_BSPDD, M_BSPDU, M_BRTOG, TRNS, KC_VOLD, KC_VOLU, KC_MUTE, TRNS, KC_WH_U, KC_END, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KC_WH_L, KC_WH_D, KC_WH_R),
/* Keymap _UL: Unlock layer
/* Keymap _AR: Arrow layer
* ,----------------------------------------------------------------.
* | | | | | | | | | | | | | | | |
* |----------------------------------------------------------------|
@ -98,6 +108,26 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
SHRUG, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
/* Keymap _GA: Game layer
* ,----------------------------------------------------------------.
* |Esc | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |P/P |
* |----------------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ |Del |
* |----------------------------------------------------------------|
* |CAPS | A| S| D| F| G| H| J| K| L| ;| '|Return |PgUp|
* |----------------------------------------------------------------|
* |Shft|End| Z| X| C| V| B| N| M| ,| .| /|Shift | Up|PgDn|
* |----------------------------------------------------------------|
* |Ctrl|Win |Alt | Space |Alt|Ctrl| FN|Lef|Dow|Rig |
* `----------------------------------------------------------------'
*/
[_GA] = KEYMAP_ANSI(
KC_ESC, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, KC_BSPC, KC_MPLY, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, \
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, \
KC_LSFT, END_HOME, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, \
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RCTRL, MO(_FL), KC_LEFT, KC_DOWN, KC_RGHT),
/* Keymap _UL: Unlock layer
* ,----------------------------------------------------------------.
* | | | | | | | | | | | | | | | |
@ -378,6 +408,29 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
}
}
break;
case MACRO_BREATH_TOGGLE:
if (record->event.pressed) {
breathing_toggle();
}
break;
case MACRO_BREATH_SPEED_INC:
if (record->event.pressed) {
breathing_speed_inc(1);
}
break;
case MACRO_BREATH_SPEED_DEC:
if (record->event.pressed) {
breathing_speed_dec(1);
}
break;
case MACRO_BREATH_DEFAULT:
if (record->event.pressed) {
breathing_defaults();
}
break;
}
return MACRO_NONE;
};

View file

@ -21,8 +21,8 @@ OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)\n
ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)\n
WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)\n
TAB_LOG = printf "\n$$LOG\n\n" | $(AWK) '{ sub(/^/," | "); print }'
TAB_LOG_PLAIN = printf "$$LOG\n"
TAB_LOG = printf "\n%s\n\n" "$$LOG" | $(AWK) '{ sub(/^/," | "); print }'
TAB_LOG_PLAIN = printf "%s\n" "$$LOG"
AWK_STATUS = $(AWK) '{ printf " %-10s\n", $$1; }'
AWK_CMD = $(AWK) '{ printf "%-99s", $$0; }'
PRINT_ERROR = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) && $(ON_ERROR)

View file

@ -169,7 +169,6 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
}
// translates key to keycode
__attribute__ ((weak))
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
// Read entire word (16bits)

View file

@ -41,3 +41,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
}
return MACRO_NONE;
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
}

View file

@ -58,3 +58,6 @@ void release_key(uint8_t col, uint8_t row) {
void clear_all_keys(void) {
memset(matrix, 0, sizeof(matrix));
}
void led_set(uint8_t usb_led) {
}

View file

@ -44,8 +44,8 @@ void TestFixture::run_one_scan_loop() {
advance_time(1);
}
void TestFixture::idle_for(uint time) {
for (uint i=0; i<time; i++) {
void TestFixture::idle_for(unsigned time) {
for (unsigned i=0; i<time; i++) {
run_one_scan_loop();
}
}

View file

@ -26,5 +26,5 @@ public:
static void TearDownTestCase();
void run_one_scan_loop();
void idle_for(uint ms);
void idle_for(unsigned ms);
};

View file

@ -1,3 +1,5 @@
SYSTEM_TYPE := $(shell gcc -dumpmachine)
CC = gcc
OBJCOPY =
OBJDUMP =
@ -14,6 +16,9 @@ COMPILEFLAGS += -funsigned-bitfields
COMPILEFLAGS += -ffunction-sections
COMPILEFLAGS += -fdata-sections
COMPILEFLAGS += -fshort-enums
ifneq ($(findstring mingw, ${SYSTEM_TYPE}),)
COMPILEFLAGS += -mno-ms-bitfields
endif
CFLAGS += $(COMPILEFLAGS)
CFLAGS += -fno-inline-small-functions

16
util/activate_msys2.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/bash
function export_variables {
local util_dir=~/qmk_utils
export PATH=$PATH:$util_dir/dfu-programmer
export PATH=$PATH:$util_dir/dfu-util-0.9-win64
export PATH=$PATH:$util_dir/flip/bin
export PATH=$PATH:$util_dir/avr8-gnu-toolchain/bin
export PATH=$PATH:$util_dir/gcc-arm-none-eabi/bin
}
export_variables

117
util/msys2_install.sh Normal file
View file

@ -0,0 +1,117 @@
#!/bin/bash
dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
download_dir=~/qmk_utils
avrtools=avr8-gnu-toolchain
armtools=gcc-arm-none-eabi
installflip=false
echo "Installing dependencies needed for the installation (quazip)"
pacman --needed -S msys/unzip msys/p7zip base-devel msys/git mingw-w64-x86_64-toolchain
source "$dir/win_shared_install.sh"
function install_avr {
rm -f -r "$avrtools"
wget "http://www.atmel.com/images/avr8-gnu-toolchain-installer-3.5.4.91-win32.any.x86.exe"
7z x avr8-gnu-toolchain-installer-3.5.4.91-win32.any.x86.exe
rm avr8-gnu-toolchain-installer-3.5.4.91-win32.any.x86.exe
}
function install_arm {
wget -O gcc-arm-none-eabi.zip "https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-win32.zip?product=GNU%20ARM%20Embedded%20Toolchain,ZIP,,Windows,6-2017-q2-update"
unzip -d gcc-arm-none-eabi gcc-arm-none-eabi.zip
rm gcc-arm-none-eabi.zip
}
function extract_flip {
rm -f -r flip
7z -oflip x FlipInstaller.exe
}
pushd "$download_dir"
if [ -f "FlipInstaller.exe" ]; then
echo
echo "Extracting flip"
extract_flip
fi
if [ ! -d "$avrtools" ]; then
while true; do
echo
echo "The AVR toolchain is not installed."
echo "This is needed for building AVR based keboards."
read -p "Do you want to install it? (Y/N) " res
case $res in
[Yy]* ) install_avr; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
else
while true; do
echo
echo "The AVR toolchain is already installed"
read -p "Do you want to reinstall? (Y/N) " res
case $res in
[Yy]* ) install_avr; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
fi
if [ ! -d "$armtools" ]; then
while true; do
echo
echo "The ARM toolchain is not installed."
echo "This is needed for building ARM based keboards."
read -p "Do you want to install it? (Y/N) " res
case $res in
[Yy]* ) install_arm; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
else
while true; do
echo
echo "The ARM toolchain is already installed"
read -p "Do you want to reinstall? (Y/N) " res
case $res in
[Yy]* ) install_arm; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
fi
popd
cp -f "$dir/activate_msys2.sh" "$download_dir/"
if grep "^source ~/qmk_utils/activate_msys2.sh$" ~/.bashrc
then
echo
echo "The line source ~/qmk_utils/activate_msys2.sh is already added to your /.bashrc"
echo "Not adding it twice!"
else
while true; do
echo
echo "Do you want to add 'source ~/qmk_utils/activate_msys2.sh' to the end of your"
echo ".bashrc file? Without this make won't find the needed utils, so if you don't"
echo "want to do it automatically, then you have to do it manually later."
read -p "(Y/N)? " res
case $res in
[Yy]* ) echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
fi
echo
echo "******************************************************************************"
echo "Installation completed!"
echo "Please close this Window and restart MSYS2 MinGW"
echo "******************************************************************************"

View file

@ -0,0 +1,80 @@
#!/bin/bash
function install_utils {
rm -f -r "$download_dir"
mkdir "$download_dir"
pushd "$download_dir"
echo "Installing dfu-programmer"
wget 'http://downloads.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip'
unzip -d dfu-programmer dfu-programmer-win-0.7.2.zip
echo "Installing dfu-util"
wget 'http://dfu-util.sourceforge.net/releases/dfu-util-0.9-win64.zip'
unzip dfu-util-0.9-win64.zip
echo "Installing teensy_loader_cli"
wget 'https://www.pjrc.com/teensy/teensy_loader_cli_windows.zip'
unzip teensy_loader_cli_windows.zip
echo "Installing Atmel Flip"
wget 'http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe'
mv Flip\ Installer\ \-\ 3.4.7.112.exe FlipInstaller.exe
echo "Downloading the QMK driver installer"
wget -qO- https://api.github.com/repos/qmk/qmk_driver_installer/releases | grep browser_download_url | head -n 1 | cut -d '"' -f 4 | wget -i -
rm -f *.zip
popd > /dev/null
}
function install_drivers {
pushd "$download_dir"
cp -f "$dir/drivers.txt" .
echo
cmd.exe /c "qmk_driver_installer.exe $1 $2 drivers.txt"
popd > /dev/null
}
pushd "$dir"
if [ ! -d "$download_dir" ]; then
install_utils
else
while true; do
echo
echo "The utils seem to already be downloaded."
read -p "Do you want to re-download them and update to the newest version (Y/N) " res
case $res in
[Yy]* ) install_utils; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
fi
while true; do
echo
echo "Which USB drivers do you want to install?"
echo "(A)all - All supported drivers will be installed"
echo "(C)onnected - Only drivers for connected keyboards (in bootloader/flashing mode)"
echo " will be installed"
echo "(F)force - Like all, but will also override existing drivers for connected"
echo " keyboards"
echo "(N)one - No drivers will be installed,"
echo " flashing your keyboard will most likely not work"
read -p "(A/C/F/N)? " res
case $res in
[Aa]* ) install_drivers --all; break;;
[Cc]* ) install_drivers; break;;
[Ff]* ) install_drivers --all --force; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
popd > /dev/null

View file

@ -1,44 +1,7 @@
#!/bin/bash
download_dir=wsl_downloaded
function install_utils {
rm -f -r $download_dir
mkdir $download_dir
pushd $download_dir
echo "Installing dfu-programmer"
wget 'http://downloads.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip'
unzip -d dfu-programmer dfu-programmer-win-0.7.2.zip
echo "Installing dfu-util"
wget 'http://dfu-util.sourceforge.net/releases/dfu-util-0.9-win64.zip'
unzip dfu-util-0.9-win64.zip
echo "Installing teensy_loader_cli"
wget 'https://www.pjrc.com/teensy/teensy_loader_cli_windows.zip'
unzip teensy_loader_cli_windows.zip
echo "Installing Atmel Flip"
wget 'http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe'
mv Flip\ Installer\ \-\ 3.4.7.112.exe FlipInstaller.exe
echo "Downloading the QMK driver installer"
wget -qO- https://api.github.com/repos/qmk/qmk_driver_installer/releases | grep browser_download_url | head -n 1 | cut -d '"' -f 4 | wget -i -
rm -f *.zip
popd > /dev/null
}
function install_drivers {
pushd $download_dir
cmd.exe /C qmk_driver_installer.exe $1 $2 ../drivers.txt
popd > /dev/null
}
dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
pushd "$dir";
if [[ $dir != /mnt/* ]];
then
@ -48,7 +11,6 @@ then
exit 1
fi
pushd "$dir"
while true; do
echo
@ -67,49 +29,25 @@ echo "Installing dependencies needed for the installation (unzip, wget)"
echo "This will ask for the sudo password"
sudo apt-get install unzip wget
download_dir=wsl_downloaded
if [ ! -d "$download_dir" ]; then
install_utils
else
while true; do
echo
read -p "The utils seem to already be downloaded, do you want to re-download them and update to the newest version (Y/N) " res
case $res in
[Yy]* ) install_utils; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
fi
source "$dir/win_shared_install.sh"
pushd "$download_dir"
while true; do
echo
read -p "Flip need to be installed if you want to use that for programming, do you want to install it now? (Y/N) " res
echo "Flip need to be installed if you want to use that for programming."
echo "Please install it to the default location!"
read -p "Do you want to install it now? (Y/N) " res
case $res in
[Yy]* ) cmd.exe /c $download_dir\\FlipInstaller.exe; break;;
[Yy]* ) cmd.exe /c FlipInstaller.exe; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
popd
while true; do
echo
echo "Which USB drivers do you want to install?"
echo "(A)all - All supported drivers will be installed"
echo "(C)onnected - Only drivers for connected keyboards (in bootloader/flashing mode) will be installed"
echo "(F)force - Like all, but will also override existing drivers for connected keyboards"
echo "(N)one - No drivers will be installed, flashing your keyboard will most likely not work"
read -p "(A/C/F/N)? " res
case $res in
[Aa]* ) install_drivers --all; break;;
[Cc]* ) install_drivers; break;;
[Ff]* ) install_drivers --all --force; break;;
[Nn]* ) break;;
* ) echo "Invalid answer";;
esac
done
echo
echo "Creating a softlink to the utils directory as ~/qmk_utils."
echo "This is needed so that the the make system can find all utils it need."
@ -124,9 +62,9 @@ then
else
while true; do
echo
echo "Do you want to add 'source ~/qmk_utils/activate_wsl.sh' to the end of you .bashrc file?"
echo "Without this make won't find the needed utils, so if you don't want to do it automatically,"
echo "then you have to do it manually."
echo "Do you want to add 'source ~/qmk_utils/activate_wsl.sh' to the end of your"
echo ".bashrc file? Without this make won't find the needed utils, so if you don't"
echo "want to do it automatically, then you have to do it manually later."
read -p "(Y/N)? " res
case $res in
[Yy]* ) echo "source ~/qmk_utils/activate_wsl.sh" >> ~/.bashrc; break;;
@ -138,9 +76,10 @@ fi
while true; do
echo
echo "Do you want to add a symlink to the QMK repository in your home directory for convenience?"
echo "This will create a folder 'qmk_firmware' in your home directory."
echo "In the future you can use this folder instead of the full path on your windows file system"
echo "Do you want to add a symlink to the QMK repository in your home directory for"
echo "convenience? This will create a folder 'qmk_firmware' in your home directory."
echo "In the future you can use this folder instead of the full path on your Windows"
echo "file system."
read -p "(Y/N)? " res
case $res in
[Yy]* ) ln -sfn "$dir/.." ~/qmk_firmware; break;;
@ -156,4 +95,3 @@ echo "You need to open a new batch command prompt for all the utils to work prop
echo "******************************************************************************"
popd > /dev/null