Update 'CARDPUTER CircuitPython/text_editor.py'
This commit is contained in:
@@ -1,17 +1,40 @@
|
|||||||
|
# GUIDE
|
||||||
|
# type freely! CTRL+D clears the text.
|
||||||
|
# backspace, space, and return function as expected.
|
||||||
|
# keys not recognised WILL print "UNKNOWN 0x??", but this is useful for extra key scans
|
||||||
|
#
|
||||||
|
# WORK IN PROGRESS
|
||||||
|
# CTRL + S to save text to the SD Card
|
||||||
|
######
|
||||||
|
|
||||||
import board
|
import board
|
||||||
import terminalio
|
import terminalio
|
||||||
from adafruit_display_text import label
|
from adafruit_display_text import label
|
||||||
from keyboard import Keyboard
|
from keyboard import Keyboard
|
||||||
|
|
||||||
# GUIDE
|
import busio
|
||||||
# type freely! CTRL+D clears the text.
|
import sdcardio
|
||||||
# backspace, space, and return function as expected.
|
import storage
|
||||||
# keys not recognised WILL print "UNKNOWN 0x??", but this is useful for extra key scans
|
import os
|
||||||
######
|
|
||||||
|
## SD Card set up for saving text to SD card
|
||||||
|
spi = busio.SPI(board.SD_SCK, MOSI=board.SD_MOSI, MISO=board.SD_MISO)
|
||||||
|
cs = board.SD_CS
|
||||||
|
|
||||||
|
try:
|
||||||
|
sdcard = sdcardio.SDCard(spi, cs)
|
||||||
|
vfs = storage.VfsFat(sdcard)
|
||||||
|
|
||||||
|
storage.mount(vfs, "/sd") # access files on sd card here
|
||||||
|
SD_status = "SD Card Mounted"
|
||||||
|
except OSError:
|
||||||
|
SD_status = "No SD card found"
|
||||||
|
pass # SD card not inserted/found
|
||||||
|
#########################################
|
||||||
|
|
||||||
keyb = Keyboard()
|
keyb = Keyboard()
|
||||||
|
|
||||||
text = "Press CTRL+D to clear text\n\n"
|
text = "Press CTRL+D to clear text\n"+SD_status+"\n\n"
|
||||||
text_area = label.Label(terminalio.FONT, text=text)
|
text_area = label.Label(terminalio.FONT, text=text)
|
||||||
text_area.x = 10
|
text_area.x = 10
|
||||||
text_area.y = 10
|
text_area.y = 10
|
||||||
Reference in New Issue
Block a user