Commits

Trammell Hudson committed bf080c3

bargraphs go down and look ok

  • Participants
  • Parent commits f45c141

Comments (0)

Files changed (1)

File interval/src/interval.c

 
 
 static const int intervals[] = {
-	 -300,
-	 60, -30,
-	 60, -30,
-	 60, -30,
-	 60, -30,
-	 60, -30,
-	 60, -30,
-	 60, -30,
-	 60, -300,
+	 -5,
+	 6, -3,
+	 6, -3,
+	 6, -3,
+	 6, -3,
+	 6, -3,
+	 6, -3,
+	 6, -3,
+	 6, -30,
 };
 
 static const int interval_count = sizeof(intervals)/sizeof(*intervals);
 static const int run_count = 8;
 static int interval = 0;
+static int remaining = 0;
+static int walk = 0;
 
 
 static Window window;
 static char time_buffer[12];
 static char remaining_buffer[12];
 
-static int remaining = -1;
-
 
 /**
  * Draw the bargraphs for the running segments.
 {
 	const unsigned w = me->bounds.size.w;
 	const unsigned h = me->bounds.size.h;
-	const int bar_h = (h - run_count) / (run_count);
+	const int bar_h = h / run_count;
 	int y = 0;
 
 	graphics_context_set_fill_color(ctx, GColorWhite);
 		if (intervals[i] < 0)
 			continue;
 
-		graphics_fill_rect(ctx, GRect(0, y, w, bar_h), 2, GCornersAll);
-		y += bar_h + 1;
+		int bar_w;
+		if (i < interval)
+			bar_w = 0;
+		else
+		if (i == interval)
+			bar_w = (w * remaining) / intervals[i];
+		else
+			bar_w = w;
+
+		graphics_fill_rect(ctx, GRect(0, y, bar_w, bar_h - 2), 2, GCornersAll);
+		y += bar_h;
 	}
 }
 
 
 	if (remaining != 0)
 		remaining--;
+	else
+	if (interval < interval_count-1)
+	{
+		remaining = intervals[++interval];
+		if (remaining < 0)
+		{
+			remaining = -remaining;
+			walk = 1;
+		} else {
+			walk = 0;
+		}
+
+		// should buzz
+	}
 
 	remaining_buffer[0] = '0' + (remaining / 100) % 10;
 	remaining_buffer[1] = '0' + (remaining / 10) % 10;
 	resource_init_current_app(&RESOURCES);
 
 
-	text_layer_init(&time_layer, GRect(20,10,100,30));
-	text_layer_init(&remaining_layer, GRect(10,40,134,45));
+	text_layer_init(&time_layer, GRect(20,00,100,30));
+	text_layer_init(&remaining_layer, GRect(30,28,104,48));
 
 	text_layer_set_text_color(&time_layer, GColorWhite);
 	text_layer_set_text_color(&remaining_layer, GColorWhite);
 	layer_add_child(&window.layer, &time_layer.layer);
 	layer_add_child(&window.layer, &remaining_layer.layer);
 
-	layer_init(&layer, GRect(0,50,144,168-50));
+	layer_init(&layer, GRect(0,70,144,168-70));
 	layer.update_proc = layer_update;
 
 	layer_add_child(&window.layer, &layer);
 		},
 	};
 
+	interval = -1;
+	remaining = 0;
+
 	app_event_loop(params, &handlers);
 }