Skip to content

Instantly share code, notes, and snippets.

@graeme-winter
Created April 8, 2021 07:41
Show Gist options
  • Save graeme-winter/ff08123ceae76399791413f2564eecaa to your computer and use it in GitHub Desktop.
Save graeme-winter/ff08123ceae76399791413f2564eecaa to your computer and use it in GitHub Desktop.
Hello, world! on a Pimoroni pico scroll, using show_bitmap_1d() method (includes full character set definition)
# generate 5x7 font bitmap as 5 bytes / char
#
# (C) Graeme Winter, 2021
#
# Encoding: each column of 7 bits is encoded top down with LSB as top ->
# horizontal line across the top is 0x01 0x01 0x01 0x01 0x01, vertical line
# on left side of box only would be 0x7f 0x00 0x00 0x00 0x00.
__bitmap = {
0x0: (0x0, 0x0, 0x0, 0x0, 0x0),
0x1: (0x0, 0x0, 0x0, 0x0, 0x0),
0x2: (0x0, 0x0, 0x0, 0x0, 0x0),
0x3: (0x0, 0x0, 0x0, 0x0, 0x0),
0x4: (0x0, 0x0, 0x0, 0x0, 0x0),
0x5: (0x0, 0x0, 0x0, 0x0, 0x0),
0x6: (0x0, 0x0, 0x0, 0x0, 0x0),
0x7: (0x0, 0x0, 0x0, 0x0, 0x0),
0x8: (0x0, 0x0, 0x0, 0x0, 0x0),
0x9: (0x0, 0x0, 0x0, 0x0, 0x0),
0xA: (0x0, 0x0, 0x0, 0x0, 0x0),
0xB: (0x0, 0x0, 0x0, 0x0, 0x0),
0xC: (0x0, 0x0, 0x0, 0x0, 0x0),
0xD: (0x0, 0x0, 0x0, 0x0, 0x0),
0xE: (0x0, 0x0, 0x0, 0x0, 0x0),
0xF: (0x0, 0x0, 0x0, 0x0, 0x0),
0x10: (0x7F, 0x0, 0x0, 0x0, 0x0),
0x11: (0x7F, 0x7F, 0x0, 0x0, 0x0),
0x12: (0x7F, 0x7F, 0x7F, 0x0, 0x0),
0x13: (0x7F, 0x7F, 0x7F, 0x7F, 0x0),
0x14: (0x7F, 0x7F, 0x7F, 0x7F, 0x7F),
0x15: (0x0, 0x7F, 0x7F, 0x7F, 0x7F),
0x16: (0x0, 0x0, 0x7F, 0x7F, 0x7F),
0x17: (0x0, 0x0, 0x0, 0x7F, 0x7F),
0x18: (0x0, 0x0, 0x0, 0x0, 0x7F),
0x19: (0x3, 0x7, 0x7E, 0x20, 0x1E),
0x1A: (0x60, 0x60, 0x6, 0x9, 0x9),
0x1B: (0x60, 0x6F, 0xA, 0xA, 0x8),
0x1C: (0x10, 0x18, 0x1C, 0x18, 0x10),
0x1D: (0x0, 0x3E, 0x1C, 0x8, 0x0),
0x1E: (0x0, 0x8, 0x1C, 0x3E, 0x0),
0x1F: (0x4, 0xC, 0x1C, 0xC, 0x4),
0x20: (0x0, 0x0, 0x0, 0x0, 0x0),
0x21: (0x0, 0x0, 0x7D, 0x0, 0x0),
0x22: (0x0, 0x70, 0x0, 0x70, 0x0),
0x23: (0x14, 0x7F, 0x14, 0x7F, 0x14),
0x24: (0x12, 0x2A, 0x7F, 0x2A, 0x24),
0x25: (0x62, 0x64, 0x8, 0x13, 0x23),
0x26: (0x36, 0x49, 0x55, 0x22, 0x5),
0x27: (0x0, 0x50, 0x60, 0x0, 0x0),
0x28: (0x0, 0x1C, 0x22, 0x41, 0x0),
0x29: (0x0, 0x41, 0x22, 0x1C, 0x0),
0x2A: (0x8, 0x2A, 0x1C, 0x2A, 0x8),
0x2B: (0x8, 0x8, 0x3E, 0x8, 0x8),
0x2C: (0x0, 0x5, 0x6, 0x0, 0x0),
0x2D: (0x8, 0x8, 0x8, 0x8, 0x8),
0x2E: (0x0, 0x3, 0x3, 0x0, 0x0),
0x2F: (0x2, 0x4, 0x8, 0x10, 0x20),
0x30: (0x3E, 0x45, 0x49, 0x51, 0x3E),
0x31: (0x0, 0x21, 0x7F, 0x1, 0x0),
0x32: (0x21, 0x43, 0x45, 0x49, 0x31),
0x33: (0x42, 0x41, 0x51, 0x69, 0x46),
0x34: (0xC, 0x14, 0x24, 0x7F, 0x4),
0x35: (0x72, 0x51, 0x51, 0x51, 0x4E),
0x36: (0x1E, 0x29, 0x49, 0x49, 0x6),
0x37: (0x40, 0x47, 0x48, 0x50, 0x60),
0x38: (0x36, 0x49, 0x49, 0x49, 0x36),
0x39: (0x30, 0x49, 0x49, 0x4A, 0x3C),
0x3A: (0x0, 0x36, 0x36, 0x0, 0x0),
0x3B: (0x0, 0x35, 0x36, 0x0, 0x0),
0x3C: (0x0, 0x8, 0x14, 0x22, 0x41),
0x3D: (0x14, 0x14, 0x14, 0x14, 0x14),
0x3E: (0x41, 0x22, 0x14, 0x8, 0x0),
0x3F: (0x20, 0x40, 0x45, 0x48, 0x30),
0x40: (0x26, 0x49, 0x4F, 0x41, 0x3E),
0x41: (0x3F, 0x44, 0x44, 0x44, 0x3F),
0x42: (0x7F, 0x49, 0x49, 0x49, 0x36),
0x43: (0x3E, 0x41, 0x41, 0x41, 0x22),
0x44: (0x7F, 0x41, 0x41, 0x22, 0x1C),
0x45: (0x7F, 0x49, 0x49, 0x49, 0x41),
0x46: (0x7F, 0x48, 0x48, 0x40, 0x40),
0x47: (0x3E, 0x41, 0x41, 0x45, 0x26),
0x48: (0x7F, 0x8, 0x8, 0x8, 0x7F),
0x49: (0x0, 0x41, 0x7F, 0x41, 0x0),
0x4A: (0x2, 0x1, 0x41, 0x7E, 0x40),
0x4B: (0x7F, 0x8, 0x14, 0x22, 0x41),
0x4C: (0x7F, 0x1, 0x1, 0x1, 0x1),
0x4D: (0x7F, 0x20, 0x10, 0x20, 0x7F),
0x4E: (0x7F, 0x10, 0x8, 0x4, 0x7F),
0x4F: (0x3E, 0x41, 0x41, 0x41, 0x3E),
0x50: (0x7F, 0x48, 0x48, 0x48, 0x30),
0x51: (0x3E, 0x41, 0x45, 0x42, 0x3D),
0x52: (0x7F, 0x48, 0x4C, 0x4A, 0x31),
0x53: (0x31, 0x49, 0x49, 0x49, 0x46),
0x54: (0x40, 0x40, 0x7F, 0x40, 0x40),
0x55: (0x7E, 0x1, 0x1, 0x1, 0x7E),
0x56: (0x7C, 0x2, 0x1, 0x2, 0x7C),
0x57: (0x7F, 0x2, 0xC, 0x2, 0x7F),
0x58: (0x63, 0x14, 0x8, 0x14, 0x63),
0x59: (0x60, 0x10, 0xF, 0x10, 0x60),
0x5A: (0x43, 0x45, 0x49, 0x51, 0x61),
0x5B: (0x0, 0x0, 0x7F, 0x41, 0x41),
0x5C: (0x20, 0x10, 0x8, 0x4, 0x2),
0x5D: (0x41, 0x41, 0x7F, 0x0, 0x0),
0x5E: (0x10, 0x20, 0x40, 0x20, 0x10),
0x5F: (0x1, 0x1, 0x1, 0x1, 0x1),
0x60: (0x0, 0x40, 0x20, 0x10, 0x0),
0x61: (0x2, 0x15, 0x15, 0x15, 0xF),
0x62: (0x7F, 0x9, 0x11, 0x11, 0xE),
0x63: (0xE, 0x11, 0x11, 0x11, 0x2),
0x64: (0xE, 0x11, 0x11, 0x9, 0x7F),
0x65: (0xE, 0x15, 0x15, 0x15, 0xC),
0x66: (0x8, 0x3F, 0x48, 0x40, 0x20),
0x67: (0x8, 0x14, 0x15, 0x15, 0x1E),
0x68: (0x7F, 0x8, 0x10, 0x10, 0xF),
0x69: (0x0, 0x11, 0x5F, 0x1, 0x0),
0x6A: (0x2, 0x1, 0x11, 0x5E, 0x0),
0x6B: (0x0, 0x7F, 0x4, 0xA, 0x11),
0x6C: (0x0, 0x41, 0x7F, 0x1, 0x0),
0x6D: (0x1F, 0x10, 0xC, 0x10, 0xF),
0x6E: (0x1F, 0x8, 0x10, 0x10, 0xF),
0x6F: (0xE, 0x11, 0x11, 0x11, 0xE),
0x70: (0x1F, 0x14, 0x14, 0x14, 0x8),
0x71: (0x8, 0x14, 0x14, 0xC, 0x1F),
0x72: (0x1F, 0x8, 0x10, 0x10, 0x8),
0x73: (0x9, 0x15, 0x15, 0x15, 0x2),
0x74: (0x10, 0x7E, 0x11, 0x1, 0x2),
0x75: (0x1E, 0x1, 0x1, 0x2, 0x1F),
0x76: (0x1C, 0x2, 0x1, 0x2, 0x1C),
0x77: (0x1E, 0x1, 0x6, 0x1, 0x1E),
0x78: (0x11, 0xA, 0x4, 0xA, 0x11),
0x79: (0x18, 0x5, 0x5, 0x5, 0x1E),
0x7A: (0x11, 0x13, 0x15, 0x19, 0x11),
0x7B: (0x0, 0x8, 0x36, 0x41, 0x0),
0x7C: (0x0, 0x0, 0x7F, 0x0, 0x0),
0x7D: (0x0, 0x41, 0x36, 0x8, 0x0),
0x7E: (0x8, 0x8, 0x2A, 0x1C, 0x8),
0x7F: (0x8, 0x1C, 0x2A, 0x8, 0x8),
0x80: (0x7, 0x4A, 0x12, 0x4A, 0x7),
0x81: (0x7, 0xA, 0x52, 0xA, 0x7),
0x82: (0x7, 0x2A, 0x52, 0x2A, 0x7),
0x83: (0x2, 0x15, 0x35, 0x55, 0xF),
0x84: (0x2, 0x15, 0x55, 0x15, 0xF),
0x85: (0x7F, 0x7F, 0x49, 0x49, 0x49),
0x86: (0x5E, 0x21, 0x21, 0x21, 0x5E),
0x87: (0x6, 0x29, 0x9, 0x29, 0x6),
0x88: (0x1D, 0x26, 0x2A, 0x32, 0x5C),
0x89: (0xC, 0x13, 0x1E, 0x32, 0xC),
0x8A: (0x5E, 0x1, 0x1, 0x1, 0x5E),
0x8B: (0xE, 0x21, 0x1, 0x22, 0xF),
0x8C: (0x54, 0x34, 0x1F, 0x34, 0x54),
0x8D: (0x15, 0x16, 0x1C, 0x34, 0x54),
0x8E: (0xC, 0x10, 0xC, 0x2, 0xC),
0x8F: (0x29, 0x55, 0x55, 0x55, 0x4A),
0x90: (0x3F, 0x48, 0x7F, 0x48, 0x48),
0x91: (0x16, 0x15, 0xE, 0x15, 0xD),
0x92: (0x9, 0x3F, 0x49, 0x49, 0x21),
0x93: (0x7F, 0x50, 0x54, 0x2F, 0x5),
0x94: (0x1C, 0x3E, 0x3E, 0x3E, 0x1C),
0x95: (0x1C, 0x22, 0x22, 0x22, 0x1C),
0x96: (0x8, 0x1C, 0x3E, 0x1C, 0x8),
0x97: (0x8, 0x14, 0x22, 0x14, 0x8),
0x98: (0x0, 0x0, 0x77, 0x0, 0x0),
0x99: (0x38, 0x45, 0x46, 0x44, 0x44),
0x9A: (0x3, 0x5, 0x9, 0x11, 0x3F),
0x9B: (0x1, 0x11, 0x29, 0x45, 0x1),
0x9C: (0x1, 0x45, 0x29, 0x11, 0x1),
0x9D: (0x4, 0xE, 0x15, 0x4, 0x7C),
0x9E: (0x10, 0x20, 0x7F, 0x20, 0x10),
0x9F: (0x4, 0x2, 0x7F, 0x2, 0x4),
0xA0: (0x0, 0x0, 0x0, 0x0, 0x0),
0xA1: (0x7, 0x5, 0x7, 0x0, 0x0),
0xA2: (0x0, 0x0, 0x78, 0x40, 0x40),
0xA3: (0x1, 0x1, 0xF, 0x0, 0x0),
0xA4: (0x4, 0x2, 0x1, 0x0, 0x0),
0xA5: (0x0, 0x6, 0x6, 0x0, 0x0),
0xA6: (0x50, 0x50, 0x51, 0x52, 0x7C),
0xA7: (0x0, 0x0, 0x0, 0x0, 0x0),
0xA8: (0x10, 0x11, 0x16, 0x14, 0x18),
0xA9: (0x2, 0x4, 0xF, 0x10, 0x0),
0xAA: (0xC, 0x8, 0x19, 0xE, 0x0),
0xAB: (0x9, 0xA, 0xC, 0x1F, 0x8),
0xAC: (0x8, 0x1F, 0x8, 0xA, 0xC),
0xAD: (0x1, 0x9, 0x9, 0xF, 0x1),
0xAE: (0x15, 0x15, 0x15, 0x1F, 0x0),
0xAF: (0xC, 0x0, 0xD, 0x1, 0xE),
0xB0: (0x8, 0x8, 0x8, 0x8, 0x8),
0xB1: (0x40, 0x41, 0x5E, 0x48, 0x70),
0xB2: (0x2, 0x4, 0xF, 0x10, 0x20),
0xB3: (0x38, 0x20, 0x61, 0x22, 0x3C),
0xB4: (0x21, 0x21, 0x3F, 0x21, 0x21),
0xB5: (0x22, 0x24, 0x28, 0x7F, 0x20),
0xB6: (0x21, 0x7E, 0x20, 0x21, 0x3E),
0xB7: (0x28, 0x28, 0x7F, 0x28, 0x28),
0xB8: (0x10, 0x61, 0x41, 0x42, 0x7C),
0xB9: (0x10, 0x60, 0x21, 0x3E, 0x20),
0xBA: (0x41, 0x41, 0x41, 0x41, 0x7F),
0xBB: (0x20, 0x79, 0x22, 0x7C, 0x20),
0xBC: (0x29, 0x29, 0x1, 0x2, 0x1C),
0xBD: (0x21, 0x22, 0x24, 0x2A, 0x31),
0xBE: (0x20, 0x7E, 0x21, 0x29, 0x31),
0xBF: (0x60, 0x11, 0x1, 0x2, 0x3C),
0xC0: (0x8, 0x31, 0x29, 0x26, 0x3C),
0xC1: (0x28, 0x29, 0x3E, 0x48, 0x8),
0xC2: (0x38, 0x0, 0x39, 0x2, 0x3C),
0xC3: (0x10, 0x51, 0x5E, 0x50, 0x10),
0xC4: (0x0, 0x7F, 0x8, 0x4, 0x0),
0xC5: (0x11, 0x12, 0x7C, 0x10, 0x10),
0xC6: (0x1, 0x21, 0x21, 0x21, 0x1),
0xC7: (0x21, 0x2A, 0x24, 0x2A, 0x30),
0xC8: (0x22, 0x24, 0x6F, 0x34, 0x22),
0xC9: (0x0, 0x1, 0x2, 0x7C, 0x0),
0xCA: (0xF, 0x0, 0x20, 0x10, 0xF),
0xCB: (0x7E, 0x11, 0x11, 0x11, 0x11),
0xCC: (0x20, 0x21, 0x21, 0x22, 0x3C),
0xCD: (0x10, 0x20, 0x10, 0x8, 0x6),
0xCE: (0x26, 0x20, 0x7F, 0x20, 0x26),
0xCF: (0x20, 0x24, 0x22, 0x25, 0x38),
0xD0: (0x0, 0x2A, 0x2A, 0x2A, 0x1),
0xD1: (0xE, 0x12, 0x22, 0x2, 0x7),
0xD2: (0x1, 0xA, 0x4, 0xA, 0x30),
0xD3: (0x20, 0x3E, 0x29, 0x29, 0x29),
0xD4: (0x10, 0x7F, 0x10, 0x14, 0x18),
0xD5: (0x1, 0x21, 0x21, 0x3F, 0x1),
0xD6: (0x29, 0x29, 0x29, 0x29, 0x3F),
0xD7: (0x10, 0x50, 0x51, 0x52, 0x1C),
0xD8: (0x78, 0x1, 0x2, 0x7C, 0x0),
0xD9: (0x1F, 0x0, 0x3F, 0x1, 0x6),
0xDA: (0x3F, 0x1, 0x2, 0x4, 0x8),
0xDB: (0x3F, 0x21, 0x21, 0x21, 0x3F),
0xDC: (0x38, 0x20, 0x21, 0x22, 0x3C),
0xDD: (0x21, 0x21, 0x1, 0x2, 0xC),
0xDE: (0x20, 0x10, 0x40, 0x20, 0x0),
0xDF: (0x70, 0x50, 0x70, 0x0, 0x0),
0xE0: (0xE, 0x11, 0x9, 0x6, 0x1),
0xE1: (0x2, 0x55, 0x15, 0x55, 0xF),
0xE2: (0x1F, 0x2A, 0x2A, 0x2A, 0x14),
0xE3: (0xA, 0x15, 0x15, 0x11, 0x2),
0xE4: (0x3F, 0x4, 0x4, 0x8, 0x3C),
0xE5: (0xE, 0x11, 0x19, 0x15, 0x12),
0xE6: (0xF, 0x14, 0x24, 0x24, 0x18),
0xE7: (0x8, 0x15, 0x15, 0x15, 0x1E),
0xE8: (0x2, 0x1, 0x1E, 0x10, 0x10),
0xE9: (0x20, 0x20, 0x0, 0x70, 0x0),
0xEA: (0x2, 0x1, 0x11, 0x5E, 0x0),
0xEB: (0x50, 0x20, 0x50, 0x0, 0x0),
0xEC: (0xC, 0x12, 0x3F, 0x12, 0x4),
0xED: (0x14, 0x7F, 0x15, 0x1, 0x1),
0xEE: (0x1F, 0x48, 0x50, 0x50, 0xF),
0xEF: (0xE, 0x51, 0x11, 0x51, 0xE),
0xF0: (0x3F, 0x14, 0x24, 0x24, 0x18),
0xF1: (0x18, 0x24, 0x24, 0x14, 0x3F),
0xF2: (0x1E, 0x29, 0x29, 0x29, 0x1E),
0xF3: (0x6, 0xA, 0x4, 0xA, 0xC),
0xF4: (0xD, 0x13, 0x10, 0x13, 0xD),
0xF5: (0x1E, 0x41, 0x1, 0x42, 0x1F),
0xF6: (0x63, 0x55, 0x49, 0x41, 0x41),
0xF7: (0x11, 0x1E, 0x10, 0x1F, 0x11),
0xF8: (0x51, 0x4A, 0x44, 0x4A, 0x51),
0xF9: (0x18, 0x5, 0x5, 0x5, 0x1E),
0xFA: (0x28, 0x28, 0x3F, 0x28, 0x48),
0xFB: (0x11, 0x1E, 0x14, 0x14, 0x17),
0xFC: (0x1F, 0x14, 0x1C, 0x14, 0x1F),
0xFD: (0x8, 0x8, 0x2A, 0x8, 0x8),
0xFE: (0x0, 0x0, 0x0, 0x0, 0x0),
0xFF: (0x7F, 0x7F, 0x7F, 0x7F, 0x7F),
}
def render(text):
"""Render the text as a byte array as defined above."""
result = bytearray()
for t in text:
for c in __bitmap[ord(t)]:
result.append(c)
result.append(0)
return result
import time
import picoscroll as scroll
scroll.init()
def hello_world():
"""Display scrolling Hello, world!"""
# generate bitmap
hello = render("Hello, World!")
# display bitmap
for offset in range(-17, len(hello)):
scroll.show_bitmap_1d(hello, 16, offset)
scroll.update()
time.sleep(0.1)
if __name__ == "__main__":
while True:
hello_world()
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment