Git Product home page Git Product logo

pebble-tz-clock-layer's Introduction

tz-clock-layer

Pebble library for easily adding a clock with a secondary timezone (including automatic daylight savings) to your app.

Warning: Currently only supports a single instance.

Get your API key from Timezone DB.

You can find a list of timezones here: Timezone list.

Screenshot of library in action

Usage

pebble package install ...

// This is a simple example, demonstrating the basic usage.
#include <tz-clock-layer/tz-clock-layer.h>

static TzClockLayer *s_remote_time_layer;

static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  tz_clock_tick_event(s_remote_time_layer, tick_time, units_changed);
}

static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_remote_time_layer = tz_clock_layer_create(GRect(0, 68, bounds.size.w, 34), "YOUR-API-KEY", "America/Los_Angeles");
  layer_add_child(window_layer, s_remote_time_layer);

  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
}

static void window_unload(Window *window) {
  tz_clock_layer_destroy(s_remote_time_layer);
}
// Add to your app.js
var TzClock = require('tz-clock-layer');
var tzClock = new TzClock();

Pebble.addEventListener('ready', function(e) {
  Pebble.sendAppMessage({'APP_READY': true});
});

Pebble.addEventListener('appmessage', function(e) {
  tzClock.appMessageHandler(e);
});

Additional Functions

Fairly standard text layer styling stuff.

void tz_clock_layer_set_font(TzClockLayer *tz_clock_layer, GFont font);
void tz_clock_layer_set_text_alignment(TzClockLayer *tz_clock_layer, GTextAlignment alignment);
void tz_clock_layer_set_background_color(TzClockLayer *tz_clock_layer, GColor color);
void tz_clock_layer_set_text_color(TzClockLayer *tz_clock_layer, GColor color);
GSize tz_clock_layer_get_content_size(TzClockLayer *tz_clock_layer);

pebble-tz-clock-layer's People

Contributors

orviwan avatar

Watchers

James Cloos avatar  avatar

Forkers

clach04

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.