![](/media/cache/profiles/98740b855aad6c1dda41b6a6b223f66a.jpg.50x50_q85.png)
code c++ carte KL25Z avec écran TFT Qr4 526S01 TP28017 oscilloscope (en développement)
Dependencies: poirier-proj-95 TFT_fonts mbed
main.cpp
- Committer:
- dujardin
- Date:
- 2015-09-29
- Revision:
- 4:56b453735e89
- Parent:
- 3:24069293d35d
- Child:
- 5:960d4056d774
File content as of revision 4:56b453735e89:
/* main.cpp 2014 Copyright (c) Seeed Technology Inc. All right reserved. recompilé à partir d'une librairy donnée par :lawliet zou(lawliet.zou@gmail.com) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public */ #include "mbed.h" #include "SeeedStudioTFTv2.h" #include "Arial12x12.h" #include "Arial24x23.h" #include "Arial28x28.h" #include "font_big.h" #include "diver.h" PwmOut rled(LED_RED); // init PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); SeeedStudioTFTv2 TFT(PTB3, PTB1, PTB2, PTB0, PTD2, PTD3, PTD1, PTA5, PTC8, PTC9, PTA4); int main() { // init I2C accélero uint8_t data[2] = {REG_CTRL_REG_1, 0x01}; i2c.write(MMA8451_I2C_ADDRESS,(char *)data,2); // initially set leds off rled=1.0f; gled=1.0f; bled=1.0f; // 1ms pwm frequency rled.period(0.001f); gled.period(0.001f); bled.period(0.001f); //Configure l'afficheur TFT TFT.background(Black); TFT.foreground(White); TFT.cls(); //Print : message de bonjour TFT.set_font((unsigned char*) Arial28x28); TFT.locate(0,0); TFT.printf("projet²"); //Wait for 1 seconds wait(1.0); //Draw some graphics // inutile sauf comme exemple de programmation TFT.cls(); TFT.set_font((unsigned char*) Arial24x23); TFT.locate(100,100); TFT.printf("Graphic"); TFT.line(0,0,100,0,Green); TFT.line(0,0,0,200,Green); TFT.line(0,0,100,200,Green); TFT.rect(100,50,150,100,Red); TFT.fillrect(180,25,220,70,Blue); TFT.circle(80,150,33,White); TFT.fillcircle(160,190,20,Yellow); double s; for (int i = 0; i < 320; i++) { s = 20 * sin((long double)i / 10); TFT.pixel(i, 100 + (int)s, Red); } //Wait for 1 seconds wait(1.0); //Multiple fonts // vous montre d'autres choses TFT.foreground(White); TFT.background(Blue); TFT.cls(); TFT.set_font((unsigned char*) Arial24x23); TFT.locate(0,0); TFT.printf("Different Fonts :"); TFT.set_font((unsigned char*) Arial24x23); TFT.locate(20,80); TFT.printf("Hello Mbed 2"); TFT.set_font((unsigned char*) Arial12x12); TFT.locate(35,120); TFT.printf("Hello Mbed 3"); while (true) { float xaccln,yaccln; xaccln=acclnread(REG_OUT_X_MSB); yaccln=acclnread(REG_OUT_Y_MSB); TFT.locate(35,220); TFT.printf("X: %1.4f, Y: %1.4f", xaccln, yaccln ); wait(0.1f); } }