-
Notifications
You must be signed in to change notification settings - Fork 4
/
MP3.h
86 lines (77 loc) · 2.17 KB
/
MP3.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*****************************************************************************/
/**
@file MP3.h
@author ELECHOUSE
@version V0.2
@brief head file for Arduino MP3 Shield
@section HISTORY
V0.2 2012-12-13 Add software serial support.
V0.1 2012-08-02 Initial version.
Copyright (c) 2012 www.elechouse.com All right reserved.
*/
/*****************************************************************************/
#ifndef __MP3_H
#define __MP3_H
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "wiring_private.h"
#include "SoftwareSerial.h"
#ifndef __TYPE_REDEFINE
#define __TYPE_REDEFINE
typedef uint8_t u8;
typedef int8_t s8;
/****************************************************
* for older IDE before 1.6, please enable line 34
* *************************************************/
//typedef uint16_t u16;
typedef int16_t s16;
typedef uint32_t u32;
typedef int32_t s32;
#endif
/** Serial port definition */
#define COM Serial
typedef enum{
MP3_HARDWARE_SERIAL,
MP3_SOFTWARE_SERIAL
}serial_type_t;
class MP3{
public:
/** constructor */
MP3();
/** begin function, Arduino style */
void begin(serial_type_t st=MP3_HARDWARE_SERIAL );
/** MP3 shield basic send command function */
void send_cmd(u8 *cmd);
/** play music in SD, and choose SD mode */
void play_sd(u16 num);
/** play music in USB, and choose USB mode */
void play_usb_disk(u16 num);
/** play music in SPI FLASH */
void play_spi_flash(u16 num);
/** play next music */
void next();
/** play previous music */
void previous();
/** pause when play, play when pause */
void pause();
/** stop playing */
void stop();
/** set volume */
void volume(u8 vol);
/** set mode, Use SINGLE, REPEAT, CYCLE or RANDOM as parameter */
void set_mode(u8 mode);
enum {SINGLE=0, REPEAT=1, CYCLE=2, RANDOM=3};
/** copy files from SD to SPI FLASH */
void sd_to_flash(void);
/** copy files from USB to SPI FLASH */
void usb_to_flash(void);
private:
/** command buffer */
enum {CMD_BUF_LEN = 10};
u8 cmd_buf[CMD_BUF_LEN];
serial_type_t serial_type;
};
#endif