Skip to content

Instantly share code, notes, and snippets.

@Robotonics
Last active December 16, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robotonics/5431453 to your computer and use it in GitHub Desktop.
Save Robotonics/5431453 to your computer and use it in GitHub Desktop.
Extract from main BTMP04 project
#include <glcd.h>
#include <glcd_Buildinfo.h>
#include <glcd_Config.h>
#include <fonts/allFonts.h>
#include <Wtv020sd16p.h>
int resetPin = 2; // The pin number of the reset pin.
int clockPin = 12; // The pin number of the clock pin.
int dataPin = 13; // The pin number of the data pin.
int busyPin = 3; // The pin number of the busy pin.
char track;
/*
Create an instance of the Wtv020sd16p class.
1st parameter: Reset pin number.
2nd parameter: Clock pin number.
3rd parameter: Data pin number.
4th parameter: Busy pin number.
*/
Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);
void setup() {
//Initializes the module.
wtv020sd16p.reset();
GLCD.Init();
GLCD.ClearScreen();
print_title();
GLCD.SelectFont(System5x7);
Serial.begin(9600);
}
void loop(){
if (Serial.available() > 0)
{
track=Serial.read();
switch (track) {
case '1':
wtv020sd16p.stopVoice();
print_track();
wtv020sd16p.playVoice(1);
break;
case '2':
wtv020sd16p.stopVoice();
print_track();
wtv020sd16p.playVoice(2);
break;
case '3':
wtv020sd16p.stopVoice();
print_track();
wtv020sd16p.playVoice(3);
break;
case '4':
wtv020sd16p.stopVoice();
print_track();
wtv020sd16p.playVoice(4);
break;
case '5':
wtv020sd16p.stopVoice();
print_track();
wtv020sd16p.playVoice(5);
break;
case '6':
wtv020sd16p.pauseVoice();
print_status();
break;
case '7':
wtv020sd16p.mute();
print_status();
break;
case '8':
wtv020sd16p.unmute();
print_status();
break;
}
}
}
void print_title() {
gText Title;
Title.DefineArea(1,0,1,19);
Title.SelectFont(System5x7);
Title.CursorTo(1,0);
Title.print ("Alison's MP3 player");
return ;
}
void print_track() {
gText Status;
Status.DefineArea(1,2,1,16);
Status.SelectFont(System5x7);
Status.CursorTo(2,2ll);
Status.print("Playing Track ");
Status.print(track);
return ;
}
void print_status() {
gText Status;
Status.DefineArea(3,6,1,15);
Status.SelectFont(System5x7);
Status.CursorTo(3,6);
if (track==6){
Status.print("Playback Paused");
}
else if (track==7){
Status.print("Audio Muted");
}
else if (track==8){
Status.print("Audio Unmuted");
}
return ;
}
@Robotonics
Copy link
Author

remove print_title from setup ()...try in loop ()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment