Commits

Trammell Hudson committed b09420a

fmt_i16 works

Comments (0)

Files changed (1)

accel/src/accel.c

 }
 
 
+static unsigned
+fmt_i16(
+	char * buf,
+	int16_t v_in
+)
+{
+	uint16_t v = v_in;
+
+	if (v_in < 0)
+	{
+		buf[0] = '-';
+		v = -v_in;
+	} else
+	if (v_in > 0)
+		buf[0] = '+';
+	else
+		buf[0] = ' ';
+
+	buf[5] = '0' + v % 10; v /= 10;
+	buf[4] = '0' + v % 10; v /= 10;
+	buf[3] = '0' + v % 10; v /= 10;
+	buf[2] = '0' + v % 10; v /= 10;
+	buf[1] = '0' + v % 10;
+
+	return 6;
+}
+
+
 static void
 handle_tick(
 	AppContextRef ctx,
 {
 	(void) ctx;
 	const PblTm * const ptm = event->tick_time;
-	static char time_buffer[16];
+	static char time_buffer[32];
+	unsigned off = 0;
+
+	struct AccelData accel = { 12345, 9999, -9999 };;
+	//accel_get_xyz(&accel);
+	off += fmt_i16(time_buffer + off, accel.x);
+	time_buffer[off++] = '\n';
+	off += fmt_i16(time_buffer + off, accel.y);
+	time_buffer[off++] = '\n';
+	off += fmt_i16(time_buffer + off, accel.z);
+	time_buffer[off++] = '\n';
 
 	string_format_time(
-		time_buffer,
-		sizeof(time_buffer),
+		time_buffer + off,
+		sizeof(time_buffer) - off,
 		"%H:%M:%S",
 		ptm
 	);
+
 	text_layer_set_text(&time_layer, time_buffer);
 }
 
 	window_init(&window, "Main");
 	window_stack_push(&window, true);
 
-	text_layer_init(&time_layer, GRect(0,0,144,20));
+	text_layer_init(&time_layer, GRect(0,0,144,168));
 	text_layer_set_text(&time_layer, "");
 	text_layer_set_font(&time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
 	layer_add_child(&window.layer, &time_layer.layer);