diff options
| author | Abdellah El Morabit <nsrddyn@gmail.com> | 2024-12-02 15:21:05 +0100 |
|---|---|---|
| committer | Abdellah El Morabit <nsrddyn@gmail.com> | 2024-12-02 15:21:05 +0100 |
| commit | 2924fb2486c9c1a66d8b04bf4b5748db83293db3 (patch) | |
| tree | a14ff763506008477db03f93025ebdd4540443ee /source | |
| parent | e7ddeccd096c54a31f1354ff9b6d8be9ebb4e6af (diff) | |
fixed the features initalizition bug
Diffstat (limited to 'source')
| -rw-r--r-- | source/features.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/source/features.py b/source/features.py index c5e532f..c5a8811 100644 --- a/source/features.py +++ b/source/features.py | |||
| @@ -40,7 +40,6 @@ class fe: | |||
| 40 | def __init__(self): | 40 | def __init__(self): |
| 41 | self.clear_terminal = clear_terminal() | 41 | self.clear_terminal = clear_terminal() |
| 42 | self.custom_greeting = custom_greeting() | 42 | self.custom_greeting = custom_greeting() |
| 43 | self.joke_of_the_day = joke_of_the_day() | ||
| 44 | self.pomodoro = pomodoro() | 43 | self.pomodoro = pomodoro() |
| 45 | self.system_readings = system_readings() | 44 | self.system_readings = system_readings() |
| 46 | self.display_uptime = display_uptime() | 45 | self.display_uptime = display_uptime() |
| @@ -49,11 +48,11 @@ class fe: | |||
| 49 | self.command_center = command_center() | 48 | self.command_center = command_center() |
| 50 | 49 | ||
| 51 | # clearing the terminal for a cleaner and program like interaction | 50 | # clearing the terminal for a cleaner and program like interaction |
| 52 | def clear_terminal(): | 51 | def clear_terminal(self): |
| 53 | os.system("cls" if os.name == "nt" else "clear") | 52 | os.system("cls" if os.name == "nt" else "clear") |
| 54 | 53 | ||
| 55 | # Features | 54 | # Features |
| 56 | def custom_greeting(): | 55 | def custom_greeting(self): |
| 57 | try: | 56 | try: |
| 58 | with open("quotes.txt", "r") as file: | 57 | with open("quotes.txt", "r") as file: |
| 59 | quotes = [quote.strip() for quote in file.readlines()] | 58 | quotes = [quote.strip() for quote in file.readlines()] |
| @@ -69,10 +68,8 @@ class fe: | |||
| 69 | time.sleep(3) | 68 | time.sleep(3) |
| 70 | lcd_instance.clear() | 69 | lcd_instance.clear() |
| 71 | 70 | ||
| 72 | def joke_of_the_day(): | ||
| 73 | pass | ||
| 74 | 71 | ||
| 75 | def pomodoro(): | 72 | def pomodoro(self): |
| 76 | try: | 73 | try: |
| 77 | duration_minutes = int(input("Enter duration in minutes: ")) | 74 | duration_minutes = int(input("Enter duration in minutes: ")) |
| 78 | duration_seconds = duration_minutes * 60 | 75 | duration_seconds = duration_minutes * 60 |
| @@ -97,7 +94,7 @@ class fe: | |||
| 97 | lcd_instance.text("Invalid input", 1) | 94 | lcd_instance.text("Invalid input", 1) |
| 98 | time.sleep(2) | 95 | time.sleep(2) |
| 99 | 96 | ||
| 100 | def system_readings(): | 97 | def system_readings(self): |
| 101 | while True: | 98 | while True: |
| 102 | load = os.getloadavg()[0] | 99 | load = os.getloadavg()[0] |
| 103 | temperature = cpu_temp.temperature if cpu_temp else "N/A" | 100 | temperature = cpu_temp.temperature if cpu_temp else "N/A" |
| @@ -106,7 +103,7 @@ class fe: | |||
| 106 | lcd_instance.text(f"Temp: {temperature}C", 2) | 103 | lcd_instance.text(f"Temp: {temperature}C", 2) |
| 107 | time.sleep(5) | 104 | time.sleep(5) |
| 108 | 105 | ||
| 109 | def display_uptime(): | 106 | def display_uptime(self): |
| 110 | try: | 107 | try: |
| 111 | with open("/proc/uptime") as f: | 108 | with open("/proc/uptime") as f: |
| 112 | uptime_seconds = float(f.readline().split()[0]) | 109 | uptime_seconds = float(f.readline().split()[0]) |
| @@ -117,7 +114,7 @@ class fe: | |||
| 117 | lcd_instance.text("Error reading uptime", 1) | 114 | lcd_instance.text("Error reading uptime", 1) |
| 118 | print("Error:", e) | 115 | print("Error:", e) |
| 119 | 116 | ||
| 120 | def recognize_speech(): | 117 | def recognize_speech(self): |
| 121 | lcd_instance.text("Listening...", 1) | 118 | lcd_instance.text("Listening...", 1) |
| 122 | try: | 119 | try: |
| 123 | with microphone as source: | 120 | with microphone as source: |
| @@ -140,7 +137,7 @@ class fe: | |||
| 140 | print("Error:", e) | 137 | print("Error:", e) |
| 141 | return None | 138 | return None |
| 142 | 139 | ||
| 143 | def save_notes(): | 140 | def save_notes(self): |
| 144 | print("Type your notes (type 'stop' to exit):") | 141 | print("Type your notes (type 'stop' to exit):") |
| 145 | while True: | 142 | while True: |
| 146 | note = input(": ") | 143 | note = input(": ") |
| @@ -153,10 +150,10 @@ class fe: | |||
| 153 | time.sleep(3) | 150 | time.sleep(3) |
| 154 | 151 | ||
| 155 | # Command center to execute features | 152 | # Command center to execute features |
| 156 | def command_center(): | 153 | def command_center(self): |
| 157 | command = recognize_speech().upper() | 154 | command = recognize_speech().upper() |
| 158 | if command: | 155 | if command: |
| 159 | command() | 156 | self.command_center() |
| 160 | else: | 157 | else: |
| 161 | lcd_instance.text(ERROR_NOT_FOUND, 1) | 158 | lcd_instance.text(ERROR_NOT_FOUND, 1) |
| 162 | print(ERROR_NOT_FOUND) | 159 | print(ERROR_NOT_FOUND) |
