GLCDFONT = [
[0x00, 0x00, 0x00, 0x00, 0x00],
[0x3E, 0x5B, 0x4F, 0x5B, 0x3E],
[0x3E, 0x6B, 0x4F, 0x6B, 0x3E],
[0x1C, 0x3E, 0x7C, 0x3E, 0x1C],
[0x18, 0x3C, 0x7E, 0x3C, 0x18],
[0x1C, 0x57, 0x7D, 0x57, 0x1C],
[0x1C, 0x5E, 0x7F, 0x5E, 0x1C],
[0x00, 0x18, 0x3C, 0x18, 0x00],
[0xFF, 0xE7, 0xC3, 0xE7, 0xFF],
[0x00, 0x18, 0x24, 0x18, 0x00],
[0xFF, 0xE7, 0xDB, 0xE7, 0xFF],
[0x30, 0x48, 0x3A, 0x06, 0x0E],
[0x26, 0x29, 0x79, 0x29, 0x26],
[0x40, 0x7F, 0x05, 0x05, 0x07],
[0x40, 0x7F, 0x05, 0x25, 0x3F],
[0x5A, 0x3C, 0xE7, 0x3C, 0x5A],
[0x7F, 0x3E, 0x1C, 0x1C, 0x08],
[0x08, 0x1C, 0x1C, 0x3E, 0x7F],
[0x14, 0x22, 0x7F, 0x22, 0x14],
[0x5F, 0x5F, 0x00, 0x5F, 0x5F],
[0x06, 0x09, 0x7F, 0x01, 0x7F],
[0x00, 0x66, 0x89, 0x95, 0x6A],
[0x60, 0x60, 0x60, 0x60, 0x60],
[0x94, 0xA2, 0xFF, 0xA2, 0x94],
[0x08, 0x04, 0x7E, 0x04, 0x08],
[0x10, 0x20, 0x7E, 0x20, 0x10],
[0x08, 0x08, 0x2A, 0x1C, 0x08],
[0x08, 0x1C, 0x2A, 0x08, 0x08],
[0x1E, 0x10, 0x10, 0x10, 0x10],
[0x0C, 0x1E, 0x0C, 0x1E, 0x0C],
[0x30, 0x38, 0x3E, 0x38, 0x30],
[0x06, 0x0E, 0x3E, 0x0E, 0x06],
[0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x5F, 0x00, 0x00],
[0x00, 0x07, 0x00, 0x07, 0x00],
[0x14, 0x7F, 0x14, 0x7F, 0x14],
[0x24, 0x2A, 0x7F, 0x2A, 0x12],
[0x23, 0x13, 0x08, 0x64, 0x62],
[0x36, 0x49, 0x56, 0x20, 0x50],
[0x00, 0x08, 0x07, 0x03, 0x00],
[0x00, 0x1C, 0x22, 0x41, 0x00],
[0x00, 0x41, 0x22, 0x1C, 0x00],
[0x2A, 0x1C, 0x7F, 0x1C, 0x2A],
[0x08, 0x08, 0x3E, 0x08, 0x08],
[0x00, 0x80, 0x70, 0x30, 0x00],
[0x08, 0x08, 0x08, 0x08, 0x08],
[0x00, 0x00, 0x60, 0x60, 0x00],
[0x20, 0x10, 0x08, 0x04, 0x02],
[0x3E, 0x51, 0x49, 0x45, 0x3E],
[0x00, 0x42, 0x7F, 0x40, 0x00],
[0x72, 0x49, 0x49, 0x49, 0x46],
[0x21, 0x41, 0x49, 0x4D, 0x33],
[0x18, 0x14, 0x12, 0x7F, 0x10],
[0x27, 0x45, 0x45, 0x45, 0x39],
[0x3C, 0x4A, 0x49, 0x49, 0x31],
[0x41, 0x21, 0x11, 0x09, 0x07],
[0x36, 0x49, 0x49, 0x49, 0x36],
[0x46, 0x49, 0x49, 0x29, 0x1E],
[0x00, 0x00, 0x14, 0x00, 0x00],
[0x00, 0x40, 0x34, 0x00, 0x00],
[0x00, 0x08, 0x14, 0x22, 0x41],
[0x14, 0x14, 0x14, 0x14, 0x14],
[0x00, 0x41, 0x22, 0x14, 0x08],
[0x02, 0x01, 0x59, 0x09, 0x06],
[0x3E, 0x41, 0x5D, 0x59, 0x4E],
[0x7C, 0x12, 0x11, 0x12, 0x7C],
[0x7F, 0x49, 0x49, 0x49, 0x36],
[0x3E, 0x41, 0x41, 0x41, 0x22],
[0x7F, 0x41, 0x41, 0x41, 0x3E],
[0x7F, 0x49, 0x49, 0x49, 0x41],
[0x7F, 0x09, 0x09, 0x09, 0x01],
[0x3E, 0x41, 0x41, 0x51, 0x73],
[0x7F, 0x08, 0x08, 0x08, 0x7F],
[0x00, 0x41, 0x7F, 0x41, 0x00],
[0x20, 0x40, 0x41, 0x3F, 0x01],
[0x7F, 0x08, 0x14, 0x22, 0x41],
[0x7F, 0x40, 0x40, 0x40, 0x40],
[0x7F, 0x02, 0x1C, 0x02, 0x7F],
[0x7F, 0x04, 0x08, 0x10, 0x7F],
[0x3E, 0x41, 0x41, 0x41, 0x3E],
[0x7F, 0x09, 0x09, 0x09, 0x06],
[0x3E, 0x41, 0x51, 0x21, 0x5E],
[0x7F, 0x09, 0x19, 0x29, 0x46],
[0x26, 0x49, 0x49, 0x49, 0x32],
[0x03, 0x01, 0x7F, 0x01, 0x03],
[0x3F, 0x40, 0x40, 0x40, 0x3F],
[0x1F, 0x20, 0x40, 0x20, 0x1F],
[0x3F, 0x40, 0x38, 0x40, 0x3F],
[0x63, 0x14, 0x08, 0x14, 0x63],
[0x03, 0x04, 0x78, 0x04, 0x03],
[0x61, 0x59, 0x49, 0x4D, 0x43],
[0x00, 0x7F, 0x41, 0x41, 0x41],
[0x02, 0x04, 0x08, 0x10, 0x20],
[0x00, 0x41, 0x41, 0x41, 0x7F],
[0x04, 0x02, 0x01, 0x02, 0x04],
[0x40, 0x40, 0x40, 0x40, 0x40],
[0x00, 0x03, 0x07, 0x08, 0x00],
[0x20, 0x54, 0x54, 0x78, 0x40],
[0x7F, 0x28, 0x44, 0x44, 0x38],
[0x38, 0x44, 0x44, 0x44, 0x28],
[0x38, 0x44, 0x44, 0x28, 0x7F],
[0x38, 0x54, 0x54, 0x54, 0x18],
[0x00, 0x08, 0x7E, 0x09, 0x02],
[0x18, 0xA4, 0xA4, 0x9C, 0x78],
[0x7F, 0x08, 0x04, 0x04, 0x78],
[0x00, 0x44, 0x7D, 0x40, 0x00],
[0x20, 0x40, 0x40, 0x3D, 0x00],
[0x7F, 0x10, 0x28, 0x44, 0x00],
[0x00, 0x41, 0x7F, 0x40, 0x00],
[0x7C, 0x04, 0x78, 0x04, 0x78],
[0x7C, 0x08, 0x04, 0x04, 0x78],
[0x38, 0x44, 0x44, 0x44, 0x38],
[0xFC, 0x18, 0x24, 0x24, 0x18],
[0x18, 0x24, 0x24, 0x18, 0xFC],
[0x7C, 0x08, 0x04, 0x04, 0x08],
[0x48, 0x54, 0x54, 0x54, 0x24],
[0x04, 0x04, 0x3F, 0x44, 0x24],
[0x3C, 0x40, 0x40, 0x20, 0x7C],
[0x1C, 0x20, 0x40, 0x20, 0x1C],
[0x3C, 0x40, 0x30, 0x40, 0x3C],
[0x44, 0x28, 0x10, 0x28, 0x44],
[0x4C, 0x90, 0x90, 0x90, 0x7C],
[0x44, 0x64, 0x54, 0x4C, 0x44],
[0x00, 0x08, 0x36, 0x41, 0x00],
[0x00, 0x00, 0x77, 0x00, 0x00],
[0x00, 0x41, 0x36, 0x08, 0x00],
[0x02, 0x01, 0x02, 0x04, 0x02],
[0x3C, 0x26, 0x23, 0x26, 0x3C],
[0x1E, 0xA1, 0xA1, 0x61, 0x12],
[0x3A, 0x40, 0x40, 0x20, 0x7A],
[0x38, 0x54, 0x54, 0x55, 0x59],
[0x21, 0x55, 0x55, 0x79, 0x41],
[0x21, 0x54, 0x54, 0x78, 0x41],
[0x21, 0x55, 0x54, 0x78, 0x40],
[0x20, 0x54, 0x55, 0x79, 0x40],
[0x0C, 0x1E, 0x52, 0x72, 0x12],
[0x39, 0x55, 0x55, 0x55, 0x59],
[0x39, 0x54, 0x54, 0x54, 0x59],
[0x39, 0x55, 0x54, 0x54, 0x58],
[0x00, 0x00, 0x45, 0x7C, 0x41],
[0x00, 0x02, 0x45, 0x7D, 0x42],
[0x00, 0x01, 0x45, 0x7C, 0x40],
[0xF0, 0x29, 0x24, 0x29, 0xF0],
[0xF0, 0x28, 0x25, 0x28, 0xF0],
[0x7C, 0x54, 0x55, 0x45, 0x00],
[0x20, 0x54, 0x54, 0x7C, 0x54],
[0x7C, 0x0A, 0x09, 0x7F, 0x49],
[0x32, 0x49, 0x49, 0x49, 0x32],
[0x32, 0x48, 0x48, 0x48, 0x32],
[0x32, 0x4A, 0x48, 0x48, 0x30],
[0x3A, 0x41, 0x41, 0x21, 0x7A],
[0x3A, 0x42, 0x40, 0x20, 0x78],
[0x00, 0x9D, 0xA0, 0xA0, 0x7D],
[0x39, 0x44, 0x44, 0x44, 0x39],
[0x3D, 0x40, 0x40, 0x40, 0x3D],
[0x3C, 0x24, 0xFF, 0x24, 0x24],
[0x48, 0x7E, 0x49, 0x43, 0x66],
[0x2B, 0x2F, 0xFC, 0x2F, 0x2B],
[0xFF, 0x09, 0x29, 0xF6, 0x20],
[0xC0, 0x88, 0x7E, 0x09, 0x03],
[0x20, 0x54, 0x54, 0x79, 0x41],
[0x00, 0x00, 0x44, 0x7D, 0x41],
[0x30, 0x48, 0x48, 0x4A, 0x32],
[0x38, 0x40, 0x40, 0x22, 0x7A],
[0x00, 0x7A, 0x0A, 0x0A, 0x72],
[0x7D, 0x0D, 0x19, 0x31, 0x7D],
[0x26, 0x29, 0x29, 0x2F, 0x28],
[0x26, 0x29, 0x29, 0x29, 0x26],
[0x30, 0x48, 0x4D, 0x40, 0x20],
[0x38, 0x08, 0x08, 0x08, 0x08],
[0x08, 0x08, 0x08, 0x08, 0x38],
[0x2F, 0x10, 0xC8, 0xAC, 0xBA],
[0x2F, 0x10, 0x28, 0x34, 0xFA],
[0x00, 0x00, 0x7B, 0x00, 0x00],
[0x08, 0x14, 0x2A, 0x14, 0x22],
[0x22, 0x14, 0x2A, 0x14, 0x08],
[0xAA, 0x00, 0x55, 0x00, 0xAA],
[0xAA, 0x55, 0xAA, 0x55, 0xAA],
[0x00, 0x00, 0x00, 0xFF, 0x00],
[0x10, 0x10, 0x10, 0xFF, 0x00],
[0x14, 0x14, 0x14, 0xFF, 0x00],
[0x10, 0x10, 0xFF, 0x00, 0xFF],
[0x10, 0x10, 0xF0, 0x10, 0xF0],
[0x14, 0x14, 0x14, 0xFC, 0x00],
[0x14, 0x14, 0xF7, 0x00, 0xFF],
[0x00, 0x00, 0xFF, 0x00, 0xFF],
[0x14, 0x14, 0xF4, 0x04, 0xFC],
[0x14, 0x14, 0x17, 0x10, 0x1F],
[0x10, 0x10, 0x1F, 0x10, 0x1F],
[0x14, 0x14, 0x14, 0x1F, 0x00],
[0x10, 0x10, 0x10, 0xF0, 0x00],
[0x00, 0x00, 0x00, 0x1F, 0x10],
[0x10, 0x10, 0x10, 0x1F, 0x10],
[0x10, 0x10, 0x10, 0xF0, 0x10],
[0x00, 0x00, 0x00, 0xFF, 0x10],
[0x10, 0x10, 0x10, 0x10, 0x10],
[0x10, 0x10, 0x10, 0xFF, 0x10],
[0x00, 0x00, 0x00, 0xFF, 0x14],
[0x00, 0x00, 0xFF, 0x00, 0xFF],
[0x00, 0x00, 0x1F, 0x10, 0x17],
[0x00, 0x00, 0xFC, 0x04, 0xF4],
[0x14, 0x14, 0x17, 0x10, 0x17],
[0x14, 0x14, 0xF4, 0x04, 0xF4],
[0x00, 0x00, 0xFF, 0x00, 0xF7],
[0x14, 0x14, 0x14, 0x14, 0x14],
[0x14, 0x14, 0xF7, 0x00, 0xF7],
[0x14, 0x14, 0x14, 0x17, 0x14],
[0x10, 0x10, 0x1F, 0x10, 0x1F],
[0x14, 0x14, 0x14, 0xF4, 0x14],
[0x10, 0x10, 0xF0, 0x10, 0xF0],
[0x00, 0x00, 0x1F, 0x10, 0x1F],
[0x00, 0x00, 0x00, 0x1F, 0x14],
[0x00, 0x00, 0x00, 0xFC, 0x14],
[0x00, 0x00, 0xF0, 0x10, 0xF0],
[0x10, 0x10, 0xFF, 0x10, 0xFF],
[0x14, 0x14, 0x14, 0xFF, 0x14],
[0x10, 0x10, 0x10, 0x1F, 0x00],
[0x00, 0x00, 0x00, 0xF0, 0x10],
[0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
[0xF0, 0xF0, 0xF0, 0xF0, 0xF0],
[0xFF, 0xFF, 0xFF, 0x00, 0x00],
[0x00, 0x00, 0x00, 0xFF, 0xFF],
[0x0F, 0x0F, 0x0F, 0x0F, 0x0F],
[0x38, 0x44, 0x44, 0x38, 0x44],
[0x7C, 0x2A, 0x2A, 0x3E, 0x14],
[0x7E, 0x02, 0x02, 0x06, 0x06],
[0x02, 0x7E, 0x02, 0x7E, 0x02],
[0x63, 0x55, 0x49, 0x41, 0x63],
[0x38, 0x44, 0x44, 0x3C, 0x04],
[0x40, 0x7E, 0x20, 0x1E, 0x20],
[0x06, 0x02, 0x7E, 0x02, 0x02],
[0x99, 0xA5, 0xE7, 0xA5, 0x99],
[0x1C, 0x2A, 0x49, 0x2A, 0x1C],
[0x4C, 0x72, 0x01, 0x72, 0x4C],
[0x30, 0x4A, 0x4D, 0x4D, 0x30],
[0x30, 0x48, 0x78, 0x48, 0x30],
[0xBC, 0x62, 0x5A, 0x46, 0x3D],
[0x3E, 0x49, 0x49, 0x49, 0x00],
[0x7E, 0x01, 0x01, 0x01, 0x7E],
[0x2A, 0x2A, 0x2A, 0x2A, 0x2A],
[0x44, 0x44, 0x5F, 0x44, 0x44],
[0x40, 0x51, 0x4A, 0x44, 0x40],
[0x40, 0x44, 0x4A, 0x51, 0x40],
[0x00, 0x00, 0xFF, 0x01, 0x03],
[0xE0, 0x80, 0xFF, 0x00, 0x00],
[0x08, 0x08, 0x6B, 0x6B, 0x08],
[0x36, 0x12, 0x36, 0x24, 0x36],
[0x06, 0x0F, 0x09, 0x0F, 0x06],
[0x00, 0x00, 0x18, 0x18, 0x00],
[0x00, 0x00, 0x10, 0x10, 0x00],
[0x30, 0x40, 0xFF, 0x01, 0x01],
[0x00, 0x1F, 0x01, 0x01, 0x1E],
[0x00, 0x19, 0x1D, 0x17, 0x12],
[0x00, 0x3C, 0x3C, 0x3C, 0x3C],
[0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00]
]
TINYFONT = [
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x00, 0x00, 0x00], # Space
[0x00, 0x17, 0x00], # !
[0x03, 0x00, 0x03], # "
[0x1f, 0x0a, 0x1f],
[0x0a, 0x1f, 0x05], # $
[0x09, 0x04, 0x12], # %
[0x0f, 0x17, 0x1c], # &
[0x00, 0x03, 0x00], # '
[0x00, 0x0e, 0x11], # (
[0x11, 0x0e, 0x00], # )
[0x05, 0x02, 0x05], # *
[0x04, 0x0e, 0x04], # +
[0x10, 0x08, 0x00], # ,
[0x04, 0x04, 0x04], # -
[0x00, 0x10, 0x00], # .
[0x18, 0x04, 0x03], # /
[0x1e, 0x11, 0x0f], # 0
[0x02, 0x1f, 0x00], # 1
[0x19, 0x15, 0x12], # 2
[0x11, 0x15, 0x0a], # 3
[0x07, 0x04, 0x1f], # 4
[0x17, 0x15, 0x09], # 5
[0x1e, 0x15, 0x1d], # 6
[0x19, 0x05, 0x03], # 7
[0x1f, 0x15, 0x1f], # 8
[0x17, 0x15, 0x0f], # 9
[0x00, 0x0a, 0x00], # :
[0x10, 0x0a, 0x00], # ;
[0x04, 0x0a, 0x11], # <
[0x0a, 0x0a, 0x0a], # =
[0x11, 0x0a, 0x04], # >
[0x01, 0x15, 0x03], # ?
[0x0e, 0x15, 0x16], # @
[0x1e, 0x05, 0x1e], # A
[0x1f, 0x15, 0x0a], # B
[0x0e, 0x11, 0x11], # C
[0x1f, 0x11, 0x0e], # D
[0x1f, 0x15, 0x15], # E
[0x1f, 0x05, 0x05], # F
[0x0e, 0x15, 0x1d], # G
[0x1f, 0x04, 0x1f], # H
[0x11, 0x1f, 0x11], # I
[0x08, 0x10, 0x0f], # J
[0x1f, 0x04, 0x1b], # K
[0x1f, 0x10, 0x10], # L
[0x1f, 0x06, 0x1f], # M
[0x1f, 0x0e, 0x1f], # N
[0x0e, 0x11, 0x0e], # O
[0x1f, 0x05, 0x02], # P
[0x0e, 0x19, 0x1e], # Q
[0x1f, 0x0d, 0x16], # R
[0x12, 0x15, 0x09], # S
[0x01, 0x1f, 0x01], # T
[0x0f, 0x10, 0x1f], # U
[0x07, 0x18, 0x07], # V
[0x1f, 0x0c, 0x1f], # W
[0x1b, 0x04, 0x1b], # X
[0x03, 0x1c, 0x03], # Y
[0x19, 0x15, 0x13], # Z
[0x1f, 0x11, 0x11], # [
[0x02, 0x04, 0x08], # \
[0x11, 0x11, 0x1f], # ]
[0x02, 0x01, 0x02], # ^
[0x10, 0x10, 0x10], # _
[0x01, 0x02, 0x00], # `
[0x1a, 0x16, 0x1c], # a
[0x1f, 0x12, 0x0c], # b
[0x0c, 0x12, 0x12], # c
[0x0c, 0x12, 0x1f], # d
[0x0c, 0x1a, 0x16], # e
[0x04, 0x1e, 0x05], # f
[0x0c, 0x2a, 0x1e], # g
[0x1f, 0x02, 0x1c], # h
[0x00, 0x1d, 0x00], # i
[0x08, 0x10, 0x0d], # j
[0x1f, 0x0c, 0x12], # k
[0x11, 0x1f, 0x10], # l
[0x1e, 0x0e, 0x1e], # m
[0x1e, 0x02, 0x1c], # n
[0x0c, 0x12, 0x0c], # o
[0x3e, 0x12, 0x0c], # p
[0x0c, 0x12, 0x3e], # q
[0x1c, 0x02, 0x02], # r
[0x14, 0x1e, 0x0a], # s
[0x02, 0x1f, 0x12], # t
[0x0e, 0x10, 0x1e], # u
[0x0e, 0x18, 0x0e], # v
[0x1e, 0x1c, 0x1e], # w
[0x12, 0x0c, 0x12], # x
[0x06, 0x28, 0x1e], # y
[0x1a, 0x1e, 0x16], # z
[0x04, 0x1b, 0x11], # {
[0x00, 0x1f, 0x00], # |
[0x11, 0x1b, 0x04], # }
[0x02, 0x03, 0x01], # ~
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
[0x1f, 0x1f, 0x1f], # SPECIAL
]
LARGEFONT = [
[0x0000, 0x0db4, 0x0004, 0x0800, 0x0804, 0x0004, 0x0800, 0x0b6c],
[0x0000, 0x015c, 0x1f54, 0x0174, 0x0000, 0x0004, 0x007c, 0x0004],
[0x0000, 0x015c, 0x1f54, 0x0174, 0x0000, 0x007c, 0x0044, 0x007c],
[0x0000, 0x1b7c, 0x0454, 0x1b44, 0x0000, 0x0004, 0x007c, 0x0004],
[0x0000, 0x017c, 0x1f54, 0x0144, 0x0000, 0x007c, 0x0044, 0x007c],
[0x0000, 0x0e7c, 0x1154, 0x1944, 0x1e00, 0x007c, 0x0018, 0x0020],
[0x0000, 0x1f78, 0x0424, 0x1b78, 0x0000, 0x0038, 0x0044, 0x0044],
[0x0000, 0x1f7c, 0x1054, 0x1068, 0x0000, 0x007c, 0x0054, 0x0044],
[0x0000, 0x007c, 0x0054, 0x0068, 0x0000, 0x005c, 0x0054, 0x0074],
[0x0000, 0x017c, 0x1f10, 0x017c, 0x0000, 0x0004, 0x007c, 0x0004],
[0x0000, 0x007c, 0x0040, 0x0040, 0x0000, 0x007c, 0x0014, 0x0004],
[0x0000, 0x001c, 0x0060, 0x001c, 0x0000, 0x0004, 0x007c, 0x0004],
[0x0000, 0x007c, 0x0014, 0x0004, 0x0000, 0x007c, 0x0014, 0x0004],
[0x0000, 0x0038, 0x0044, 0x0044, 0x0000, 0x007c, 0x0014, 0x0068],
[0x0000, 0x005c, 0x0054, 0x0074, 0x0000, 0x007c, 0x0044, 0x007c],
[0x0000, 0x0000, 0x005c, 0x0054, 0x0074, 0x0000, 0x007c, 0x0000],
[0x0000, 0x1f7c, 0x1544, 0x1138, 0x0000, 0x007c, 0x0040, 0x0040],
[0x0000, 0x127c, 0x1f44, 0x1038, 0x0000, 0x0038, 0x0044, 0x007c],
[0x0000, 0x127c, 0x1944, 0x1638, 0x0000, 0x0038, 0x0044, 0x0044],
[0x0000, 0x157c, 0x1544, 0x0a38, 0x0000, 0x0038, 0x0044, 0x0044],
[0x0000, 0x077c, 0x0444, 0x1f38, 0x0000, 0x0038, 0x0044, 0x0044],
[0x0000, 0x1f7c, 0x0418, 0x1b20, 0x007c, 0x0000, 0x0078, 0x0024],
[0x0000, 0x1f5c, 0x0654, 0x0874, 0x1f00, 0x000c, 0x0070, 0x000c],
[0x0000, 0x1f7c, 0x1554, 0x1a44, 0x0000, 0x0004, 0x007c, 0x0004],
[0x0000, 0x1f38, 0x0644, 0x0844, 0x1f00, 0x0078, 0x0024, 0x0078],
[0x0000, 0x007c, 0x0054, 0x0044, 0x0000, 0x007c, 0x0018, 0x007c],
[0x0000, 0x1f5c, 0x1554, 0x1a74, 0x0000, 0x007c, 0x0040, 0x007c],
[0x0000, 0x0e7c, 0x1154, 0x1144, 0x0000, 0x005c, 0x0054, 0x0074],
[0x0000, 0x007c, 0x0014, 0x0004, 0x0000, 0x005c, 0x0054, 0x0074],
[0x0000, 0x007c, 0x0044, 0x0074, 0x0000, 0x005c, 0x0054, 0x0074],
[0x0000, 0x007c, 0x0014, 0x0068, 0x0000, 0x005c, 0x0054, 0x0074],
[0x0000, 0x007c, 0x0040, 0x007c, 0x0000, 0x005c, 0x0054, 0x0074],
[0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000],
[0x0000, 0x0000, 0x0000, 0x0038, 0x0dfc, 0x0dfc, 0x0038, 0x0000],
[0x0000, 0x0000, 0x000e, 0x001e, 0x0000, 0x0000, 0x001e, 0x000e],
[0x0000, 0x0220, 0x0ff8, 0x0ff8, 0x0220, 0x0ff8, 0x0ff8, 0x0220],
[0x0000, 0x0638, 0x0c7c, 0x0844, 0x3847, 0x3847, 0x0fcc, 0x0798],
[0x0000, 0x0c30, 0x0630, 0x0300, 0x0180, 0x00c0, 0x0c60, 0x0c30],
[0x0000, 0x0780, 0x0fd8, 0x087c, 0x08e4, 0x07bc, 0x0fd8, 0x0840],
[0x0000, 0x0000, 0x0000, 0x001e, 0x000e, 0x0000, 0x0000, 0x0000],
[0x0000, 0x0000, 0x0000, 0x03f0, 0x07f8, 0x0c0c, 0x0804, 0x0000],
[0x0000, 0x0000, 0x0000, 0x0804, 0x0c0c, 0x07f8, 0x03f0, 0x0000],
[0x0000, 0x0080, 0x02a0, 0x03e0, 0x01c0, 0x01c0, 0x03e0, 0x02a0],
[0x0000, 0x0000, 0x0080, 0x0080, 0x03e0, 0x03e0, 0x0080, 0x0080],
[0x0000, 0x0000, 0x0000, 0x1000, 0x1e00, 0x0e00, 0x0000, 0x0000],
[0x0000, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080],
[0x0000, 0x0000, 0x0000, 0x0000, 0x0c00, 0x0c00, 0x0000, 0x0000],
[0x0000, 0x0c00, 0x0600, 0x0300, 0x0180, 0x00c0, 0x0060, 0x0030],
[0x0000, 0x03f0, 0x07f8, 0x0c0c, 0x08c4, 0x0c0c, 0x07f8, 0x03f0],
[0x0000, 0x0000, 0x0810, 0x0818, 0x0ffc, 0x0ffc, 0x0800, 0x0800],
[0x0000, 0x0e08, 0x0f0c, 0x0984, 0x08c4, 0x0864, 0x0c3c, 0x0c18],
[0x0000, 0x0408, 0x0c0c, 0x0844, 0x0844, 0x0844, 0x0ffc, 0x07b8],
[0x0000, 0x00c0, 0x00e0, 0x00b0, 0x0898, 0x0ffc, 0x0ffc, 0x0880],
[0x0000, 0x047c, 0x0c7c, 0x0844, 0x0844, 0x0844, 0x0fc4, 0x0784],
[0x0000, 0x07f0, 0x0ff8, 0x084c, 0x0844, 0x0844, 0x0fc0, 0x0780],
[0x0000, 0x000c, 0x000c, 0x0f04, 0x0f84, 0x00c4, 0x007c, 0x003c],
[0x0000, 0x07b8, 0x0ffc, 0x0844, 0x0844, 0x0844, 0x0ffc, 0x07b8],
[0x0000, 0x0038, 0x087c, 0x0844, 0x0844, 0x0c44, 0x07fc, 0x03f8],
[0x0000, 0x0000, 0x0000, 0x0000, 0x0630, 0x0630, 0x0000, 0x0000],
[0x0000, 0x0000, 0x0000, 0x0800, 0x0e30, 0x0630, 0x0000, 0x0000],
[0x0000, 0x0000, 0x0080, 0x01c0, 0x0360, 0x0630, 0x0c18, 0x0808],
[0x0000, 0x0000, 0x0120, 0x0120, 0x0120, 0x0120, 0x0120, 0x0120],
[0x0000, 0x0000, 0x0808, 0x0c18, 0x0630, 0x0360, 0x01c0, 0x0080],
[0x0000, 0x0018, 0x001c, 0x0004, 0x0dc4, 0x0de4, 0x003c, 0x0018],
[0x0000, 0x07f0, 0x0ff8, 0x0808, 0x0bc8, 0x0bc8, 0x0bf8, 0x01f0],
[0x0000, 0x0fe0, 0x0ff0, 0x0098, 0x008c, 0x0098, 0x0ff0, 0x0fe0],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0844, 0x0844, 0x0ffc, 0x07b8],
[0x0000, 0x03f0, 0x07f8, 0x0c0c, 0x0804, 0x0804, 0x0c0c, 0x0618],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0804, 0x0c0c, 0x07f8, 0x03f0],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0844, 0x08e4, 0x0c0c, 0x0e1c],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0844, 0x00e4, 0x000c, 0x001c],
[0x0000, 0x03f0, 0x07f8, 0x0c0c, 0x0884, 0x0884, 0x078c, 0x0f98],
[0x0000, 0x0ffc, 0x0ffc, 0x0040, 0x0040, 0x0040, 0x0ffc, 0x0ffc],
[0x0000, 0x0000, 0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0804, 0x0000],
[0x0000, 0x0700, 0x0f00, 0x0800, 0x0804, 0x0ffc, 0x07fc, 0x0004],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x00c0, 0x01e0, 0x0f3c, 0x0e1c],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0804, 0x0800, 0x0c00, 0x0e00],
[0x0000, 0x0ffc, 0x0ffc, 0x0038, 0x0070, 0x0038, 0x0ffc, 0x0ffc],
[0x0000, 0x0ffc, 0x0ffc, 0x0038, 0x0070, 0x00e0, 0x0ffc, 0x0ffc],
[0x0000, 0x07f8, 0x0ffc, 0x0804, 0x0804, 0x0804, 0x0ffc, 0x07f8],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0844, 0x0044, 0x007c, 0x0038],
[0x0000, 0x07f8, 0x0ffc, 0x0804, 0x0e04, 0x3c04, 0x3ffc, 0x27f8],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0044, 0x00c4, 0x0ffc, 0x0f38],
[0x0000, 0x0618, 0x0e3c, 0x0864, 0x0844, 0x08c4, 0x0f9c, 0x0718],
[0x0000, 0x0000, 0x001c, 0x080c, 0x0ffc, 0x0ffc, 0x080c, 0x001c],
[0x0000, 0x07fc, 0x0ffc, 0x0800, 0x0800, 0x0800, 0x0ffc, 0x07fc],
[0x0000, 0x01fc, 0x03fc, 0x0600, 0x0c00, 0x0600, 0x03fc, 0x01fc],
[0x0000, 0x07fc, 0x0ffc, 0x0e00, 0x03c0, 0x0e00, 0x0ffc, 0x07fc],
[0x0000, 0x0c0c, 0x0f3c, 0x03f0, 0x01e0, 0x03f0, 0x0f3c, 0x0c0c],
[0x0000, 0x0000, 0x003c, 0x087c, 0x0fc0, 0x0fc0, 0x087c, 0x003c],
[0x0000, 0x0e1c, 0x0f0c, 0x0984, 0x08c4, 0x0864, 0x0c3c, 0x0e1c],
[0x0000, 0x0000, 0x0000, 0x0ffc, 0x0ffc, 0x0804, 0x0804, 0x0000],
[0x0000, 0x0038, 0x0070, 0x00e0, 0x01c0, 0x0380, 0x0700, 0x0e00],
[0x0000, 0x0000, 0x0000, 0x0804, 0x0804, 0x0ffc, 0x0ffc, 0x0000],
[0x0000, 0x0008, 0x000c, 0x0006, 0x0003, 0x0006, 0x000c, 0x0008],
[0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000],
[0x0000, 0x0000, 0x0000, 0x0003, 0x0007, 0x0004, 0x0000, 0x0000],
[0x0000, 0x0700, 0x0fa0, 0x08a0, 0x08a0, 0x07e0, 0x0fc0, 0x0800],
[0x0000, 0x0004, 0x0ffc, 0x0ffc, 0x0820, 0x0860, 0x0fc0, 0x0780],
[0x0000, 0x07c0, 0x0fe0, 0x0820, 0x0820, 0x0820, 0x0c60, 0x0440],
[0x0000, 0x0780, 0x0fc0, 0x0860, 0x0824, 0x07fc, 0x0ffc, 0x0800],
[0x0000, 0x07c0, 0x0fe0, 0x08a0, 0x08a0, 0x08a0, 0x0ce0, 0x04c0],
[0x0000, 0x0840, 0x0ff8, 0x0ffc, 0x0844, 0x000c, 0x0018, 0x0000],
[0x0000, 0x27c0, 0x6fe0, 0x4820, 0x4820, 0x7fc0, 0x3fe0, 0x0020],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0040, 0x0020, 0x0fe0, 0x0fc0],
[0x0000, 0x0000, 0x0000, 0x0820, 0x0fec, 0x0fec, 0x0800, 0x0000],
[0x0000, 0x0000, 0x3000, 0x7000, 0x4000, 0x4020, 0x7fec, 0x3fec],
[0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0180, 0x03c0, 0x0e60, 0x0c20],
[0x0000, 0x0000, 0x0000, 0x0804, 0x0ffc, 0x0ffc, 0x0800, 0x0000],
[0x0000, 0x0fe0, 0x0fe0, 0x0060, 0x07c0, 0x0060, 0x0fe0, 0x0fc0],
[0x0000, 0x0020, 0x0fe0, 0x0fc0, 0x0020, 0x0020, 0x0fe0, 0x0fc0],
[0x0000, 0x07c0, 0x0fe0, 0x0820, 0x0820, 0x0820, 0x0fe0, 0x07c0],
[0x0000, 0x4020, 0x7fe0, 0x7fc0, 0x4820, 0x0820, 0x0fe0, 0x07c0],
[0x0000, 0x07c0, 0x0fe0, 0x0820, 0x4820, 0x7fc0, 0x7fe0, 0x4020],
[0x0000, 0x0820, 0x0fe0, 0x0fc0, 0x0860, 0x0020, 0x00e0, 0x00c0],
[0x0000, 0x0440, 0x0ce0, 0x09a0, 0x0920, 0x0b20, 0x0e60, 0x0440],
[0x0000, 0x0020, 0x0020, 0x07f8, 0x0ffc, 0x0820, 0x0c20, 0x0400],
[0x0000, 0x07e0, 0x0fe0, 0x0800, 0x0800, 0x07e0, 0x0fe0, 0x0800],
[0x0000, 0x0000, 0x03e0, 0x07e0, 0x0c00, 0x0c00, 0x07e0, 0x03e0],
[0x0000, 0x07e0, 0x0fe0, 0x0c00, 0x0780, 0x0c00, 0x0fe0, 0x07e0],
[0x0000, 0x0820, 0x0c60, 0x07c0, 0x0380, 0x07c0, 0x0c60, 0x0820],
[0x0000, 0x47e0, 0x4fe0, 0x4800, 0x4800, 0x6800, 0x3fe0, 0x1fe0],
[0x0000, 0x0c60, 0x0e60, 0x0b20, 0x09a0, 0x08e0, 0x0c60, 0x0c20],
[0x0000, 0x0000, 0x0040, 0x0040, 0x07f8, 0x0fbc, 0x0804, 0x0804],
[0x0000, 0x0000, 0x0000, 0x0000, 0x0fbc, 0x0fbc, 0x0000, 0x0000],
[0x0000, 0x0000, 0x0804, 0x0804, 0x0fbc, 0x07f8, 0x0040, 0x0040],
[0x0000, 0x0008, 0x000c, 0x0004, 0x000c, 0x0008, 0x000c, 0x0004],
[0x0000, 0x1f7c, 0x1044, 0x1038, 0x0000, 0x007c, 0x0054, 0x0044]
]
fw, fh = 6, 8
fonts = {
'8x6': {
'data': GLCDFONT,
'height': 8,
'bounds': (0, 255),
'undef': [0x00, 0x00, 0x00, 0x00, 0x00],
'sep': 1
},
'6x4': {
'data': TINYFONT,
'height': 6,
'bounds': (0, 255),
'undef': [0x1f, 0x1f, 0x1f],
'sep': 1
},
'16x8': {
'data': LARGEFONT,
'height': 16,
'bounds': (0, 127),
'undef': [
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000],
'sep': 2
}
}
default_font = '8x6'
[docs]def str_dim(text, font=default_font, font_scale=1, final_sep=True):
f = fonts[font]
fh = f['height']
FONT = f['data']
y = font_scale * fh
x_list = []
x = 0
for c in text:
if c == '\n':
y += font_scale * fh
x = 0
elif c == '\r':
pass # skip it
else:
c = ord(c) # make it the int value
if c < f['bounds'][0] or c > f['bounds'][1]:
c_data = f['undef']
else:
c_data = FONT[c - f['bounds'][0]]
fw = len(c_data)
fw += f['sep']
x += font_scale * fw
x_list.append(x)
if not final_sep:
x_list = [xi - font_scale * f['sep'] for xi in x_list]
return (max(x_list), y)