Commits

Trammell Hudson committed c42112c

started on n nederlanse clock

  • Participants

Comments (0)

Files changed (1)

+/** \file
+ * Word clock, with Dutch time
+ *
+ * een uur
+ * een over een
+ * kwart over een
+ * tien voor half twee
+ * half twee
+ * vijf over half twee
+ * kwart voor twee
+ * 
+ * And 's ochtends, 's middags, 's avonds, 's nachts
+ * vier uur
+ * half vier 
+ */
+#include "pebble_os.h"
+#include "pebble_app.h"
+#include "pebble_fonts.h"
+
+static const char *nums[] = {
+	"",
+	"een",
+	"twee",
+	"drie",
+	"vier",
+	"vijf",
+	"zes",
+	"zeven",
+	"acht",
+	"negen",
+	"tien",
+	"elf",
+	"twaalf",
+	"dertien",
+	"veertien",
+	"kwart",
+};
+
+PBL_APP_INFO(
+	"Nederlandse",
+	"hudson",
+	1, // Version
+	INVALID_RESOURCE,
+	APP_INFO_WATCH_FACE
+);
+
+
+static char time_buffer[32];
+static Window window;
+static TextLayer time_layer;
+
+/** Called once per minute */
+static void
+handle_tick(
+	AppContextRef ctx,
+	PebbleTickEvent * const event
+)
+{
+	(void) ctx;
+	const PblTm * const ptm = event->tick_time;
+
+	string_format_time(
+		time_buffer,
+		sizeof(time_buffer),
+		"%H:%M",
+		event->tick_time
+	);
+	text_layer_set_text(&time_layer, time_buffer);
+}
+
+
+static void
+handle_init(
+	AppContextRef ctx
+)
+{
+	(void) ctx;
+
+	window_init(&window, "Main");
+	window_stack_push(&window, true);
+
+	text_layer_init(&time_layer, GRect(22,10,144-24,50));
+	time_buffer[0] = '\0';
+	text_layer_set_text(&time_layer, time_buffer);
+	text_layer_set_font(&time_layer, fonts_get_system_font(FONT_KEY_GOTHAM_42_BOLD));
+	layer_add_child(&window.layer, &time_layer.layer);
+}
+
+
+void
+pbl_main(
+	void * const params
+)
+{
+	PebbleAppHandlers handlers = {
+		.init_handler	= &handle_init,
+		.tick_info	= {
+			.tick_handler = &handle_tick,
+			.tick_units = MINUTE_UNIT,
+		},
+	};
+
+	app_event_loop(params, &handlers);
+}