diff options
| author | Abdellah El Morabit <nsrddyn@gmail.com> | 2024-11-14 19:31:03 +0100 |
|---|---|---|
| committer | Abdellah El Morabit <nsrddyn@gmail.com> | 2024-11-14 19:31:03 +0100 |
| commit | fe441f69a4632e5245588574923ef8dc467eced5 (patch) | |
| tree | c9975c3b706a4c810ba975c2884c748d7255c770 | |
| parent | 9ebcbfc83a64b8a27d0725dbd12f6a8fdb042934 (diff) | |
tried implementing ollama
| -rw-r--r-- | I2C/I2C.xcodeproj/project.xcworkspace/xcuserdata/nsrddyn.xcuserdatad/UserInterfaceState.xcuserstate | bin | 28421 -> 37489 bytes | |||
| -rw-r--r-- | I2C/I2C.xcodeproj/xcuserdata/nsrddyn.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist | 40 | ||||
| -rw-r--r-- | I2C/I2C/ContentView.swift | 27 | ||||
| -rw-r--r-- | I2C/I2CUITests/I2CUITests.swift | 1 | ||||
| -rw-r--r-- | bin/__pycache__/source.cpython-313.pyc | bin | 0 -> 5737 bytes | |||
| -rw-r--r-- | bin/i2c.py | 47 | ||||
| -rw-r--r-- | bin/icon.png | bin | 3754 -> 0 bytes | |||
| -rw-r--r-- | bin/kasper_gui.py | 6 | ||||
| -rw-r--r-- | bin/kasper_source.py | 154 | ||||
| -rw-r--r-- | bin/main.py | 9 | ||||
| -rw-r--r-- | bin/source.py | 128 | ||||
| -rw-r--r-- | webconsole/index.html | 12 | ||||
| -rw-r--r-- | webconsole/main.js | 0 |
13 files changed, 241 insertions, 183 deletions
diff --git a/I2C/I2C.xcodeproj/project.xcworkspace/xcuserdata/nsrddyn.xcuserdatad/UserInterfaceState.xcuserstate b/I2C/I2C.xcodeproj/project.xcworkspace/xcuserdata/nsrddyn.xcuserdatad/UserInterfaceState.xcuserstate index 78be191..07340b1 100644 --- a/I2C/I2C.xcodeproj/project.xcworkspace/xcuserdata/nsrddyn.xcuserdatad/UserInterfaceState.xcuserstate +++ b/I2C/I2C.xcodeproj/project.xcworkspace/xcuserdata/nsrddyn.xcuserdatad/UserInterfaceState.xcuserstate | |||
| Binary files differ | |||
diff --git a/I2C/I2C.xcodeproj/xcuserdata/nsrddyn.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/I2C/I2C.xcodeproj/xcuserdata/nsrddyn.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..214cbf9 --- /dev/null +++ b/I2C/I2C.xcodeproj/xcuserdata/nsrddyn.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <Bucket | ||
| 3 | uuid = "E25B4326-8E67-45A7-85E6-44F99F067B3F" | ||
| 4 | type = "1" | ||
| 5 | version = "2.0"> | ||
| 6 | <Breakpoints> | ||
| 7 | <BreakpointProxy | ||
| 8 | BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
| 9 | <BreakpointContent | ||
| 10 | uuid = "CDFF4D12-343E-452F-9711-F46A454AB787" | ||
| 11 | shouldBeEnabled = "Yes" | ||
| 12 | ignoreCount = "0" | ||
| 13 | continueAfterRunningActions = "No" | ||
| 14 | filePath = "I2C/ContentView.swift" | ||
| 15 | startingColumnNumber = "9223372036854775807" | ||
| 16 | endingColumnNumber = "9223372036854775807" | ||
| 17 | startingLineNumber = "12" | ||
| 18 | endingLineNumber = "12" | ||
| 19 | landmarkName = "body" | ||
| 20 | landmarkType = "24"> | ||
| 21 | </BreakpointContent> | ||
| 22 | </BreakpointProxy> | ||
| 23 | <BreakpointProxy | ||
| 24 | BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
| 25 | <BreakpointContent | ||
| 26 | uuid = "D2C0A7B9-3CCF-4EDE-B649-263CFF06097B" | ||
| 27 | shouldBeEnabled = "Yes" | ||
| 28 | ignoreCount = "0" | ||
| 29 | continueAfterRunningActions = "No" | ||
| 30 | filePath = "I2CUITests/I2CUITests.swift" | ||
| 31 | startingColumnNumber = "9223372036854775807" | ||
| 32 | endingColumnNumber = "9223372036854775807" | ||
| 33 | startingLineNumber = "19" | ||
| 34 | endingLineNumber = "19" | ||
| 35 | landmarkName = "I2CUITests" | ||
| 36 | landmarkType = "3"> | ||
| 37 | </BreakpointContent> | ||
| 38 | </BreakpointProxy> | ||
| 39 | </Breakpoints> | ||
| 40 | </Bucket> | ||
diff --git a/I2C/I2C/ContentView.swift b/I2C/I2C/ContentView.swift index e21bcb2..6d0448d 100644 --- a/I2C/I2C/ContentView.swift +++ b/I2C/I2C/ContentView.swift | |||
| @@ -1,34 +1,17 @@ | |||
| 1 | import SwiftUI | 1 | import SwiftUI |
| 2 | 2 | ||
| 3 | struct ContentView: View { | 3 | struct ContentView: View { |
| 4 | var header: some View { | 4 | let options = ["CPU INFO", "CPU UPTIME", "SPEECH TRANSCRIBER", "NOTES"] |
| 5 | VStack { | ||
| 6 | Text("Hello world!") | ||
| 7 | } | ||
| 8 | |||
| 9 | } | ||
| 10 | var body: some View { | 5 | var body: some View { |
| 11 | VStack { | 6 | VStack { |
| 12 | Circle() | 7 | Button( |
| 13 | .fill(.blue) | 8 | RoundedRectangle(cornerRadius: 25) |
| 14 | .frame(width: 100, height: 100) | 9 | .fill(Color.red) |
| 15 | .padding() | 10 | ) |
| 16 | header | ||
| 17 | Button("VOICE RECOGNITION"){ | ||
| 18 | |||
| 19 | } | ||
| 20 | Button("CPU UPTIME"){ | ||
| 21 | |||
| 22 | } | ||
| 23 | Button("CPU INFO"){ | ||
| 24 | |||
| 25 | } | ||
| 26 | } | 11 | } |
| 27 | } | 12 | } |
| 28 | } | 13 | } |
| 29 | 14 | ||
| 30 | |||
| 31 | |||
| 32 | #Preview { | 15 | #Preview { |
| 33 | ContentView() | 16 | ContentView() |
| 34 | } | 17 | } |
diff --git a/I2C/I2CUITests/I2CUITests.swift b/I2C/I2CUITests/I2CUITests.swift index c225d79..a98bb08 100644 --- a/I2C/I2CUITests/I2CUITests.swift +++ b/I2C/I2CUITests/I2CUITests.swift | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | // I2CUITests | 3 | // I2CUITests |
| 4 | // | 4 | // |
| 5 | // Created by nsrddyn on 09/11/2024. | 5 | // Created by nsrddyn on 09/11/2024. |
| 6 | // | ||
| 7 | 6 | ||
| 8 | import XCTest | 7 | import XCTest |
| 9 | 8 | ||
diff --git a/bin/__pycache__/source.cpython-313.pyc b/bin/__pycache__/source.cpython-313.pyc new file mode 100644 index 0000000..79aee1d --- /dev/null +++ b/bin/__pycache__/source.cpython-313.pyc | |||
| Binary files differ | |||
diff --git a/bin/i2c.py b/bin/i2c.py new file mode 100644 index 0000000..a79d9d1 --- /dev/null +++ b/bin/i2c.py | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | import smbus2 as SMBus | ||
| 2 | import time | ||
| 3 | |||
| 4 | LCD_BACKLIGHT = 0x08 | ||
| 5 | LCD_NOBACKLIGHT = 0x00 | ||
| 6 | ENABLE_BIT = 0b00000100 | ||
| 7 | LINES = {1: 0x80, 2: 0xC0} | ||
| 8 | ALIGN_FUNC = {"left": "ljust", "right": "rjust", "center": "center"} | ||
| 9 | |||
| 10 | |||
| 11 | class LCD: | ||
| 12 | |||
| 13 | def __init__(self, address=0x27, bus=1, width=20, rows=4, backlight=True): | ||
| 14 | self.address = address | ||
| 15 | self.bus = SMBus(bus) | ||
| 16 | self.width = width | ||
| 17 | self.rows = rows | ||
| 18 | self.backlight_status = backlight | ||
| 19 | self.delay = 0.0005 | ||
| 20 | |||
| 21 | for cmd in (0x33, 0x32, 0x06, 0x0C, 0x28, 0x01): | ||
| 22 | self.write(cmd) | ||
| 23 | time.sleep(self.delay) | ||
| 24 | |||
| 25 | def write(self, byte, mode=0): | ||
| 26 | backlight = LCD_BACKLIGHT if self.backlight_status else LCD_NOBACKLIGHT | ||
| 27 | self._write_byte(mode | ((byte << 4) & 0xF0) | backlight) | ||
| 28 | |||
| 29 | def _write_byte(self, byte): | ||
| 30 | self.bus.write_byte(self.address, byte) | ||
| 31 | self.bus.write_byte(self.address, (byte | ENABLE_BIT)) | ||
| 32 | time.sleep(self.delay) | ||
| 33 | self.bus.write_byte(self.address, (byte & ~ENABLE_BIT)) | ||
| 34 | time.sleep(self.delay) | ||
| 35 | |||
| 36 | def display_text(self, text, line=1, align="left"): | ||
| 37 | self.write(LINES.get(line, LINES[1])) | ||
| 38 | aligned_text = getattr(text, ALIGN_FUNC.get(align, "ljust"))(self.width) | ||
| 39 | for char in aligned_text: | ||
| 40 | self.write(ord(char), mode=1) | ||
| 41 | |||
| 42 | def clear(self): | ||
| 43 | self.write(0x01) | ||
| 44 | |||
| 45 | def set_backlight(self, turn_on=True): | ||
| 46 | self.backlight_status = turn_on | ||
| 47 | self.write(0) | ||
diff --git a/bin/icon.png b/bin/icon.png deleted file mode 100644 index c372c49..0000000 --- a/bin/icon.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/bin/kasper_gui.py b/bin/kasper_gui.py deleted file mode 100644 index e5edc6a..0000000 --- a/bin/kasper_gui.py +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | import tkinter | ||
| 2 | |||
| 3 | display = tkinter.Tk() | ||
| 4 | display.title("Kasper") | ||
| 5 | |||
| 6 | display.mainloop() \ No newline at end of file | ||
diff --git a/bin/kasper_source.py b/bin/kasper_source.py deleted file mode 100644 index 8067997..0000000 --- a/bin/kasper_source.py +++ /dev/null | |||
| @@ -1,154 +0,0 @@ | |||
| 1 | from smbus import SMBus | ||
| 2 | from gpiozero import CPUTemperature | ||
| 3 | import speech_recognition as speech | ||
| 4 | import os | ||
| 5 | import time | ||
| 6 | from time import sleep | ||
| 7 | |||
| 8 | # LCD Constants | ||
| 9 | LCD_BACKLIGHT = 0x08 | ||
| 10 | LCD_NOBACKLIGHT = 0x00 | ||
| 11 | ENABLE_BIT = 0b00000100 | ||
| 12 | LINES = {1: 0x80, 2: 0xC0, 3: 0x94, 4: 0xD4} | ||
| 13 | ALIGN_FUNC = {"left": "ljust", "right": "rjust", "center": "center"} | ||
| 14 | |||
| 15 | # Error Messages | ||
| 16 | ERROR_BAD_REQUEST = "400 Bad Request" | ||
| 17 | ERROR_UNAUTHORIZED = "401 Unauthorized" | ||
| 18 | ERROR_NOT_FOUND = "404 Not Found" | ||
| 19 | ERROR_TIMEOUT = "408 Request Timeout" | ||
| 20 | |||
| 21 | # LCD Control Class | ||
| 22 | class LCD: | ||
| 23 | |||
| 24 | def __init__(self, address=0x27, bus=1, width=20, rows=4, backlight=True): | ||
| 25 | self.address = address | ||
| 26 | self.bus = SMBus(bus) | ||
| 27 | self.width = width | ||
| 28 | self.rows = rows | ||
| 29 | self.backlight_status = backlight | ||
| 30 | self.delay = 0.0005 | ||
| 31 | |||
| 32 | # LCD Initialization | ||
| 33 | for cmd in (0x33, 0x32, 0x06, 0x0C, 0x28, 0x01): | ||
| 34 | self.write(cmd) | ||
| 35 | time.sleep(self.delay) | ||
| 36 | |||
| 37 | def write(self, byte, mode=0): | ||
| 38 | """Send a command or character to the LCD.""" | ||
| 39 | backlight = LCD_BACKLIGHT if self.backlight_status else LCD_NOBACKLIGHT | ||
| 40 | self._write_byte(mode | ((byte << 4) & 0xF0) | backlight) | ||
| 41 | |||
| 42 | def _write_byte(self, byte): | ||
| 43 | """Write a byte to the I2C bus.""" | ||
| 44 | self.bus.write_byte(self.address, byte) | ||
| 45 | self.bus.write_byte(self.address, (byte | ENABLE_BIT)) | ||
| 46 | time.sleep(self.delay) | ||
| 47 | self.bus.write_byte(self.address, (byte & ~ENABLE_BIT)) | ||
| 48 | time.sleep(self.delay) | ||
| 49 | |||
| 50 | def display_text(self, text, line=1, align="left"): | ||
| 51 | """Display text on a specified line with alignment.""" | ||
| 52 | self.write(LINES.get(line, LINES[1])) | ||
| 53 | aligned_text = getattr(text, ALIGN_FUNC.get(align, "ljust"))(self.width) | ||
| 54 | for char in aligned_text: | ||
| 55 | self.write(ord(char), mode=1) | ||
| 56 | |||
| 57 | def clear(self): | ||
| 58 | """Clear the display.""" | ||
| 59 | self.write(0x01) | ||
| 60 | |||
| 61 | def set_backlight(self, turn_on=True): | ||
| 62 | """Toggle backlight on or off.""" | ||
| 63 | self.backlight_status = turn_on | ||
| 64 | self.write(0) | ||
| 65 | |||
| 66 | # Initialize components | ||
| 67 | lcd = LCD() | ||
| 68 | cpu_temp = CPUTemperature() | ||
| 69 | recognizer = speech.Recognizer() | ||
| 70 | microphone = speech.Microphone() | ||
| 71 | |||
| 72 | |||
| 73 | # Display Functions | ||
| 74 | def display_cpu_info(): | ||
| 75 | # clearing the display before accessing it | ||
| 76 | lcd.clear() | ||
| 77 | """Display CPU load and temperature on the LCD.""" | ||
| 78 | while True: | ||
| 79 | load = os.getloadavg()[0] # 1-minute load average | ||
| 80 | temperature = cpu_temp.temperature | ||
| 81 | lcd.clear() | ||
| 82 | lcd.display_text(f"CPU Load: {load:.2f}", 1) | ||
| 83 | lcd.display_text(f"Temp: {temperature:.1f}C", 2) | ||
| 84 | time.sleep(5) | ||
| 85 | |||
| 86 | |||
| 87 | def display_uptime(): | ||
| 88 | # clearing the display before accessing it | ||
| 89 | lcd.clear() | ||
| 90 | """Display system uptime on the LCD.""" | ||
| 91 | with open("/proc/uptime") as f: | ||
| 92 | uptime_seconds = float(f.readline().split()[0]) | ||
| 93 | uptime_str = time.strftime("%H:%M:%S", time.gmtime(uptime_seconds)) | ||
| 94 | lcd.clear() | ||
| 95 | lcd.display_text(f"Uptime: {uptime_str}", 1) | ||
| 96 | |||
| 97 | |||
| 98 | def recognize_speech(): | ||
| 99 | # clearing the display before accessing it | ||
| 100 | lcd.clear() | ||
| 101 | """Capture and transcribe speech input.""" | ||
| 102 | try: | ||
| 103 | with microphone as source: | ||
| 104 | recognizer.adjust_for_ambient_noise(source) | ||
| 105 | print("Listening...") | ||
| 106 | audio = recognizer.listen(source) | ||
| 107 | text = recognizer.recognize_google(audio) | ||
| 108 | lcd.clear() | ||
| 109 | lcd.display_text(text, 1) | ||
| 110 | print("Speech recognized:", text) | ||
| 111 | except speech.UnknownValueError: | ||
| 112 | lcd.display_text(ERROR_BAD_REQUEST, 1) | ||
| 113 | print(ERROR_BAD_REQUEST) | ||
| 114 | except speech.RequestError: | ||
| 115 | lcd.display_text(ERROR_UNAUTHORIZED, 1) | ||
| 116 | print(ERROR_UNAUTHORIZED) | ||
| 117 | |||
| 118 | def notes(): | ||
| 119 | while True: | ||
| 120 | OUTPUT = input() | ||
| 121 | print(OUTPUT) | ||
| 122 | lcd.display_text(OUTPUT, 1) | ||
| 123 | sleep(2) | ||
| 124 | |||
| 125 | |||
| 126 | # Main Program Options | ||
| 127 | OPTIONS = { | ||
| 128 | "CPU_INFO": display_cpu_info, | ||
| 129 | "UPTIME": display_uptime, | ||
| 130 | "SPEECH_TRANSCRIBER": recognize_speech, | ||
| 131 | "NOTES": notes, | ||
| 132 | } | ||
| 133 | |||
| 134 | |||
| 135 | def main(): | ||
| 136 | # clearing the display before doing anything | ||
| 137 | lcd.clear() | ||
| 138 | # Main program loop to accept user commands. | ||
| 139 | print("WELCOME TO THE I2C COMMAND LINE CENTER") | ||
| 140 | print("Options:", ", ".join(OPTIONS.keys())) | ||
| 141 | |||
| 142 | while True: | ||
| 143 | user_input = input("Enter command: ").upper() | ||
| 144 | action = OPTIONS.get(user_input) | ||
| 145 | |||
| 146 | if action: | ||
| 147 | action() | ||
| 148 | else: | ||
| 149 | lcd.display_text(ERROR_NOT_FOUND, 1) | ||
| 150 | print(ERROR_NOT_FOUND) | ||
| 151 | |||
| 152 | |||
| 153 | if __name__ == "__main__": | ||
| 154 | main() | ||
diff --git a/bin/main.py b/bin/main.py new file mode 100644 index 0000000..2231547 --- /dev/null +++ b/bin/main.py | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | import tk | ||
| 2 | import source as main | ||
| 3 | |||
| 4 | source = main() | ||
| 5 | |||
| 6 | display = tk.Tk() | ||
| 7 | display.title("Kasper") | ||
| 8 | |||
| 9 | display.mainloop() \ No newline at end of file | ||
diff --git a/bin/source.py b/bin/source.py new file mode 100644 index 0000000..c232351 --- /dev/null +++ b/bin/source.py | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | import time | ||
| 2 | import os | ||
| 3 | import ollama | ||
| 4 | import speech_recognition as speech | ||
| 5 | import i2c as LCD | ||
| 6 | from gpiozero import CPUTemperature | ||
| 7 | |||
| 8 | ERROR_BAD_REQUEST = "400 Bad Request" | ||
| 9 | ERROR_UNAUTHORIZED = "401 Unauthorized" | ||
| 10 | ERROR_NOT_FOUND = "404 Not Found" | ||
| 11 | ERROR_TIMEOUT = "408 Request Timeout" | ||
| 12 | |||
| 13 | lcd = LCD() | ||
| 14 | cpu_temp = CPUTemperature() | ||
| 15 | lama = ollama() | ||
| 16 | recognizer = speech.Recognizer() | ||
| 17 | microphone = speech.Microphone() | ||
| 18 | |||
| 19 | |||
| 20 | def display_cpu_info(): | ||
| 21 | lcd.clear() | ||
| 22 | while True: | ||
| 23 | load = os.getloadavg()[0] # 1-minute load average | ||
| 24 | temperature = cpu_temp.temperature | ||
| 25 | lcd.clear() | ||
| 26 | lcd.display_text(f"CPU Load:i {load}", 1) | ||
| 27 | lcd.display_text(f"Temp: {temperature:}C", 2) | ||
| 28 | time.sleep(5) | ||
| 29 | |||
| 30 | |||
| 31 | def display_uptime(): | ||
| 32 | lcd.clear() | ||
| 33 | with open("/proc/uptime") as f: | ||
| 34 | uptime_seconds = float(f.readline().split()[0]) | ||
| 35 | uptime_str = time.strftime("%H:%M:%S", time.gmtime(uptime_seconds)) | ||
| 36 | lcd.clear() | ||
| 37 | lcd.display_text(f"Uptime: {uptime_str}", 1, "center") | ||
| 38 | |||
| 39 | |||
| 40 | def recognize_speech(): | ||
| 41 | lcd.clear() | ||
| 42 | try: | ||
| 43 | with microphone as source: | ||
| 44 | recognizer.adjust_for_ambient_noise(source) | ||
| 45 | print("Listening...") | ||
| 46 | audio = recognizer.listen(source) | ||
| 47 | text = recognizer.recognize_google(audio) | ||
| 48 | lcd.clear() | ||
| 49 | lcd.display_text(text, 1) | ||
| 50 | print("Speech recognized:", text) | ||
| 51 | except speech.UnknownValueError: | ||
| 52 | lcd.display_text(ERROR_BAD_REQUEST, 1) | ||
| 53 | print(ERROR_BAD_REQUEST) | ||
| 54 | except speech.RequestError: | ||
| 55 | lcd.display_text(ERROR_UNAUTHORIZED, 1) | ||
| 56 | print(ERROR_UNAUTHORIZED) | ||
| 57 | |||
| 58 | |||
| 59 | def save_notes(): | ||
| 60 | PRINT_REQUEST = True | ||
| 61 | EXIT_CODES = ['stop', 'break', 'quit', 'exit'] | ||
| 62 | if PRINT_REQUEST == True: | ||
| 63 | while True: | ||
| 64 | OUTPUT = input() | ||
| 65 | print(OUTPUT) | ||
| 66 | lcd.display_text(OUTPUT, 1) | ||
| 67 | time.sleep(2) | ||
| 68 | for i in EXIT_CODES: | ||
| 69 | if OUTPUT == i: | ||
| 70 | PRINT_REQUEST == False | ||
| 71 | |||
| 72 | def lama(): | ||
| 73 | QUESTION_REQUEST = True | ||
| 74 | while QUESTION_REQUEST == True: | ||
| 75 | QUESTION_REQUEST = input | ||
| 76 | ("do you want to ask a question") == 'yes' | ||
| 77 | if QUESTION_REQUEST == True: | ||
| 78 | USER_QUESTION = input() | ||
| 79 | response = lama.chat( | ||
| 80 | model="llama3.2", | ||
| 81 | messages=[ | ||
| 82 | { | ||
| 83 | "role": "user", | ||
| 84 | "content": USER_QUESTION, | ||
| 85 | }, | ||
| 86 | ], | ||
| 87 | ) | ||
| 88 | print(response["messages"]["content"]) | ||
| 89 | else: | ||
| 90 | break | ||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | OPTIONS = { | ||
| 95 | "LAMA": ollama(), | ||
| 96 | "CPU_INFO": display_cpu_info(), | ||
| 97 | "UPTIME": display_uptime(), | ||
| 98 | "SPEECH_TRANSCRIBER": recognize_speech(), | ||
| 99 | "NOTES": save_notes(), | ||
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 | def main(): | ||
| 104 | lcd.clear() | ||
| 105 | print("WELCOME TO THE I2C COMMAND LINE CENTER") | ||
| 106 | print("Options:", ", ".join(OPTIONS.keys())) | ||
| 107 | |||
| 108 | while True: | ||
| 109 | user_input = input("Enter command: ").upper() | ||
| 110 | action = OPTIONS.get(user_input) | ||
| 111 | |||
| 112 | if action: | ||
| 113 | action() | ||
| 114 | else: | ||
| 115 | lcd.display_text(ERROR_NOT_FOUND, 1) | ||
| 116 | print(ERROR_NOT_FOUND) | ||
| 117 | |||
| 118 | |||
| 119 | def destroy(): | ||
| 120 | lcd.clear() | ||
| 121 | os.system("cls" if os.name == "nt" else "clear") | ||
| 122 | |||
| 123 | |||
| 124 | if __name__ == "__main__": | ||
| 125 | try: | ||
| 126 | main() | ||
| 127 | except KeyboardInterrupt: | ||
| 128 | destroy() | ||
diff --git a/webconsole/index.html b/webconsole/index.html new file mode 100644 index 0000000..812011f --- /dev/null +++ b/webconsole/index.html | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | <!DOCTYPE html> | ||
| 2 | <html lang="en"> | ||
| 3 | <head> | ||
| 4 | <meta charset="UTF-8"> | ||
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| 6 | <title>CONSOLE</title> | ||
| 7 | </head> | ||
| 8 | <body> | ||
| 9 | |||
| 10 | |||
| 11 | </body> | ||
| 12 | </html> \ No newline at end of file | ||
diff --git a/webconsole/main.js b/webconsole/main.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/webconsole/main.js | |||
