Skip to content

Instantly share code, notes, and snippets.

@FoamyGuy
Created February 3, 2024 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FoamyGuy/53a115c2b8a320e34af5a97633514a20 to your computer and use it in GitHub Desktop.
Save FoamyGuy/53a115c2b8a320e34af5a97633514a20 to your computer and use it in GitHub Desktop.
# SPDX-FileCopyrightText: 2023 Jeff Epler for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import traceback
import board
from adafruit_editor import editor, picker
from adafruit_featherwing import tft_featherwing_35
import terminalio
import displayio
from adafruit_display_text.bitmap_label import Label
import usb_cdc
from digitalio import DigitalInOut, Direction
def print(message):
usb_cdc.data.write(f"{message}\r\n".encode("utf-8"))
# usb_host_power = DigitalInOut(board.USB_HOST_5V_POWER)
# usb_host_power.direction = Direction.OUTPUT
# usb_host_power.value = False
tft_featherwing = tft_featherwing_35.TFTFeatherWing35V2()
display = tft_featherwing.display
customized_console_group = displayio.Group()
display.root_group = customized_console_group
customized_console_group.append(displayio.CIRCUITPYTHON_TERMINAL)
visible_cursor = Label(terminalio.FONT, text="H", color=0x000000, background_color=0xeeeeee, padding_left=1)
visible_cursor.hidden = True
visible_cursor.anchor_point = (0, 0)
visible_cursor.anchored_position = (100, 100)
customized_console_group.append(visible_cursor)
print("Hello?")
try:
#if True:
while True:
try:
visible_cursor.hidden = True
filename = picker.pick_file()
except KeyboardInterrupt:
customized_console_group.remove(displayio.CIRCUITPYTHON_TERMINAL)
break
try:
print("making cursor visible")
visible_cursor.hidden = False
editor.edit(filename, visible_cursor)
except KeyboardInterrupt:
visible_cursor.hidden = True
pass
except Exception as e: # EVERYTHING!!!!
#traceback.print_exception(e)
print(e)
customized_console_group.remove(displayio.CIRCUITPYTHON_TERMINAL)
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment