pyupm_wt5001 module

class pyupm_wt5001.WT5001(uart)[source]

Bases: object

API for the WT5001 Serial MP3 Module.

ID: wt5001

Name: Serial MP3 Module

Other Names: Grove Serial MP3 Player

Category: sound

Manufacturer: seeed

Link:http://www.seeedstudio.com/wiki/Grove_%E2%80%93_Serial_MP3_Player

Connection: uart UPM support for the WT5001 Serial MP3 module. This was tested specifically with the Grove Serial MP3 module.

C++ includes: wt5001.hpp

ALL_REPEAT = 2
CLEAR_ALARM = 181
CLEAR_ALARM_DUR = 182
COPY_SD2FLASH = 170
COPY_UDISK2FLASH = 171
INSERT_SONG = 172
NEXT = 165
NONE = 0
NORMAL = 0
PAUSE = 163
PLAY_MODE = 169
PLAY_SD = 160
PLAY_SPI = 161
PLAY_UDISK = 162
PREVIOUS = 166
QUEUE = 168
RANDOM = 3
READ_CF_CHAR = 199
READ_CUR_FNAME = 198
READ_DATE = 209
READ_PLAY_STATE = 194
READ_SD_NUMF = 196
READ_SPI_NUMF = 195
READ_TIME = 210
READ_UDISK_NUMF = 197
READ_VOLUME = 193
SD = 0
SET_ALARM = 179
SET_ALARM_DUR = 180
SET_DATE = 177
SET_TIME = 178
SET_VOLUME = 167
SINGLE_REPEAT = 1
SPI = 1
STOP = 164
UDISK = 2
checkResponse(opcode)[source]

bool checkResponse(WT5001_OPCODE_T opcode)

Gets a command response and returns its validity

opcode: Opcode to verify

True if successful

clearAlarm()[source]

bool clearAlarm()

Clears any alarm that has been set

True if successful

dataAvailable(millis)[source]

bool dataAvailable(unsigned int millis)

Checks to see if there is data available for reading

millis: Number of milliseconds to wait; 0 means no waiting

True if there is data available for reading

getCurrentFile(curf)[source]

uint16_t getCurrentFile()

Gets the index of the current file

Index of the curretn file

std::runtime_error: if reading from the sensor failed

getCurrentFileNoParam()[source]

uint16_t getCurrentFile()

Gets the index of the current file

Index of the curretn file

std::runtime_error: if reading from the sensor failed

getDate(year, month, day)[source]

bool getDate(uint16_t *year, uint8_t *month, uint8_t *day)

Gets the device date

year: 4-digit year

month: Month

day: Day

True if successful

getNumFiles(psrc, numf)[source]

uint16_t getNumFiles(WT5001_PLAYSOURCE_T psrc)

Gets the number of files present on the source device

psrc: Storage source

Number of files

std::runtime_error: if reading from the sensor failed

getNumFilesOneParam(psrc)[source]

uint16_t getNumFiles(WT5001_PLAYSOURCE_T psrc)

Gets the number of files present on the source device

psrc: Storage source

Number of files

std::runtime_error: if reading from the sensor failed

getPlayState(ps)[source]

uint8_t getPlayState()

Gets the current play state: 1 = playing, 2 = stopped, 3 = paused

Play state

std::runtime_error: if reading from the sensor failed

getPlayStateNoParam()[source]

uint8_t getPlayState()

Gets the current play state: 1 = playing, 2 = stopped, 3 = paused

Play state

std::runtime_error: if reading from the sensor failed

getTime(hour, minute, second)[source]

bool getTime(uint8_t *hour, uint8_t *minute, uint8_t *second)

Gets the device time

hour: Hour

minute: Minute

second: Second

True if successful

getVolume(vol)[source]

uint8_t getVolume()

Gets the current volume

Volume

std::runtime_error: if reading from the sensor failed

getVolumeNoParam()[source]

uint8_t getVolume()

Gets the current volume

Volume

std::runtime_error: if reading from the sensor failed

insert(index)[source]

bool insert(uint16_t index)

Inserts a track to play immediately, interrupting the current track. When the inserted track is finished, the interrupted track resumes where it was interrupted.

index: File number to insert

True if successful

next()[source]

bool next()

Moves to the next track

True if successful

pause()[source]

bool pause()

Pauses the playback or resumes it if already paused

True if successful

play(psrc, index)[source]

bool play(WT5001_PLAYSOURCE_T psrc, uint16_t index)

Plays a file from a source

psrc: Play source (SD, UDISK, SPI)

index: File number to play

True if successful

previous()[source]

bool previous()

Moves to the previous track

True if successful

queue(index)[source]

bool queue(uint16_t index)

Queues a track to play next, when the current song is finished

index: File number to queue

True if successful

readData(buffer, len)[source]

int readData(char *buffer, int len)

Reads any available data in a user-supplied buffer. Note: the call blocks until data is available to be read. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.

buffer: Buffer to hold the data read

len: Length of the buffer

Number of bytes read

setAlarm(hour, minute, second)[source]

bool setAlarm(uint8_t hour, uint8_t minute, uint8_t second)

Sets the alarm

hour: Hour

minute: Minute

second: Second

True if successful

setDate(year, month, day)[source]

bool setDate(uint16_t year, uint8_t month, uint8_t day)

Sets the date of the internal clock

year: 4-digit year

month: Month

day: Day

True if successful

setPlayMode(pm)[source]

bool setPlayMode(WT5001_PLAYMODE_T pm)

Sets the playback mode

pm: Play mode to enable

True if successful

setTime(hour, minute, second)[source]

bool setTime(uint8_t hour, uint8_t minute, uint8_t second)

Sets the time of the internal clock

hour: Hour

minute: Minute

second: Second

True if successful

setVolume(vol)[source]

bool setVolume(uint8_t vol)

Sets the volume. Valid range is 0-31. 0 means mute.

True if successful

setupTty(*args)[source]

bool setupTty(speed_t baud=B9600)

Sets up proper tty I/O modes and the baud rate. The default baud rate is 9,600 (B9600).

baud: Desired baud rate.

True if successful

stop()[source]

bool stop()

Stops playing

True if successful

writeData(buffer, len)[source]

int writeData(char *buffer, int len)

Writes the data in the buffer to the device

buffer: Buffer to hold the data read

len: Length of the buffer

Number of bytes written

class pyupm_wt5001.uint16Array(nelements)[source]

Bases: object

cast()[source]
static frompointer()
class pyupm_wt5001.uint8Array(nelements)[source]

Bases: object

cast()[source]
static frompointer()