Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Keyboard] Added D48 keyboard. #8548

Merged
merged 26 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cb79a47
[Keyboard] Added D48 keyboard.
and3rson Mar 24, 2020
e89d1de
Updated README.
and3rson Mar 24, 2020
bee34b7
Cleanups.
and3rson Mar 24, 2020
04a327a
Moved d48 to handwired/
and3rson Mar 24, 2020
4f052e5
Added link to build process album.
and3rson Mar 24, 2020
5b49678
Coding conventions cleanups.
and3rson Mar 24, 2020
577bca3
Added DS1307 RTC!
and3rson Mar 25, 2020
93cd115
Minor cleanups.
and3rson Mar 25, 2020
b749824
Apply suggestions from code review
and3rson Mar 26, 2020
7fd428f
Minor refactoring.
and3rson Mar 26, 2020
d14d1ac
Readme fix.
and3rson Mar 26, 2020
8e17bab
Moved leftover keymap-specific code from keyboard space into keymap.
and3rson Mar 26, 2020
ff2e782
Added encoder button pins to extra matrix row.
and3rson Mar 26, 2020
003b8b2
Updated README, updated pinout & cleaned up the glcdfont
and3rson Apr 1, 2020
421c5a0
Apply suggestions from code review
and3rson Apr 5, 2020
50b2aad
Update config.h
and3rson Apr 5, 2020
ff73a48
Merge remote-tracking branch 'upstream/master' into d48
and3rson Apr 12, 2020
67980be
Apply suggestions from code review
and3rson Apr 12, 2020
d4719b4
Merge branch 'd48' of github.com:and3rson/qmk_firmware into d48
and3rson Apr 12, 2020
d788d05
Added default keymap. Refactored existing keymap.
and3rson Apr 12, 2020
1d5e207
Update keyboards/handwired/d48/README.md
and3rson Apr 12, 2020
ce2dd23
Apply suggestions from code review
and3rson Apr 12, 2020
45a4c5b
Minor alignment fix.
and3rson Apr 12, 2020
583a192
Update keyboards/handwired/d48/glcdfont_d48.c
and3rson Apr 28, 2020
d2977e6
Changes as per PR.
and3rson Apr 28, 2020
eb1924f
Apply suggestions from code review
and3rson May 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions keyboards/handwired/d48/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# D48

![Proton C based handwired 40% keyboard](https://i.imgur.com/2wCYuno.jpg)

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 d48:anderson:dfu-util

## 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

![D48 pinout](https://imgur.com/LgHDQUU.jpg)

## 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.

## 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).
and3rson marked this conversation as resolved.
Show resolved Hide resolved

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!
87 changes: 87 additions & 0 deletions keyboards/handwired/d48/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#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
#define DESCRIPTION Proton C based 12x4 ortholinear keyboard with 2 encoders, 128x32 OLED display, WS2812 strip & a buzzer
drashna marked this conversation as resolved.
Show resolved Hide resolved

/* Key matrix size */
#define MATRIX_ROWS 4
#define MATRIX_COLS 12

/* Key matrix pins */
#define MATRIX_ROW_PINS { \
B9, B1, B2, B4 \
}

#define MATRIX_COL_PINS { \
A2, B0, A7, A8, \
A13, A14, B12, B11, \
B10, B15, B14, B13 \
}
and3rson marked this conversation as resolved.
Show resolved Hide resolved
#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)

/* Custom light modes switcher */
#define LIGHTMODE_ENABLE

/* DS1307 */
#define DS1307_ADDR (0x68 << 1)
46 changes: 46 additions & 0 deletions keyboards/handwired/d48/d48.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "d48.h"
#include "smoothled.h"
#include "dmc12.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
39 changes: 39 additions & 0 deletions keyboards/handwired/d48/d48.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include "quantum.h"

#define LAYOUT( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, 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 \
) { \
{ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, 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 } \
}

/* Used to create a keymap using only KC_ prefixed keys */

#define LAYOUT_kc( \
L00, L01, L02, L03, L04, L05, L06, L07, L08, L09, L0A, L0B, \
L10, L11, L12, L13, L14, L15, L16, L17, L18, L19, L1A, L1B, \
L20, L21, L22, L23, L24, L25, L26, L27, L28, L29, L2A, L2B, \
L30, L31, L32, L33, L34, L35, L36, L37, L38, L39, L3A, L3B \
) \
LAYOUT( \
KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##L06, KC_##L07, KC_##L08, KC_##L09, KC_##L0A, KC_##L0B, \
KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##L16, KC_##L17, KC_##L18, KC_##L19, KC_##L1A, KC_##L1B, \
KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##L26, KC_##L27, KC_##L28, KC_##L29, KC_##L2A, KC_##L2B, \
KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##L36, KC_##L37, KC_##L38, KC_##L39, KC_##L3A, KC_##L3B \
)

/* 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);
Loading