π A library to handle core functionality for building Fitbit OS watchface
Note, this is still a work in progress
The purpose of this library is to provide a simple interface to abstract the basic core functionality of a Fitbit watchface (date and time). As a result, you'll be able to manage and render the time and date, all within 2 lines code, allowing you to focus mainly on styling and superset features.
Functionality
- Manage and Display Date including i18n / multi-language support
- Manage and Display Time including user's format preferences and updating on ticks.
- Simple interface
- Support custom font through FitFont Rendering
Future Roadmap
- multi-line time (hour / minutes)
- Support seconds
Create a Text
or FitFont
element in your .view
. Provide that ID to the core class caller, and initialize the core.
const TimeConfiguration = { timeId: 'time' };
const DateConfiguration = { dateId: 'date' };
const core = new Core(TimeConfiguration, DateConfiguration);
core.initialize();
Example: Coloring Elements
const core = new Core({ timeId: 'time', dateId: 'date' });
core.initialize();
if (user.clicked) {
core.time.setColor('deepbluesky');
core.date.setColor('plum');
}
Example: Using Custom Fonts with Fitfont
index.view: View GUI File
<svg>
<use href="#fitfont" id="time">
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
</use>
<use href="#fitfont" id="date">
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
<use href="#fitfont-char"/>
</use>
</svg>
your.js: Clockface JS File
const CustomDateFont = {
font: 'Roboto_30',
halign: 'middle',
valign: 'start',
letterspacing: 0
};
const CustomTimeFont = {
font: 'Roboto_70',
halign: 'middle',
valign: 'start',
letterspacing: 1
};
const core = new Core({
timeId: 'time',
fitfont: CustomTimeFont
}, {
dateId: 'date',
fitfont: CustomDateFont
});
// Time and Date Displayed
core.initialize();
if (someCondition) {
const TimeElement = core.time.get();
TimeElement.letterspacing = 3;
TimeElement.halign = 'end';
}
Type: class
Usage: new Core(TimeConfiguration, DateConfiguration)
Type: object
Configuration for the element used to display the time.
Type: string
ID of the Time Element
Type: object
Fitfont configuration, this will render the element as a Fitfont element instead. ID will be populated with the timeId
.
Type: enum
("12h"/"24h")
Configure which format will the clock display.
Type: function
Register a callback that will be executed upon tick (clock update) events.
Type: object
Configuration for the element used to display the date.
Type: string
ID of the Date Element
Type: object
Fitfont configuration, this will render the element as a Fitfont element instead. ID will be populated with the dateId
.
Type: boolean
Set to true to automatically reference your PO files for translations. Days are all lowercase.
Note: fitbit-core
will use these msgid
to map across your i18n/po files: ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
Type: Class Instance
Parses the date object and sets the element text value to the date.
Sets the Date element color to the value inputted.
Type: Class Instance
Parses the date object and sets element text value to the time.
Sets the Time element color to the value inputted.
Configure a onTick handler to be called when the time ticks
This library works well in conjunction with:
fitbit-settings
- A simple library to handle managing settings
This module is being used for the following watchfaces:
- Dogee (4.8 βs) - A free dogecoin watchface by Pixels on Ridge
Pixels on Ridge
MIT Β© Brandon Him