hoi hoi ik heb een adruino uno en zou hier mijn nieuw 3,5" tft smartgpu 2 willen intalleren maar hij blijft in start scherm gaan met het 2,8" scherm is het geen probleem werkt perfect maar het 3,5" scherm kan niet als arduino schield geruikt worden ??? heeft iemand een idee hoe ik dit kan oplossen
#include <SMARTGPU2.h> //include the SMARTGPU2 library!
SMARTGPU2 lcd; //create our object called LCD
char songsOnSDCard[20]={0}; //array containing the names of the different called videos, up to 20 characters including .vid extension
unsigned char volume=100;
/**********************************/
void drawIntro(void){
lcd.drawGradientRect(0,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,MAGENTA,BLACK,VERTICAL);
lcd.setTextSize(FONT5);
lcd.string(80,30,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Jukebox",0);
lcd.string(40,100,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"SmartGPU 2",0);
lcd.setTextSize(FONT3);
lcd.string(23,180,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Vizic Technologies 2014",0);
delay(2000);
lcd.drawGradientRect(0,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,MAGENTA,BLACK,VERTICAL);
lcd.string(30,100,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Searching for songs...",0);
delay(500);
}
/**********************************/
void drawControls(ACTIVE stateRR, char *symbol, ACTIVE stateFF){
//draw button RR
lcd.objButton(5,MAX_Y_LANDSCAPE-50,((LCD_WIDTH/3)*1)-1,MAX_Y_LANDSCAPE-5,stateRR,"<<<");
//draw button Play/Pause
lcd.objButton(((LCD_WIDTH/3)*1)+1,MAX_Y_LANDSCAPE-50,((LCD_WIDTH/3)*2)-1,MAX_Y_LANDSCAPE-5,SELECTED,symbol);
//draw button FF
lcd.objButton(((LCD_WIDTH/3)*2)+1,MAX_Y_LANDSCAPE-50,MAX_X_LANDSCAPE-5,MAX_Y_LANDSCAPE-5,stateFF,">>>");
}
/**************************************************/
//looks in the current directory for .wav files and returns the name without .wav extension in the *fileName given array
void findNextAudioFile(char *fileName){
static unsigned int songNumber=0;
char *pch;
while(1){
if(lcd.SDFgetFileName(songNumber++,fileName) == F_INVALID_PARAMETER) songNumber=0; //if the function throws invalid parameter, then reset i
pch=strstr(fileName,".wav"); //find the .wav extension in the name
if(pch != 0){ //if .wav extension is present in the name
strncpy(pch,0x00,1); //cut/replace the .wav extension for the NULL 0x00 character
lcd.erase();
return; //exit
} //if no .wav extension is found, then continue with the while(1) loop
lcd.string(0,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"No Audio File Found",0);
}
}
/**********************************/
/**********************************/
void setup() { //initial setup
//Those two functions must always be called for SMARTGPU2 support
lcd.init(); //configure the serial and pinout of arduino board for SMARTGPU2 support
lcd.start(); //initialize the SMARTGPU2 processor
}
/**********************************/
/**********************************/
/**********************************/
/**********************************/
void loop() { //main loop
POINT point;
unsigned int vid=0,i=0;
STATE state;
lcd.baudChange(BAUD5); //Set a fast baud!, always that we use touch functions is recommended to use fast baud rates
//Audio Init
lcd.initDACAudio(ENABLE); //Turn on the Audio DACs
lcd.audioBoost(ENABLE); //ENABLE boost
lcd.setTextSize(FONT2);
lcd.SDFopenDir("Music"); //Open the folder that contains the songs, if commented songs will be searched on root path
//draw background/Intro
drawIntro();
//start playing
while(1){ //Loop forever in the player!
lcd.erase();
findNextAudioFile(songsOnSDCard); //obtain a xxx.wav file name without the.wav extension
lcd.stopWAVFile(); //stop current song if any
lcd.playWAVFile(songsOnSDCard,0); //play found .wav file
lcd.string(0,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,songsOnSDCard,0); //print file name
drawControls(DESELECTED,"Pause",DESELECTED); //draw Buttons
while((lcd.getWAVPlayState(&state)==OK) && (state == ENABLE)){ //while song is still playing
lcd.drawGradientRect(0,40,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE-70,random(0,65536),random(0,65536),HORIZONTAL); //draw animation
delay(100);
//try to receive a touch...
if(lcd.touchScreen(&point)==VALID){ //if valid touch...
if(point.y > (MAX_Y_LANDSCAPE-50)){ //if touch on buttons
if(point.x < ((LCD_WIDTH/3)*1)){ //touch on <<< button
drawControls(SELECTED,"Pause",DESELECTED);
delay(200); //wait
drawControls(DESELECTED,"Pause",DESELECTED);
lcd.advanceWAVFile(0); //rewind to beginning
}else if(point.x < ((LCD_WIDTH/3)*2)){ //touch on Play/Pause button
lcd.getWAVPlayState(&state);
if(state == ENABLE){ //if playing
lcd.pauseWAVFile(); //pause playing
drawControls(DESELECTED,"Play",DESELECTED);
delay(300);
while(1){ //loop until touch on play button is performed
while(lcd.touchScreen(&point) == INVALID);
if((point.y >= (MAX_Y_LANDSCAPE-50)) && (point.x > ((LCD_WIDTH/3)*1)) && point.x < ((LCD_WIDTH/3)*2)){ //if touch on Play/Pause button
lcd.pauseWAVFile(); //resume playing
drawControls(DESELECTED,"Pause",DESELECTED);
delay(300);
break;
}
}
}else{ break;}
}else{ //touch on >>> button
drawControls(DESELECTED,"Pause",SELECTED);
delay(200); //wait
drawControls(DESELECTED,"Pause",DESELECTED);
break; //go to next track
}
}else{ //touch on any other part of the screen = volume up or volume down
if(point.x < (LCD_WIDTH/2)){ //touch on left side of the screen
if(volume >= 10) volume-=10; //decrease volume only if it is bigger than 10
}else{ //touch on right side of the screen
if(volume < 100) volume+=10; //increase volume only if it is lower than 100
}
lcd.setVolumeWAV(volume); //set new volume
lcd.string(MAX_X_LANDSCAPE-150,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"volume:",0); //print file name
lcd.drawRectangle(MAX_X_LANDSCAPE-50,0,MAX_X_LANDSCAPE,40,BLACK,FILL);
lcd.printNumber(MAX_X_LANDSCAPE-50,0,volume);
}
}
}
}
}