serdisplib-ruby 0.5.1-x86-linux → 0.5.2-x86-linux
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/build.sh +4 -2
- data/examples/imlib2_util.rb +26 -17
- data/examples/uptime.rb +31 -15
- data/ext/serdisplib/serdisplib.so +0 -0
- data/ext/serdisplib/serdisplib_wrap.o +0 -0
- data/serdisplib-ruby-0.5.2-x86-linux.gem +0 -0
- data/serdisplib-ruby.gemspec +1 -1
- metadata +3 -2
data/build.sh
CHANGED
@@ -21,8 +21,10 @@ gem build serdisplib-ruby.gemspec
|
|
21
21
|
# Build make source archive
|
22
22
|
pushd ..
|
23
23
|
find | grep \.svn$ | cut -c3- > exclude.txt
|
24
|
-
tar cvfX serdisplib-ruby.tar
|
25
|
-
rm exclude.txt
|
24
|
+
tar cvfX serdisplib-ruby.tar exclude.txt serdisplib-ruby/
|
25
|
+
#rm exclude.txt
|
26
|
+
gzip serdisplib-ruby.tar
|
27
|
+
file serdisplib-ruby.tar.gz
|
26
28
|
popd
|
27
29
|
|
28
30
|
echo "Done."
|
data/examples/imlib2_util.rb
CHANGED
@@ -14,40 +14,49 @@ require 'imlib2'
|
|
14
14
|
module Imlib2Util
|
15
15
|
|
16
16
|
#
|
17
|
+
# Convert Imlib2 image ARGB 8-bit per channel data into a Ruby array.
|
17
18
|
#
|
19
|
+
# Note: Imlib2-Ruby returns the data as each array element being a pixel
|
20
|
+
# component (i.e. Alpha or Red or Blue or Green), this function combines
|
21
|
+
# them back to ARGB data.
|
18
22
|
#
|
19
|
-
def Imlib2Util.
|
23
|
+
def Imlib2Util.imlib_image_to_argb_serdisp_data( im )
|
20
24
|
|
21
25
|
im_width = im.width
|
22
26
|
im_height = im.height
|
23
27
|
im_rgba_data = im.data_for_reading_only( )
|
24
28
|
im_lcd_data = []
|
25
|
-
im_height.times do
|
26
|
-
|
27
|
-
im_width.times do hoz_line << 0; end
|
28
|
-
im_lcd_data << hoz_line
|
29
|
+
im_height.times do
|
30
|
+
im_lcd_data << Array.new( im_width )
|
29
31
|
end
|
30
|
-
|
32
|
+
|
31
33
|
im_width.times do |x|
|
32
34
|
im_height.times do |y|
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
#im_lcd_data[y][x] |= ( im_rgba_data[4 + x + (y*im_width)] & 0x00FFFFFF ) > 0 ? 0x01 << 3 : 0x00 << 3;
|
42
|
-
#im_lcd_data[y][x] |= ( im_rgba_data[5 + x + (y*im_width)] & 0x00FFFFFF ) > 0 ? 0x01 << 2 : 0x00 << 2;
|
43
|
-
#im_lcd_data[y][x] |= ( im_rgba_data[6 + x + (y*im_width)] & 0x00FFFFFF ) > 0 ? 0x01 << 1 : 0x00 << 1;
|
44
|
-
#im_lcd_data[y][x] |= ( im_rgba_data[7 + x + (y*im_width)] & 0x00FFFFFF ) > 0 ? 0x01 << 0 : 0x00 << 0;
|
36
|
+
pixel_ind = 4 * ( x + ( y * im_width ) )
|
37
|
+
a = im_rgba_data[pixel_ind + 0]
|
38
|
+
r = im_rgba_data[pixel_ind + 1]
|
39
|
+
g = im_rgba_data[pixel_ind + 2]
|
40
|
+
b = im_rgba_data[pixel_ind + 3]
|
41
|
+
|
42
|
+
im_lcd_data[y][x] = ( a << 24 ) | ( r << 16 ) | ( g << 8 ) | b
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
46
|
im_lcd_data
|
49
47
|
end
|
50
48
|
|
49
|
+
#
|
50
|
+
# Render's centered text on the Imlib2 image buffer given a vertical
|
51
|
+
# position.
|
52
|
+
#
|
53
|
+
def Imlib2Util.imlib_draw_centered_text( dd, ypos, im, font, text )
|
54
|
+
|
55
|
+
fw, fh = font.size text
|
56
|
+
fx, fy = (im.width - fw) / 2, ypos
|
57
|
+
im.draw_text( font, text, fx, fy, Imlib2::Color::WHITE )
|
58
|
+
end
|
59
|
+
|
51
60
|
end
|
52
61
|
|
53
62
|
# End of imlib2_util.rb
|
data/examples/uptime.rb
CHANGED
@@ -79,9 +79,21 @@ def print_interpreter_usage( )
|
|
79
79
|
puts "\n\n"
|
80
80
|
puts "exit | quit | q exit this program"
|
81
81
|
puts "help | h display this usage information"
|
82
|
+
puts "invert | inv toggle display inversion"
|
83
|
+
puts "rotate | rot rotate display 180 degrees"
|
82
84
|
puts "delay | d <[0-9]+> update refresh delay in seconds (default: 2)\n\n"
|
83
85
|
end
|
84
86
|
|
87
|
+
#
|
88
|
+
# Call `uptime` and parse uptime output, returning separate pieces as set.
|
89
|
+
#
|
90
|
+
def get_uptime_info( )
|
91
|
+
|
92
|
+
uptime_output = `uptime`
|
93
|
+
uptime_output =~ /([A-Za-z0-9: ]+),[ \t]+([0-9]+)[ \t]+users,[ \t]+load average: ([0-9.]+), ([0-9.]+), ([0-9.]+)/
|
94
|
+
return $1.strip, $2.strip, $3.strip, $4.strip, $5.strip
|
95
|
+
end
|
96
|
+
|
85
97
|
#-----------------------------------------------------------------------------
|
86
98
|
# Entry-Point
|
87
99
|
#-----------------------------------------------------------------------------
|
@@ -142,28 +154,25 @@ if ( __FILE__ == $0 ) then
|
|
142
154
|
h = serdisp_getheight( dd )
|
143
155
|
w = serdisp_getwidth( dd )
|
144
156
|
im = Imlib2::Image.new( w, h )
|
145
|
-
Imlib2::Font.add_path '
|
146
|
-
font = Imlib2::Font.new( 'yudit/
|
147
|
-
|
148
|
-
fw, fh = font.size text
|
149
|
-
fx, fy = (im.width - fw) / 2, (im.height / 2 - fh ) / 2
|
150
|
-
im.draw_text font, text, fx, fy, Imlib2::Color::RED
|
151
|
-
im.save( 'test.png' )
|
152
|
-
|
157
|
+
Imlib2::Font.add_path( 'fonts' )
|
158
|
+
font = Imlib2::Font.new( 'yudit/14' )
|
159
|
+
|
153
160
|
while ( g_loop )
|
154
|
-
|
155
|
-
|
156
|
-
|
161
|
+
im.clear( )
|
162
|
+
time, users, load1, load5, load15 = get_uptime_info( )
|
163
|
+
Imlib2Util.imlib_draw_centered_text( dd, 5, im, font, time )
|
164
|
+
Imlib2Util.imlib_draw_centered_text( dd, 25, im, font, "#{users} users" )
|
165
|
+
Imlib2Util.imlib_draw_centered_text( dd, 45, im, font, "#{load1}, #{load5}, #{load15}" )
|
157
166
|
|
158
|
-
lcd_data = Imlib2Util.
|
167
|
+
lcd_data = Imlib2Util.imlib_image_to_argb_serdisp_data( im )
|
159
168
|
im.width.times do |x|
|
160
169
|
im.height.times do |y|
|
161
170
|
|
162
|
-
|
163
|
-
|
171
|
+
pixel = ( lcd_data[y][x] & 0x00FFFFFF ) > 0 ? g_fgcolour : g_bgcolour
|
172
|
+
serdisp_setcolour( dd, x, y, pixel )
|
173
|
+
|
164
174
|
end
|
165
175
|
end
|
166
|
-
puts "Done setting LCD."
|
167
176
|
|
168
177
|
serdisp_update( dd )
|
169
178
|
sleep( g_delay )
|
@@ -183,6 +192,13 @@ if ( __FILE__ == $0 ) then
|
|
183
192
|
|
184
193
|
when 'q', 'quit', 'exit'
|
185
194
|
g_loop = false
|
195
|
+
|
196
|
+
when 'invert', 'inv'
|
197
|
+
serdisp_setoption( dd, 'INVERT', SD_OPTION_TOGGLE )
|
198
|
+
|
199
|
+
when /rotate( [0-9]+)?/, /rot( [0-9]+)?/
|
200
|
+
rc = ( nil == $1 ) ? SD_OPTION_TOGGLE : $1.to_i
|
201
|
+
serdisp_setoption( dd, 'ROTATE', rc )
|
186
202
|
|
187
203
|
when /delay ([0-9]+)?/, /d ([0-9]+)?/
|
188
204
|
puts "Setting delay time to #{$1.to_i} seconds"
|
Binary file
|
Binary file
|
Binary file
|
data/serdisplib-ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serdisplib-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: x86-linux
|
6
6
|
authors:
|
7
7
|
- David Muir
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-06-
|
12
|
+
date: 2008-06-24 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -32,6 +32,7 @@ files:
|
|
32
32
|
- ext/serdisplib/serdisplib_wrap.o
|
33
33
|
- ext/serdisplib/serdisplib.i
|
34
34
|
- ext/serdisplib/Makefile
|
35
|
+
- serdisplib-ruby-0.5.2-x86-linux.gem
|
35
36
|
- ChangeLog
|
36
37
|
- setup.rb
|
37
38
|
- README
|