-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelay.js
31 lines (28 loc) · 1.07 KB
/
relay.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// MAJOR PROJECT UI
// Daniel Messham
// Date
//
// Extra for Experts:
// - describe what you did to take this project "above and beyond"
function draw() {
background(backgroundColor);
labelDraw("Auxillary Relays")
relayMenu()
}
function relayMenu(){
for(let list=0; list<relayTable.length; list++){
let txt = relayTable[list][1]+" , "+relayTable[list][2]+" , "+relayTable[list][3]
let accent= "gray"
if(relayTable[list][3]==true){accent="green"}//set button accent color according to state
else{accent="darkCyan"}
drawButton(5,37*list+40,width-10, 27, txt, accent, 230);
if(mouseArea(5,37*list+40,width-10, 27)&&mouseIsPressed){//see if the mouse is in the area of a button and if it is being pressed
if(millis()-timeBase>=timeDelay){
if(relayTable[list][3]==false){relayTable[list][3]=true}//set relay state to true if it is false
else(relayTable[list][3]=false)//set it to false if it is anything else
timeBase = millis()//reset the delay for a button press
console.log(list + "" +relayTable[list][3])
}
}
}
}