// version 02 jetpack animations simplified & morsecodedisplaycontroller added #ifndef MULTIPROPDISPLAYCONTROLLER_H #define MULTIPROPDISPLAYCONTROLLER_H /* add to ssd1306.h #ifdef PROPS_MULTI_PROP_H // added by Oli #include "multipropdisplaycontroller.h" // added by Oli #endif // added by Oli */ struct MultiPropDisplayConfigFile : public ConfigFile { MultiPropDisplayConfigFile() { link(&font_config); } void iterateVariables(VariableOP *op) override { CONFIG_VARIABLE2(ProffieOSSaberModeImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSBlasterModeImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSDetonatorModeImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSJetpackModeImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSMorsecodeModeImageDuration, 1000.0f); } // for OLED displays, the time a sabermode.bmp will play float ProffieOSSaberModeImageDuration; // for OLED displays, the time a blastermode.bmp will play float ProffieOSBlasterModeImageDuration; // for OLED displays, the time a detonatormode.bmp will play float ProffieOSDetonatorModeImageDuration; // for OLED displays, the time a jetpackmode.bmp will play float ProffieOSJetpackModeImageDuration; // for OLED displays, the time a morsecodemode.bmp will play float ProffieOSMorsecodeModeImageDuration; }; #define ONCE_PER_MULTIPROP_EFFECT(X) \ X(sabermode) \ X(blastermode) \ X(detonatormode) \ X(jetpackmode) \ X(morsecodemode) template> struct MultiPropDisplayEffects { MultiPropDisplayEffects() : dummy_(0) ONCE_PER_MULTIPROP_EFFECT(INIT_IMG) {} int dummy_; ONCE_PER_MULTIPROP_EFFECT(DEF_IMG) }; template> class MultiPropDisplayController : public StandardDisplayController { public: MultiPropDisplayEffects img_; MultiPropDisplayConfigFile &multiprop_font_config; MultiPropDisplayController() : img_(*getPtr>()), multiprop_font_config(*getPtr()) {} void SB_Effect2(EffectType effect, EffectLocation location) override { switch (effect) { case EFFECT_SABERMODE: if (img_.IMG_sabermode) ShowFileWithSoundLength(&img_.IMG_sabermode, multiprop_font_config.ProffieOSSaberModeImageDuration); else { SetMessage("saber/nmode"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_BLASTERMODE: if (img_.IMG_blastermode) ShowFileWithSoundLength(&img_.IMG_blastermode, multiprop_font_config.ProffieOSBlasterModeImageDuration); else { SetMessage("blaster/n mode"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_DETONATORMODE: if (img_.IMG_detonatormode) ShowFileWithSoundLength(&img_.IMG_detonatormode, multiprop_font_config.ProffieOSDetonatorModeImageDuration); else { SetMessage("detonator/n mode"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_JETPACKMODE: if (img_.IMG_jetpackmode) ShowFileWithSoundLength(&img_.IMG_jetpackmode, multiprop_font_config.ProffieOSJetpackModeImageDuration); else { SetMessage("jetpack/nmode"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_MORSECODEMODE: if (img_.IMG_morsecodemode) ShowFileWithSoundLength(&img_.IMG_morsecodemode, multiprop_font_config.ProffieOSMorsecodeModeImageDuration); else { SetMessage("morse code/n mode"); SetScreenNow(SCREEN_MESSAGE); } break; default: StandardDisplayController::SB_Effect2(effect, location); } } void SB_Off2(typename StandardDisplayController::OffType offtype, EffectLocation location) override { if (offtype == StandardDisplayController::OFF_BLAST) { ShowFileWithSoundLength(img_.IMG_sabermode, multiprop_font_config.ProffieOSSaberModeImageDuration); } else { StandardDisplayController::SB_Off2(offtype, location); } } }; /**********************************\ |* *| |* JETPACK DISPLAY CONTROLLER *| |* *| \**********************************/ struct JetpackDisplayConfigFile : public ConfigFile { JetpackDisplayConfigFile() { link(&font_config); } void iterateVariables(VariableOP *op) override { CONFIG_VARIABLE2(ProffieOSFalseStartImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSStutteringImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSSelfDestructImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSAimingImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSTargettingImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSMissileLaunchImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSMissileGoesBoomImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSMandoTalkImageDuration, 1000.0f); CONFIG_VARIABLE2(ProffieOSDisarmImageDuration, 1000.0f); } // for OLED displays, the time a falsestart.bmp will play float ProffieOSFalseStartImageDuration; // for OLED displays, the time a stuttering.bmp will play float ProffieOSStutteringImageDuration; // for OLED displays, the time a shutdown.bmp will play float ProffieOSSelfDestructImageDuration; // for OLED displays, the time a aiming.bmp will play float ProffieOSAimingImageDuration; // for OLED displays, the time a targetting.bmp will play float ProffieOSTargettingImageDuration; // for OLED displays, the time a missilelaunch.bmp will play float ProffieOSMissileLaunchImageDuration; // for OLED displays, the time a missilegoesboom.bmp will play float ProffieOSMissileGoesBoomImageDuration; // for OLED displays, the time a mandotalk.bmp will play float ProffieOSMandoTalkImageDuration; // for OLED displays, the time a disarm.bmp will play float ProffieOSDisarmImageDuration; }; #define ONCE_PER_JETPACK_EFFECT(X) \ X(startidlemode) \ X(idle) \ X(falsestart) \ X(startjetpack) \ X(running) \ X(stuttering) \ X(shutdown) \ X(selfdestruct) \ X(aiming) \ X(targetting) \ X(missilelaunch) \ X(missilegoesboom) \ X(mandotalk) \ X(disarm) template> struct JetpackDisplayEffects { JetpackDisplayEffects() : dummy_(0) ONCE_PER_JETPACK_EFFECT(INIT_IMG) {} int dummy_; ONCE_PER_JETPACK_EFFECT(DEF_IMG) }; template> class JetpackDisplayController : public StandardDisplayController { public: JetpackDisplayEffects img_; JetpackDisplayConfigFile &jetpack_font_config; JetpackDisplayController() : img_(*getPtr>()), jetpack_font_config(*getPtr()) {} void SB_Effect2(EffectType effect, EffectLocation location) override { switch (effect) { // jetpack missile display effects: Make animations for OLED from the episode from Mando S02E06 // ================================ case EFFECT_AIMING: if (img_.IMG_aiming) // animation of viewfinder coming down ShowFileWithSoundLength(&img_.IMG_aiming, jetpack_font_config.ProffieOSAimingImageDuration); else { SetMessage("aiming"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_TARGETTING: if (img_.IMG_targetting) // animation of targetting ShowFileWithSoundLength(&img_.IMG_targetting, jetpack_font_config.ProffieOSTargettingImageDuration); else { SetMessage("targetting"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_MISSILELAUNCH: if (img_.IMG_missilelaunch) // animation of jetpack launching missile ShowFileWithSoundLength(&img_.IMG_missilelaunch, jetpack_font_config.ProffieOSMissileLaunchImageDuration); else { SetMessage("launching\nmissile"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_MISSILEGOESBOOM: if (img_.IMG_missilegoesboom) // animation of explosion ShowFileWithSoundLength(&img_.IMG_missilegoesboom, jetpack_font_config.ProffieOSMissileGoesBoomImageDuration); else { SetMessage("missile\nexplodes"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_MANDOTALK: if (img_.IMG_mandotalk) // animation of mando & boba talking: "Nice shot! I was aiming for the other one!" ShowFileWithSoundLength(&img_.IMG_mandotalk, jetpack_font_config.ProffieOSMandoTalkImageDuration); else { SetMessage("nice shot"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_DISARM: if (img_.IMG_disarm) // animation of viewfinder going back up ShowFileWithSoundLength(&img_.IMG_disarm, jetpack_font_config.ProffieOSDisarmImageDuration); else { SetMessage("disarming"); SetScreenNow(SCREEN_MESSAGE); } break; // jetpack misshaps display effects: // ================================= case EFFECT_FALSESTART: if (img_.IMG_falsestart) // Jetpack with "smoke fart" animation ShowFileWithSoundLength(&img_.IMG_falsestart, jetpack_font_config.ProffieOSFalseStartImageDuration); else { SetMessage("jetpack\nfalse start"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_STUTTERING: if (img_.IMG_stuttering) // Jetpack with trail of "smoke farts" animation ShowFileWithSoundLength(&img_.IMG_stuttering, jetpack_font_config.ProffieOSStutteringImageDuration); else { SetMessage("jetpack\nstuttering"); SetScreenNow(SCREEN_MESSAGE); } break; case EFFECT_SELFDESTRUCT: if (img_.selfdestruct) // Jetpack exploding animation ShowFileWithSoundLength(&img_.selfdestruct, jetpack_font_config.ProffieOSSelfDestructImageDuration); else { SetMessage("jetpack\nself destruct"); SetScreenNow(SCREEN_MESSAGE); } break; // jetpack normal operation display effects: (I do not have any idea of animations for these!) // ========================================= (So I think the text only will do, at least for now?) case EFFECT_STARTIDLEMODE: SetMessage("jetpack\nigniting"); SetScreenNow(SCREEN_MESSAGE); break; case EFFECT_IDLE: SetMessage("jetpack\nidling"); SetScreenNow(SCREEN_MESSAGE); break; case EFFECT_STARTJETPACK: SetMessage("jetpack\nstarting"); SetScreenNow(SCREEN_MESSAGE); break; case EFFECT_RUNNING: SetMessage("jetpack\running"); SetScreenNow(SCREEN_MESSAGE); break; case EFFECT_SHUTDOWN: SetMessage("jetpack\nshutdown"); SetScreenNow(SCREEN_MESSAGE); break; case EFFECT_STOP: SetMessage(" jetpack\ncompletely off"); SetScreenNow(SCREEN_MESSAGE); break; default: StandardDisplayController::SB_Effect2(effect, location); } } void SB_Off2(typename StandardDisplayController::OffType offtype, EffectLocation location) override { if (offtype == StandardDisplayController::OFF_BLAST) { ShowFileWithSoundLength(img_.IMG_disarm, jetpack_font_config.ProffieOSDisarmImageDuration); } else { StandardDisplayController::SB_Off2(offtype, location); } } }; /************************************\ |* *| |* MORSECODE DISPLAY CONTROLLER *| |* *| \************************************/ struct MorseCodeDisplayConfigFile : public ConfigFile { MorseCodeDisplayConfigFile() { link(&font_config); } void iterateVariables(VariableOP *op) override { CONFIG_VARIABLE2(ProffieOSShowMorseCodeImageDuration, 1000.0f); } // for OLED displays, the time a showmorsecode.bmp will play float ProffieOSShowMorseCodeImageDuration; }; #define ONCE_PER_MORSECODE_EFFECT(X) \ X(showmorsecode) template> struct MorseCodeDisplayEffects { MorseCodeDisplayEffects() : dummy_(0) ONCE_PER_MORSECODE_EFFECT(INIT_IMG) {} int dummy_; ONCE_PER_MORSECODE_EFFECT(DEF_IMG) }; template> class MorseCodeDisplayController : public StandardDisplayController { public: MorseCodeDisplayEffects img_; MorseCodeDisplayConfigFile &morsecode_font_config; MorseCodeDisplayController() : img_(*getPtr>()), morsecode_font_config(*getPtr()) {} void SB_Effect2(EffectType effect, EffectLocation location) override { switch (effect) { case EFFECT_SHOWMORSECODE: SetMessage("add morsecode\ndisplay variable here"); // To do: create a function in morsecode_prop.h that will set the SetScreenNow(SCREEN_MESSAGE); // value of "variable" that can be used here. break; default: StandardDisplayController::SB_Effect2(effect, location); } } void SB_Off2(typename StandardDisplayController::OffType offtype, EffectLocation location) override { if (offtype == StandardDisplayController::OFF_SHOWMORSECODE) { ShowFileWithSoundLength(img_.IMG_showmorsecode, morsecode_font_config.ProffieOSShowMorseCodeImageDuration); } else { StandardDisplayController::SB_Off2(offtype, location); } } }; #endif //MULTIPROPDISPLAYCONTROLLER_H