DOGS-102 Graphic LCD module Example. Based on Igor Skochinsky's "DOGLCDDemo" program.
Dependencies: DOG-S_GraphicLCD mbed
Fork of DOGLCDDemo by
main.cpp
- Committer:
- ban4jp
- Date:
- 2014-05-03
- Revision:
- 1:b7a86d680935
- Parent:
- 0:2a5dccfd318f
File content as of revision 1:b7a86d680935:
//#define DEBUG #include "mbed.h" //DOGS102 Library #include "DogLCD.h" #include "Graphics.h" #include "Cuboid.h" #include "TrimeshObject.h" //Demo Data #include "TieFighter.h" #include "hellombed.h" #if defined(TARGET_LPC1768) SPI spi(p11, NC, p13); DogLCD dog(spi, p18, p20, p19); // spi, cs, a0, reset #elif defined(TARGET_LPC1114) SPI spi(dp2, NC, dp6); DogLCD dog(spi, dp9, dp11, dp10); // spi, cs, a0, reset #endif Graphics g(&dog); TrimeshObject tf(tie_fighter_vertices, tie_fighter_faces, TIE_FIGHTER_NUM_FACES); Cuboid cube; int main() { dog.init(); // draw "hello mbed" dog.send_pic(pic_hellombed); wait(1); // draw rectangle around the screen g.line(0, 0, dog.width()-1, 0, 0xFFFFFF); wait(1); g.line(dog.width()-1, 0, dog.width()-1, dog.height()-1, 0xFFFFFF); wait(1); g.line(dog.width()-1, dog.height()-1, 0, dog.height()-1, 0xFFFFFF); wait(1); g.line(0, dog.height()-1, 0, 0, 0xFFFFFF); wait(3); dog.clear_screen(); float rotx = 0, roty = 0, rotz = 0; #ifdef DEBUG Timer timer; timer.start(); int frameno = 0; const int pollcount = 100; #endif // shift 1/4th of screen to the left tf.position(-dog.width() / 4, 0, 0); tf.colour(0xffffff); // shift 1/4th of screen to the right cube.position(+dog.width() / 4, 0, 0); cube.colour(0xffffff); while (1) { rotx += 0.1; roty += 0.08; rotz += 0.05; // set rotation angles tf.rotate(rotx, roty, rotz); cube.rotate(rotx, roty, rotz); // lock update dog.beginupdate(); dog.clear_screen(); // render TieFighter tf.render(g); // and the cube cube.render(g); // unlock update (and draw framebuffer) dog.endupdate(); #ifdef DEBUG if ( ++frameno == pollcount ) { // output fps to serial int end = timer.read_ms(); float fps = pollcount*1000.0/end; printf("%d frames, %d ms, FPS: %f\n", pollcount, end, fps); frameno = 0; timer.reset(); } #endif //dog.fill(40, 40, 52, 52, 0x000000); } }