el15mh 200929957

Dependencies:   mbed

Committer:
el15mh
Date:
Tue Apr 04 10:30:56 2017 +0000
Revision:
4:66ab008f7b06
Parent:
3:02653cb1c8f8
Child:
5:55eee1d71c1d
menu with first animation trial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el15mh 0:d7701c5c20e6 1 #include "mbed.h"
el15mh 0:d7701c5c20e6 2 #include "N5110.h"
el15mh 0:d7701c5c20e6 3 #include "Gamepad.h"
el15mh 3:02653cb1c8f8 4 #include "Menu.h"
el15mh 4:66ab008f7b06 5 #include "Maze.h"
el15mh 4:66ab008f7b06 6 #include "Ball.h"
el15mh 0:d7701c5c20e6 7
el15mh 0:d7701c5c20e6 8 // CREATE OBJECTS //
el15mh 0:d7701c5c20e6 9 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
el15mh 0:d7701c5c20e6 10 Gamepad pad;
el15mh 3:02653cb1c8f8 11 Menu menu;
el15mh 4:66ab008f7b06 12 Maze maze;
el15mh 4:66ab008f7b06 13 Ball ball;
el15mh 0:d7701c5c20e6 14
el15mh 0:d7701c5c20e6 15 // FUNCTION PROTOTYPES //
el15mh 0:d7701c5c20e6 16 void init();
el15mh 4:66ab008f7b06 17 void intro();
el15mh 0:d7701c5c20e6 18
el15mh 0:d7701c5c20e6 19 int main()
el15mh 0:d7701c5c20e6 20 {
el15mh 0:d7701c5c20e6 21 init(); // initialise devices
el15mh 0:d7701c5c20e6 22
el15mh 2:a488caea1601 23 printf("Devices initialised \n");
el15mh 2:a488caea1601 24
el15mh 2:a488caea1601 25 while(1) {
el15mh 0:d7701c5c20e6 26
el15mh 4:66ab008f7b06 27 intro();
el15mh 1:8ce2586b5965 28
el15mh 4:66ab008f7b06 29 // menu.main(lcd, pad);
el15mh 4:66ab008f7b06 30 // maze.drawBox(lcd);
el15mh 4:66ab008f7b06 31 // lcd.drawCircle(15, 15, 3, FILL_BLACK);
el15mh 4:66ab008f7b06 32 // ball.draw(lcd, 20, 20, 10);
el15mh 0:d7701c5c20e6 33 }
el15mh 0:d7701c5c20e6 34 }
el15mh 0:d7701c5c20e6 35
el15mh 2:a488caea1601 36
el15mh 1:8ce2586b5965 37 void init()
el15mh 0:d7701c5c20e6 38 {
el15mh 1:8ce2586b5965 39 lcd.init();
el15mh 1:8ce2586b5965 40 pad.init();
el15mh 0:d7701c5c20e6 41 }
el15mh 2:a488caea1601 42
el15mh 4:66ab008f7b06 43 void intro()
el15mh 4:66ab008f7b06 44 {
el15mh 4:66ab008f7b06 45
el15mh 4:66ab008f7b06 46 // printf("intro started \n");
el15mh 4:66ab008f7b06 47
el15mh 4:66ab008f7b06 48 while (1){
el15mh 4:66ab008f7b06 49
el15mh 4:66ab008f7b06 50 // animation sequence
el15mh 4:66ab008f7b06 51 // lcd.drawCircle(x, y, radius, type);
el15mh 4:66ab008f7b06 52 for (int i = 0; i < 61; i++){
el15mh 4:66ab008f7b06 53
el15mh 4:66ab008f7b06 54 lcd.clear();
el15mh 4:66ab008f7b06 55 lcd.printString(" Welcome to ", 0, 1);
el15mh 4:66ab008f7b06 56 lcd.printString(" Roller Maze ", 0, 2);
el15mh 4:66ab008f7b06 57 // printf("loop \n");
el15mh 4:66ab008f7b06 58 lcd.drawLine(56, 40, 68, 40, FILL_BLACK);
el15mh 4:66ab008f7b06 59 lcd.drawLine(56, 41, 68, 41, FILL_BLACK);
el15mh 4:66ab008f7b06 60 lcd.refresh();
el15mh 4:66ab008f7b06 61
el15mh 4:66ab008f7b06 62 if (i < 57){
el15mh 4:66ab008f7b06 63 lcd.drawCircle(i, 36, 4, FILL_BLACK);
el15mh 4:66ab008f7b06 64 lcd.refresh();
el15mh 4:66ab008f7b06 65 wait_ms(50);
el15mh 4:66ab008f7b06 66
el15mh 4:66ab008f7b06 67 }
el15mh 4:66ab008f7b06 68 else if (i == 57){
el15mh 4:66ab008f7b06 69
el15mh 4:66ab008f7b06 70 lcd.drawCircle(i, 37, 4, FILL_BLACK);
el15mh 4:66ab008f7b06 71 lcd.refresh();
el15mh 4:66ab008f7b06 72 wait_ms(50);
el15mh 4:66ab008f7b06 73
el15mh 4:66ab008f7b06 74 for (int c = 55; c < 68; c++){
el15mh 4:66ab008f7b06 75
el15mh 4:66ab008f7b06 76 lcd.clearPixel(c, 42);
el15mh 4:66ab008f7b06 77 lcd.clearPixel(c, 43);
el15mh 4:66ab008f7b06 78 lcd.clearPixel(c, 44);
el15mh 4:66ab008f7b06 79 lcd.clearPixel(c, 45);
el15mh 4:66ab008f7b06 80 lcd.clearPixel(c, 46);
el15mh 4:66ab008f7b06 81 lcd.refresh();
el15mh 4:66ab008f7b06 82 }
el15mh 4:66ab008f7b06 83 }
el15mh 4:66ab008f7b06 84 else if (i == 58){
el15mh 4:66ab008f7b06 85
el15mh 4:66ab008f7b06 86 lcd.drawCircle(i, 38, 4, FILL_BLACK);
el15mh 4:66ab008f7b06 87 lcd.refresh();
el15mh 4:66ab008f7b06 88 wait_ms(50);
el15mh 4:66ab008f7b06 89
el15mh 4:66ab008f7b06 90 for (int c = 55; c < 68; c++){
el15mh 4:66ab008f7b06 91
el15mh 4:66ab008f7b06 92 lcd.clearPixel(c, 42);
el15mh 4:66ab008f7b06 93 lcd.clearPixel(c, 43);
el15mh 4:66ab008f7b06 94 lcd.clearPixel(c, 44);
el15mh 4:66ab008f7b06 95 lcd.clearPixel(c, 45);
el15mh 4:66ab008f7b06 96 lcd.clearPixel(c, 46);
el15mh 4:66ab008f7b06 97 lcd.refresh();
el15mh 4:66ab008f7b06 98 }
el15mh 4:66ab008f7b06 99 }
el15mh 4:66ab008f7b06 100 else if (i == 59){
el15mh 4:66ab008f7b06 101
el15mh 4:66ab008f7b06 102 lcd.drawCircle(i, 39, 4, FILL_BLACK);
el15mh 4:66ab008f7b06 103 lcd.refresh();
el15mh 4:66ab008f7b06 104 wait_ms(50);
el15mh 4:66ab008f7b06 105
el15mh 4:66ab008f7b06 106 for (int c = 55; c < 68; c++){
el15mh 4:66ab008f7b06 107
el15mh 4:66ab008f7b06 108 lcd.clearPixel(c, 42);
el15mh 4:66ab008f7b06 109 lcd.clearPixel(c, 43);
el15mh 4:66ab008f7b06 110 lcd.clearPixel(c, 44);
el15mh 4:66ab008f7b06 111 lcd.clearPixel(c, 45);
el15mh 4:66ab008f7b06 112 lcd.clearPixel(c, 46);
el15mh 4:66ab008f7b06 113 lcd.refresh();
el15mh 4:66ab008f7b06 114 }
el15mh 4:66ab008f7b06 115 }
el15mh 4:66ab008f7b06 116 else{
el15mh 4:66ab008f7b06 117
el15mh 4:66ab008f7b06 118 for (int j = 40, j < 45; j++){
el15mh 4:66ab008f7b06 119
el15mh 4:66ab008f7b06 120 lcd.drawCirle(i, j, 4, FILL_BLACK);
el15mh 4:66ab008f7b06 121 lcd.refresh();
el15mh 4:66ab008f7b06 122 wait_ms(50);
el15mh 4:66ab008f7b06 123
el15mh 4:66ab008f7b06 124 for (int c = 55; c < 68; c++){
el15mh 4:66ab008f7b06 125
el15mh 4:66ab008f7b06 126 lcd.clearPixel(c, 42);
el15mh 4:66ab008f7b06 127 lcd.clearPixel(c, 43);
el15mh 4:66ab008f7b06 128 lcd.clearPixel(c, 44);
el15mh 4:66ab008f7b06 129 lcd.clearPixel(c, 45);
el15mh 4:66ab008f7b06 130 lcd.clearPixel(c, 46);
el15mh 4:66ab008f7b06 131 lcd.refresh();
el15mh 4:66ab008f7b06 132 }
el15mh 4:66ab008f7b06 133 }
el15mh 4:66ab008f7b06 134 }
el15mh 4:66ab008f7b06 135
el15mh 4:66ab008f7b06 136 // printf("%i \n", i);
el15mh 4:66ab008f7b06 137 }
el15mh 4:66ab008f7b06 138 }
el15mh 4:66ab008f7b06 139
el15mh 4:66ab008f7b06 140
el15mh 4:66ab008f7b06 141 }
el15mh 4:66ab008f7b06 142