From 110b0daebb01d7ef20ccadce30e3fa2d45f44513 Mon Sep 17 00:00:00 2001 From: ZareMate <0.zaremate@gmail.com> Date: Mon, 13 Jan 2025 12:12:09 +0100 Subject: [PATCH] Add initial project setup with VSCode configurations and main functionality for serial communication --- .gitignore | 0 .vscode/arduino.json | 3 ++ .vscode/c_cpp_properties.json | 18 +++++++++++ .vscode/launch.json | 24 ++++++++++++++ .vscode/settings.json | 59 ++++++++++++++++++++++++++++++++++ START.lnk | Bin 0 -> 1630 bytes main.py | 56 ++++++++++++++++++++++++++++++++ main/main.ino | 21 ++++++++++++ start.ps1 | 8 +++++ 9 files changed, 189 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/arduino.json create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 START.lnk create mode 100644 main.py create mode 100644 main/main.ino create mode 100644 start.ps1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.vscode/arduino.json b/.vscode/arduino.json new file mode 100644 index 0000000..0a1ed01 --- /dev/null +++ b/.vscode/arduino.json @@ -0,0 +1,3 @@ +{ + "port": "COM3" +} \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..a3d4300 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "windows-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "C:/msys64/ucrt64/bin/gcc.exe", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "windows-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e62909d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": "d:/Documents/Gitea/ESP32-discord", + "program": "d:/Documents/Gitea/ESP32-discord/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bb879da --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/START.lnk b/START.lnk new file mode 100644 index 0000000000000000000000000000000000000000..5e39ac405588f83e530ca5d3178aefc99aaead4b GIT binary patch literal 1630 zcmb_cTWFI>6#m+()capr#f`VD*rKh8e_BgxK&Ym+eUO@xdTIEThW2-xrDAYeb~hdQG~?@UG_WkCx5BCtoz^$XJ*csGv|DB z&Y4*UAg3soBXCEJsJo7QIJr*kY5Dqk<%^svCugKCnJ;p(JVqxe%^XYL9;fFPVWEF? zeaiX98`jQ^oc;jZ@XWE?e^j0s5J9%x=x>Iy#G z;HFMvz9?GmG~4Ta?>%fn7+q*bH74pS}V$+6f zIY4j0p>L4;)eTI<=(&SlJJ|sz8Z$m)El&<;*y(ZWfOnjqXUb3Uzxr`)y^o!=;0BMO zh&Fi>CNI`fcfg6LK#vP_x7lMd${D+|>k5u2yTfTI4GX{1zJ}g^4N)6$+(zss@*Wbf zfYd>nmpLu7izMwAQUNKCRC4j+h{hQ#kxT^`*_>qsV<9#q0LHhtov39@436Ds!wzQ5 zWKATPKLhow56NPP>$QxnUuDz9iV1VSjVEGUPi2G*mG2Pw1i2_V4+Pmn;7l>+mn6Bx zRPxEjyN=&;w=@pbx(BZ|9UGFpRuXS?W;17LyFxKD5=xk^WVlQC*6n9UuQ`79ok&0E z+wr0D)$R?yRUCYjE;y2hxf)8}eQ$q|iI`0LduhuP@CV-O!_R%#TR-qQRoEZjwkSe* zyEs}%l2B(8@5B=LRDi}m7ULg9Zv2m;Tq-V9+s{#eyxO<9?$)|$-_0+D2TP7c9&V?6 zf@lbk<)i@Ncu19`ah73G$slB*T$aXhVOE! 0: + line = ser.readline().decode('utf-8').strip() + print(f"Received: {line}") + + if line == "mute": + keyboard.send('ctrl+shift+f16') + elif line == "deafen": + keyboard.send('ctrl+shift+f15') + else: + print(f"Unknown command: {line}") + + time.sleep(0.1) + except KeyboardInterrupt: + print("Exiting program.") + break + except Exception as e: + print(f"Error during execution: {e}") + break + + except serial.SerialException as e: + print(f"Could not open serial port: {e}") + finally: + if 'ser' in locals() and ser.is_open: + ser.close() + print("Serial connection closed.") + +if __name__ == "__main__": + main() diff --git a/main/main.ino b/main/main.ino new file mode 100644 index 0000000..e10fc57 --- /dev/null +++ b/main/main.ino @@ -0,0 +1,21 @@ +void setup() +{ + pinMode(16, INPUT_PULLUP); // D16 for "mute" button + pinMode(17, INPUT_PULLUP); // D17 for "deafen" button + Serial.begin(115200); +} + +void loop() +{ + // ...existing code... + if (digitalRead(16) == LOW) + { // Button on D16 pressed + Serial.println("mute"); + delay(200); // Debounce delay + } + if (digitalRead(17) == LOW) + { // Button on D17 pressed + Serial.println("deafen"); + delay(200); // Debounce delay + } +} diff --git a/start.ps1 b/start.ps1 new file mode 100644 index 0000000..1c8f3b1 --- /dev/null +++ b/start.ps1 @@ -0,0 +1,8 @@ +# Activate the virtual environment +& .venv\Scripts\activate + +# Run the Python script +python main.py + +# Deactivate the virtual environment +deactivate \ No newline at end of file