├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── __init__.py ├── app.py ├── build.bat ├── build.ps1 ├── build.sh ├── core └── cmd.py ├── create_venv.sh ├── find_cmds.sh ├── fonts ├── Rain-DRM3-License.txt └── Rain-DRM3.otf ├── gui.py ├── idmc.ico ├── images ├── demo.gif ├── demo_16.png ├── demo_32.png ├── demo_512.png ├── demo_64.png └── logo.png ├── pyproject.toml ├── run_in_venv.ps1 ├── run_in_venv.sh ├── utils └── utils.py └── windows_scripts ├── gui.ps1 └── setup_and_install_gui.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | venv_windows/ 128 | ENV/ 129 | env.bak/ 130 | venv.bak/ 131 | 132 | # Spyder project settings 133 | .spyderproject 134 | .spyproject 135 | 136 | # Rope project settings 137 | .ropeproject 138 | 139 | # mkdocs documentation 140 | /site 141 | 142 | # mypy 143 | .mypy_cache/ 144 | .dmypy.json 145 | dmypy.json 146 | 147 | # Pyre type checker 148 | .pyre/ 149 | 150 | # pytype static type analyzer 151 | .pytype/ 152 | 153 | # Cython debug symbols 154 | cython_debug/ 155 | 156 | # PyCharm 157 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 158 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 159 | # and can be added to the global gitignore or merged into this file. For a more nuclear 160 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 161 | #.idea/ 162 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | education, socio-economic status, nationality, personal appearance, race, 10 | religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at {{ email }}. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!NOTE] 2 | > Due to a long-term health condition (post-COVID since almost three years), I am unable to continue developing this project. Although many amazing contributors have helped over the years, I am unsure when I will be able to resume work. This is my most popular project (over 300 stars!), and I hope others will continue to improve the client and library for various use cases, such as Home Assistant integration. Thank you for your understanding and support. 3 | 4 |
5 |

6 | 7 | Logo 8 | 9 | 10 |

Pixel Display Client

11 | 12 |

13 | control all your 16x16 or 32x32 pixel displays 14 |
15 |
16 | Explore the docs » 17 |
18 |
19 | Report Bug 20 | . 21 | Request Feature 22 |

23 |

