Skip to content

Instantly share code, notes, and snippets.

@thomasmacpherson
Last active December 29, 2015 08:29
Show Gist options
  • Save thomasmacpherson/7643591 to your computer and use it in GitHub Desktop.
Save thomasmacpherson/7643591 to your computer and use it in GitHub Desktop.
PiFace Control And Display Doctor Who anniversary message.
import pifacecad
cad = pifacecad.PiFaceCAD()
cad.lcd.backlight_on()
# the bit map for the 4 characters that make up the tardis, in hex
tardis0 = pifacecad.LCDBitmap([0x1, 0x7, 0xF, 0xF, 0x9, 0x9, 0x9, 0xF])
tardis1 = pifacecad.LCDBitmap([0x10, 0x1c, 0x1e, 0x1e, 0x12, 0x12, 0x12, 0x1e])
tardis2 = pifacecad.LCDBitmap([0xf, 0x9, 0x9, 0x9, 0xf, 0xf, 0xf, 0x1f])
tardis3 = pifacecad.LCDBitmap([0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1f])
# the bit map for the 4 characters that make up the dalek, in binary
dalek0 = pifacecad.LCDBitmap([ 0b00000,
0b00000,
0b00001,
0b00011,
0b00011,
0b01111,
0b00011,
0b00011])
dalek2 = pifacecad.LCDBitmap([ 0b10011,
0b11111,
0b10011,
0b00011,
0b00011,
0b00111,
0b01111,
0b11111])
dalek1 = pifacecad.LCDBitmap([ 0b00000,
0b00000,
0b10000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000])
dalek3 = pifacecad.LCDBitmap([ 0b11000,
0b11100,
0b11100,
0b11100,
0b11110,
0b11110,
0b11110,
0b11111])
# storing the bitmaps to LCD memory
cad.lcd.store_custom_bitmap(0, tardis0)
cad.lcd.store_custom_bitmap(1, tardis1)
cad.lcd.store_custom_bitmap(2, tardis2)
cad.lcd.store_custom_bitmap(3, tardis3)
cad.lcd.store_custom_bitmap(4, dalek0)
cad.lcd.store_custom_bitmap(5, dalek1)
cad.lcd.store_custom_bitmap(6, dalek2)
cad.lcd.store_custom_bitmap(7, dalek3)
# draw the tardis
cad.lcd.write_custom_bitmap(0)
cad.lcd.write_custom_bitmap(1)
cad.lcd.set_cursor(0,1)
cad.lcd.write_custom_bitmap(2)
cad.lcd.write_custom_bitmap(3)
cad.lcd.set_cursor(2,1)
cad.lcd.write("EXTERMINATE!")
# draw the dalek at the far end of the screen
cad.lcd.set_cursor(14,0)
cad.lcd.write_custom_bitmap(4)
cad.lcd.write_custom_bitmap(5)
cad.lcd.set_cursor(14,1)
cad.lcd.write_custom_bitmap(6)
cad.lcd.write_custom_bitmap(7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment