diff --git a/display/ssd1306.h b/display/ssd1306.h index f7f087a28..e71830f33 100644 --- a/display/ssd1306.h +++ b/display/ssd1306.h @@ -281,19 +281,31 @@ class StandardDisplayController : public DisplayControllerBase, Sa return last_delay_ = FillFrameBuffer2(advance); } +#ifdef USB_CLASS_MSC + bool EscapeIdleIfNeeded() { + return looped_idle_ == Tristate::True && USBD_Configured(); + } +#else + bool EscapeIdleIfNeeded() { return false; } +#endif + void ShowDefault(bool ignore_lockup = false) { screen_ = SCREEN_PLI; t_ = 0; if (SaberBase::IsOn()) { if (SaberBase::Lockup() && IMG_lock && !ignore_lockup) { - ShowFile(&IMG_lock, 3600000.0); + SetFile(&IMG_lock, 3600000.0); } else if (looped_on_ == Tristate::True) { - ShowFile(&IMG_on, font_config.ProffieOSOnImageDuration); + SetFile(&IMG_on, font_config.ProffieOSOnImageDuration); } } else { // Off if (looped_idle_ != Tristate::False) { - ShowFile(&IMG_idle, 3600000.0); + if (EscapeIdleIfNeeded()) { + SetMessage("usb"); + } else { + SetFile(&IMG_idle, 3600000.0); + } } } } @@ -361,13 +373,11 @@ class StandardDisplayController : public DisplayControllerBase, Sa } case SCREEN_IMAGE: -#ifdef USB_CLASS_MSC - if (looped_idle_ == Tristate::True && current_effect_ == &IMG_idle && USBD_Configured()) { + if (EscapeIdleIfNeeded() && current_effect_ == &IMG_idle) { // We are idle-looping, and usb is connected. Time to stop. - SB_Message("usb"); + SetMessage("usb"); return FillFrameBuffer2(advance); } -#endif MountSDCard(); { int count = 0; @@ -435,7 +445,8 @@ class StandardDisplayController : public DisplayControllerBase, Sa if (IMG_font) { ShowFile(&IMG_font, font_config.ProffieOSFontImageDuration); } else if (prop.current_preset_name()) { - SB_Message(prop.current_preset_name()); + SetMessage(prop.current_preset_name()); + SetScreenNow(SCREEN_MESSAGE); } else if (IMG_idle) { ShowFile(&IMG_idle, 3600000.0); } @@ -460,10 +471,10 @@ class StandardDisplayController : public DisplayControllerBase, Sa } } - void SB_Message(const char* text) { + void SetMessage(const char* text) { strncpy(message_, text, sizeof(message_)); message_[sizeof(message_)-1] = 0; - SetScreenNow(SCREEN_MESSAGE); + screen_ = SCREEN_MESSAGE; } void SB_Top(uint64_t total_cycles) override { @@ -497,20 +508,27 @@ class StandardDisplayController : public DisplayControllerBase, Sa display_->Page(); } - bool ShowFile(Effect* effect, float duration) { + bool SetFile(Effect* effect, float duration) { if (!*effect) return false; MountSDCard(); eof_ = true; file_.Play(effect); frame_available_ = false; frame_count_ = 0; - SetScreenNow(SCREEN_IMAGE); + screen_ = SCREEN_IMAGE; eof_ = false; current_effect_ = effect; effect_display_duration_ = duration; return true; } + bool ShowFile(Effect* effect, float duration) { + if (SetFile(effect, duration)) { + SetScreenNow(SCREEN_IMAGE); + } + return true; + } + void ShowFile(const char* file) { MountSDCard(); eof_ = true;