added get_ardvoice macro to the crate
This commit is contained in:
parent
928d1fae1c
commit
8792cc6bdd
3 changed files with 13 additions and 3 deletions
|
@ -18,7 +18,7 @@ pub unsafe extern "C" fn setup() {
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
arduboy.begin();
|
arduboy.begin();
|
||||||
arduboy.set_frame_rate(30);
|
arduboy.set_frame_rate(30);
|
||||||
ardvoice.play_voice(get_sprite_addr!(song))
|
ardvoice.play_voice(get_ardvoice_tone_addr!(song))
|
||||||
}
|
}
|
||||||
|
|
||||||
// The loop() function repeats forever after setup() is done
|
// The loop() function repeats forever after setup() is done
|
||||||
|
@ -30,7 +30,7 @@ pub unsafe extern "C" fn loop_() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if arduboy.pressed(B) {
|
if arduboy.pressed(B) {
|
||||||
ardvoice.play_voice(get_sprite_addr!(song))
|
ardvoice.play_voice(get_ardvoice_tone_addr!(song))
|
||||||
}
|
}
|
||||||
if arduboy.pressed(A) {
|
if arduboy.pressed(A) {
|
||||||
ardvoice.stop_voice()
|
ardvoice.stop_voice()
|
||||||
|
|
|
@ -85,6 +85,14 @@ macro_rules! get_sprite_addr {
|
||||||
}
|
}
|
||||||
pub(super) use get_sprite_addr;
|
pub(super) use get_sprite_addr;
|
||||||
|
|
||||||
|
///Create a `const` raw pointer to a ardvoice tone as u8, without creating an intermediate reference.
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! get_ardvoice_tone_addr {
|
||||||
|
( $s:expr ) => {
|
||||||
|
unsafe { addr_of!($s) as *const u8 }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
pub(super) use get_ardvoice_tone_addr;
|
||||||
///Create a `const` raw pointer to a sprite as u16, without creating an intermediate reference.
|
///Create a `const` raw pointer to a sprite as u16, without creating an intermediate reference.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_tones_addr {
|
macro_rules! get_tones_addr {
|
||||||
|
|
|
@ -19,7 +19,9 @@ pub use crate::library::eeprom::{EEPROM, EEPROMBYTE, EEPROMBYTECHECKLESS};
|
||||||
pub use crate::library::progmem::Pstring;
|
pub use crate::library::progmem::Pstring;
|
||||||
pub use crate::library::sprites;
|
pub use crate::library::sprites;
|
||||||
pub use crate::print::*;
|
pub use crate::print::*;
|
||||||
pub use crate::{f, get_sprite_addr, get_string_addr, get_tones_addr, progmem};
|
pub use crate::{
|
||||||
|
f, get_ardvoice_tone_addr, get_sprite_addr, get_string_addr, get_tones_addr, progmem,
|
||||||
|
};
|
||||||
use core::cmp;
|
use core::cmp;
|
||||||
pub use core::ffi::{
|
pub use core::ffi::{
|
||||||
c_char, c_double, c_float, c_int, c_long, c_longlong, c_size_t, c_uchar, c_uint, c_ulong,
|
c_char, c_double, c_float, c_int, c_long, c_longlong, c_size_t, c_uchar, c_uint, c_ulong,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue