Added the valve settings#5
Conversation
df27e1e to
475ce0f
Compare
There was a problem hiding this comment.
Pull Request Overview
This pull request adds valve control functionality to the irrigation system, allowing users to configure and control two valves through a web interface. The changes include automated valve operation at scheduled times (8 AM and 8 PM) with configurable durations.
- Adds web UI configuration dropdowns for valve durations (1-15 minutes)
- Implements backend logic for valve timing and automated scheduling
- Adds GPIO pin definitions and setup for two valve controls
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Web/script.js | Adds valve configuration UI functions and duplicate event listeners |
| Web/motor.php | Extends API to handle valve duration configuration requests |
| Web/index.html | Adds valve configuration dropdowns to the web interface |
| Scripts/PinDescription.py | Defines GPIO pin numbers for valve controls |
| Scripts/Main.py | Implements valve control logic with scheduled operations |
| Scripts/Common.py | Adds valve-related constants and timing configurations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
475ce0f to
b39db97
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| time.sleep(0.1) # Sleep to reduce CPU usage | ||
| except KeyboardInterrupt: | ||
| cleanupGpio(gpio) |
There was a problem hiding this comment.
The cleanupGpio function only turns off MOTOR_PIN but doesn't turn off VALVE1_PIN and VALVE2_PIN. This could leave valves running after the program exits.
| function updateConfigValue(id, value) { | ||
| const select = document.getElementById(id); | ||
| const selectedSpan = document.getElementById(`selected${id.charAt(0).toUpperCase() + id.slice(1)}`); | ||
| if (value) { | ||
| select.value = value; | ||
| selectedSpan.textContent = `${value} min`; |
There was a problem hiding this comment.
[nitpick] The string manipulation to generate the selectedSpan ID is complex and error-prone. Consider using a mapping object or more explicit ID generation to improve readability.
| function updateConfigValue(id, value) { | |
| const select = document.getElementById(id); | |
| const selectedSpan = document.getElementById(`selected${id.charAt(0).toUpperCase() + id.slice(1)}`); | |
| if (value) { | |
| select.value = value; | |
| selectedSpan.textContent = `${value} min`; | |
| // Mapping from select element IDs to their corresponding span IDs | |
| const selectToSpanMap = { | |
| valve1Duration: 'selectedValve1Duration', | |
| valve2Duration: 'selectedValve2Duration' | |
| }; | |
| function updateConfigValue(id, value) { | |
| const select = document.getElementById(id); | |
| const spanId = selectToSpanMap[id]; | |
| const selectedSpan = document.getElementById(spanId); | |
| if (value) { | |
| select.value = value; | |
| if (selectedSpan) { | |
| selectedSpan.textContent = `${value} min`; | |
| } |
| print(f"Updated valve durations: Valve1={valve1Duration} min, Valve2={valve2Duration} min") | ||
|
|
||
| # Morning valve operation | ||
| if now.hour == MORNING_8AM and not morningRunDone: |
There was a problem hiding this comment.
The valve scheduling logic only checks the hour but not minutes/seconds. This means valves could be activated multiple times within the same hour if the loop runs multiple times, despite the morningRunDone/eveningRunDone flags.
| morningRunDone = True | ||
|
|
||
| # Evening valve operation | ||
| if now.hour == EVENING_8PM and not eveningRunDone: |
There was a problem hiding this comment.
The valve scheduling logic only checks the hour but not minutes/seconds. This means valves could be activated multiple times within the same hour if the loop runs multiple times, despite the morningRunDone/eveningRunDone flags.
Signed-off-by: Arghya Biswas <arghyabiswas05@gmail.com>
b39db97 to
5616581
Compare
No description provided.