Skip to content

Added the valve settings#5

Merged
arghyabi merged 1 commit into
masterfrom
add_valve_Seetings
Sep 22, 2025
Merged

Added the valve settings#5
arghyabi merged 1 commit into
masterfrom
add_valve_Seetings

Conversation

@arghyabi
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Web/script.js Outdated
Comment thread Scripts/Main.py
Comment thread Scripts/Main.py
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Scripts/Main.py

time.sleep(0.1) # Sleep to reduce CPU usage
except KeyboardInterrupt:
cleanupGpio(gpio)
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread Web/script.js
Comment on lines +72 to +77
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`;
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
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`;
}

Copilot uses AI. Check for mistakes.
Comment thread Scripts/Main.py
print(f"Updated valve durations: Valve1={valve1Duration} min, Valve2={valve2Duration} min")

# Morning valve operation
if now.hour == MORNING_8AM and not morningRunDone:
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread Scripts/Main.py
morningRunDone = True

# Evening valve operation
if now.hour == EVENING_8PM and not eveningRunDone:
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Signed-off-by: Arghya Biswas <arghyabiswas05@gmail.com>
@arghyabi arghyabi merged commit b921cca into master Sep 22, 2025
1 check passed
@arghyabi arghyabi deleted the add_valve_Seetings branch September 22, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants