import time
import json
import random
#Coder Ravi
# ==================================================
# DISPLAY PLACEHOLDER (Replace with TFT draw later)
# ==================================================
def clear():
print("\n" * 6)
def show(text):
print(text)
# ==================================================
# STORAGE
# ==================================================
FILE = "students.json"
def load_data():
try:
with open(FILE, "r") as f:
return json.load(f)
except:
return {}
def save_data(data):
with open(FILE, "w") as f:
json.dump(data, f)
# ==================================================
# MOTIVATION QUOTES
# ==================================================
LOCAL_QUOTES = [
"Focus builds the future.",
"Small focus, big success.",
"Discipline beats motivation.",
"One task at a time."
]
def get_ai_quote():
# Placeholder – fetched from laptop via Wi-Fi
return "A curious mind with a purpose… -CoderRavi"
# ==================================================
# AUTHENTICATION
# ==================================================
def login():
data = load_data()
clear()
show("SMART STUDY TABLE")
show("------------------")
student_id = input("Enter Student ID: ")
if student_id not in data:
data[student_id] = {
"tasks": [],
"notes": ""
}
save_data(data)
show("New student profile created")
show("Login successful")
time.sleep(1)
return student_id
# ==================================================
# TASK MANAGEMENT
# ==================================================
def tasks_menu(student_id):
data = load_data()
tasks = data[student_id]["tasks"]
while True:
clear()
show("TASK LIST")
show("---------")
for i, task in enumerate(tasks):
symbol = "✔" if task["done"] else "✖"
show(f"{i+1}. {symbol} {task['text']}")
show("------------------")
show("1:Add Task")
show("2:Toggle Complete")
show("3:Back")
ch = input("> ")
if ch == "1":
text = input("New Task: ")
tasks.append({"text": text, "done": False})
save_data(data)
elif ch == "2":
idx = int(input("Task number: ")) - 1
if 0 <= idx < len(tasks):
tasks[idx]["done"] = not tasks[idx]["done"]
save_data(data)
elif ch == "3":
break
# ==================================================
# NOTES
# ==================================================
def notes_menu(student_id):
data = load_data()
clear()
show("NOTES")
show("-----")
show(data[student_id]["notes"])
show("------------------")
ch = input("1:Edit 2:Back > ")
if ch == "1":
data[student_id]["notes"] = input("Write note: ")
save_data(data)
# ==================================================
# STUDY TIMER (ADVANCED)
# ==================================================
def study_timer():
clear()
minutes = int(input("Set minutes: "))
total = minutes * 60
remaining = total
running = True
while remaining > 0:
clear()
mins = remaining // 60
secs = remaining % 60
show(f"TIMER: {mins:02d}:{secs:02d}")
show("1:Pause 2:Reset 3:Exit")
start = time.time()
while time.time() - start < 1:
pass
if running:
remaining -= 1
if input("") == "1":
running = False
show("PAUSED")
ch = input("1:Resume 2:Reset 3:Exit > ")
if ch == "1":
running = True
elif ch == "2":
remaining = total
running = True
elif ch == "3":
return
elif input("") == "2":
remaining = total
elif input("") == "3":
return
show("STUDY SESSION COMPLETE!")
time.sleep(2)
# ==================================================
# STATUS SCREEN (POSTURE + FOCUS)
# ==================================================
def status_screen(posture_status, focus_status):
clear()
# POSTURE
if posture_status == "BAD":
show("POSTURE: BAD")
show("😞 Sit Straight!")
else:
show("POSTURE: GOOD")
show("😊 Good Job")
show("------------------")
# FOCUS
if focus_status == "BAD":
show("FOCUS: LOW")
quote = random.choice(LOCAL_QUOTES)
show("Motivation:")
show(quote)
else:
show("FOCUS: GOOD")
show("Keep Going!")
time.sleep(3)
# ==================================================
# HOME MENU
# ==================================================
def home(student_id):
while True:
clear()
show(f"STUDENT: {student_id}")
show("------------------")
show("1.Tasks")
show("2.Notes")
show("3.Study Timer")
show("4.Status")
show("5.Logout")
ch = input("> ")
if ch == "1":
tasks_menu(student_id)
elif ch == "2":
notes_menu(student_id)
elif ch == "3":
study_timer()
elif ch == "4":
# Dummy sensor values for demo
posture_status = random.choice(["GOOD", "BAD"])
focus_status = random.choice(["GOOD", "BAD"])
status_screen(posture_status, focus_status)
elif ch == "5":
break
# ==================================================
# MAIN LOOP
# ==================================================
while True:
user = login()
home(user)