Hello this is my first attempt to build a library and i just cant get it to work
This is my error : im completely lost, i tried a couple of different formats for the constructor but no luck so far....
Arduino:1.8.7 (Windows 10), TD: 1.44, Tarjeta:"Arduino Nano, ATmega328P (Old Bootloader)"
C:\Users\Javier\Documents\Arduino\libraries\javicatalex_mp3player\javicatalex_mp3player.cpp: In constructor 'mp3_catalex::mp3_catalex(int, int)':
C:\Users\Javier\Documents\Arduino\libraries\javicatalex_mp3player\javicatalex_mp3player.cpp:24:36: error: 'sendCommand' was not declared in this scope
sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card
^
C:\Users\Javier\Documents\Arduino\libraries\javicatalex_mp3player\javicatalex_mp3player.cpp: At global scope:
C:\Users\Javier\Documents\Arduino\libraries\javicatalex_mp3player\javicatalex_mp3player.cpp:28:6: error: prototype for 'void mp3_catalex::play_volume(int, int)' does not match any in class 'mp3_catalex'
void mp3_catalex::play_volume(int song_number,int volume ){
^
In file included from C:\Users\Javier\Documents\Arduino\libraries\javicatalex_mp3player\javicatalex_mp3player.cpp:10:0:
C:\Users\Javier\Documents\Arduino\libraries\javicatalex_mp3player\javicatalex_mp3player.h:51:11: error: candidate is: void mp3_catalex::play_volume(byte, byte)
void play_volume(byte song_number,byte volume );
^
exit status 1
Error compilando para la tarjeta Arduino Nano.
Este reporte podría tener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.
This is my header file
#ifndef javicatalex_mp3player_h
#define javicatalex_mp3player_h
////////////////////////COMMANDS FOR THE SERIAL COMMUNICATION WITH THE MP3 PLAYER///////////////////////////
#define NEXT_SONG 0X01
#define PREV_SONG 0X02
#define CMD_PLAY_W_INDEX 0X03 //DATA IS REQUIRED (number of song)
#define VOLUME_UP_ONE 0X04
#define VOLUME_DOWN_ONE 0X05
#define CMD_SET_VOLUME 0X06//DATA IS REQUIRED (number of volume from 0 up to 30(0x1E))
#define SET_DAC 0X17
#define CMD_PLAY_WITHVOLUME 0X22 //data is needed 0x7E 06 22 00 xx yy EF;(xx volume)(yy number of song)
#define CMD_SEL_DEV 0X09 //SELECT STORAGE DEVICE, DATA IS REQUIRED
#define DEV_TF 0X02 //HELLO,IM THE DATA REQUIRED
#define SLEEP_MODE_START 0X0A
#define SLEEP_MODE_WAKEUP 0X0B
#define CMD_RESET 0X0C//CHIP RESET
#define CMD_PLAY 0X0D //RESUME PLAYBACK
#define CMD_PAUSE 0X0E //PLAYBACK IS PAUSED
#define CMD_PLAY_WITHFOLDER 0X0F//DATA IS NEEDED, 0x7E 06 0F 00 01 02 EF;(play the song with the directory \01\002xxxxxx.mp3
#define STOP_PLAY 0X16
#define PLAY_FOLDER 0X17// data is needed 0x7E 06 17 00 01 XX EF;(play the 01 folder)(value xx we dont care)
#define SET_CYCLEPLAY 0X19//data is needed 00 start; 01 close
#define SET_DAC 0X17//data is needed 00 start DAC OUTPUT;01 DAC no output
////////////////////////////////////////////////////////////////////////////////////
#include "Arduino.h"
//#include <SoftwareSerial.h>
class mp3_catalex
{
public:
mp3_catalex(int ARDUINO_RX_PIN,int ARDUINO_TX_PIN);
void play_volume(byte song_number,byte volume );
private:
int command_data;
};
#endif
and this is my cpp file
#include "Arduino.h"
#include "javicatalex_mp3player.h"
#include <SoftwareSerial.h>
mp3_catalex::mp3_catalex(int ARDUINO_RX_PIN,int ARDUINO_TX_PIN){
pinMode(ARDUINO_RX_PIN, INPUT);
pinMode(ARDUINO_TX_PIN, OUTPUT);
SoftwareSerial mySerial(ARDUINO_RX_PIN, ARDUINO_TX_PIN);//init the serial protocol, tell to myserial wich pins are TX and Rx
mySerial.begin(9600);//Start our Serial coms for THE MP3 9600 BAUDS
delay(500);//Wait chip initialization is complete
sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card
delay(200);//wait for 200ms
}
void mp3_catalex::play_volume(int song_number,int volume ){
command_data=(((song_number&0xff)<<8)&(volume&0xff);
sendCommand(CMD_PLAY_WITHVOLUME, command_data);
}
This is my .ino file
#include "javicatalex_mp3player.h"
#include <SoftwareSerial.h>
mp3_catalex my_mp3(5, 6);
byte song=1;
byte volume=1;
void setup() {
Serial.begin(9600);
}
void loop() {
my_mp3.play_volume(0x01, 0x01);
}