24 | 25 | ![Downloads](https://img.shields.io/github/downloads/derkalle4/python3-idotmatrix-client/total) ![Contributors](https://img.shields.io/github/contributors/derkalle4/python3-idotmatrix-client?color=dark-green) ![Forks](https://img.shields.io/github/forks/derkalle4/python3-idotmatrix-client?style=social) ![Stargazers](https://img.shields.io/github/stars/derkalle4/python3-idotmatrix-client?style=social) ![Issues](https://img.shields.io/github/issues/derkalle4/python3-idotmatrix-client) ![License](https://img.shields.io/github/license/derkalle4/python3-idotmatrix-client) 26 | 27 | ## Table Of Contents 28 | 29 | * [About the Project](#about-the-project) 30 | * [Built With](#built-with) 31 | * [Getting Started](#getting-started) 32 | * [Prerequisites](#prerequisites) 33 | * [Installation](#installation) 34 | * [Usage](#usage) 35 | * [Gif Compilations](#gif-compilations) 36 | * [GUI](#gui) 37 | * [Troubleshooting](#troubleshooting) 38 | * [Roadmap](#roadmap) 39 | * [Contributing](#contributing) 40 | * [License](#license) 41 | * [Authors](#authors) 42 | * [Acknowledgements](#acknowledgements) 43 | 44 | ## About The Project 45 | 46 | This repository aims to reverse engineer the [iDotMatrix](https://play.google.com/store/apps/details?id=com.tech.idotmatrix&pli=1) Android App for pixel screen displays like [this one on Aliexpress](https://de.aliexpress.com/item/1005006105517779.html). The goal is to be able to control multiple pixel screen displays via a GUI, an Rest API and the command line. 47 | 48 | The initial reason for this project was to have a foundation to update one or multiple pixel displays during live streams on Twitch or other platforms where one can use this to further automate interactions with the audience. Please let us know if you're using this to do so :) 49 | 50 | ## Built With 51 | 52 | * [Python 3](https://www.python.org/downloads/) 53 | * [iDotMatrix Library](https://github.com/derkalle4/python3-idotmatrix-library) 54 | * [argparse](https://docs.python.org/3/library/argparse.html) 55 | * [asyncio](https://docs.python.org/3/library/asyncio.html) 56 | * [bleak](https://github.com/hbldh/bleak) 57 | * [pillow](https://python-pillow.org) 58 | * [PyQt5](https://pypi.org/project/PyQt5/) 59 | * [pyinstaller](https://pyinstaller.org) 60 | 61 | ## Getting Started 62 | 63 | To get a local copy up and running follow these simple example steps: 64 | 65 | ### Prerequisites 66 | 67 | Please install the following for your OS: 68 | 69 | * Latest version of Python (Python3) 70 | 71 | 72 | 73 | ### Installation 74 | 75 | #### For Linux or MSYS2/Git Bash 76 | 77 | 1. Clone the repo 78 | 79 | ```sh 80 | git clone https://github.com/derkalle4/python3-idotmatrix-client.git 81 | ``` 82 | 83 | 2. `cd` to it 84 | 85 | ```sh 86 | cd python3-idotmatrix-client 87 | ``` 88 | 89 | 3. Create virtual environment and install all dependencies 90 | 91 | ```sh 92 | ./create_venv.sh 93 | ``` 94 | 95 | #### For windows 96 | 97 | 1. Download the repository 98 | 99 | Either click the green "Code" button in GitHub and clicking "Download ZIP", and extracting this file to a folder, or by using Git: 100 | 101 | ```ps1 102 | git clone https://github.com/derkalle4/python3-idotmatrix-client.git 103 | ``` 104 | 105 | 2. Install Python 106 | 107 | Go to https://www.python.org/downloads/windows/ and install the latets stable release. 108 | 109 | 110 | 3. Open it in Explorer and run "build.ps1" 111 | 112 | The `build.ps1` script automatically handles setting up the python virtual environment and a shortcut to the GUI. 113 | 114 | Open this script by right clicking it, and clicking "Run with PowerShell", or by nagivating to them in a PowerShell terminal and writing "./" followed by its filename. 115 | 116 | 117 | 118 | 119 | 120 | 121 | ## Usage 122 | 123 | If you used the ./create_venv.sh you should use this command to run the app: 124 | 125 | ```sh 126 | ./run_in_venv.sh 127 | ``` 128 | 129 | If you have manually opened the virtual environment, or are not using a virtual environment, the same can be accomplished with the following: 130 | 131 | ```sh 132 | python3 .\app.py 133 | ``` 134 | 135 | #### command line arguments 136 | 137 | ##### -h or --help 138 | 139 | Shows you every available command line argument. This will always show the newest args, try it if something from this section doesn't work, in case an argument here is outdated. 140 | 141 | ##### --address (required for all commands except "scan") 142 | 143 | Specifies the address of the pixel display device. Use "auto" to use the first available device (automatically looking for IDM-* devices in range). 144 | 145 | ```sh 146 | ./run_in_venv.sh --address 00:11:22:33:44:ff 147 | ``` 148 | 149 | ##### --scan 150 | 151 | Scans all bluetooth devices in range for iDotMatrix devices. Quits afterwards. Cannot be combined with other commands (use --address auto instead). 152 | 153 | ```sh 154 | ./run_in_venv.sh --scan 155 | ``` 156 | 157 | ##### --sync-time 158 | 159 | Sets the time of the device to the current local time. 160 | 161 | ```sh 162 | ./run_in_venv.sh --address 00:11:22:33:44:ff --sync-time 163 | ``` 164 | 165 | ###### --set-time 166 | 167 | Sets the time of the device to any time you want. 168 | 169 | ```sh 170 | ./run_in_venv.sh --address 00:11:22:33:44:ff --sync-time --set-time 18-12-2023-19:10:10 171 | ``` 172 | 173 | ##### --screen 174 | 175 | Turns the screen either on or off. 176 | 177 | ```sh 178 | ./run_in_venv.sh --address 00:11:22:33:44:ff --screen on 179 | ./run_in_venv.sh --address 00:11:22:33:44:ff --screen off 180 | ``` 181 | 182 | ##### --flip-screen 183 | 184 | Rotates the device display by 180 degrees. True to rotate. False to disable rotation. 185 | 186 | ```sh 187 | ./run_in_venv.sh --address 00:11:22:33:44:ff --flip-screen true 188 | ``` 189 | 190 | ##### --toggle-screen-freeze 191 | 192 | Freezes or unfreezes the screen. Does not seem to work currently. 193 | 194 | ```sh 195 | ./run_in_venv.sh --address 00:11:22:33:44:ff --toggle-screen-freeze 196 | ``` 197 | 198 | ##### --chronograph 199 | 200 | Sets the mode of the cronograph: 201 | 202 | - 0 = reset 203 | - 1 = (re)start 204 | - 2 = pause 205 | - 3 = continue after pause 206 | 207 | ```sh 208 | ./run_in_venv.sh --address 00:11:22:33:44:ff --chronograph 0 209 | ``` 210 | 211 | ##### --clock 212 | 213 | Sets the mode of the clock: 214 | 215 | - 0 = default 216 | - 1 = christmas 217 | - 2 = racing 218 | - 3 = inverted full screen 219 | - 4 = animated hourglass 220 | - 5 = frame 1 221 | - 6 = frame 2 222 | - 7 = frame 3 223 | 224 | ```sh 225 | ./run_in_venv.sh --address 00:11:22:33:44:ff --clock 0 226 | ``` 227 | 228 | ###### --clock-with-date 229 | 230 | Shows the date in addition to the time. 231 | 232 | ```sh 233 | ./run_in_venv.sh --address 00:11:22:33:44:ff --clock 0 --clock-with-date 234 | ``` 235 | 236 | ###### --clock-24h 237 | 238 | Shows the time in 24h format. 239 | 240 | ```sh 241 | ./run_in_venv.sh --address 00:11:22:33:44:ff --clock 0 --clock-24h 242 | ``` 243 | 244 | ###### --clock-color 245 | 246 | Sets the color of the clock in format -- 247 | 248 | ```sh 249 | ./run_in_venv.sh --address 00:11:22:33:44:ff --clock 0 --clock-color 255-0-0 250 | ``` 251 | 252 | ##### --countdown 253 | 254 | Sets the mode of the countdown: 255 | 256 | - 0 = disable 257 | - 1 = start 258 | - 2 = pause 259 | - 3 = restart 260 | 261 | ```sh 262 | ./run_in_venv.sh --address 00:11:22:33:44:ff --countdown 1 263 | ``` 264 | 265 | ###### --countdown-time 266 | 267 | Sets the time of the countdown in format - 268 | 269 | ```sh 270 | ./run_in_venv.sh --address 00:11:22:33:44:ff --countdown 1 --countdown-time 5-0 271 | ``` 272 | 273 | ##### --fullscreen-color 274 | 275 | Sets all pixels to the given color in format -- 276 | 277 | ```sh 278 | ./run_in_venv.sh --address 00:11:22:33:44:ff --fullscreen-color 255-255-255 279 | ``` 280 | 281 | ##### --pixel-color 282 | 283 | Sets one or multiple pixels to the given color in format ---- 284 | 285 | ```sh 286 | ./run_in_venv.sh --address 00:11:22:33:44:ff --pixel-color 10-10-255-255-255 287 | ``` 288 | 289 | ##### --scoreboard 290 | 291 | Sets the score of the scoreboard <0-999>-<0-999> 292 | 293 | ```sh 294 | ./run_in_venv.sh --address 00:11:22:33:44:ff --scoreboard 21-12 295 | ``` 296 | 297 | ##### --image 298 | 299 | Wether to enable the image display mode or not. Set to true show an image or false to hide. 300 | 301 | ```sh 302 | ./run_in_venv.sh --address 00:11:22:33:44:ff --image true 303 | ``` 304 | 305 | ###### --set-image 306 | 307 | Path to an image to display on the device without further processing. This must match your display pixel size (e.g. demo_16.png for the 16x16 variant). See --process-image for more information on how to process a larger (or smaller) image! 308 | 309 | If you do not want to process the image: when using Gimp I had to export the file to a 32x32 pixel PNG (for my 32x32 Pixel Display) and disable all features except the "save resolution" feature to save time when sending the image to the device. Every kind of metadata makes the image bigger and because we only can send around 20bytes at once this can certainly increase the transfer time! 310 | 311 | The [Demo PNG](https://opengameart.org/content/pixel-art-practice) was downloaded from OpenGameArt.org. 312 | 313 | ```sh 314 | ./run_in_venv.sh --address 00:11:22:33:44:ff --image true --set-image ./images/demo_16.png 315 | ./run_in_venv.sh --address 00:11:22:33:44:ff --image true --set-image ./images/demo_32.png 316 | ./run_in_venv.sh --address 00:11:22:33:44:ff --image true --set-image ./images/demo_64.png 317 | ``` 318 | 319 | ###### --process-image 320 | 321 | If specified it will process the given image. If used, the Python3 library Pillow will be utilized to convert the given image to a PNG with the given amount of pixels (e.g. 32 for 32x32 or 16 for 16x16 pixels). Technically you could use all kind of sizes and variations of images. Keep in mind: processing could take some time depending on your computer. In my tests the given demo.png file takes around 1 second without processing and three seconds with processing. 322 | 323 | ```sh 324 | ./run_in_venv.sh --address 00:11:22:33:44:ff --image true --set-image ./images/demo_512.png --process-image 32 325 | ``` 326 | 327 | ##### --set-gif 328 | 329 | Path to an GIF to display on the device. See --process-gif for more information! The [Demo GIF](https://opengameart.org/content/animated-pixel-torch) was downloaded from OpenGameArt.org. 330 | 331 | ```sh 332 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-gif ./images/demo.gif 333 | ``` 334 | 335 | ###### --process-gif 336 | 337 | If specified it will process the given image. If used, the Python3 library Pillow will be utilized to convert the given image to a GIF with the given amount of pixels (e.g. 32 for 32x32 or 16 for 16x16 pixels). Technically you could use all kind of sizes for the GIF. Keep in mind: processing could take some time depending on your computer and using larger GIFs may result in a bad image quality. You should hand-craft your GIFs in the correct format for best results! 338 | 339 | ```sh 340 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-gif ./images/demo.gif --process-gif 32 341 | ``` 342 | 343 | ##### --set-text 344 | 345 | Sets a given text to the display. The [Demo Font](https://www.fontspace.com/rain-font-f22577) was downloaded from fontspace.com and is licensed open source (see font folder or link for details). 346 | 347 | ```sh 348 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-text "Hello World" 349 | ``` 350 | 351 | ###### --text-size 352 | 353 | Sets the size of the text. 354 | 355 | ```sh 356 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-text "Hello World" --text-size 10 357 | ``` 358 | 359 | ###### --text-mode 360 | 361 | Sets the mode of the text. 362 | 363 | ```sh 364 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-text "Hello World" --text-mode 1 365 | ``` 366 | 367 | ###### --text-speed 368 | 369 | Sets the speed of the text. 370 | 371 | ```sh 372 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-text "Hello World" --text-speed 50 373 | ``` 374 | 375 | ###### --text-color-mode 376 | 377 | Sets the color mode of the text. 378 | 379 | ```sh 380 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-text "Hello World" --text-color-mode 1 381 | ``` 382 | 383 | ###### --text-color 384 | 385 | Sets the color of the text. 386 | 387 | ```sh 388 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-text "Hello World" --text-color 255-255-255 389 | ``` 390 | 391 | ###### --text-bg-mode 392 | 393 | Sets the background mode of the text. 394 | 395 | ```sh 396 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-text "Hello World" --text-bg-mode 1 397 | ``` 398 | 399 | ###### --text-bg-color 400 | 401 | Sets the background color of the text. 402 | 403 | ```sh 404 | ./run_in_venv.sh --address 00:11:22:33:44:ff --set-text "Hello World" --text-bg-color 0-0-255 405 | ``` 406 | 407 | ### Gif Compilations 408 | 409 | There's no internal method for creating a compilation of gifs or images, similar to what the app offers, 410 | but you can create this manually with external tools like ImageMaick or https://ezgif.com/, 411 | and upload it to the iDotMatrix device as a single gif. 412 | 413 | 414 | ## GUI 415 | 416 | ### Run Methods 417 | You can run the GUI uncompiled with python, or you can build an executible with Pyinstaller. 418 | 419 | #### Method 1) Run via Python 420 | * Open terminal at ```/python3-idotmatrix-client``` 421 | * Run ```pip install pyqt5``` 422 | * Run ```py gui.py``` 423 | 424 | #### Method 2) Build and Run using PyInstaller 425 | * Run ```build.bat``` for **Windows** or ```build.sh``` for **Linux** 426 | * Click the new ```iDotMatrix Controller``` program in ```/python3-idotmatrix-client``` 427 | 428 | #### Method 3) (Windows only) Build and Run using `build.ps1` 429 | * Right click ```build.ps1``` in Windows Explorer, and click "Run with PowerShell", and answer its prompt. 430 | * Open the new ```iDotMatrix GUI``` program on your desktop 431 | 432 | ### Features 433 | * **Device Search**: *Scans for nearby devices, asks for name, adds to home screen.* 434 | * **Clock Style**: *Set the Clock Style and Color. Auto sync time.* 435 | * **Sync Time**: *Sync time to machine clock.* 436 | * **Set Time**: *Set time.* 437 | * **Screen On/Off**: *Turn the screen On or Off.* 438 | * **Stop Watch**: *Use a stop watch.* 439 | * **Countdown Timer**: *Use a Countdown Timer.* 440 | * **Set Text**: *Set the text value and effects.* 441 | * **Color Studio**: *Set background color, or paint your own designs and save them for later use.* 442 | * **Scoreboard**: *Show a three-digit, two player scoreboard.* 443 | * **Set Image**: *Pick an image from the file browser to set. Auto Image Processing.* 444 | * **Set GIF**: *Pick a GIF from the file browser to set. Auto GIF Processing is attempted but does not always work. Source material closer to 16x16 or 32x32 works best.* 445 | 446 | ### Known Issues 447 | * [ ] Commands somtimes fail to connect to the device. Usually rerunning the last command will work. 448 | * [ ] Screen Flip & Screen Freeze work inconsistantly and are not included with the GUI. 449 | 450 | *Found a GUI bug? Submitting a new GUI request? Tag [@TheBigWazz](https://github.com/thebigwazz)* 451 | 452 |
453 | 454 | ## Troubleshooting 455 | 456 | ### Can't upload gifs/images 457 | 458 | Try: 459 | 460 | - Sending the "reset" command (`--reset`) 461 | - Use `--process-image` so the program tries to scale your images correctly for you 462 | - Pre-scale your image to 32x32 or 16x16 pixels using an image editor, and send it unprocessed ("raw" in the GUI) 463 | - Convert your image to a gif and upload it (You can use ImageMagick or something like http://ezgif.com) 464 | 465 | ### Can't find device ID 466 | 467 | Try: 468 | 469 | - Check that bluetooth is on 470 | - Place the iDotMatrix display nearby 471 | - Unplug and replug the iDotMatrix display 472 | - Restart your PC 473 | - If that's not an option for you, killing every "Python" task might work instead. 474 | 475 | ### Other 476 | 477 | If all else fails, you can open an issue on the repository's GitHub. 478 | 479 | 480 | ## Roadmap 481 | 482 | If you want to contribute please focus on the reverse-engineering part (find more information in the [iDotMatrix Library](https://github.com/derkalle4/python3-idotmatrix-library)). Many thanks for all contributions! If you want to dive deep into other issues please check for "#TODO" comments in the source code as well. 483 | 484 | * [X] outsource the reverse-engineered part to a library (suggestion from issue #17) 485 | * [ ] build configuration file to manage (multiple) devices 486 | * [ ] Build command line interface with all features to interact with the device 487 | * [ ] Build RestAPI to interact with the device remotely 488 | * [ ] Homeassistant Integration 489 | * [X] Build GUI to allow non-technical people to use this software 490 | * [X] build search tool to find displays nearby 491 | * [ ] make this software compatible with Windows and Linux 492 | * [ ] provide executables for Windows 493 | 494 | ## Contributing 495 | 496 | Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**. 497 | * If you have suggestions for adding or removing projects, feel free to [open an issue](https://github.com/derkalle4/python3-idotmatrix-client/issues/new) to discuss it, or directly create a pull request after you edit the *README.md* file with necessary changes. 498 | * Please make sure you check your spelling and grammar. 499 | * Create individual PR for each suggestion. 500 | * Please also read through the [Code Of Conduct](https://github.com/derkalle4/python3-idotmatrix-client/blob/main/CODE_OF_CONDUCT.md) before posting your first idea as well. 501 | 502 | ### Creating A Pull Request 503 | 504 | 1. Fork the Project 505 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 506 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 507 | 4. Push to the Branch (`git push origin feature/AmazingFeature`) 508 | 5. Open a Pull Request 509 | 510 | ## License 511 | 512 | Distributed under the GNU GENERAL PUBLIC License. See [LICENSE](https://github.com/derkalle4/python3-idotmatrix-client/blob/main/LICENSE) for more information. 513 | 514 | ## Authors 515 | 516 | * [Kalle Minkner](https://github.com/derkalle4) - *Project Founder* 517 | * [Jon-Mailes Graeffe](https://github.com/jmgraeffe) - *Co-Founder* 518 | 519 | ## Acknowledgements 520 | 521 | * [Othneil Drew](https://github.com/othneildrew/Best-README-Template) - *README Template* 522 | * [LordRippon](https://github.com/LordRippon) - *Reverse Engineering for the Displays* 523 | * [8none1](https://github.com/8none1) - *Reverse Engineering for the Displays* 524 | * [schorsch3000](https://github.com/schorsch3000) - *smaller fixes* 525 | * [tekka007](https://github.com/tekka007) - *code refactoring and reverse engineering* 526 | * [inselberg](https://github.com/inselberg) - *Reverse Engineering for the Displays* 527 | * [TheBigWazz](https://github.com/thebigwazz) - *GUI and Device Search* 528 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/__init__.py -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | # python imports 2 | import argparse 3 | import asyncio 4 | import logging 5 | 6 | # idotmatrix imports 7 | from core.cmd import CMD 8 | 9 | 10 | def log(): 11 | # set basic logging 12 | logging.basicConfig( 13 | level=logging.DEBUG, 14 | format="%(asctime)s :: %(levelname)s :: %(name)s :: %(message)s", 15 | datefmt="%d.%m.%Y %H:%M:%S", 16 | handlers=[logging.StreamHandler()], 17 | ) 18 | # set log level of asyncio 19 | logging.getLogger("asyncio").setLevel(logging.WARNING) 20 | # set log level of bleak 21 | logging.getLogger("bleak").setLevel(logging.WARNING) 22 | 23 | 24 | def main(): 25 | cmd = CMD() 26 | parser = argparse.ArgumentParser( 27 | description="control all your 16x16 or 32x32 pixel displays" 28 | ) 29 | # global argument 30 | parser.add_argument( 31 | "--address", 32 | action="store", 33 | help="the bluetooth address of the device", 34 | ) 35 | # add cmd arguments 36 | cmd.add_arguments(parser) 37 | # parse arguments 38 | args = parser.parse_args() 39 | # run command 40 | asyncio.run(cmd.run(args)) 41 | 42 | 43 | if __name__ == "__main__": 44 | log() 45 | log = logging.getLogger("idotmatrix") 46 | log.info("initialize app") 47 | try: 48 | main() 49 | except KeyboardInterrupt: 50 | log.info("Caught keyboard interrupt. Stopping app.") 51 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | pip install pyqt5 2 | 3 | pip install pyinstaller 4 | 5 | pyinstaller gui.py -F -w -n "iDotMatrix Controller" -i idmc.ico --distpath ./ -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | .\windows_scripts\setup_and_install_gui.ps1 2 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | pip install pyqt5 2 | 3 | pip install pyinstaller 4 | 5 | pyinstaller gui.py -F -w -n "iDotMatrix Controller" -i idmc.ico --distpath ./ -------------------------------------------------------------------------------- /core/cmd.py: -------------------------------------------------------------------------------- 1 | # python imports 2 | from datetime import datetime 3 | import logging 4 | import os 5 | from PIL import Image 6 | import time 7 | from utils import utils 8 | 9 | # idotmatrix imports 10 | from idotmatrix import ConnectionManager 11 | from idotmatrix import Chronograph 12 | from idotmatrix import Clock 13 | from idotmatrix import Common 14 | from idotmatrix import Countdown 15 | from idotmatrix import Gif 16 | from idotmatrix import Image 17 | from idotmatrix import FullscreenColor 18 | from idotmatrix import MusicSync 19 | from idotmatrix import Scoreboard 20 | from idotmatrix import Graffiti 21 | from idotmatrix import Text 22 | 23 | 24 | class CMD: 25 | conn = ConnectionManager() 26 | logging = logging.getLogger("idotmatrix." + __name__) 27 | 28 | def add_arguments(self, parser): 29 | # scan 30 | parser.add_argument( 31 | "--scan", 32 | action="store_true", 33 | help="scans all bluetooth devices in range for iDotMatrix displays", 34 | ) 35 | # test 36 | parser.add_argument( 37 | "--test", 38 | action="store_true", 39 | help="run the test function from the command line class", 40 | ) 41 | # time sync 42 | parser.add_argument( 43 | "--sync-time", 44 | action="store_true", 45 | help="sync time to device", 46 | ) 47 | parser.add_argument( 48 | "--set-time", 49 | action="store", 50 | help="optionally set time to sync to device (use with --sync-time)", 51 | default=datetime.now().strftime("%d-%m-%Y-%H:%M:%S"), 52 | ) 53 | # device screen rotation 54 | parser.add_argument( 55 | "--flip-screen", 56 | type=str, 57 | choices=["true", "false"], 58 | help="flips screen (true = flip, false = normal)", 59 | ) 60 | # screen toggle 61 | parser.add_argument( 62 | "--toggle-screen-freeze", 63 | action="store_true", 64 | help="freezes or unfreezes the screen", 65 | ) 66 | # enable or disable device screen 67 | parser.add_argument( 68 | "--screen", 69 | type=str, 70 | choices=["on", "off"], 71 | help="turns screen on or off", 72 | ) 73 | # brightness 74 | parser.add_argument( 75 | "--set-brightness", 76 | action="store", 77 | help="sets the brightness of the screen in percent: range 5..100", 78 | ) 79 | # password 80 | parser.add_argument( 81 | "--set-password", 82 | action="store", 83 | help="sets password", 84 | ) 85 | # chronograph 86 | parser.add_argument( 87 | "--chronograph", 88 | action="store", 89 | help="sets the chronograph mode: 0 = reset, 1 = (re)start, 2 = pause, 3 = continue after pause", 90 | ) 91 | # clock 92 | parser.add_argument( 93 | "--clock", 94 | action="store", 95 | help="sets the clock mode: 0 = default, 1 = christmas, 2 = racing, 3 = inverted full screen, 4 = animated hourglass, 5 = frame 1, 6 = frame 2, 7 = frame 3", 96 | ) 97 | parser.add_argument( 98 | "--clock-with-date", 99 | action="store_true", 100 | help="shows the current date in addition to the current time.", 101 | ) 102 | parser.add_argument( 103 | "--clock-24h", 104 | action="store_true", 105 | help="shows the current time in 24h format.", 106 | ) 107 | parser.add_argument( 108 | "--clock-color", 109 | action="store", 110 | help="sets the color of the clock. Format: -- (example: 255-255-255)", 111 | default="255-255-255", 112 | ) 113 | # countdown 114 | parser.add_argument( 115 | "--countdown", 116 | action="store", 117 | help="sets the countdown mode: 0 = disable, 1 = start, 2 = pause, 3 = restart", 118 | ) 119 | parser.add_argument( 120 | "--countdown-time", 121 | action="store", 122 | type=str, 123 | help="sets the countdown mode: - (example: 10-30)", 124 | default="5-0", 125 | ) 126 | # fullscreen color 127 | parser.add_argument( 128 | "--fullscreen-color", 129 | action="store", 130 | help="sets a fullscreen color. Format: -- (example: 255-255-255)", 131 | ) 132 | # pixel color 133 | parser.add_argument( 134 | "--pixel-color", 135 | action="append", 136 | help="sets a pixel to a specific color. Could be used multiple times. Format: ---- (example: 0-0-255-255-255)", 137 | nargs="+", 138 | ) 139 | # scoreboard 140 | parser.add_argument( 141 | "--scoreboard", 142 | action="store", 143 | help="shows the scoreboard with the given scores. Format: <0-999>-<0-999>", 144 | ) 145 | # image upload 146 | parser.add_argument( 147 | "--image", 148 | action="store", 149 | help="enables or disables the image mode (true = enable, false = disable)", 150 | ) 151 | parser.add_argument( 152 | "--set-image", 153 | action="store", 154 | help="uploads a given image file (fastest is png, max. pixel depending on your display). Format: ./path/to/image.png", 155 | ) 156 | parser.add_argument( 157 | "--process-image", 158 | action="store", 159 | help="processes the image instead of sending it raw (useful when the size does not match or it is not a png). Format: ", 160 | ) 161 | # gif upload 162 | parser.add_argument( 163 | "--set-gif", 164 | action="store", 165 | help="uploads a given gif file (pixel depending on your display). Format: ./path/to/image.gif", 166 | ) 167 | parser.add_argument( 168 | "--process-gif", 169 | action="store", 170 | help="processes the gif instead of sending it raw (useful when the size does not match). Format: ", 171 | ) 172 | # text upload 173 | parser.add_argument( 174 | "--set-text", 175 | action="store", 176 | type=str, 177 | help="sets the given text on your display.", 178 | ) 179 | parser.add_argument( 180 | "--text-font-path", 181 | action="store", 182 | type=str, 183 | help="sets the given font for the text.", 184 | ) 185 | parser.add_argument( 186 | "--text-size", 187 | action="store", 188 | type=int, 189 | help="Text size. Defaults to 16.", 190 | default=16, 191 | ) 192 | parser.add_argument( 193 | "--text-mode", 194 | action="store", 195 | type=int, 196 | help="Text mode. Defaults to 0. 0 = replace text, 1 = marquee, 2 = reversed marquee, 3 = vertical rising marquee, 4 = vertical lowering marquee, 5 = blinking, 6 = fading, 7 = tetris, 8 = filling", 197 | default=0, 198 | ) 199 | parser.add_argument( 200 | "--text-speed", 201 | action="store", 202 | type=int, 203 | help="speed (int, optional): Speed of Text. Defaults to 95.", 204 | default=95, 205 | ) 206 | parser.add_argument( 207 | "--text-color-mode", 208 | action="store", 209 | type=int, 210 | help="Text Color Mode. Defaults to 1. 0 = white, 1 = use given RGB color, 2,3,4,5 = rainbow modes", 211 | default=1, 212 | ) 213 | parser.add_argument( 214 | "--text-color", 215 | action="store", 216 | type=str, 217 | help="sets the text color. Format: -- (example: 255-255-255)", 218 | default="255-0-0", 219 | ) 220 | parser.add_argument( 221 | "--text-bg-mode", 222 | action="store", 223 | type=int, 224 | help="Text Background Mode. Defaults to 0. 0 = black, 1 = use given RGB color", 225 | default=0, 226 | ) 227 | parser.add_argument( 228 | "--text-bg-color", 229 | action="store", 230 | type=str, 231 | help="sets the text background color. Format: -- (example: 255-255-255)", 232 | default="255-255-255", 233 | ) 234 | parser.add_argument( 235 | "--reset", 236 | action="store_true", 237 | help="Sends the reset command to the display. This can sometimes help fix persistent glitches.", 238 | ) 239 | parser.add_argument( 240 | "--weather-api-key", 241 | action="store", 242 | type=str, 243 | help="The 'https://weatherapi.com' api key for weather commands.", 244 | ) 245 | parser.add_argument( 246 | "--weather-image-query", 247 | action="store", 248 | type=str, 249 | help="Query to send weatherapi, e.g. city name. Displays an image representing the current weather. \nThis arg requires you to also pass '--process-image' with your pixel size, and the '--weather-api-key' with your 'https://weatherapi.com/' API key.", 250 | ) 251 | parser.add_argument( 252 | "--weather-gif-query", 253 | action="store", 254 | type=str, 255 | help="Query to send weatherapi, e.g. city name. Displays a gif representing current weather. \nThis arg requires you to also pass '--process-gif' with your pixel size, and the '--weather-api-key' with your 'https://weatherapi.com/' API key.", 256 | ) 257 | 258 | async def run(self, args): 259 | self.logging.info("initializing command line") 260 | address = None 261 | if args.scan: 262 | await self.conn.scan() 263 | quit() 264 | if args.address: 265 | self.logging.debug("using --address") 266 | address = args.address 267 | elif "IDOTMATRIX_ADDRESS" in os.environ: 268 | self.logging.debug("using IDOTMATRIX_ADDRESS") 269 | address = os.environ["IDOTMATRIX_ADDRESS"] 270 | if address is None: 271 | self.logging.error("no device address given") 272 | quit() 273 | elif str(address).lower() == "auto": 274 | await self.conn.connectBySearch() 275 | else: 276 | await self.conn.connectByAddress(address) 277 | # arguments which can be run in parallel 278 | if args.sync_time: 279 | await self.sync_time(args.set_time) 280 | if args.flip_screen: 281 | await self.flip_screen(args.flip_screen) 282 | if args.toggle_screen_freeze: 283 | await self.toggle_screen_freeze() 284 | if args.screen: 285 | await self.screen(args.screen) 286 | if args.set_brightness: 287 | await self.set_brightness(int(args.set_brightness)) 288 | if args.set_password: 289 | await self.set_password(args.set_password) 290 | if args.reset: 291 | await self.reset(args) 292 | # arguments which cannot run in parallel 293 | if args.test: 294 | await self.test() 295 | elif args.chronograph: 296 | await self.chronograph(args.chronograph) 297 | elif args.clock: 298 | await self.clock(args) 299 | elif args.countdown: 300 | await self.countdown(args) 301 | elif args.fullscreen_color: 302 | await self.fullscreenColor(args.fullscreen_color) 303 | elif args.pixel_color: 304 | await self.pixelColor(args.pixel_color) 305 | elif args.scoreboard: 306 | await self.scoreboard(args.scoreboard) 307 | elif args.image: 308 | await self.image(args) 309 | elif args.set_gif: 310 | await self.gif(args) 311 | elif args.set_text: 312 | await self.text(args) 313 | elif args.weather_image_query: 314 | await self.weather_image_query(args) 315 | elif args.weather_gif_query: 316 | await self.weather_gif_query(args) 317 | 318 | async def test(self): 319 | """Tests all available options for the device""" 320 | self.logging.info("starting test of device") 321 | ## chronograph 322 | await Chronograph().setMode(1) 323 | time.sleep(5) 324 | await Chronograph().setMode(0) 325 | time.sleep(1) 326 | ## clock 327 | await Clock().setTimeIndicator(True) 328 | await Clock().setMode(0, True, True) 329 | time.sleep(5) 330 | ## countdown 331 | await Countdown().setMode(1, 0, 5) 332 | time.sleep(5) 333 | await Countdown().setMode(0, 0, 5) 334 | ## fullscreen color 335 | await FullscreenColor().setMode(255, 0, 0) 336 | time.sleep(5) 337 | ## scoreboard 338 | await Scoreboard().setMode(1, 0) 339 | time.sleep(1) 340 | await Scoreboard().setMode(1, 1) 341 | time.sleep(1) 342 | await Scoreboard().setMode(1, 2) 343 | time.sleep(1) 344 | await Scoreboard().setMode(2, 2) 345 | ## graffiti 346 | # load graffiti board and color pixel 0,0 red 347 | await Graffiti().setPixel(255, 0, 0, 0, 0) 348 | # load graffitti board and color pixel 1,1 green 349 | await Graffiti().setPixel(0, 255, 0, 1, 1) 350 | # load graffitti board and color pixel 2,2 blue 351 | await Graffiti().setPixel(0, 0, 255, 2, 2) 352 | time.sleep(5) 353 | ## diy image (png) 354 | await Image().setMode(1) 355 | await Image().uploadUnprocessed("./images/demo_32.png") 356 | 357 | async def sync_time(self, argument): 358 | """Synchronize local time to device""" 359 | self.logging.info("starting to synchronize time") 360 | try: 361 | date = datetime.strptime(argument, "%d-%m-%Y-%H:%M:%S") 362 | except ValueError: 363 | self.logging.error( 364 | "wrong format of --set-time: please use dd-mm-YYYY-HH-MM-SS" 365 | ) 366 | quit() 367 | await Common().setTime( 368 | date.year, 369 | date.month, 370 | date.day, 371 | date.hour, 372 | date.minute, 373 | date.second, 374 | ) 375 | 376 | async def flip_screen(self, argument: str) -> None: 377 | """flip device screen 180 degrees""" 378 | self.logging.info("flipping screen") 379 | await Common().flipScreen(argument.upper() == "TRUE") 380 | 381 | async def toggle_screen_freeze(self) -> None: 382 | """toggles the screen freeze""" 383 | self.logging.info("toggling screen freeze") 384 | await Common().freezeScreen() 385 | 386 | async def screen(self, argument: str) -> None: 387 | """turns the screen on or off""" 388 | if argument.upper() == "ON": 389 | self.logging.info("turning screen on") 390 | await Common().screenOn() 391 | else: 392 | self.logging.info("turning screen off") 393 | await Common().screenOff() 394 | 395 | async def set_brightness(self, argument: int) -> None: 396 | """sets the brightness of the screen""" 397 | if argument in range(5, 101): 398 | self.logging.info(f"setting brightness of the screen: {argument}%") 399 | await Common().setBrightness(argument) 400 | else: 401 | self.logging.error("brightness out of range (should be between 5 and 100)") 402 | 403 | async def set_password(self, argument: str) -> None: 404 | """sets connection password""" 405 | try: 406 | conv_password = int(argument) 407 | if len(argument) == 6 and conv_password in range(0, 1000000): 408 | self.logging.info(f"setting password: {argument}") 409 | await Common().setPassword(conv_password) 410 | else: 411 | self.logging.error( 412 | f"Password should be 6 digits long and in range 000000...999999" 413 | ) 414 | except ValueError: 415 | self.logging.error(f"Invalid integer: {argument}") 416 | 417 | async def chronograph(self, argument): 418 | """sets the chronograph mode""" 419 | self.logging.info("setting chronograph mode") 420 | if int(argument) in range(0, 4): 421 | await Chronograph().setMode(int(argument)) 422 | else: 423 | self.logging.error("wrong argument for chronograph mode") 424 | quit() 425 | 426 | async def clock(self, args): 427 | """sets the clock mode""" 428 | self.logging.info("setting clock mode") 429 | if int(args.clock) in range(0, 8): 430 | color = args.clock_color.split("-") 431 | if len(color) < 3: 432 | self.logging.error("wrong argument for --clock-color") 433 | quit() 434 | await Clock().setMode( 435 | style=int(args.clock), 436 | visibleDate=args.clock_with_date, 437 | hour24=args.clock_24h, 438 | r=int(color[0]), 439 | g=int(color[1]), 440 | b=int(color[2]), 441 | ) 442 | else: 443 | self.logging.error("wrong argument for --clock") 444 | quit() 445 | 446 | async def countdown(self, args: str) -> None: 447 | """sets the countdown mode""" 448 | self.logging.info("setting countdown mode") 449 | mode = int(args.countdown) 450 | if mode not in range(0, 4): 451 | self.logging.error("wrong argument for --countdown") 452 | quit() 453 | times = args.countdown_time.split("-") 454 | if not len(times) == 2: 455 | self.logging.error("wrong argument for --countdown-time") 456 | quit() 457 | minutes, seconds = [int(x) for x in times] 458 | if minutes not in range(0, 100): 459 | self.logging.error( 460 | "wrong argument for --countdown-time - minutes must be between 0 and 99" 461 | ) 462 | quit() 463 | if seconds not in range(0, 60): 464 | self.logging.error( 465 | "wrong argument for --countdown-time - seconds must be between 0 and 59" 466 | ) 467 | quit() 468 | if minutes == 0 and seconds == 0: 469 | self.logging.error( 470 | "wrong argument for --countdown-time - time cannot be zero" 471 | ) 472 | quit() 473 | await Countdown().setMode( 474 | mode=mode, 475 | minutes=minutes, 476 | seconds=seconds, 477 | ) 478 | 479 | async def fullscreenColor(self, argument): 480 | """sets a given fullscreen color""" 481 | self.logging.info("setting fullscreen color") 482 | color = argument.split("-") 483 | if len(color) != 3: 484 | self.logging.error("wrong argument for --fullscreen-color") 485 | quit() 486 | await FullscreenColor().setMode( 487 | int(color[0]), 488 | int(color[1]), 489 | color[2], 490 | ) 491 | 492 | async def pixelColor(self, argument): 493 | """sets the given pixel colors""" 494 | self.logging.info("setting pixel color") 495 | if len(argument) <= 0: 496 | self.logging.error("wrong argument for --pixel-color") 497 | quit() 498 | pixels = [] 499 | # get all pixels to set 500 | for params in argument: 501 | for pixel in params: 502 | pixels.append(pixel) 503 | # validate all pixels and send them 504 | for pixel in pixels: 505 | split = pixel.split("-") 506 | # check if we got all data 507 | if len(split) != 5: 508 | self.logging.error( 509 | "need exactly 5 arguments for a single pixel in --pixel-color" 510 | ) 511 | quit() 512 | # TODO: proper check if we are within the pixel range of the device 513 | # TODO: maybe we can use a delimiter to make use of the MTU size (sending chunks instead of separate requests) 514 | # TODO: when filling 32x32 pixels it seems to have trouble to send all pixels. One pixel will be "forgotten" somehow 515 | await Graffiti().setPixel( 516 | x=int(split[0]), 517 | y=int(split[1]), 518 | r=int(split[2]), 519 | g=int(split[3]), 520 | b=int(split[4]), 521 | ) 522 | 523 | async def scoreboard(self, argument): 524 | """sets given score on the scoreboard and shows it""" 525 | self.logging.info("setting scoreboard mode") 526 | scores = argument.split("-") 527 | if len(scores) != 2: 528 | self.logging.error("wrong argument for --scoreboard") 529 | quit() 530 | if int(scores[0]) < 0 or int(scores[1]) < 0: 531 | self.logging.error("no negative values allowed for --scoreboard") 532 | quit() 533 | if int(scores[0]) > 999 or int(scores[1]) > 999: 534 | self.logging.error("exceeded maximum value of 999 for --scoreboard") 535 | quit() 536 | await Scoreboard().setMode( 537 | count1=int(scores[0]), 538 | count2=int(scores[1]), 539 | ) 540 | 541 | async def image(self, args): 542 | """enables or disables the image mode and uploads a given image file""" 543 | self.logging.info("setting image") 544 | image = Image() 545 | if args.image == "false": 546 | await image.setMode( 547 | mode=0, 548 | ) 549 | else: 550 | await image.setMode( 551 | mode=1, 552 | ) 553 | if args.set_image: 554 | if args.process_image: 555 | await image.uploadProcessed( 556 | file_path=args.set_image, 557 | pixel_size=int(args.process_image), 558 | ) 559 | else: 560 | await image.uploadUnprocessed( 561 | file_path=args.set_image, 562 | ) 563 | 564 | async def gif(self, args): 565 | """enables or disables the gif mode and uploads a given gif file""" 566 | self.logging.info("setting (animated) GIF") 567 | gif = Gif() 568 | if args.process_gif: 569 | await gif.uploadProcessed( 570 | file_path=args.set_gif, 571 | pixel_size=int(args.process_gif), 572 | ) 573 | else: 574 | await gif.uploadUnprocessed( 575 | file_path=args.set_gif, 576 | ) 577 | 578 | async def text(self, args): 579 | """sets the given text on the device""" 580 | self.logging.info("setting text") 581 | text = Text() 582 | text_color = args.text_color.split("-") 583 | if len(text_color) != 3: 584 | self.logging.error("wrong argument for --text-color") 585 | quit() 586 | bg_color = args.text_bg_color.split("-") 587 | if len(bg_color) != 3: 588 | self.logging.error("wrong argument for --text-bg-color") 589 | quit() 590 | await text.setMode( 591 | text=args.set_text, 592 | font_size=args.text_size, 593 | font_path=args.text_font_path, 594 | text_mode=args.text_mode, 595 | speed=args.text_speed, 596 | text_color_mode=args.text_color_mode, 597 | text_color=(int(text_color[0]), int(text_color[1]), int(text_color[2])), 598 | text_bg_mode=args.text_bg_mode, 599 | text_bg_color=(int(bg_color[0]), int(bg_color[1]), int(bg_color[2])), 600 | ) 601 | 602 | async def reset(self, args): 603 | # The following was figured out by 8none1: 604 | # https://github.com/8none1/idotmatrix/commit/1a08e1e9b82d78427ab1c896c24c2a7fb45bc2f0 605 | reset_packets = [ 606 | bytes(bytearray.fromhex("04 00 03 80")), 607 | bytes(bytearray.fromhex("05 00 04 80 50")), 608 | ] 609 | for packet in reset_packets: 610 | await self.conn.send(packet) 611 | 612 | async def weather_image_query(self, args): 613 | api_key = args.weather_api_key 614 | pixels = args.process_image 615 | if pixels==None: 616 | self.logging.error("The pixel-size wasn't given. " 617 | "The arg '--process-image' must be used to provide this, e.g. '--process-image 32'.") 618 | return 619 | 620 | try: 621 | img_path = utils.get_weather_img(args.weather_image_query, api_key, int(pixels)) 622 | except Exception as e: 623 | self.logging.error(f"failed to get weather info or make weather image: {e}") 624 | return 625 | 626 | setattr(args, 'image', 'on') 627 | setattr(args, 'set_image', img_path) 628 | await self.image(args) 629 | 630 | 631 | async def weather_gif_query(self, args): 632 | api_key = args.weather_api_key 633 | pixels = args.process_gif 634 | if pixels==None: 635 | self.logging.error("The pixel-size wasn't given. " 636 | "The arg '--process-gif' must be used to provide this, e.g. '--process-gif 32'.") 637 | return 638 | 639 | try: 640 | gif_path = utils.get_weather_gif(args.weather_gif_query, api_key, int(pixels)) 641 | except Exception as e: 642 | self.logging.error(f"failed to get weather info or make weather gif: {e}") 643 | return 644 | 645 | setattr(args, 'set_gif', gif_path) 646 | await self.gif(args) 647 | -------------------------------------------------------------------------------- /create_venv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # get the directory of the file 4 | IDO_DIR="$(dirname "$0")" 5 | 6 | . "$IDO_DIR"/find_cmds.sh 7 | 8 | # create venv 9 | $PYTHON_CMD -m venv "$IDO_DIR/venv" 10 | 11 | # enable venv 12 | # Check if the OS is Windows and choose the correct activation script 13 | if [[ "$OSTYPE" == "msys" ]]; then 14 | # Windows Git Bash 15 | source "$IDO_DIR/venv/Scripts/activate" 16 | else 17 | # POSIX (Linux, macOS, etc.) 18 | source "$IDO_DIR/venv/bin/activate" 19 | fi 20 | 21 | # install dependencies from pyproject.toml 22 | $PYTHON_CMD -m pip install "$IDO_DIR/" 23 | -------------------------------------------------------------------------------- /find_cmds.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export PYTHON_CMD 3 | 4 | if [ -z "$PYTHON_CMD" ]; then 5 | 6 | if command -v python3 &>/dev/null; then 7 | PYTHON_CMD=python3 8 | else 9 | if command -v python &>/dev/null; then 10 | PYTHON_CMD=python 11 | else 12 | echo "Python not found" >&2 13 | exit 1 14 | fi 15 | fi 16 | fi 17 | -------------------------------------------------------------------------------- /fonts/Rain-DRM3-License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Kosal Sen, Philatype (), 2 | with Reserved Font Name Sen. 3 | 4 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 5 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 6 | 7 | ----------------------------------------------------------- 8 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 9 | ----------------------------------------------------------- 10 | 11 | PREAMBLE 12 | The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. 13 | 14 | The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. 15 | 16 | DEFINITIONS 17 | "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. 18 | 19 | "Reserved Font Name" refers to any names specified as such after the copyright statement(s). 20 | 21 | "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). 22 | 23 | "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. 24 | 25 | "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. 26 | 27 | PERMISSION & CONDITIONS 28 | Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 29 | 30 | 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 31 | 32 | 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 33 | 34 | 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 35 | 36 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 37 | 38 | 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. 39 | 40 | TERMINATION 41 | This license becomes null and void if any of the above conditions are not met. 42 | 43 | DISCLAIMER 44 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. -------------------------------------------------------------------------------- /fonts/Rain-DRM3.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/fonts/Rain-DRM3.otf -------------------------------------------------------------------------------- /gui.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from datetime import datetime 3 | from PIL import Image, ImageDraw, ImageSequence 4 | import numpy 5 | 6 | 7 | 8 | from utils.utils import digits, patterns, colors 9 | from PyQt5.QtWidgets import ( 10 | QApplication, QWidget, QVBoxLayout, QPushButton, QLabel, QStackedWidget, 11 | QPlainTextEdit, QHBoxLayout, QMessageBox, QListWidgetItem, QGridLayout, 12 | QDialog, QLineEdit, QListWidget, QInputDialog, QCheckBox, QDialogButtonBox, 13 | QComboBox, QColorDialog, QSlider, QMenu, QFileDialog 14 | ) 15 | from PyQt5.QtGui import QFont, QIcon, QColor 16 | from PyQt5.QtCore import Qt, QProcess, QSettings, pyqtSignal 17 | import sys, os, re, copy 18 | 19 | 20 | # --- Module-Scope Variables --- 21 | proj_dir = os.path.dirname(os.path.abspath(__file__)) 22 | if sys.platform == 'win32': 23 | shell_cmd = 'powershell.exe' 24 | shell_init_args = ['-File', f"{proj_dir}\\run_in_venv.ps1"] 25 | else: 26 | shell_cmd = 'sh' 27 | shell_init_args = [f"{proj_dir}/run_in_venv.sh"] 28 | 29 | 30 | 31 | 32 | # --- Dialog Classes --- 33 | class ClockStyleDialog(QDialog): 34 | def __init__(self, parent=None): 35 | super().__init__(parent) 36 | self.setWindowTitle('Clock Style') 37 | self.layout = QVBoxLayout(self) 38 | 39 | # Available clock styles 40 | self.clock_styles = ['Default', 'Christmas', 'Racing', 'Inverted Full Screen', 'Animated Hourglass', 'Frame 1', 'Frame 2', 'Frame 3'] 41 | self.selected_color = None # Variable to hold the selected color 42 | 43 | # Clock style selection 44 | self.clock_style_label = QLabel('Select Clock Style:') 45 | self.clock_style_combo = QComboBox(self) 46 | self.clock_style_combo.addItems(self.clock_styles) 47 | 48 | # Checkboxes for additional options 49 | self.show_date_checkbox = QCheckBox('Show Date', self) 50 | self.show_24hr_checkbox = QCheckBox('24-Hour Format', self) 51 | 52 | # Color picker button 53 | self.color_picker_button = QPushButton('Choose Color', self) 54 | self.color_picker_button.clicked.connect(self.open_color_dialog) 55 | 56 | # Dialog button box (OK and Cancel) 57 | self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self) 58 | self.button_box.accepted.connect(self.accept) 59 | self.button_box.rejected.connect(self.reject) 60 | 61 | # Add widgets to the layout 62 | self.layout.addWidget(self.clock_style_label) 63 | self.layout.addWidget(self.clock_style_combo) 64 | self.layout.addWidget(self.show_date_checkbox) 65 | self.layout.addWidget(self.show_24hr_checkbox) 66 | self.layout.addWidget(self.color_picker_button) 67 | self.layout.addWidget(self.button_box) 68 | 69 | def open_color_dialog(self): 70 | color_dialog = QColorDialog(self) 71 | if color_dialog.exec_() == QColorDialog.Accepted: 72 | self.selected_color = color_dialog.selectedColor() 73 | self.color_picker_button.setStyleSheet(f"background-color: {self.selected_color.name()}") 74 | 75 | def get_options(self): 76 | if self.exec_() == QDialog.Accepted: 77 | clock_style = self.clock_style_combo.currentText() 78 | show_date = self.show_date_checkbox.isChecked() 79 | show_24hr = self.show_24hr_checkbox.isChecked() 80 | return clock_style, show_date, show_24hr, self.selected_color, True 81 | else: 82 | return None, None, None, None, False 83 | 84 | 85 | class CustomInputDialog(QDialog): 86 | def __init__(self, parent=None): 87 | super().__init__(parent) 88 | self.setWindowTitle('Input') 89 | self.layout = QVBoxLayout(self) 90 | 91 | self.label = QLabel('Name this device?', self) 92 | self.layout.addWidget(self.label) 93 | 94 | self.line_edit = QLineEdit(self) 95 | self.layout.addWidget(self.line_edit) 96 | 97 | self.button_layout = QHBoxLayout() 98 | self.yes_button = QPushButton('Yes', self) 99 | self.no_button = QPushButton('No', self) 100 | self.button_layout.addWidget(self.yes_button) 101 | self.button_layout.addWidget(self.no_button) 102 | self.layout.addLayout(self.button_layout) 103 | 104 | self.yes_button.clicked.connect(self.accept) 105 | self.no_button.clicked.connect(self.reject) 106 | 107 | def get_input(self): 108 | if self.exec_() == QDialog.Accepted: 109 | return self.line_edit.text(), True 110 | else: 111 | return '', False 112 | 113 | class SizeDialog(QDialog): 114 | def __init__(self, parent=None): 115 | super().__init__(parent) 116 | self.setWindowTitle("Choose Pixel Display Size") 117 | layout = QVBoxLayout() 118 | self.size_combo = QComboBox() 119 | self.size_combo.addItems(["16x16", "32x32"]) 120 | layout.addWidget(self.size_combo) 121 | button_box = QDialogButtonBox(QDialogButtonBox.Ok) 122 | button_box.accepted.connect(self.accept) 123 | layout.addWidget(button_box) 124 | self.setLayout(layout) 125 | 126 | def get(self): 127 | if self.exec_() == QDialog.Accepted: 128 | return self.size_combo.currentText().split("x")[0], True 129 | else: 130 | return "16", False 131 | 132 | 133 | 134 | class TextStyleDialog(QDialog): 135 | def __init__(self, parent=None): 136 | super().__init__(parent) 137 | self.setWindowTitle('Text Settings') 138 | self.layout = QVBoxLayout(self) 139 | 140 | # Initialize selected colors 141 | self.selected_text_color = None 142 | self.selected_bg_color = None 143 | 144 | # Text input 145 | self.text_label = QLabel('Enter Text:') 146 | self.text_input = QLineEdit(self) 147 | self.layout.addWidget(self.text_label) 148 | self.layout.addWidget(self.text_input) 149 | 150 | # Text Size 151 | self.text_size_label = QLabel('Text Size:') 152 | self.text_size_combo = QComboBox(self) 153 | self.text_size_combo.addItems(["16", "32"]) 154 | self.layout.addWidget(self.text_size_label) 155 | self.layout.addWidget(self.text_size_combo) 156 | 157 | # Text Mode 158 | self.text_mode_label = QLabel('Text Style:') 159 | self.text_mode_combo = QComboBox(self) 160 | self.text_mode_combo.addItems(["", "Left", "Right", "Up", "Down", "Blink", "Breathe", "Snowflake", "Laser"]) 161 | self.layout.addWidget(self.text_mode_label) 162 | self.layout.addWidget(self.text_mode_combo) 163 | 164 | # Text Speed 165 | self.text_speed_label = QLabel('Text Speed:') 166 | self.text_speed_slider = QSlider(Qt.Horizontal) 167 | self.text_speed_slider.setRange(0, 100) 168 | self.layout.addWidget(self.text_speed_label) 169 | self.layout.addWidget(self.text_speed_slider) 170 | 171 | # Text Color Mode 172 | self.text_color_mode_label = QLabel('Text Color Effect:') 173 | self.text_color_mode_combo = QComboBox(self) 174 | self.text_color_mode_combo.addItems(["", "Solid", "Rainbow", "Sunset", "Neon", "Calm"]) 175 | self.layout.addWidget(self.text_color_mode_label) 176 | self.layout.addWidget(self.text_color_mode_combo) 177 | 178 | # Text Color 179 | self.text_color_button = QPushButton('Choose Text Color') 180 | self.text_color_button.clicked.connect(self.choose_text_color) 181 | self.layout.addWidget(self.text_color_button) 182 | 183 | # Text Background Mode 184 | self.text_bg_mode_label = QLabel('Background Style:') 185 | self.text_bg_mode_combo = QComboBox(self) 186 | self.text_bg_mode_combo.addItems(["None", "Solid"]) 187 | self.layout.addWidget(self.text_bg_mode_label) 188 | self.layout.addWidget(self.text_bg_mode_combo) 189 | 190 | # Text Background Color 191 | self.text_bg_color_button = QPushButton('Choose Background Color') 192 | self.text_bg_color_button.clicked.connect(self.choose_bg_color) 193 | self.layout.addWidget(self.text_bg_color_button) 194 | 195 | # Dialog buttons 196 | self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self) 197 | self.button_box.accepted.connect(self.accept) 198 | self.button_box.rejected.connect(self.reject) 199 | self.layout.addWidget(self.button_box) 200 | 201 | def choose_text_color(self): 202 | color_dialog = QColorDialog(self) 203 | if color_dialog.exec_() == QColorDialog.Accepted: 204 | self.selected_text_color = color_dialog.selectedColor() 205 | self.text_color_button.setStyleSheet(f"background-color: {self.selected_text_color.name()}") 206 | 207 | def choose_bg_color(self): 208 | color_dialog = QColorDialog(self) 209 | if color_dialog.exec_() == QColorDialog.Accepted: 210 | self.selected_bg_color = color_dialog.selectedColor() 211 | self.text_bg_color_button.setStyleSheet(f"background-color: {self.selected_bg_color.name()}") 212 | 213 | def get_settings(self): 214 | if self.exec_() == QDialog.Accepted: 215 | return ( 216 | self.text_input.text(), 217 | int(self.text_size_combo.currentText()), 218 | self.text_mode_combo.currentIndex(), 219 | self.text_speed_slider.value(), 220 | self.text_color_mode_combo.currentIndex(), 221 | self.selected_text_color, 222 | self.text_bg_mode_combo.currentIndex(), 223 | self.selected_bg_color, 224 | ) 225 | else: 226 | return None 227 | 228 | class ColorControlDialog(QDialog): 229 | accepted = pyqtSignal(str, bool) 230 | 231 | def __init__(self, parent=None, mac_address=None): 232 | super().__init__(parent) 233 | self.setWindowTitle('Color Control') 234 | self.mac_address = mac_address 235 | self.layout = QVBoxLayout(self) 236 | 237 | # Initialize buttons 238 | self.fullscreen_color_button = QPushButton('Fullscreen Color') 239 | self.pixel_paint_button = QPushButton('Pixel Paint') 240 | 241 | # Connect buttons to their respective slots 242 | self.fullscreen_color_button.clicked.connect(lambda: self.choose_color(False)) 243 | self.pixel_paint_button.clicked.connect(self.open_pixel_paint_dialog) 244 | 245 | # Add buttons to layout 246 | self.layout.addWidget(self.fullscreen_color_button) 247 | self.layout.addWidget(self.pixel_paint_button) 248 | 249 | # Dialog button box (OK and Cancel) 250 | self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self) 251 | self.button_box.accepted.connect(self.accept) 252 | self.button_box.rejected.connect(self.reject) 253 | self.layout.addWidget(self.button_box) 254 | 255 | # Initialize variables for selected color and mode 256 | self.selected_color = None 257 | self.is_pixel_paint = False 258 | 259 | def choose_color(self, is_pixel_paint): 260 | color_dialog = QColorDialog(self) 261 | if is_pixel_paint: 262 | color_dialog.setOption(QColorDialog.ShowAlphaChannel) 263 | if color_dialog.exec_() == QDialog.Accepted: 264 | self.selected_color = color_dialog.selectedColor() 265 | self.is_pixel_paint = is_pixel_paint 266 | 267 | def open_pixel_paint_dialog(self): 268 | dialog = PixelPaintDialog(self.mac_address) 269 | dialog.exec_() 270 | 271 | def accept(self): 272 | if self.selected_color and not self.is_pixel_paint: 273 | self.accepted.emit(self.selected_color.name(), self.is_pixel_paint) 274 | super().accept() 275 | 276 | class PixelPaintDialog(QDialog): 277 | 278 | FAVORITES_KEY = "PixelPaintFavorites" 279 | 280 | def __init__(self, mac_address): 281 | super().__init__() 282 | self.mac_address = mac_address 283 | self.init_ui() 284 | self.load_favorites() 285 | self.finished.connect(self.save_favorites) 286 | 287 | def init_ui(self): 288 | self.setWindowTitle('Pixel Paint') 289 | self.setGeometry(100, 100, 800, 800) 290 | 291 | self.current_color = QColor(0, 0, 0) 292 | self.grid_size = 32 293 | self.cell_size = 20 294 | self.grid = [[QColor(255, 255, 255) for _ in range(self.grid_size)] for _ in range(self.grid_size)] 295 | self.undo_stack = [] 296 | self.current_stroke = [] 297 | self.setWindowIcon(QIcon('gui/idmc.ico')) 298 | 299 | layout = QVBoxLayout() 300 | 301 | toolbar_layout = QHBoxLayout() 302 | self.color_buttons = [] 303 | common_colors = [ 304 | ((254, 254, 254), "White"), 305 | ((255, 0, 0), "Red"), 306 | ((0, 255, 0), "Green"), 307 | ((0, 0, 255), "Blue"), 308 | ((255, 255, 0), "Yellow"), 309 | ((0, 255, 255), "Cyan"), 310 | ((255, 0, 255), "Magenta") 311 | ] 312 | 313 | for color, label_text in common_colors: 314 | button = QPushButton(label_text) 315 | button.setProperty('color_data', color) 316 | button.setStyleSheet(f"background-color: rgb{color}; border: 2px solid transparent;") 317 | button.clicked.connect(lambda _, col=color: self.set_current_color(QColor(*col))) 318 | toolbar_layout.addWidget(button) 319 | self.color_buttons.append(button) 320 | 321 | erase_button = QPushButton("Erase") 322 | erase_button.setProperty('color_data', (255, 255, 255)) 323 | erase_button.setStyleSheet("background-color: white; border: 2px solid transparent;") 324 | erase_button.clicked.connect(self.erase_cell) 325 | toolbar_layout.addWidget(erase_button) 326 | self.color_buttons.append(erase_button) 327 | 328 | color_picker_button = QPushButton('Pick Color') 329 | color_picker_button.clicked.connect(self.pick_color) 330 | toolbar_layout.addWidget(color_picker_button) 331 | 332 | layout.addLayout(toolbar_layout) 333 | 334 | self.favorites_list = QListWidget() 335 | self.favorites_list.setMaximumWidth(200) 336 | self.favorites_list.setContextMenuPolicy(Qt.CustomContextMenu) 337 | self.favorites_list.customContextMenuRequested.connect(self.show_favorites_context_menu) 338 | 339 | button_layout = QHBoxLayout() 340 | save_button = QPushButton('Save') 341 | save_button.clicked.connect(self.save_grid) 342 | button_layout.addWidget(save_button) 343 | 344 | load_button = QPushButton('Load') 345 | load_button.clicked.connect(self.load_grid) 346 | button_layout.addWidget(load_button) 347 | 348 | clear_button = QPushButton('Clear') 349 | clear_button.clicked.connect(self.clear_grid) 350 | button_layout.addWidget(clear_button) 351 | 352 | undo_button = QPushButton('Undo') 353 | undo_button.clicked.connect(self.undo) 354 | button_layout.addWidget(undo_button) 355 | 356 | layout.addLayout(button_layout) 357 | 358 | self.grid_widget = QGridLayout() 359 | self.grid_widget.setSpacing(0) 360 | self.grid_labels = [] 361 | for row in range(self.grid_size): 362 | row_labels = [] 363 | for col in range(self.grid_size): 364 | label = QLabel() 365 | label.setFixedSize(self.cell_size, self.cell_size) 366 | label.setStyleSheet("border: 1px solid black; background-color: white;") 367 | label.mousePressEvent = lambda event, r=row, c=col: self.paint_cell(r, c) 368 | label.mouseMoveEvent = self.mouse_move_event 369 | self.grid_widget.addWidget(label, row, col) 370 | row_labels.append(label) 371 | self.grid_labels.append(row_labels) 372 | 373 | grid_container = QVBoxLayout() 374 | grid_container.addLayout(self.grid_widget) 375 | 376 | layout_with_favorites = QHBoxLayout() 377 | layout_with_favorites.addWidget(self.favorites_list) 378 | layout_with_favorites.addLayout(grid_container) 379 | layout.addLayout(layout_with_favorites) 380 | 381 | send_clear_layout = QHBoxLayout() 382 | send_button = QPushButton('Send to Device') 383 | send_button.clicked.connect(self.send_grid) 384 | send_clear_layout.addWidget(send_button) 385 | 386 | clear_device_button = QPushButton('Clear Device') 387 | clear_device_button.clicked.connect(self.clear_device) 388 | send_clear_layout.addWidget(clear_device_button) 389 | 390 | layout.addLayout(send_clear_layout) 391 | 392 | # Close button 393 | close_button = QPushButton('Close') 394 | close_button.clicked.connect(self.close) 395 | layout.addWidget(close_button) 396 | 397 | self.setLayout(layout) 398 | 399 | def set_current_color(self, color): 400 | self.current_color = color 401 | for button in self.color_buttons: 402 | if button.property('color_data') == (color.red(), color.green(), color.blue()): 403 | button.setStyleSheet(f"background-color: rgb{color.red(), color.green(), color.blue()}; border: 2px solid gray;") 404 | else: 405 | button.setStyleSheet(f"background-color: rgb{button.property('color_data')}; border: 2px solid transparent;") 406 | 407 | def pick_color(self): 408 | color = QColorDialog.getColor() 409 | if color.isValid(): 410 | self.set_current_color(color) 411 | 412 | def erase_cell(self): 413 | self.set_current_color(QColor(255, 255, 255)) 414 | 415 | def paint_cell(self, row, col): 416 | if not self.current_stroke: 417 | self.undo_stack.append([]) 418 | self.current_stroke.append((row, col)) 419 | self.grid[row][col] = self.current_color 420 | self.update_cell_style(row, col) 421 | 422 | def mouse_move_event(self, event): 423 | if event.buttons() & Qt.LeftButton: 424 | pos_in_dialog = self.mapFromGlobal(event.globalPos()) 425 | for row in range(self.grid_size): 426 | for col in range(self.grid_size): 427 | if self.grid_labels[row][col].geometry().contains(pos_in_dialog): 428 | self.paint_cell(row, col) 429 | return 430 | 431 | def mousePressEvent(self, event): 432 | if event.button() == Qt.LeftButton: 433 | pos_in_dialog = self.mapFromGlobal(event.globalPos()) 434 | for row in range(self.grid_size): 435 | for col in range(self.grid_size): 436 | if self.grid_labels[row][col].geometry().contains(pos_in_dialog): 437 | self.paint_cell(row, col) 438 | return 439 | 440 | def mouseReleaseEvent(self, event): 441 | if self.current_stroke: 442 | self.undo_stack[-1].extend(self.current_stroke) 443 | self.current_stroke = [] 444 | 445 | def save_grid(self): 446 | name, ok = QInputDialog.getText(self, 'Save Grid', 'Enter a name for this favorite:') 447 | if ok and name: 448 | self.favorites_list.addItem(name) 449 | settings = QSettings("MyCompany", self.FAVORITES_KEY) 450 | settings.setValue(name, self.grid) 451 | self.save_favorites() 452 | 453 | def load_grid(self): 454 | current_item = self.favorites_list.currentItem() 455 | if current_item: 456 | name = current_item.text() 457 | settings = QSettings("MyCompany", self.FAVORITES_KEY) 458 | loaded_grid = settings.value(name) 459 | if loaded_grid: 460 | self.grid = loaded_grid 461 | for row in range(self.grid_size): 462 | for col in range(self.grid_size): 463 | self.update_cell_style(row, col) 464 | else: 465 | QMessageBox.warning(self, 'Load Grid', f'Grid "{name}" not found.') 466 | 467 | def clear_grid(self): 468 | self.undo_stack.append(copy.deepcopy(self.grid)) 469 | for row in range(self.grid_size): 470 | for col in range(self.grid_size): 471 | self.grid[row][col] = QColor(255, 255, 255) 472 | self.update_cell_style(row, col) 473 | self.undo_stack[-1].append(None) 474 | 475 | def undo(self): 476 | if self.undo_stack: 477 | stroke_to_undo = self.undo_stack.pop() 478 | if stroke_to_undo and stroke_to_undo[-1] is None: 479 | stroke_to_undo.pop() 480 | self.grid = copy.deepcopy(stroke_to_undo) 481 | for row in range(self.grid_size): 482 | for col in range(self.grid_size): 483 | self.update_cell_style(row, col) 484 | else: 485 | for row, col in stroke_to_undo: 486 | self.grid[row][col] = QColor(255, 255, 255) 487 | self.update_cell_style(row, col) 488 | 489 | def send_grid(self): 490 | commands = [] 491 | for row in range(self.grid_size): 492 | for col in range(self.grid_size): 493 | color = self.grid[row][col] 494 | if color != QColor(255, 255, 255): 495 | command = f"{col}-{row}-{color.red()}-{color.green()}-{color.blue()}" 496 | commands.append(command) 497 | if commands: 498 | self.send_command_to_device(commands) 499 | else: 500 | QMessageBox.warning(self, 'Send Grid', 'No pixels to send.') 501 | 502 | def send_command_to_device(self, commands): 503 | command_array = ["--address", self.mac_address] 504 | for command in commands: 505 | command_array.extend(["--pixel-color", command]) 506 | self.run_command(command_array) 507 | 508 | def send_clear_command_to_device(self, commands): 509 | command_array = ["--address", self.mac_address] 510 | self.run_command(command_array) 511 | 512 | def run_command(self, command_array:list): 513 | process = QProcess(self) 514 | process.start(shell_cmd, [*shell_init_args, *command_array]) 515 | process.waitForFinished() 516 | 517 | def clear_device(self): 518 | rgb_str = "0-0-0" 519 | self.send_clear_command_to_device(["--fullscreen-color", rgb_str.replace('#', '')]) 520 | 521 | def update_cell_style(self, row, col): 522 | color = self.grid[row][col] 523 | border_style = "border: 1px solid black;" if color == QColor(255, 255, 255) else "" 524 | self.grid_labels[row][col].setStyleSheet(f"background-color: {color.name()}; {border_style}") 525 | 526 | def load_favorites(self): 527 | settings = QSettings("MyCompany", self.FAVORITES_KEY) 528 | favorite_names = settings.value("favoriteNames", []) 529 | for name in favorite_names: 530 | self.favorites_list.addItem(name) 531 | 532 | def save_favorites(self): 533 | settings = QSettings("MyCompany", self.FAVORITES_KEY) 534 | favorite_names = [self.favorites_list.item(i).text() for i in range(self.favorites_list.count())] 535 | settings.setValue("favoriteNames", favorite_names) 536 | 537 | def show_favorites_context_menu(self, pos): 538 | item = self.favorites_list.itemAt(pos) 539 | if item: 540 | menu = QMenu(self) 541 | load_action = menu.addAction("Load") 542 | delete_action = menu.addAction("Delete") 543 | action = menu.exec_(self.favorites_list.mapToGlobal(pos)) 544 | if action == load_action: 545 | self.load_grid() 546 | elif action == delete_action: 547 | self.delete_favorite(item) 548 | 549 | def delete_favorite(self, item): 550 | name = item.text() 551 | settings = QSettings("MyCompany", self.FAVORITES_KEY) 552 | settings.remove(name) 553 | self.favorites_list.takeItem(self.favorites_list.row(item)) 554 | self.save_favorites() 555 | 556 | class ScoreboardDialog(QDialog): 557 | def __init__(self, device_page): 558 | super().__init__() 559 | self.device_page = device_page 560 | self.left_score = 0 561 | self.right_score = 0 562 | self.init_ui() 563 | 564 | def init_ui(self): 565 | self.setWindowTitle("Scoreboard") 566 | self.setWindowIcon(QIcon('gui/idmc.ico')) # Set title bar icon 567 | self.setFixedSize(300, 200) 568 | layout = QGridLayout() 569 | 570 | # Score Labels (Centered) 571 | self.left_score_label = QLabel(str(self.left_score)) 572 | self.left_score_label.setAlignment(Qt.AlignCenter) # Center the label horizontally 573 | self.left_score_label.setFont(QFont("Arial", 36, QFont.Bold)) 574 | layout.addWidget(self.left_score_label, 1, 0) 575 | 576 | self.right_score_label = QLabel(str(self.right_score)) 577 | self.right_score_label.setAlignment(Qt.AlignCenter) # Center the label horizontally 578 | self.right_score_label.setFont(QFont("Arial", 36, QFont.Bold)) 579 | layout.addWidget(self.right_score_label, 1, 1) # Changed column to 1 for centering 580 | 581 | # Increment Buttons (Above) 582 | left_inc_button = QPushButton("+1") 583 | left_inc_button.clicked.connect(lambda: self.adjust_score(True, True)) # True for left, True for increment 584 | layout.addWidget(left_inc_button, 0, 0) # Row 0 for above 585 | 586 | right_inc_button = QPushButton("+1") 587 | right_inc_button.clicked.connect(lambda: self.adjust_score(False, True)) # False for right, True for increment 588 | layout.addWidget(right_inc_button, 0, 1) # Row 0 for above 589 | 590 | # Decrement Buttons (Below) 591 | left_dec_button = QPushButton("-1") 592 | left_dec_button.clicked.connect(lambda: self.adjust_score(True, False)) # True for left, False for decrement 593 | layout.addWidget(left_dec_button, 2, 0) # Row 2 for below 594 | 595 | right_dec_button = QPushButton("-1") 596 | right_dec_button.clicked.connect(lambda: self.adjust_score(False, False)) # False for right, False for decrement 597 | layout.addWidget(right_dec_button, 2, 1) # Row 2 for below 598 | 599 | self.setLayout(layout) 600 | 601 | def adjust_score(self, is_left, is_inc): 602 | if is_left: 603 | if is_inc or self.left_score > 0: # Increment only if score is above 0 or we are incrementing 604 | self.left_score += 1 if is_inc else -1 605 | self.left_score_label.setText(str(self.left_score)) 606 | else: 607 | if is_inc or self.right_score > 0: # Increment only if score is above 0 or we are incrementing 608 | self.right_score += 1 if is_inc else -1 609 | self.right_score_label.setText(str(self.right_score)) 610 | 611 | self.send_score() 612 | 613 | def send_score(self): 614 | score_str = f"{self.left_score}-{self.right_score}" 615 | self.device_page.run_command(["--address", self.device_page.mac_address, "--scoreboard", score_str]) 616 | 617 | # --- Main App Classes --- 618 | class DevicePage(QWidget): 619 | 620 | # --- UI Setup --- 621 | def __init__(self, main_window, friendly_name, device_name, mac_address): 622 | super().__init__() 623 | self.main_window = main_window 624 | self.friendly_name = friendly_name 625 | self.device_name = device_name 626 | self.mac_address = mac_address 627 | self.first_output_received = False 628 | self.last_command = None 629 | self.clock_styles = ['Default', 'Christmas', 'Racing', 'Inverted Full Screen', 630 | 'Animated Hourglass', 'Frame 1', 'Frame 2', 'Frame 3'] 631 | self.weatherapi_api_key = None 632 | self.init_ui() 633 | self.flip_screen_state = False 634 | 635 | def init_ui(self): 636 | layout = QVBoxLayout() 637 | layout.setContentsMargins(0, 0, 0, 0) 638 | 639 | header_layout = QHBoxLayout() 640 | header_layout.setContentsMargins(0, 0, 0, 0) 641 | header_layout.setSpacing(0) 642 | 643 | delete_button = QPushButton("Delete", self) 644 | delete_button.clicked.connect(self.delete_device) 645 | header_layout.addWidget(delete_button, 0) 646 | 647 | label = QLabel(f" {self.friendly_name} MAC: {self.mac_address}", self) 648 | label.setContentsMargins(0, 0, 0, 0) 649 | header_layout.addWidget(label, 1) 650 | 651 | back_button = QPushButton("Back", self) 652 | back_button.clicked.connect(self.go_back_to_homepage) 653 | header_layout.addWidget(back_button, 0) 654 | layout.addLayout(header_layout) 655 | 656 | # Grid layout for buttons 657 | grid_layout = QGridLayout() 658 | self.action_buttons = [] 659 | actions = [ 660 | ("Reset", self.reset), 661 | ("Clock Style", self.clock_control), 662 | ("Sync Time", self.sync_time), 663 | ("Set Time", self.set_time), 664 | ("Set Text", self.set_text), 665 | ("Screen On", lambda: self.screen_control("on")), 666 | ("Screen Off", lambda: self.screen_control("off")), 667 | ("Stop Watch", self.chronograph_control), 668 | ("Countdown Timer", lambda: self.countdown_control(1)), 669 | ("Color Studio", self.color_control), 670 | ("Scoreboard", self.open_scoreboard), 671 | ("Set Image", self.set_image), 672 | ("Set GIF", self.set_gif), 673 | ("Set Raw Image", self.set_image_unprocessed), 674 | ("Set Raw GIF", self.set_gif_unprocessed), 675 | ("Set Weather API-Key", self.set_weather_api_key), 676 | ("Set Weather", self.set_weather), 677 | ("Set Weather GIF", self.set_weather_gif), 678 | 679 | 680 | ] 681 | 682 | for index, (text, func) in enumerate(actions): 683 | button = QPushButton(text, self) 684 | button.clicked.connect(func) 685 | grid_layout.addWidget(button, index // 5, index % 5) 686 | self.action_buttons.append(button) 687 | 688 | layout.addLayout(grid_layout) 689 | 690 | console_widget = QWidget() 691 | console_layout = QVBoxLayout(console_widget) 692 | console_label = QLabel("Console:") 693 | console_label.setFont(QFont("Arial", 12, QFont.Bold)) 694 | console_layout.addWidget(console_label) 695 | self.console_output = QPlainTextEdit(self) 696 | self.console_output.setReadOnly(True) 697 | console_layout.addWidget(self.console_output) 698 | layout.addWidget(console_widget) 699 | 700 | self.setLayout(layout) 701 | 702 | # --- Helpers --- 703 | def go_back_to_homepage(self): 704 | self.main_window.stacked_widget.setCurrentWidget(self.main_window.homepage) 705 | 706 | def run_command(self, args): 707 | self.console_output.clear() 708 | self.process = QProcess(self) 709 | self.process.setProcessChannelMode(QProcess.MergedChannels) 710 | self.process.readyRead.connect(self.handle_ready_read) 711 | self.process.finished.connect(self.process_finished) 712 | self.process.start(shell_cmd, [*shell_init_args, *args]) 713 | 714 | def handle_ready_read(self): 715 | data = self.process.readAll() 716 | try: 717 | stdout = bytes(data).decode("utf8").strip() 718 | except Exception: 719 | stdout = bytes(data).decode("latin1").strip() 720 | 721 | current_command = self.process.arguments()[2:] 722 | output_lines = stdout.splitlines() 723 | 724 | if output_lines: 725 | first_line = output_lines[0] 726 | rest_of_output = '\n'.join(output_lines[1:]) 727 | 728 | if self.last_command != current_command: 729 | self.console_output.appendPlainText(f"Command: {' '.join(current_command)}\n") 730 | self.last_command = current_command 731 | 732 | self.console_output.appendPlainText(f"Output: {first_line}\n") 733 | 734 | if rest_of_output: 735 | self.console_output.appendPlainText(rest_of_output + '\n') 736 | else: 737 | self.console_output.appendPlainText(f"Command: {' '.join(current_command)}\nOutput:\n") 738 | 739 | self.last_command = current_command 740 | 741 | def process_finished(self): 742 | pass 743 | 744 | def hex_to_rgb(self, hex_color): 745 | hex_color = hex_color.lstrip('#') 746 | if len(hex_color) == 6: 747 | return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4)) 748 | elif len(hex_color) == 3: 749 | return tuple(int(hex_color[i]*2, 16) for i in range(3)) 750 | else: 751 | raise ValueError("Invalid hex color format") 752 | 753 | def handle_color_control_accepted(self, color_name): 754 | rgb_str = color_name.replace('#', '') 755 | self.run_command(["--address", self.mac_address, "--fullscreen-color", rgb_str]) 756 | 757 | 758 | # --- Device Button Actions --- 759 | def delete_device(self): 760 | confirmation = QMessageBox.question(self, "Delete Device", f"Are you sure you want to delete {self.friendly_name}?", 761 | QMessageBox.Yes | QMessageBox.No, QMessageBox.No) 762 | if confirmation == QMessageBox.Yes: 763 | for i in range(self.main_window.configuration_page.device_list.count()): 764 | item = self.main_window.configuration_page.device_list.item(i) 765 | if item.toolTip() == self.mac_address: 766 | self.main_window.configuration_page.device_list.takeItem(i) 767 | break 768 | 769 | button_to_remove = self.main_window.device_buttons.pop(self.mac_address, None) 770 | if button_to_remove: 771 | self.main_window.homepage_layout.removeWidget(button_to_remove) 772 | button_to_remove.deleteLater() 773 | 774 | del self.main_window.device_pages[self.mac_address] 775 | self.main_window.save_device_settings() 776 | self.main_window.stacked_widget.setCurrentWidget(self.main_window.homepage) 777 | 778 | def clock_control(self): 779 | dialog = ClockStyleDialog(self) 780 | clock_style, show_date, show_24hr, color, ok_pressed = dialog.get_options() 781 | 782 | if ok_pressed: 783 | args = ["--address", self.mac_address, "--clock", str(self.clock_styles.index(clock_style)), "--sync-time"] 784 | if show_date: 785 | args.append("--clock-with-date") 786 | if show_24hr: 787 | args.append("--clock-24h") 788 | if color: 789 | rgb_str = f"{color.red()}-{color.green()}-{color.blue()}" 790 | args.append(f"--clock-color={rgb_str}") 791 | self.run_command(args) 792 | 793 | def sync_time(self): 794 | self.run_command(["--address", self.mac_address, "--sync-time"]) 795 | 796 | def set_time(self): 797 | time, ok_pressed = QInputDialog.getText(self, "Set Time", "Enter the time (DD-MM-YYYY-HH:MM:SS):") 798 | if ok_pressed: 799 | self.run_command(["--address", self.mac_address, "--set-time", time]) 800 | 801 | 802 | def screen_control(self, state): 803 | self.run_command(["--address", self.mac_address, "--screen", state]) 804 | 805 | def chronograph_control(self): 806 | options = ['Reset', '(Re)Start', 'Pause', 'Continue after Pause'] 807 | default_index = 1 808 | option, ok_pressed = QInputDialog.getItem(self, "Stop Watch", "Select an option:", options, default_index, False) 809 | if ok_pressed: 810 | self.run_command(["--address", self.mac_address, "--chronograph", str(options.index(option))]) 811 | 812 | def countdown_control(self, state): 813 | options = ['Disable', 'Start', 'Pause', 'Restart'] 814 | option, ok_pressed = QInputDialog.getItem(self, "Countdown Control", 815 | "Select an option:", options, 0, False) 816 | if ok_pressed and option == 'Start': 817 | time, ok_pressed = QInputDialog.getText(self, "Set Time", "Enter the Countdown time:\n\n(eg: 5min. 30sec. = 5-30)") 818 | else: 819 | time = None 820 | 821 | if ok_pressed: 822 | command_args = ["--address", self.mac_address, "--countdown", str(options.index(option))] 823 | if time is not None: 824 | command_args.extend(["--countdown-time", time]) 825 | 826 | self.run_command(command_args) 827 | else: 828 | print("Countdown canceled, no command will be executed.") 829 | 830 | 831 | def set_text(self): 832 | dialog = TextStyleDialog(self) 833 | settings = dialog.get_settings() 834 | if settings is not None: 835 | text, text_size, text_mode, text_speed, text_color_mode_index, text_color, text_bg_mode_index, text_bg_color = settings 836 | 837 | text_mode = str(text_mode) 838 | text_color_mode = str(text_color_mode_index) 839 | text_bg_mode = str(text_bg_mode_index) 840 | 841 | args = ["--address", self.mac_address, "--set-text", text, "--text-size", str(text_size), "--text-mode", text_mode, "--text-speed", str(text_speed), "--text-color-mode", text_color_mode] 842 | 843 | if text_color: 844 | rgb_text = f"{text_color.red()}-{text_color.green()}-{text_color.blue()}" 845 | args.append(f"--text-color={rgb_text}") 846 | if text_bg_color: 847 | rgb_bg = f"{text_bg_color.red()}-{text_bg_color.green()}-{text_bg_color.blue()}" 848 | args.append(f"--text-bg-color={rgb_bg}") 849 | if text_bg_mode != "None": 850 | args.append(f"--text-bg-mode={text_bg_mode}") 851 | 852 | self.run_command(args) 853 | else: 854 | print("No text settings were provided.") 855 | 856 | def color_control(self): 857 | dialog = ColorControlDialog(self, self.mac_address) 858 | if dialog.exec_() == QDialog.Accepted and dialog.selected_color: 859 | r, g, b = dialog.selected_color.red(), dialog.selected_color.green(), dialog.selected_color.blue() 860 | rgb_str = f"{r}-{g}-{b}" 861 | 862 | self.run_command(["--address", self.mac_address, "--fullscreen-color", rgb_str]) 863 | 864 | def open_scoreboard(self): 865 | dialog = ScoreboardDialog(self) 866 | dialog.exec_() 867 | 868 | def set_image(self): 869 | options = QFileDialog.Options() 870 | options |= QFileDialog.ReadOnly 871 | file_path, _ = QFileDialog.getOpenFileName(self, "Select Image", "", "PNG Files (*.png);;All Files (*)", options=options) 872 | 873 | if file_path: 874 | # Image Size Selection Dialog 875 | size_dialog = QDialog(self) 876 | size_dialog.setWindowTitle("Pick Size") 877 | layout = QVBoxLayout() 878 | size_combo = QComboBox() 879 | size_combo.addItems(["16x16", "32x32"]) 880 | layout.addWidget(size_combo) 881 | button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) 882 | button_box.accepted.connect(size_dialog.accept) 883 | button_box.rejected.connect(size_dialog.reject) 884 | layout.addWidget(button_box) 885 | size_dialog.setLayout(layout) 886 | 887 | if size_dialog.exec_() == QDialog.Accepted: 888 | image_size = size_combo.currentText().split("x")[0] 889 | self.run_command(["--address", self.mac_address, "--image", "true", "--set-image", file_path, "--process-image", image_size]) 890 | 891 | def set_gif(self): 892 | confirmation = QMessageBox.question(self, "GIF Notice", "All GIFs are processed by default to ensure maximum compatibility. \n\nThis doesn't always work for all GIFs. \n\nGIFs closer to 32x32 or 16x16 have better chances of working.", 893 | QMessageBox.Yes | QMessageBox.No, QMessageBox.No) 894 | 895 | if confirmation == QMessageBox.Yes: 896 | options = QFileDialog.Options() 897 | options |= QFileDialog.ReadOnly 898 | file_path, _ = QFileDialog.getOpenFileName(self, "Select GIF", "", "GIF Files (*.gif);;All Files (*)", options=options) 899 | 900 | if file_path: 901 | size_dialog = QDialog(self) 902 | size_dialog.setWindowTitle("Choose GIF Size") 903 | layout = QVBoxLayout() 904 | size_combo = QComboBox() 905 | size_combo.addItems(["16x16", "32x32"]) 906 | layout.addWidget(size_combo) 907 | button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) 908 | button_box.accepted.connect(size_dialog.accept) 909 | button_box.rejected.connect(size_dialog.reject) 910 | layout.addWidget(button_box) 911 | size_dialog.setLayout(layout) 912 | 913 | if size_dialog.exec_() == QDialog.Accepted: 914 | image_size = size_combo.currentText().split("x")[0] 915 | self.run_command(["--address", self.mac_address, "--set-gif", file_path, "--process-gif", image_size]) 916 | 917 | def set_image_unprocessed(self): 918 | options = QFileDialog.Options() 919 | options |= QFileDialog.ReadOnly 920 | file_path, _ = QFileDialog.getOpenFileName(self, "Select Image", "", "PNG Files (*.png);;All Files (*)", options=options) 921 | 922 | if file_path: 923 | self.run_command(["--address", self.mac_address, "--image", "true", "--set-image", file_path]) 924 | 925 | def set_gif_unprocessed(self): 926 | options = QFileDialog.Options() 927 | options |= QFileDialog.ReadOnly 928 | file_path, _ = QFileDialog.getOpenFileName(self, "Select GIF", "", "GIF Files (*.gif);;All Files (*)", options=options) 929 | 930 | if file_path: 931 | self.run_command(["--address", self.mac_address, "--set-gif", file_path]) 932 | 933 | def set_weather_api_key(self): 934 | response, responded = QInputDialog.getText(self, "API Key", "Enter your 'https://weatherapi.com' api key") 935 | if responded: 936 | self.weatherapi_api_key = response 937 | else: 938 | print("No api key was provided, this is needed for the weather functionality.") 939 | 940 | def set_weather(self): 941 | city, ok_pressed = QInputDialog.getText(self, "Set Weather", "Remember to set the API key first. \nEnter the city query, e.g. name:") 942 | size, ignore = SizeDialog().get() 943 | 944 | if ok_pressed and city: 945 | self.run_command([ 946 | "--address", self.mac_address, 947 | "--process-image", str(size), 948 | "--weather-api-key", self.weatherapi_api_key, 949 | "--weather-image-query", city, 950 | ]) 951 | 952 | def set_weather_gif(self): 953 | city, ok_pressed = QInputDialog.getText(self, "Set Weather", "Remember to set the API key first. \nEnter the city query, e.g. name:") 954 | size, ignore = SizeDialog().get() 955 | 956 | if ok_pressed and city: 957 | self.run_command([ 958 | "--address", self.mac_address, 959 | "--process-image", str(size), 960 | "--weather-api-key", self.weatherapi_api_key, 961 | "--weather-gif-query", city, 962 | ]) 963 | 964 | def reset(self): 965 | self.run_command([ 966 | "--address", self.mac_address, 967 | "--reset", 968 | ]) 969 | 970 | 971 | class ConfigurationPage(QWidget): 972 | def __init__(self, main_window): 973 | super().__init__() 974 | self.main_window = main_window 975 | self.device_name = "" 976 | 977 | self.layout = QHBoxLayout() 978 | self.left_layout = QVBoxLayout() 979 | 980 | console_label = QLabel("Console:") 981 | console_label.setFont(QFont("Arial", 12, QFont.Bold)) 982 | self.left_layout.addWidget(console_label) 983 | 984 | self.console_output = QPlainTextEdit(self) 985 | self.console_output.setReadOnly(True) 986 | self.left_layout.addWidget(self.console_output) 987 | 988 | instruction_label = QLabel('Select a device from the list to add:') 989 | instruction_label.setFont(QFont("Arial", 12, QFont.Bold)) 990 | self.left_layout.addWidget(instruction_label) 991 | 992 | self.device_list = QListWidget() 993 | self.device_list.itemClicked.connect(self.device_selected) 994 | self.left_layout.addWidget(self.device_list) 995 | 996 | self.layout.addLayout(self.left_layout) 997 | 998 | self.right_layout = QVBoxLayout() 999 | 1000 | back_button = QPushButton('Back') 1001 | back_button.clicked.connect(self.go_back_to_homepage) 1002 | back_button.setFixedSize(150, 50) 1003 | self.right_layout.addWidget(back_button) 1004 | 1005 | add_selected_device_button = QPushButton('Add Selected Device') 1006 | add_selected_device_button.clicked.connect(self.add_selected_device) 1007 | add_selected_device_button.setFixedSize(150, 50) 1008 | self.right_layout.addWidget(add_selected_device_button) 1009 | 1010 | self.layout.addLayout(self.right_layout) 1011 | self.setLayout(self.layout) 1012 | 1013 | def device_selected(self, item): 1014 | self.selected_device = item.text() 1015 | 1016 | def add_selected_device(self): 1017 | if hasattr(self, 'selected_device'): 1018 | if self.selected_device in self.main_window.device_buttons: 1019 | QMessageBox.warning(self, 'Device Already Added', f'Device "{self.selected_device}" is already added to the homepage.') 1020 | return 1021 | 1022 | dialog = CustomInputDialog(self) 1023 | friendly_name, ok = dialog.get_input() 1024 | if ok and friendly_name: 1025 | mac_address = self.device_list.currentItem().toolTip() 1026 | else: 1027 | mac_address = self.device_list.currentItem().toolTip() 1028 | friendly_name = self.selected_device 1029 | 1030 | self.main_window.add_device_to_homepage(friendly_name, mac_address) 1031 | QMessageBox.information(self, 'Device Added', f'Device "{friendly_name}" has been added.') 1032 | self.main_window.save_device_settings() 1033 | else: 1034 | QMessageBox.warning(self, 'No Device Selected', 'Please select a device from the list.') 1035 | 1036 | def go_back_to_homepage(self): 1037 | self.main_window.stacked_widget.setCurrentWidget(self.main_window.homepage) 1038 | 1039 | def update_device_name(self, new_name): 1040 | self.device_name = new_name 1041 | 1042 | def save_device_name(self): 1043 | self.main_window.save_device_settings() 1044 | 1045 | class MainWindow(QWidget): 1046 | def __init__(self): 1047 | super().__init__() 1048 | self.setWindowTitle('iDotMatrix Controller') 1049 | self.setWindowIcon(QIcon('gui/idmc.ico')) 1050 | 1051 | screen_geometry = QApplication.desktop().availableGeometry() 1052 | self.screen_center = screen_geometry.center() 1053 | 1054 | self.layout = QVBoxLayout() 1055 | self.layout.setAlignment(Qt.AlignTop) 1056 | 1057 | header_font = QFont("Arial", 18, QFont.Bold) 1058 | header_label = QLabel('iDotMatrix Controller') 1059 | header_label.setFont(header_font) 1060 | self.layout.addWidget(header_label) 1061 | 1062 | self.stacked_widget = QStackedWidget() 1063 | self.layout.addWidget(self.stacked_widget) 1064 | 1065 | self.homepage = QWidget() 1066 | self.homepage_layout = QVBoxLayout() 1067 | self.homepage_layout.setAlignment(Qt.AlignCenter) 1068 | 1069 | add_device_button = QPushButton('Add Device') 1070 | add_device_button.setFixedSize(150, 50) 1071 | add_device_button.clicked.connect(self.show_configuration_page) 1072 | self.homepage_layout.addWidget(add_device_button) 1073 | 1074 | self.homepage.setLayout(self.homepage_layout) 1075 | self.stacked_widget.addWidget(self.homepage) 1076 | 1077 | self.configuration_page = ConfigurationPage(self) 1078 | self.stacked_widget.addWidget(self.configuration_page) 1079 | 1080 | self.setLayout(self.layout) 1081 | self.resize(800, 600) 1082 | self.center_window() 1083 | 1084 | self.device_pages = {} 1085 | 1086 | self.device_buttons = {} 1087 | self.load_device_settings() 1088 | 1089 | self.connect_device_buttons() 1090 | 1091 | def center_window(self): 1092 | window_size = self.frameGeometry().size() 1093 | x = self.screen_center.x() - window_size.width() // 2 1094 | y = self.screen_center.y() - window_size.height() // 2 1095 | self.move(x, y) 1096 | 1097 | def show_configuration_page(self): 1098 | self.stacked_widget.setCurrentWidget(self.configuration_page) 1099 | self.scan_for_devices() 1100 | 1101 | def scan_for_devices(self): 1102 | self.configuration_page.console_output.clear() 1103 | self.output_str = "" 1104 | self.process = QProcess(self) 1105 | self.process.setProcessChannelMode(QProcess.MergedChannels) 1106 | self.process.readyRead.connect(self.handle_ready_read) 1107 | self.process.finished.connect(self.process_finished) 1108 | self.process.start(shell_cmd, [*shell_init_args, "--scan"]) 1109 | 1110 | def handle_ready_read(self): 1111 | data = self.process.readAll() 1112 | try: 1113 | stdout = bytes(data).decode("utf8") 1114 | except Exception: 1115 | stdout = bytes(data).decode("latin1") 1116 | 1117 | self.output_str += stdout 1118 | self.configuration_page.console_output.appendPlainText(stdout) 1119 | 1120 | device_name_pattern = re.compile(r"found device ([\dA-F:]+) with name (\S+)") 1121 | matches = device_name_pattern.findall(stdout) 1122 | if matches: 1123 | self.configuration_page.device_list.clear() 1124 | for mac_address, device_name in matches: 1125 | item = QListWidgetItem(device_name) 1126 | self.configuration_page.device_list.addItem(item) 1127 | item.setToolTip(mac_address) 1128 | 1129 | def process_finished(self): 1130 | pass 1131 | 1132 | def add_device_to_homepage(self, friendly_name, mac_address): 1133 | if mac_address not in self.device_buttons: 1134 | device_button = QPushButton(friendly_name) 1135 | device_button.setToolTip(mac_address) 1136 | device_button.setFixedSize(150, 50) 1137 | self.homepage_layout.addWidget(device_button) 1138 | self.device_buttons[mac_address] = device_button 1139 | else: 1140 | QMessageBox.warning(self, 'Device Already Added', f'Device with MAC address "{mac_address}" is already added to the homepage.') 1141 | device_button.clicked.connect(self.show_device_page) 1142 | 1143 | def save_device_settings(self): 1144 | settings = QSettings("MyCompany", "iDotMatrixController") 1145 | devices = [(mac_address, button.text()) for mac_address, button in self.device_buttons.items()] 1146 | settings.setValue("devices", devices) 1147 | settings.setValue("device_name", self.configuration_page.device_name) 1148 | 1149 | def load_device_settings(self): 1150 | settings = QSettings("MyCompany", "iDotMatrixController") 1151 | devices = settings.value("devices", []) 1152 | for device in devices: 1153 | if len(device) == 2: 1154 | mac_address, friendly_name = device 1155 | self.add_device_to_homepage(friendly_name, mac_address) 1156 | self.configuration_page.device_name = settings.value("device_name", "") 1157 | 1158 | def connect_device_buttons(self): 1159 | for mac_address, button in self.device_buttons.items(): 1160 | button.clicked.connect(self.show_device_page) 1161 | 1162 | def show_device_page(self): 1163 | sender = self.sender() 1164 | if sender: 1165 | mac_address = sender.toolTip() 1166 | 1167 | if mac_address in self.device_pages: 1168 | device_page = self.device_pages[mac_address] 1169 | else: 1170 | device_name = None 1171 | for i in range(self.configuration_page.device_list.count()): 1172 | item = self.configuration_page.device_list.item(i) 1173 | if item.toolTip() == mac_address: 1174 | device_name = item.text() 1175 | break 1176 | 1177 | friendly_name = sender.text() 1178 | device_page = DevicePage(self, friendly_name, device_name, mac_address) 1179 | self.device_pages[mac_address] = device_page 1180 | self.stacked_widget.addWidget(device_page) 1181 | 1182 | self.stacked_widget.setCurrentWidget(device_page) 1183 | 1184 | def show_device_page(self): 1185 | sender = self.sender() 1186 | if sender: 1187 | mac_address = sender.toolTip() 1188 | if mac_address in self.device_pages: 1189 | device_page = self.device_pages[mac_address] 1190 | else: 1191 | device_name = None 1192 | for i in range(self.configuration_page.device_list.count()): 1193 | item = self.configuration_page.device_list.item(i) 1194 | if item.toolTip() == mac_address: 1195 | device_name = item.text() 1196 | break 1197 | 1198 | friendly_name = sender.text() 1199 | device_page = DevicePage(self, friendly_name, device_name, mac_address) 1200 | self.device_pages[mac_address] = device_page 1201 | self.stacked_widget.addWidget(device_page) 1202 | 1203 | self.stacked_widget.setCurrentWidget(device_page) 1204 | 1205 | def open_pixel_paint_dialog(self, mac_address): 1206 | dialog = PixelPaintDialog(mac_address) 1207 | dialog.exec_() 1208 | 1209 | # --- Main Execution --- 1210 | if __name__ == "__main__": 1211 | app = QApplication(sys.argv) 1212 | window = MainWindow() 1213 | window.show() 1214 | sys.exit(app.exec_()) 1215 | -------------------------------------------------------------------------------- /idmc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/idmc.ico -------------------------------------------------------------------------------- /images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/images/demo.gif -------------------------------------------------------------------------------- /images/demo_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/images/demo_16.png -------------------------------------------------------------------------------- /images/demo_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/images/demo_32.png -------------------------------------------------------------------------------- /images/demo_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/images/demo_512.png -------------------------------------------------------------------------------- /images/demo_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/images/demo_64.png -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derkalle4/python3-idotmatrix-client/4511bb5390817a9a153feddd061ede1b9bb34c2c/images/logo.png -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | 3 | name = "iDotMatrix-Client" 4 | version = "0.0.1" 5 | description = "configure any iDotMatrix compatible 16x16 or 32x32 pixel display without chinese android apps." 6 | readme = "README.md" 7 | requires-python = ">=3.7" 8 | license = {file = "LICENSE"} 9 | keywords = ["idotmatrix", "bluetooth", "kandru"] 10 | authors = [ 11 | {name = "Kalle Minkner", email = "info@kalleminkner.de" } 12 | ] 13 | maintainers = [ 14 | {name = "Kalle Minkner", email = "info@kalleminkner.de" } 15 | ] 16 | dependencies = [ 17 | "asyncio", 18 | "idotmatrix==0.0.9", 19 | "bleak", 20 | "pillow", 21 | "argparse", 22 | "requests", 23 | "numpy" 24 | ] 25 | 26 | [project.urls] 27 | 28 | "Homepage" = "https://kandru.net" 29 | "Source" = "https://github.com/derkalle4/python3-idotmatrix-client" 30 | 31 | [build-system] 32 | requires = ["setuptools>=43.0.0", "wheel"] 33 | build-backend = "setuptools.build_meta" 34 | 35 | [tool.setuptools] 36 | py-modules = [] 37 | -------------------------------------------------------------------------------- /run_in_venv.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [switch]$DontInvokeApp # Used to pass args directly to python, not app.py, e.g. for installing non-standard pip packages. 3 | ) 4 | 5 | $originalArgs = $args 6 | $originalPath = Get-Location 7 | & { 8 | $root = $PSScriptRoot 9 | Set-Location -Path "$root" 10 | 11 | $likelyCorrectPath = Test-Path -Path "$root\app.py" -PathType Leaf 12 | if (-not $likelyCorrectPath){ 13 | Write-Host "ERROR: The script seems to have been run from the wrong path. Try right-clicking the .ps1 file and clicking 'run with powershell'." 14 | Set-Location -Path $originalPath 15 | pause 16 | exit 17 | } 18 | 19 | 20 | $venvAlreadyExists = Test-Path -Path "$root\venv_windows\Scripts\Activate.ps1" -PathType Leaf 21 | if (-not $venvAlreadyExists) { 22 | Write-Host "Venv for Windows doesn't exist, creating it. " 23 | python -m venv "$root\venv_windows" 24 | if (-not $?){ 25 | Write-Host "`nERROR: Failed to create venv, exiting program. Make sure Python is installed." 26 | Set-Location -Path $originalPath 27 | pause 28 | exit 29 | } 30 | Write-Host "Venv created." 31 | } 32 | 33 | 34 | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force 35 | . "$root\venv_windows\Scripts\Activate.ps1" 36 | if (-not "$?"){ 37 | Write-Host "ERROR: Failed to open venv. Make sure Python is installed, then try this script again." 38 | Set-Location -Path $originalPath 39 | pause 40 | exit 41 | } 42 | 43 | $py_cmd = "python" 44 | if (Test-Path -Path "$root/venv_windows/Scripts/python3.exe" -PathType Leaf ){ 45 | $py_cmd = "$root/venv_windows/Scripts/python3.exe" 46 | } elseif (Test-Path -Path "$root/venv_windows/Scripts/python.exe" -PathType Leaf){ 47 | $py_cmd = "$root/venv_windows/Scripts/python.exe" 48 | } else { 49 | Write-Host "ERROR: Failed to find venv's python executable, try re-making the venv by deleting the 'venv_windows' folder and running build.ps1." 50 | Set-Location -Path $originalPath 51 | pause 52 | exit 53 | } 54 | 55 | if (-not $venvAlreadyExists){ 56 | Write-Host "Installing dependencies into venv." 57 | & $py_cmd -m pip install "$root/" 58 | } 59 | 60 | if ($DontInvokeApp){ 61 | & $py_cmd $originalArgs 62 | } else { 63 | & $py_cmd "$root/app.py" $originalArgs 64 | } 65 | 66 | Set-Location -Path $originalPath 67 | 68 | } 69 | -------------------------------------------------------------------------------- /run_in_venv.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | get_py() { 5 | if command -v python3 &>/dev/null; then 6 | echo "python3" 7 | return 0 8 | fi 9 | if command -v python &>/dev/null; then 10 | echo "python" 11 | return 0 12 | fi 13 | echo "Python not found" >&2 14 | return 1 15 | } 16 | 17 | get_venv_dir() { 18 | local pwd_dir="$1" 19 | if [[ "$OSTYPE" == "msys" ]]; then 20 | # Windows Bash (msys, git bash) 21 | echo "$pwd_dir/venv/Scripts" 22 | return 0 23 | else 24 | # POSIX (Linux, macOS, etc.) 25 | echo "$pwd_dir/venv/bin" 26 | return 0 27 | fi 28 | } 29 | 30 | setup_venv() { 31 | local pwd_dir="$1" 32 | local py_cmd=$(get_py) 33 | # make venv 34 | echo "Creating venv..." 35 | $py_cmd -m venv "$pwd_dir/venv" 36 | local venv_dir=$(get_venv_dir "$pwd_dir") 37 | # open venv 38 | source "$venv_dir/activate" 39 | venv_py_cmd=$(get_venv_py "$venv_dir") 40 | # install dependencies from pyproject.toml 41 | echo "Installing dependencies into venv..." 42 | $venv_py_cmd -m pip install "$pwd_dir/" 43 | return 0 44 | } 45 | 46 | get_venv_py() { 47 | # find and return a direct path to the python binary in the venv. 48 | # this ensures we're not calling the global python binary, 49 | # which can sometimes happen depending on the system. 50 | local venv_dir="$1" 51 | test -f "$venv_dir/python3" && echo "$venv_dir/python3" && return 0 52 | test -f "$venv_dir/python" && echo "$venv_dir/python" && return 0 53 | test -f "$venv_dir/py3" && echo "$venv_dir/py3" && return 0 54 | test -f "$venv_dir/py" && echo "$venv_dir/py" && return 0 55 | echo "Python not found in venv, was it correctly set up?" >&2 56 | return 1 57 | } 58 | 59 | 60 | pwd_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) # POSIX-safe script directory fetching. Details: https://stackoverflow.com/a/29835459 61 | py_cmd=$(get_py) 62 | venv_dir=$(get_venv_dir "$pwd_dir") 63 | 64 | # create venv if it doesn't exist 65 | test -d "$venv_dir" || setup_venv "$pwd_dir" 66 | # open venv 67 | source "$venv_dir/activate" 68 | # make sure we use the python binary belonging to the venv 69 | venv_py_cmd=$(get_venv_py "$venv_dir") 70 | # run app 71 | $venv_py_cmd "$pwd_dir/app.py" "$@" 72 | -------------------------------------------------------------------------------- /utils/utils.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from PIL import Image, ImageDraw 3 | import numpy 4 | 5 | digits = { 6 | "-": [ 7 | " ", 8 | " ", 9 | " ", 10 | "1111", 11 | " ", 12 | " ", 13 | " " 14 | ], 15 | "0": [ 16 | "1111", 17 | "1 1", 18 | "1 1", 19 | "1 1", 20 | "1 1", 21 | "1 1", 22 | "1111" 23 | ], 24 | "1": [ 25 | " 1 ", 26 | " 11 ", 27 | " 1 ", 28 | " 1 ", 29 | " 1 ", 30 | " 1 ", 31 | " 111" 32 | ], 33 | "2": [ 34 | "1111", 35 | "1 1", 36 | " 1", 37 | "1111", 38 | "1 ", 39 | "1 ", 40 | "1111" 41 | ], 42 | "3": [ 43 | "1111", 44 | "1 1", 45 | " 1", 46 | " 111", 47 | " 1", 48 | "1 1", 49 | "1111" 50 | ], 51 | "4": [ 52 | " 1", 53 | " 11", 54 | " 1 1", 55 | "1 1", 56 | "1111", 57 | " 1", 58 | " 1" 59 | ], 60 | "5": [ 61 | "1111", 62 | "1 ", 63 | "1 ", 64 | "111 ", 65 | " 1", 66 | "1 1", 67 | "1111" 68 | ], 69 | "6": [ 70 | "1111", 71 | "1 ", 72 | "1 ", 73 | "1111", 74 | "1 1", 75 | "1 1", 76 | "1111" 77 | ], 78 | "7": [ 79 | "1111", 80 | "1 1", 81 | " 1", 82 | " 1 ", 83 | " 1 ", 84 | " 1 ", 85 | " 1 " 86 | ], 87 | "8": [ 88 | "1111", 89 | "1 1", 90 | "1 1", 91 | "1111", 92 | "1 1", 93 | "1 1", 94 | "1111" 95 | ], 96 | "9": [ 97 | "1111", 98 | "1 1", 99 | "1 1", 100 | "1111", 101 | " 1", 102 | "1 1", 103 | "1111" 104 | ] 105 | } 106 | colors = { 107 | "b": "#000000", # Black 108 | "y1": "#e5ff00", # Light yellow 109 | "y2": "#e6bd09", # Medium yellow 110 | "y3": "#e6a307", # Dark yellow 111 | "w": "#FFFFFF", # White 112 | "g": "#AAAAAA", # Dark gray 113 | "gD":"#4f4f4f", # gray dark 114 | "y": "#FFFF00", # Yellow (thunder) 115 | "c": "#00FFFF", # Light blue (rain) 116 | "bl":"#0088ff", #blue 117 | 118 | } 119 | 120 | 121 | patterns = { 122 | "sun": [ 123 | ["b", "b", "b", "b", "b", "b", "b", "b"], 124 | ["b", "b", "y1", "y1", "y1", "y3", "b", "b"], 125 | ["b", "y1", "y1", "y1", "y1", "y2", "y3", "b"], 126 | ["b", "y1", "y1", "y1", "y1", "y2", "y3", "b"], 127 | ["b", "y1", "y1", "y1", "y2", "y2", "y3", "b"], 128 | ["b", "y3", "y2", "y2", "y2", "y3", "y3", "b"], 129 | ["b", "b", "y3", "y3", "y3", "y3", "b", "b"], 130 | ["b", "b", "b", "b", "b", "b", "b", "b"], 131 | ], 132 | "moon": [ 133 | ["b", "b", "b", "b", "b", "b", "b", "b"], 134 | ["b", "b", "g", "g", "g", "gD", "b", "b"], 135 | ["b", "g", "gD", "gD", "g", "g", "gD", "b"], 136 | ["b", "g", "g", "g", "g", "g", "g", "b"], 137 | ["b", "g", "g", "g", "gD", "gD", "g", "b"], 138 | ["b", "g", "gD", "g", "gD", "gD", "g", "b"], 139 | ["b", "b", "g", "g", "g", "g", "b", "b"], 140 | ["b", "b", "b", "b", "b", "b", "b", "b"], 141 | ], 142 | "cloudy": [ 143 | ["b", "b", "b", "b", "b", "b", "b", "b"], 144 | ["b", "b", "b", "g", "g", "g", "b", "b"], 145 | ["b", "g", "g", "w", "w", "w", "g", "b"], 146 | ["b", "g", "w", "w", "w", "w", "g", "b"], 147 | ["g", "w", "w", "w", "g", "g", "w", "g"], 148 | ["g", "w", "w", "g", "w", "w", "w", "g"], 149 | ["b", "g", "g", "g", "g", "g", "g", "b"], 150 | ["b", "b", "b", "b", "b", "b", "b", "b"], 151 | ], 152 | "partly cloudy": [ 153 | ["b", "b", "b", "b", "y", "y", "b", "b"], 154 | ["b", "b", "b", "y", "y", "y", "y", "b"], 155 | ["b", "g", "g", "y", "y", "y", "y", "y"], 156 | ["g", "w", "w", "g", "g", "y", "y", "y"], 157 | ["g", "w", "w", "w", "w", "g", "g", "b"], 158 | ["g", "w", "w", "w", "w", "w", "g", "b"], 159 | ["g", "g", "g", "g", "g", "g", "g", "b"], 160 | ["b", "b", "b", "b", "b", "b", "b", "b"], 161 | ], 162 | "partly cloudy night": [ 163 | ["b", "b", "b", "b", "gD", "gD", "b", "b"], 164 | ["b", "b", "b", "gD", "gD", "gD", "gD", "b"], 165 | ["b", "g", "g", "gD", "gD", "gD", "gD", "gD"], 166 | ["g", "w", "w", "g", "g", "gD", "gD", "gD"], 167 | ["g", "w", "w", "w", "w", "g", "g", "b"], 168 | ["g", "w", "w", "w", "w", "w", "g", "b"], 169 | ["g", "g", "g", "g", "g", "g", "g", "b"], 170 | ["b", "b", "b", "b", "b", "b", "b", "b"], 171 | ], 172 | "fog": [ 173 | ["b", "b", "b", "b", "b", "b", "b", "b"], 174 | ["g", "g", "g", "g", "gD", "gD", "gD", "gD"], 175 | ["gD", "gD", "gD", "g", "g", "g", "g", "g"], 176 | ["g", "g", "g", "g", "g", "gD", "gD", "gD"], 177 | ["gD", "gD", "g", "g", "g", "g", "g", "g"], 178 | ["g", "g", "g", "g", "gD", "gD", "gD", "gD"], 179 | ["gD", "gD", "gD", "g", "g", "g", "g", "g"], 180 | ["b", "b", "b", "b", "b", "b", "b", "b"], 181 | ], 182 | "raining": [ 183 | ["b", "b", "b", "g", "g", "g", "b", "b"], 184 | ["b", "g", "g", "g", "g", "g", "g", "b"], 185 | ["b", "g", "g", "g", "g", "g", "g", "b"], 186 | ["g", "g", "g", "g", "g", "g", "g", "g"], 187 | ["g", "g", "g", "g", "g", "g", "g", "g"], 188 | ["b", "bl", "b", "bl", "b", "bl", "b", "b"], 189 | ["b", "b", "bl", "b", "bl", "b", "bl", "b"], 190 | ["b", "b", "b", "b", "b", "b", "b", "b"], 191 | ], 192 | "snowing": [ 193 | ["b", "b", "b", "g", "g", "g", "b", "b"], 194 | ["b", "g", "g", "g", "g", "g", "g", "b"], 195 | ["b", "g", "g", "g", "g", "g", "g", "b"], 196 | ["g", "g", "g", "g", "g", "g", "g", "g"], 197 | ["g", "g", "g", "g", "g", "g", "g", "g"], 198 | ["b", "w", "b", "w", "b", "w", "b", "b"], 199 | ["b", "b", "w", "b", "w", "b", "w", "b"], 200 | ["b", "b", "b", "b", "b", "b", "b", "b"], 201 | ], 202 | "thundering": [ 203 | ["b", "b", "b", "g", "g", "g", "b", "b"], 204 | ["b", "g", "g", "g", "g", "g", "g", "b"], 205 | ["b", "g", "g", "g", "g", "g", "g", "b"], 206 | ["g", "g", "g", "y1", "g", "g", "y1", "g"], 207 | ["g", "g", "y1", "g", "g", "y1", "g", "g"], 208 | ["b", "b", "b", "y1", "b", "b", "y1", "b"], 209 | ["b", "b", "y1", "b", "b", "y1", "b", "b"], 210 | ["b", "b", "b", "b", "b", "b", "b", "b"], 211 | ], 212 | "windy": [ 213 | ["b", "b", "b", "g", "g", "g", "b", "b"], 214 | ["b", "g", "g", "g", "g", "g", "g", "b"], 215 | ["b", "g", "g", "g", "g", "g", "g", "b"], 216 | ["g", "g", "g", "y1", "g", "g", "y1", "g"], 217 | ["g", "g", "y1", "g", "g", "y1", "g", "g"], 218 | ["b", "b", "b", "y1", "b", "b", "y1", "b"], 219 | ["b", "b", "y1", "b", "b", "y1", "b", "b"], 220 | ["b", "b", "b", "b", "b", "b", "b", "b"], 221 | ], 222 | } 223 | 224 | 225 | def draw_digit(draw, x_offset, y_offset, digit): 226 | pattern = digits[digit] 227 | for y, row in enumerate(pattern): 228 | for x, pixel in enumerate(row): 229 | if pixel == "1": 230 | draw.point((x + x_offset, y + y_offset), fill=(255,255,255)) 231 | 232 | def draw_colored_pattern(draw, x_offset, y_offset, key): 233 | if key not in patterns: 234 | raise ValueError(f"The pattern '{key}' is not defined.") 235 | pattern = patterns[key] 236 | for y, row in enumerate(pattern): 237 | for x, pixel in enumerate(row): 238 | if pixel in colors: 239 | draw.point((x + x_offset, y + y_offset), fill=colors[pixel]) 240 | 241 | 242 | def get_current_weather_data(city_query, api_key): 243 | url = f"https://api.weatherapi.com/v1/current.json?q={city_query}&key={api_key}" 244 | response = requests.get(url) 245 | data = response.json() 246 | if response.status_code == 200: 247 | return data 248 | else: 249 | raise ValueError("API could not get info on given city query, or invalid API key.") 250 | 251 | 252 | def get_current_weather_data_forecast(city_query, api_key): 253 | #2 days, just in case the actual hour +6 is the next day 254 | url = f"https://api.weatherapi.com/v1/forecast.json?q={city_query}&days=2&key={api_key}" 255 | response = requests.get(url) 256 | data = response.json() 257 | if response.status_code == 200: 258 | return data 259 | else: 260 | raise ValueError("API could not get info on given city query, or invalid API key.") 261 | 262 | 263 | def get_weather_category(condition_code,is_day): 264 | weather_switch = { 265 | "sun": [1000], 266 | "partly cloudy": [1003], 267 | "cloudy": [1006, 1009], 268 | "fog": [1030, 1135, 1147], 269 | "raining": [ 270 | 1063, 1150, 1153, 1180, 1183, 1186, 1189, 1192, 1195, 1240, 271 | 1243, 1246, 1273, 1276 272 | ], 273 | "snowing": [ 274 | 1066, 1114, 1117, 1168, 1171, 1204, 1207, 1210, 1213, 1216, 275 | 1219, 1222, 1225, 1255, 1258, 1279, 1282 276 | ], 277 | "thundering": [1087, 1273, 1276, 1279, 1282], 278 | "windy": [1114, 1117] 279 | } 280 | if is_day == 0: 281 | # If it is night , we change the category 282 | weather_switch["moon"] = weather_switch.pop("sun", [1000]) 283 | weather_switch["partly cloudy night"] = weather_switch.pop("partly cloudy", [1003]) 284 | 285 | for category, codes in weather_switch.items(): 286 | if condition_code in codes: 287 | return category 288 | return "unknown" 289 | 290 | 291 | def get_weather_img(city_query:str, api_key:str, pixels:int) -> str: 292 | if None in {city_query, api_key, pixels}: 293 | raise Exception("Insufficient args given.") 294 | pixels = int(pixels) 295 | # Get weather data 296 | data_api = get_current_weather_data(city_query, api_key) 297 | 298 | current_weather_code = data_api["current"]["condition"]["code"] 299 | is_day = data_api["current"]["is_day"] 300 | 301 | weather_category = get_weather_category(current_weather_code,is_day) 302 | temperature_celsius = int(round(data_api["current"]["temp_c"])) 303 | 304 | # Do pixel img 305 | img = Image.new('RGB', (pixels, pixels), color='black') 306 | draw = ImageDraw.Draw(img) 307 | 308 | # Extract the celsius digits 309 | first_digit = str(temperature_celsius).zfill(2)[0] 310 | second_digit = str(temperature_celsius).zfill(2)[1] 311 | 312 | # Draw temperature and weather 313 | draw_digit(draw, 3, 8, first_digit) 314 | draw_digit(draw, 9, 8, second_digit) 315 | draw_colored_pattern(draw, 4, 0, weather_category) 316 | 317 | # Save the img 318 | file_path = "weather.png" 319 | img.save(file_path) 320 | 321 | return file_path 322 | 323 | 324 | def get_weather_gif(city_query:str, api_key:str, pixels:int) -> str: 325 | if None in {city_query, api_key, pixels}: 326 | raise Exception("Insufficient args given.") 327 | pixels = int(pixels) 328 | data_api = get_current_weather_data_forecast(city_query, api_key=api_key) 329 | current_hour = int(data_api["location"]["localtime"].split()[1].split(":")[0]) 330 | 331 | hourly_forecast = data_api["forecast"]["forecastday"][0]["hour"] 332 | #Array for all the images 333 | images=[] 334 | #range must be max 6 because specs 335 | for i in range(6): 336 | #Checking if the next hour is in the same day or next 337 | hour_index = (current_hour + i) % 24 338 | if current_hour + i < 24: # Same day 339 | hour_data = data_api["forecast"]["forecastday"][0]["hour"][hour_index] 340 | else: # Next day 341 | hour_data = data_api["forecast"]["forecastday"][1]["hour"][hour_index] 342 | 343 | condition_code = hour_data["condition"]["code"] 344 | is_day = hour_data["is_day"] 345 | 346 | #Celsius temperature 347 | temperature_celsius = int(round(hour_data["temp_c"])) 348 | 349 | weather_category = get_weather_category(condition_code, is_day) 350 | 351 | # Create the pixel image 352 | img = Image.new('RGB', (pixels, pixels), color=1) 353 | draw = ImageDraw.Draw(img) 354 | 355 | # Extract the Celsius digits 356 | first_digit = str(temperature_celsius).zfill(2)[0] 357 | second_digit = str(temperature_celsius).zfill(2)[1] 358 | # Determine the digit color (red for the first image, white for others) 359 | 360 | draw.rectangle([0, 15, i, 15], fill=(255, 255, 255)) #horizontal line to draw the hour, each point is the index of the hour 361 | 362 | draw_digit(draw, 3, 8, first_digit) 363 | draw_digit(draw, 9, 8, second_digit) 364 | draw_colored_pattern(draw, 4, 0, weather_category) 365 | 366 | # Save the gif with a unique name 367 | if img.getbbox(): 368 | images.append(img) 369 | else: 370 | print(f"IMG {i} is empty, it will not be added") 371 | 372 | # Run the command with the new image 373 | 374 | images_array = [numpy.array(img) for img in images] 375 | 376 | gif_path = "weather_forecast.gif" 377 | 378 | images[0].save(gif_path, save_all=True, append_images=images[1:], duration=[1000, 1000, 1000, 1000, 1000, 1000], loop=0) 379 | 380 | return gif_path 381 | 382 | 383 | -------------------------------------------------------------------------------- /windows_scripts/gui.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force 2 | $root = Resolve-Path -Path "$PSScriptRoot\.." 3 | & "$root\run_in_venv.ps1" -DontInvokeApp "$root\gui.py" 4 | pause 5 | -------------------------------------------------------------------------------- /windows_scripts/setup_and_install_gui.ps1: -------------------------------------------------------------------------------- 1 | # Starts by making sure the app is set up 2 | Write-Host "`n# SETTING UP iDotMatrix #" 3 | Write-Host "NOTE: If something goes wrong, try running the script with an administrator instance of Powershell." 4 | 5 | 6 | $root = Resolve-Path -Path "$PSScriptRoot\.." 7 | 8 | cd "$root" 9 | if (-not $?) { 10 | Write-Host "\nERROR: Failed to navigate to root of repository" 11 | pause 12 | exit 13 | } 14 | 15 | 16 | Write-Host "`n## PYTHON SETUP ##" 17 | Write-Host "`n### VERIFYING LAUNCH DIRECTORY ###" 18 | Write-Host "INFO: Launching from $PSScriptRoot" 19 | Write-Host "INFO: Assuming $root is the root of the git repository." 20 | 21 | $GuiFileFound = Test-Path -Path ".\gui.py" 22 | if (-not $GuiFileFound) { 23 | Write-Host "`nERROR: gui.py not found. `nThis means that the script wasn't launched from the correct folder.`n" 24 | Write-Host "`nTo work correctly, you need to launch this script from the root folder of the iDotMatrix git folder." 25 | Write-Host "`nTo do this, open the folder this script is located in in Windws Explorer, right click the script, and press 'Run in powershell'.`n" 26 | Write-Host "`nIf that doesn't work, either open a powershell window and cd to the folder, or open the iDotMatrix git folder in Windows Explorer, then shift-right-click inside in an empty spot in the folder window, and click 'Open in powershell'." 27 | Write-Host "`nWith powershell open, write .\windows_scripts\setup_and_make_launcher.ps1 and press enter" 28 | pause 29 | exit 30 | } 31 | 32 | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force 33 | $py_cmd = "$root/run_in_venv.ps1" 34 | 35 | Write-Host "`n### OPENING/MAKING VENV & INSTALLING DEPENDENCIES ###" 36 | & $py_cmd -DontInvokeApp -m pip install pyqt5 requests numpy 37 | 38 | 39 | Write-Host "`n## CREATING LAUNCHER SHORTCUT ##" 40 | Write-Host "This script will now create the shortcut on your desktop and in Windows list of programs if possible." 41 | 42 | $WshShell = New-Object -COMObject WScript.Shell 43 | 44 | $ShortcutRoot = "$Home\Desktop" 45 | $ShortcutRootFound = Test-Path -Path "$ShortcutRoot" 46 | if (-not $ShortcutRootFound) { 47 | Write-Host "`nERROR: Your desktop couldn't be found by the script, the shortcut will be placed in the same folder as this script instead." 48 | $ShortcutRoot = "$PSScriptRoot" 49 | } 50 | 51 | $ShortcutPath = "$ShortcutRoot\iDotMatrix GUI.lnk" 52 | 53 | 54 | $Shortcut = $WshShell.CreateShortcut("$ShortcutPath") 55 | $Shortcut.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" 56 | 57 | $userInput = Read-Host -Prompt "`nCHOICE: Do you want the terminal to be hidden when launching the GUI?`n[y/n]" 58 | if ($userInput -eq "y") { 59 | $Shortcut.Arguments = "-WindowStyle Hidden -File `"$PSScriptRoot\gui.ps1`"" 60 | Write-Host "INFO: The launcher shortcut will now hide its terminal after opening. If the GUI isn't opening, re-run this script without hiding the terminal, so you can see what went wrong." 61 | } else { 62 | $Shortcut.Arguments = "-File `"$PSScriptRoot\gui.ps1`"" #-WindowStyle Hidden 63 | } 64 | 65 | $Shortcut.IconLocation = "$root\idmc.ico" 66 | $Shortcut.WorkingDirectory = split-path -parent $MyInvocation.MyCommand.Definition 67 | $Shortcut.Save() 68 | 69 | $ProgramsPath = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs" 70 | if (Test-Path -Path "$ProgramsPath") { 71 | Write-Host "INFO: Copying shortcut to make it register as an app, to the path: $ProgramsPath" 72 | Copy-Item "$ShortcutPath" -Destination "$ProgramsPath" 73 | } else { 74 | Write-Host "ERROR: Couldn't find your program folder. You can copy the shortcut to this folder manually instead, the path should look like this, but possibly with a different drive letter: $ProgramsPath" 75 | } 76 | 77 | Write-Host "`n## FINISHED ##" 78 | 79 | Write-Host "`n### OPTIONAL TROUBLESHOOTING ###" 80 | Write-Host "- If something went wrong with the shortcut, try running the script with an administrator instance of Powershell, as Windows might require this for making the shortcut." 81 | Write-Host "- If some commands in the script fails, first re-run without a hidden terminal if you chose to hide it, to see the errors." 82 | Write-Host "- If that doesn't help, make sure you have Python installed, and see if you can open the GUI manually through powershell, by copying the commands in this file that start with `"python`"." 83 | Write-Host "`n### SUMMARY ###" 84 | Write-Host "A shortcut should now have been created on your desktop, and a copy of it added to $ProgramsPath to make the program searchable, unless the log above states otherwise." 85 | Write-Host "Try opening it, if the shortcut isn't there or nothing shows up, read the TROUBLESHOOTING section above." 86 | Write-Host "`n`n" 87 | 88 | pause 89 | --------------------------------------------------------------------------------