Crates.io | qwiic-mp3-trigger |
lib.rs | qwiic-mp3-trigger |
version | 0.1.2 |
source | src |
created_at | 2018-06-09 20:14:42.405484 |
updated_at | 2018-06-10 21:58:26.436598 |
description | i2c interface to the SparkFun Sqiic MP3 Trigger (https://www.sparkfun.com/products/14714) |
homepage | https://github.com/querry43/rust-qwiic-mp3-trigger |
repository | https://github.com/querry43/rust-qwiic-mp3-trigger |
max_upload_size | |
id | 69384 |
size | 32,082 |
A rust crate for the Sparkfun Qwiic MP3 Trigger (https://www.sparkfun.com/products/14714).
extern crate i2cdev;
extern crate qwiic_mp3_trigger;
use i2cdev::linux::LinuxI2CDevice;
fn main() {
let i2cdev = LinuxI2CDevice::new("/dev/i2c-1", 0x37).unwrap();
let mut mp3_trigger = qwiic_mp3_trigger::QwiicMP3Trigger::new(i2cdev).unwrap();
mp3_trigger.ping().unwrap();
let version: String = mp3_trigger.get_version().unwrap();
let song_count: u8 = mp3_trigger.get_song_count().unwrap();
let card_status: qwiic_mp3_trigger::CardStatus = mp3_trigger.get_card_status().unwrap();
mp3_trigger.play_track(1).unwrap();
mp3_trigger.play_filenumber(1).unwrap();
mp3_trigger.play_next().unwrap();
mp3_trigger.play_previous().unwrap();
mp3_trigger.stop().unwrap();
mp3_trigger.pause().unwrap();
let song_name: String = mp3_trigger.get_song_name().unwrap();
let play_status: qwiic_mp3_trigger::PlayStatus = mp3_trigger.get_play_status().unwrap();
mp3_trigger.set_eq(qwiic_mp3_trigger::EqualizerMode::Bass).unwrap();
mp3_trigger.set_volume(31).unwrap();
mp3_trigger.set_address(0x88).unwrap();
}
The raspberry pi is a good deal faster than the attiny85 in this module. Communication is flakey unless you slow down the rate. Add the following to /boot/config.txt
and reboot.
dtparam=i2c_baudrate=50000
This crate uses the log crate for debug!
and trace!
logging. Enable it by initializing a logger such as simple_logger.