First version of the SYSTEM module

This commit is contained in:
Bo⋆˚✿˖° 2025-09-22 15:44:24 +02:00
parent fc2af7031e
commit 9f61b54f15
Signed by: FreedTapestry21
GPG key ID: 5E19D8C7E935C480
3 changed files with 132 additions and 16 deletions

34
main.py
View file

@ -2,9 +2,12 @@
# Petcard Bootloader - v1.0
# Copyright (c) 2025 FreedTapestry21
#
# Licensed under the MIT license
#
from machine import Pin
import network, urequest, machine
import machine
#import network, urequest, machine
# Define variables
CONSOLE_WELCOME = """
@ -37,12 +40,13 @@ def connect(ssid, psk):
pass
def boot():
import system
init()
print("Loading system...")
with open("petcard.py") as app:
exec(app.read())
# Check if button is pressed for recovery/update process
if __name__ == '__main__':
def main():
print(CONSOLE_WELCOME)
UPDATE = False
if ok.value() == 1:
UPDATE = True
@ -51,21 +55,29 @@ if __name__ == '__main__':
inp = input("Are you sure you want to enter the Petcard recovery process? (y/N)")
if inp == "" or inp == "n" or inp == "N":
print("Rebooting to resume boot process...")
machine.soft_reset()
if inp == "y" or inp == "Y":
print("Entering Petcard recovery process...")
print("Please enter your Wi-Fi credentials")
ssid = input("SSID: ")
psk = input("Password: ")
connect(ssid, psk)
#connect(ssid, psk)
print('Connected to network "' + str(ssid) + '"')
# Downloading system.py
download("system.py", "Petcard system")
download("petcard.py", "Petcard")
# Disabled due to being stuck with a Pico for now
#download("system.py", "Petcard system")
#download("petcard.py", "Petcard")
print("System recovery complete, restarting system...")
machine.reset()
machine.soft_reset()
else:
print("'" + inp + "' is not recognized as an option! Rebooting...")
machine.reset()
machine.soft_reset()
else:
boot()
boot()
# Check if button is pressed for recovery/update process
if __name__ == '__main__':
main()