| 141 | self.gfx.clear_input_events() # Flush stale events from service takeover |
| 142 | |
| 143 | def cleanup(self): |
| 144 | if hasattr(self, 'gfx'): |
| 145 | try: |
| 146 | # Clear screen to black before releasing hardware so the |
| 147 | # display doesn't freeze on the last drawn frame while |
| 148 | # pineapplepager is restarting. |
| 149 | self.gfx.clear(Pager.BLACK) |
| 150 | self.gfx.flip() |
| 151 | except Exception: |
| 152 | pass |
| 153 | try: |
| 154 | self.gfx.cleanup() |
| 155 | except Exception: |
| 156 | pass |
| 157 | |
| 158 | def _adjust_brightness(self, direction): |
| 159 | """Adjust screen brightness. direction: +1 or -1.""" |