Reference
Communication Protocol Description
I2C Address Settings
The default I2C address of the recording and playback module is 0x30, which can be manually modified within the range of 0x30-0x39.
- When power off, press and hold the toggle switch, power on at this time
- When the LED light is white, it means entering the I2C address setting mode
- The number displayed by the digital tube is the low bit of the I2C address, such as: 2 means the set address is 0x32; 3 means the set address is 0x33.
- Dial the toggle switch to the address you want to set, press the toggle switch to save.
I2C Recording/Playback
- Recording: Select recording 0, delete recording 0, countdown 3 seconds to start recording, stop after 20 seconds of recording.
- Playback: Start looping from recording 0, skip if there is no recording.
I2C Speech Synthesis
There are two modes for speech synthesis.
- ICE_SYNTHESIS_MODE: Input -123.987, Output "negative one hundred twenty three nine eight seven". Can be used to directly read sensor data, measurement parameters, etc. The valid range of this mode is 9 integers and 9 decimals. If the integer is out of the range, the synthesis will be stopped, and if the decimal is out of the range, the tail will be truncated.
- VOICE_REPLACE_MODE: Input 15071097, Output "one five zero seven one zero nine seven". Can be used to read student ID, phone number, etc. The effective length of this mode is 32 characters, non-numeric characters are automatically skipped, and an error will be reported if the character string is too long.
API Description
/**
* @brief initialization parameters for i2c
* @return 0 or 1, 0 is i2c begin success, 1 is i2c begin error
*/
uint8_t begin();
/**
* @brief Set button mode
* @param BUTTON_MODE_ON 0x00
* @param BUTTON_MODE_OFF 0x01
*/
void setButtonMode(uint8_t mode);
/**
* @brief Set light mode
* @param LIGHT_MODE_OFF 0x00
* @param LIGHT_MODE_ON 0x01
*/
void setLightMode(uint8_t mode);
/**
* @brief set voice number
* @param VOICE_NUMBER_0 0x00
* @param VOICE_NUMBER_1 0x01
* @param VOICE_NUMBER_2 0x02
* @param VOICE_NUMBER_3 0x03
* @param VOICE_NUMBER_4 0x04
* @param VOICE_NUMBER_5 0x05
* @param VOICE_NUMBER_6 0x06
* @param VOICE_NUMBER_7 0x07
* @param VOICE_NUMBER_8 0x08
* @param VOICE_NUMBER_9 0x09
* @return state
* VOICE_SYNTHESISING is speech synthesis state
* VOICE_PLAYING is playing state
* VOICE_RECORDING is recording state
* VOICE_NONE is idle condition set number success
*/
uint8_t setVoiceNumber(uint8_t number);
/**
* @brief get i2c device address
* @return i2c device address
*/
uint8_t getI2CAddress();
/**
* @brief get now state
* @return state
* VOICE_SYNTHESISING is speech synthesis state
* VOICE_PLAYING is playing state
* VOICE_RECORDING is recording state
* VOICE_NONE is idle condition
*/
uint8_t getNowState(void);
/**
* @brief get Button Mode
* @return Mode
* BUTTON_MODE_ON 0x00
* BUTTON_MODE_OFF 0x01
*/
uint8_t getButtonMode(void);
/**
* @brief get light Mode
* @return Mode
* LIGHT_MODE_OFF 0x00
* BUTTON_MODE_OFF 0x01
*/
uint8_t getButtonMode(void);
/**
* @brief get voice number
* @return number
* VOICE_NUMBER_0 0x00
* VOICE_NUMBER_1 0x01
* VOICE_NUMBER_2 0x02
* VOICE_NUMBER_3 0x03
* VOICE_NUMBER_4 0x04
* VOICE_NUMBER_5 0x05
* VOICE_NUMBER_6 0x06
* VOICE_NUMBER_7 0x07
* VOICE_NUMBER_8 0x08
* VOICE_NUMBER_9 0x09
*/
uint8_t getVoiceNumber(void);
/**
* @brief get voice state
* @return state 0 is Current position has audio 1 is empty
*/
uint8_t getVoiceState(void);
/**
* @brief get time reamaining
* @return The time range is 0-100
*/
uint8_t getTimeRemaining(void);
/**
* @brief start record
* @return VOICE_SUCCESS is start record ,VOICE_BUSY is repeat recording or playback,VOICE_NONE is Audio already exists, delete and record
*/
uint8_t recordvoiceStart(void);
/**
* @brief start play
* @return VOICE_SUCCESS is start play ,VOICE_BUSY is repeat recording or playback,VOICE_NONE is no songs in the current number
*/
uint8_t playVoiceStart(void);
/**
* @brief delete voice
* @return VOICE_SUCCESS is delete success ,VOICE_BUSY is repeat recording or playback,VOICE_NONE is no songs in the current number
*/
uint8_t deleteVoice(void);
/**
* @brief End of the tape
* @return VOICE_SUCCESS is end success ,VOICE_NONE is no begin record
*/
uint8_t recordVoiceEnd(void);
/**
* @brief End play
* @return VOICE_SUCCESS is end success ,VOICE_NONE is no begin record
*/
uint8_t playVoiceEnd(void);
/**
* @brief speech synthesis
* @param language is CHINESE_LANGUAGE 0x01
* ENGLISH_LANGUAGE 0x02
* @param number range is (999999999 to -999999999)
* @return VOICE_SUCCESS is speech synthesis success
* VOICE_BUSY is recording or playing. Please finish recording or playing first
* VOICE_SYNTHESISING is In speech synthesis
* DATA_ERROR is data error
* MODE_ERROR is mode error
*/
uint8_t voiceSynthesis(uint8_t language ,int64_t number);
/**
* @brief speech synthesis
* @param language is CHINESE_LANGUAGE 0x01
* ENGLISH_LANGUAGE 0x02
* @param string is Input string the scope is determined by the pattern
* @param mode is VOICE_SYNTHESIS_MODE range (999999999.999999999 to -999999999.999999999)
* VOICE_REPLACE_MODE Nine-bit string
* @return VOICE_SUCCESS is speech synthesis success
* VOICE_BUSY is recording or playing. Please finish recording or playing first
* VOICE_SYNTHESISING is In speech synthesis
* DATA_ERROR is data error
* MODE_ERROR is mode error
*/
uint8_t voiceSynthesis(uint8_t language ,String string ,uint8_t mode);
How to Use
The module function can be easily adjusted by flipping the button for recording and playback.
Recording
- Toggle the switch up and down to select the number that can store the recording. For the number with no recording, the LED does not light up.
- Long press the toggle switch, when the LED turns red, recording starts.
- The number x10 displayed on the digital tube indicates the remaining available recording time. If it displays 8, it means it can record for about 80 seconds.
- Any operation of the toggle switch will stop recording.
Playback
- Flip the switch up and down to select the number with recording. For the number with a recording, the LED shows yellow.
- Short press the toggle switch, the LED will turn green and start playing
- Any operation of the toggle switch will stop recording.
Deletion
- Flip the switch up and down to select the number with recording
- The number with a recording, the LED is yellow
- Long press the toggle switch, the LED light flashes red quickly, start deleting
- After the LED flashes, the deletion is complete, and the current number can be re-recorded.
Mind+ Programming
- Click the link to download the Mind+ software.
- About how to program on Mind+, please refer to https://mindplus.dfrobot.com/microbit.
Was this article helpful?
