idotmatrix-api-client 0.2.3__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. idotmatrix_api_client-1.0.0/PKG-INFO +185 -0
  2. idotmatrix_api_client-1.0.0/README.md +163 -0
  3. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/apps/digital_picture_frame.py +3 -22
  4. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/connection_manager.py +14 -0
  5. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/__init__.py +7 -1
  6. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/countdown.py +0 -1
  7. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/effect.py +5 -1
  8. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/gif.py +214 -111
  9. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/graffiti.py +2 -2
  10. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/image.py +41 -12
  11. idotmatrix_api_client-1.0.0/idotmatrix/modules/materials.py +227 -0
  12. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/system.py +1 -1
  13. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/text.py +3 -1
  14. idotmatrix_api_client-1.0.0/idotmatrix/tui/__init__.py +1 -0
  15. idotmatrix_api_client-1.0.0/idotmatrix/tui/__main__.py +31 -0
  16. idotmatrix_api_client-1.0.0/idotmatrix/tui/app.py +896 -0
  17. idotmatrix_api_client-1.0.0/idotmatrix/tui/canvas.py +140 -0
  18. idotmatrix_api_client-1.0.0/idotmatrix/tui/colorwheel.py +245 -0
  19. idotmatrix_api_client-1.0.0/idotmatrix/tui/controls.py +61 -0
  20. idotmatrix_api_client-1.0.0/idotmatrix/tui/convert.py +73 -0
  21. idotmatrix_api_client-1.0.0/idotmatrix/tui/devicebar.py +55 -0
  22. idotmatrix_api_client-1.0.0/idotmatrix/tui/devices.py +243 -0
  23. idotmatrix_api_client-1.0.0/idotmatrix/tui/dialogs.py +259 -0
  24. idotmatrix_api_client-1.0.0/idotmatrix/tui/draw.py +575 -0
  25. idotmatrix_api_client-1.0.0/idotmatrix/tui/features.py +235 -0
  26. idotmatrix_api_client-1.0.0/idotmatrix/tui/files.py +89 -0
  27. idotmatrix_api_client-1.0.0/idotmatrix/tui/forms.py +381 -0
  28. idotmatrix_api_client-1.0.0/idotmatrix/tui/pages.py +71 -0
  29. idotmatrix_api_client-1.0.0/idotmatrix/tui/preview.py +243 -0
  30. idotmatrix_api_client-1.0.0/idotmatrix/tui/previews.py +206 -0
  31. idotmatrix_api_client-1.0.0/idotmatrix/tui/scanner.py +37 -0
  32. idotmatrix_api_client-1.0.0/idotmatrix/tui/scoreboard.py +172 -0
  33. idotmatrix_api_client-1.0.0/idotmatrix/tui/settings.py +243 -0
  34. idotmatrix_api_client-1.0.0/idotmatrix/tui/widgets.py +523 -0
  35. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/util/file_watch.py +0 -1
  36. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/util/image_utils.py +46 -2
  37. idotmatrix_api_client-1.0.0/idotmatrix/util/overlay.py +95 -0
  38. idotmatrix_api_client-1.0.0/idotmatrix/util/quality.py +50 -0
  39. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/pyproject.toml +8 -1
  40. idotmatrix_api_client-0.2.3/PKG-INFO +0 -378
  41. idotmatrix_api_client-0.2.3/README.md +0 -359
  42. idotmatrix_api_client-0.2.3/idotmatrix/modules/materials.py +0 -120
  43. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/LICENSE +0 -0
  44. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/__init__.py +0 -0
  45. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/apps/__init__.py +0 -0
  46. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/client.py +0 -0
  47. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/const.py +0 -0
  48. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-ErbosDraco1StOpenNbpRegular-l5wX.ttf +0 -0
  49. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-MinecraftStandard.otf +0 -0
  50. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-MinecraftStandardBoldOblique.otf +0 -0
  51. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-PixelOperator8-Bold.ttf +0 -0
  52. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-PixelOperator8.ttf +0 -0
  53. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-PixelifySans-Regular.ttf +0 -0
  54. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-PressStart2P-Regular.ttf +0 -0
  55. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-dogica.ttf +0 -0
  56. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-dogicabold.ttf +0 -0
  57. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-dogicapixel.ttf +0 -0
  58. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16-dogicapixelbold.ttf +0 -0
  59. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16_32-HomeVideo-BLG6G.ttf +0 -0
  60. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16_32-HomeVideoBold-R90Dv.ttf +0 -0
  61. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/16_32-MayfairNbpBold-gAA4.ttf +0 -0
  62. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/32-Jersey10-Regular.ttf +0 -0
  63. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/CC-BY-SA-4.0-License.txt +0 -0
  64. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/ErbosDraco-License.txt +0 -0
  65. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/HomeVideo-License.txt +0 -0
  66. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/Jersey10-Regular-License.txt +0 -0
  67. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/MayfairNbpBold-License.txt +0 -0
  68. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/MinecraftStandard-License.txt +0 -0
  69. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/PixelOperator-License.txt +0 -0
  70. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/PixelifySans-License.txt +0 -0
  71. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/PressStart2P-Regular-License.txt +0 -0
  72. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/Rain-DRM3-License.txt +0 -0
  73. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/Rain-DRM3.otf +0 -0
  74. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/fonts/dogica_license.txt +0 -0
  75. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/chronograph.py +0 -0
  76. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/clock.py +0 -0
  77. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/common.py +0 -0
  78. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/eco.py +0 -0
  79. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/fullscreen_color.py +0 -0
  80. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/music_sync.py +0 -0
  81. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/modules/scoreboard.py +0 -0
  82. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/protocol.py +0 -0
  83. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/screensize.py +0 -0
  84. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/transport.py +0 -0
  85. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/util/__init__.py +0 -0
  86. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/util/color_utils.py +0 -0
  87. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/util/command_ack.py +0 -0
  88. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/util/device_info.py +0 -0
  89. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/util/device_material.py +0 -0
  90. {idotmatrix_api_client-0.2.3 → idotmatrix_api_client-1.0.0}/idotmatrix/util/upload_ack.py +0 -0
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.4
2
+ Name: idotmatrix-api-client
3
+ Version: 1.0.0
4
+ Summary: A library for controlling iDotMatrix displays.
5
+ License-Expression: GPL-3.0-or-later
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.12,<3.15
8
+ Classifier: Intended Audience :: Developers
9
+ Provides-Extra: tui
10
+ Requires-Dist: bleak (>=0.22.3)
11
+ Requires-Dist: cryptography (>=46.0.7)
12
+ Requires-Dist: pillow (>=12.2.0)
13
+ Requires-Dist: textual (>=8.0.0) ; extra == "tui"
14
+ Requires-Dist: textual-image (>=0.14.0) ; extra == "tui"
15
+ Requires-Dist: watchdog (>=6.0.0)
16
+ Project-URL: Bug Tracker, https://github.com/markusressel/idotmatrix-api-client/issues
17
+ Project-URL: Documentation, https://github.com/markusressel/idotmatrix-api-client
18
+ Project-URL: Homepage, https://github.com/markusressel/idotmatrix-api-client
19
+ Project-URL: Repository, https://github.com/markusressel/idotmatrix-api-client
20
+ Description-Content-Type: text/markdown
21
+
22
+ <br/>
23
+ <p align="center">
24
+ <a href="https://github.com/markusressel/idotmatrix-api-client">
25
+ <img src="images/logo.png" alt="Logo" width="250" height="250">
26
+ </a>
27
+
28
+ <h3 align="center">idotmatrix-api-client</h3>
29
+
30
+ <p align="center">
31
+ Control 16x16, 32x32 and 64x64 sized iDotMatrix Pixel Displays
32
+ </p>
33
+
34
+ <p align="center">
35
+ <img src="https://img.shields.io/github/contributors/markusressel/idotmatrix-api-client?color=dark-green" alt="Contributors">
36
+ <img src="https://img.shields.io/github/license/markusressel/idotmatrix-api-client" alt="License">
37
+ </p>
38
+ </p>
39
+
40
+ ## Features
41
+
42
+ <img src="docs/images/device.png" alt="An iDotMatrix pixel display showing a pixel art picture" width="220" align="right">
43
+
44
+ A library to control displays like the one on the right without the official
45
+ [iDotMatrix](https://play.google.com/store/apps/details?id=com.tech.idotmatrix&pli=1) app, based on its reverse engineered
46
+ Bluetooth protocol.
47
+
48
+ Looking for Home Assistant? The [ha-idotmatrix](https://github.com/markusressel/ha-idotmatrix) integration is built on
49
+ this library.
50
+
51
+ * Show photos, animated GIFs and pixel art, with text on top, or store them in the slots of the device so that it
52
+ cycles through them on its own
53
+ * Clock, countdown, chronograph, scoreboard, graffiti board, effects and a full screen color
54
+ * Scrolling text with the bundled pixel fonts
55
+ * Music sync with the microphone of the device
56
+ * Brightness, eco mode, power and time
57
+ * Digital picture frame for a folder of pictures
58
+ * Terminal UI to try all of it
59
+ * Works with the 16x16, 32x32 and 64x64 displays, with `bleak` or with the Bluetooth stack of Home Assistant
60
+
61
+ Open ends (alarm and buzzer, the cloud API, password protection, firmware update) are collected in the
62
+ [device protocol notes](docs/DEVICE-PROTOCOL.md#not-understood-yet).
63
+
64
+ <br clear="right"/>
65
+
66
+ ## Getting Started
67
+
68
+ You need Python 3.12 or newer and a display that works with the iDotMatrix app (Windows may work but is untested).
69
+
70
+ ### Terminal UI
71
+
72
+ The quickest way to try your display: browse a folder, preview how pictures and animations look on the display, send
73
+ them, and control its features, with a pixel editor.
74
+
75
+ ![The terminal UI: the files of a folder, the preview as it looks on the display and the details](docs/images/tui.png)
76
+
77
+ ```sh
78
+ pip install 'idotmatrix-api-client[tui]'
79
+ idotmatrix-tui /path/to/pictures
80
+ ```
81
+
82
+ See the [TUI notes](docs/TUI.md) for the keys and options.
83
+
84
+ ### API Client
85
+
86
+ To control the display from your own code, install the library and use the `IDotMatrixClient`:
87
+
88
+ ```sh
89
+ pip install idotmatrix-api-client
90
+ ```
91
+
92
+ ```python
93
+ import asyncio
94
+
95
+ from idotmatrix import IDotMatrixClient, ScreenSize
96
+
97
+
98
+ async def main():
99
+ client = IDotMatrixClient(screen_size=ScreenSize.SIZE_64x64)
100
+ await client.connect() # connects to the first iDotMatrix display it finds
101
+
102
+ await client.set_brightness(50)
103
+ await client.text.show_text("Hello World!")
104
+ await client.image.show_image_file("photo.jpg")
105
+
106
+
107
+ asyncio.run(main())
108
+ ```
109
+
110
+ The [examples](./examples) show more: GIFs, labels, effects, and storing files in the slots of the device.
111
+
112
+ #### Digital Picture Frame
113
+
114
+ The `DigitalPictureFrame` class builds on the client and shows images and GIFs as a slideshow. It can
115
+
116
+ * display a static list of images and/or GIFs
117
+ * watch one or more directories for images and GIFs
118
+ * automatically reconnect to the device in case of an error or connection loss
119
+
120
+ See [examples/example_digital_picture_frame.py](./examples/example_digital_picture_frame.py) for how to use it.
121
+
122
+ #### Home Assistant and other Bluetooth stacks
123
+
124
+ If something else owns the Bluetooth stack, like Home Assistant with its scanner and Bluetooth proxies, see the
125
+ [integration notes](docs/INTEGRATION.md).
126
+
127
+ ## Fonts
128
+
129
+ Text is drawn in 1-bit cells without anti-aliasing, so pixel fonts work best. The package bundles a selection that was
130
+ tested at fixed `font_size` values. See the [font notes](docs/FONTS.md) for the sizes, licenses and how to add more.
131
+
132
+ ## Helpful Links
133
+
134
+ * This project
135
+ * [idotmatrix-api-client on PyPI](https://pypi.org/project/idotmatrix-api-client/)
136
+ * [Device protocol notes](docs/DEVICE-PROTOCOL.md): what is known about the Bluetooth protocol of the displays
137
+ * Related projects
138
+ * [ha-idotmatrix](https://github.com/markusressel/ha-idotmatrix): Home Assistant integration built on this library
139
+ * [derkalle4/python3-idotmatrix-library](https://github.com/derkalle4/python3-idotmatrix-library): the original
140
+ project this is a fork of
141
+ * [8none1/idotmatrix](https://github.com/8none1/idotmatrix): further notes and tools for the displays
142
+ * [fbnlrz/homeyidotmatrix](https://github.com/fbnlrz/homeyidotmatrix): Homey integration with protocol notes
143
+ * The official [iDotMatrix app](https://play.google.com/store/apps/details?id=com.tech.idotmatrix) (Android)
144
+ * Create images or GIFs
145
+ * [pixilart](https://www.pixilart.com/draw): create a new drawing and select a preset for the size of your display
146
+ (e.g. 64x64)
147
+
148
+ ## Other Hardware
149
+ This software is specifically built for devices which are supported by the iDotMatrix app. There are other devices
150
+ being sold which have a similar form factor and claim to be compatible, but which are not. Below is a list of known
151
+ non-iDotMatrix-compatible hardware and associated software.
152
+ - For hardware supported by the "LOY SPACE" app: https://github.com/eskibars/popledder/
153
+
154
+ ## Contributing
155
+
156
+ GitHub is for social coding: if you want to write code, I encourage contributions through pull requests from forks
157
+ of this repository. Create GitHub tickets for bugs and new features and comment on the ones that you are interested in.
158
+
159
+ To work on the library, see the [development notes](docs/DEVELOPMENT.md).
160
+
161
+ ## License
162
+
163
+ Distributed under the GNU GENERAL PUBLIC License.
164
+ See [LICENSE](https://github.com/markusressel/idotmatrix-api-client/blob/main/LICENSE) for more information.
165
+
166
+ ## Differences From The Original Project
167
+
168
+ This is a fork of [derkalle4/python3-idotmatrix-library](https://github.com/derkalle4/python3-idotmatrix-library),
169
+ which is no longer maintained. The fork continues its development and maintenance.
170
+
171
+ The API is not compatible with the original: the structure was reworked for usability and maintainability, so code
172
+ written for the original needs some adjustments to run with this library. Returning the raw bytearray data of commands
173
+ was dropped to keep the library simple.
174
+
175
+ ## Acknowledgements
176
+
177
+ Original project by [derkalle4](https://github.com/derkalle4) and [jmgraeffe](https://github.com/jmgraeffe).
178
+
179
+ * [Othneil Drew](https://github.com/othneildrew/Best-README-Template) - *README Template*
180
+ * [LordRippon](https://github.com/LordRippon) - *Reverse Engineering for the Displays*
181
+ * [8none1](https://github.com/8none1) - *Reverse Engineering for the Displays*
182
+ * [schorsch3000](https://github.com/schorsch3000) - *smaller fixes*
183
+ * [tekka007](https://github.com/tekka007) - *code refactoring and reverse engineering*
184
+ * [inselberg](https://github.com/inselberg) - *Reverse Engineering for the Displays*
185
+
@@ -0,0 +1,163 @@
1
+ <br/>
2
+ <p align="center">
3
+ <a href="https://github.com/markusressel/idotmatrix-api-client">
4
+ <img src="images/logo.png" alt="Logo" width="250" height="250">
5
+ </a>
6
+
7
+ <h3 align="center">idotmatrix-api-client</h3>
8
+
9
+ <p align="center">
10
+ Control 16x16, 32x32 and 64x64 sized iDotMatrix Pixel Displays
11
+ </p>
12
+
13
+ <p align="center">
14
+ <img src="https://img.shields.io/github/contributors/markusressel/idotmatrix-api-client?color=dark-green" alt="Contributors">
15
+ <img src="https://img.shields.io/github/license/markusressel/idotmatrix-api-client" alt="License">
16
+ </p>
17
+ </p>
18
+
19
+ ## Features
20
+
21
+ <img src="docs/images/device.png" alt="An iDotMatrix pixel display showing a pixel art picture" width="220" align="right">
22
+
23
+ A library to control displays like the one on the right without the official
24
+ [iDotMatrix](https://play.google.com/store/apps/details?id=com.tech.idotmatrix&pli=1) app, based on its reverse engineered
25
+ Bluetooth protocol.
26
+
27
+ Looking for Home Assistant? The [ha-idotmatrix](https://github.com/markusressel/ha-idotmatrix) integration is built on
28
+ this library.
29
+
30
+ * Show photos, animated GIFs and pixel art, with text on top, or store them in the slots of the device so that it
31
+ cycles through them on its own
32
+ * Clock, countdown, chronograph, scoreboard, graffiti board, effects and a full screen color
33
+ * Scrolling text with the bundled pixel fonts
34
+ * Music sync with the microphone of the device
35
+ * Brightness, eco mode, power and time
36
+ * Digital picture frame for a folder of pictures
37
+ * Terminal UI to try all of it
38
+ * Works with the 16x16, 32x32 and 64x64 displays, with `bleak` or with the Bluetooth stack of Home Assistant
39
+
40
+ Open ends (alarm and buzzer, the cloud API, password protection, firmware update) are collected in the
41
+ [device protocol notes](docs/DEVICE-PROTOCOL.md#not-understood-yet).
42
+
43
+ <br clear="right"/>
44
+
45
+ ## Getting Started
46
+
47
+ You need Python 3.12 or newer and a display that works with the iDotMatrix app (Windows may work but is untested).
48
+
49
+ ### Terminal UI
50
+
51
+ The quickest way to try your display: browse a folder, preview how pictures and animations look on the display, send
52
+ them, and control its features, with a pixel editor.
53
+
54
+ ![The terminal UI: the files of a folder, the preview as it looks on the display and the details](docs/images/tui.png)
55
+
56
+ ```sh
57
+ pip install 'idotmatrix-api-client[tui]'
58
+ idotmatrix-tui /path/to/pictures
59
+ ```
60
+
61
+ See the [TUI notes](docs/TUI.md) for the keys and options.
62
+
63
+ ### API Client
64
+
65
+ To control the display from your own code, install the library and use the `IDotMatrixClient`:
66
+
67
+ ```sh
68
+ pip install idotmatrix-api-client
69
+ ```
70
+
71
+ ```python
72
+ import asyncio
73
+
74
+ from idotmatrix import IDotMatrixClient, ScreenSize
75
+
76
+
77
+ async def main():
78
+ client = IDotMatrixClient(screen_size=ScreenSize.SIZE_64x64)
79
+ await client.connect() # connects to the first iDotMatrix display it finds
80
+
81
+ await client.set_brightness(50)
82
+ await client.text.show_text("Hello World!")
83
+ await client.image.show_image_file("photo.jpg")
84
+
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ The [examples](./examples) show more: GIFs, labels, effects, and storing files in the slots of the device.
90
+
91
+ #### Digital Picture Frame
92
+
93
+ The `DigitalPictureFrame` class builds on the client and shows images and GIFs as a slideshow. It can
94
+
95
+ * display a static list of images and/or GIFs
96
+ * watch one or more directories for images and GIFs
97
+ * automatically reconnect to the device in case of an error or connection loss
98
+
99
+ See [examples/example_digital_picture_frame.py](./examples/example_digital_picture_frame.py) for how to use it.
100
+
101
+ #### Home Assistant and other Bluetooth stacks
102
+
103
+ If something else owns the Bluetooth stack, like Home Assistant with its scanner and Bluetooth proxies, see the
104
+ [integration notes](docs/INTEGRATION.md).
105
+
106
+ ## Fonts
107
+
108
+ Text is drawn in 1-bit cells without anti-aliasing, so pixel fonts work best. The package bundles a selection that was
109
+ tested at fixed `font_size` values. See the [font notes](docs/FONTS.md) for the sizes, licenses and how to add more.
110
+
111
+ ## Helpful Links
112
+
113
+ * This project
114
+ * [idotmatrix-api-client on PyPI](https://pypi.org/project/idotmatrix-api-client/)
115
+ * [Device protocol notes](docs/DEVICE-PROTOCOL.md): what is known about the Bluetooth protocol of the displays
116
+ * Related projects
117
+ * [ha-idotmatrix](https://github.com/markusressel/ha-idotmatrix): Home Assistant integration built on this library
118
+ * [derkalle4/python3-idotmatrix-library](https://github.com/derkalle4/python3-idotmatrix-library): the original
119
+ project this is a fork of
120
+ * [8none1/idotmatrix](https://github.com/8none1/idotmatrix): further notes and tools for the displays
121
+ * [fbnlrz/homeyidotmatrix](https://github.com/fbnlrz/homeyidotmatrix): Homey integration with protocol notes
122
+ * The official [iDotMatrix app](https://play.google.com/store/apps/details?id=com.tech.idotmatrix) (Android)
123
+ * Create images or GIFs
124
+ * [pixilart](https://www.pixilart.com/draw): create a new drawing and select a preset for the size of your display
125
+ (e.g. 64x64)
126
+
127
+ ## Other Hardware
128
+ This software is specifically built for devices which are supported by the iDotMatrix app. There are other devices
129
+ being sold which have a similar form factor and claim to be compatible, but which are not. Below is a list of known
130
+ non-iDotMatrix-compatible hardware and associated software.
131
+ - For hardware supported by the "LOY SPACE" app: https://github.com/eskibars/popledder/
132
+
133
+ ## Contributing
134
+
135
+ GitHub is for social coding: if you want to write code, I encourage contributions through pull requests from forks
136
+ of this repository. Create GitHub tickets for bugs and new features and comment on the ones that you are interested in.
137
+
138
+ To work on the library, see the [development notes](docs/DEVELOPMENT.md).
139
+
140
+ ## License
141
+
142
+ Distributed under the GNU GENERAL PUBLIC License.
143
+ See [LICENSE](https://github.com/markusressel/idotmatrix-api-client/blob/main/LICENSE) for more information.
144
+
145
+ ## Differences From The Original Project
146
+
147
+ This is a fork of [derkalle4/python3-idotmatrix-library](https://github.com/derkalle4/python3-idotmatrix-library),
148
+ which is no longer maintained. The fork continues its development and maintenance.
149
+
150
+ The API is not compatible with the original: the structure was reworked for usability and maintainability, so code
151
+ written for the original needs some adjustments to run with this library. Returning the raw bytearray data of commands
152
+ was dropped to keep the library simple.
153
+
154
+ ## Acknowledgements
155
+
156
+ Original project by [derkalle4](https://github.com/derkalle4) and [jmgraeffe](https://github.com/jmgraeffe).
157
+
158
+ * [Othneil Drew](https://github.com/othneildrew/Best-README-Template) - *README Template*
159
+ * [LordRippon](https://github.com/LordRippon) - *Reverse Engineering for the Displays*
160
+ * [8none1](https://github.com/8none1) - *Reverse Engineering for the Displays*
161
+ * [schorsch3000](https://github.com/schorsch3000) - *smaller fixes*
162
+ * [tekka007](https://github.com/tekka007) - *code refactoring and reverse engineering*
163
+ * [inselberg](https://github.com/inselberg) - *Reverse Engineering for the Displays*
@@ -1,7 +1,6 @@
1
1
  import asyncio
2
2
  import logging
3
3
  import re
4
- import signal
5
4
  from asyncio import sleep, Task
6
5
  from enum import Enum
7
6
  from os import PathLike
@@ -272,6 +271,9 @@ class DigitalPictureFrame:
272
271
  """
273
272
  Starts a slideshow of images on the digital picture frame.
274
273
 
274
+ It does not handle signals: the application decides how it shuts down, and calls `stop_slideshow()` then
275
+ (see examples/example_digital_picture_frame.py).
276
+
275
277
  Args:
276
278
  interval (int): Time in seconds between image changes. Defaults to 5 seconds.
277
279
  """
@@ -280,24 +282,6 @@ class DigitalPictureFrame:
280
282
  if interval is not None:
281
283
  self.set_interval(interval)
282
284
 
283
- async def async_signal_handler():
284
- """
285
- Handles the signal to stop the slideshow gracefully.
286
- """
287
- await self.stop_slideshow()
288
- # TODO: doing it like this is probably a bad idea,
289
- # since it will also kill anything else that is currently running,
290
- # or even fail to stop the loop,
291
- # but I haven't gotten anything else to work yet :(
292
- asyncio.get_event_loop().stop()
293
-
294
- def signal_handler(signum):
295
- signame = signal.Signals(signum).name
296
- logging.info(f'Signal handler called with signal {signame} ({signum})')
297
- asyncio.ensure_future(async_signal_handler())
298
-
299
- asyncio.get_event_loop().add_signal_handler(signal.SIGINT, lambda: signal_handler(signal.SIGINT))
300
- asyncio.get_event_loop().add_signal_handler(signal.SIGTERM, lambda: signal_handler(signal.SIGTERM))
301
285
  self._slideshow_task = self._start_slideshow_task()
302
286
  await asyncio.sleep(0)
303
287
  return self._slideshow_task
@@ -332,9 +316,6 @@ class DigitalPictureFrame:
332
316
  await self.device_client.clock.show(show_date=False)
333
317
  await self.device_client.disconnect()
334
318
 
335
- asyncio.get_event_loop().remove_signal_handler(signal.SIGINT)
336
- asyncio.get_event_loop().remove_signal_handler(signal.SIGTERM)
337
-
338
319
  def is_slideshow_running(self) -> bool:
339
320
  """
340
321
  Checks if the slideshow is currently running.
@@ -429,6 +429,7 @@ class ConnectionManager:
429
429
  packets: List[List[bytearray | bytes]],
430
430
  response: bool = False,
431
431
  wait_for_ack: bool = False,
432
+ progress: Callable[[int, int], None] | None = None,
432
433
  ):
433
434
  """
434
435
  Sends multiple packets to the device.
@@ -443,6 +444,9 @@ class ConnectionManager:
443
444
  response: If True, a write-with-response operation will be used, otherwise a write-without-response operation will be used.
444
445
  wait_for_ack: If True, the device has to acknowledge each packet before the next one is sent. This is how
445
446
  the official app transfers images and GIFs, the device drops or garbles data that is sent too early.
447
+ progress: Called with (packets done, packets in total) after each packet, with wait_for_ack once the
448
+ device acknowledged it. The upload is done when the two are equal, also when the device skips the
449
+ rest because it already has the data. Runs on the event loop, so it must not block.
446
450
  Raises:
447
451
  UploadError: If wait_for_ack is set and the device rejects a packet or does not answer in time.
448
452
  """
@@ -494,7 +498,17 @@ class ConnectionManager:
494
498
  if status == UploadStatus.FINISHED and i < len(packets) - 1:
495
499
  # f.e. the device already has the same data stored
496
500
  self.logging.debug("the device reports the upload as finished, skipping the remaining packets")
501
+ self._report_progress(progress, len(packets), len(packets))
497
502
  return
503
+ self._report_progress(progress, i + 1, len(packets))
504
+
505
+ def _report_progress(self, progress: Callable[[int, int], None] | None, done: int, total: int) -> None:
506
+ if progress is None:
507
+ return
508
+ try:
509
+ progress(done, total)
510
+ except Exception:
511
+ self.logging.exception("the progress callback failed")
498
512
 
499
513
  async def _write_chunk(
500
514
  self, packet: List[bytearray | bytes], response: bool, all_with_response: bool, paced: bool, label: str
@@ -1,4 +1,5 @@
1
1
  from asyncio import sleep
2
+ from collections.abc import Callable
2
3
  from typing import List
3
4
 
4
5
  from idotmatrix.connection_manager import ConnectionManager
@@ -45,6 +46,7 @@ class IDotMatrixModule:
45
46
  response: bool = False,
46
47
  sleep_after: float = None,
47
48
  wait_for_ack: bool = False,
49
+ progress: Callable[[int, int], None] | None = None,
48
50
  ):
49
51
  """
50
52
  Sends multiple packets to the IDotMatrix device.
@@ -54,11 +56,15 @@ class IDotMatrixModule:
54
56
  sleep_after (float, optional): Time to wait after sending the packets. Defaults to 0 if response=True and 0.5 seconds if response=False.
55
57
  wait_for_ack (bool, optional): Whether the device has to acknowledge each packet before the next one is sent.
56
58
  Required for uploads of images and GIFs. Defaults to False.
59
+ progress (Callable[[int, int], None], optional): Called with (packets done, packets in total), see
60
+ `ConnectionManager.send_packets`.
57
61
  """
58
62
  if sleep_after is None:
59
63
  sleep_after = 0 if response else 0.5
60
64
 
61
- await self._connection_manager.send_packets(packets=packets, response=response, wait_for_ack=wait_for_ack)
65
+ extra = {} if progress is None else {"progress": progress}
66
+ await self._connection_manager.send_packets(
67
+ packets=packets, response=response, wait_for_ack=wait_for_ack, **extra)
62
68
  if sleep_after > 0:
63
69
  # sometimes the device needs a moment to process the command before it is able to receive the next one
64
70
  await sleep(sleep_after)
@@ -51,7 +51,6 @@ class CountdownModule(IDotMatrixModule):
51
51
  """
52
52
  if mode not in range(0, 4):
53
53
  raise ValueError("Countdown.setMode expects parameter mode to be between 0 and 3")
54
- # TODO: check for valid range of minutes
55
54
  if seconds > 59 or seconds < 0:
56
55
  raise ValueError("Countdown.setMode expects parameter seconds to be between 0 and 59")
57
56
  if minutes > 59 or minutes < 0:
@@ -9,7 +9,11 @@ from idotmatrix.util import color_utils
9
9
 
10
10
 
11
11
  class EffectStyle(Enum):
12
- """Enum for the different effect styles."""
12
+ """
13
+ Enum for the different effect styles. Tried on a 64x64: GRADIENT_HORIZONTAL_RAINBOW (0) is smooth horizontal
14
+ stripes moving down, VERTICAL_RAINBOW (3) is hard vertical stripes moving to the right and
15
+ DIAGONAL_RIGHT_RAINBOW (4) is hard stripes (from the top left to the bottom right) that move to the top right. DIAGONAL_LEFT_RAINBOW_ON_BLACK (5) is single colored stripes from the bottom left to the top right on black (stripe and gap 4 pixels wide) that move to the top left. The others were not checked.
16
+ """
13
17
 
14
18
  GRADIENT_HORIZONTAL_RAINBOW = 0
15
19
  RANDOM_COLORED_PIXELS_ON_BLACK = 1