Class: Tinkerforge::BrickletLCD128x64
- Inherits:
-
Object
- Object
- Tinkerforge::BrickletLCD128x64
- Includes:
- Shared::IBM437_encoding
- Defined in:
- lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb
Instance Method Summary collapse
-
#backlight ⇒ Object
Returns the current setting for the backlight (0..100).
-
#backlight=(brightness) ⇒ Object
Sets the brightness of the backlight (0..100).
-
#blackout ⇒ Object
Switches off the backlight.
-
#buffered? ⇒ Boolean
Returns true if automatic draw is set to false.
-
#clear ⇒ Object
Clears the display, including the GUI.
-
#contrast ⇒ Object
Returns the current contrast setting (0..63).
-
#contrast=(value) ⇒ Object
Sets the contrast (0..63).
-
#encode(string) ⇒ Object
Encodes a string in the IBM437 character set used by some displays.
-
#put_screen(text = '', test: false) ⇒ Object
Clears the display and prints upto 8 lines of text.
-
#redraw(force_complete_redraw = false) ⇒ Object
(also: #flush)
Draws the currently buffered frame.
-
#show(object) ⇒ Object
Shows an object.
-
#state ⇒ Object
Returns the device's state.
Instance Method Details
#backlight ⇒ Object
Returns the current setting for the backlight (0..100).
20 21 22 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 20 def backlight get_display_configuration[1] end |
#backlight=(brightness) ⇒ Object
Sets the brightness of the backlight (0..100).
25 26 27 28 29 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 25 def backlight=(brightness) state = get_display_configuration state[1] = brightness.to_i set_display_configuration *state end |
#blackout ⇒ Object
Switches off the backlight.
32 33 34 35 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 32 def blackout self.backlight = 0 true end |
#buffered? ⇒ Boolean
Returns true if automatic draw is set to false.
56 57 58 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 56 def buffered? ! get_display_configuration[3] end |
#clear ⇒ Object
Clears the display, including the GUI.
50 51 52 53 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 50 def clear clear_display remove_all_gui end |
#contrast ⇒ Object
Returns the current contrast setting (0..63).
38 39 40 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 38 def contrast get_display_configuration[0] end |
#contrast=(value) ⇒ Object
Sets the contrast (0..63).
43 44 45 46 47 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 43 def contrast=(value) state = get_display_configuration state[0] = value.to_i set_display_configuration *state end |
#encode(string) ⇒ Object
Encodes a string in the IBM437 character set used by some displays.
Characters that can not be encoded are replaced with '?'.
See:
15 16 17 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 15 def encode(string) ibm437_encode(string) end |
#put_screen(text = '', test: false) ⇒ Object
Clears the display and prints upto 8 lines of text.
Text may contain newline characters to separate lines. Lines longer than 21 characters will be wrapped.
Text is automatically encoded in the IBM437 character set.
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 83 def put_screen(text='', test: false) lines = text.split("\n") lines = lines.map { |s| s.empty? ? '' : s.scan(/.{1,21}/) }.flatten lines = lines[0,8].map { |l| encode l } return lines if test clear lines.each_with_index do |s,l| write_line l, 0, s end nil end |
#redraw(force_complete_redraw = false) ⇒ Object Also known as: flush
Draws the currently buffered frame.
61 62 63 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 61 def redraw(force_complete_redraw=false) draw_buffered_frame force_complete_redraw end |
#show(object) ⇒ Object
Shows an object.
98 99 100 101 102 103 104 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 98 def show(object) if object.respond_to?( :_view_21x8, true) put_screen ( object.send(:_view_21x8) rescue "21x8 view error\n\n#{object.class.to_s}" ) elsif put_screen object.inspect[0,168] end end |
#state ⇒ Object
Returns the device's state.
68 69 70 71 72 73 |
# File 'lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb', line 68 def state super.merge( 'touch_led_config' => get_touch_led_config, 'display_configuration' => get_display_configuration, ) end |