Skip to content

Commit

Permalink
added support for USB Disks (#18)
Browse files Browse the repository at this point in the history
* added support for USB Disks

* tiny update

* followed naming convention
  • Loading branch information
mrmaddin authored and Makuna committed Apr 13, 2019
1 parent 13af1e0 commit 2461622
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
12 changes: 12 additions & 0 deletions examples/PlayAdvertisements/PlayAdvertisements.ino
Expand Up @@ -31,14 +31,26 @@ public:
{
Serial.println("Card online ");
}
static void OnUsbOnline(uint16_t code)
{
Serial.println("USB Disk online ");
}
static void OnCardInserted(uint16_t code)
{
Serial.println("Card inserted ");
}
static void OnUsbInserted(uint16_t code)
{
Serial.println("USB Disk inserted ");
}
static void OnCardRemoved(uint16_t code)
{
Serial.println("Card removed ");
}
static void OnUsbRemoved(uint16_t code)
{
Serial.println("USB Disk removed ");
}
};

// instance a DFMiniMp3 object,
Expand Down
21 changes: 21 additions & 0 deletions examples/PlayMp3/PlayMp3.ino
Expand Up @@ -39,19 +39,40 @@ public:
Serial.println(code);
}

static void OnUsbOnline(uint16_t code)
{
Serial.println();
Serial.print("USB Disk online ");
Serial.println(code);
}

static void OnCardInserted(uint16_t code)
{
Serial.println();
Serial.print("Card inserted ");
Serial.println(code);
}

static void OnUsbInserted(uint16_t code)
{
Serial.println();
Serial.print("USB Disk inserted ");
Serial.println(code);
}

static void OnCardRemoved(uint16_t code)
{
Serial.println();
Serial.print("Card removed ");
Serial.println(code);
}

static void OnUsbRemoved(uint16_t code)
{
Serial.println();
Serial.print("USB Disk removed ");
Serial.println(code);
}
};

// instance a DFMiniMp3 object,
Expand Down
12 changes: 12 additions & 0 deletions examples/PlayRandom/PlayRandom.ino
Expand Up @@ -27,14 +27,26 @@ public:
{
Serial.println("Card online ");
}
static void OnUsbOnline(uint16_t code)
{
Serial.println("USB Disk online ");
}
static void OnCardInserted(uint16_t code)
{
Serial.println("Card inserted ");
}
static void OnUsbInserted(uint16_t code)
{
Serial.println("USB Disk inserted ");
}
static void OnCardRemoved(uint16_t code)
{
Serial.println("Card removed ");
}
static void OnUsbRemoved(uint16_t code)
{
Serial.println("USB Disk removed ");
}
};

// instance a DFMiniMp3 object,
Expand Down
19 changes: 17 additions & 2 deletions src/DFMiniMp3.h
Expand Up @@ -65,7 +65,7 @@ enum DfMp3_Eq

enum DfMp3_PlaySource
{
DfMp3_PlaySource_U,
DfMp3_PlaySource_Usb,
DfMp3_PlaySource_Sd,
DfMp3_PlaySource_Aux,
DfMp3_PlaySource_Sleep,
Expand Down Expand Up @@ -404,7 +404,8 @@ template<class T_SERIAL_METHOD, class T_NOTIFICATION_METHOD> class DFMiniMp3
{
switch (replyCommand)
{
case 0x3d:
case 0x3d: // micro sd
case 0x3c: // usb
T_NOTIFICATION_METHOD::OnPlayFinished(replyArg);
break;

Expand All @@ -414,20 +415,34 @@ template<class T_SERIAL_METHOD, class T_NOTIFICATION_METHOD> class DFMiniMp3
_isOnline = true;
T_NOTIFICATION_METHOD::OnCardOnline(replyArg);
}
else if (replyArg & 0x01)
{
_isOnline = true;
T_NOTIFICATION_METHOD::OnUsbOnline(replyArg);
}
break;

case 0x3A:
if (replyArg & 0x02)
{
T_NOTIFICATION_METHOD::OnCardInserted(replyArg);
}
else if (replyArg & 0x01)
{
T_NOTIFICATION_METHOD::OnUsbInserted(replyArg);
}
break;

case 0x3B:
if (replyArg & 0x02)
{
T_NOTIFICATION_METHOD::OnCardRemoved(replyArg);
}
else if (replyArg & 0x01)
{
T_NOTIFICATION_METHOD::OnUsbRemoved(replyArg);
}

break;

case 0x40:
Expand Down

0 comments on commit 2461622

Please sign in to comment.