summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornasrlol <nsrddyn@gmail.com>2024-12-09 21:30:52 +0100
committernasrlol <nsrddyn@gmail.com>2024-12-09 21:30:52 +0100
commit2049c11d4f2f1b2bfa48c23b9eba6cb1babfc812 (patch)
tree6bdce13d8d2c9aa23e42a3d3ca97e52d547d9d44
parent9a390f7b41e980d05c1c05c669febc16f6826ecd (diff)
trying out a fix for the input handling with curses
-rw-r--r--source/features.py7
-rw-r--r--source/main_cli.py8
2 files changed, 12 insertions, 3 deletions
diff --git a/source/features.py b/source/features.py
index 7690feb..2d2d80e 100644
--- a/source/features.py
+++ b/source/features.py
@@ -3,6 +3,7 @@ import os
3import speech_recognition as sr 3import speech_recognition as sr
4from gpiozero import CPUTemperature 4from gpiozero import CPUTemperature
5import hardware_driver as lcd # importing the ./hardware_driver.py file 5import hardware_driver as lcd # importing the ./hardware_driver.py file
6from main_cli import input_handling
6 7
7# some functions need to be put on a different thread but we are keeping that project for another time 8# some functions need to be put on a different thread but we are keeping that project for another time
8# import threading 9# import threading
@@ -63,7 +64,7 @@ class feat:
63 def custom_greeting(self): 64 def custom_greeting(self):
64 self.clear_terminal_lcd() 65 self.clear_terminal_lcd()
65 try: 66 try:
66 with open("quotes.txt", "r") as file: 67 with open("../assets/text/quotes.txt", "r") as file:
67 quotes = [quote.strip() for quote in file.readlines()] 68 quotes = [quote.strip() for quote in file.readlines()]
68 except FileNotFoundError: 69 except FileNotFoundError:
69 L.text("Quotes file missing", 1) 70 L.text("Quotes file missing", 1)
@@ -152,11 +153,11 @@ class feat:
152 print("Error:", e) 153 print("Error:", e)
153 return None 154 return None
154 155
155 def save_notes(self): 156 def save_notes(self, input_handling):
156 self.clear_terminal_lcd() 157 self.clear_terminal_lcd()
157 print("Type your notes (type 'stop' to exit):") 158 print("Type your notes (type 'stop' to exit):")
158 while True: 159 while True:
159 note = input(": ") 160 note = input_handling(": ")
160 if note.lower() in ["stop", "exit", "quit"]: 161 if note.lower() in ["stop", "exit", "quit"]:
161 break 162 break
162 first_line = note[:16] 163 first_line = note[:16]
diff --git a/source/main_cli.py b/source/main_cli.py
index 53f49aa..b474551 100644
--- a/source/main_cli.py
+++ b/source/main_cli.py
@@ -98,6 +98,14 @@ def draw_menu(stdscr):
98 break # Exit the while loop and terminate the program 98 break # Exit the while loop and terminate the program
99 99
100 100
101def input_handling():
102 while True:
103 key = stdscr.getkey()
104 stdcr.addstr(f"key: {key}")
105 stdcr.refresh()
106 stdcr.getch()
107
108
101def main(): 109def main():
102 """ 110 """
103 The main function wraps the curses functionality and runs the application. 111 The main function wraps the curses functionality and runs the application.