
code c++ carte KL25Z avec écran TFT Qr4 526S01 TP28017 oscilloscope (en développement)
Dependencies: poirier-proj-95 TFT_fonts mbed
Revision 5:960d4056d774, committed 2015-11-28
- Comitter:
- xpoirier
- Date:
- Sat Nov 28 12:00:07 2015 +0000
- Parent:
- 4:56b453735e89
- Commit message:
- Projet - oscilloscope - iut neuville sur oise
Changed in this revision
SeeedStudioTFTv2.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SeeedStudioTFTv2.lib Tue Sep 29 13:47:30 2015 +0000 +++ b/SeeedStudioTFTv2.lib Sat Nov 28 12:00:07 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mazgch/code/SeeedStudioTFTv2/#f2aaffad7d38 +https://developer.mbed.org/users/xpoirier/code/poirier-proj-95/#8f24787e9626
--- a/main.cpp Tue Sep 29 13:47:30 2015 +0000 +++ b/main.cpp Sat Nov 28 12:00:07 2015 +0000 @@ -1,12 +1,3 @@ -/* - 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" @@ -17,90 +8,62 @@ 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); + SeeedStudioTFTv2 TFT(PTB3, PTB1, PTB2, PTB0, PTD2, PTD3, PTD1, PTA5, PTC8, PTC9, PTA4); + + DigitalOut sortie01(PTA1); + AnalogIn entree01(PTC2); + 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); + //TFT.calibrate(); // CALIBRAGE DE L ECRAN + //point pt; + int var_menu=0; + int i,k; + float vs; + float tab[200]; + while(var_menu == 0)//=============================================== MENU PRINCIPAL ======================================================================= + { + + for(k=0;k<4;k++) + { + sortie01 = 0; + for(i=0;i<50;i++) + { + wait_us(2); // 100/50 = 2 + vs = entree01.read(); + tab[i]=vs; + } + sortie01 = 1; + for(i=51;i<100;i++) + { + wait_us(2); // 100/50 = 2 + vs = entree01.read(); + tab[i]=vs; + } + sortie01 = 0; + for(i=101;i<150;i++) + { + wait_us(2); // 100/50 = 2 + vs = entree01.read(); + tab[i]=vs; + } + sortie01 = 1; + for(i=151;i<200;i++) + { + wait_us(2); // 100/50 = 2 + vs = entree01.read(); + tab[i]=vs; + } + } + for(i=0;i<200;i++) + { + TFT.line(i,200-50*tab[i],i+1,200-50*tab[i+1],Green); + } + wait(1); + TFT.fillrect(0,0,240,320,Black); + + }//fin du while(var_menu==0); - - //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); - - - } - -} +}//fin main