Skip to content

update example to check for raspberry pi #3

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

Merged
merged 3 commits into from
Jun 11, 2024
Merged
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
13 changes: 11 additions & 2 deletions examples/ch9328_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@

import time
import board
import busio
from adafruit_ch9328.ch9328 import Adafruit_CH9328
from adafruit_ch9328.ch9328_keymap import Keymap

# Initialize UART for the CH9328
uart = busio.UART(board.TX, board.RX, baudrate=9600)
# check for Raspberry Pi
# pylint: disable=simplifiable-condition
if "CE0" and "CE1" in dir(board):
import serial

uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=3000)
# otherwise use busio
else:
import busio

uart = busio.UART(board.TX, board.RX, baudrate=9600)
ch9328 = Adafruit_CH9328(uart)

# Wait for 2 seconds
Expand Down
Loading