-
Notifications
You must be signed in to change notification settings - Fork 9
/
Page Format.txt
329 lines (313 loc) · 11.5 KB
/
Page Format.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
The RaspDacDisplay code now allows the display to be configured to show content in a more flexible way. Each state of the system (e.g. Play, Stop) has a PageList which is a collection of pages, each of which determines what to show, and how long to show it. While in a particular state, the system walks through each page of a PageList, displaying the page for the duration specified within the Page definition. Here is a quick description of each part of a PageList.
PageList consists of...
name: The name of the page list. Must have PAGE_Start and PAGE_Stop for the two main player modes.
alert: An alert directive (if the page is used to display an alert message)
interruptible: Whether the page is interruptible or not (default is True). Mainly used for alert messages.
pages: An array of Pages (in to be displayed order)
An alert directive consists of ...
variable: The variable to monitor
type: The type of monitoring (change, above, below, range)
suppressonstatechange: Whether the monitoring of a variable should be ignored if the state of the system changes (e.g. Play -> Stop sets volume to 0)
values: An array of values to compare against. Should be missing or none for change, one var for above/below, and two for range.
coolingperiod: The amount of time that must be waited for the alert can be displayed again.
A Page consists of...
name: The name of the page
duration: Length of time to display the page
hidewhenempty: Directive to hide page if variables are empty (True or all, any, False)
If set to all or True, all variables must by empty for the page to be skipped
If set to any, any empty variable will cause the page to be skipped
Any other value will force the page to be displayed regardless of variable value
hidewhenemptyvars: A list of variables to test for empty if hidewhenempty is set
lines: An array of lines to display on the page
A line consists of ...
name: The name of the line
variable: An array of variables in to-be-displayed order
format: A format string e.g "Artist {0} / Title {1}".
strftime: A strftime style format string used to format current_time_formatted (see strftime.org for examples)
justification: How should the line be justified ("left", "right", "center")?
scroll: Sets whether scrolling is enabled for the line or not (True, False).
ALERT_LIST consists of...
PageLists: An array of Pages each of which must have an alert directive
To create a new PageList for a particular state, you modify what is assigned to the PAGE list variables (PAGE_Play, PAGE_Stop). Note that PageLists use a combination of dictionary and array structures. Be careful to make sure that you follow the formatting carefully so that the PageList structure can still be parsed.
The variable values that you use within your PageLists must be returned by the status functions. Currently the following variables are supported.
'state' - The current state of the system (e.g. play, stop)
'artist' - The name of the artist for the song that is currently playing
'title' - The name of the song that is currently playing
'album' - The name of the album that is currently playing
'current' - The amount of time the current song has been playing in seconds
'duration' - The length of the current song in seconds
'position' - A formatted combination of current and duration (e.g. ##:##/##:##)
'volume' - The current volume of the player
'playlist_position' - The number of the current track in the play list
'playlist_count' - The number of tracks currently in the play list
'playlist_display' - A formatted combination of playlist_count and playlist_display (e.g. ##/##)
Displays "Streaming" if content is a streaming source without playlist information
'bitrate' - The bitrate of the current track
'type' - The encoding type of the current track (e.g. FLAC, MP3)
'current_tempc' - Current system temperature in celsius
'current_tempf' - Current system temperature in fahrenheit
'disk_avail' - Amount of bytes current left on root partition
'disk_availp' - Percentage of disk used on root partition
'current_time' - The current local time (assuming TIMEZONE is set correctly)
'current_time_formatted - The current local time formatted using strftime variable (if present)
'current_date' - The current date (assuming TIMEZONE is set correctly)
'current_ip' - The current IP address of the system
For Play and Stop states, the system walks through each of the Pages in the current state's page file, displaying page each for that pages duration. If the state of the system changes while a Page is being displayed, the display immediately switches to display the first page of the new state.
Alerting operates differently. Each PageList in the ALERT_LIST represents a timely or urgent message that may need to be displayed based upon a condition that the specific PageList in the Alert_LIST is monitoring. This is specified in the alert directive for that particular PageList. If the alert condition is met, that PageList is immediately displayed. Normally, there is only one page per PageList in the ALERT_LIST and that Page will be set to not be interruptible. This means that if the system state changes while an alert message is being displayed, the display will not update to show the new status until the alert page duration expires. To prevent an alert from monopolizing the display, there is also a CoolingPeriod value that can be set that will not allow the alert to occur even if the monitoring condition is still met. The default CoolingPeriod is set by the COOLINGPERIOD variable.
Example
PAGES_Play = {
'name':"Play",
'pages':
[
{
'name':"Album",
'duration':10,
'hidewhenempty':'all',
'hidewhenemptyvars': [ "album" ],
'lines': [
{
'name':"top",
'variables': [ "album" ],
'format':"Album: {0}",
'justification':"left",
'scroll':True
},
{
'name':"bottom",
'variables': [ "playlist_position", "playlist_count", "position" ],
'format':"{0}/{1} {2}",
'justification':"left",
'scroll':False
}
]
},
{
'name':"Blank",
'duration':0.5,
'lines': [
{
'name':"top",
'format':"",
},
{
'name':"bottom",
'variables': [ "playlist_position", "playlist_count", "position" ],
'format':"{0}/{1} {2}",
'justification':"left",
'scroll':False
}
]
},
{
'name':"Artist",
'duration':10,
'hidewhenempty':'all',
'hidewhenemptyvars': [ "artist" ],
'lines': [
{
'name':"top",
'variables': [ "artist" ],
'format':"Artist: {0}",
'justification':"left",
'scroll':True
},
{
'name':"bottom",
'variables': [ "playlist_position", "playlist_count", "position" ],
'format':"{0}/{1} {2}",
'justification':"left",
'scroll':False
}
]
},
{
'name':"Blank",
'duration':0.5,
'lines': [
{
'name':"top",
'format':"",
},
{
'name':"bottom",
'variables': [ "playlist_position", "playlist_count", "position" ],
'format':"{0}/{1} {2}",
'justification':"left",
'scroll':False
}
]
},
{
'name':"Title",
'duration':10,
'hidewhenempty':'all',
'hidewhenemptyvars': [ "title" ],
'lines': [
{
'name':"top",
'variables': [ "title" ],
'format':"Title: {0}",
'justification':"left",
'scroll':True
},
{
'name':"bottom",
'variables': [ "playlist_position", "playlist_count", "position" ],
'format':"{0}/{1} {2}",
'justification':"left",
'scroll':False
}
]
},
{
'name':"Blank",
'duration':0.5,
'lines': [
{
'name':"top",
'format':"",
},
{
'name':"bottom",
'variables': [ "playlist_position", "playlist_count", "position" ],
'format':"{0}/{1} {2}",
'justification':"left",
'scroll':False
}
]
},
{
'name':"Meta Data",
'duration':10,
'hidewhenempty':'any',
'hidewhenemptyvars': [ "bitrate", "type" ],
'lines': [
{
'name':"top",
'variables': [ "bitrate", "type" ],
'format':"Rate: {0}, Type: {1}",
'justification':"left",
'scroll':True
},
{
'name':"bottom",
'variables': [ "playlist_position", "playlist_count", "position" ],
'format':"{0}/{1} {2}",
'justification':"left",
'scroll':False
}
]
}
]
}
PAGES_Stop = {
'name':"Stop",
'pages':
[
{
'name':"Ready",
'duration':10,
'lines': [
{
'name':"top",
'variables': [ ],
'format':"Ready",
'justification':"center",
'scroll':False
},
{
'name':"bottom",
'variables': [ "current_time" ],
'format':"{0}",
'justification':"center",
'scroll':False
}
]
},
{
'name':"IPADDR",
'duration':1.5,
'lines': [
{
'name':"top",
'variables': [ "current_ip" ],
'format':"{0}",
'justification':"center",
'scroll':False
},
{
'name':"bottom",
'variables': [ "current_time" ],
'format':"{0}",
'justification':"center",
'scroll':False
}
]
}
]
}
ALERT_Volume = {
'name':"Volume",
'alert': {
'variable': "volume",
'suppressonstatechange':True,
'type': "change",
'coolingperiod': 0
},
'interruptible':False,
'pages': [
{
'name':"Volume",
'duration':2,
'lines': [
{
'name':"top",
'variables': [ ],
'format':"Volume",
'justification':"center",
'scroll':False
},
{
'name':"bottom",
'variables': [ "volume" ],
'format':"{0}",
'justification':"center",
'scroll':False
}
]
}
]
}
ALERT_VolumeTooHigh = {
'name':"VolumeTooHigh",
'alert': {
'variable': "volume",
'type': "above",
'values': [ 95 ],
'coolingperiod': 15
},
'interruptible':False,
'pages': [
{
'name':"Volume",
'duration':5,
'lines': [
{
'name':"top",
'variables': [ ],
'format':"Volume Too High",
'justification':"center",
'scroll':False
},
{
'name':"bottom",
'variables': [ "volume" ],
'format':"{0}",
'justification':"center",
'scroll':False
}
]
}
]
}
ALERT_LIST = [ PAGES_Volume, PAGES_VolumeTooHigh ]