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
d0e4dca0
Commit
d0e4dca0
authored
2 years ago
by
aliceg3
Browse files
Options
Downloads
Patches
Plain Diff
"good enough" sensor code
parent
c38e1260
No related branches found
Branches containing commit
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
+58
-43
58 additions, 43 deletions
arduino_code/test_webpage_sensors/test_webpage_sensors.ino
with
58 additions
and
43 deletions
arduino_code/test_webpage_sensors/test_webpage_sensors.ino
+
58
−
43
View file @
d0e4dca0
...
...
@@ -31,25 +31,22 @@ const char* input_parameter2 = "state";
#define motor2IN3 15
#define motor2IN4 4
#define PRESSURE1GOAL 41
#define PRESSURE2GOAL 39
#define PRESSURE1GOAL 22
#define PRESSURE2GOAL 19
#define MOTORTORQUE .6
Stepper
motor1
(
200
,
motor1IN1
,
motor1IN2
,
motor1IN3
,
motor1IN4
);
Stepper
motor2
(
200
,
motor2IN1
,
motor2IN2
,
motor2IN3
,
motor2IN4
);
//AccelStepper motor1(AccelStepper::FULL4WIRE, motor1IN1, motor1IN2, motor1IN3, motor1IN4);
// current temperature & humidity, updated in loop()
int
pressure1
=
0.0
;
int
pressure2
=
0.0
;
float
motor1Speed
=
0.0
;
float
motor2Speed
=
0.0
;
String
pressure1status
=
"NOT YET..."
;
String
pressure2status
=
"NOT YET..."
;
String
motor1status
=
"just started"
;
String
motor2status
=
"just started"
;
int
motor1goal
;
int
motor2goal
;
String
motor1status
=
"Initialized"
;
String
motor2status
=
"Initialized"
;
// Create AsyncWebServer object on port 80
AsyncWebServer
server
(
80
);
...
...
@@ -73,15 +70,17 @@ const char index_html[] PROGMEM = R"rawliteral(
margin: 0px auto;
text-align: center;
}
h2 { font-size: 3.0rem; }
p { font-size: 3.0rem; }
.units { font-size: 1.2rem; }
h2 { font-size: 1.5rem; }
h4 {display: inline; padding:5px};
h5 {display: block};
p { font-size: 1.5rem; }
.units { font-size: 1.0rem; }
.sensorlabel{
font-size: 1.
5
rem;
font-size: 1.
0
rem;
vertical-align:center;
padding-bottom: 15px;
}
.statuslabel { font-size: 1.3rem; }
.statuslabel { font-size: 1.3rem;
padding-bottom: 15px;}
button2 {background-color: #555555;}
body {max-width: 600px; margin:0px auto; padding-bottom: 25px;}
.switch {position: relative; display: inline-block; width: 120px; height: 68px}
...
...
@@ -93,16 +92,16 @@ const char index_html[] PROGMEM = R"rawliteral(
.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+.slider
o
FF:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
input:checked+.slider
O
FF:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
</style>
</head>
<body>
<h2>Remotely Adjustable Boot</h2>
<p>
<i class="fas fa-thermometer-half" style="color:#4a32a8;"></i>
<span class="sensorlabel">Pressure LEFT</span>
<br>
<span id="pressure1">%PRESSURE1%</span>
<span class="sensorlabel">Pressure LEFT
- Prescribed Pressure: %PRESSURE1GOAL% mmHg
</span>
<br
/
>
<span id="pressure1"
class="statuslabel"
>%PRESSURE1%</span>
<sup class="units">mmHg</sup>
</p>
<p>
...
...
@@ -111,8 +110,9 @@ const char index_html[] PROGMEM = R"rawliteral(
</p>
<p>
<i class="fas fa-thermometer-half" style="color:#4a32a8;"></i>
<span class="sensorlabel">Pressure RIGHT</span>
<span id="pressure2">%PRESSURE2%</span>
<span class="sensorlabel">Pressure RIGHT - Prescribed Pressure: %PRESSURE2GOAL% mmHg</span>
<br />
<span id="pressure2" class="statuslabel">%PRESSURE2%</span>
<sup class="units">mmHg</sup>
</p>
<p>
...
...
@@ -121,15 +121,21 @@ const char index_html[] PROGMEM = R"rawliteral(
</p>
<p>
<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>
<span class="sensorlabel">Ankle Motor - Prescribed Torque: %MOTORTORQUE% N*m</span>
<br />
<span class="sensorlabel">Status:</span>
<span id="motor1status" class="statuslabel">%motor1STATUS%</span>
</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>
<span class="sensorlabel">Foot Motor - Prescribed Torque: %MOTORTORQUE% N*m</span>
<br />
<span class="sensorlabel">Status:</span>
<span id="motor2status" class="statuslabel">%motor2STATUS%</span>
</p>
<p>
<h4>Tighten Boot Straps</h4>
<h4>Loosen Boot Straps</h4>
</p>
%BUTTONPLACEHOLDER%
<script>function toggleCheckbox(element) {
...
...
@@ -227,22 +233,31 @@ String processor(const String& var){
else
if
(
var
==
"PRESSURE1STATUS"
){
return
String
(
pressure1status
);
}
else
if
(
var
==
"PRESSURE1GOAL"
){
return
String
(
PRESSURE1GOAL
);
}
else
if
(
var
==
"PRESSURE2"
){
return
String
(
pressure2
);
}
else
if
(
var
==
"PRESSURE2STATUS"
){
return
String
(
pressure2status
);
}
else
if
(
var
==
"PRESSURE2GOAL"
){
return
String
(
PRESSURE2GOAL
);
}
else
if
(
var
==
"motor1STATUS"
){
return
String
(
motor1status
);
}
else
if
(
var
==
"motor2STATUS"
){
return
String
(
motor2status
);
}
else
if
(
var
==
"MOTORTORQUE"
){
return
String
(
MOTORTORQUE
);
}
else
if
(
var
==
"BUTTONPLACEHOLDER"
){
String
buttons
=
""
;
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>"
;
buttons
+=
"<h4></h4><label class=
\"
switch
\"
><input type=
\"
checkbox
\"
onchange=
\"
toggleCheckbox(this)
\"
id=
\"
1
\"
"
+
outputState
(
2
)
+
"><span class=
\"
sliderON
\"
></span></label>"
;
buttons
+=
"<h4></h4><label class=
\"
switch
\"
><input type=
\"
checkbox
\"
onchange=
\"
toggleCheckbox(this)
\"
id=
\"
2
\"
"
+
outputState
(
2
)
+
"><span class=
\"
sliderOFF
\"
></span></label>"
;
return
buttons
;
}
return
String
();
...
...
@@ -311,7 +326,7 @@ void setup(){
if
(
inputMessage1
.
toInt
()
==
1
){
if
(
inputMessage2
.
toInt
()
==
1
){
motor1status
=
"
Ankle motor t
ightening..."
;
// doesn't work idk why
motor1status
=
"
T
ightening..."
;
// doesn't work idk why
motor2status
=
"Waiting..."
;
}
if
(
inputMessage2
.
toInt
()
==
0
){
...
...
@@ -322,7 +337,7 @@ void setup(){
if
(
inputMessage1
.
toInt
()
==
2
)
{
if
(
inputMessage2
.
toInt
()
==
1
){
motor1status
=
"
Ankle motor l
oosening..."
;
// doesn't work idk why
motor1status
=
"
L
oosening..."
;
// doesn't work idk why
motor2status
=
"Waiting..."
;
}
if
(
inputMessage2
.
toInt
()
==
0
){
...
...
@@ -351,17 +366,17 @@ void loop(){
int
intervals2
[
7
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
};
int
intervalValues2
[
7
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
};
if
(
motor1status
==
"
Ankle motor t
ightening..."
){
if
(
motor1status
==
"
T
ightening..."
){
motor1
.
setSpeed
(
60
);
motor1
.
step
(
5
00
);
motor1
.
step
(
6
00
);
digitalWrite
(
motor1IN1
,
LOW
);
digitalWrite
(
motor1IN2
,
LOW
);
digitalWrite
(
motor1IN3
,
LOW
);
digitalWrite
(
motor1IN4
,
LOW
);
motor1status
=
"
Tighte
ne
d
"
;
motor1status
=
"
Do
ne"
;
motor2status
=
"
Foot motor t
ightening..."
;
motor2status
=
"
T
ightening..."
;
motor2
.
setSpeed
(
60
);
motor2
.
step
(
-
500
);
...
...
@@ -370,20 +385,20 @@ void loop(){
digitalWrite
(
motor2IN2
,
LOW
);
digitalWrite
(
motor2IN3
,
LOW
);
digitalWrite
(
motor2IN4
,
LOW
);
motor2status
=
"
Tighte
ne
d
"
;
motor2status
=
"
Do
ne"
;
}
if
(
String
(
motor1status
)
==
"
Ankle motor l
oosening..."
){
if
(
String
(
motor1status
)
==
"
L
oosening..."
){
motor1
.
setSpeed
(
60
);
motor1
.
step
(
-
5
00
);
motor1
.
step
(
-
4
00
);
digitalWrite
(
motor1IN1
,
LOW
);
digitalWrite
(
motor1IN2
,
LOW
);
digitalWrite
(
motor1IN3
,
LOW
);
digitalWrite
(
motor1IN4
,
LOW
);
motor1status
=
"
Loose
ne
d
"
;
motor1status
=
"
Do
ne"
;
motor2status
=
"
Foot motor l
oosening..."
;
motor2status
=
"
L
oosening..."
;
motor2
.
setSpeed
(
60
);
motor2
.
step
(
300
);
...
...
@@ -392,7 +407,7 @@ void loop(){
digitalWrite
(
motor2IN2
,
LOW
);
digitalWrite
(
motor2IN3
,
LOW
);
digitalWrite
(
motor2IN4
,
LOW
);
motor2status
=
"
Loose
ne
d
"
;
motor2status
=
"
Do
ne"
;
}
for
(
int
counter
=
0
;
counter
<
10
;
counter
++
)
{
...
...
@@ -434,14 +449,14 @@ void loop(){
pressure1status
=
"LEFT GOAL REACHED"
;
}
else
{
pressure1status
=
"
n
ot yet..."
;
pressure1status
=
"
N
ot yet..."
;
}
if
(((
float
)
abs
(
pressure2
-
PRESSURE2GOAL
)
/
(
float
)
PRESSURE2GOAL
)
<=
0.15
){
pressure2status
=
"RIGHT GOAL REACHED"
;
}
else
{
pressure2status
=
"
n
ot yet..."
;
pressure2status
=
"
N
ot yet..."
;
}
}
...
...
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