Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# FILE: keyboard_poll.py
# BRIEF: Polling + debug example for Soldered Inputronic Keyboard (PRESS only)
# LAST UPDATED: 2026-02-11

import time
from machine import I2C, Pin
from os import uname

from inputronic_keyboard import InputronicKeyboard


def make_i2c():
# Match the style from your BMP280 example: auto pins for known boards
if uname().sysname in ("esp32", "esp8266", "Soldered Dasduino CONNECTPLUS"):
return I2C(0, scl=Pin(22), sda=Pin(21))
raise Exception("Board not recognized; create I2C manually and pass it in.")


def main():
print()
print("Soldered Inputronic Keyboard - Polling (PRESS Only)")
print("Press any key to see its position and resolved output.\n")

# Initialize I2C + keyboard
i2c = make_i2c()
try:
kbd = InputronicKeyboard(i2c=i2c)
except Exception as e:
print("Keyboard not found. Check Qwiic/easyC connection.")
print("Error:", e)
while True:
time.sleep_ms(250)

print("Keyboard ready.\n")

while True:
# Process all pending events
while kbd.events_available() > 0:
ev = kbd.read_mapped_event()
if ev is None:
break

is_release, row, col, label = ev

# Ignore release events
if is_release or label is None:
continue

# Resolved printable character (SHIFT handled internally)
ch = kbd.label_to_char(label, apply_shift=True)

# Print press information (similar to Arduino sketch)
# Format: PRESS Row: x Col: y Label: ... Char: 'c' or (n/a)
if ch is not None:
print(
"PRESS\tRow:",
row,
"\tCol:",
col,
"\tLabel:",
label,
"\tChar: '{}'".format(ch),
)
else:
print(
"PRESS\tRow:",
row,
"\tCol:",
col,
"\tLabel:",
label,
"\tChar: (n/a)",
)

time.sleep_ms(1)


# Run
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# FILE: oled_type.py
# BRIEF: Live typing example for Inputronic Keyboard + Soldered SSD1306 (MicroPython)
# LAST UPDATED: 2026-02-11

import time
from inputronic_keyboard import InputronicKeyboard
from ssd1306 import SSD1306

SCREEN_WIDTH = 128
SCREEN_HEIGHT = 64
CHAR_W = 8
CHAR_H = 8
COLS = SCREEN_WIDTH // CHAR_W # 16
ROWS = SCREEN_HEIGHT // CHAR_H # 8


def redraw_oled(display, text):
"""
Redraw screen from text buffer with newline + wrap support.
Keeps last ROWS lines visible (simple terminal viewport).
"""
# Build lines with wrap
lines = []
cur = ""

for ch in text:
if ch == "\n":
lines.append(cur)
cur = ""
continue

cur += ch
if len(cur) >= COLS:
lines.append(cur[:COLS])
cur = cur[COLS:]

lines.append(cur)

# Keep only last visible lines
lines = lines[-ROWS:]

# Draw
display.fill(0)
y = 0
for ln in lines:
# framebuf.text doesn't clip nicely if longer, so clip to COLS
display.text(ln[:COLS], 0, y, 1)
y += CHAR_H
display.show()


def main():
print()
print("Soldered Inputronic Keyboard - OledType Example (MicroPython)")
print(
"SPACE=' ' | BACK=Backspace | ENTER=Newline | CAPS=Toggle Case | SHIFT=Modifier"
)
print()

# Init OLED (your driver auto-inits I2C if not given)
try:
display = SSD1306()
except Exception as e:
print("OLED not found. Check I2C wiring.")
print("Error:", e)
while True:
time.sleep_ms(250)

# Init keyboard (it can share same bus; also auto-inits if not given,
# but better to share I2C explicitly in a combined project)
try:
kbd = InputronicKeyboard(i2c=display.i2c)
except Exception as e:
print("Keyboard not found. Check Qwiic/easyC connection.")
print("Error:", e)
while True:
time.sleep_ms(250)

print("Keyboard and OLED ready. Start typing!\n")

typed = []

redraw_oled(display, "")

while True:
changed = False

while kbd.events_available() > 0:
ev = kbd.read_mapped_event()
if ev is None:
break

is_release, row, col, label = ev
if is_release or label is None:
continue

# SPACE
if label == "SPACE":
typed.append(" ")
changed = True
continue

# BACK
if label == "BACK":
if typed:
typed.pop()
changed = True
continue

# ENTER -> newline
if label == "ENTER":
typed.append("\n")
changed = True
continue

# CAPS / SHIFT ignored (handled internally)
if label == "CAPS" or label == "SHIFT":
continue

# Printable
ch = kbd.label_to_char(label, apply_shift=True)
if ch is not None:
typed.append(ch)
changed = True

if changed:
text = "".join(typed)
redraw_oled(display, text)
print("Typed:", text)

time.sleep_ms(1)


main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# FILE: serial_type.py
# BRIEF: Live typing example for Soldered Inputronic Keyboard (MicroPython)
# LAST UPDATED: 2026-02-11

import time
from machine import I2C, Pin
from os import uname

from inputronic_keyboard import InputronicKeyboard


def make_i2c():
# Auto I2C pins for known boards (same style as other examples)
if uname().sysname in ("esp32", "esp8266", "Soldered Dasduino CONNECTPLUS"):
return I2C(0, scl=Pin(22), sda=Pin(21))
raise Exception("Board not recognized; create I2C manually.")


def main():

print()
print("Soldered Inputronic Keyboard - SerialType (Polling)")
print(
"SPACE=' ' | BACK=Backspace | ENTER=Newline | CAPS=Toggle Case | SHIFT=Modifier"
)
print()

# Init keyboard
i2c = make_i2c()

try:
kbd = InputronicKeyboard(i2c=i2c)
except Exception as e:
print("Keyboard not found. Check Qwiic/easyC connection.")
print("Error:", e)

while True:
time.sleep_ms(250)

print("Keyboard initialized successfully!")
print("Start typing below:\n")

# Main loop
while True:
# Process all pending keyboard events
while kbd.events_available() > 0:
ev = kbd.read_mapped_event()
if ev is None:
break

is_release, row, col, label = ev

# Only key press
if is_release or label is None:
continue

# -----------------------------
# Special keys
# -----------------------------

# Space
if label == "SPACE":
print(" ", end="")
continue

# Backspace (terminal style)
if label == "BACK":
print("\b \b", end="")
continue

# New line
if label == "ENTER":
print()
continue

# CAPS + SHIFT (handled internally)
if label == "CAPS" or label == "SHIFT":
continue

# -----------------------------
# Printable characters
# -----------------------------

ch = kbd.label_to_char(label, apply_shift=True)
if ch is not None:
print(ch, end="")

# Cooperative delay
time.sleep_ms(1)


# Run
main()
Loading