Skip to content

Commit 07640c3

Browse files
committed
initial change
1 parent a3dab19 commit 07640c3

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

data/hrtowatts.html

+22-11
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,54 @@ <h1>
2222
<h1><strong>Physical Working Capacity</strong></h1>
2323
<h2>
2424
<p>For the most accurate power estimation when not using a power meter, please submit the following information.
25-
<br>Note: You can get estimated watts from any outdoor ride recorded in Strava with heart rate information.
25+
<br>Note: You can get estimated watts from any outdoor ride recorded in Strava with heart rate information.
2626
</p>
2727
<form action="/send_settings">
2828
<table class="center" height="182" cellspacing="1">
2929
<tbody>
3030
<tr>
3131
<td>
32-
<p class="tooltip">Easy Session Average HR<span class="tooltiptext">Session 1 HR<br><br>Average Heartrate over an easy 1 Hour course.</span></p>
32+
<p class="tooltip">Easy Session Average HR<span class="tooltiptext">Session 1 HR<br><br>Average
33+
Heartrate over an easy 1 Hour course.</span></p>
3334
</td>
3435
<td><input type="number" id="session1HR" name="session1HR" value="0" /></td>
3536
</tr>
3637
<tr>
3738
<td>
38-
<p class="tooltip">Easy Session Average Power<span class="tooltiptext">Average Power over an easy 1 hour course in watts.</span></p>
39+
<p class="tooltip">Easy Session Average Power<span class="tooltiptext">Average Power over an easy 1 hour
40+
course in watts.</span></p>
3941
</td>
4042
<td><input type="number" id="session1Pwr" name="session1Pwr" value="0" />
4143
</td>
4244
</tr>
4345
<tr>
4446
<td>
45-
<p class="tooltip">Hard Session Average HR<span class="tooltiptext">Average HR over a hard 1 hour course.</span></p>
47+
<p class="tooltip">Hard Session Average HR<span class="tooltiptext">Average HR over a hard 1 hour
48+
course.</span></p>
4649
</td>
4750
<td><input type="number" id="session2HR" name="session2HR" value="0" />
4851
</td>
49-
</tr>
5052
<tr>
5153
<td>
52-
<p class="tooltip">Hard Session Average Power<span class="tooltiptext">Average Power over a hard 1 hour course in watts.</span></p>
54+
<p class="tooltip">Hard Session Average Power<span class="tooltiptext">Average Power over a hard 1 hour
55+
course in watts.</span></p>
5356
</td>
5457
<td><input type="number" id="session2Pwr" name="session2Pwr" value="0" />
5558
</td>
5659
</tr>
57-
60+
<tr>
61+
<td>
62+
<p class="tooltip">HR->PWR<span class="tooltiptext">Automatically calculate watts using
63+
heartrate when powermeter not connected</span></p>
64+
</td>
65+
<td><label class="switch"><input type="checkbox" name="stealthchop" id="stealthchop"><span
66+
class="slider"></span></label>
67+
</td>
5868
</tr>
59-
</tbody>
60-
</table><br>
61-
<input type="submit" value="Submit" />
62-
</form>
69+
</tbody>
70+
</table><br>
71+
<input type="submit" value="Submit" />
72+
</form>
6373
</h2>
6474
</body>
6575

@@ -83,6 +93,7 @@ <h2>
8393
document.getElementById("session1Pwr").value = obj.session1Pwr;
8494
document.getElementById("session2HR").value = obj.session2HR;
8595
document.getElementById("session2Pwr").value = obj.session2Pwr;
96+
document.getElementById("hr2Pwr").checked = obj.hr2Pwr;
8697
setTimeout(function () { document.getElementById("loadingWatermark").remove(); }, 1000);
8798
}
8899
};

include/SmartSpin_parameters.h

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ int session1HR;
9090
int session1Pwr;
9191
int session2HR;
9292
int session2Pwr;
93+
bool hr2Pwr;
9394

9495
void setDefaults();
9596
String returnJSON();

src/BLE_Server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void BLENotify(void *pvParameters)
172172
{
173173
for (;;)
174174
{
175-
if (spinBLEClient.connectedHR && !spinBLEClient.connectedPM && (userConfig.getSimulatedHr() > 0))
175+
if (spinBLEClient.connectedHR && !spinBLEClient.connectedPM && (userConfig.getSimulatedHr() > 0) && userPWC.hr2Pwr)
176176
{
177177
calculateInstPwrFromHR();
178178
}

src/HTTP_Server_Basic.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ void startHttpServer()
202202
{
203203
userPWC.session2Pwr = server.arg("session2Pwr").toInt();
204204
}
205+
if (!server.arg("hr2Pwr").isEmpty())
206+
{
207+
userPWC.hr2Pwr = server.arg("hr2Pwr");
208+
}
205209

206210
String response = "<!DOCTYPE html><html><body><h2>";
207211
if (wasBTUpdate) //Special BT update response

src/SmartSpin_parameters.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ session1HR = 129; //examples from https://www.cyclinganalytics.com/
241241
session1Pwr = 100;
242242
session2HR = 154;
243243
session2Pwr = 150;
244+
hr2Pwr = true;
244245
}
245246

246247
//-- return all config as one a single JSON string
@@ -253,6 +254,7 @@ String physicalWorkingCapacity::returnJSON()
253254
doc["session1Pwr"] = session1Pwr;
254255
doc["session2HR"] = session2HR;
255256
doc["session2Pwr"] = session2Pwr;
257+
doc["hr2Pwr"] = hr2Pwr;
256258

257259
String output;
258260
serializeJson(doc, output);
@@ -280,6 +282,8 @@ void physicalWorkingCapacity::saveToSPIFFS()
280282
doc["session1Pwr"] = session1Pwr;
281283
doc["session2HR"] = session2HR;
282284
doc["session2Pwr"] = session2Pwr;
285+
doc["hr2Pwr"] = hr2Pwr;
286+
283287

284288
// Serialize JSON to file
285289
if (serializeJson(doc, file) == 0)
@@ -321,6 +325,7 @@ void physicalWorkingCapacity::loadFromSPIFFS()
321325
session1Pwr = doc["session1Pwr"];
322326
session2HR = doc["session2HR"];
323327
session2Pwr = doc["session2Pwr"];
328+
hr2Pwr = doc["hr2Pwr"];
324329

325330
debugDirector("Config File Loaded: " + String(userPWCFILENAME));
326331
file.close();

0 commit comments

Comments
 (0)