Commits

Trammell Hudson committed b3f79c5

CST Style watch

Comments (0)

Files changed (7)

 DIRS += hoelaat
 DIRS += auth
+DIRS += mario
+DIRS += words
+DIRS += cst
 
 all: $(DIRS)
 
+APP := cst
+
+SRCS += cst.c
+
+FONTS := \
+	fonts/CST-Black.ttf:32 \
+	fonts/CST-Light.ttf:15 \
+
+IMAGES := \
+	images/menu_icon.png \
+
+include ../../Makefile.pebble
+/** \file
+ * CST font clock
+ *
+ * Two lines:
+ * HH:MM (large, bold)
+ * YYYY-MM-DD
+ */
+#include <pebble_os.h>
+#include <pebble_app.h>
+#include <pebble_fonts.h>
+
+PBL_APP_INFO(
+	"CST Style",
+	"hudson",
+	1, // Version
+	RESOURCE_ID_IMAGE_MENU_ICON,
+	APP_INFO_WATCH_FACE
+);
+
+static Window window;
+
+static char time_text[8];
+static char date_text[16];
+
+static TextLayer time_layer;
+static TextLayer date_layer;
+static TextLayer day_layer;
+
+
+static const char *days[] = {
+	"Sunday",
+	"Monday",
+	"Tuesday",
+	"Wednesday",
+	"Thursday",
+	"Friday",
+	"Saturday",
+};
+
+
+/** 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_text,
+		sizeof(time_text),
+		"%H:%M",
+		ptm
+	);
+
+	string_format_time(
+		date_text,
+		sizeof(date_text),
+		"%Y%m%d",
+		ptm
+	);
+
+
+	text_layer_set_text(&date_layer, date_text);
+	text_layer_set_text(&time_layer, time_text);
+	text_layer_set_text(&day_layer, days[ptm->tm_wday]);
+}
+
+
+static void
+text_layer(
+	TextLayer * layer,
+	GRect frame,
+	int font
+)
+{
+	text_layer_init(layer, frame);
+	text_layer_set_text(layer, "");
+	text_layer_set_text_color(layer, GColorWhite);
+	text_layer_set_background_color(layer, GColorClear);
+	text_layer_set_font(layer, fonts_load_custom_font(resource_get_handle(font)));
+
+	layer_add_child(&window.layer, &layer->layer);
+}
+
+
+static void
+handle_init(
+	AppContextRef ctx
+)
+{
+	(void) ctx;
+
+	window_init(&window, "Main");
+	window_stack_push(&window, true);
+	window_set_background_color(&window, GColorBlack);
+
+	resource_init_current_app(&RESOURCES);
+
+	int y = 15;
+	int h = 30;
+
+	// Stack top to bottom.  Note that the hour can take up
+	// two rows at midnight.
+	text_layer(
+		&time_layer,
+		GRect(0, 50, 144, 40),
+		RESOURCE_ID_FONT_CST_BLACK_32
+	);
+
+	text_layer(
+		&date_layer,
+		GRect(0, 90, 144, 40),
+		RESOURCE_ID_FONT_CST_LIGHT_15
+	);
+
+	text_layer(
+		&day_layer,
+		GRect(0, 110, 144, 40),
+		RESOURCE_ID_FONT_CST_LIGHT_15
+	);
+}
+
+
+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);
+}

cst/src/fonts/CST-Black.ttf

Binary file added.

cst/src/fonts/CST-Light.ttf

Binary file added.

cst/src/images/menu_icon.png

Added
New image

menu_icon_blank.png

Added
New image