Uses 1117K of libraries. Click here for Pure Java version (7296L/39K).
!7 cmodule AlarmOnPowerLoss > DynPrintLogAndEnabled { switchable bool setOff; switchable S mp3SnippetID = #1001093; transient Player player; start-thread { if (!enabled) ret; if (setOff) print("Already set off. Reset in menu"); print("Setting live in 10..."); doWithSleep(10.0, r { loadLibrary(mp3SnippetID) }); if (!enabled) ret; print("Alarm live."); doEvery(5.0, r check); } void check enter { if (enabled && !setOff && linux_batteryDischarging()) setOff(); } void setOff { setField(setOff := true); action(); } void action enter { cleanMeUp(); player = playMP3(loadLibrary(mp3SnippetID)); } visual withCenteredButtons(super, "Reset/Shut Up", rThread reset, "Test", rThread action); void reset enter { shutUp(); setField(setOff := false); print("Reset."); } void shutUp enter { cleanMeUp(); } void cleanMeUp { if (player != null) player.close(); player = null; } }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1026041 |
Snippet name: | Alarm When Power Source Unlugged |
Eternal ID of this version: | #1026041/8 |
Text MD5: | 9c10bb0cfb3dc84bf42c3fc343f9629d |
Transpilation MD5: | a33a22644b2ecd03bb4c098342be819a |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-11-13 23:25:05 |
Source code size: | 1063 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 211 / 337 |
Version history: | 7 change(s) |
Referenced in: | -