@@ -24,14 +24,14 @@ void DFRobotDFPlayerMini::uint16ToArray(uint16_t value, uint8_t *array){
2424
2525uint16_t DFRobotDFPlayerMini::calculateCheckSum (uint8_t *buffer){
2626 uint16_t sum = 0 ;
27- for (int i=Stack::Version ; i<Stack::CheckSum ; i++) {
27+ for (int i=Stack_Version ; i<Stack_CheckSum ; i++) {
2828 sum += buffer[i];
2929 }
3030 return -sum;
3131}
3232
3333void DFRobotDFPlayerMini::sendStack (){
34- if (_sending[Stack::ACK ]) {
34+ if (_sending[Stack_ACK ]) {
3535 while (_isSending) {
3636 available ();
3737 }
@@ -51,17 +51,17 @@ void DFRobotDFPlayerMini::sendStack(){
5151#endif
5252 _serial->write (_sending, DFPLAYER_SEND_LENGTH);
5353 _timeOutTimer = millis ();
54- _isSending = _sending[Stack::ACK ];
54+ _isSending = _sending[Stack_ACK ];
5555}
5656
5757void DFRobotDFPlayerMini::sendStack (uint8_t command){
5858 sendStack (command, 0 );
5959}
6060
6161void DFRobotDFPlayerMini::sendStack (uint8_t command, uint16_t argument){
62- _sending[Stack::Command ] = command;
63- uint16ToArray (argument, _sending+Stack::Parameter );
64- uint16ToArray (calculateCheckSum (_sending), _sending+Stack::CheckSum );
62+ _sending[Stack_Command ] = command;
63+ uint16ToArray (argument, _sending+Stack_Parameter );
64+ uint16ToArray (calculateCheckSum (_sending), _sending+Stack_CheckSum );
6565 sendStack ();
6666}
6767
@@ -72,17 +72,17 @@ void DFRobotDFPlayerMini::sendStack(uint8_t command, uint8_t argumentHigh, uint8
7272}
7373
7474void DFRobotDFPlayerMini::enableACK (){
75- _sending[Stack::ACK ] = 0x01 ;
75+ _sending[Stack_ACK ] = 0x01 ;
7676}
7777
7878void DFRobotDFPlayerMini::disableACK (){
79- _sending[Stack::ACK ] = 0x00 ;
79+ _sending[Stack_ACK ] = 0x00 ;
8080}
8181
8282bool DFRobotDFPlayerMini::waitAvailable (){
8383 _isSending = true ;
8484 while (!available ());
85- return _handleType != HandleType:: TimeOut;
85+ return _handleType != TimeOut;
8686}
8787
8888bool DFRobotDFPlayerMini::begin (Stream &stream, bool isACK){
@@ -102,7 +102,7 @@ bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK){
102102 return (readType () == DFPlayerCardOnline) || !isACK;
103103}
104104
105- HandleType DFRobotDFPlayerMini::readType (){
105+ uint8_t DFRobotDFPlayerMini::readType (){
106106 _isAvailable = false ;
107107 return _handleType;
108108}
@@ -112,15 +112,15 @@ uint16_t DFRobotDFPlayerMini::read(){
112112 return _handleParameter;
113113}
114114
115- bool DFRobotDFPlayerMini::handleMessage (HandleType type, uint16_t parameter){
115+ bool DFRobotDFPlayerMini::handleMessage (uint8_t type, uint16_t parameter){
116116 _receivedIndex = 0 ;
117117 _handleType = type;
118118 _handleParameter = parameter;
119119 _isAvailable = true ;
120120 return _isAvailable;
121121}
122122
123- bool DFRobotDFPlayerMini::handleError (HandleType type, uint16_t parameter){
123+ bool DFRobotDFPlayerMini::handleError (uint8_t type, uint16_t parameter){
124124 handleMessage (type, parameter);
125125 _isSending = false ;
126126}
@@ -131,30 +131,30 @@ uint8_t DFRobotDFPlayerMini::readCommand(){
131131}
132132
133133void DFRobotDFPlayerMini::parseStack (){
134- _handleCommand = *(_received + Stack::Command );
135- _handleParameter = arrayToUint16 (_received + Stack::Parameter );
134+ _handleCommand = *(_received + Stack_Command );
135+ _handleParameter = arrayToUint16 (_received + Stack_Parameter );
136136
137137 switch (_handleCommand) {
138138 case 0x3D :
139- handleMessage (HandleType:: DFPlayerPlayFinished, _handleParameter);
139+ handleMessage (DFPlayerPlayFinished, _handleParameter);
140140 break ;
141141 case 0x3F :
142142 if (_handleParameter & 0x02 ) {
143- handleMessage (HandleType:: DFPlayerCardOnline, _handleParameter);
143+ handleMessage (DFPlayerCardOnline, _handleParameter);
144144 }
145145 break ;
146146 case 0x3A :
147147 if (_handleParameter & 0x02 ) {
148- handleMessage (HandleType:: DFPlayerCardInserted, _handleParameter);
148+ handleMessage (DFPlayerCardInserted, _handleParameter);
149149 }
150150 break ;
151151 case 0x3B :
152152 if (_handleParameter & 0x02 ) {
153- handleMessage (HandleType:: DFPlayerCardRemoved, _handleParameter);
153+ handleMessage (DFPlayerCardRemoved, _handleParameter);
154154 }
155155 break ;
156156 case 0x40 :
157- handleMessage (HandleType:: DFPlayerError, _handleParameter);
157+ handleMessage (DFPlayerError, _handleParameter);
158158 break ;
159159 case 0x41 :
160160 _isSending = false ;
@@ -190,19 +190,19 @@ uint16_t DFRobotDFPlayerMini::arrayToUint16(uint8_t *array){
190190}
191191
192192bool DFRobotDFPlayerMini::validateStack (){
193- return calculateCheckSum (_received) == arrayToUint16 (_received+Stack::CheckSum );
193+ return calculateCheckSum (_received) == arrayToUint16 (_received+Stack_CheckSum );
194194}
195195
196196bool DFRobotDFPlayerMini::available (){
197197 while (_serial->available ()) {
198198 if (_receivedIndex == 0 ) {
199- _received[Stack::Header ] = _serial->read ();
199+ _received[Stack_Header ] = _serial->read ();
200200#ifdef _DEBUG
201201 Serial.print (F (" received:" ));
202202 Serial.print (_received[_receivedIndex],HEX);
203203 Serial.print (F (" " ));
204204#endif
205- if (_received[Stack::Header ] == 0x7E ) {
205+ if (_received[Stack_Header ] == 0x7E ) {
206206 _isAvailable = false ;
207207 _receivedIndex ++;
208208 }
@@ -214,17 +214,17 @@ bool DFRobotDFPlayerMini::available(){
214214 Serial.print (F (" " ));
215215#endif
216216 switch (_receivedIndex) {
217- case Stack::Version :
217+ case Stack_Version :
218218 if (_received[_receivedIndex] != 0xFF ) {
219219 return handleError (WrongStack);
220220 }
221221 break ;
222- case Stack::Length :
222+ case Stack_Length :
223223 if (_received[_receivedIndex] != 0x06 ) {
224224 return handleError (WrongStack);
225225 }
226226 break ;
227- case Stack::End :
227+ case Stack_End :
228228#ifdef _DEBUG
229229 Serial.println ();
230230#endif
@@ -235,7 +235,7 @@ bool DFRobotDFPlayerMini::available(){
235235 if (validateStack ()) {
236236 _receivedIndex = 0 ;
237237 parseStack ();
238- if (_isAvailable && !_sending[Stack::ACK ]) {
238+ if (_isAvailable && !_sending[Stack_ACK ]) {
239239 _isSending = false ;
240240 }
241241 return _isAvailable;
0 commit comments