123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include <signal.h>
- #include "wt5001.h"
-
- using namespace std;
-
- void printUsage(char *progname)
- {
- cout << "Usage:" << progname << " <command>" << endl;
- cout << "Commands:" << endl;
- cout << "0 - stop playing" << endl;
- cout << "1 - start playing track 1" << endl;
- cout << "2 - pause/un-pause playback" << endl;
- cout << "3 - next track" << endl;
- cout << "4 - previous track" << endl;
- }
-
- int main (int argc, char **argv)
- {
-
-
-
-
- upm::WT5001* mp3 = new upm::WT5001(0);
-
- int cmd = -1;
- if (argc > 1)
- cmd = atoi(argv[1]);
-
-
- if (!mp3->setupTty(B9600))
- {
- cerr << "Failed to setup tty port parameters" << endl;
- return 1;
- }
-
- switch (cmd)
- {
- case 0:
- mp3->stop();
- break;
-
- case 1:
- mp3->play(upm::WT5001::SD, 1);
- break;
-
- case 2:
- mp3->pause();
- break;
-
- case 3:
- mp3->next();
- break;
-
- case 4:
- mp3->previous();
- break;
-
- default:
-
- printUsage(argv[0]);
- break;
- }
-
-
-
-
-
-
-
-
- uint8_t vol = 0;
- if (mp3->getVolume(&vol))
- cout << "The current volume is: " << int(vol) << endl;
-
- uint8_t ps = 0;
- if (mp3->getPlayState(&ps))
- cout << "The current play state is: " << int(ps) << endl;
-
- uint16_t numf = 0;
- if (mp3->getNumFiles(upm::WT5001::SD, &numf))
- cout << "The number of files on the SD card is: " << int(numf) << endl;
-
- uint16_t curf = 0;
- if (mp3->getCurrentFile(&curf))
- cout << "The current file is: " << int(curf) << endl;
-
- uint16_t year = 0;
- uint8_t month = 0, day = 0;
- if (mp3->getDate(&year, &month, &day))
- cout << "The device date is: " << int(month) << "/" << int(day)
- << "/" << int(year) << endl;
-
- uint8_t hour = 0, minute = 0, second = 0;
- if (mp3->getTime(&hour, &minute, &second))
- cout << "The device time is: " << int(hour) << ":" << int(minute)
- << ":" << int(second) << endl;
-
-
-
- cout << "Exiting..." << endl;
-
- delete mp3;
- return 0;
- }
|