mirror of
https://git.wetfence.xyz/RandyTheSilly/Civic-Segments.git
synced 2026-09-05 10:07:14 -04:00
Make temperature range configurable
This commit is contained in:
+14
-3
@@ -16,13 +16,24 @@ module.exports = [
|
||||
"type": "toggle",
|
||||
"messageKey": "CLAY_SHOW_TIME_MG",
|
||||
"defaultValue": false,
|
||||
"label": "Show time segments midground"
|
||||
"label": "Show time segments midground",
|
||||
"description": "Show or hide the unlit segments behind the time."
|
||||
},
|
||||
{
|
||||
"type": "slider",
|
||||
"messageKey": "CLAY_TEMP_BAR_0",
|
||||
defaultValue: -32,
|
||||
min: -50,
|
||||
max: 0,
|
||||
"label": "Minimum of temperature range",
|
||||
"description": "Default: -32°C<br><br>Measured in Celsius, this value sets the temperature that is considered the minimum on the watchface. When it is this temperature, 0 temperature bars will be displayed. The maximum is this value +80, making the default maximum 48°C."
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"messageKey": "CLAY_LOW_FUEL_BARS",
|
||||
"defaultValue": 10,
|
||||
"label": "Low fuel percentage",
|
||||
"defaultValue": 2,
|
||||
"label": "Low fuel indicator percentage",
|
||||
"description": "The low fuel indicator will appear at this battery percentage.",
|
||||
"options": [
|
||||
{
|
||||
"label": "disabled",
|
||||
|
||||
@@ -29,7 +29,6 @@ module.exports = function (minified) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO show/hide LED color selector (only on emery)
|
||||
function toggleCustomColors() {
|
||||
if (this.get()) {
|
||||
clayConfig.getItemById('color_preset_selector').hide();
|
||||
|
||||
+13
-6
@@ -15,14 +15,21 @@ function locationSuccess(pos) {
|
||||
|
||||
xhrRequest(url, 'GET',
|
||||
function (responseText) {
|
||||
var json = JSON.parse(responseText);
|
||||
const current_temp = JSON.parse(responseText).current.temperature_2m;
|
||||
const min_temp = JSON.parse(localStorage.getItem('clay-settings')).CLAY_TEMP_BAR_0;
|
||||
const max_temp = min_temp + 80;
|
||||
|
||||
// clamp into a range of 80 (technically 81)C (-32,48), -32C=-25.6F, 48C=118.4F
|
||||
var temperature = Math.min(Math.max(json.current.temperature_2m, -32), 48);
|
||||
// set set range minimum to 0 (add 32) and convert to bars (0-20)
|
||||
temperature = Math.round((temperature + 32) / 4);
|
||||
const clamped_temp = Math.min(Math.max(current_temp, min_temp), max_temp);
|
||||
const normalized_temp = clamped_temp - min_temp;
|
||||
const temp_bars = Math.round(normalized_temp / 4);
|
||||
|
||||
Pebble.sendAppMessage({ PKJS_TEMP_BAR_COUNT: temperature });
|
||||
console.log("Current temp: " + current_temp);
|
||||
console.log("Min temp: " + min_temp);
|
||||
console.log("Max temp: " + max_temp);
|
||||
console.log("Clamped temp: " + clamped_temp);
|
||||
console.log("Bars " + temp_bars);
|
||||
|
||||
Pebble.sendAppMessage({ PKJS_TEMP_BAR_COUNT: temp_bars });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user