Uses 1117K of libraries. Click here for Pure Java version (7296L/39K).
1 | !7 |
2 | |
3 | cmodule AlarmOnPowerLoss > DynPrintLogAndEnabled { |
4 | switchable bool setOff; |
5 | switchable S mp3SnippetID = #1001093; |
6 | |
7 | transient Player player; |
8 | |
9 | start-thread { |
10 | if (!enabled) ret; |
11 | if (setOff) print("Already set off. Reset in menu"); |
12 | print("Setting live in 10..."); |
13 | doWithSleep(10.0, r { loadLibrary(mp3SnippetID) }); |
14 | if (!enabled) ret; |
15 | print("Alarm live."); |
16 | doEvery(5.0, r check); |
17 | } |
18 | |
19 | void check enter { |
20 | if (enabled && !setOff && linux_batteryDischarging()) |
21 | setOff(); |
22 | } |
23 | |
24 | void setOff { |
25 | setField(setOff := true); |
26 | action(); |
27 | } |
28 | |
29 | void action enter { |
30 | cleanMeUp(); |
31 | player = playMP3(loadLibrary(mp3SnippetID)); |
32 | } |
33 | |
34 | visual withCenteredButtons(super, |
35 | "Reset/Shut Up", rThread reset, |
36 | "Test", rThread action); |
37 | |
38 | void reset enter { |
39 | shutUp(); |
40 | setField(setOff := false); |
41 | print("Reset."); |
42 | } |
43 | |
44 | void shutUp enter { cleanMeUp(); } |
45 | |
46 | void cleanMeUp { |
47 | if (player != null) player.close(); |
48 | player = null; |
49 | } |
50 | } |
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: | 212 / 339 |
Version history: | 7 change(s) |
Referenced in: | [show references] |