p
Dependencies: SDFileSystem SPI_TFT_ILI9341 TFT_fonts mbed
Diff: main.cpp
- Revision:
- 0:c9e8b902e5f1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 08 14:35:24 2015 +0000 @@ -0,0 +1,127 @@ +#include "mbed.h" +#include "SPI_TFT_ILI9341.h" +#include "stdio.h" +#include "string" +#include "Arial12x12.h" +#include "Arial24x23.h" +#include "Arial28x28.h" +#include "font_big.h" + #include "SDFileSystem.h" +PwmOut mypwm(PWM_OUT); +SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, D7, "sd"); +DigitalOut myled(LED1); +PwmOut RED(D8); +PwmOut GREEN(D10); +PwmOut BLUE(D9); +InterruptIn button(USER_BUTTON); +extern unsigned char p1[]; +extern unsigned char p2[]; +extern unsigned char p3[]; +char List[4][8]={"track01","track02","track03","track04"}; +Serial pc(SERIAL_TX,SERIAL_RX); +// the TFT is connected to SPI pin 11-14 +int mark=10,list_nowplay=0; +SPI_TFT_ILI9341 TFT(SPI_MOSI,SPI_MISO,SPI_SCK,SPI_CS, D9, D8,"TFT"); // mosi, miso, sclk, cs, reset, dc + +void letplay() +{ + TFT.cls(); + TFT.foreground(White); + TFT.background(Black); + TFT.cls(); + TFT.set_orientation(1); + TFT.Bitmap(60,1,200,173,p1); +} +void angry() +{ + TFT.cls(); + TFT.foreground(White); + TFT.background(Black); + TFT.cls(); + TFT.set_orientation(1); + TFT.Bitmap(60,1,200,173,p2); +} +void cry() +{ + TFT.cls(); + TFT.foreground(White); + TFT.background(Black); + TFT.cls(); + TFT.set_orientation(1); + TFT.Bitmap(60,1,200,173,p3); +} +void print_list() +{ + int i=0,j=0; + TFT.claim(stdout); + TFT.cls(); + TFT.foreground(White); + TFT.background(Black); + TFT.cls(); + + TFT.set_orientation(3); + TFT.set_font((unsigned char*) Arial28x28); + TFT.locate(150,120); + TFT.printf("Manual Mode:"); + TFT.cls(); + TFT.set_orientation(3); + TFT.set_font((unsigned char*) Arial24x23); + do + { + TFT.locate(5,j); + TFT.printf("%2d . %s\r\n", i,List[i]); + i++; + j=j+23; + }while(i<4); + +} +void select_list() +{ + //i=10; + if(mark>=96) + { + mark=10; + } + TFT.cls(); + print_list(); + TFT.set_orientation(0); + TFT.fillcircle(mark,20,10,Red); + + mark=mark+23; + list_nowplay++; + //pc.printf("%d\n",list_nowplay); +} +void SmoothRed() +{ + int i,j; + for(i=0.0;i<=1.0;i+=0.1) + { + RED.write(i); + wait(1); + for(j=0.0;j<=1.0;j+=0.1) + { + GREEN.write(j); + wait(1); + } + } + + /* for(i=1.0;i>=0;i-=0.1) + { + RED.write(i); + wait(1); + }*/ + +} + +int main() +{ + // print_list(); + // select_list(); + // button.rise(&select_list); + while(1) + { + SmoothRed(); + wait(2); + } + +}