Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the DYPlayer as an instance in another object instance #62

Open
sbarabe opened this issue May 10, 2024 · 1 comment
Open

Using the DYPlayer as an instance in another object instance #62

sbarabe opened this issue May 10, 2024 · 1 comment

Comments

@sbarabe
Copy link

sbarabe commented May 10, 2024

Hi, in an arduino sketch on Platformio, I'm trying to create an instance of the DYPlayer in an ohter instance.

I am using Nano Every and the DYPlayerArduino.h

Exemple:

> class AudioPlayer
> {
> private:
>     DY::Player _dyPlayer;
> public:
>     Player(Stream *serial):_dyPlayer(serial){}
> };

Then in the main sketch I'm using:

AudioPlayer(&Serial) ;

ou

AudioPlayer(&SoftSerial)

but I keep having those messages at compile:

no instance of constructor "DY::Player::Player" matches the argument list
argument types are: (arduino::Stream )
conversion` from 'arduino::Stream
' to 'const DY::Player' is ambiguous

Do you think it's possible to fix this ? Thank you !

@sbarabe
Copy link
Author

sbarabe commented May 10, 2024

Ok here is how I solve my problem. The only thig I'm not sure is if the constructor with no argument ( Player_DY::Player_DY() : _player(){}; ) really works and if it is initiating a DYPlayer with hardware serial ?

`

#include <Arduino.h>
#include <DYPlayerArduino.h>
#include <SoftwareSerial.h>

SoftwareSerial serial(4, 5);

class Player_DY
{
private:
  DY::Player _player;

public:
  Player_DY::Player_DY(SoftwareSerial &serial) : _player(&serial){};
  Player_DY::Player_DY(HardwareSerial &serial) : _player(&serial){};
  Player_DY::Player_DY() : _player(){};
  void begin()
  {
    _player.begin();
  }
};

Player_DY playerSW(serial);
Player_DY playerHW(Serial1);
Player_DY player;

void setup()
{
player.begin();
playerSW.begin();
playerHW.begin();
}

void loop()
{ }

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant