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 all 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
87 changes: 87 additions & 0 deletions keyboards/handwired/d48/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# 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 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

![D48 pinout](https://imgur.com/QoStCvD.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.

## 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).
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!
77 changes: 77 additions & 0 deletions keyboards/handwired/d48/config.h
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions keyboards/handwired/d48/d48.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "d48.h"
19 changes: 19 additions & 0 deletions keyboards/handwired/d48/d48.h
Original file line number Diff line number Diff line change
@@ -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 } \
}
21 changes: 21 additions & 0 deletions keyboards/handwired/d48/ds1307.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "ds1307.h"
#include "i2c_master.h"

and3rson marked this conversation as resolved.
Show resolved Hide resolved
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;
}
6 changes: 6 additions & 0 deletions keyboards/handwired/d48/ds1307.h
Original file line number Diff line number Diff line change
@@ -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);
Loading