Skip to content

Commit

Permalink
[] sixths: add blinking dot, rework altitude adjustment to use system.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelmachek committed Nov 29, 2023
1 parent 5dd975f commit 568b7c9
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions apps/sixths/sixths.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ var gps_dist = 0;
var mark_heading = -1;

// Is the human present?
var is_active = false, last_active = getTime(), last_unlocked = getTime();
var is_active = false, last_active = getTime() - 14*60, last_unlocked = getTime();
var draw_dot = false;
var is_level = false;

// For altitude handling.
var cur_altitude = 0;
var cur_temperature = 0, alt_adjust = 0;
var alt_adjust_mode = "";
var cur_temperature = 0;

// Marks
var cur_mark = null;
Expand Down Expand Up @@ -117,9 +117,6 @@ function gpsHandleFix(fix) {
alt_adjust = cur_altitude - (fix.alt + geoid_to_sea_level);
alt_adjust_mode = "g";
}
if (1) {
debug = ""+fix.alt+"m "+alt_adjust;
}
if (1) {
let now1 = Date();
let now2 = fix.time;
Expand Down Expand Up @@ -498,7 +495,18 @@ function drawTime(now) {
else
g.setFont('Vector', 26);
g.setFontAlign(1, 1);
g.drawString(now.getHours() + ":" + add0(now.getMinutes()), W, 90);
draw_dot = !draw_dot;
let dot = ":";
if (!draw_dot)
dot = ".";
g.drawString(now.getHours() + dot + add0(now.getMinutes()), W, 90);
}
function adjPressure(a) {
o = Bangle.getOptions();
print(o);
o.seaLevelPressure = o.seaLevelPressure * m + a;
Bangle.setOptions(o);
avr = [];
}
function draw() {
if (disp_mode == 2) {
Expand Down Expand Up @@ -539,11 +547,21 @@ function draw() {
g.drawString(msg, 10, 145);

if (getTime() - last_active > 15*60) {
alt_adjust = cur_altitude - rest_altitude;
alt_adjust_mode = "h";
msg = "H)" + fmtAlt(alt_adjust);
let alt_adjust = cur_altitude - rest_altitude;
let abs = Math.abs(alt_adjust);
print("adj", alt_adjust);
o = Bangle.getOptions();
if (abs > 10 && abs < 150) {
let a = 0.01;
// FIXME: draw is called often compared to alt reading
if (cur_altitude > rest_altitude)
a = -a;
o.seaLevelPressure = o.seaLevelPressure + a;
Bangle.setOptions(o);
}
msg = o.seaLevelPressure.toFixed(1) + "hPa";
} else {
msg = alt_adjust_mode+")"+fmtAlt(cur_altitude - alt_adjust);
msg = fmtAlt(cur_altitude);
}
msg = msg + " " + cur_temperature.toFixed(1)+icon_c;
if (cur_mark) {
Expand Down Expand Up @@ -674,7 +692,7 @@ function aliveTask() {
}
function lockHandler(locked) {
if (!locked) {
last_Unlocked = getTime();
last_unlocked = getTime();
draw();
}
}
Expand Down

0 comments on commit 568b7c9

Please sign in to comment.