Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ECE 445 UI repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aliceg3
ECE 445 UI repo
Commits
d639f2da
Commit
d639f2da
authored
2 years ago
by
aliceg3
Browse files
Options
Downloads
Patches
Plain Diff
double switches
parent
aaccef05
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arduino_code/test_webpage_sensors/test_webpage_sensors.ino
+61
-47
61 additions, 47 deletions
arduino_code/test_webpage_sensors/test_webpage_sensors.ino
with
61 additions
and
47 deletions
arduino_code/test_webpage_sensors/test_webpage_sensors.ino
+
61
−
47
View file @
d639f2da
...
...
@@ -34,9 +34,6 @@ const char* input_parameter2 = "state";
#define PRESSURE1GOAL 41
#define PRESSURE2GOAL 39
#define MOTOR1GOAL
#define MOTOR2GOAL
Stepper
motor1
(
200
,
motor1IN1
,
motor1IN2
,
motor1IN3
,
motor1IN4
);
Stepper
motor2
(
200
,
motor2IN1
,
motor2IN2
,
motor2IN3
,
motor2IN4
);
...
...
@@ -51,6 +48,8 @@ String pressure1status = "NOT YET...";
String
pressure2status
=
"NOT YET..."
;
String
motor1status
=
"just started"
;
String
motor2status
=
"just started"
;
int
motor1goal
;
int
motor2goal
;
// Create AsyncWebServer object on port 80
AsyncWebServer
server
(
80
);
...
...
@@ -87,10 +86,14 @@ const char index_html[] PROGMEM = R"rawliteral(
body {max-width: 600px; margin:0px auto; padding-bottom: 25px;}
.switch {position: relative; display: inline-block; width: 120px; height: 68px}
.switch input {display: none}
.slider {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
.slider:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
input:checked+.slider {background-color: #b30000}
input:checked+.slider:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
.sliderON {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
.sliderON:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
input:checked+.sliderON {background-color: #20A110}
input:checked+.sliderON:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
.sliderOFF {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
.sliderOFF:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
input:checked+.sliderOFF {background-color: #b30000}
input:checked+.slideroFF:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
</style>
</head>
<body>
...
...
@@ -120,13 +123,13 @@ const char index_html[] PROGMEM = R"rawliteral(
<i class="fas fa-wrench" style="color:#4a32a8;"></i>
<span class="sensorlabel">motor1 Status</span>
<span id="motor1status">%motor1STATUS%</span>
<sup class="units">torque</sup>
//
<sup class="units">torque</sup>
</p>
<p>
<i class="fas fa-wrench" style="color:#4a32a8;"></i>
<span class="sensorlabel">motor2 Status</span>
<span id="motor2status">%motor2STATUS%</span>
<sup class="units">torque</sup>
//
<sup class="units">torque</sup>
</p>
%BUTTONPLACEHOLDER%
<script>function toggleCheckbox(element) {
...
...
@@ -238,7 +241,8 @@ String processor(const String& var){
}
else
if
(
var
==
"BUTTONPLACEHOLDER"
){
String
buttons
=
""
;
buttons
+=
"<h4>Motor 1 Control</h4><label class=
\"
switch
\"
><input type=
\"
checkbox
\"
onchange=
\"
toggleCheckbox(this)
\"
id=
\"
2
\"
"
+
outputState
(
2
)
+
"><span class=
\"
slider
\"
></span></label>"
;
buttons
+=
"<h4>TIGHTEN Boot</h4><label class=
\"
switch
\"
><input type=
\"
checkbox
\"
onchange=
\"
toggleCheckbox(this)
\"
id=
\"
1
\"
"
+
outputState
(
2
)
+
"><span class=
\"
sliderON
\"
></span></label>"
;
buttons
+=
"<h4>Release Boot</h4><label class=
\"
switch
\"
><input type=
\"
checkbox
\"
onchange=
\"
toggleCheckbox(this)
\"
id=
\"
2
\"
"
+
outputState
(
2
)
+
"><span class=
\"
sliderOFF
\"
></span></label>"
;
return
buttons
;
}
return
String
();
...
...
@@ -305,38 +309,27 @@ void setup(){
Serial
.
print
(
" - Set to: "
);
Serial
.
println
(
inputMessage2
);
if
(
inputMessage2
.
toInt
()
==
1
){
// delay(200);
motor1status
=
"motor1 running"
;
// doesn't work idk why
motor2status
=
"awaiting..."
;
// motor11111.setSpeed(60);
// motor11111.step(500);
//// motor11111.setSpeed(0);
// digitalWrite(motor11111IN1, LOW);
// digitalWrite(motor11111IN2, LOW);
// digitalWrite(motor11111IN3, LOW);
// digitalWrite(motor11111IN4, LOW);
// delay(200);
// motor1status = "reset";
// motor11111.setCurrentPosition(0);
// motor11111.setAcceleration(10);
//
// motor11111.moveTo(2000);
//
// while(motor11111.distanceToGo() <= 1000) {
// motor11111.setSpeed(80);
// motor11111.runToPosition();
// }
// motor1status = "motor11111 stop";
if
(
inputMessage1
.
toInt
()
==
1
){
if
(
inputMessage2
.
toInt
()
==
1
){
motor1status
=
"Ankle motor tightening..."
;
// doesn't work idk why
motor2status
=
"Waiting..."
;
}
if
(
inputMessage2
.
toInt
()
==
0
){
motor1status
=
"Off"
;
motor2status
=
"Off"
;
}
}
//
if
(
inputMessage2
.
toInt
()
==
0
){
// motor11111.setSpeed(0);
motor1status
=
"reset"
;
motor2status
=
"reset"
;
if
(
inputMessage1
.
toInt
()
==
2
)
{
if
(
inputMessage2
.
toInt
()
==
1
){
motor1status
=
"Ankle motor loosening..."
;
// doesn't work idk why
motor2status
=
"Waiting..."
;
}
if
(
inputMessage2
.
toInt
()
==
0
){
motor1status
=
"Off"
;
motor2status
=
"Off"
;
}
}
request
->
send
(
200
,
"text/plain"
,
"OK"
);
...
...
@@ -358,28 +351,49 @@ void loop(){
int
intervals2
[
7
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
};
int
intervalValues2
[
7
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
};
if
(
motor1status
==
"
motor1 run
ning"
){
if
(
motor1status
==
"
Ankle motor tighte
ning
...
"
){
motor1
.
setSpeed
(
60
);
motor1
.
step
(
500
);
//
motor11111.setSpeed(0);
digitalWrite
(
motor1IN1
,
LOW
);
digitalWrite
(
motor1IN2
,
LOW
);
digitalWrite
(
motor1IN3
,
LOW
);
digitalWrite
(
motor1IN4
,
LOW
);
motor1status
=
"
stop
"
;
motor1status
=
"
Tightened
"
;
motor2status
=
"
run
ning..."
;
motor2status
=
"
Foot motor tighte
ning..."
;
motor2
.
setSpeed
(
60
);
motor2
.
step
(
-
500
);
// motor11111.setSpeed(0);
digitalWrite
(
motor2IN1
,
LOW
);
digitalWrite
(
motor2IN2
,
LOW
);
digitalWrite
(
motor2IN3
,
LOW
);
digitalWrite
(
motor2IN4
,
LOW
);
motor2status
=
"stop"
;
motor2status
=
"Tightened"
;
}
if
(
motor1status
==
"Ankle motor loosening ..."
){
motor1
.
setSpeed
(
60
);
motor1
.
step
(
500
);
digitalWrite
(
motor1IN1
,
LOW
);
digitalWrite
(
motor1IN2
,
LOW
);
digitalWrite
(
motor1IN3
,
LOW
);
digitalWrite
(
motor1IN4
,
LOW
);
motor1status
=
"Loosened"
;
motor2status
=
"Foot motor loosening..."
;
motor2
.
setSpeed
(
60
);
motor2
.
step
(
-
500
);
digitalWrite
(
motor2IN1
,
LOW
);
digitalWrite
(
motor2IN2
,
LOW
);
digitalWrite
(
motor2IN3
,
LOW
);
digitalWrite
(
motor2IN4
,
LOW
);
motor2status
=
"Loosened"
;
}
for
(
int
counter
=
0
;
counter
<
10
;
counter
++
)
{
int
a1
=
analogRead
(
PRESSUREPIN1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment