Class: Tinkerforge::BrickletEPaper296x128
- Defined in:
- lib/tinkerforge/bricklet_e_paper_296x128.rb
Overview
Three color 296x128 e-paper display
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
2146- DEVICE_DISPLAY_NAME =
:nodoc:
'E-Paper 296x128 Bricklet'- CALLBACK_DRAW_STATUS =
Callback for the current draw status. Will be called every time the draw status changes (see BrickletEPaper296x128#get_draw_status).
11- FUNCTION_DRAW =
:nodoc:
1- FUNCTION_GET_DRAW_STATUS =
:nodoc:
2- FUNCTION_WRITE_BLACK_WHITE_LOW_LEVEL =
:nodoc:
3- FUNCTION_READ_BLACK_WHITE_LOW_LEVEL =
:nodoc:
4- FUNCTION_WRITE_COLOR_LOW_LEVEL =
:nodoc:
5- FUNCTION_READ_COLOR_LOW_LEVEL =
:nodoc:
6- FUNCTION_FILL_DISPLAY =
:nodoc:
7- FUNCTION_DRAW_TEXT =
:nodoc:
8- FUNCTION_DRAW_LINE =
:nodoc:
9- FUNCTION_DRAW_BOX =
:nodoc:
10- FUNCTION_SET_UPDATE_MODE =
:nodoc:
12- FUNCTION_GET_UPDATE_MODE =
:nodoc:
13- FUNCTION_SET_DISPLAY_TYPE =
:nodoc:
14- FUNCTION_GET_DISPLAY_TYPE =
:nodoc:
15- FUNCTION_GET_SPITFP_ERROR_COUNT =
:nodoc:
234- FUNCTION_SET_BOOTLOADER_MODE =
:nodoc:
235- FUNCTION_GET_BOOTLOADER_MODE =
:nodoc:
236- FUNCTION_SET_WRITE_FIRMWARE_POINTER =
:nodoc:
237- FUNCTION_WRITE_FIRMWARE =
:nodoc:
238- FUNCTION_SET_STATUS_LED_CONFIG =
:nodoc:
239- FUNCTION_GET_STATUS_LED_CONFIG =
:nodoc:
240- FUNCTION_GET_CHIP_TEMPERATURE =
:nodoc:
242- FUNCTION_RESET =
:nodoc:
243- FUNCTION_WRITE_UID =
:nodoc:
248- FUNCTION_READ_UID =
:nodoc:
249- FUNCTION_GET_IDENTITY =
:nodoc:
255- DRAW_STATUS_IDLE =
:nodoc:
0- DRAW_STATUS_COPYING =
:nodoc:
1- DRAW_STATUS_DRAWING =
:nodoc:
2- COLOR_BLACK =
:nodoc:
0- COLOR_WHITE =
:nodoc:
1- COLOR_RED =
:nodoc:
2- COLOR_GRAY =
:nodoc:
2- FONT_6X8 =
:nodoc:
0- FONT_6X16 =
:nodoc:
1- FONT_6X24 =
:nodoc:
2- FONT_6X32 =
:nodoc:
3- FONT_12X16 =
:nodoc:
4- FONT_12X24 =
:nodoc:
5- FONT_12X32 =
:nodoc:
6- FONT_18X24 =
:nodoc:
7- FONT_18X32 =
:nodoc:
8- FONT_24X32 =
:nodoc:
9- ORIENTATION_HORIZONTAL =
:nodoc:
0- ORIENTATION_VERTICAL =
:nodoc:
1- UPDATE_MODE_DEFAULT =
:nodoc:
0- UPDATE_MODE_BLACK_WHITE =
:nodoc:
1- UPDATE_MODE_DELTA =
:nodoc:
2- DISPLAY_TYPE_BLACK_WHITE_RED =
:nodoc:
0- DISPLAY_TYPE_BLACK_WHITE_GRAY =
:nodoc:
1- BOOTLOADER_MODE_BOOTLOADER =
:nodoc:
0- BOOTLOADER_MODE_FIRMWARE =
:nodoc:
1- BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT =
:nodoc:
2- BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT =
:nodoc:
3- BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT =
:nodoc:
4- BOOTLOADER_STATUS_OK =
:nodoc:
0- BOOTLOADER_STATUS_INVALID_MODE =
:nodoc:
1- BOOTLOADER_STATUS_NO_CHANGE =
:nodoc:
2- BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT =
:nodoc:
3- BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT =
:nodoc:
4- BOOTLOADER_STATUS_CRC_MISMATCH =
:nodoc:
5- STATUS_LED_CONFIG_OFF =
:nodoc:
0- STATUS_LED_CONFIG_ON =
:nodoc:
1- STATUS_LED_CONFIG_SHOW_HEARTBEAT =
:nodoc:
2- STATUS_LED_CONFIG_SHOW_STATUS =
:nodoc:
3
Constants inherited from Device
Device::DEVICE_IDENTIFIER_CHECK_MATCH, Device::DEVICE_IDENTIFIER_CHECK_MISMATCH, Device::DEVICE_IDENTIFIER_CHECK_PENDING, Device::RESPONSE_EXPECTED_ALWAYS_TRUE, Device::RESPONSE_EXPECTED_FALSE, Device::RESPONSE_EXPECTED_INVALID_FUNCTION_ID, Device::RESPONSE_EXPECTED_TRUE
Instance Attribute Summary
Attributes inherited from Device
#callback_formats, #expected_response_function_id, #expected_response_sequence_number, #high_level_callbacks, #registered_callbacks, #replaced, #uid
Instance Method Summary collapse
-
#draw ⇒ Object
Draws the current black/white and red or gray buffer to the e-paper display.
-
#draw_box(position_x_start, position_y_start, position_x_end, position_y_end, fill, color) ⇒ Object
Draws a box from (x, y)-start to (x, y)-end in the given color.
-
#draw_line(position_x_start, position_y_start, position_x_end, position_y_end, color) ⇒ Object
Draws a line from (x, y)-start to (x, y)-end in the given color.
-
#draw_text(position_x, position_y, font, color, orientation, text) ⇒ Object
Draws a text with up to 50 characters at the pixel position (x, y).
-
#fill_display(color) ⇒ Object
Fills the complete content of the display with the given color.
-
#get_bootloader_mode ⇒ Object
Returns the current bootloader mode, see BrickletEPaper296x128#set_bootloader_mode.
-
#get_chip_temperature ⇒ Object
Returns the temperature as measured inside the microcontroller.
-
#get_display_type ⇒ Object
Returns the type of the e-paper display.
-
#get_draw_status ⇒ Object
Returns one of three draw statuses:.
-
#get_identity ⇒ Object
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
-
#get_spitfp_error_count ⇒ Object
Returns the error count for the communication between Brick and Bricklet.
-
#get_status_led_config ⇒ Object
Returns the configuration as set by BrickletEPaper296x128#set_status_led_config.
-
#get_update_mode ⇒ Object
Returns the update mode as set by BrickletEPaper296x128#set_update_mode.
-
#initialize(uid, ipcon) ⇒ BrickletEPaper296x128
constructor
Creates an object with the unique device ID
uidand adds it to the IP Connectionipcon. -
#read_black_white(x_start, y_start, x_end, y_end) ⇒ Object
Returns the current content of the black/white pixel buffer for the specified window.
-
#read_black_white_low_level(x_start, y_start, x_end, y_end) ⇒ Object
Returns the current content of the black/white pixel buffer for the specified window.
-
#read_color(x_start, y_start, x_end, y_end) ⇒ Object
Returns the current content of the red or gray pixel buffer for the specified window.
-
#read_color_low_level(x_start, y_start, x_end, y_end) ⇒ Object
Returns the current content of the red or gray pixel buffer for the specified window.
-
#read_uid ⇒ Object
Returns the current UID as an integer.
-
#register_callback(id, &block) ⇒ Object
Registers a callback with ID
idto the blockblock. -
#reset ⇒ Object
Calling this function will reset the Bricklet.
-
#set_bootloader_mode(mode) ⇒ Object
Sets the bootloader mode and returns the status after the requested mode change was instigated.
-
#set_display_type(display_type) ⇒ Object
Sets the type of the display.
-
#set_status_led_config(config) ⇒ Object
Sets the status LED configuration.
-
#set_update_mode(update_mode) ⇒ Object
..
-
#set_write_firmware_pointer(pointer) ⇒ Object
Sets the firmware pointer for BrickletEPaper296x128#write_firmware.
-
#write_black_white(x_start, y_start, x_end, y_end, pixels) ⇒ Object
Writes black/white pixels to the specified window into the buffer.
-
#write_black_white_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) ⇒ Object
Writes black/white pixels to the specified window into the buffer.
-
#write_color(x_start, y_start, x_end, y_end, pixels) ⇒ Object
The E-Paper 296x128 Bricklet is available with the colors black/white/red and black/white/gray.
-
#write_color_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) ⇒ Object
The E-Paper 296x128 Bricklet is available with the colors black/white/red and black/white/gray.
-
#write_firmware(data) ⇒ Object
Writes 64 Bytes of firmware at the position as written by BrickletEPaper296x128#set_write_firmware_pointer before.
-
#write_uid(uid) ⇒ Object
Writes a new UID into flash.
Methods inherited from Device
#check_validity, #dequeue_response, #enqueue_response, #get_api_version, #get_response_expected, #send_request, #set_response_expected, #set_response_expected_all
Constructor Details
#initialize(uid, ipcon) ⇒ BrickletEPaper296x128
Creates an object with the unique device ID uid and adds it to the IP Connection ipcon.
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 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 93 def initialize(uid, ipcon) super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME @api_version = [2, 0, 0] @response_expected[FUNCTION_DRAW] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_DRAW_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_WRITE_BLACK_WHITE_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_READ_BLACK_WHITE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_WRITE_COLOR_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_READ_COLOR_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_FILL_DISPLAY] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DRAW_TEXT] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DRAW_LINE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DRAW_BOX] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_SET_UPDATE_MODE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_UPDATE_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_DISPLAY_TYPE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_DISPLAY_TYPE] = 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_DRAW_STATUS] = [9, 'C'] @ipcon.add_device self end |
Instance Method Details
#draw ⇒ Object
Draws the current black/white and red or gray buffer to the e-paper display.
The Bricklet does not have any double-buffering. You should not call this function while writing to the buffer. See BrickletEPaper296x128#get_draw_status.
134 135 136 137 138 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 134 def draw check_validity send_request FUNCTION_DRAW, [], '', 8, '' end |
#draw_box(position_x_start, position_y_start, position_x_end, position_y_end, fill, color) ⇒ Object
Draws a box from (x, y)-start to (x, y)-end in the given color.
If you set fill to true, the box will be filled with the color. Otherwise only the outline will be drawn.
This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer to the display use BrickletEPaper296x128#draw.
262 263 264 265 266 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 262 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], 'S C S C ? C', 8, '' end |
#draw_line(position_x_start, position_y_start, position_x_end, position_y_end, color) ⇒ Object
Draws a line from (x, y)-start to (x, y)-end in the given color.
This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer to the display use BrickletEPaper296x128#draw.
249 250 251 252 253 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 249 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], 'S C S C C', 8, '' end |
#draw_text(position_x, position_y, font, color, orientation, text) ⇒ Object
Draws a text with up to 50 characters at the pixel position (x, y).
You can use one of 9 different font sizes and draw the text in black/white/red|gray. The text can be drawn horizontal or vertical.
This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer to the display use BrickletEPaper296x128#draw.
239 240 241 242 243 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 239 def draw_text(position_x, position_y, font, color, orientation, text) check_validity send_request FUNCTION_DRAW_TEXT, [position_x, position_y, font, color, orientation, text], 'S C C C C Z50', 8, '' end |
#fill_display(color) ⇒ Object
Fills the complete content of the display with the given color.
This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer to the display use BrickletEPaper296x128#draw.
226 227 228 229 230 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 226 def fill_display(color) check_validity send_request FUNCTION_FILL_DISPLAY, [color], 'C', 8, '' end |
#get_bootloader_mode ⇒ Object
Returns the current bootloader mode, see BrickletEPaper296x128#set_bootloader_mode.
366 367 368 369 370 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 366 def get_bootloader_mode check_validity send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C' end |
#get_chip_temperature ⇒ Object
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.
424 425 426 427 428 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 424 def get_chip_temperature check_validity send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's' end |
#get_display_type ⇒ Object
Returns the type of the e-paper display. It can either be black/white/red or black/white/gray.
327 328 329 330 331 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 327 def get_display_type check_validity send_request FUNCTION_GET_DISPLAY_TYPE, [], '', 9, 'C' end |
#get_draw_status ⇒ Object
Returns one of three draw statuses:
-
Idle
-
Copying: Data is being copied from the buffer of the Bricklet to the buffer of the display.
-
Drawing: The display is updating its content (during this phase the flickering etc happens).
You can write to the buffer (through one of the write or draw functions) when the status is either idle or drawing. You should not write to the buffer while it is being copied to the display. There is no double-buffering.
149 150 151 152 153 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 149 def get_draw_status check_validity send_request FUNCTION_GET_DRAW_STATUS, [], '', 9, 'C' end |
#get_identity ⇒ Object
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|
471 472 473 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 471 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end |
#get_spitfp_error_count ⇒ Object
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.
344 345 346 347 348 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 344 def get_spitfp_error_count check_validity send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L' end |
#get_status_led_config ⇒ Object
Returns the configuration as set by BrickletEPaper296x128#set_status_led_config
412 413 414 415 416 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 412 def get_status_led_config check_validity send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C' end |
#get_update_mode ⇒ Object
Returns the update mode as set by BrickletEPaper296x128#set_update_mode.
309 310 311 312 313 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 309 def get_update_mode check_validity send_request FUNCTION_GET_UPDATE_MODE, [], '', 9, 'C' end |
#read_black_white(x_start, y_start, x_end, y_end) ⇒ Object
Returns the current content of the black/white pixel buffer for the specified window.
The pixels are read into the window line by line top to bottom and each line is read from left to right.
The current content of the buffer does not have to be the current content of the display. It is possible that the data was not drawn to the display yet and after a restart of the Bricklet the buffer will be reset to black, while the display retains its content.
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 526 def read_black_white(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_black_white_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_black_white_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 + 464 < pixels_length ret = read_black_white_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 |
#read_black_white_low_level(x_start, y_start, x_end, y_end) ⇒ Object
Returns the current content of the black/white pixel buffer for the specified window.
The pixels are read into the window line by line top to bottom and each line is read from left to right.
The current content of the buffer does not have to be the current content of the display. It is possible that the data was not drawn to the display yet and after a restart of the Bricklet the buffer will be reset to black, while the display retains its content.
181 182 183 184 185 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 181 def read_black_white_low_level(x_start, y_start, x_end, y_end) check_validity send_request FUNCTION_READ_BLACK_WHITE_LOW_LEVEL, [x_start, y_start, x_end, y_end], 'S C S C', 70, 'S S ?464' end |
#read_color(x_start, y_start, x_end, y_end) ⇒ Object
Returns the current content of the red or gray pixel buffer for 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.
The current content of the buffer does not have to be the current content of the display. It is possible that the data was not drawn to the display yet and after a restart of the Bricklet the buffer will be reset to black, while the display retains its content.
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 613 def read_color(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_color_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_color_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 + 464 < pixels_length ret = read_color_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 |
#read_color_low_level(x_start, y_start, x_end, y_end) ⇒ Object
Returns the current content of the red or gray pixel buffer for 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.
The current content of the buffer does not have to be the current content of the display. It is possible that the data was not drawn to the display yet and after a restart of the Bricklet the buffer will be reset to black, while the display retains its content.
216 217 218 219 220 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 216 def read_color_low_level(x_start, y_start, x_end, y_end) check_validity send_request FUNCTION_READ_COLOR_LOW_LEVEL, [x_start, y_start, x_end, y_end], 'S C S C', 70, 'S S ?464' end |
#read_uid ⇒ Object
Returns the current UID as an integer. Encode as Base58 to get the usual string version.
455 456 457 458 459 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 455 def read_uid check_validity send_request FUNCTION_READ_UID, [], '', 12, 'L' end |
#register_callback(id, &block) ⇒ Object
Registers a callback with ID id to the block block.
647 648 649 650 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 647 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end |
#reset ⇒ Object
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!
436 437 438 439 440 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 436 def reset check_validity send_request FUNCTION_RESET, [], '', 8, '' end |
#set_bootloader_mode(mode) ⇒ Object
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.
359 360 361 362 363 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 359 def set_bootloader_mode(mode) check_validity send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C' end |
#set_display_type(display_type) ⇒ Object
Sets the type of the display. The e-paper display is available in black/white/red and black/white/gray. This will be factory set during the flashing and testing phase. The value is saved in non-volatile memory and will stay after a power cycle.
319 320 321 322 323 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 319 def set_display_type(display_type) check_validity send_request FUNCTION_SET_DISPLAY_TYPE, [display_type], 'C', 8, '' end |
#set_status_led_config(config) ⇒ Object
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.
405 406 407 408 409 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 405 def set_status_led_config(config) check_validity send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, '' end |
#set_update_mode(update_mode) ⇒ Object
- .. note
-
The default update mode corresponds to the default e-paper display manufacturer settings. All of the other modes are experimental and will result in increased ghosting and possibly other long-term side effects.
If you want to know more about the inner workings of an e-paper display take a look at this excellent video from Ben Krasnow: ‘www.youtube.com/watch?v=MsbiO8EAsGw <www.youtube.com/watch?v=MsbiO8EAsGw>`__.
If you are not sure about this option, leave the update mode at default.
Currently there are three update modes available:
-
Default: Settings as given by the manufacturer. An update will take about 7.5 seconds and during the update the screen will flicker several times.
-
Black/White: This will only update the black/white pixel. It uses the manufacturer settings for black/white and ignores the red or gray pixel buffer. With this mode the display will flicker once and it takes about 2.5 seconds. Compared to the default settings there is more ghosting.
-
Delta: This will only update the black/white pixel. It uses an aggressive method where the changes are not applied for a whole buffer but only for the delta between the last and the next buffer. With this mode the display will not flicker during an update and it takes about 900-950ms. Compared to the other two settings there is more ghosting. This mode can be used for something like a flicker-free live update of a text.
With the black/white/red display if you use either the black/white or the delta mode, after a while of going back and forth between black and white the white color will start to appear red-ish or pink-ish.
If you use the aggressive delta mode and rapidly change the content, we recommend that you change back to the default mode every few hours and in the default mode cycle between the three available colors a few times. This will get rid of the ghosting and after that you can go back to the delta mode with flicker-free updates.
302 303 304 305 306 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 302 def set_update_mode(update_mode) check_validity send_request FUNCTION_SET_UPDATE_MODE, [update_mode], 'C', 8, '' end |
#set_write_firmware_pointer(pointer) ⇒ Object
Sets the firmware pointer for BrickletEPaper296x128#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.
378 379 380 381 382 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 378 def set_write_firmware_pointer(pointer) check_validity send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, '' end |
#write_black_white(x_start, y_start, x_end, y_end, pixels) ⇒ Object
Writes black/white pixels to the specified window into the buffer.
The pixels are written into the window line by line top to bottom and each line is written from left to right.
The value 0 (false) corresponds to a black pixel and the value 1 (true) to a white pixel.
This function writes the pixels into the black/white pixel buffer, to draw the buffer to the display use BrickletEPaper296x128#draw.
Use BrickletEPaper296x128#write_color to write red or gray pixels.
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 487 def write_black_white(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] * 432 ret = write_black_white_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, 432] if pixels_chunk_data.length < 432 pixels_chunk_data += [false] * (432 - pixels_chunk_data.length) end ret = write_black_white_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data pixels_chunk_offset += 432 end } end ret end |
#write_black_white_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) ⇒ Object
Writes black/white pixels to the specified window into the buffer.
The pixels are written into the window line by line top to bottom and each line is written from left to right.
The value 0 (false) corresponds to a black pixel and the value 1 (true) to a white pixel.
This function writes the pixels into the black/white pixel buffer, to draw the buffer to the display use BrickletEPaper296x128#draw.
Use BrickletEPaper296x128#write_color to write red or gray pixels.
167 168 169 170 171 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 167 def write_black_white_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) check_validity send_request FUNCTION_WRITE_BLACK_WHITE_LOW_LEVEL, [x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data], 'S C S C S S ?432', 8, '' end |
#write_color(x_start, y_start, x_end, y_end, pixels) ⇒ Object
The E-Paper 296x128 Bricklet is available with the colors black/white/red and black/white/gray. Depending on the model this function writes either red or gray pixels to the specified window into the buffer.
The pixels are written into the window line by line top to bottom and each line is written from left to right.
The value 0 (false) means that this pixel does not have color. It will be either black or white (see BrickletEPaper296x128#write_black_white). The value 1 (true) corresponds to a red or gray pixel, depending on the Bricklet model.
This function writes the pixels into the red or gray pixel buffer, to draw the buffer to the display use BrickletEPaper296x128#draw.
Use BrickletEPaper296x128#write_black_white to write black/white pixels.
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 574 def write_color(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] * 432 ret = write_color_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, 432] if pixels_chunk_data.length < 432 pixels_chunk_data += [false] * (432 - pixels_chunk_data.length) end ret = write_color_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data pixels_chunk_offset += 432 end } end ret end |
#write_color_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) ⇒ Object
The E-Paper 296x128 Bricklet is available with the colors black/white/red and black/white/gray. Depending on the model this function writes either red or gray pixels to the specified window into the buffer.
The pixels are written into the window line by line top to bottom and each line is written from left to right.
The value 0 (false) means that this pixel does not have color. It will be either black or white (see BrickletEPaper296x128#write_black_white). The value 1 (true) corresponds to a red or gray pixel, depending on the Bricklet model.
This function writes the pixels into the red or gray pixel buffer, to draw the buffer to the display use BrickletEPaper296x128#draw.
Use BrickletEPaper296x128#write_black_white to write black/white pixels.
202 203 204 205 206 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 202 def write_color_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) check_validity send_request FUNCTION_WRITE_COLOR_LOW_LEVEL, [x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data], 'S C S C S S ?432', 8, '' end |
#write_firmware(data) ⇒ Object
Writes 64 Bytes of firmware at the position as written by BrickletEPaper296x128#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.
392 393 394 395 396 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 392 def write_firmware(data) check_validity send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C' end |
#write_uid(uid) ⇒ Object
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.
447 448 449 450 451 |
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 447 def write_uid(uid) check_validity send_request FUNCTION_WRITE_UID, [uid], 'L', 8, '' end |