Skip to content

Instantly share code, notes, and snippets.

@joeycastillo
Created November 2, 2024 23:09
Show Gist options
  • Save joeycastillo/a617c949258fae4e5e333eaeb06b102a to your computer and use it in GitHub Desktop.
Save joeycastillo/a617c949258fae4e5e333eaeb06b102a to your computer and use it in GitHub Desktop.
from machine import Pin, I2C
import time
display_i2c = i2c1 # right side I2C, replace with i2c0 for left side
CHARS = (
0b00000000, # [space]
0b00000000, # !
0b01001000, # "
0b11001100, # # (°)
0b01100111, # $ (Like an L with an extra segment, use $J to make a W)
0b01000010, # %
0b11101000, # & (Like an F without a cross stroke, use &7 to make an M)
0b00001000, # '
0b11100001, # (
0b10001011, # )
0b00000000, # * (Currently unused)
0b00001110, # +
0b00000010, # ,
0b00000100, # -
0b00010000, # .
0b00101100, # /
0b11101011, # 0
0b00001010, # 1
0b10101101, # 2
0b10001111, # 3
0b01001110, # 4
0b11000111, # 5
0b11100111, # 6
0b11001010, # 7
0b11101111, # 8
0b11001111, # 9
0b00000000, # : (currently unused)
0b01000000, # ; (Like the apostrophe, but on the other side, use 'foo; to say ‘foo’)
0b00100001, # <
0b00000101, # =
0b00100001, # >
0b00000000, # ?
0b11111111, # @
0b11101110, # A
0b01100111, # B
0b00100101, # C
0b00101111, # D
0b11100101, # E
0b11100100, # F
0b11100011, # G
0b01100110, # H
0b01100000, # I
0b00101011, # J
0b11100110, # K
0b01100001, # L
0b11101010, # M
0b00100110, # N
0b00100111, # O
0b11101100, # P
0b11001110, # Q
0b00100100, # R
0b11000011, # S
0b01100101, # T
0b00100011, # U
0b01101011, # V
0b01101111, # W
0b01101110, # X
0b01001111, # Y
0b10101001, # Z
)
def display(value) -> None:
buf = [0]
value = value.upper()
for c in value:
b = CHARS[ord(c) - 32]
buf.append(b)
display_i2c.writeto(0x3E, bytes(buf))
# initialize the display
display_i2c.writeto(0x3E, bytes([0xC8]))
# Hack the planet!
while True:
display(" XA(K ")
time.sleep(0.75)
display(" TXE ")
time.sleep(0.75)
display("PLAMET")
time.sleep(1.5)
display(" ")
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment