-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from SK1Y101/develop
v0.2
- Loading branch information
Showing
28 changed files
with
217 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Import the fitbit builtins | ||
|
||
// Define any helper functions | ||
// Change a digit display | ||
function showDigit(ele, digit) { | ||
try { | ||
ele.href = "digits/digit_" + digit + ".png"; | ||
} catch(err) { | ||
console.log(err + ": Couldn't assign digit '" + digit + "'") | ||
}; | ||
}; | ||
|
||
// Hide a set of gui elemetns | ||
function showElement(ele, val) { | ||
try { | ||
ele.forEach(function(eles) { | ||
eles.style.display = (val ? "inline" : "none"); | ||
}); | ||
} catch(err) { | ||
ele.style.display = (val ? "inline" : "none"); | ||
}; | ||
}; | ||
|
||
// Pad a value such that it has a defined length | ||
function pad(val, def="00") { | ||
return (def + val.toString()).slice(-def.length); | ||
}; | ||
|
||
// Define this module | ||
export let TimeIndicator = function(doc) { | ||
// Fetch the gui elements for the time | ||
const hourTen = doc.getElementById("hour_ten"); | ||
const hourOne = doc.getElementById("hour_one"); | ||
const minsTen = doc.getElementById("min_ten"); | ||
const minsOne = doc.getElementById("min_one"); | ||
|
||
// Fetch the pikachu sprite | ||
const daySprite = doc.getElementsByClassName("day") | ||
const nightSprite = doc.getElementsByClassName("night") | ||
|
||
// Function to update the time | ||
this.drawTime = function(now) { | ||
// Fetch the time elements | ||
var hour = pad(now.getHours()); | ||
var mins = pad(now.getMinutes()); | ||
var daytime = Math.abs(15 - now.getHours()) < 5; | ||
|
||
// update the time elements | ||
showDigit(hourTen, hour[0]); | ||
showDigit(hourOne, hour[1]); | ||
showDigit(minsTen, mins[0]); | ||
showDigit(minsOne, mins[1]); | ||
|
||
// And update the sprite | ||
showElement(daySprite, daytime); | ||
showElement(nightSprite, !daytime); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+299 Bytes
FitbitPoketch-Export/resources/buttons/Poketch_Button_pt_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.