├── LICENSE ├── README.md ├── max7219_font.h └── max7219grid.hpp /LICENSE: -------------------------------------------------------------------------------- 1 | # ESPHome License 2 | 3 | Copyright (c) 2019 ESPHome 4 | 5 | The ESPHome License is made up of two base licenses: MIT and the GNU GENERAL PUBLIC LICENSE. 6 | The C++/runtime codebase of the ESPHome project (file extensions .c, .cpp, .h, .hpp, .tcc, .ino) are 7 | published under the GPLv3 license. The python codebase and all other parts of this codebase are 8 | published under the MIT license. 9 | 10 | Both MIT and GPLv3 licenses are attached to this document. 11 | 12 | ## MIT License 13 | 14 | Copyright (c) 2019 ESPHome 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy 17 | of this software and associated documentation files (the "Software"), to deal 18 | in the Software without restriction, including without limitation the rights 19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | copies of the Software, and to permit persons to whom the Software is 21 | furnished to do so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in all 24 | copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 | SOFTWARE. 33 | 34 | ## GPLv3 License 35 | 36 | GNU GENERAL PUBLIC LICENSE 37 | Version 3, 29 June 2007 38 | 39 | Copyright (C) 2007 Free Software Foundation, Inc. 40 | Everyone is permitted to copy and distribute verbatim copies 41 | of this license document, but changing it is not allowed. 42 | 43 | Preamble 44 | 45 | The GNU General Public License is a free, copyleft license for 46 | software and other kinds of works. 47 | 48 | The licenses for most software and other practical works are designed 49 | to take away your freedom to share and change the works. By contrast, 50 | the GNU General Public License is intended to guarantee your freedom to 51 | share and change all versions of a program--to make sure it remains free 52 | software for all its users. We, the Free Software Foundation, use the 53 | GNU General Public License for most of our software; it applies also to 54 | any other work released this way by its authors. You can apply it to 55 | your programs, too. 56 | 57 | When we speak of free software, we are referring to freedom, not 58 | price. Our General Public Licenses are designed to make sure that you 59 | have the freedom to distribute copies of free software (and charge for 60 | them if you wish), that you receive source code or can get it if you 61 | want it, that you can change the software or use pieces of it in new 62 | free programs, and that you know you can do these things. 63 | 64 | To protect your rights, we need to prevent others from denying you 65 | these rights or asking you to surrender the rights. Therefore, you have 66 | certain responsibilities if you distribute copies of the software, or if 67 | you modify it: responsibilities to respect the freedom of others. 68 | 69 | For example, if you distribute copies of such a program, whether 70 | gratis or for a fee, you must pass on to the recipients the same 71 | freedoms that you received. You must make sure that they, too, receive 72 | or can get the source code. And you must show them these terms so they 73 | know their rights. 74 | 75 | Developers that use the GNU GPL protect your rights with two steps: 76 | (1) assert copyright on the software, and (2) offer you this License 77 | giving you legal permission to copy, distribute and/or modify it. 78 | 79 | For the developers' and authors' protection, the GPL clearly explains 80 | that there is no warranty for this free software. For both users' and 81 | authors' sake, the GPL requires that modified versions be marked as 82 | changed, so that their problems will not be attributed erroneously to 83 | authors of previous versions. 84 | 85 | Some devices are designed to deny users access to install or run 86 | modified versions of the software inside them, although the manufacturer 87 | can do so. This is fundamentally incompatible with the aim of 88 | protecting users' freedom to change the software. The systematic 89 | pattern of such abuse occurs in the area of products for individuals to 90 | use, which is precisely where it is most unacceptable. Therefore, we 91 | have designed this version of the GPL to prohibit the practice for those 92 | products. If such problems arise substantially in other domains, we 93 | stand ready to extend this provision to those domains in future versions 94 | of the GPL, as needed to protect the freedom of users. 95 | 96 | Finally, every program is threatened constantly by software patents. 97 | States should not allow patents to restrict development and use of 98 | software on general-purpose computers, but in those that do, we wish to 99 | avoid the special danger that patents applied to a free program could 100 | make it effectively proprietary. To prevent this, the GPL assures that 101 | patents cannot be used to render the program non-free. 102 | 103 | The precise terms and conditions for copying, distribution and 104 | modification follow. 105 | 106 | TERMS AND CONDITIONS 107 | 108 | 0. Definitions. 109 | 110 | "This License" refers to version 3 of the GNU General Public License. 111 | 112 | "Copyright" also means copyright-like laws that apply to other kinds of 113 | works, such as semiconductor masks. 114 | 115 | "The Program" refers to any copyrightable work licensed under this 116 | License. Each licensee is addressed as "you". "Licensees" and 117 | "recipients" may be individuals or organizations. 118 | 119 | To "modify" a work means to copy from or adapt all or part of the work 120 | in a fashion requiring copyright permission, other than the making of an 121 | exact copy. The resulting work is called a "modified version" of the 122 | earlier work or a work "based on" the earlier work. 123 | 124 | A "covered work" means either the unmodified Program or a work based 125 | on the Program. 126 | 127 | To "propagate" a work means to do anything with it that, without 128 | permission, would make you directly or secondarily liable for 129 | infringement under applicable copyright law, except executing it on a 130 | computer or modifying a private copy. Propagation includes copying, 131 | distribution (with or without modification), making available to the 132 | public, and in some countries other activities as well. 133 | 134 | To "convey" a work means any kind of propagation that enables other 135 | parties to make or receive copies. Mere interaction with a user through 136 | a computer network, with no transfer of a copy, is not conveying. 137 | 138 | An interactive user interface displays "Appropriate Legal Notices" 139 | to the extent that it includes a convenient and prominently visible 140 | feature that (1) displays an appropriate copyright notice, and (2) 141 | tells the user that there is no warranty for the work (except to the 142 | extent that warranties are provided), that licensees may convey the 143 | work under this License, and how to view a copy of this License. If 144 | the interface presents a list of user commands or options, such as a 145 | menu, a prominent item in the list meets this criterion. 146 | 147 | 1. Source Code. 148 | 149 | The "source code" for a work means the preferred form of the work 150 | for making modifications to it. "Object code" means any non-source 151 | form of a work. 152 | 153 | A "Standard Interface" means an interface that either is an official 154 | standard defined by a recognized standards body, or, in the case of 155 | interfaces specified for a particular programming language, one that 156 | is widely used among developers working in that language. 157 | 158 | The "System Libraries" of an executable work include anything, other 159 | than the work as a whole, that (a) is included in the normal form of 160 | packaging a Major Component, but which is not part of that Major 161 | Component, and (b) serves only to enable use of the work with that 162 | Major Component, or to implement a Standard Interface for which an 163 | implementation is available to the public in source code form. A 164 | "Major Component", in this context, means a major essential component 165 | (kernel, window system, and so on) of the specific operating system 166 | (if any) on which the executable work runs, or a compiler used to 167 | produce the work, or an object code interpreter used to run it. 168 | 169 | The "Corresponding Source" for a work in object code form means all 170 | the source code needed to generate, install, and (for an executable 171 | work) run the object code and to modify the work, including scripts to 172 | control those activities. However, it does not include the work's 173 | System Libraries, or general-purpose tools or generally available free 174 | programs which are used unmodified in performing those activities but 175 | which are not part of the work. For example, Corresponding Source 176 | includes interface definition files associated with source files for 177 | the work, and the source code for shared libraries and dynamically 178 | linked subprograms that the work is specifically designed to require, 179 | such as by intimate data communication or control flow between those 180 | subprograms and other parts of the work. 181 | 182 | The Corresponding Source need not include anything that users 183 | can regenerate automatically from other parts of the Corresponding 184 | Source. 185 | 186 | The Corresponding Source for a work in source code form is that 187 | same work. 188 | 189 | 2. Basic Permissions. 190 | 191 | All rights granted under this License are granted for the term of 192 | copyright on the Program, and are irrevocable provided the stated 193 | conditions are met. This License explicitly affirms your unlimited 194 | permission to run the unmodified Program. The output from running a 195 | covered work is covered by this License only if the output, given its 196 | content, constitutes a covered work. This License acknowledges your 197 | rights of fair use or other equivalent, as provided by copyright law. 198 | 199 | You may make, run and propagate covered works that you do not 200 | convey, without conditions so long as your license otherwise remains 201 | in force. You may convey covered works to others for the sole purpose 202 | of having them make modifications exclusively for you, or provide you 203 | with facilities for running those works, provided that you comply with 204 | the terms of this License in conveying all material for which you do 205 | not control copyright. Those thus making or running the covered works 206 | for you must do so exclusively on your behalf, under your direction 207 | and control, on terms that prohibit them from making any copies of 208 | your copyrighted material outside their relationship with you. 209 | 210 | Conveying under any other circumstances is permitted solely under 211 | the conditions stated below. Sublicensing is not allowed; section 10 212 | makes it unnecessary. 213 | 214 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 215 | 216 | No covered work shall be deemed part of an effective technological 217 | measure under any applicable law fulfilling obligations under article 218 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 219 | similar laws prohibiting or restricting circumvention of such 220 | measures. 221 | 222 | When you convey a covered work, you waive any legal power to forbid 223 | circumvention of technological measures to the extent such circumvention 224 | is effected by exercising rights under this License with respect to 225 | the covered work, and you disclaim any intention to limit operation or 226 | modification of the work as a means of enforcing, against the work's 227 | users, your or third parties' legal rights to forbid circumvention of 228 | technological measures. 229 | 230 | 4. Conveying Verbatim Copies. 231 | 232 | You may convey verbatim copies of the Program's source code as you 233 | receive it, in any medium, provided that you conspicuously and 234 | appropriately publish on each copy an appropriate copyright notice; 235 | keep intact all notices stating that this License and any 236 | non-permissive terms added in accord with section 7 apply to the code; 237 | keep intact all notices of the absence of any warranty; and give all 238 | recipients a copy of this License along with the Program. 239 | 240 | You may charge any price or no price for each copy that you convey, 241 | and you may offer support or warranty protection for a fee. 242 | 243 | 5. Conveying Modified Source Versions. 244 | 245 | You may convey a work based on the Program, or the modifications to 246 | produce it from the Program, in the form of source code under the 247 | terms of section 4, provided that you also meet all of these conditions: 248 | 249 | a) The work must carry prominent notices stating that you modified 250 | it, and giving a relevant date. 251 | 252 | b) The work must carry prominent notices stating that it is 253 | released under this License and any conditions added under section 254 | 7. This requirement modifies the requirement in section 4 to 255 | "keep intact all notices". 256 | 257 | c) You must license the entire work, as a whole, under this 258 | License to anyone who comes into possession of a copy. This 259 | License will therefore apply, along with any applicable section 7 260 | additional terms, to the whole of the work, and all its parts, 261 | regardless of how they are packaged. This License gives no 262 | permission to license the work in any other way, but it does not 263 | invalidate such permission if you have separately received it. 264 | 265 | d) If the work has interactive user interfaces, each must display 266 | Appropriate Legal Notices; however, if the Program has interactive 267 | interfaces that do not display Appropriate Legal Notices, your 268 | work need not make them do so. 269 | 270 | A compilation of a covered work with other separate and independent 271 | works, which are not by their nature extensions of the covered work, 272 | and which are not combined with it such as to form a larger program, 273 | in or on a volume of a storage or distribution medium, is called an 274 | "aggregate" if the compilation and its resulting copyright are not 275 | used to limit the access or legal rights of the compilation's users 276 | beyond what the individual works permit. Inclusion of a covered work 277 | in an aggregate does not cause this License to apply to the other 278 | parts of the aggregate. 279 | 280 | 6. Conveying Non-Source Forms. 281 | 282 | You may convey a covered work in object code form under the terms 283 | of sections 4 and 5, provided that you also convey the 284 | machine-readable Corresponding Source under the terms of this License, 285 | in one of these ways: 286 | 287 | a) Convey the object code in, or embodied in, a physical product 288 | (including a physical distribution medium), accompanied by the 289 | Corresponding Source fixed on a durable physical medium 290 | customarily used for software interchange. 291 | 292 | b) Convey the object code in, or embodied in, a physical product 293 | (including a physical distribution medium), accompanied by a 294 | written offer, valid for at least three years and valid for as 295 | long as you offer spare parts or customer support for that product 296 | model, to give anyone who possesses the object code either (1) a 297 | copy of the Corresponding Source for all the software in the 298 | product that is covered by this License, on a durable physical 299 | medium customarily used for software interchange, for a price no 300 | more than your reasonable cost of physically performing this 301 | conveying of source, or (2) access to copy the 302 | Corresponding Source from a network server at no charge. 303 | 304 | c) Convey individual copies of the object code with a copy of the 305 | written offer to provide the Corresponding Source. This 306 | alternative is allowed only occasionally and noncommercially, and 307 | only if you received the object code with such an offer, in accord 308 | with subsection 6b. 309 | 310 | d) Convey the object code by offering access from a designated 311 | place (gratis or for a charge), and offer equivalent access to the 312 | Corresponding Source in the same way through the same place at no 313 | further charge. You need not require recipients to copy the 314 | Corresponding Source along with the object code. If the place to 315 | copy the object code is a network server, the Corresponding Source 316 | may be on a different server (operated by you or a third party) 317 | that supports equivalent copying facilities, provided you maintain 318 | clear directions next to the object code saying where to find the 319 | Corresponding Source. Regardless of what server hosts the 320 | Corresponding Source, you remain obligated to ensure that it is 321 | available for as long as needed to satisfy these requirements. 322 | 323 | e) Convey the object code using peer-to-peer transmission, provided 324 | you inform other peers where the object code and Corresponding 325 | Source of the work are being offered to the general public at no 326 | charge under subsection 6d. 327 | 328 | A separable portion of the object code, whose source code is excluded 329 | from the Corresponding Source as a System Library, need not be 330 | included in conveying the object code work. 331 | 332 | A "User Product" is either (1) a "consumer product", which means any 333 | tangible personal property which is normally used for personal, family, 334 | or household purposes, or (2) anything designed or sold for incorporation 335 | into a dwelling. In determining whether a product is a consumer product, 336 | doubtful cases shall be resolved in favor of coverage. For a particular 337 | product received by a particular user, "normally used" refers to a 338 | typical or common use of that class of product, regardless of the status 339 | of the particular user or of the way in which the particular user 340 | actually uses, or expects or is expected to use, the product. A product 341 | is a consumer product regardless of whether the product has substantial 342 | commercial, industrial or non-consumer uses, unless such uses represent 343 | the only significant mode of use of the product. 344 | 345 | "Installation Information" for a User Product means any methods, 346 | procedures, authorization keys, or other information required to install 347 | and execute modified versions of a covered work in that User Product from 348 | a modified version of its Corresponding Source. The information must 349 | suffice to ensure that the continued functioning of the modified object 350 | code is in no case prevented or interfered with solely because 351 | modification has been made. 352 | 353 | If you convey an object code work under this section in, or with, or 354 | specifically for use in, a User Product, and the conveying occurs as 355 | part of a transaction in which the right of possession and use of the 356 | User Product is transferred to the recipient in perpetuity or for a 357 | fixed term (regardless of how the transaction is characterized), the 358 | Corresponding Source conveyed under this section must be accompanied 359 | by the Installation Information. But this requirement does not apply 360 | if neither you nor any third party retains the ability to install 361 | modified object code on the User Product (for example, the work has 362 | been installed in ROM). 363 | 364 | The requirement to provide Installation Information does not include a 365 | requirement to continue to provide support service, warranty, or updates 366 | for a work that has been modified or installed by the recipient, or for 367 | the User Product in which it has been modified or installed. Access to a 368 | network may be denied when the modification itself materially and 369 | adversely affects the operation of the network or violates the rules and 370 | protocols for communication across the network. 371 | 372 | Corresponding Source conveyed, and Installation Information provided, 373 | in accord with this section must be in a format that is publicly 374 | documented (and with an implementation available to the public in 375 | source code form), and must require no special password or key for 376 | unpacking, reading or copying. 377 | 378 | 7. Additional Terms. 379 | 380 | "Additional permissions" are terms that supplement the terms of this 381 | License by making exceptions from one or more of its conditions. 382 | Additional permissions that are applicable to the entire Program shall 383 | be treated as though they were included in this License, to the extent 384 | that they are valid under applicable law. If additional permissions 385 | apply only to part of the Program, that part may be used separately 386 | under those permissions, but the entire Program remains governed by 387 | this License without regard to the additional permissions. 388 | 389 | When you convey a copy of a covered work, you may at your option 390 | remove any additional permissions from that copy, or from any part of 391 | it. (Additional permissions may be written to require their own 392 | removal in certain cases when you modify the work.) You may place 393 | additional permissions on material, added by you to a covered work, 394 | for which you have or can give appropriate copyright permission. 395 | 396 | Notwithstanding any other provision of this License, for material you 397 | add to a covered work, you may (if authorized by the copyright holders of 398 | that material) supplement the terms of this License with terms: 399 | 400 | a) Disclaiming warranty or limiting liability differently from the 401 | terms of sections 15 and 16 of this License; or 402 | 403 | b) Requiring preservation of specified reasonable legal notices or 404 | author attributions in that material or in the Appropriate Legal 405 | Notices displayed by works containing it; or 406 | 407 | c) Prohibiting misrepresentation of the origin of that material, or 408 | requiring that modified versions of such material be marked in 409 | reasonable ways as different from the original version; or 410 | 411 | d) Limiting the use for publicity purposes of names of licensors or 412 | authors of the material; or 413 | 414 | e) Declining to grant rights under trademark law for use of some 415 | trade names, trademarks, or service marks; or 416 | 417 | f) Requiring indemnification of licensors and authors of that 418 | material by anyone who conveys the material (or modified versions of 419 | it) with contractual assumptions of liability to the recipient, for 420 | any liability that these contractual assumptions directly impose on 421 | those licensors and authors. 422 | 423 | All other non-permissive additional terms are considered "further 424 | restrictions" within the meaning of section 10. If the Program as you 425 | received it, or any part of it, contains a notice stating that it is 426 | governed by this License along with a term that is a further 427 | restriction, you may remove that term. If a license document contains 428 | a further restriction but permits relicensing or conveying under this 429 | License, you may add to a covered work material governed by the terms 430 | of that license document, provided that the further restriction does 431 | not survive such relicensing or conveying. 432 | 433 | If you add terms to a covered work in accord with this section, you 434 | must place, in the relevant source files, a statement of the 435 | additional terms that apply to those files, or a notice indicating 436 | where to find the applicable terms. 437 | 438 | Additional terms, permissive or non-permissive, may be stated in the 439 | form of a separately written license, or stated as exceptions; 440 | the above requirements apply either way. 441 | 442 | 8. Termination. 443 | 444 | You may not propagate or modify a covered work except as expressly 445 | provided under this License. Any attempt otherwise to propagate or 446 | modify it is void, and will automatically terminate your rights under 447 | this License (including any patent licenses granted under the third 448 | paragraph of section 11). 449 | 450 | However, if you cease all violation of this License, then your 451 | license from a particular copyright holder is reinstated (a) 452 | provisionally, unless and until the copyright holder explicitly and 453 | finally terminates your license, and (b) permanently, if the copyright 454 | holder fails to notify you of the violation by some reasonable means 455 | prior to 60 days after the cessation. 456 | 457 | Moreover, your license from a particular copyright holder is 458 | reinstated permanently if the copyright holder notifies you of the 459 | violation by some reasonable means, this is the first time you have 460 | received notice of violation of this License (for any work) from that 461 | copyright holder, and you cure the violation prior to 30 days after 462 | your receipt of the notice. 463 | 464 | Termination of your rights under this section does not terminate the 465 | licenses of parties who have received copies or rights from you under 466 | this License. If your rights have been terminated and not permanently 467 | reinstated, you do not qualify to receive new licenses for the same 468 | material under section 10. 469 | 470 | 9. Acceptance Not Required for Having Copies. 471 | 472 | You are not required to accept this License in order to receive or 473 | run a copy of the Program. Ancillary propagation of a covered work 474 | occurring solely as a consequence of using peer-to-peer transmission 475 | to receive a copy likewise does not require acceptance. However, 476 | nothing other than this License grants you permission to propagate or 477 | modify any covered work. These actions infringe copyright if you do 478 | not accept this License. Therefore, by modifying or propagating a 479 | covered work, you indicate your acceptance of this License to do so. 480 | 481 | 10. Automatic Licensing of Downstream Recipients. 482 | 483 | Each time you convey a covered work, the recipient automatically 484 | receives a license from the original licensors, to run, modify and 485 | propagate that work, subject to this License. You are not responsible 486 | for enforcing compliance by third parties with this License. 487 | 488 | An "entity transaction" is a transaction transferring control of an 489 | organization, or substantially all assets of one, or subdividing an 490 | organization, or merging organizations. If propagation of a covered 491 | work results from an entity transaction, each party to that 492 | transaction who receives a copy of the work also receives whatever 493 | licenses to the work the party's predecessor in interest had or could 494 | give under the previous paragraph, plus a right to possession of the 495 | Corresponding Source of the work from the predecessor in interest, if 496 | the predecessor has it or can get it with reasonable efforts. 497 | 498 | You may not impose any further restrictions on the exercise of the 499 | rights granted or affirmed under this License. For example, you may 500 | not impose a license fee, royalty, or other charge for exercise of 501 | rights granted under this License, and you may not initiate litigation 502 | (including a cross-claim or counterclaim in a lawsuit) alleging that 503 | any patent claim is infringed by making, using, selling, offering for 504 | sale, or importing the Program or any portion of it. 505 | 506 | 11. Patents. 507 | 508 | A "contributor" is a copyright holder who authorizes use under this 509 | License of the Program or a work on which the Program is based. The 510 | work thus licensed is called the contributor's "contributor version". 511 | 512 | A contributor's "essential patent claims" are all patent claims 513 | owned or controlled by the contributor, whether already acquired or 514 | hereafter acquired, that would be infringed by some manner, permitted 515 | by this License, of making, using, or selling its contributor version, 516 | but do not include claims that would be infringed only as a 517 | consequence of further modification of the contributor version. For 518 | purposes of this definition, "control" includes the right to grant 519 | patent sublicenses in a manner consistent with the requirements of 520 | this License. 521 | 522 | Each contributor grants you a non-exclusive, worldwide, royalty-free 523 | patent license under the contributor's essential patent claims, to 524 | make, use, sell, offer for sale, import and otherwise run, modify and 525 | propagate the contents of its contributor version. 526 | 527 | In the following three paragraphs, a "patent license" is any express 528 | agreement or commitment, however denominated, not to enforce a patent 529 | (such as an express permission to practice a patent or covenant not to 530 | sue for patent infringement). To "grant" such a patent license to a 531 | party means to make such an agreement or commitment not to enforce a 532 | patent against the party. 533 | 534 | If you convey a covered work, knowingly relying on a patent license, 535 | and the Corresponding Source of the work is not available for anyone 536 | to copy, free of charge and under the terms of this License, through a 537 | publicly available network server or other readily accessible means, 538 | then you must either (1) cause the Corresponding Source to be so 539 | available, or (2) arrange to deprive yourself of the benefit of the 540 | patent license for this particular work, or (3) arrange, in a manner 541 | consistent with the requirements of this License, to extend the patent 542 | license to downstream recipients. "Knowingly relying" means you have 543 | actual knowledge that, but for the patent license, your conveying the 544 | covered work in a country, or your recipient's use of the covered work 545 | in a country, would infringe one or more identifiable patents in that 546 | country that you have reason to believe are valid. 547 | 548 | If, pursuant to or in connection with a single transaction or 549 | arrangement, you convey, or propagate by procuring conveyance of, a 550 | covered work, and grant a patent license to some of the parties 551 | receiving the covered work authorizing them to use, propagate, modify 552 | or convey a specific copy of the covered work, then the patent license 553 | you grant is automatically extended to all recipients of the covered 554 | work and works based on it. 555 | 556 | A patent license is "discriminatory" if it does not include within 557 | the scope of its coverage, prohibits the exercise of, or is 558 | conditioned on the non-exercise of one or more of the rights that are 559 | specifically granted under this License. You may not convey a covered 560 | work if you are a party to an arrangement with a third party that is 561 | in the business of distributing software, under which you make payment 562 | to the third party based on the extent of your activity of conveying 563 | the work, and under which the third party grants, to any of the 564 | parties who would receive the covered work from you, a discriminatory 565 | patent license (a) in connection with copies of the covered work 566 | conveyed by you (or copies made from those copies), or (b) primarily 567 | for and in connection with specific products or compilations that 568 | contain the covered work, unless you entered into that arrangement, 569 | or that patent license was granted, prior to 28 March 2007. 570 | 571 | Nothing in this License shall be construed as excluding or limiting 572 | any implied license or other defenses to infringement that may 573 | otherwise be available to you under applicable patent law. 574 | 575 | 12. No Surrender of Others' Freedom. 576 | 577 | If conditions are imposed on you (whether by court order, agreement or 578 | otherwise) that contradict the conditions of this License, they do not 579 | excuse you from the conditions of this License. If you cannot convey a 580 | covered work so as to satisfy simultaneously your obligations under this 581 | License and any other pertinent obligations, then as a consequence you may 582 | not convey it at all. For example, if you agree to terms that obligate you 583 | to collect a royalty for further conveying from those to whom you convey 584 | the Program, the only way you could satisfy both those terms and this 585 | License would be to refrain entirely from conveying the Program. 586 | 587 | 13. Use with the GNU Affero General Public License. 588 | 589 | Notwithstanding any other provision of this License, you have 590 | permission to link or combine any covered work with a work licensed 591 | under version 3 of the GNU Affero General Public License into a single 592 | combined work, and to convey the resulting work. The terms of this 593 | License will continue to apply to the part which is the covered work, 594 | but the special requirements of the GNU Affero General Public License, 595 | section 13, concerning interaction through a network will apply to the 596 | combination as such. 597 | 598 | 14. Revised Versions of this License. 599 | 600 | The Free Software Foundation may publish revised and/or new versions of 601 | the GNU General Public License from time to time. Such new versions will 602 | be similar in spirit to the present version, but may differ in detail to 603 | address new problems or concerns. 604 | 605 | Each version is given a distinguishing version number. If the 606 | Program specifies that a certain numbered version of the GNU General 607 | Public License "or any later version" applies to it, you have the 608 | option of following the terms and conditions either of that numbered 609 | version or of any later version published by the Free Software 610 | Foundation. If the Program does not specify a version number of the 611 | GNU General Public License, you may choose any version ever published 612 | by the Free Software Foundation. 613 | 614 | If the Program specifies that a proxy can decide which future 615 | versions of the GNU General Public License can be used, that proxy's 616 | public statement of acceptance of a version permanently authorizes you 617 | to choose that version for the Program. 618 | 619 | Later license versions may give you additional or different 620 | permissions. However, no additional obligations are imposed on any 621 | author or copyright holder as a result of your choosing to follow a 622 | later version. 623 | 624 | 15. Disclaimer of Warranty. 625 | 626 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 627 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 628 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 629 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 630 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 631 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 632 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 633 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 634 | 635 | 16. Limitation of Liability. 636 | 637 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 638 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 639 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 640 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 641 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 642 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 643 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 644 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 645 | SUCH DAMAGES. 646 | 647 | 17. Interpretation of Sections 15 and 16. 648 | 649 | If the disclaimer of warranty and limitation of liability provided 650 | above cannot be given local legal effect according to their terms, 651 | reviewing courts shall apply local law that most closely approximates 652 | an absolute waiver of all civil liability in connection with the 653 | Program, unless a warranty or assumption of liability accompanies a 654 | copy of the Program in return for a fee. 655 | 656 | END OF TERMS AND CONDITIONS 657 | 658 | How to Apply These Terms to Your New Programs 659 | 660 | If you develop a new program, and you want it to be of the greatest 661 | possible use to the public, the best way to achieve this is to make it 662 | free software which everyone can redistribute and change under these terms. 663 | 664 | To do so, attach the following notices to the program. It is safest 665 | to attach them to the start of each source file to most effectively 666 | state the exclusion of warranty; and each file should have at least 667 | the "copyright" line and a pointer to where the full notice is found. 668 | 669 | 670 | Copyright (C) 671 | 672 | This program is free software: you can redistribute it and/or modify 673 | it under the terms of the GNU General Public License as published by 674 | the Free Software Foundation, either version 3 of the License, or 675 | (at your option) any later version. 676 | 677 | This program is distributed in the hope that it will be useful, 678 | but WITHOUT ANY WARRANTY; without even the implied warranty of 679 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 680 | GNU General Public License for more details. 681 | 682 | You should have received a copy of the GNU General Public License 683 | along with this program. If not, see . 684 | 685 | Also add information on how to contact you by electronic and paper mail. 686 | 687 | If the program does terminal interaction, make it output a short 688 | notice like this when it starts in an interactive mode: 689 | 690 | Copyright (C) 691 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 692 | This is free software, and you are welcome to redistribute it 693 | under certain conditions; type `show c' for details. 694 | 695 | The hypothetical commands `show w' and `show c' should show the appropriate 696 | parts of the General Public License. Of course, your program's commands 697 | might be different; for a GUI interface, you would use an "about box". 698 | 699 | You should also get your employer (if you work as a programmer) or school, 700 | if any, to sign a "copyright disclaimer" for the program, if necessary. 701 | For more information on this, and how to apply and follow the GNU GPL, see 702 | . 703 | 704 | The GNU General Public License does not permit incorporating your program 705 | into proprietary programs. If your program is a subroutine library, you 706 | may consider it more useful to permit linking proprietary applications with 707 | the library. If this is what you want to do, use the GNU Lesser General 708 | Public License instead of this License. But first, please read 709 | . 710 | 711 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MAX7219 Grid display 2 | ## Installation 3 | 1. `git clone https://github.com/ASMfreaK/esphome_max7219.git max7219grid` 4 | 2. Use this example configuration 5 | 6 | ```yaml 7 | 8 | esphome: 9 | # ... 10 | includes: 11 | - max7219grid/max7219grid.hpp 12 | 13 | # ... 14 | spi: 15 | clk_pin: D1 16 | mosi_pin: D2 17 | id: _spi 18 | 19 | custom_component: 20 | - lambda: |- 21 | using Disp = esphome::display::MAX7219GridComponent; 22 | auto grid = new Disp(id(_spi), new esphome::GPIOPin(D3, OUTPUT), 100); 23 | grid->set_num_chips(4); 24 | auto writer = [](Disp& it){ 25 | static uint16_t offset=0; 26 | ++offset; 27 | for(uint16_t l=0; l< it.width(); ++l){ 28 | it.fill_vertical_line(l, 0x1 << ((l + offset) % it.height())); 29 | } 30 | }; 31 | grid->set_writer(writer); 32 | return {grid}; 33 | 34 | ``` 35 | -------------------------------------------------------------------------------- /max7219_font.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asmfreak/esphome_max7219/115b41ee61d4ca929804055b516da66c30cf5617/max7219_font.h -------------------------------------------------------------------------------- /max7219grid.hpp: -------------------------------------------------------------------------------- 1 | #include "esphome/defines.h" 2 | 3 | #include "esphome/helpers.h" 4 | #include "esphome/spi_component.h" 5 | #include "esphome/time/rtc_component.h" 6 | 7 | ESPHOME_NAMESPACE_BEGIN 8 | 9 | namespace display { 10 | 11 | extern const uint8_t MAX7219_ASCII_TO_RAW[94] PROGMEM; 12 | 13 | class MAX7219GridComponent; 14 | 15 | using max7219_writer_t = std::function; 16 | 17 | class MAX7219GridComponent : public PollingComponent, public SPIDevice { 18 | public: 19 | MAX7219GridComponent(SPIComponent *parent, GPIOPin *cs, uint32_t update_interval = 1000); 20 | 21 | void set_writer(max7219_writer_t &&writer); 22 | 23 | void setup() override; 24 | 25 | void dump_config() override; 26 | 27 | void update() override; 28 | 29 | float get_setup_priority() const override; 30 | 31 | void display(); 32 | 33 | void set_intensity(uint8_t intensity); 34 | void set_num_chips(uint8_t num_chips); 35 | 36 | uint8_t printf(uint8_t pos, const char *format, ...) __attribute__((format(printf, 3, 4))); 37 | uint8_t printf(const char *format, ...) __attribute__((format(printf, 2, 3))); 38 | 39 | uint8_t print(uint8_t pos, const char *str); 40 | uint8_t print(const char *str); 41 | uint16_t width(){ return this->num_chips_ * 8;} 42 | uint16_t height(){ return 8;} 43 | void fill_vertical_line(uint16_t line, uint8_t val){ 44 | if(line < width()){ 45 | this->buffer_[line] = val; 46 | } 47 | } 48 | 49 | #ifdef USE_TIME 50 | uint8_t strftime(uint8_t pos, const char *format, time::ESPTime time) __attribute__((format(strftime, 3, 0))); 51 | 52 | uint8_t strftime(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0))); 53 | #endif 54 | 55 | protected: 56 | void send_byte_(uint8_t a_register, uint8_t data); 57 | void send_to_all_(uint8_t a_register, uint8_t data); 58 | bool is_device_msb_first() override; 59 | 60 | uint8_t intensity_{15}; 61 | uint8_t num_chips_{1}; 62 | uint8_t *buffer_; 63 | optional writer_{}; 64 | }; 65 | 66 | } // namespace display 67 | 68 | ESPHOME_NAMESPACE_END 69 | 70 | 71 | #include "esphome/log.h" 72 | 73 | ESPHOME_NAMESPACE_BEGIN 74 | 75 | namespace display { 76 | 77 | static const char *TAG = "display.max7219"; 78 | static const uint8_t MAX7219_REGISTER_NOOP = 0x00; 79 | static const uint8_t MAX7219_REGISTER_DECODE_MODE = 0x09; 80 | static const uint8_t MAX7219_REGISTER_INTENSITY = 0x0A; 81 | static const uint8_t MAX7219_REGISTER_SCAN_LIMIT = 0x0B; 82 | static const uint8_t MAX7219_REGISTER_SHUTDOWN = 0x0C; 83 | static const uint8_t MAX7219_REGISTER_DISPLAY_TEST = 0x0F; 84 | constexpr uint8_t MAX7219_NO_SHUTDOWN = 0x00; 85 | constexpr uint8_t MAX7219_SHUTDOWN = 0x01; 86 | constexpr uint8_t MAX7219_NO_DISPLAY_TEST = 0x00; 87 | constexpr uint8_t MAX7219_DISPLAY_TEST = 0x01; 88 | 89 | MAX7219GridComponent::MAX7219GridComponent(SPIComponent *parent, GPIOPin *cs, uint32_t update_interval) 90 | : PollingComponent(update_interval), SPIDevice(parent, cs) {} 91 | 92 | float MAX7219GridComponent::get_setup_priority() const { return setup_priority::POST_HARDWARE; } 93 | void MAX7219GridComponent::setup() { 94 | ESP_LOGCONFIG(TAG, "Setting up MAX7219..."); 95 | this->spi_setup(); 96 | this->buffer_ = new uint8_t[this->num_chips_ * 8]; 97 | for (uint8_t i = 0; i < this->num_chips_ * 8; i++) 98 | this->buffer_[i] = 0; 99 | // let's assume the user has all 8 digits connected, only important in daisy chained setups anyway 100 | this->send_to_all_(MAX7219_REGISTER_SHUTDOWN, MAX7219_NO_SHUTDOWN); 101 | this->send_to_all_(MAX7219_REGISTER_DISPLAY_TEST, MAX7219_NO_DISPLAY_TEST); 102 | //this->send_to_all_(MAX7219_REGISTER_SHUTDOWN, MAX7219_NO_SHUTDOWN); 103 | // let's assume the user has all 8 digits connected, only important in daisy chained setups anyway 104 | this->send_to_all_(MAX7219_REGISTER_SCAN_LIMIT, 7); 105 | // let's use our own ASCII -> led pattern encoding 106 | this->send_to_all_(MAX7219_REGISTER_DECODE_MODE, 0); 107 | this->send_to_all_(MAX7219_REGISTER_INTENSITY, this->intensity_); 108 | delay(250); 109 | this->display(); 110 | // power up 111 | this->send_to_all_(MAX7219_REGISTER_SHUTDOWN, 1); 112 | } 113 | void MAX7219GridComponent::dump_config() { 114 | ESP_LOGCONFIG(TAG, "MAX7219:"); 115 | ESP_LOGCONFIG(TAG, " Number of Chips: %u", this->num_chips_); 116 | ESP_LOGCONFIG(TAG, " Intensity: %u", this->intensity_); 117 | LOG_PIN(" CS Pin: ", this->cs_); 118 | LOG_UPDATE_INTERVAL(this); 119 | } 120 | 121 | void MAX7219GridComponent::display() { 122 | 123 | for (uint8_t i = 0; i < 8; i++) { 124 | this->enable(); 125 | for (uint8_t j = 0; j < this->num_chips_; j++) { 126 | this->send_byte_(8 - i, this->buffer_[j * 8 + i]); 127 | } 128 | this->disable(); 129 | } 130 | } 131 | void MAX7219GridComponent::send_byte_(uint8_t a_register, uint8_t data) { 132 | // ESP_LOGW(TAG, "R(%x)<- %x", a_register, data); 133 | this->write_byte(a_register); 134 | this->write_byte(data); 135 | } 136 | void MAX7219GridComponent::send_to_all_(uint8_t a_register, uint8_t data) { 137 | this->enable(); 138 | for (uint8_t i = 0; i < this->num_chips_; i++) 139 | this->send_byte_(a_register, data); 140 | this->disable(); 141 | } 142 | bool MAX7219GridComponent::is_device_msb_first() { return true; } 143 | void MAX7219GridComponent::update() { 144 | for (uint8_t i = 0; i < this->num_chips_ * 8; i++){ 145 | this->buffer_[i] = 0; 146 | } 147 | if (this->writer_.has_value()) 148 | (*this->writer_)(*this); 149 | this->display(); 150 | } 151 | uint8_t MAX7219GridComponent::print(uint8_t start_pos, const char *str) { 152 | // uint8_t pos = start_pos; 153 | // for (; *str != '\0'; str++) { 154 | // uint8_t data = MAX7219_UNKNOWN_CHAR; 155 | // if (*str >= ' ' && *str <= '}') 156 | // data = pgm_read_byte(&MAX7219_ASCII_TO_RAW[*str - ' ']); 157 | // 158 | // if (data == MAX7219_UNKNOWN_CHAR) { 159 | // ESP_LOGW(TAG, "Encountered character '%c' with no MAX7219 representation while translating string!", *str); 160 | // } 161 | // if (*str == '.') { 162 | // if (pos != start_pos) 163 | // pos--; 164 | // this->buffer_[pos] |= 0b10000000; 165 | // } else { 166 | // if (pos >= this->num_chips_ * 8) { 167 | // ESP_LOGE(TAG, "MAX7219 String is too long for the display!"); 168 | // break; 169 | // } 170 | // this->buffer_[pos] = data; 171 | // } 172 | // pos++; 173 | // } 174 | // return pos - start_pos; 175 | return 0; 176 | } 177 | uint8_t MAX7219GridComponent::print(const char *str) { 178 | return this->print(0, str); 179 | } 180 | uint8_t MAX7219GridComponent::printf(uint8_t pos, const char *format, ...) { 181 | va_list arg; 182 | va_start(arg, format); 183 | char buffer[64]; 184 | int ret = vsnprintf(buffer, sizeof(buffer), format, arg); 185 | va_end(arg); 186 | if (ret > 0) 187 | return this->print(pos, buffer); 188 | return 0; 189 | } 190 | uint8_t MAX7219GridComponent::printf(const char *format, ...) { 191 | va_list arg; 192 | va_start(arg, format); 193 | char buffer[64]; 194 | int ret = vsnprintf(buffer, sizeof(buffer), format, arg); 195 | va_end(arg); 196 | if (ret > 0) 197 | return this->print(buffer); 198 | return 0; 199 | } 200 | void MAX7219GridComponent::set_writer(max7219_writer_t &&writer) { 201 | this->writer_ = writer; 202 | } 203 | void MAX7219GridComponent::set_intensity(uint8_t intensity) { 204 | this->intensity_ = intensity; 205 | } 206 | void MAX7219GridComponent::set_num_chips(uint8_t num_chips) { 207 | this->num_chips_ = num_chips; 208 | } 209 | 210 | #ifdef USE_TIME 211 | uint8_t MAX7219GridComponent::strftime(uint8_t pos, const char *format, time::ESPTime time) { 212 | char buffer[64]; 213 | size_t ret = time.strftime(buffer, sizeof(buffer), format); 214 | if (ret > 0) 215 | return this->print(pos, buffer); 216 | return 0; 217 | } 218 | uint8_t MAX7219GridComponent::strftime(const char *format, time::ESPTime time) { 219 | return this->strftime(0, format, time); 220 | } 221 | #endif 222 | 223 | } // namespace display 224 | 225 | ESPHOME_NAMESPACE_END 226 | --------------------------------------------------------------------------------