Class: Tinkerforge::BrickletEPaper296x128

Inherits:
Device
  • Object
show all
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_SET_DISPLAY_DRIVER =

:nodoc:

16
FUNCTION_GET_DISPLAY_DRIVER =

:nodoc:

17
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
DISPLAY_DRIVER_SSD1675A =

:nodoc:

0
DISPLAY_DRIVER_SSD1680 =

: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

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.



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
129
130
131
132
133
134
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 97

def initialize(uid, ipcon)
  super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME

  @api_version = [2, 0, 1]

  @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_SET_DISPLAY_DRIVER] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_DISPLAY_DRIVER] = 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

#drawObject

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.



140
141
142
143
144
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 140

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.



270
271
272
273
274
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 270

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.



257
258
259
260
261
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 257

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.

The font conforms to code page 437.



247
248
249
250
251
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 247

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.



232
233
234
235
236
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 232

def fill_display(color)
  check_validity

  send_request FUNCTION_FILL_DISPLAY, [color], 'C', 8, ''
end

#get_bootloader_modeObject

Returns the current bootloader mode, see BrickletEPaper296x128#set_bootloader_mode.



395
396
397
398
399
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 395

def get_bootloader_mode
  check_validity

  send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
end

#get_chip_temperatureObject

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.



453
454
455
456
457
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 453

def get_chip_temperature
  check_validity

  send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
end

#get_display_driverObject

Returns the e-paper display driver.

.. versionadded

2.0.3$nbsp;(Plugin)



356
357
358
359
360
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 356

def get_display_driver
  check_validity

  send_request FUNCTION_GET_DISPLAY_DRIVER, [], '', 9, 'C'
end

#get_display_typeObject

Returns the type of the e-paper display. It can either be black/white/red or black/white/gray.



335
336
337
338
339
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 335

def get_display_type
  check_validity

  send_request FUNCTION_GET_DISPLAY_TYPE, [], '', 9, 'C'
end

#get_draw_statusObject

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.



155
156
157
158
159
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 155

def get_draw_status
  check_validity

  send_request FUNCTION_GET_DRAW_STATUS, [], '', 9, 'C'
end

#get_identityObject

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|



500
501
502
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 500

def get_identity
  send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
end

#get_spitfp_error_countObject

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.



373
374
375
376
377
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 373

def get_spitfp_error_count
  check_validity

  send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
end

#get_status_led_configObject

Returns the configuration as set by BrickletEPaper296x128#set_status_led_config



441
442
443
444
445
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 441

def get_status_led_config
  check_validity

  send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
end

#get_update_modeObject

Returns the update mode as set by BrickletEPaper296x128#set_update_mode.



317
318
319
320
321
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 317

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.



555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 555

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.



187
188
189
190
191
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 187

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.



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 642

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.



222
223
224
225
226
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 222

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_uidObject

Returns the current UID as an integer. Encode as Base58 to get the usual string version.



484
485
486
487
488
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 484

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.



676
677
678
679
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 676

def register_callback(id, &block)
  callback = block
  @registered_callbacks[id] = callback
end

#resetObject

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!



465
466
467
468
469
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 465

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.



388
389
390
391
392
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 388

def set_bootloader_mode(mode)
  check_validity

  send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
end

#set_display_driver(display_driver) ⇒ Object

Sets the type of display driver. The Bricklet can currently support SSD1675A and SSD1680. 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.

.. versionadded

2.0.3$nbsp;(Plugin)



347
348
349
350
351
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 347

def set_display_driver(display_driver)
  check_validity

  send_request FUNCTION_SET_DISPLAY_DRIVER, [display_driver], 'C', 8, ''
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.



327
328
329
330
331
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 327

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.



434
435
436
437
438
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 434

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.



310
311
312
313
314
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 310

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.



407
408
409
410
411
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 407

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.



516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 516

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.



173
174
175
176
177
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 173

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.



603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 603

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.



208
209
210
211
212
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 208

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.



421
422
423
424
425
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 421

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.



476
477
478
479
480
# File 'lib/tinkerforge/bricklet_e_paper_296x128.rb', line 476

def write_uid(uid)
  check_validity

  send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
end