aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena of Valhalla'' Grandi <valhalla.trueelena.org>2013-04-07 13:39:29 +0200
committerElena of Valhalla'' Grandi <valhalla.trueelena.org>2013-04-07 13:39:29 +0200
commitc47d7487daa3f94ac216ba3cd29849a545ef6f14 (patch)
tree1e0c69413d2bd292d44f16b6a9d13835617ffc1c
parent2a141ff744afade50014d33b88d3886c3f762857 (diff)
Arduino sketch: move all u8g stuff to the graphic functions
-rw-r--r--arduino_sketch/arcerino/arcerino.ino83
1 files changed, 46 insertions, 37 deletions
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();