Allow user to connect multiple screen.

Dependencies:   mbed-rtos mbed

Committer:
Ratchapong
Date:
Wed Mar 11 05:00:37 2015 +0000
Revision:
0:052d0f82433e
Working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ratchapong 0:052d0f82433e 1 #include "mbed.h"
Ratchapong 0:052d0f82433e 2 #include "rtos.h"
Ratchapong 0:052d0f82433e 3 #include "uLCD_4DGL.h"
Ratchapong 0:052d0f82433e 4 #include "Game.h"
Ratchapong 0:052d0f82433e 5 #include "uLCD_Multiscreen.h"
Ratchapong 0:052d0f82433e 6
Ratchapong 0:052d0f82433e 7
Ratchapong 0:052d0f82433e 8 //already defined
Ratchapong 0:052d0f82433e 9 //#define SIZE_X 128
Ratchapong 0:052d0f82433e 10 //#define SIZE_Y 128
Ratchapong 0:052d0f82433e 11
Ratchapong 0:052d0f82433e 12 //display
Ratchapong 0:052d0f82433e 13 uLCD_4DGL screen1(p28, p27, p11);
Ratchapong 0:052d0f82433e 14 uLCD_4DGL screen2(p9, p10, p11);
Ratchapong 0:052d0f82433e 15 std::vector<uLCD_4DGL*> my_screens;
Ratchapong 0:052d0f82433e 16
Ratchapong 0:052d0f82433e 17
Ratchapong 0:052d0f82433e 18 //inputs
Ratchapong 0:052d0f82433e 19 AnalogIn sliderh(p15);
Ratchapong 0:052d0f82433e 20 AnalogIn sliderv(p16);
Ratchapong 0:052d0f82433e 21
Ratchapong 0:052d0f82433e 22
Ratchapong 0:052d0f82433e 23
Ratchapong 0:052d0f82433e 24 //game objects
Ratchapong 0:052d0f82433e 25
Ratchapong 0:052d0f82433e 26
Ratchapong 0:052d0f82433e 27
Ratchapong 0:052d0f82433e 28
Ratchapong 0:052d0f82433e 29 int main() {
Ratchapong 0:052d0f82433e 30 my_screens.push_back(&screen1);
Ratchapong 0:052d0f82433e 31 my_screens.push_back(&screen2);
Ratchapong 0:052d0f82433e 32 uLCD_Multiscreen multiscreen(my_screens);
Ratchapong 0:052d0f82433e 33 Controller controller(sliderh, sliderv);
Ratchapong 0:052d0f82433e 34 vec2 screen = {SIZE_X, SIZE_Y};
Ratchapong 0:052d0f82433e 35 Renderer gfx(multiscreen, screen);
Ratchapong 0:052d0f82433e 36 Game game(gfx, controller);
Ratchapong 0:052d0f82433e 37
Ratchapong 0:052d0f82433e 38
Ratchapong 0:052d0f82433e 39
Ratchapong 0:052d0f82433e 40 multiscreen.setBaudRate(3000000);
Ratchapong 0:052d0f82433e 41 multiscreen.changeBackground(0x444444);
Ratchapong 0:052d0f82433e 42 gfx.background = 0x444444;
Ratchapong 0:052d0f82433e 43 multiscreen.cls();
Ratchapong 0:052d0f82433e 44 //multiscreen.unfilledRectangle(0, 0, 50, 10, -1);
Ratchapong 0:052d0f82433e 45
Ratchapong 0:052d0f82433e 46 while(true){
Ratchapong 0:052d0f82433e 47 int x = sliderh.read()* 1000;
Ratchapong 0:052d0f82433e 48 int y = sliderv.read()* 1000;
Ratchapong 0:052d0f82433e 49
Ratchapong 0:052d0f82433e 50 //printf(controller.sliderv );
Ratchapong 0:052d0f82433e 51 game.loop();
Ratchapong 0:052d0f82433e 52 game.getInput(x, y);
Ratchapong 0:052d0f82433e 53 //Thread::wait(10);
Ratchapong 0:052d0f82433e 54 }
Ratchapong 0:052d0f82433e 55 }