diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b2b33d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.dtsi linguist-language=C++ +*.keymap linguist-language=C++ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f280203 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,5 @@ +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + uses: zmkfirmware/zmk/.github/workflows/build-user-config.yml@main diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f379648 --- /dev/null +++ b/.gitignore @@ -0,0 +1,86 @@ +# zmk +zmk/ + +# sketchybar +sketchybar/dotfiles/ +sketchybar/dotfiles +sketchybar/dotfiles/* + +# MacOS +.DS_Store +vim-tools_notiz.vim +.DS_Store +./*/.DS_Store +.vscode +# .vimspector.json +push.sh +/test +test/ + +# c, cpp +*.x +*.d +*.dSYM +*.o +*.out + +# log +*.log + +# cache +*.cache +cache/ + +# Windows +Thumbs.db +Desktop.ini + +# Tags +#TAGS +#!TAGS/ +#tags +doc/tags +tags-cn +!tags/ +.tags +.tags1 +tags.lock +tags.temp +gtags.files +GTAGS +GRTAGS +GPATH +cscope.files +cscope.out +cscope.in.out +cscope.po.out + +# Vim +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist +*~ + +# Test % Tmp +test.* +tmp.* +temp.* + +# Java +*.class + +# JavaScript +node_modules + +# Python +*.pyc +.idea/ +/.idea +# build/ +__pycache__ + +# Rust +target/ +**/*.rs.bk diff --git a/README.md b/README.md new file mode 100644 index 0000000..30ca401 --- /dev/null +++ b/README.md @@ -0,0 +1,72 @@ +# Oled Adapter +This module is an adapter for 128x32, 128x64 and 128x128 OLED screens, to be +used on keyboards with ZMK without having to modify the shields of the +keyboards. + +Compatible with all boards with pro micro and seeeduino xiao BLE pinout, like +the Nice!Nano, Puchi, clones and others. + +Shields supported: +- oled_adapter_pro_micro_128x32 +- oled_adapter_pro_micro_128x64 +- oled_adapter_pro_micro_128x128 +- oled_adapter_seeeduino_xiao_ble_128x32 +- oled_adapter_seeeduino_xiao_ble_128x64 +- oled_adapter_seeeduino_xiao_ble_128x128 + +[![oled_adapter_example1](src/oled_adapter_example1.jpg)](https://github.com/mctechnology17/zmk-config) +[![oled_adapter_example2](src/oled_adapter_example2.jpg)](https://github.com/mctechnology17/zmk-config) + +# Usage +The following commands demonstrate how to overwrite the default 128x32 screen +with different screen sizes for various setups as an example: + +- **Overwrite the left screen from 128x32 to 128x128:** + ```bash + west build -b nice_nano_v2 -- -DSHIELD="corne_left oled_adapter_pro_micro_128x128" + ``` + +- **Overwrite the right screen from 128x32 to 128x64:** + ```bash + west build -b puchi_ble_v1 -- -DSHIELD="corne_right oled_adapter_pro_micro_128x64" + ``` + +- **Using the Xiao as a dongle with the Corne, replacing the screen with 128x128:** + ```bash + # This example is from a dongle previously configured using a corne + west build -b seeeduino_xiao_ble -- -DSHIELD="corne_dongle_xiao dongle_display oled_adapter_seeeduino_xiao_ble_128x128" + ``` + +# Configuration +To use this module, first add it to your `config/west.yml` by adding a new +entry to `remotes` and `projects`: + +```yaml +manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + - name: mctechnology17 + url-base: https://github.com/mctechnology17 + projects: + - name: zmk + remote: zmkfirmware + revision: main + import: app/west.yml + - name: zmk-config + remote: mctechnology17 + revision: main + self: + path: config +``` + +Now simply indicate in the board and the shield in the `build.yaml` file: + +```yaml +--- +include: + - board: nice_nano_v2 + shield: corne_left oled_adapter_pro_micro_128x128 + - board: puchi_ble_v1 + shield: corne_right oled_adapter_pro_micro_128x64 +``` diff --git a/boards/shields/.gitkeep b/boards/shields/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/boards/shields/oled_adapter/Kconfig.defconfig b/boards/shields/oled_adapter/Kconfig.defconfig new file mode 100644 index 0000000..24b70e4 --- /dev/null +++ b/boards/shields/oled_adapter/Kconfig.defconfig @@ -0,0 +1,16 @@ +# Copyright (c) 2022 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if SHIELD_OLED_ADAPTER_PRO_MICRO_128X32 || SHIELD_OLED_ADAPTER_PRO_MICRO_128X64 || SHIELD_OLED_ADAPTER_PRO_MICRO_128X128 || SHIELD_OLED_ADAPTER_SEEEDUINO_XIAO_BLE_128X32 || SHIELD_OLED_ADAPTER_SEEEDUINO_XIAO_BLE_128X64 || SHIELD_OLED_ADAPTER_SEEEDUINO_XIAO_BLE_128X128 + +if ZMK_DISPLAY + +config I2C + default y + +config SSD1306 + default y + +endif # ZMK_DISPLAY + +endif diff --git a/boards/shields/oled_adapter/Kconfig.shield b/boards/shields/oled_adapter/Kconfig.shield new file mode 100644 index 0000000..c50963a --- /dev/null +++ b/boards/shields/oled_adapter/Kconfig.shield @@ -0,0 +1,20 @@ +# Copyright (c) 2022 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_OLED_ADAPTER_PRO_MICRO_128X32 + def_bool $(shields_list_contains,oled_adapter_pro_micro_128x32) + +config SHIELD_OLED_ADAPTER_PRO_MICRO_128X64 + def_bool $(shields_list_contains,oled_adapter_pro_micro_128x64) + +config SHIELD_OLED_ADAPTER_PRO_MICRO_128X128 + def_bool $(shields_list_contains,oled_adapter_pro_micro_128x128) + +config SHIELD_OLED_ADAPTER_SEEEDUINO_XIAO_BLE_128X32 + def_bool $(shields_list_contains,oled_adapter_seeeduino_xiao_ble_128x32) + +config SHIELD_OLED_ADAPTER_SEEEDUINO_XIAO_BLE_128X64 + def_bool $(shields_list_contains,oled_adapter_seeeduino_xiao_ble_128x64) + +config SHIELD_OLED_ADAPTER_SEEEDUINO_XIAO_BLE_128X128 + def_bool $(shields_list_contains,oled_adapter_seeeduino_xiao_ble_128x128) diff --git a/boards/shields/oled_adapter/README.md b/boards/shields/oled_adapter/README.md new file mode 100644 index 0000000..beb8969 --- /dev/null +++ b/boards/shields/oled_adapter/README.md @@ -0,0 +1,24 @@ +# Oled Adapter + +This module is an adapter for 128x32, 128x64 and 128x128 OLED screens, to be +used on keyboards with ZMK without having to modify the shields of the +keyboards. + +The following commands demonstrate how to overwrite the default 128x32 screen +with different screen sizes for various setups as an example: + +- **Overwrite the left screen from 128x32 to 128x128:** + ```bash + west build -b nice_nano_v2 -- -DSHIELD="corne_left oled_adapter_pro_micro_128x128" + ``` + +- **Overwrite the right screen from 128x32 to 128x64:** + ```bash + west build -b puchi_ble_v1 -- -DSHIELD="corne_right oled_adapter_pro_micro_128x64" + ``` + +- **Using the Xiao as a dongle with the Corne, replacing the screen with 128x128:** + ```bash + # This example is from a dongle previously configured using a corne + west build -b seeeduino_xiao_ble -- -DSHIELD="corne_dongle_xiao dongle_display oled_adapter_seeeduino_xiao_ble_128x128" + ``` diff --git a/boards/shields/oled_adapter/oled_adapter.zmk.yml b/boards/shields/oled_adapter/oled_adapter.zmk.yml new file mode 100644 index 0000000..fe3f976 --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter.zmk.yml @@ -0,0 +1,15 @@ +file_format: "1" +id: oled_adapter +name: oled adapter +type: shield +url: https://github.com/mctechnology17/oled_adapter +exposes: [i2c_oled] +features: + - display +siblings: + - oled_adapter_pro_micro_128x32 + - oled_adapter_pro_micro_128x64 + - oled_adapter_pro_micro_128x128 + - oled_adapter_seeeduino_xiao_ble_128x32 + - oled_adapter_seeeduino_xiao_ble_128x64 + - oled_adapter_seeeduino_xiao_ble_128x128 diff --git a/boards/shields/oled_adapter/oled_adapter_pro_micro_128x128.conf b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x128.conf new file mode 100644 index 0000000..a0d1b7d --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x128.conf @@ -0,0 +1 @@ +CONFIG_ZMK_DISPLAY=y diff --git a/boards/shields/oled_adapter/oled_adapter_pro_micro_128x128.overlay b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x128.overlay new file mode 100644 index 0000000..33b1e20 --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x128.overlay @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +/delete-node/ &oled; + +&pro_micro_i2c { + status = "okay"; + oled_128x128: sh1106@3c { + compatible = "sinowealth,sh1106"; + reg = <0x3c>; + width = <120>; + height = <128>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <119>; + segment-remap; + com-invdir; + inversion-on; + prechargep = <0x22>; + }; +}; + +/ { + chosen { + zephyr,display = &oled_128x128; + }; +}; +// vim: filetype=dts fdm=marker: diff --git a/boards/shields/oled_adapter/oled_adapter_pro_micro_128x32.conf b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x32.conf new file mode 100644 index 0000000..a0d1b7d --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x32.conf @@ -0,0 +1 @@ +CONFIG_ZMK_DISPLAY=y diff --git a/boards/shields/oled_adapter/oled_adapter_pro_micro_128x32.overlay b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x32.overlay new file mode 100644 index 0000000..7b19989 --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x32.overlay @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +/delete-node/ &oled; + +&pro_micro_i2c { + status = "okay"; + + oled_128x32: ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + width = <128>; + height = <32>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <31>; + segment-remap; + com-invdir; + com-sequential; + inversion-on; + prechargep = <0x22>; + }; +}; + +/ { + chosen { + zephyr,display = &oled_128x32; + }; +}; +// vim: filetype=dts fdm=marker: diff --git a/boards/shields/oled_adapter/oled_adapter_pro_micro_128x64.conf b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x64.conf new file mode 100644 index 0000000..a0d1b7d --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x64.conf @@ -0,0 +1 @@ +CONFIG_ZMK_DISPLAY=y diff --git a/boards/shields/oled_adapter/oled_adapter_pro_micro_128x64.overlay b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x64.overlay new file mode 100644 index 0000000..fde8c10 --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_pro_micro_128x64.overlay @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ +/delete-node/ &oled; + +&pro_micro_i2c { + status = "okay"; + + oled_128x64: ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + width = <128>; + height = <64>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <63>; + segment-remap; + com-invdir; + inversion-on; + prechargep = <0x22>; + }; +}; + +/ { + chosen { + zephyr,display = &oled_128x64; + }; +}; +// vim: filetype=dts fdm=marker: diff --git a/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x128.conf b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x128.conf new file mode 100644 index 0000000..a0d1b7d --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x128.conf @@ -0,0 +1 @@ +CONFIG_ZMK_DISPLAY=y diff --git a/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x128.overlay b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x128.overlay new file mode 100644 index 0000000..e94b51d --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x128.overlay @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ +/delete-node/ &oled; + +&xiao_i2c { + status = "okay"; + oled_128x128: sh1106@3c { + compatible = "sinowealth,sh1106"; + reg = <0x3c>; + width = <120>; + height = <128>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <119>; + segment-remap; + com-invdir; + inversion-on; + prechargep = <0x22>; + }; +}; + +/ { + chosen { + zephyr,display = &oled_128x128; + }; +}; +// vim: filetype=dts fdm=marker: diff --git a/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x32.conf b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x32.conf new file mode 100644 index 0000000..a0d1b7d --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x32.conf @@ -0,0 +1 @@ +CONFIG_ZMK_DISPLAY=y diff --git a/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x32.overlay b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x32.overlay new file mode 100644 index 0000000..3c1cec9 --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x32.overlay @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ +/delete-node/ &oled; + +&xiao_i2c { + status = "okay"; + + oled_128x32: ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + width = <128>; + height = <32>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <31>; + segment-remap; + com-invdir; + com-sequential; + inversion-on; + prechargep = <0x22>; + }; +}; + +/ { + chosen { + zephyr,display = &oled_128x32; + }; +}; +// vim: filetype=dts fdm=marker: diff --git a/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x64.conf b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x64.conf new file mode 100644 index 0000000..a0d1b7d --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x64.conf @@ -0,0 +1 @@ +CONFIG_ZMK_DISPLAY=y diff --git a/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x64.overlay b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x64.overlay new file mode 100644 index 0000000..a63bd6c --- /dev/null +++ b/boards/shields/oled_adapter/oled_adapter_seeeduino_xiao_ble_128x64.overlay @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ +/delete-node/ &oled; + +&xiao_i2c { + status = "okay"; + + oled_128x64: ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + width = <128>; + height = <64>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <63>; + segment-remap; + com-invdir; + inversion-on; + prechargep = <0x22>; + }; +}; + +/ { + chosen { + zephyr,display = &oled_128x64; + }; +}; +// vim: filetype=dts fdm=marker: diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..6185508 --- /dev/null +++ b/build.yaml @@ -0,0 +1,6 @@ +--- +include: + - board: nice_nano_v2 + shield: corne_left oled_adapter_pro_micro_128x128 + - board: puchi_ble_v1 + shield: corne_right oled_adapter_pro_micro_128x64 diff --git a/config/west.yml b/config/west.yml new file mode 100644 index 0000000..1e5d479 --- /dev/null +++ b/config/west.yml @@ -0,0 +1,16 @@ +manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + - name: mctechnology17 + url-base: https://github.com/mctechnology17 + projects: + - name: zmk + remote: zmkfirmware + revision: main + import: app/west.yml + - name: zmk-config + remote: mctechnology17 + revision: main + self: + path: config diff --git a/src/oled_adapter_example1.jpg b/src/oled_adapter_example1.jpg new file mode 100644 index 0000000..e8d5481 Binary files /dev/null and b/src/oled_adapter_example1.jpg differ diff --git a/src/oled_adapter_example2.jpg b/src/oled_adapter_example2.jpg new file mode 100644 index 0000000..230d131 Binary files /dev/null and b/src/oled_adapter_example2.jpg differ diff --git a/zephyr/module.yml b/zephyr/module.yml new file mode 100644 index 0000000..c975871 --- /dev/null +++ b/zephyr/module.yml @@ -0,0 +1,3 @@ +build: + settings: + board_root: .