From c47d7487daa3f94ac216ba3cd29849a545ef6f14 Mon Sep 17 00:00:00 2001 From: Elena of Valhalla'' Grandi Date: Sun, 7 Apr 2013 13:39:29 +0200 Subject: Arduino sketch: move all u8g stuff to the graphic functions --- arduino_sketch/arcerino/arcerino.ino | 83 ++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 37 deletions(-) (limited to 'arduino_sketch') diff --git a/arduino_sketch/arcerino/arcerino.ino b/arduino_sketch/arcerino/arcerino.ino index 171bdb9..869f3e4 100644 --- a/arduino_sketch/arcerino/arcerino.ino +++ b/arduino_sketch/arcerino/arcerino.ino @@ -43,48 +43,60 @@ void draw_board() { } void draw_game() { - draw_board(); - u8g.drawVLine(x+LCD_0X,y-4+LCD_0Y,9); - u8g.drawHLine(x-4+LCD_0X,y+LCD_0Y,9); + u8g.firstPage(); + do { + draw_board(); + u8g.drawVLine(x+LCD_0X,y-4+LCD_0Y,9); + u8g.drawHLine(x-4+LCD_0X,y+LCD_0Y,9); + } while(u8g.nextPage()); } void draw_score() { - draw_board(); - u8g.drawDisc(x+LCD_0X,y+LCD_0Y,3); + u8g.firstPage(); + do { + draw_board(); + u8g.drawDisc(x+LCD_0X,y+LCD_0Y,3); + } while(u8g.nextPage()); } void draw_title() { - u8g.setFont(FONT_BIG); - u8g.setPrintPos(0,MIDDLE_TEXT_Y); - u8g.print("Arcerino"); - u8g.setFont(FONT_SMALL); - u8g.setPrintPos(LOAD_TEXT_X,BOTTOM_TEXT_Y); - u8g.print("Loading..."); + u8g.firstPage(); + do { + u8g.setFont(FONT_BIG); + u8g.setPrintPos(0,MIDDLE_TEXT_Y); + u8g.print("Arcerino"); + u8g.setFont(FONT_SMALL); + u8g.setPrintPos(LOAD_TEXT_X,BOTTOM_TEXT_Y); + u8g.print("Loading..."); + } while(u8g.nextPage()); } void draw_wait() { - u8g.setFont(FONT_SMALL); - u8g.setPrintPos(0,TOP_TEXT_Y); - u8g.print("Your score: "); - u8g.print(score,DEC); - u8g.setPrintPos(0,BOTTOM_TEXT_Y); - u8g.print("Press Z to start"); - u8g.setPrintPos(0,MIDDLE_TEXT_Y); - u8g.print("Rank: "); - u8g.setFont(FONT_BIG); - if (score >= 100) { - u8g.print("A++"); - } else if (score >= 90) { - u8g.print("A"); - } else if (score >= 80) { - u8g.print("B"); - } else if (score >= 60) { - u8g.print("C"); - } else if (score >= 30) { - u8g.print("D"); - } else { - u8g.print("E"); - } + u8g.firstPage(); + do { + u8g.setFont(FONT_SMALL); + u8g.setPrintPos(0,TOP_TEXT_Y); + u8g.print("Your score: "); + u8g.print(score,DEC); + u8g.setPrintPos(0,BOTTOM_TEXT_Y); + u8g.print("Press Z to start"); + u8g.setPrintPos(0,MIDDLE_TEXT_Y); + u8g.print("Rank: "); + u8g.setFont(FONT_BIG); + if (score >= 100) { + u8g.print("A++"); + } else if (score >= 90) { + u8g.print("A"); + } else if (score >= 80) { + u8g.print("B"); + } else if (score >= 60) { + u8g.print("C"); + } else if (score >= 30) { + u8g.print("D"); + } else { + u8g.print("E"); + } + } while(u8g.nextPage()); } void update_position() { @@ -134,10 +146,7 @@ void setup() { u8g.setColorIndex(1); u8g.setContrast(192); nunchuk_get_data(); - u8g.firstPage(); - do { - draw_title(); - } while(u8g.nextPage()); + draw_title(); delay(4000); new_arrow(); new_round(); -- cgit v1.2.3