[Keyboard] Added D48 keyboard (#8548)
* [Keyboard] Added D48 keyboard. * Updated README. * Cleanups. * Moved d48 to handwired/ * Added link to build process album. * Coding conventions cleanups. * Added DS1307 RTC! * Minor cleanups. * Apply suggestions from code review Co-Authored-By: Drashna Jaelre <drashna@live.com> * Minor refactoring. * Readme fix. * Moved leftover keymap-specific code from keyboard space into keymap. * Added encoder button pins to extra matrix row. * Updated README, updated pinout & cleaned up the glcdfont * Apply suggestions from code review Co-Authored-By: Drashna Jaelre <drashna@live.com> * Update config.h * Apply suggestions from code review Co-Authored-By: Ryan <fauxpark@gmail.com> * Added default keymap. Refactored existing keymap. * Update keyboards/handwired/d48/README.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Apply suggestions from code review Co-Authored-By: Joel Challis <git@zvecr.com> * Minor alignment fix. * Update keyboards/handwired/d48/glcdfont_d48.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Changes as per PR. * Apply suggestions from code review Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Joel Challis <git@zvecr.com> Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>miryoku-merge-master
parent
803610a284
commit
1f7bbf279c
@ -0,0 +1,87 @@
|
||||
# D48
|
||||
|
||||

|
||||
|
||||
A Proton C based handwired 48 key keyboard with 2 rotary encoders, I2C OLED, WS2812 strip, buzzer & clock!
|
||||
|
||||
- Keyboard Maintainer: Andrew Dunai
|
||||
- Hardware Supported: Proton C handwired
|
||||
|
||||
Make example for this keyboard (after setting up your build environment):
|
||||
|
||||
make handwired/d48:default
|
||||
|
||||
## Details
|
||||
|
||||
- Proton C based handwired keyboard
|
||||
- 2x custom 1.25mm stainless steel plates
|
||||
- Kailh Choc White (clicky)
|
||||
- 2x rotary encoders
|
||||
- 0.91" 128x32 I<sup>2</sup>C OLED
|
||||
- Small buzzer mounted inside (still waiting for the AST1109MLTRQ boys)
|
||||
- WS2812 strip (14 LEDs)
|
||||
- DS1307 I<sup>2</sup>C module real-time clock
|
||||
|
||||
Build process: [album](https://imgur.com/gallery/zZZGdDw)
|
||||
|
||||
## Pinout
|
||||
|
||||

|
||||
|
||||
## Challenges
|
||||
|
||||
I'm very happy with the result, but at some point Proton C was driving me nuts.
|
||||
|
||||
I did a lot of trial and error during assembly & programming.
|
||||
There were a lot of *yet* undocumented caveats,
|
||||
so I'll outline them here so that you guys can avoid the same issues I had.
|
||||
|
||||
## Matrix & encoders
|
||||
|
||||
Although this is a 48-key board with a 12-col & 4-row matrix, I've decided to add an extra row above the first one
|
||||
to make my matrix 12x5 and wire encoders' push buttons as 2 extra keys, thus making it a total of 50 (12x4 + 2 encoders).
|
||||
I used 2 columns (9 & 12) for those buttons.
|
||||
|
||||
So, a first row actually has 2 buttons on columns 9 & 12 (because encoders are located near those columns).
|
||||
Encoders' push buttons are also configured via QMK's keymap.
|
||||
|
||||
Check out the `d48.h` & `config.h` for pins used & keymap macro definition.
|
||||
|
||||
## I<sup>2</sup>C/OLED
|
||||
|
||||
Most of the stuff worked out of the box, except me choosing the right pins for my OLED.
|
||||
|
||||
On the Proton C pinout, there are 3 labels for I<sup>2</sup>C and for some reason
|
||||
there are 2 pairs of SDA/SCL for I<sup>2</sup>C<sup>1</sup> channel: `B8`/`B9` (rear left side) and `B6`/`B7` (rear right side).
|
||||
I'm not sure if this is a mistake or if I was doing something wrong. So initially I picked `B8`/`B9`
|
||||
which were not working. When I switched to B6/B7, things worked like a charm.
|
||||
Later I used B9 for matrix row. No issues so far.
|
||||
|
||||
Oh, and by the way, while using `B8`/`B9`, keyboard was sometimes *swallowing* quick keypresses.
|
||||
I believe this was due to I(2)C timeouts (because incorrect pins were used for OLED).
|
||||
|
||||
## Buzzer
|
||||
|
||||
It turns out once you switch on `AUDIO_ENABLE`, you cannot use A4 & A5 because they interfere with the buzzer.
|
||||
My guess is that buzzer uses DAC channels (not sure why both).
|
||||
|
||||
I couldn't find this in documentation. Honestly, Proton C has almost zero documentation and this was
|
||||
the biggest challenge. Anyway, apart from almost going crazy from those challenges, I really liked it!
|
||||
|
||||
## RGB
|
||||
|
||||
I used pin `A15` for my WS28128 RGB strip.
|
||||
|
||||
## D1307 real-time clock
|
||||
|
||||
Connecting DS1307 RTC was a piece of cake: same I<sup>2</sup> pins as OLED (SDA/SCL), GND to GND and power to Proton C VUSB pin (5v).
|
||||
|
||||
## Other issues
|
||||
|
||||
- `B5` could not be used for matrix.
|
||||
- `TAP_CODE_DELAY` had to be increased to 10 to fix `tap_code(KC_VOLU/KC_VOLD)` calls being swallowed in encoder callback.
|
||||
- Be extremely attentive about the pinout: keep in mind that **the official Proton C pinout displays the rear of the board, not the front.** Being used to front pinouts, I ended up soldering entire matrix to the wrong side, so I had to desolder every wire and connect it to the opposite side.
|
||||
|
||||
## Conclusion
|
||||
|
||||
I had a lot of fun. The layout was inspired by the Planck THK. Feel free to ask any questions!
|
||||
@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6060
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER Andrew Dunai
|
||||
#define PRODUCT D48
|
||||
|
||||
/* Key matrix size */
|
||||
#define MATRIX_ROWS 5
|
||||
#define MATRIX_COLS 12
|
||||
|
||||
/* Key matrix pins */
|
||||
#define MATRIX_ROW_PINS { B8, B9, B1, B2, B4 }
|
||||
|
||||
#define MATRIX_COL_PINS { A2, B0, A7, A8, A13, A14, B12, B11, B10, B15, B14, B13 }
|
||||
#define UNUSED_PINS
|
||||
|
||||
/* COL2ROW or ROW2COL */
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
// #define DEBOUNCE 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
|
||||
|
||||
/* prevent stuck modifiers */
|
||||
// #define PREVENT_STUCK_MODIFIERS
|
||||
|
||||
/* RGB Underglow */
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
#define RGB_DI_PIN A15
|
||||
#define RGBLED_NUM 14
|
||||
#define RGBLIGHT_HUE_STEP 8
|
||||
#define RGBLIGHT_SAT_STEP 8
|
||||
#define RGBLIGHT_VAL_STEP 8
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#endif
|
||||
|
||||
/* Audio */
|
||||
#ifdef AUDIO_ENABLE
|
||||
#define STARTUP_SONG_DOOM SONG(E1M1_DOOM)
|
||||
#define STARTUP_SONG SONG( \
|
||||
Q__NOTE(_E6), \
|
||||
Q__NOTE(_A6), \
|
||||
H__NOTE(_E7), \
|
||||
Q__NOTE(_E6), \
|
||||
Q__NOTE(_E7) \
|
||||
)
|
||||
#endif
|
||||
|
||||
/* Encoders */
|
||||
#define ENCODERS_PAD_A { B3, A0 }
|
||||
#define ENCODERS_PAD_B { A6, A1 }
|
||||
/* #define ENCODER_RESOLUTION 4 */
|
||||
|
||||
/* OLED */
|
||||
#define OLED_FONT_H "glcdfont_d48.c"
|
||||
#define OLED_TIMEOUT 0
|
||||
// #define OLED_SCROLL_TIMEOUT 1000
|
||||
|
||||
/* Taps (encoder tap_code) */
|
||||
#define TAP_CODE_DELAY 10
|
||||
|
||||
/* I2C */
|
||||
//#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
|
||||
//#define PAL_MODE_STM32_ALTERNATE_OPENDRAIN (PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN)
|
||||
|
||||
/* DS1307 */
|
||||
#define DS1307_ADDR (0x68 << 1)
|
||||
@ -0,0 +1 @@
|
||||
#include "d48.h"
|
||||
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
#define ___ KC_NO
|
||||
|
||||
#define LAYOUT( \
|
||||
K08, K0B, \
|
||||
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
|
||||
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
|
||||
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, \
|
||||
K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B \
|
||||
) { \
|
||||
{ ___, ___, ___, ___, ___, ___, ___, ___, K08, ___, ___, K0B }, \
|
||||
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B }, \
|
||||
{ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \
|
||||
{ K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B }, \
|
||||
{ K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B } \
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
#include "ds1307.h"
|
||||
#include "i2c_master.h"
|
||||
|
||||
void ds1307_set_time(uint8_t h, uint8_t m, uint8_t s) {
|
||||
uint8_t data[] = {
|
||||
((s % 10) | ((s / 10) << 4)) & 0x7F,
|
||||
((m % 10) | ((m / 10) << 4)) & 0x7F,
|
||||
((h % 10) | ((h / 10) << 4)) & 0x3F,
|
||||
0, 0, 0, 0, 0
|
||||
}; // 24-hour mode
|
||||
i2c_writeReg(DS1307_ADDR, 0, data, 8, 100);
|
||||
}
|
||||
|
||||
void ds1307_get_time(uint8_t *h, uint8_t *m, uint8_t *s) {
|
||||
uint8_t data[3];
|
||||
i2c_readReg(DS1307_ADDR, 0, data, 3, 100);
|
||||
i2c_stop();
|
||||
*s = (data[0] & 0b1111) + ((data[0] & 0b1110000) >> 4) * 10;
|
||||
*m = (data[1] & 0b1111) + ((data[1] & 0b1110000) >> 4) * 10;
|
||||
*h = (data[2] & 0b1111) + ((data[2] & 0b0110000) >> 4) * 10;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void ds1307_set_time(uint8_t h, uint8_t m, uint8_t s);
|
||||
void ds1307_get_time(uint8_t *h, uint8_t *m, uint8_t *s);
|
||||
@ -0,0 +1,231 @@
|
||||
#include "progmem.h"
|
||||
|
||||
// Helidox 8x6 font with QMK Firmware Logo
|
||||
// Online editor: http://teripom.x0.com/
|
||||
|
||||
static const unsigned char font[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00,
|
||||
0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00, 0x00,
|
||||
0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26, 0x00,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07, 0x00,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00,
|
||||
0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14, 0x00,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A, 0x00,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60, 0x00,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08, 0x00,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10, 0x00,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10, 0x00,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30, 0x00,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62, 0x00,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50, 0x00,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08, 0x00,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x00,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02, 0x00,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46, 0x00,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33, 0x00,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10, 0x00,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39, 0x00,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07, 0x00,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36, 0x00,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E, 0x00,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41, 0x00,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x00,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08, 0x00,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06, 0x00,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36, 0x00,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22, 0x00,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41, 0x00,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01, 0x00,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73, 0x00,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01, 0x00,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41, 0x00,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40, 0x00,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06, 0x00,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46, 0x00,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32, 0x00,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03, 0x00,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63, 0x00,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03, 0x00,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43, 0x00,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41, 0x00,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20, 0x00,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F, 0x00,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04, 0x00,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40, 0x00,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40, 0x00,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38, 0x00,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28, 0x00,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F, 0x00,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18, 0x00,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02, 0x00,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78, 0x00,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78, 0x00,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78, 0x00,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38, 0x00,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18, 0x00,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC, 0x00,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08, 0x00,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24, 0x00,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24, 0x00,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44, 0x00,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44, 0x00,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02, 0x00,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x70, 0x78, 0x3C,
|
||||
0x1E, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0,
|
||||
0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC,
|
||||
0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07, 0x07, 0x0F,
|
||||
0x1F, 0xFE, 0xFE, 0xF8, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xF0, 0xFC, 0xFE, 0xFE, 0x3F,
|
||||
0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x9F,
|
||||
0xFF, 0xFE, 0xFE, 0xFC, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x22, 0x22, 0x00, 0x02, 0x3E,
|
||||
0x02, 0x00, 0x3E, 0x20, 0x20, 0x00,
|
||||
0x00, 0x3C, 0x0A, 0x3C, 0x00, 0x3E,
|
||||
0x20, 0x20, 0x02, 0x3E, 0x02, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x32, 0x00, 0x1E,
|
||||
0x20, 0x20, 0x1E, 0x00, 0x3E, 0x00,
|
||||
0x00, 0x2C, 0x2A, 0x1A, 0x00, 0x3E,
|
||||
0x0A, 0x02, 0x00, 0x02, 0x3E, 0x02,
|
||||
0x00, 0x00, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF,
|
||||
0xFF, 0xE7, 0xE0, 0xE0, 0xE7, 0xFF,
|
||||
0xFF, 0xFF, 0xF8, 0xC0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3C,
|
||||
0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x7E,
|
||||
0xFF, 0xE7, 0xE7, 0x81, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
|
||||
0xF0, 0xF8, 0x7C, 0x3E, 0x1F, 0x0F,
|
||||
0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x2F, 0x2F, 0x0F, 0x0F,
|
||||
0xF0, 0xF0, 0xF2, 0xF2, 0xF0, 0xF0,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x00, 0x00, 0x22, 0x22, 0x00, 0xFF,
|
||||
0x0F, 0x0F, 0x2F, 0x2F, 0x0F, 0xFF,
|
||||
0xF0, 0xF0, 0xF2, 0xF2, 0xF0, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF0, 0xFE, 0xFF, 0xFF, 0x0F, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x0F, 0xFF, 0xFF, 0xFE, 0xF0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0,
|
||||
0xF8, 0x7F, 0x7F, 0x1F, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x0F, 0x3F, 0x7F, 0x7F, 0xFF,
|
||||
0xF9, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8,
|
||||
0xFC, 0x7F, 0x7F, 0x3F, 0x0F, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0xFF, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
|
||||
0xFF, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0xFF, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
};
|
||||
@ -0,0 +1,44 @@
|
||||
#include "lightmode.h"
|
||||
|
||||
#ifdef LIGHTMODE_ENABLE
|
||||
|
||||
/* Light modes switcher */
|
||||
|
||||
uint8_t light_mode = SMOOTHLED;
|
||||
|
||||
void set_light_mode(light_mode_t value, uint32_t color) {
|
||||
light_mode = value;
|
||||
if (light_mode == SMOOTHLED) {
|
||||
smoothled_set(color);
|
||||
} else {
|
||||
dmc12_start(color, true);
|
||||
}
|
||||
}
|
||||
|
||||
void process_light_mode(void) {
|
||||
if (light_mode == SMOOTHLED) {
|
||||
smoothled_process();
|
||||
} else {
|
||||
dmc12_process();
|
||||
}
|
||||
}
|
||||
|
||||
void update_light_mode(uint32_t color) {
|
||||
if (light_mode == SMOOTHLED) {
|
||||
smoothled_set(color);
|
||||
} else {
|
||||
dmc12_start(color, false);
|
||||
}
|
||||
}
|
||||
|
||||
void next_light_mode(uint32_t color) {
|
||||
light_mode = (light_mode + 1) % LIGHT_MODE_SIZE;
|
||||
set_light_mode(light_mode, color);
|
||||
}
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
process_light_mode();
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,12 @@
|
||||
#include "smoothled.h"
|
||||
#include "dmc12.h"
|
||||
#include "quantum.h"
|
||||
|
||||
/* Light modes */
|
||||
enum light_mode_enum { SMOOTHLED, DMC12, LIGHT_MODE_SIZE };
|
||||
typedef enum light_mode_enum light_mode_t;
|
||||
|
||||
void set_light_mode(light_mode_t value, uint32_t color);
|
||||
void process_light_mode(void);
|
||||
void update_light_mode(uint32_t color);
|
||||
void next_light_mode(uint32_t color);
|
||||
@ -0,0 +1,2 @@
|
||||
OPT_DEFS += -DLIGHTMODE_ENABLE
|
||||
SRC += smoothled.c dmc12.c seq.c lightmode.c
|
||||
@ -0,0 +1,22 @@
|
||||
# MCU name
|
||||
MCU = STM32F303
|
||||
|
||||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
NKRO_ENABLE = yes # USB 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
|
||||
AUDIO_ENABLE = yes
|
||||
USE_I2C = no
|
||||
RGBLIGHT_ENABLE = yes
|
||||
ENCODER_ENABLE = yes
|
||||
OLED_DRIVER_ENABLE = yes
|
||||
UNICODE_ENABLE = yes
|
||||
|
||||
SRC += ds1307.c taphold.c
|
||||
@ -0,0 +1,29 @@
|
||||
#include "taphold.h"
|
||||
|
||||
bool taphold_process(uint16_t keycode, keyrecord_t *record) {
|
||||
for (int i = 0; i < taphold_config_size; i++) {
|
||||
taphold_t *config = &taphold_config[i];
|
||||
if (config->key == keycode && record->event.pressed) {
|
||||
if (config->mode == TAPHOLD_LAYER) {
|
||||
layer_on(config->longAction);
|
||||
} else {
|
||||
register_code(config->longAction);
|
||||
}
|
||||
config->time = timer_read32();
|
||||
config->keypos = record->event.key;
|
||||
return false;
|
||||
} else if (KEYEQ(record->event.key, config->keypos) && !record->event.pressed) {
|
||||
if (config->mode == TAPHOLD_LAYER) {
|
||||
layer_off(config->longAction);
|
||||
} else {
|
||||
unregister_code(config->longAction);
|
||||
}
|
||||
if (timer_elapsed32(config->time) < taphold_timeout) {
|
||||
tap_code(config->shortAction);
|
||||
}
|
||||
config->keypos.row = 255;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
#include "quantum.h"
|
||||
|
||||
typedef enum taphold_mode_t {
|
||||
TAPHOLD_LAYER,
|
||||
TAPHOLD_MOD
|
||||
} taphold_mode_t;
|
||||
|
||||
typedef struct taphold_t {
|
||||
uint16_t key;
|
||||
uint32_t time;
|
||||
taphold_mode_t mode;
|
||||
uint16_t shortAction;
|
||||
uint16_t longAction;
|
||||
keypos_t keypos;
|
||||
// We store key pos to properly release the key
|
||||
// even when a different layer is active and the key has a different action now
|
||||
} taphold_t;
|
||||
|
||||
extern taphold_t taphold_config[];
|
||||
extern uint16_t taphold_config_size;
|
||||
// Dual keys tap/hold timeout.
|
||||
// If key is tapped for less than this value, send key in addition to primary action after completing the action.
|
||||
extern uint32_t taphold_timeout;
|
||||
|
||||
bool taphold_process(uint16_t keycode, keyrecord_t *record);
|
||||
@ -0,0 +1,46 @@
|
||||
#include "dmc12.h"
|
||||
|
||||
static uint32_t dmc12_color = 0;
|
||||
static uint16_t dmc12_timer = 0;
|
||||
static int8_t dmc12_current = 0;
|
||||
static uint8_t dmc12_direction = 1;
|
||||
|
||||
void dmc12_start(uint32_t color, bool reset) {
|
||||
dmc12_color = color;
|
||||
if (reset) {
|
||||
dmc12_timer = 0;
|
||||
dmc12_current = 0;
|
||||
dmc12_direction = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void dmc12_process(void) {
|
||||
if (!dmc12_timer) {
|
||||
dmc12_timer = timer_read();
|
||||
return;
|
||||
}
|
||||
float dist_from_center = ((float)abs(dmc12_current - RGBLED_NUM / 2)) / ((float)RGBLED_NUM);
|
||||
if (timer_elapsed(dmc12_timer) > dist_from_center * LED_INTERVAL) {
|
||||
dmc12_current += dmc12_direction;
|
||||
if (dmc12_current == 0 || dmc12_current == RGBLED_NUM - 1) {
|
||||
dmc12_direction *= -1;
|
||||
}
|
||||
dmc12_timer = timer_read();
|
||||
for (int i = 0; i < RGBLED_NUM; i++) {
|
||||
if (i > dmc12_current - LED_RADIUS && i < dmc12_current + LED_RADIUS) {
|
||||
float intensity = (LED_RADIUS - abs(i - dmc12_current)) / ((float)LED_RADIUS);
|
||||
if (i != dmc12_current) {
|
||||
intensity /= 4.0;
|
||||
}
|
||||
rgblight_setrgb_at(
|
||||
((dmc12_color >> 16) & 0xFF) * intensity,
|
||||
((dmc12_color >> 8) & 0xFF) * intensity,
|
||||
(dmc12_color & 0xFF) * intensity,
|
||||
i
|
||||
);
|
||||
} else {
|
||||
rgblight_setrgb_at(0, 0, 0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
// Sexy LED animation.
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
#define LED_INTERVAL 160
|
||||
#define LED_RADIUS 6
|
||||
|
||||
void dmc12_start(uint32_t color, bool reset);
|
||||
void dmc12_process(void);
|
||||
@ -0,0 +1,38 @@
|
||||
#include "seq.h"
|
||||
|
||||
static char buffer[32];
|
||||
static uint8_t buffer_size = 0;
|
||||
|
||||
void seq_start(void) {
|
||||
buffer_size = 0;
|
||||
SEND_STRING(":");
|
||||
}
|
||||
|
||||
bool seq_feed(uint16_t keycode) {
|
||||
if (keycode == KC_ENTER) {
|
||||
for (int i = 0; i < buffer_size + 1; i++) {
|
||||
tap_code(KC_BSPACE);
|
||||
}
|
||||
for (int i = 0; i < seq_config_size; i++) {
|
||||
seq_t item = seq_config[i];
|
||||
if (strncmp(item.sequence, buffer, buffer_size) == 0) {
|
||||
send_unicode_string(item.result);
|
||||
}
|
||||
}
|
||||
buffer_size = 0;
|
||||
return false;
|
||||
} else if (keycode == KC_BSPACE) {
|
||||
if (buffer_size) {
|
||||
buffer_size--;
|
||||
tap_code(keycode);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (keycode >= KC_A && keycode <= KC_Z) {
|
||||
buffer[buffer_size++] = keycode - KC_A + 'a';
|
||||
tap_code(keycode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
#include "quantum.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
typedef struct seq_t {
|
||||
const char *sequence;
|
||||
const char *result;
|
||||
} seq_t;
|
||||
|
||||
extern seq_t seq_config[];
|
||||
extern uint16_t seq_config_size;
|
||||
|
||||
void seq_start(void);
|
||||
bool seq_feed(uint16_t keycode);
|
||||
@ -0,0 +1,34 @@
|
||||
#include <smoothled.h>
|
||||
|
||||
static uint32_t sourceColor = 0x000000;
|
||||
static uint32_t currentColor = 0x000000;
|
||||
static uint32_t targetColor = 0x000000;
|
||||
static int32_t smoothledTimer = -1;
|
||||
|
||||
void smoothled_set(uint32_t color) {
|
||||
smoothledTimer = timer_read32();
|
||||
sourceColor = currentColor;
|
||||
targetColor = color;
|
||||
}
|
||||
|
||||
void smoothled_process(void) {
|
||||
if (smoothledTimer < 0) {
|
||||
return;
|
||||
}
|
||||
int32_t kb = timer_elapsed32(smoothledTimer);
|
||||
int32_t ka = SMOOTH_DURATION - kb;
|
||||
if (kb > SMOOTH_DURATION) {
|
||||
kb = SMOOTH_DURATION;
|
||||
ka = 0;
|
||||
smoothledTimer = -1;
|
||||
}
|
||||
currentColor = 0;
|
||||
for (int i = 2; i >= 0; i--) {
|
||||
uint32_t shift = i * 8;
|
||||
currentColor |= (ka * ((uint32_t)(sourceColor >> shift) & 0xFF) + kb * ((uint32_t)(targetColor >> shift) & 0xFF)) / SMOOTH_DURATION;
|
||||
/*currentColor |= ((targetColor >> shift) & 0xFF);*/
|
||||
currentColor <<= 8;
|
||||
}
|
||||
currentColor >>= 8;
|
||||
rgblight_setrgb((currentColor >> 16) & 0xFF, (currentColor >> 8) & 0xFF, currentColor & 0xFF);
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
#include "quantum.h"
|
||||
|
||||
#define SMOOTH_DURATION 160
|
||||
|
||||
void smoothled_set(uint32_t color);
|
||||
void smoothled_process(void);
|
||||
Loading…
Reference in New Issue