Skip to content
Snippets Groups Projects
Commit d0e4dca0 authored by aliceg3's avatar aliceg3
Browse files

"good enough" sensor code

parent c38e1260
No related branches found
No related tags found
No related merge requests found
......@@ -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.5rem;
font-size: 1.0rem;
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+.slideroFF:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
input:checked+.sliderOFF: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 tightening..."; // doesn't work idk why
motor1status = "Tightening..."; // 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 loosening..."; // doesn't work idk why
motor1status = "Loosening..."; // 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 tightening..."){
if (motor1status == "Tightening..."){
motor1.setSpeed(60);
motor1.step(500);
motor1.step(600);
digitalWrite(motor1IN1, LOW);
digitalWrite(motor1IN2, LOW);
digitalWrite(motor1IN3, LOW);
digitalWrite(motor1IN4, LOW);
motor1status = "Tightened";
motor1status = "Done";
motor2status = "Foot motor tightening...";
motor2status = "Tightening...";
motor2.setSpeed(60);
motor2.step(-500);
......@@ -370,20 +385,20 @@ void loop(){
digitalWrite(motor2IN2, LOW);
digitalWrite(motor2IN3, LOW);
digitalWrite(motor2IN4, LOW);
motor2status = "Tightened";
motor2status = "Done";
}
if (String(motor1status) == "Ankle motor loosening..."){
if (String(motor1status) == "Loosening..."){
motor1.setSpeed(60);
motor1.step(-500);
motor1.step(-400);
digitalWrite(motor1IN1, LOW);
digitalWrite(motor1IN2, LOW);
digitalWrite(motor1IN3, LOW);
digitalWrite(motor1IN4, LOW);
motor1status = "Loosened";
motor1status = "Done";
motor2status = "Foot motor loosening...";
motor2status = "Loosening...";
motor2.setSpeed(60);
motor2.step(300);
......@@ -392,7 +407,7 @@ void loop(){
digitalWrite(motor2IN2, LOW);
digitalWrite(motor2IN3, LOW);
digitalWrite(motor2IN4, LOW);
motor2status = "Loosened";
motor2status = "Done";
}
for(int counter = 0; counter < 10; counter ++) {
......@@ -434,14 +449,14 @@ void loop(){
pressure1status = "LEFT GOAL REACHED";
}
else {
pressure1status = "not yet...";
pressure1status = "Not yet...";
}
if (((float)abs(pressure2 - PRESSURE2GOAL)/(float)PRESSURE2GOAL) <= 0.15){
pressure2status = "RIGHT GOAL REACHED";
}
else {
pressure2status = "not yet...";
pressure2status = "Not yet...";
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment