Commits

Trammell Hudson committed fdf4baa

almost perfect now!

Comments (0)

Files changed (2)

 #define BOLT_H (GLCD_YPIXELS - BOLT_X)
 
 // Coin position
-#define COIN_X 80
+#define COIN_X 75
 
 #define TURTLE_MIN BOLT_X  // Turtle boundary
 #define TURTLE_MAX (BOLT_X+BOLT_W-8)
 	int h
 )
 {
-	graphics_context_set_stroke_color(ctx, GColorWhite);
-	graphics_draw_round_rect(ctx, GRect(y*2, x*2,h*2,w*2), 0);
+	graphics_context_set_fill_color(ctx, GColorWhite);
+	graphics_draw_round_rect(ctx, GRect(y*2, (GLCD_XPIXELS - x-w)*2,h*2,w*2), 0);
 }
 
 static inline void
 )
 {
 	graphics_context_set_fill_color(ctx, inverted ? GColorWhite : GColorBlack);
-	graphics_fill_rect(ctx, GRect(y*2,  x*2, h*2, w*2), 0, GCornerNone);
+	graphics_fill_rect(ctx, GRect(y*2, (GLCD_XPIXELS-x-w)*2, h*2, w*2), 0, GCornerNone);
 }
 
 
 )
 {
 	graphics_context_set_fill_color(ctx, GColorBlack);
-	graphics_fill_rect(ctx, GRect(y*2,  x*2, 2, 2), 0, GCornerNone);
+	graphics_fill_rect(ctx, GRect(y*2, (GLCD_XPIXELS-x-1)*2, 2, 2), 0, GCornerNone);
 }
 
 static inline void
 )
 {
 	graphics_context_set_fill_color(ctx, GColorWhite);
-	graphics_fill_rect(ctx, GRect(y*2,  x*2, 2, 2), 0, GCornerNone);
+	graphics_fill_rect(ctx, GRect(y*2,  (GLCD_XPIXELS-x-1)*2, 2, 2), 0, GCornerNone);
 }
 
+
+static uint8_t glcd_x;
+static uint8_t glcd_y;
+
+static void
+glcdSetAddress(
+	uint8_t x,
+	uint8_t y
+)
+{
+	glcd_x = x;
+	glcd_y = y;
+}
+
+
+static void
+glcdDataWrite(
+	uint8_t pix
+)
+{
+	uint8_t mask = 1;
+	for (int y = 0 ; y < 8 ; y++, mask <<= 1)
+	{
+		if (pix & mask)
+			glcdSetDot(glcd_x, glcd_y + y);
+		else
+			glcdClearDot(glcd_x, glcd_y + y);
+	}
+
+	glcd_x++;
+}
+
+
+static void
+glcdWriteChar(
+	unsigned char c,
+	uint8_t inverted
+)
+{
+        u08 i = 0;
+        u08 pix_width = 5;
+
+        for(i = 0; i < pix_width; i++)
+        {
+		uint8_t pix = Font5x7[((c - 0x20) * 5) + i];
+		if (inverted)
+			pix = ~pix;
+
+		glcdDataWrite(pix);
+	}
+
+	glcdDataWrite(inverted ? 0xFF : 0x00);
+}
+
+
 extern volatile uint8_t time_s, time_m, time_h;
 extern volatile uint8_t old_m, old_h;
 extern volatile uint8_t date_m, date_d, date_y;
 }
 
 void setscore(void){
-  if(score_mode != last_score_mode) {
+  if(1) { // score_mode != last_score_mode) {
     redraw_time = 1;
     last_score_mode = score_mode;
     // Default left and right displays
   // clear screen
   glcdFillRectangle(0, 0, GLCD_XPIXELS, GLCD_YPIXELS, inverted);
   // get time & display
-  last_score_mode = 99; // ???
+  //last_score_mode = 99; // ???
   setscore();
 
 #if 0
   static uint8_t direction = 0;
   static uint8_t wait_frame = 0;
 
-  if (!wait_frame){
-
     if (direction == 0){
       draw_turtle(x, y, 0);
+  if (!wait_frame)
       x++;
     }
 
     if (direction == 1){
       draw_turtle(x, y, 1);
+  if (!wait_frame)
       x--;
     }
 
-    wait_frame = 1;
-  }else{
-    wait_frame = 0;
-  }
+  wait_frame = !wait_frame;
 
   if (x >= TURTLE_MAX){ // Switch to going left
     direction = 1;
 }
 
 void WriteTime(uint8_t inverted) {
-  write_font = 77;
-
-#if 0
   // Draw Date
   glcdSetAddress(1,1);
   WriteDigits(left_score2,inverted);
   WriteDigits(right_score2,inverted);
 
   // Draw Time
-  glcdSetAddress(89,0);
+  glcdSetAddress(45,0);
   glcdWriteChar('x', inverted);
   WriteDigits(left_score,inverted);
   WriteDigits(right_score,inverted);
-#endif
-
-  write_font = 57;
 }
 
 void WriteDigits(uint8_t t, uint8_t inverted)
 {
-#if 0
-	glcdWriteChar(48 + (t/10),inverted);
-	glcdWriteChar(48 + (t%10),inverted);
-#endif
+	glcdWriteChar('0' + (t/10),inverted);
+	glcdWriteChar('0' + (t%10),inverted);
 }
 
 
 
 	timer_handle = app_timer_send_event(
 		ctx,
-		50 /* milliseconds */,
+		75 /* milliseconds */,
 		COOKIE_MY_TIMER
 	);
 }
 	(void) ctx;
 	const PblTm * const ptm = event->tick_time;
 
+	if (time_m != ptm->tm_min)
+		minute_changed = 1;
+	if (time_h != ptm->tm_hour)
+		hour_changed = 1;
+
 	time_s = ptm->tm_sec;
 	time_m = ptm->tm_min;
 	time_h = ptm->tm_hour;
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.