|
8 | 8 | padHours: true, |
9 | 9 | showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute |
10 | 10 | font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2 |
| 11 | + whenToShow: 0, // 0=always, 1=on clock only |
11 | 12 | }, require("Storage").readJSON("widalarmeta.json",1) || {}); |
12 | 13 |
|
13 | 14 | if (config.font == 0) { |
|
55 | 56 | let calcWidth = 0; |
56 | 57 | let drawSeconds = false; |
57 | 58 |
|
58 | | - if (next > 0 && next <= config.maxhours*60*60*1000) { |
59 | | - const hours = Math.floor((next-1) / 3600000).toString(); |
60 | | - const minutes = Math.floor(((next-1) % 3600000) / 60000).toString(); |
61 | | - const seconds = Math.floor(((next-1) % 60000) / 1000).toString(); |
62 | | - drawSeconds = (config.showSeconds & 0b01 && !Bangle.isLocked()) || (config.showSeconds & 0b10 && next <= 1000*60); |
63 | | - |
64 | | - g.reset(); // reset the graphics context to defaults (color/font/etc) |
65 | | - g.setFontAlign(-1,0); // center font in y direction |
66 | | - g.clearRect(this.x, this.y, this.x+this.width-1, this.y+23); |
67 | | - |
68 | | - var text = ""; |
69 | | - if (config.padHours) { |
70 | | - text += hours.padStart(2, '0'); |
71 | | - } else { |
72 | | - text += hours; |
73 | | - } |
74 | | - text += ":" + minutes.padStart(2, '0'); |
75 | | - if (drawSeconds) { |
76 | | - text += ":" + seconds.padStart(2, '0'); |
77 | | - } |
78 | | - if (config.font == 0) { |
79 | | - g.setFont("5x9Numeric7Seg:1x2"); |
80 | | - } else if (config.font == 1) { |
81 | | - g.setFont("Teletext5x9Ascii:1x2"); |
82 | | - } else { |
83 | | - // Default to this if no other font is set. |
84 | | - g.setFont("6x8:1x2"); |
85 | | - } |
86 | | - g.drawString(text, this.x+1, this.y+12); |
87 | | - |
88 | | - calcWidth = g.stringWidth(text) + 2; // One pixel on each side |
89 | | - this.bellVisible = false; |
90 | | - } else if (config.drawBell && this.numActiveAlarms > 0) { |
91 | | - calcWidth = 24; |
92 | | - // next alarm too far in future, draw only widalarm bell |
93 | | - if (this.bellVisible !== true || fromInterval !== true) { |
94 | | - g.reset().drawImage(atob("GBgBAAAAAAAAABgADhhwDDwwGP8YGf+YMf+MM//MM//MA//AA//AA//AA//AA//AA//AB//gD//wD//wAAAAADwAABgAAAAAAAAA"),this.x,this.y); |
95 | | - this.bellVisible = true; |
| 59 | + // If always showing, or the clock is visible |
| 60 | + if (config.whenToShow === 0 || Bangle.CLOCK) { |
| 61 | + // Determine text and width |
| 62 | + if (next > 0 && next <= config.maxhours*60*60*1000) { |
| 63 | + const hours = Math.floor((next-1) / 3600000).toString(); |
| 64 | + const minutes = Math.floor(((next-1) % 3600000) / 60000).toString(); |
| 65 | + const seconds = Math.floor(((next-1) % 60000) / 1000).toString(); |
| 66 | + drawSeconds = (config.showSeconds & 0b01 && !Bangle.isLocked()) || (config.showSeconds & 0b10 && next <= 1000*60); |
| 67 | + |
| 68 | + g.reset(); // reset the graphics context to defaults (color/font/etc) |
| 69 | + g.setFontAlign(-1,0); // center font in y direction |
| 70 | + g.clearRect(this.x, this.y, this.x+this.width-1, this.y+23); |
| 71 | + |
| 72 | + var text = ""; |
| 73 | + if (config.padHours) { |
| 74 | + text += hours.padStart(2, '0'); |
| 75 | + } else { |
| 76 | + text += hours; |
| 77 | + } |
| 78 | + text += ":" + minutes.padStart(2, '0'); |
| 79 | + if (drawSeconds) { |
| 80 | + text += ":" + seconds.padStart(2, '0'); |
| 81 | + } |
| 82 | + if (config.font == 0) { |
| 83 | + g.setFont("5x9Numeric7Seg:1x2"); |
| 84 | + } else if (config.font == 1) { |
| 85 | + g.setFont("Teletext5x9Ascii:1x2"); |
| 86 | + } else { |
| 87 | + // Default to this if no other font is set. |
| 88 | + g.setFont("6x8:1x2"); |
| 89 | + } |
| 90 | + g.drawString(text, this.x+1, this.y+12); |
| 91 | + |
| 92 | + calcWidth = g.stringWidth(text) + 2; // One pixel on each side |
| 93 | + this.bellVisible = false; |
| 94 | + } else if (config.drawBell && this.numActiveAlarms > 0) { |
| 95 | + calcWidth = 24; |
| 96 | + // next alarm too far in future, draw only widalarm bell |
| 97 | + if (this.bellVisible !== true || fromInterval !== true) { |
| 98 | + g.reset().drawImage(atob("GBgBAAAAAAAAABgADhhwDDwwGP8YGf+YMf+MM//MM//MA//AA//AA//AA//AA//AA//AB//gD//wD//wAAAAADwAABgAAAAAAAAA"),this.x,this.y); |
| 99 | + this.bellVisible = true; |
| 100 | + } |
96 | 101 | } |
97 | 102 | } |
98 | 103 |
|
|
0 commit comments