Skip to content

Commit 1f690b1

Browse files
authored
Add invert_luminance option (#29)
1 parent 4046aa8 commit 1f690b1

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

custom_components/gicisky/gicisky_ble/devices.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class DeviceEntry:
1313
mirror_y: bool = False
1414
rotation: int = 0
1515
compression: bool = False
16+
invert_luminance: bool = False
1617
manufacturer: str = "Gicisky"
1718
max_voltage: float = 2.9
1819
min_voltage: float = 2.2
@@ -65,7 +66,8 @@ class DeviceEntry:
6566
model="EPD 10.2\" BWR",
6667
width=960,
6768
height=640,
68-
#compression=True,
69+
compression=True,
70+
invert_luminance=True,
6971
max_voltage=3.0
7072
),
7173
}

custom_components/gicisky/gicisky_ble/writer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def __init__(
100100
self.mirror_x = device.mirror_x
101101
self.mirror_y = device.mirror_y
102102
self.compression = device.compression
103+
self.invert_luminance = device.invert_luminance
103104
self.packet_size = 0 #(device.width * device.height) // 8 * (2 if device.red else 1)
104105
self.event: Event = Event()
105106
self.command_data: bytes | None = None
@@ -262,7 +263,10 @@ def _make_image_packet(self, image: Image, threshold: int, red_threshold: int) -
262263
r, g, b = pixels[px]
263264

264265
luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b
265-
if self.compression:
266+
if self.invert_luminance:
267+
if luminance > threshold:
268+
current_byte |= (1 << bit_pos)
269+
elif self.compression:
266270
if luminance < threshold:
267271
current_byte |= (1 << bit_pos)
268272
else:

custom_components/gicisky/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"documentation": "https://github.com/eigger/hass-gicisky",
1919
"issue_tracker": "https://github.com/eigger/hass-gicisky/issues",
2020
"iot_class": "local_push",
21-
"version": "1.4.4",
21+
"version": "1.4.5",
2222
"requirements": [
2323
"qrcode[pil]==7.4.2",
2424
"python-barcode==0.15.1"

0 commit comments

Comments
 (0)