Viper Os
This is a micropython ide/terminal based operating system for the raspberry pi pico that can run up to to different apps stored on the pico as long as they have a certain name so the file system can identify it it also has features like a wordpad mode where you can use it for office work and can save it as a txt file it also has a bible verse feature where you can get daily bible verses and more will be added as well as a integrated trivia game a file viewer that can also allow you to open files as well as logfile features and much more.
Source Code
import os
import sys
import random
#import machine
def menu():
print ("type a option into the integrated terminal")
print ("IMPORTANT: if the terminal hangs, press Ctrl+D")
print ("to run app 1 type 'vipe1' ... to run app 10 type 'vipe10'")
print ("to generate a log file type 'logfile'")
print ("to get a description type 'about'")
print ("to open wordpad type 'wordpad' (type 'saveword' inside to save/exit)")
print ("to play a game type 'game1'")
print ("to view all files type 'ld'")
print ("to shut down type 'shutdown'")
print ("for a random bible verse type 'bibleverse'")
print ("----------------------------------")
def bootScreen():
print("""
.
.. ..
.. ..
.......... ..
.. ..........
.. ..
...
.
. .
""")
bootInput = input("viper os press any key to boot")
menu()
def fileBrowser():
print (os.listdir())
fileName = input ("user>>")
try:
with open (fileName, 'r') as file:
content = file.read()
print("File content:\n", content)
except OSError:
print ("unknown file")
except Exception as e:
print ("error")
input ("press any key to boot back to the main shell")
menu()
def wordpad():
print("--- WORDPAD MODE ---")
print("Type anything. Type 'saveword' to save and return to shell.")
session_text = []
while True:
userText = input("| ")
if userText.lower() == "saveword":
with open('wordpad.txt', 'a') as f:
# Joins all lines typed and saves them
f.write("\n" + "\n".join(session_text))
print("FILES ARE SAVING TO: " + os.getcwd())
print("File has been successfully saved to wordpad.txt")
break
else:
session_text.append(userText)
print(userText)
menu()
def trivia():
print ("raspberry pi pico trivia challenge")
print ("question 1: what is the cpu of the raspberry pi pico called?")
print ("a-rp2040 b-pico5427 c-raspberry cpu d-pi controller")
userAnswer = input("answer:")
if userAnswer.lower() == "rp2040" or userAnswer.lower() == "a":
print ("right!")
else:
print ("incorrect!")
menu()
def bibleverse():
verses = [
"For God so loved the world... - John 3:16",
"The Lord is my shepherd; I shall not want. - Psalm 23:1",
"I can do all things through Christ... - Philippians 4:13",
"Trust in the Lord with all your heart... - Proverbs 3:5",
"In the beginning, God created the heavens... - Genesis 1:1"
]
print(random.choice(verses))
verseInput = input("press any button to boot back to the terminal")
menu()
menu()
try:
while True:
user_Input = input ("type in your command below: ")
if user_Input.lower() == "vipe1":
exec(open('vipe1.py').read())
elif user_Input.lower() == "vipe2":
exec(open('vipe2.py').read())
# ... (Repeat for vipe3 through vipe10)
elif user_Input.lower() == "shutdown":
sys.exit()
elif user_Input.lower() == "logfile":
with open('logs.txt', 'a') as f:
f.write('\nNew log entry')
print("Log entry created.")
elif user_Input.lower() == "ld":
fileBrowser()
elif user_Input.lower() == "about":
print ("Viper OS is a MicroPython based shell for the RPi Pico")
input ("press any key to continue")
menu()
elif user_Input.lower() == "wordpad":
wordpad()
elif user_Input.lower() == "game1":
trivia()
elif user_Input.lower() == "restart":
bootScreen()
elif user_Input.lower() == "bibleverse":
bibleverse()
else:
print ("System Error: please enter a valid command")
menu()
except Exception as e:
print ("An error occurred:", e)