First Upload

0.6 Alpha offers minimal core functionality.
This commit is contained in:
Zahkc 2023-07-03 21:09:16 +10:00 committed by GitHub
parent a66ee57176
commit 769c1cbc05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 192 additions and 0 deletions

1
Save/current.json Normal file
View File

@ -0,0 +1 @@
TestTestTake 2Take 2Take 2Take 2

BIN
Sprites/Backgrounds/bg1.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

3
boot_out.txt Normal file
View File

@ -0,0 +1,3 @@
Adafruit CircuitPython 8.1.0 on 2023-05-22; Adafruit Feather ESP32-S2 Reverse TFT with ESP32S2
Board ID:adafruit_feather_esp32s2_reverse_tft
UID:0740D17FA749

76
code.py Normal file
View File

@ -0,0 +1,76 @@
import time
import alarm
import board
import displayio
import digitalio
import bitmaptools
import adafruit_imageload
import menu
import selector
import buttonBus
#screen /dev/ttyACM0 115200
#setup
board.DISPLAY.root_group.hidden = False
board.DISPLAY.rotation = 90
splash = displayio.Group()
board.DISPLAY.show(splash)
bg, bgPallette = adafruit_imageload.load("/Sprites/Backgrounds/bg1.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette)
bgTile = displayio.TileGrid(bg, pixel_shader=bgPallette)
tama, tamaPallette = adafruit_imageload.load("/Sprites/Characters/MUSH/ADULT/BODY.BMP", bitmap=displayio.Bitmap, palette=displayio.Palette)
tamaPallette.make_transparent(3)
tamaTile = displayio.TileGrid(tama, pixel_shader=tamaPallette, x=20, y=100)
splash.append(bgTile)
splash.append(tamaTile)
bounce = False
bounceAmount = -10
selector.showSelector(splash)
#Menu Activites
def do(x):
if x == 0:
pass
elif x == 1:
pass
elif x == 2:
pass
elif x == 3:
pass
elif x == 4:
menu.toggleMenu(splash)
elif x == 5:
buttonBus.button1.deinit()
pin_alarm = alarm.pin.PinAlarm(pin=board.D1, value=True, pull=True)
time.sleep(0.5)
alarm.exit_and_deep_sleep_until_alarms(pin_alarm)
#System Loop
while True:
if(round(time.monotonic()%0.5, 1) == 0.5):
if bounce == False:
bounce = True
bounceAmount = bounceAmount * -1
tamaTile.y += bounceAmount
else:
if bounce == True:
bounce = False
if buttonBus.getSelectedButton() == 0:
selector.lastPos()
time.sleep(0.2)
elif buttonBus.getSelectedButton() == 1:
do(selector.spos)
time.sleep(0.2)
elif buttonBus.getSelectedButton() == 2:
selector.nextPos()
time.sleep(0.2)

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/adafruit_max1704x.mpy Normal file

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

21
lib/buttonBus.py Normal file
View File

@ -0,0 +1,21 @@
import digitalio
import board
import time
button0 = digitalio.DigitalInOut(board.D0)
button0.direction = digitalio.Direction.INPUT
button0.pull = digitalio.Pull.UP
button1 = digitalio.DigitalInOut(board.D1)
button1.direction = digitalio.Direction.INPUT
button1.pull = digitalio.Pull.DOWN
button2 = digitalio.DigitalInOut(board.D2)
button2.direction = digitalio.Direction.INPUT
button2.pull = digitalio.Pull.DOWN
def getSelectedButton():
if not button0.value:
return 0
elif button1.value:
return 1
elif button2.value:
return 2

28
lib/menu.py Normal file
View File

@ -0,0 +1,28 @@
import board
import adafruit_max1704x
import time
import terminalio
import displayio
from adafruit_display_shapes.rect import Rect
from adafruit_display_text import bitmap_label, wrap_text_to_lines
menuToggle = True
battery = adafruit_max1704x.MAX17048(board.I2C())
def toggleMenu(splash):
global menuToggle
global battery
if menuToggle:
battery.reset()
time.sleep(0.05)
timeText = bitmap_label.Label(terminalio.FONT, text="Time: " + str(time.time() - 946684800), scale=1, color=0x000000, x=25, y=60)
batText = bitmap_label.Label(terminalio.FONT, text="Battery: " + str(round(battery.cell_percent)) + "%", scale=1, color=0x000000, x=25, y=80)
menuGroup = displayio.Group()
menuGroup.append(Rect(10, 10, 115, 220, fill=0xFFFFFF, outline=0x000000, stroke=2))
menuGroup.append(bitmap_label.Label(terminalio.FONT, text="Menu", scale=2, color=0x000000, x=30, y=30))
menuGroup.append(timeText)
menuGroup.append(batText)
splash.append(menuGroup)
else:
splash.pop()
menuToggle ^= True

16
lib/save.py Normal file
View File

@ -0,0 +1,16 @@
import storage
import supervisor
import microcontroller
try:
storage.remount("/", supervisor.runtime.usb_connected)
except RuntimeError as E:
print("PC Mode")
microcontroller.reset()
try:
with open("/Save/current.json", "a") as save:
save.write("Take 2")
save.flush()
except OSError as E:
print("READ ONLY")
print(E)

47
lib/selector.py Normal file
View File

@ -0,0 +1,47 @@
from adafruit_display_shapes.circle import Circle
spos = -1
select = Circle(15, 10, 10, outline=0x000000, stroke=2)
def showSelector(splash):
global spos
if spos == -1:
splash.append(select)
spos += 1
print("added")
def hideSelector(splash):
global spos
if spos != -1:
splash.pop()
def nextPos():
global spos
spos = (spos + 1) % 6
updatePos()
def lastPos():
global spos
spos = (spos - 1) % 6
updatePos()
def updatePos():
global select
if spos == 0:
select.x = 5
select.y = 0
elif spos == 1:
select.x = 40
select.y = 0
elif spos == 2:
select.x = 70
select.y = 0
elif spos == 3:
select.x = 90
select.y = 0
elif spos == 4:
select.x = 0
select.y = 220
elif spos == 5:
select.x = 110
select.y = 220

0
settings.toml Normal file
View File