qwiic-mp3-trigger

Crates.ioqwiic-mp3-trigger
lib.rsqwiic-mp3-trigger
version0.1.2
sourcesrc
created_at2018-06-09 20:14:42.405484
updated_at2018-06-10 21:58:26.436598
descriptioni2c interface to the SparkFun Sqiic MP3 Trigger (https://www.sparkfun.com/products/14714)
homepagehttps://github.com/querry43/rust-qwiic-mp3-trigger
repositoryhttps://github.com/querry43/rust-qwiic-mp3-trigger
max_upload_size
id69384
size32,082
Matt Harrington (querry43)

documentation

https://github.com/querry43/rust-qwiic-mp3-trigger/blob/master/README.md

README

rust-qwiic-mp3-trigger

Build status License crates.io Documentation

A rust crate for the Sparkfun Qwiic MP3 Trigger (https://www.sparkfun.com/products/14714).

Synopsys

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();
}

Configuring i2c

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

Debugging

This crate uses the log crate for debug! and trace! logging. Enable it by initializing a logger such as simple_logger.

Commit count: 3

cargo fmt