Trammell Hudson avatar Trammell Hudson committed 9e8ed2d

small text

Comments (0)

Files changed (1)

words/src/words.c

 {
 	int row;
 	int col;
-	char text[8];
+	char text_on[8];
+	char text_off[8];
 } word_t;
 
 #define LAYER_FIVE	13
 
 static const word_t words[] = {
 	// Hours 1-12
-	[1] = {  5, 0, "ONE" },
-	[2] = {  6, 8, "TWO" },
-	[3] = {  5, 6, "THREE" },
-	[4] = {  6, 0, "FOUR" },
-	[5] = {  6, 4, "FIVE" }, // hour
-	[6] = {  5, 3, "SIX" },
-	[7] = {  8, 0, "SEVEN" },
-	[8] = {  7, 0, "EIGHT" },
-	[9] = {  4, 7, "NINE" },
-	[10] = {  9, 0, "TEN" }, // hour
-	[11] = {  7, 5, "ELEVEN" },
-	[12] = {  8, 5, "TWELVE" },
+	[1] = {  5, 0, "ONE", "one" },
+	[2] = {  6, 8, "TWO", "two" },
+	[3] = {  5, 6, "THREE", "three" },
+	[4] = {  6, 0, "FOUR", "four" },
+	[5] = {  6, 4, "FIVE", "five" }, // hour
+	[6] = {  5, 3, "SIX", "six" },
+	[7] = {  8, 0, "SEVEN", "seven" },
+	[8] = {  7, 0, "EIGHT", "eight" },
+	[9] = {  4, 7, "NINE", "nine" },
+	[10] = {  9, 0, "TEN", "ten" }, // hour
+	[11] = {  7, 5, "ELEVEN", "eleven" },
+	[12] = {  8, 5, "TWELVE", "twelve" },
 
 	// Minutes 13-
-	[LAYER_FIVE]	= {  2, 6, "FIVE" }, // minute
-	[LAYER_TEN]	= {  3, 5, "TEN" }, // minute
-	[LAYER_QUARTER]	= {  1, 2, "QUARTER" },
-	[LAYER_HALF]	= {  3, 0, "HALF" },
-	[LAYER_TWENTY]	= {  2, 0, "TWENTY" },
+	[LAYER_FIVE]	= {  2, 6, "FIVE", "five" }, // minute
+	[LAYER_TEN]	= {  3, 5, "TEN", "ten" }, // minute
+	[LAYER_QUARTER]	= {  1, 2, "QUARTER", "quarter" },
+	[LAYER_HALF]	= {  3, 0, "HALF", "half" },
+	[LAYER_TWENTY]	= {  2, 0, "TWENTY", "twenty" },
 
 	// Relative
-	[LAYER_IT] = {  0, 0, "IT" },
-	[LAYER_PAST]	= {  4, 0, "PAST" },
-	[LAYER_TO]	= {  3, 9, "TO" },
-	[LAYER_OCLOCK]	= {  9, 5, "OCLOCK" },
-	[LAYER_IS]	= {  0, 3, "IS" },
+	[LAYER_IT] = {  0, 0, "IT", "it" },
+	[LAYER_PAST]	= {  4, 0, "PAST", "past" },
+	[LAYER_TO]	= {  3, 9, "TO", "to", },
+	[LAYER_OCLOCK]	= {  9, 5, "OCLOCK", "oclock" },
+	[LAYER_IS]	= {  0, 3, "IS", "is" },
 
 	// Fillers
-	[LAYER_FILLER]	= {  0, 2, "L" },
-	{  0, 5, "AATIME" },
-	{  1, 0, "A" },
-	{  1, 1, "T" },
-	{  1, 9, "TH" },
-	{  2, 10, "X" },
-	{  3, 4, "B" },
-	{  3, 8, "F" },
-	{  4, 4, "ERU" },
-	{  9, 3, "SE" },
+	[LAYER_FILLER]	= {  0, 2, "L", "l" },
+	{  0, 5, "AATIME", "aatime" },
+	{  1, 0, "A", "a" },
+	{  1, 1, "T", "t" },
+	{  1, 9, "TH", "th" },
+	{  2, 10, "X", "x" },
+	{  3, 4, "B", "b" },
+	{  3, 8, "F", "f" },
+	{  4, 4, "ERU", "eru" },
+	{  9, 3, "SE", "se" },
 };
 
 #define WORD_COUNT ((sizeof(words) / sizeof(*words)))
 
 static void
 layer_mark(
-	TextLayer * const layer,
+	int which,
 	int on
 )
 {
+	TextLayer * const layer = &layers[which];
+	const word_t * const w = &words[which];
+
+	text_layer_set_text(
+		layer,
+		on ? w->text_on : w->text_off
+	);
+
 	text_layer_set_font(
 		layer,
 		fonts_load_custom_font(resource_get_handle(on ? FONT_ON : FONT_OFF))
 	{
 		hour++;
 		min = 60 - min;
-		layer_mark(&layers[LAYER_TO], 1);
-		layer_mark(&layers[LAYER_PAST], 0);
+		layer_mark(LAYER_TO, 1);
+		layer_mark(LAYER_PAST, 0);
 	} else {
-		layer_mark(&layers[LAYER_TO], 0);
-		layer_mark(&layers[LAYER_PAST], min >= 5);
+		layer_mark(LAYER_TO, 0);
+		layer_mark(LAYER_PAST, min >= 5);
 	}
 
 	// Convert from 24-hour to 12-hour time
 		hour -= 12;
 
 	for (int i = 1 ; i < 12 ; i++)
-		layer_mark(&layers[i], i == hour ? 1 : 0);
+		layer_mark(i, i == hour ? 1 : 0);
 
 	// mark all of the minutes as off,
 	// and then turn on the ones that count
-	layer_mark(&layers[LAYER_OCLOCK], 0);
-	layer_mark(&layers[LAYER_FIVE], 0);
-	layer_mark(&layers[LAYER_TEN], 0);
-	layer_mark(&layers[LAYER_QUARTER], 0);
-	layer_mark(&layers[LAYER_TWENTY], 0);
-	layer_mark(&layers[LAYER_HALF], 0);
+	layer_mark(LAYER_OCLOCK, 0);
+	layer_mark(LAYER_FIVE, 0);
+	layer_mark(LAYER_TEN, 0);
+	layer_mark(LAYER_QUARTER, 0);
+	layer_mark(LAYER_TWENTY, 0);
+	layer_mark(LAYER_HALF, 0);
 
 	if (min < 5)
-		layer_mark(&layers[LAYER_OCLOCK], 1);
+		layer_mark(LAYER_OCLOCK, 1);
 	else
 	if (min < 10)
-		layer_mark(&layers[LAYER_FIVE], 1);
+		layer_mark(LAYER_FIVE, 1);
 	else
 	if (min < 15)
-		layer_mark(&layers[LAYER_TEN], 1);
+		layer_mark(LAYER_TEN, 1);
 	else
 	if (min < 20)
-		layer_mark(&layers[LAYER_QUARTER], 1);
+		layer_mark(LAYER_QUARTER, 1);
 	else
 	if (min < 25)
-		layer_mark(&layers[LAYER_TWENTY], 1);
+		layer_mark(LAYER_TWENTY, 1);
 	else
 	if (min < 30)
 	{
-		layer_mark(&layers[LAYER_TWENTY], 1);
-		layer_mark(&layers[LAYER_FIVE], 1);
+		layer_mark(LAYER_TWENTY, 1);
+		layer_mark(LAYER_FIVE, 1);
 	} else
 	{
-		layer_mark(&layers[LAYER_HALF], 1);
+		layer_mark(LAYER_HALF, 1);
 	}
 		
 /*
 
 static void
 text_layer(
-	TextLayer * layer,
-	int row,
-	int col,
-	const char * text
+	int which
 )
 {
+	TextLayer * const layer = &layers[which];
+	const word_t * const w = &words[which];
+
 	GRect frame = GRect(
-		col*FONT_W + 10,
-		row*FONT_H,
-		strlen(text)*(FONT_W+4),
+		w->col*FONT_W + 10,
+		w->row*FONT_H,
+		strlen(w->text_on)*(FONT_W+4),
 		FONT_H+5
 	);
 	text_layer_init(layer, frame);
-	text_layer_set_text(layer, text);
 	text_layer_set_text_color(layer, GColorWhite);
 	text_layer_set_background_color(layer, GColorClear);
-	layer_mark(layer, 0); // all are "off" initially
+	layer_mark(which, 0); // all are "off" initially
 
 	layer_add_child(&window.layer, &layer->layer);
 }
 
 	for (unsigned i = 0 ; i < WORD_COUNT ; i++)
 	{
-		const word_t * const w = &words[i];
-		text_layer(
-			&layers[i],
-			w->row,
-			w->col,
-			w->text
-		);
+		text_layer(i);
 	}
 
 	// Flag the ones that are always on
-	layer_mark(&layers[LAYER_IT], 1);
-	layer_mark(&layers[LAYER_IS], 1);
+	layer_mark(LAYER_IT, 1);
+	layer_mark(LAYER_IS, 1);
 }
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.