High-level wrapper for pager hardware control.
| 80 | |
| 81 | |
| 82 | class Pager: |
| 83 | """High-level wrapper for pager hardware control.""" |
| 84 | |
| 85 | # Predefined colors (RGB565) |
| 86 | BLACK = 0x0000 |
| 87 | WHITE = 0xFFFF |
| 88 | RED = 0xF800 |
| 89 | GREEN = 0x07E0 |
| 90 | BLUE = 0x001F |
| 91 | YELLOW = 0xFFE0 |
| 92 | CYAN = 0x07FF |
| 93 | MAGENTA = 0xF81F |
| 94 | ORANGE = 0xFD20 |
| 95 | PURPLE = 0x8010 |
| 96 | GRAY = 0x8410 |
| 97 | |
| 98 | # Rotation modes |
| 99 | ROTATION_0 = 0 # Portrait 222x480 |
| 100 | ROTATION_90 = 90 # Landscape 480x222 |
| 101 | ROTATION_180 = 180 # Portrait inverted |
| 102 | ROTATION_270 = 270 # Landscape inverted (default) |
| 103 | |
| 104 | # Font sizes (for built-in bitmap font) |
| 105 | FONT_SMALL = 1 # 5x7 |
| 106 | FONT_MEDIUM = 2 # 10x14 |
| 107 | FONT_LARGE = 3 # 15x21 |
| 108 | |
| 109 | # Button masks |
| 110 | BTN_UP = 0x01 |
| 111 | BTN_DOWN = 0x02 |
| 112 | BTN_LEFT = 0x04 |
| 113 | BTN_RIGHT = 0x08 |
| 114 | BTN_A = 0x10 # Green |
| 115 | BTN_B = 0x20 # Red |
| 116 | BTN_POWER = 0x40 # Power button |
| 117 | |
| 118 | # Input event types (for get_input_event) |
| 119 | EVENT_NONE = 0 |
| 120 | EVENT_PRESS = 1 |
| 121 | EVENT_RELEASE = 2 |
| 122 | |
| 123 | # RTTTL playback modes |
| 124 | RTTTL_SOUND_ONLY = 0 # Sound only (default) |
| 125 | RTTTL_SOUND_VIBRATE = 1 # Sound + vibration |
| 126 | RTTTL_VIBRATE_ONLY = 2 # Silent vibration pattern |
| 127 | |
| 128 | # RTTTL melodies |
| 129 | RTTTL_TETRIS = ( |
| 130 | "tetris:d=4,o=5,b=160:" |
| 131 | "e6,8b,8c6,8d6,16e6,16d6,8c6,8b,a,8a,8c6,e6,8d6,8c6," |
| 132 | "b,8b,8c6,d6,e6,c6,a,2a,8p," |
| 133 | "d6,8f6,a6,8g6,8f6,e6,8e6,8c6,e6,8d6,8c6," |
| 134 | "b,8b,8c6,d6,e6,c6,a,a" |
| 135 | ) |
| 136 | RTTTL_GAME_OVER = "smbdeath:d=4,o=5,b=90:8p,16b,16f6,16p,16f6,16f.6,16e.6,16d6,16c6,16p,16e,16p,16c,4p" |
| 137 | RTTTL_LEVEL_UP = "levelup:d=16,o=5,b=200:c,e,g,c6,8p,g,c6,e6,8g6" |
| 138 | |
| 139 | def __init__(self): |
no outgoing calls
no test coverage detected