DFPlayerMini Library porting from Arduino Library (www.github.com/dfrobot/DFPlayer_Mini_Mp3)
DFPlayerMini.h@0:62b52a8325e3, 2016-11-22 (annotated)
- Committer:
- kysiki
- Date:
- Tue Nov 22 17:00:13 2016 +0000
- Revision:
- 0:62b52a8325e3
DFPlayerMini?????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kysiki | 0:62b52a8325e3 | 1 | /******************************************************************************* |
kysiki | 0:62b52a8325e3 | 2 | * Copyright (C) 2014 DFRobot * |
kysiki | 0:62b52a8325e3 | 3 | * * |
kysiki | 0:62b52a8325e3 | 4 | * DFPlayer_Mini_Mp3, This library provides a quite complete function for * |
kysiki | 0:62b52a8325e3 | 5 | * DFPlayer mini mp3 module. * |
kysiki | 0:62b52a8325e3 | 6 | * www.github.com/dfrobot/DFPlayer_Mini_Mp3 (github as default source provider)* |
kysiki | 0:62b52a8325e3 | 7 | * DFRobot-A great source for opensource hardware and robot. * |
kysiki | 0:62b52a8325e3 | 8 | * * |
kysiki | 0:62b52a8325e3 | 9 | * This file is part of the DFplayer_Mini_Mp3 library. * |
kysiki | 0:62b52a8325e3 | 10 | * * |
kysiki | 0:62b52a8325e3 | 11 | * DFPlayer_Mini_Mp3 is free software: you can redistribute it and/or * |
kysiki | 0:62b52a8325e3 | 12 | * modify it under the terms of the GNU Lesser General Public License as * |
kysiki | 0:62b52a8325e3 | 13 | * published by the Free Software Foundation, either version 3 of * |
kysiki | 0:62b52a8325e3 | 14 | * the License, or any later version. * |
kysiki | 0:62b52a8325e3 | 15 | * * |
kysiki | 0:62b52a8325e3 | 16 | * DFPlayer_Mini_Mp3 is distributed in the hope that it will be useful, * |
kysiki | 0:62b52a8325e3 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
kysiki | 0:62b52a8325e3 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
kysiki | 0:62b52a8325e3 | 19 | * GNU Lesser General Public License for more details. * |
kysiki | 0:62b52a8325e3 | 20 | * * |
kysiki | 0:62b52a8325e3 | 21 | * DFPlayer_Mini_Mp3 is distributed in the hope that it will be useful, * |
kysiki | 0:62b52a8325e3 | 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
kysiki | 0:62b52a8325e3 | 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
kysiki | 0:62b52a8325e3 | 24 | * GNU Lesser General Public License for more details. * |
kysiki | 0:62b52a8325e3 | 25 | * * |
kysiki | 0:62b52a8325e3 | 26 | * You should have received a copy of the GNU Lesser General Public * |
kysiki | 0:62b52a8325e3 | 27 | * License along with DFPlayer_Mini_Mp3. If not, see * |
kysiki | 0:62b52a8325e3 | 28 | * <http://www.gnu.org/licenses/>. * |
kysiki | 0:62b52a8325e3 | 29 | ******************************************************************************/ |
kysiki | 0:62b52a8325e3 | 30 | |
kysiki | 0:62b52a8325e3 | 31 | // =========================================================================== |
kysiki | 0:62b52a8325e3 | 32 | // DFPlayerMini.cpp |
kysiki | 0:62b52a8325e3 | 33 | // Nov 23 2016, kysiki |
kysiki | 0:62b52a8325e3 | 34 | // =========================================================================== |
kysiki | 0:62b52a8325e3 | 35 | // Just a simple library for DFPlayer Mini porting from DFPlayer library V2.0. |
kysiki | 0:62b52a8325e3 | 36 | // (https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299) |
kysiki | 0:62b52a8325e3 | 37 | #ifndef MBED_SHIFTREG_H |
kysiki | 0:62b52a8325e3 | 38 | #define MBED_DFPLAYERMINI_H |
kysiki | 0:62b52a8325e3 | 39 | |
kysiki | 0:62b52a8325e3 | 40 | class DFPlayerMini { |
kysiki | 0:62b52a8325e3 | 41 | public: |
kysiki | 0:62b52a8325e3 | 42 | DFPlayerMini(PinName txPin, PinName rxPin); |
kysiki | 0:62b52a8325e3 | 43 | void mp3_set_reply (uint8_t state); |
kysiki | 0:62b52a8325e3 | 44 | void mp3_play_physical (uint16_t num); |
kysiki | 0:62b52a8325e3 | 45 | void mp3_play_physical (); |
kysiki | 0:62b52a8325e3 | 46 | void mp3_next (); |
kysiki | 0:62b52a8325e3 | 47 | void mp3_prev (); |
kysiki | 0:62b52a8325e3 | 48 | void mp3_set_volume (uint16_t volume); |
kysiki | 0:62b52a8325e3 | 49 | void mp3_set_EQ (uint16_t eq); |
kysiki | 0:62b52a8325e3 | 50 | void mp3_set_device (uint16_t device); |
kysiki | 0:62b52a8325e3 | 51 | void mp3_sleep (); |
kysiki | 0:62b52a8325e3 | 52 | void mp3_reset (); |
kysiki | 0:62b52a8325e3 | 53 | void mp3_play (); |
kysiki | 0:62b52a8325e3 | 54 | void mp3_pause (); |
kysiki | 0:62b52a8325e3 | 55 | void mp3_stop (); |
kysiki | 0:62b52a8325e3 | 56 | void mp3_play (uint16_t num); |
kysiki | 0:62b52a8325e3 | 57 | void mp3_get_state (); |
kysiki | 0:62b52a8325e3 | 58 | void mp3_get_volume (); |
kysiki | 0:62b52a8325e3 | 59 | void mp3_get_u_sum (); |
kysiki | 0:62b52a8325e3 | 60 | void mp3_get_tf_sum (); |
kysiki | 0:62b52a8325e3 | 61 | void mp3_get_flash_sum (); |
kysiki | 0:62b52a8325e3 | 62 | void mp3_get_tf_current (); |
kysiki | 0:62b52a8325e3 | 63 | void mp3_get_u_current (); |
kysiki | 0:62b52a8325e3 | 64 | void mp3_get_flash_current (); |
kysiki | 0:62b52a8325e3 | 65 | void mp3_single_loop (uint8_t state); |
kysiki | 0:62b52a8325e3 | 66 | void mp3_single_play (uint16_t num); |
kysiki | 0:62b52a8325e3 | 67 | void mp3_DAC (uint8_t state); |
kysiki | 0:62b52a8325e3 | 68 | void mp3_random_play (); |
kysiki | 0:62b52a8325e3 | 69 | |
kysiki | 0:62b52a8325e3 | 70 | private: |
kysiki | 0:62b52a8325e3 | 71 | Serial mp3; |
kysiki | 0:62b52a8325e3 | 72 | uint8_t send_buf[10]; |
kysiki | 0:62b52a8325e3 | 73 | uint8_t recv_buf[10]; |
kysiki | 0:62b52a8325e3 | 74 | uint8_t is_reply; |
kysiki | 0:62b52a8325e3 | 75 | static void fill_uint16_bigend (uint8_t *thebuf, uint16_t data); |
kysiki | 0:62b52a8325e3 | 76 | uint16_t mp3_get_checksum (uint8_t *thebuf); |
kysiki | 0:62b52a8325e3 | 77 | void mp3_fill_checksum (); |
kysiki | 0:62b52a8325e3 | 78 | void send_func (); |
kysiki | 0:62b52a8325e3 | 79 | void mp3_send_cmd (uint8_t cmd, uint16_t arg); |
kysiki | 0:62b52a8325e3 | 80 | void mp3_send_cmd (uint8_t cmd); |
kysiki | 0:62b52a8325e3 | 81 | }; |
kysiki | 0:62b52a8325e3 | 82 | |
kysiki | 0:62b52a8325e3 | 83 | #endif |