topherfangio-lcdproc-ruby 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +9 -0
- data/Rakefile +70 -0
- data/TODO +18 -0
- data/VERSION +1 -0
- data/devices/crystalfontz/packet.rb +108 -0
- data/devices/devices.rb +41 -0
- data/examples/basic.rb +39 -0
- data/examples/clock.rb +78 -0
- data/examples/lights.rb +67 -0
- data/lcdproc.rb +43 -0
- data/lib/console.rb +39 -0
- data/lib/core_extensions/array.rb +37 -0
- data/lib/core_extensions/string.rb +37 -0
- data/lib/includes/lcdproc.rb +27 -0
- data/lib/lcdproc-ruby.rb +0 -0
- data/lib/lcdproc/client.rb +458 -0
- data/lib/lcdproc/command.rb +54 -0
- data/lib/lcdproc/errors.rb +41 -0
- data/lib/lcdproc/key_event.rb +59 -0
- data/lib/lcdproc/menu.rb +188 -0
- data/lib/lcdproc/menu_event.rb +49 -0
- data/lib/lcdproc/menu_item.rb +108 -0
- data/lib/lcdproc/menu_items/action.rb +72 -0
- data/lib/lcdproc/menu_items/alpha.rb +85 -0
- data/lib/lcdproc/menu_items/checkbox.rb +76 -0
- data/lib/lcdproc/menu_items/ip.rb +75 -0
- data/lib/lcdproc/menu_items/numeric.rb +75 -0
- data/lib/lcdproc/menu_items/ring.rb +75 -0
- data/lib/lcdproc/menu_items/slider.rb +83 -0
- data/lib/lcdproc/menu_items/submenu.rb +77 -0
- data/lib/lcdproc/response.rb +65 -0
- data/lib/lcdproc/screen.rb +283 -0
- data/lib/lcdproc/widget.rb +142 -0
- data/lib/lcdproc/widgets/graph.rb +185 -0
- data/lib/lcdproc/widgets/hbar.rb +101 -0
- data/lib/lcdproc/widgets/icon.rb +94 -0
- data/lib/lcdproc/widgets/num.rb +92 -0
- data/lib/lcdproc/widgets/scroller.rb +110 -0
- data/lib/lcdproc/widgets/string.rb +94 -0
- data/lib/lcdproc/widgets/title.rb +90 -0
- data/lib/lcdproc/widgets/vbar.rb +111 -0
- data/script/console.rb +28 -0
- data/script/telnet.rb +90 -0
- data/tasks/test/basic.rake +82 -0
- data/tasks/test/keys.rake +66 -0
- data/tasks/test/menus.rake +74 -0
- metadata +104 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
#-------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2008 Topher Fangio
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#-------------------------------------------------------------------------------
|
25
|
+
|
26
|
+
|
27
|
+
module LCDProc
|
28
|
+
|
29
|
+
module MenuItems
|
30
|
+
|
31
|
+
class Action
|
32
|
+
include LCDProc::MenuItem
|
33
|
+
LCDProc::MenuItem.add_support( :action, self )
|
34
|
+
|
35
|
+
@@action_item_count = 0
|
36
|
+
|
37
|
+
|
38
|
+
# Creates a new Action MenuItem object.
|
39
|
+
#
|
40
|
+
# The <tt>user_options</tt> will accept a hash of the following MenuItem options.
|
41
|
+
#
|
42
|
+
# * <tt>:id</tt> - The unique string that identifies this action. Defaults to "ActionMenuItem_" + a sequence number.
|
43
|
+
#
|
44
|
+
# The <tt>lcdproc_options</tt> will accept a hash of the options to be passed to LCDd when creating or updating the action.
|
45
|
+
#
|
46
|
+
# * <tt>:text</tt> - The text to be displayed on the LCD for this action. Defaults to the id.
|
47
|
+
def initialize( user_options = {}, lcdproc_options = {} )
|
48
|
+
@lcdproc_options = {}
|
49
|
+
|
50
|
+
if user_options[:id].nil?
|
51
|
+
@id = "ActionMenuItem_#{@@action_item_count}"
|
52
|
+
else
|
53
|
+
@id = user_options[:id]
|
54
|
+
end
|
55
|
+
|
56
|
+
@lcdproc_type = "action"
|
57
|
+
@lcdproc_event_type = "select"
|
58
|
+
|
59
|
+
@lcdproc_options[:menu_result] = :none
|
60
|
+
@lcdproc_options[:text] = "#{@id}"
|
61
|
+
|
62
|
+
@lcdproc_options.update( lcdproc_options )
|
63
|
+
|
64
|
+
@lcdproc_options[:text] = "\"#{@lcdproc_options[:text]}\""
|
65
|
+
|
66
|
+
@@action_item_count += 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#-------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2008 Topher Fangio
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#-------------------------------------------------------------------------------
|
25
|
+
|
26
|
+
|
27
|
+
module LCDProc
|
28
|
+
|
29
|
+
module MenuItems
|
30
|
+
|
31
|
+
class Alpha
|
32
|
+
include LCDProc::MenuItem
|
33
|
+
LCDProc::MenuItem.add_support( :alpha, self )
|
34
|
+
|
35
|
+
@@alpha_item_count = 0
|
36
|
+
|
37
|
+
# Creates a new Alpha MenuItem object.
|
38
|
+
#
|
39
|
+
# The <tt>user_options</tt> will accept a hash of the following MenuItem options.
|
40
|
+
#
|
41
|
+
# * <tt>:id</tt> - The unique string that identifies this alpha. Defaults to "AlphaMenuItem_" + a sequence number.
|
42
|
+
#
|
43
|
+
# The <tt>lcdproc_options</tt> will accept a hash of the options to be passed to LCDd when creating or updating the alpha.
|
44
|
+
#
|
45
|
+
# * <tt>:text</tt> - The text to be displayed on the LCD for this alpha. Defaults to the id.
|
46
|
+
# * <tt>:value</tt> - The string that you wish to be able to modify. Defaults to "AString".
|
47
|
+
# * <tt>:password_char</tt> - If you wish that the text entered be a password, you may set this char to appear instead of the actual letters. Defaults to "" (off).
|
48
|
+
# * <tt>:minlength</tt> - The minimum allowed length of the string. Defaults to 0.
|
49
|
+
# * <tt>:maxlength</tt> - The maximum allowed length of the string. Defaults to 10.
|
50
|
+
# * <tt>:allow_caps</tt> - Whether or not the string is allowed to have capital letters. Defaults to true.
|
51
|
+
# * <tt>:allow_noncaps</tt> - ??? Not quite sure about this one, I believe it is whether or not you may have lower case letters. Defaults to false (this is the puzzling part).
|
52
|
+
# * <tt>:allow_numbers</tt> - Whether or not the string is allowed to have numbers. Defaults to false.
|
53
|
+
# * <tt>:allow_extras</tt> - A string containing any other characters that you wish to be allowed. Defaults to "".
|
54
|
+
def initialize( user_options = {}, lcdproc_options = {} )
|
55
|
+
@lcdproc_options = {}
|
56
|
+
|
57
|
+
if user_options[:id].nil?
|
58
|
+
@id = "AlphaMenuItem_#{@@alpha_item_count}"
|
59
|
+
else
|
60
|
+
@id = user_options[:id]
|
61
|
+
end
|
62
|
+
|
63
|
+
@lcdproc_type = "alpha"
|
64
|
+
@lcdproc_event_type = "update"
|
65
|
+
|
66
|
+
@lcdproc_options[:text] = "#{@id}"
|
67
|
+
@lcdproc_options[:value] = "AString"
|
68
|
+
@lcdproc_options[:password_char] = ""
|
69
|
+
@lcdproc_options[:minlength] = 0
|
70
|
+
@lcdproc_options[:maxlength] = 10
|
71
|
+
@lcdproc_options[:allow_caps] = true
|
72
|
+
@lcdproc_options[:allow_noncaps] = false
|
73
|
+
@lcdproc_options[:allow_numbers] = false
|
74
|
+
|
75
|
+
@lcdproc_options.update( lcdproc_options )
|
76
|
+
|
77
|
+
[ :text, :value, :password_char ].each { |s| @lcdproc_options[s].quotify! }
|
78
|
+
|
79
|
+
@@alpha_item_count += 1
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#-------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2008 Topher Fangio
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#-------------------------------------------------------------------------------
|
25
|
+
|
26
|
+
|
27
|
+
module LCDProc
|
28
|
+
|
29
|
+
module MenuItems
|
30
|
+
|
31
|
+
class Checkbox
|
32
|
+
include LCDProc::MenuItem
|
33
|
+
LCDProc::MenuItem.add_support( :checkbox, self )
|
34
|
+
|
35
|
+
@@checkbox_item_count = 0
|
36
|
+
|
37
|
+
|
38
|
+
# Creates a new Checkbox MenuItem object.
|
39
|
+
#
|
40
|
+
# The <tt>user_options</tt> will accept a hash of the following MenuItem options.
|
41
|
+
#
|
42
|
+
# * <tt>:id</tt> - The unique string that identifies this checkbox. Defaults to "CheckboxMenuItem_" + a sequence number.
|
43
|
+
#
|
44
|
+
# The <tt>lcdproc_options</tt> will accept a hash of the options to be passed to LCDd when creating or updating the checkbox.
|
45
|
+
#
|
46
|
+
# * <tt>:text</tt> - The text to be displayed on the LCD for this checkbox. Defaults to the id.
|
47
|
+
# * <tt>:value</tt> - The starting value. Valid options are :off, :on, and :gray (if :allow_grey is true). Defaults to :off.
|
48
|
+
# * <tt>:allow_grey</tt> - If true, the value may be set to :grey.
|
49
|
+
def initialize( user_options = {}, lcdproc_options = {} )
|
50
|
+
@lcdproc_options = {}
|
51
|
+
|
52
|
+
if user_options[:id].nil?
|
53
|
+
@id = "CheckboxMenuItem_#{@@checkbox_item_count}"
|
54
|
+
else
|
55
|
+
@id = user_options[:id]
|
56
|
+
end
|
57
|
+
|
58
|
+
@lcdproc_type = "checkbox"
|
59
|
+
@lcdproc_event_type = "update"
|
60
|
+
|
61
|
+
@lcdproc_options[:text] = "#{@id}"
|
62
|
+
|
63
|
+
@lcdproc_options[:value] = :off
|
64
|
+
@lcdproc_options[:allow_gray] = false
|
65
|
+
|
66
|
+
@lcdproc_options.update( lcdproc_options )
|
67
|
+
|
68
|
+
@lcdproc_options[:text] = "\"#{@lcdproc_options[:text]}\""
|
69
|
+
|
70
|
+
@@checkbox_item_count += 1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#-------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2008 Topher Fangio
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#-------------------------------------------------------------------------------
|
25
|
+
|
26
|
+
|
27
|
+
module LCDProc
|
28
|
+
|
29
|
+
module MenuItems
|
30
|
+
|
31
|
+
class IP
|
32
|
+
include LCDProc::MenuItem
|
33
|
+
LCDProc::MenuItem.add_support( :ip, self )
|
34
|
+
|
35
|
+
@@ip_item_count = 0
|
36
|
+
|
37
|
+
# Creates a new IP MenuItem object.
|
38
|
+
#
|
39
|
+
# The <tt>user_options</tt> will accept a hash of the following MenuItem options.
|
40
|
+
#
|
41
|
+
# * <tt>:id</tt> - The unique string that identifies this ip menu item. Defaults to "IPMenuItem_" + a sequence number.
|
42
|
+
#
|
43
|
+
# The <tt>lcdproc_options</tt> will accept a hash of the options to be passed to LCDd when creating or updating the ip.
|
44
|
+
#
|
45
|
+
# * <tt>:text</tt> - The text to be displayed on the LCD for this ip. Defaults to the id.
|
46
|
+
# * <tt>:value</tt> - The value of the IP address. Defaults to "0.0.0.0".
|
47
|
+
# * <tt>:v6</tt> - Whether or not the IP address should be in IPv6 format or not. Defaults to false.
|
48
|
+
def initialize( user_options = {}, lcdproc_options = {} )
|
49
|
+
@lcdproc_options = {}
|
50
|
+
|
51
|
+
if user_options[:id].nil?
|
52
|
+
@id = "IPMenuItem_#{@@ip_item_count}"
|
53
|
+
else
|
54
|
+
@id = user_options[:id]
|
55
|
+
end
|
56
|
+
|
57
|
+
@lcdproc_type = "ip"
|
58
|
+
@lcdproc_event_type = "update"
|
59
|
+
|
60
|
+
@lcdproc_options[:text] = "#{@id}"
|
61
|
+
|
62
|
+
@lcdproc_options[:value] = "0.0.0.0"
|
63
|
+
@lcdproc_options[:v6] = false
|
64
|
+
|
65
|
+
@lcdproc_options.update( lcdproc_options )
|
66
|
+
|
67
|
+
[ :text, :value ].each { |s| @lcdproc_options[s].quotify! }
|
68
|
+
|
69
|
+
@@ip_item_count += 1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#-------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2008 Topher Fangio
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#-------------------------------------------------------------------------------
|
25
|
+
|
26
|
+
|
27
|
+
module LCDProc
|
28
|
+
|
29
|
+
module MenuItems
|
30
|
+
|
31
|
+
class Numeric
|
32
|
+
include LCDProc::MenuItem
|
33
|
+
LCDProc::MenuItem.add_support( :numeric, self )
|
34
|
+
|
35
|
+
@@numeric_item_count = 0
|
36
|
+
|
37
|
+
# Creates a new Numeric MenuItem object.
|
38
|
+
#
|
39
|
+
# The <tt>user_options</tt> will accept a hash of the following MenuItem options.
|
40
|
+
#
|
41
|
+
# * <tt>:id</tt> - The unique string that identifies this numeric. Defaults to "NumericMenuItem_" + a sequence number.
|
42
|
+
#
|
43
|
+
# The <tt>lcdproc_options</tt> will accept a hash of the options to be passed to LCDd when creating or updating the numeric.
|
44
|
+
#
|
45
|
+
# * <tt>:text</tt> - The text to be displayed on the LCD for this numeric. Defaults to the id.
|
46
|
+
# * <tt>:minvalue</tt> - The minimum value that the numeric should allow. Defaults to 0 but can be negative.
|
47
|
+
# * <tt>:maxvalue</tt> - The maximum value that the numeric should allow. Defaults to 100.
|
48
|
+
def initialize( user_options = {}, lcdproc_options = {} )
|
49
|
+
@lcdproc_options = {}
|
50
|
+
|
51
|
+
if user_options[:id].nil?
|
52
|
+
@id = "NumericMenuItem_#{@@numeric_item_count}"
|
53
|
+
else
|
54
|
+
@id = user_options[:id]
|
55
|
+
end
|
56
|
+
|
57
|
+
@lcdproc_type = "numeric"
|
58
|
+
@lcdproc_event_type = "update"
|
59
|
+
|
60
|
+
@lcdproc_options[:text] = @id
|
61
|
+
|
62
|
+
@lcdproc_options[:minvalue] = 0
|
63
|
+
@lcdproc_options[:maxvalue] = 100
|
64
|
+
|
65
|
+
@lcdproc_options.update( lcdproc_options )
|
66
|
+
|
67
|
+
@lcdproc_options[:text] = "\"#{@lcdproc_options[:text]}\""
|
68
|
+
|
69
|
+
@@numeric_item_count += 1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#-------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2008 Topher Fangio
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#-------------------------------------------------------------------------------
|
25
|
+
|
26
|
+
|
27
|
+
module LCDProc
|
28
|
+
|
29
|
+
module MenuItems
|
30
|
+
|
31
|
+
class Ring
|
32
|
+
include LCDProc::MenuItem
|
33
|
+
LCDProc::MenuItem.add_support( :ring, self )
|
34
|
+
|
35
|
+
@@ring_item_count = 0
|
36
|
+
|
37
|
+
# Creates a new Ring MenuItem object.
|
38
|
+
#
|
39
|
+
# The <tt>user_options</tt> will accept a hash of the following MenuItem options.
|
40
|
+
#
|
41
|
+
# * <tt>:id</tt> - The unique string that identifies this ring. Defaults to "RingMenuMenuItem_" + a sequence number.
|
42
|
+
#
|
43
|
+
# The <tt>lcdproc_options</tt> will accept a hash of the options to be passed to LCDd when creating or updating the ring.
|
44
|
+
#
|
45
|
+
# * <tt>:text</tt> - The text to be displayed on the LCD for this ring. Defaults to the id.
|
46
|
+
# * <tt>:strings</tt> - A tab separated list of the strings to be displayed as options. Defaults to "Yes\tNo\tMaybe".
|
47
|
+
# * <tt>:value</tt> - The index of the string to be displayed initially. Defaults to 0.
|
48
|
+
def initialize( user_options = {}, lcdproc_options = {} )
|
49
|
+
@lcdproc_options = {}
|
50
|
+
|
51
|
+
if user_options[:id].nil?
|
52
|
+
@id = "RingMenuItem_#{@@ring_item_count}"
|
53
|
+
else
|
54
|
+
@id = user_options[:id]
|
55
|
+
end
|
56
|
+
|
57
|
+
@lcdproc_type = "ring"
|
58
|
+
@lcdproc_event_type = "update"
|
59
|
+
|
60
|
+
@lcdproc_options[:text] = @id
|
61
|
+
|
62
|
+
@lcdproc_options[:strings] = "Yes\tNo\tMaybe"
|
63
|
+
@lcdproc_options[:value] = 0
|
64
|
+
|
65
|
+
@lcdproc_options.update( lcdproc_options )
|
66
|
+
|
67
|
+
[ :text, :strings ].each { |s| @lcdproc_options[s].quotify! }
|
68
|
+
|
69
|
+
@@ring_item_count += 1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|