Package jpigpio.devices
Class VS1053
java.lang.Object
jpigpio.devices.VS1053
public class VS1053
extends java.lang.Object
The VS1053 is an audio device accessed via SPI. We will assume that the VS1053 is connected to hardware SPI as normal. Since the pin out of the VS1053 development board is:
+------+------+------+------+-----+ | XCS | DREQ | MOSI | DGND | 5V | +------+------+------+------+-----+ | XDCS | XRST | SCK | MISO | 5V | +------+------+------+------+-----+
We will assume:
XCS - SPI_CE0 XDCS - SPI_CE1 DREQ - ?? XRST - 5V MOSI - SPI_MOSI SCK - SPI_SCLK DGND - GND MISO - SPI_MISO 5V - 5V
- Author:
- kolban
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
disableMidi()
The LCtech board contains a design flaw.void
dump()
void
endSineTest()
End the sine testjava.lang.String
format(int value, java.lang.String type)
Format a data value into a string.int
getAudata()
int
getBass()
Get the Bass register value.int
getClockF()
Read the ClockF register of the device.int
getMode()
Retrieve the device mode register value.int
getStatus()
Retrieve the status register of the device.int
getVolume()
Read the volume register of the device.void
memoryTest()
Perform a memory testvoid
playFile(java.io.File file)
Play a data file through the device.void
setAudata(int value)
void
setClockF(int value)
Set the ClockF value.void
setLine(boolean value)
Set the Line vs Mic mode.void
setMode(int value)
Set the device mode register to a supplied value.void
setTestMode(boolean mode)
Enable or disable the test mode of the device.void
setVolume(int value)
A volume value is replicated in the high and low bytes of the volume wordvoid
softReset()
Perform a soft reset of the device.void
startSineTest()
Perform the sine testvoid
waitForReady()
Wait for the DREQ to signal that the device is ready for more work.
-
Constructor Details
-
VS1053
- Throws:
PigpioException
-
-
Method Details
-
getMode
Retrieve the device mode register value.- Returns:
- The value of the device mode register (16 bits).
- Throws:
PigpioException
-
setMode
Set the device mode register to a supplied value.- Parameters:
value
- The value to be placed in the mode register (16 bits).- Throws:
PigpioException
-
getStatus
Retrieve the status register of the device.- Returns:
- The status register of the device (16 bits).
- Throws:
PigpioException
-
getAudata
- Throws:
PigpioException
-
setAudata
- Throws:
PigpioException
-
getVolume
Read the volume register of the device.- Returns:
- The volume register of the device (16 bits).
- Throws:
PigpioException
-
setVolume
A volume value is replicated in the high and low bytes of the volume word- Parameters:
value
- The byte value of the volume- Throws:
PigpioException
-
getClockF
Read the ClockF register of the device.- Returns:
- The ClockF register of the device (16 bits).
- Throws:
PigpioException
-
setClockF
Set the ClockF value.- Parameters:
value
- The value of the ClockF register to be set.- Throws:
PigpioException
-
getBass
Get the Bass register value.- Returns:
- The value of the Bass register.
- Throws:
PigpioException
-
setLine
Set the Line vs Mic mode. A value of true sets Line mode while a value of false sets Mic mode.- Parameters:
value
- The mode to use. True means use line input while false means use Mic input.- Throws:
PigpioException
-
setTestMode
Enable or disable the test mode of the device.- Parameters:
mode
- True to enable the test mode and false to disable.- Throws:
PigpioException
-
waitForReady
Wait for the DREQ to signal that the device is ready for more work.- Throws:
PigpioException
-
softReset
Perform a soft reset of the device.- Throws:
PigpioException
-
format
public java.lang.String format(int value, java.lang.String type)Format a data value into a string. The data value will be data returned from one of the registers that can be formated.- Parameters:
value
- The value of a register.type
- The type of the register that is to be formatted. One of:- AUDATA
- MODE
- Returns:
-
startSineTest
Perform the sine test- Throws:
PigpioException
-
endSineTest
End the sine test- Throws:
PigpioException
-
memoryTest
Perform a memory test- Throws:
PigpioException
-
disableMidi
The LCtech board contains a design flaw. The GPIO 0 and 1 pins are not connected and appear to float high. What this means is that the device enters Midi mode on boot. Correctly, these pins should be set low. One way to achieve this is to physically solder the pins but that is difficult. An alternate is the recipe found in the forum which is to set the GPIO pins to output and explicitly set their values to 0 (low). See the following for details: http://www.bajdi.com/lcsoft-vs1053-mp3-module/- Throws:
PigpioException
-
dump
- Throws:
PigpioException
-
playFile
Play a data file through the device.- Parameters:
file
- The file to play.- Throws:
PigpioException
-