From aeebb9ea40de51ef8d28d47e3dcc28b90956a597 Mon Sep 17 00:00:00 2001 From: Leon Anavi Date: Fri, 10 Jan 2025 10:04:40 +0200 Subject: [PATCH] ANAVI Knobs 3: Support SSD1306 I2C OLED Display (#1070) * boards/anavi/knobs3/code.py: Add display Add a new feature to support a mini OLED I2C SSD1306 display. Signed-off-by: Leon Anavi * boards/anavi/knobs3/README.md: Display Add information about the Display extension for ANAVI Knobs 3. Signed-off-by: Leon Anavi --------- Signed-off-by: Leon Anavi --- boards/anavi/knobs3/README.md | 1 + boards/anavi/knobs3/code.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/boards/anavi/knobs3/README.md b/boards/anavi/knobs3/README.md index b961a740c..15e3ec92a 100644 --- a/boards/anavi/knobs3/README.md +++ b/boards/anavi/knobs3/README.md @@ -8,3 +8,4 @@ Extensions enabled by default: - [Encoder](/docs/en/encoder.md) Twist control for all the things - [RGB](/docs/en/rgb.md) Light it up (for underlighting) - [MediaKeys](/docs/en/media_keys.md) Control volume and other media functions +- [Display](/docs/en/Display.md) Show information on the mini OLED display \ No newline at end of file diff --git a/boards/anavi/knobs3/code.py b/boards/anavi/knobs3/code.py index b3ca3983a..c395534fd 100644 --- a/boards/anavi/knobs3/code.py +++ b/boards/anavi/knobs3/code.py @@ -1,5 +1,7 @@ import board +from kmk.extensions.display import Display, TextEntry +from kmk.extensions.display.ssd1306 import SSD1306 from kmk.extensions.media_keys import MediaKeys from kmk.extensions.RGB import RGB, AnimationModes from kmk.keys import KC @@ -8,6 +10,20 @@ from kmk.scanners.keypad import KeysScanner knob = KMKKeyboard() + +# I2C pins for the mini OLED display +knob.SCL = board.D5 +knob.SDA = board.D4 + +display = Display( + display=SSD1306(sda=board.D4, scl=board.D5), + entries=[ + TextEntry(text='ANAVI Knobs 3\n\nKMK Firmware'), + ], + height=64, +) +knob.extensions.append(display) + knob.matrix = KeysScanner([], value_when_pressed=False) media_keys = MediaKeys() @@ -26,8 +42,6 @@ ) knob.modules.append(encoder_handler) -print('ANAVI Knobs 3') - rgb = RGB( pixel_pin=board.NEOPIXEL, num_pixels=1,