class Tinkerforge::BrickletLCD128x64
7.1cm (2.8“) display with 128x64 pixel and touch screen
Constants
- CALLBACK_GUI_BUTTON_PRESSED
This callback is triggered periodically with the period that is set by
BrickletLCD128x64#set_gui_button_pressed_callback_configuration
. The parameters are the same as forBrickletLCD128x64#get_gui_button_pressed
.- .. versionadded
-
2.0.2$nbsp;(Plugin)
- CALLBACK_GUI_SLIDER_VALUE
This callback is triggered periodically with the period that is set by
BrickletLCD128x64#set_gui_slider_value_callback_configuration
. The parameters are the same as forBrickletLCD128x64#get_gui_slider_value
.- .. versionadded
-
2.0.2$nbsp;(Plugin)
- CALLBACK_GUI_TAB_SELECTED
This callback is triggered periodically with the period that is set by
BrickletLCD128x64#set_gui_tab_selected_callback_configuration
. The parameters are the same as forBrickletLCD128x64#get_gui_tab_selected
.- .. versionadded
-
2.0.2$nbsp;(Plugin)
- CALLBACK_TOUCH_GESTURE
This callback is triggered periodically with the period that is set by
BrickletLCD128x64#set_touch_gesture_callback_configuration
. The parameters are the same as forBrickletLCD128x64#get_touch_gesture
.- CALLBACK_TOUCH_POSITION
This callback is triggered periodically with the period that is set by
BrickletLCD128x64#set_touch_position_callback_configuration
. The parameters are the same as forBrickletLCD128x64#get_touch_position
.
Public Class Methods
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 156 def initialize(uid, ipcon) super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME @api_version = [2, 0, 1] @response_expected[FUNCTION_WRITE_PIXELS_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_READ_PIXELS_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_CLEAR_DISPLAY] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_SET_DISPLAY_CONFIGURATION] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_DISPLAY_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_WRITE_LINE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DRAW_BUFFERED_FRAME] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_TOUCH_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_TOUCH_POSITION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_TOUCH_POSITION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_TOUCH_GESTURE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_TOUCH_GESTURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_TOUCH_GESTURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_DRAW_LINE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DRAW_BOX] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DRAW_TEXT] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_SET_GUI_BUTTON] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_GUI_BUTTON] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_REMOVE_GUI_BUTTON] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_SET_GUI_BUTTON_PRESSED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_GUI_BUTTON_PRESSED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_GUI_BUTTON_PRESSED] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_GUI_SLIDER] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_GUI_SLIDER] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_REMOVE_GUI_SLIDER] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_SET_GUI_SLIDER_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_GUI_SLIDER_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_GUI_SLIDER_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_GUI_TAB_CONFIGURATION] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_GUI_TAB_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_GUI_TAB_TEXT] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_GUI_TAB_TEXT] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_GUI_TAB_ICON] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_GUI_TAB_ICON] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_REMOVE_GUI_TAB] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_SET_GUI_TAB_SELECTED] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_SET_GUI_TAB_SELECTED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_GUI_TAB_SELECTED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_GUI_TAB_SELECTED] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_GUI_GRAPH_CONFIGURATION] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_GUI_GRAPH_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_GUI_GRAPH_DATA_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_GUI_GRAPH_DATA_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_REMOVE_GUI_GRAPH] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_REMOVE_ALL_GUI] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_SET_TOUCH_LED_CONFIG] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_TOUCH_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @callback_formats[CALLBACK_TOUCH_POSITION] = [18, 'S S S L'] @callback_formats[CALLBACK_TOUCH_GESTURE] = [27, 'C L S S S S S L'] @callback_formats[CALLBACK_GUI_BUTTON_PRESSED] = [10, 'C ?'] @callback_formats[CALLBACK_GUI_SLIDER_VALUE] = [10, 'C C'] @callback_formats[CALLBACK_GUI_TAB_SELECTED] = [9, 'c'] @ipcon.add_device self end
Public Instance Methods
Clears the complete content of the display.
If automatic draw is enabled (default) the pixels are directly cleared.
If automatic draw is disabled the the internal buffer is cleared and the buffer is transferred to the display only after BrickletLCD128x64#draw_buffered_frame
is called. This can be used to avoid flicker when drawing a complex frame in multiple steps.
Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
function.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 282 def clear_display check_validity send_request FUNCTION_CLEAR_DISPLAY, [], '', 8, '' end
Draws a white or black box from (x, y)-start to (x, y)-end.
If you set fill to true, the box will be filled with the color. Otherwise only the outline will be drawn.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 439 def draw_box(position_x_start, position_y_start, position_x_end, position_y_end, fill, color) check_validity send_request FUNCTION_DRAW_BOX, [position_x_start, position_y_start, position_x_end, position_y_end, fill, color], 'C C C C ? ?', 8, '' end
Draws the currently buffered frame. Normally each call of BrickletLCD128x64#write_pixels
and BrickletLCD128x64#write_line
draws directly onto the display. If you turn automatic draw off (BrickletLCD128x64#set_display_configuration
), the data is written in an internal buffer and only transferred to the display by calling this function. This can be used to avoid flicker when drawing a complex frame in multiple steps.
Set the `force complete redraw` to true to redraw the whole display instead of only the changed parts. Normally it should not be necessary to set this to true. It may only become necessary in case of stuck pixels because of errors.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 345 def draw_buffered_frame(force_complete_redraw) check_validity send_request FUNCTION_DRAW_BUFFERED_FRAME, [force_complete_redraw], '?', 8, '' end
Draws a white or black line from (x, y)-start to (x, y)-end.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 427 def draw_line(position_x_start, position_y_start, position_x_end, position_y_end, color) check_validity send_request FUNCTION_DRAW_LINE, [position_x_start, position_y_start, position_x_end, position_y_end, color], 'C C C C ?', 8, '' end
Draws a text at the pixel position (x, y).
You can use one of 9 different font sizes and draw the text in white or black.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 450 def draw_text(position_x, position_y, font, color, text) check_validity send_request FUNCTION_DRAW_TEXT, [position_x, position_y, font, color, text], 'C C C ? Z22', 8, '' end
Returns the current bootloader mode, see BrickletLCD128x64#set_bootloader_mode
.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 906 def get_bootloader_mode check_validity send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C' end
Returns the temperature as measured inside the microcontroller. The value returned is not the ambient temperature!
The temperature is only proportional to the real temperature and it has bad accuracy. Practically it is only useful as an indicator for temperature changes.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 964 def get_chip_temperature check_validity send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's' end
Returns the configuration as set by BrickletLCD128x64#set_display_configuration
.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 301 def get_display_configuration check_validity send_request FUNCTION_GET_DISPLAY_CONFIGURATION, [], '', 12, 'C C ? ?' end
Returns the graph properties for a given `Index` as set by BrickletLCD128x64#set_gui_graph_configuration
.
Additionally the `Active` parameter shows if a graph is currently active/visible or not.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 795 def get_gui_graph_configuration(index) check_validity send_request FUNCTION_GET_GUI_GRAPH_CONFIGURATION, [index], 'C', 22, '? C C C C C Z4 Z4' end
Returns the graph data for a given index as set by BrickletLCD128x64#set_gui_graph_data
.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 1156 def get_gui_graph_data(index) data_length = nil # assigned in block data_data = nil # assigned in block @stream_mutex.synchronize { ret = get_gui_graph_data_low_level index data_length = ret[0] data_chunk_offset = ret[1] data_out_of_sync = data_chunk_offset != 0 data_data = ret[2] while not data_out_of_sync and data_data.length < data_length ret = get_gui_graph_data_low_level index data_length = ret[0] data_chunk_offset = ret[1] data_out_of_sync = data_chunk_offset != data_data.length data_data += ret[2] end if data_out_of_sync # discard remaining stream to bring it back in-sync while data_chunk_offset + 59 < data_length ret = get_gui_graph_data_low_level index data_length = ret[0] data_chunk_offset = ret[1] end raise StreamOutOfSyncException, 'Data stream is out-of-sync' end } data_data[0, data_length] end
Returns the graph data for a given index as set by BrickletLCD128x64#set_gui_graph_data
.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 824 def get_gui_graph_data_low_level(index) check_validity send_request FUNCTION_GET_GUI_GRAPH_DATA_LOW_LEVEL, [index], 'C', 71, 'S S C59' end
Returns the slider properties for a given `Index` as set by BrickletLCD128x64#set_gui_slider
.
Additionally the `Active` parameter shows if a button is currently active/visible or not.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 581 def get_gui_slider(index) check_validity send_request FUNCTION_GET_GUI_SLIDER, [index], 'C', 14, '? C C C C C' end
Returns the current slider value for the given index.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 628 def get_gui_slider_value(index) check_validity send_request FUNCTION_GET_GUI_SLIDER_VALUE, [index], 'C', 9, 'C' end
Returns the callback configuration as set by BrickletLCD128x64#set_gui_slider_value_callback_configuration
.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 619 def get_gui_slider_value_callback_configuration check_validity send_request FUNCTION_GET_GUI_SLIDER_VALUE_CALLBACK_CONFIGURATION, [], '', 13, 'L ?' end
Returns the tab configuration as set by BrickletLCD128x64#set_gui_tab_configuration
.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 650 def get_gui_tab_configuration check_validity send_request FUNCTION_GET_GUI_TAB_CONFIGURATION, [], '', 10, 'C ?' end
Returns the icon for a given index as set by BrickletLCD128x64#set_gui_tab_icon
.
Additionally the `Active` parameter shows if the tab is currently active/visible or not.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 701 def get_gui_tab_icon(index) check_validity send_request FUNCTION_GET_GUI_TAB_ICON, [index], 'C', 30, '? ?168' end
Returns the index of the currently selected tab. If there are not tabs, the returned index is -1.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 758 def get_gui_tab_selected check_validity send_request FUNCTION_GET_GUI_TAB_SELECTED, [], '', 9, 'c' end
Returns the callback configuration as set by BrickletLCD128x64#set_gui_tab_selected_callback_configuration
.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 748 def get_gui_tab_selected_callback_configuration check_validity send_request FUNCTION_GET_GUI_TAB_SELECTED_CALLBACK_CONFIGURATION, [], '', 13, 'L ?' end
Returns the text for a given index as set by BrickletLCD128x64#set_gui_tab_text
.
Additionally the `Active` parameter shows if the tab is currently active/visible or not.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 675 def get_gui_tab_text(index) check_validity send_request FUNCTION_GET_GUI_TAB_TEXT, [index], 'C', 14, '? Z5' end
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'.
The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 1011 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end
Returns the error count for the communication between Brick and Bricklet.
The errors are divided into
-
ACK checksum errors,
-
message checksum errors,
-
framing errors and
-
overflow errors.
The errors counts are for errors that occur on the Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 884 def get_spitfp_error_count check_validity send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L' end
Returns the configuration as set by BrickletLCD128x64#set_status_led_config
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 952 def get_status_led_config check_validity send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C' end
Returns one of four touch gestures that can be automatically detected by the Bricklet.
The gestures are swipes from left to right, right to left, top to bottom and bottom to top.
Additionally to the gestures a vector with a start and end position of the gesture is provided. You can use this vector do determine a more exact location of the gesture (e.g. the swipe from top to bottom was on the left or right part of the screen).
The age parameter corresponds to the age of gesture (how long ago it was).
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 395 def get_touch_gesture check_validity send_request FUNCTION_GET_TOUCH_GESTURE, [], '', 27, 'C L S S S S S L' end
Returns the callback configuration as set by BrickletLCD128x64#set_touch_gesture_callback_configuration
.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 418 def get_touch_gesture_callback_configuration check_validity send_request FUNCTION_GET_TOUCH_GESTURE_CALLBACK_CONFIGURATION, [], '', 13, 'L ?' end
Returns the configuration as set by BrickletLCD128x64#set_touch_led_config
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 867 def get_touch_led_config check_validity send_request FUNCTION_GET_TOUCH_LED_CONFIG, [], '', 9, 'C' end
Returns the last valid touch position:
-
Pressure: Amount of pressure applied by the user
-
X: Touch position on x-axis
-
Y: Touch position on y-axis
-
Age: Age of touch press (how long ago it was)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 357 def get_touch_position check_validity send_request FUNCTION_GET_TOUCH_POSITION, [], '', 18, 'S S S L' end
Returns the callback configuration as set by BrickletLCD128x64#set_touch_position_callback_configuration
.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 380 def get_touch_position_callback_configuration check_validity send_request FUNCTION_GET_TOUCH_POSITION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?' end
Reads pixels from the specified window.
The pixels are read from the window line by line top to bottom and each line is read from left to right.
If automatic draw is enabled (default) the pixels that are read are always the same that are shown on the display.
If automatic draw is disabled the pixels are read from the internal buffer (see BrickletLCD128x64#draw_buffered_frame
).
Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
function.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 1075 def read_pixels(x_start, y_start, x_end, y_end) pixels_length = nil # assigned in block pixels_data = nil # assigned in block @stream_mutex.synchronize { ret = read_pixels_low_level x_start, y_start, x_end, y_end pixels_length = ret[0] pixels_chunk_offset = ret[1] pixels_out_of_sync = pixels_chunk_offset != 0 pixels_data = ret[2] while not pixels_out_of_sync and pixels_data.length < pixels_length ret = read_pixels_low_level x_start, y_start, x_end, y_end pixels_length = ret[0] pixels_chunk_offset = ret[1] pixels_out_of_sync = pixels_chunk_offset != pixels_data.length pixels_data += ret[2] end if pixels_out_of_sync # discard remaining stream to bring it back in-sync while pixels_chunk_offset + 480 < pixels_length ret = read_pixels_low_level x_start, y_start, x_end, y_end pixels_length = ret[0] pixels_chunk_offset = ret[1] end raise StreamOutOfSyncException, 'Pixels stream is out-of-sync' end } pixels_data[0, pixels_length] end
Reads pixels from the specified window.
The pixels are read from the window line by line top to bottom and each line is read from left to right.
If automatic draw is enabled (default) the pixels that are read are always the same that are shown on the display.
If automatic draw is disabled the pixels are read from the internal buffer (see BrickletLCD128x64#draw_buffered_frame
).
Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
function.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 265 def read_pixels_low_level(x_start, y_start, x_end, y_end) check_validity send_request FUNCTION_READ_PIXELS_LOW_LEVEL, [x_start, y_start, x_end, y_end], 'C C C C', 72, 'S S ?480' end
Returns the current UID as an integer. Encode as Base58
to get the usual string version.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 995 def read_uid check_validity send_request FUNCTION_READ_UID, [], '', 12, 'L' end
Registers a callback with ID id
to the block block
.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 1190 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end
Removes all GUI elements (buttons, slider, graphs, tabs).
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 844 def remove_all_gui check_validity send_request FUNCTION_REMOVE_ALL_GUI, [], '', 8, '' end
Removes the graph with the given index.
You can use index 255 to remove all graphs.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 835 def remove_gui_graph(index) check_validity send_request FUNCTION_REMOVE_GUI_GRAPH, [index], 'C', 8, '' end
Removes the slider with the given index.
You can use index 255 to remove all slider.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 592 def remove_gui_slider(index) check_validity send_request FUNCTION_REMOVE_GUI_SLIDER, [index], 'C', 8, '' end
Removes the tab with the given index.
You can use index 255 to remove all tabs.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 712 def remove_gui_tab(index) check_validity send_request FUNCTION_REMOVE_GUI_TAB, [index], 'C', 8, '' end
Calling this function will reset the Bricklet. All configurations will be lost.
After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 976 def reset check_validity send_request FUNCTION_RESET, [], '', 8, '' end
Sets the bootloader mode and returns the status after the requested mode change was instigated.
You can change from bootloader mode to firmware mode and vice versa. A change from bootloader mode to firmware mode will only take place if the entry function, device identifier and CRC are present and correct.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 899 def set_bootloader_mode(mode) check_validity send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C' end
Sets the configuration of the display.
If automatic draw is set to true, the display is automatically updated with every call of BrickletLCD128x64#write_pixels
and BrickletLCD128x64#write_line
. If it is set to false, the changes are written into an internal buffer and only shown on the display after a call of BrickletLCD128x64#draw_buffered_frame
.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 294 def set_display_configuration(contrast, backlight, invert, automatic_draw) check_validity send_request FUNCTION_SET_DISPLAY_CONFIGURATION, [contrast, backlight, invert, automatic_draw], 'C C ? ?', 8, '' end
Sets the configuration for up to four graphs.
The graph type can be dot-, line- or bar-graph.
The x and y position are pixel positions.
You can add a text for the x and y axis. The text is drawn at the inside of the graph and it can overwrite some of the graph data. If you need the text outside of the graph you can leave this text here empty and use BrickletLCD128x64#draw_text
to draw the caption outside of the graph.
The data of the graph can be set and updated with BrickletLCD128x64#set_gui_graph_data
.
The graph is drawn in a separate GUI buffer and the graph-frame and data will always stay on top of the graphics drawn with BrickletLCD128x64#write_pixels
. To remove the graph use BrickletLCD128x64#remove_gui_graph
.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 783 def set_gui_graph_configuration(index, graph_type, position_x, position_y, width, height, text_x, text_y) check_validity send_request FUNCTION_SET_GUI_GRAPH_CONFIGURATION, [index, graph_type, position_x, position_y, width, height, text_x, text_y], 'C C C C C C Z4 Z4', 8, '' end
Sets the data for a graph with the given index. You have to configure the graph with BrickletLCD128x64#set_gui_graph_configuration
before you can set the first data.
The graph will show the first n values of the data that you set, where n is the width set with BrickletLCD128x64#set_gui_graph_configuration
. If you set less then n values it will show the rest of the values as zero.
The maximum number of data-points you can set is 118 (which also corresponds to the maximum width of the graph).
You have to scale your values to be between 0 and 255. 0 will be shown at the bottom of the graph and 255 at the top.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 1122 def set_gui_graph_data(index, data) if data.length > 65535 raise ArgumentError, 'Data can be at most 65535 items long' end data_length = data.length data_chunk_offset = 0 if data_length == 0 data_chunk_data = [0] * 59 ret = set_gui_graph_data_low_level index, data_length, data_chunk_offset, data_chunk_data else ret = nil # assigned in block @stream_mutex.synchronize { while data_chunk_offset < data_length data_chunk_data = data[data_chunk_offset, 59] if data_chunk_data.length < 59 data_chunk_data += [0] * (59 - data_chunk_data.length) end ret = set_gui_graph_data_low_level index, data_length, data_chunk_offset, data_chunk_data data_chunk_offset += 59 end } end ret end
Sets the data for a graph with the given index. You have to configure the graph with BrickletLCD128x64#set_gui_graph_configuration
before you can set the first data.
The graph will show the first n values of the data that you set, where n is the width set with BrickletLCD128x64#set_gui_graph_configuration
. If you set less then n values it will show the rest of the values as zero.
The maximum number of data-points you can set is 118 (which also corresponds to the maximum width of the graph).
You have to scale your values to be between 0 and 255. 0 will be shown at the bottom of the graph and 255 at the top.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 815 def set_gui_graph_data_low_level(index, data_length, data_chunk_offset, data_chunk_data) check_validity send_request FUNCTION_SET_GUI_GRAPH_DATA_LOW_LEVEL, [index, data_length, data_chunk_offset, data_chunk_data], 'C S S C59', 8, '' end
Draws a slider at position (x, y) with the given length.
You can use up to 6 sliders.
If you use the horizontal direction, the x position + length has to be within the range of 1 to 128 and the y position has to be within the range of 0 to 46.
If you use the vertical direction, the y position + length has to be within the range of 1 to 64 and the x position has to be within the range of 0 to 110.
The minimum length of a slider is 8.
The parameter value is the start-position of the slider, it can be between 0 and length-8.
You can enable a callback for the slider value with BrickletLCD128x64#set_gui_slider_value_callback_configuration
.
The slider is drawn in a separate GUI buffer and it will always stay on top of the graphics drawn with BrickletLCD128x64#write_pixels
. To remove the button use BrickletLCD128x64#remove_gui_slider
.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 569 def set_gui_slider(index, position_x, position_y, length, direction, value) check_validity send_request FUNCTION_SET_GUI_SLIDER, [index, position_x, position_y, length, direction, value], 'C C C C C C', 8, '' end
The period is the period with which the CALLBACK_GUI_SLIDER_VALUE
callback is triggered periodically. A value of 0 turns the callback off.
If the `value has to change`-parameter is set to true, the callback is only triggered after the value has changed. If the value didn't change within the period, the callback is triggered immediately on change.
If it is set to false, the callback is continuously triggered with the period, independent of the value.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 609 def set_gui_slider_value_callback_configuration(period, value_has_to_change) check_validity send_request FUNCTION_SET_GUI_SLIDER_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, '' end
Sets the general configuration for tabs. You can configure the tabs to only accept clicks or only swipes (gesture left/right and right/left) or both.
Additionally, if you set `Clear GUI` to true, all of the GUI elements (buttons, slider, graphs) will automatically be removed on every tab change.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 641 def set_gui_tab_configuration(change_tab_config, clear_gui) check_validity send_request FUNCTION_SET_GUI_TAB_CONFIGURATION, [change_tab_config, clear_gui], 'C ?', 8, '' end
Adds a icon-tab with the given index. The icon can have a width of 28 pixels with a height of 6 pixels. It is drawn line-by-line from left to right.
You can use up to 10 tabs.
A icon-tab with the same index as a text-tab will overwrite the text-tab.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 689 def set_gui_tab_icon(index, icon) check_validity send_request FUNCTION_SET_GUI_TAB_ICON, [index, icon], 'C ?168', 8, '' end
Sets the tab with the given index as selected (drawn as selected on the display).
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 721 def set_gui_tab_selected(index) check_validity send_request FUNCTION_SET_GUI_TAB_SELECTED, [index], 'C', 8, '' end
The period is the period with which the CALLBACK_GUI_TAB_SELECTED
callback is triggered periodically. A value of 0 turns the callback off.
If the `value has to change`-parameter is set to true, the callback is only triggered after the value has changed. If the value didn't change within the period, the callback is triggered immediately on change.
If it is set to false, the callback is continuously triggered with the period, independent of the value.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 738 def set_gui_tab_selected_callback_configuration(period, value_has_to_change) check_validity send_request FUNCTION_SET_GUI_TAB_SELECTED_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, '' end
Adds a text-tab with the given index.
You can use up to 10 tabs.
A text-tab with the same index as a icon-tab will overwrite the icon-tab.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 663 def set_gui_tab_text(index, text) check_validity send_request FUNCTION_SET_GUI_TAB_TEXT, [index, text], 'C Z5', 8, '' end
Sets the status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets.
You can also turn the LED permanently on/off or show a heartbeat.
If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 945 def set_status_led_config(config) check_validity send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, '' end
The period is the period with which the CALLBACK_TOUCH_GESTURE
callback is triggered periodically. A value of 0 turns the callback off.
If the `value has to change`-parameter is set to true, the callback is only triggered after the value has changed. If the value didn't change within the period, the callback is triggered immediately on change.
If it is set to false, the callback is continuously triggered with the period, independent of the value.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 410 def set_touch_gesture_callback_configuration(period, value_has_to_change) check_validity send_request FUNCTION_SET_TOUCH_GESTURE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, '' end
Sets the touch LED configuration. By default the LED is on if the LCD is touched.
You can also turn the LED permanently on/off or show a heartbeat.
If the Bricklet is in bootloader mode, the LED is off.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 858 def set_touch_led_config(config) check_validity send_request FUNCTION_SET_TOUCH_LED_CONFIG, [config], 'C', 8, '' end
The period is the period with which the CALLBACK_TOUCH_POSITION
callback is triggered periodically. A value of 0 turns the callback off.
If the `value has to change`-parameter is set to true, the callback is only triggered after the value has changed. If the value didn't change within the period, the callback is triggered immediately on change.
If it is set to false, the callback is continuously triggered with the period, independent of the value.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 372 def set_touch_position_callback_configuration(period, value_has_to_change) check_validity send_request FUNCTION_SET_TOUCH_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, '' end
Sets the firmware pointer for BrickletLCD128x64#write_firmware
. The pointer has to be increased by chunks of size 64. The data is written to flash every 4 chunks (which equals to one page of size 256).
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 918 def set_write_firmware_pointer(pointer) check_validity send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, '' end
Writes 64 Bytes of firmware at the position as written by BrickletLCD128x64#set_write_firmware_pointer
before. The firmware is written to flash every 4 chunks.
You can only write firmware in bootloader mode.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 932 def write_firmware(data) check_validity send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C' end
Writes text to a specific line with a specific position.
For example: (1, 10, “Hello”) will write Hello in the middle of the second line of the display.
The display uses a special 5x7 pixel charset. You can view the characters of the charset in Brick Viewer.
If automatic draw is enabled (default) the text is directly written to the screen. Only pixels that have actually changed are updated on the screen, the rest stays the same.
If automatic draw is disabled the text is written to an internal buffer and the buffer is transferred to the display only after BrickletLCD128x64#draw_buffered_frame
is called. This can be used to avoid flicker when drawing a complex frame in multiple steps.
Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
function.
This function is a 1:1 replacement for the function with the same name in the LCD 20x4 Bricklet. You can draw text at a specific pixel position and with different font sizes with the BrickletLCD128x64#draw_text
function.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 330 def write_line(line, position, text) check_validity send_request FUNCTION_WRITE_LINE, [line, position, text], 'C C Z22', 8, '' end
Writes pixels to the specified window.
The pixels are written into the window line by line top to bottom and each line is written from left to right.
If automatic draw is enabled (default) the pixels are directly written to the screen. Only pixels that have actually changed are updated on the screen, the rest stays the same.
If automatic draw is disabled the pixels are written to an internal buffer and the buffer is transferred to the display only after BrickletLCD128x64#draw_buffered_frame
is called. This can be used to avoid flicker when drawing a complex frame in multiple steps.
Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
function.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 1031 def write_pixels(x_start, y_start, x_end, y_end, pixels) if pixels.length > 65535 raise ArgumentError, 'Pixels can be at most 65535 items long' end pixels_length = pixels.length pixels_chunk_offset = 0 if pixels_length == 0 pixels_chunk_data = [false] * 448 ret = write_pixels_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data else ret = nil # assigned in block @stream_mutex.synchronize { while pixels_chunk_offset < pixels_length pixels_chunk_data = pixels[pixels_chunk_offset, 448] if pixels_chunk_data.length < 448 pixels_chunk_data += [false] * (448 - pixels_chunk_data.length) end ret = write_pixels_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data pixels_chunk_offset += 448 end } end ret end
Writes pixels to the specified window.
The pixels are written into the window line by line top to bottom and each line is written from left to right.
If automatic draw is enabled (default) the pixels are directly written to the screen. Only pixels that have actually changed are updated on the screen, the rest stays the same.
If automatic draw is disabled the pixels are written to an internal buffer and the buffer is transferred to the display only after BrickletLCD128x64#draw_buffered_frame
is called. This can be used to avoid flicker when drawing a complex frame in multiple steps.
Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
function.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 246 def write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) check_validity send_request FUNCTION_WRITE_PIXELS_LOW_LEVEL, [x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data], 'C C C C S S ?448', 8, '' end
Writes a new UID into flash. If you want to set a new UID you have to decode the Base58
encoded UID string into an integer first.
We recommend that you use Brick Viewer to change the UID.
# File lib/tinkerforge/bricklet_lcd_128x64.rb, line 987 def write_uid(uid) check_validity send_request FUNCTION_WRITE_UID, [uid], 'L', 8, '' end