From 6ff1c13b222b7f8b26ae192fc08cdae04898500e Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sat, 20 Feb 2016 14:54:06 -0500 Subject: [PATCH] we already have a minimal begin, it's boot() --- src/Arduboy.cpp | 12 +++--------- src/Arduboy.h | 25 +++++++++++++++++-------- src/audio/audio.cpp | 5 +++++ src/audio/audio.h | 2 +- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Arduboy.cpp b/src/Arduboy.cpp index 60a76f2..9dab6b4 100644 --- a/src/Arduboy.cpp +++ b/src/Arduboy.cpp @@ -26,27 +26,21 @@ void Arduboy::start() // deprecated void Arduboy::begin() { - boot(); + boot(); // raw hardware + // utils if(pressed(UP_BUTTON)) { flashlight(); } bootLogo(); - // Audio - tunes.initChannel(PIN_SPEAKER_1); - tunes.initChannel(PIN_SPEAKER_2); audio.begin(); } -void Arduboy::beginMinimal() +void Arduboy::beginNoLogo() // deprecated { boot(); - - // Audio - tunes.initChannel(PIN_SPEAKER_1); - tunes.initChannel(PIN_SPEAKER_2); audio.begin(); } diff --git a/src/Arduboy.h b/src/Arduboy.h index 40775b3..b679b30 100644 --- a/src/Arduboy.h +++ b/src/Arduboy.h @@ -41,16 +41,25 @@ public: */ boolean notPressed(uint8_t buttons); - /// Initializes the hardware + /// Initialize hardware, boot logo, boot utilities, etc. void begin(); - /// Initializes the hardware (no logo, no other bootime niceities) + + /// Init hardware, no logo, no boot utilities. /** - * If you want to build your own customized boot sequence compare - * begin() with beginMinimal() and just add back the things you wish - * to have in your own sequence, leaving out the things you do not - * desire. - **/ - void beginMinimal(); + * If you really want this functionality going foward we recommend + * just call `boot()` directly, then do any other custom init you + * desire before passing control into your main sketch. + * + * Look at the source for `begin()` and just rip out what you do not + * need and start there. + * + * The minimum functionality required is currently: + * + * boot() // raw hardware init (from core) + * audio.begin() // if you need audio + */ + void beginNoLogo() __attribute__ ((deprecated("use boot() + custom code instead"))); + void start() __attribute__ ((deprecated("use begin() instead"))); /// Scrolls in the Arduboy logo diff --git a/src/audio/audio.cpp b/src/audio/audio.cpp index cfd614e..d873a54 100644 --- a/src/audio/audio.cpp +++ b/src/audio/audio.cpp @@ -43,6 +43,11 @@ bool ArduboyAudio::audio_enabled = false; void ArduboyAudio::on() { + // JIT audio init + if (_tune_num_chans == 0) { + ArduboyTunes::initChannel(PIN_SPEAKER_1); + ArduboyTunes::initChannel(PIN_SPEAKER_2); + } power_timer1_enable(); power_timer3_enable(); audio_enabled = true; diff --git a/src/audio/audio.h b/src/audio/audio.h index e239593..63cb70d 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -33,7 +33,7 @@ public: // Playtune Functions /// Assign a timer to an output pin. - void initChannel(byte pin); + void static initChannel(byte pin); /// Start playing a polyphonic score. void playScore(const byte *score);