Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jtornero/03b41524410ebf7e2dbc6dd2ab43e602 to your computer and use it in GitHub Desktop.
Save jtornero/03b41524410ebf7e2dbc6dd2ab43e602 to your computer and use it in GitHub Desktop.
Circuitpython keyboard with telnet and beep - PSEUDOCODE
# We create a keypad, connect to wifi, etc.
# Function to make a buzzer in pin whatever_pin beep
async beep():
whatever_pin.on()
await.sleep(sometime)
whatever_pin.off()
async double_beep():
whatever_pin.on()
await.sleep(sometime)
whatever_pin.off()
await.sleep(sometime)
whatever_pin.on()
await.sleep(sometime)
whatever_pin.off()
# Function to handle telnet connections
async handle_telnet(client_socket):
while True:
DETECT KEYPAD EVENTS
if CERTAIN EVENT:
await beep()
do_whatever
elif OTHER EVENT:
await.souble_beep()
do whatever
# Configuring telnet server socket (with socketpool)
# Main function
async def main():
while True:
client_socket, client_address = telnet_socket.accept()
print("Client connected from:", client_address)
tarea_teclado = asyncio.create_task(handle_telnet(client_socket))
tarea_singlebeep = asyncio.create_task(beep())
await asyncio.gather(tarea_teclado, beep, double_beep)
client_socket.close()
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment