From f402fb2eadc050d057af47d8229ddf101936d69b Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Fri, 4 Aug 2017 23:31:25 -0600 Subject: [PATCH 01/26] copied algernon's LED Stalker effect as a code base --- .gitignore | 4 + .travis.yml | 21 + COPYING | 674 +++++++++++++++++++++++++++ Makefile | 13 + README.md | 87 ++++ examples/LED-Stalker/LED-Stalker.ino | 54 +++ library.properties | 10 + src/Kaleidoscope-LED-Stalker.h | 21 + src/Kaleidoscope/LED-Stalker.cpp | 140 ++++++ src/Kaleidoscope/LED-Stalker.h | 72 +++ 10 files changed, 1096 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 COPYING create mode 100644 Makefile create mode 100644 README.md create mode 100644 examples/LED-Stalker/LED-Stalker.ino create mode 100644 library.properties create mode 100644 src/Kaleidoscope-LED-Stalker.h create mode 100644 src/Kaleidoscope/LED-Stalker.cpp create mode 100644 src/Kaleidoscope/LED-Stalker.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..be16c9be --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.#* +*~ +/hardware/ +/output/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..e7030acf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +dist: trusty +sudo: false +os: + - linux +install: + - git clone --depth 1 --recurse-submodules https://github.com/keyboardio/Arduino-Boards hardware/keyboardio/avr +script: + - make travis-test BOARD_HARDWARE_PATH=$(pwd)/hardware +notifications: + irc: + channels: + - "chat.freenode.net#keyboardio" + use_notice: true + skip_join: true + template: + - "%{repository_name}/%{branch} %{commit} by %{author}: %{commit_subject} %{build_url} %{message}" + email: + on_success: change + on_failure: change +cache: + ccache: true diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..2b04143a --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +# This stub makefile for a Kaleidoscope plugin pulls in +# all targets from the Kaleidoscope-Plugin library + +MAKEFILE_PREFIX=keyboardio/avr/libraries/Kaleidoscope-Plugin/build +UNAME_S := $(shell uname -s) + +ifeq ($(UNAME_S),Darwin) +BOARD_HARDWARE_PATH ?= $(HOME)/Documents/Arduino/hardware +else +BOARD_HARDWARE_PATH ?= $(HOME)/Arduino/hardware +endif + +include $(BOARD_HARDWARE_PATH)/$(MAKEFILE_PREFIX)/rules.mk diff --git a/README.md b/README.md new file mode 100644 index 00000000..6ffdec09 --- /dev/null +++ b/README.md @@ -0,0 +1,87 @@ +# Kaleidoscope-LED-Stalker + +![status][st:experimental] [![Build Status][travis:image]][travis:status] + + [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Stalker.svg?branch=master + [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Stalker + + [st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52 + [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 + [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 + +The `StalkerEffect` plugin provides an interesting new typing experience: the +LEDs light up as you tap keys and play one of the selected effects: a haunting +trail of ghostly white lights, or a blazing trail of fire. + +## Using the plugin + +To use the plugin, one needs to include the header and select the effect. + +```c++ +#include +#include + +void setup (){ + Kaleidoscope.use(&StalkerEffect); + + Kaleidoscope.setup(); + + StalkerEffect.variant = STALKER(Haunt, (CRGB(0, 128, 0))); + StalkerEffect.activate(); +} +``` + +It is recommended to place the activation of the plugin (the `USE_PLUGINS` call) +as early as possible, so the plugin can catch all relevant key presses. The +configuration can happen at any time and should use the `STALKER` macro to do so. + +## Plugin methods + +The plugin provides the `StalkerEffect` object, which has the following +properties: + +### `.variant` + +> Set the effect to use with the plugin. See below for a list. +> +> It is recommended to use the `STALKER` macro to declare the effect itself. + +### `.stepLength` + +> The length - in milliseconds - of each step of the animation. An animation +> lasts 256 steps. +> +> Defaults to 50. + +## Plugin helpers + +### `STALKER(effect, params)` + +> Returns an effect, to be used to assign a value the `.variant` property of the +> `StalkerEffect` object. Any arguments given to the macro are passed on +> to the effect. If the effect takes no arguments, use an empty `params` list. + +## Plugin effects + +The plugin provides the following effects: + +### `Haunt([color])` + +> A ghostly haunt effect, that trails the key taps with a ghostly white color +> (or any other color, if specified). Use the `CRGB(r,g,b)` macro to specify the +> color, if you want something else than the ghostly white. + +### `BlazingTrail()` + +> A blazing trail of fire will follow our fingers! + +## Dependencies + +* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) + +## Further reading + +Starting from the [example][plugin:example] is the recommended way of getting +started with the plugin. + + [plugin:example]: https://github.com/keyboardio/Kaleidoscope-LED-Stalker/blob/master/examples/LED-Stalker/LED-Stalker.ino diff --git a/examples/LED-Stalker/LED-Stalker.ino b/examples/LED-Stalker/LED-Stalker.ino new file mode 100644 index 00000000..bbab98f8 --- /dev/null +++ b/examples/LED-Stalker/LED-Stalker.ino @@ -0,0 +1,54 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them + * Copyright (C) 2017 Gergely Nagy + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include "LED-Off.h" + +const Key keymaps[][ROWS][COLS] PROGMEM = { + [0] = KEYMAP_STACKED + ( + Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, + Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, + Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, + Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, + + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, + Key_NoKey, + + Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip, + Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, + Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, + Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, + + Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, + Key_NoKey), +}; + +void setup() { + Kaleidoscope.use(&LEDOff, &StalkerEffect); + + Kaleidoscope.setup(); + + StalkerEffect.variant = STALKER(BlazingTrail); + StalkerEffect.activate(); +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/library.properties b/library.properties new file mode 100644 index 00000000..8c121e5d --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=Kaleidoscope-LED-Stalker +version=0.0.0 +author=Gergely Nagy +maintainer=Gergely Nagy +sentence=Stalk keys pressed by lighting up and fading back the LED under them. +paragraph=Stalk keys pressed by lighting up and fading back the LED under them. +category=Communication +url=https://github.com/keyboardio/Kaleidoscope-LED-Stalker +architectures=avr +dot_a_linkage=true diff --git a/src/Kaleidoscope-LED-Stalker.h b/src/Kaleidoscope-LED-Stalker.h new file mode 100644 index 00000000..e9c84797 --- /dev/null +++ b/src/Kaleidoscope-LED-Stalker.h @@ -0,0 +1,21 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them + * Copyright (C) 2017 Gergely Nagy + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include diff --git a/src/Kaleidoscope/LED-Stalker.cpp b/src/Kaleidoscope/LED-Stalker.cpp new file mode 100644 index 00000000..b3d40029 --- /dev/null +++ b/src/Kaleidoscope/LED-Stalker.cpp @@ -0,0 +1,140 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them + * Copyright (C) 2017 Gergely Nagy + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +namespace kaleidoscope { + +uint8_t StalkerEffect::map_[ROWS][COLS]; +StalkerEffect::ColorComputer *StalkerEffect::variant; +uint16_t StalkerEffect::step_length = 50; +uint32_t StalkerEffect::step_end_time_; + +StalkerEffect::StalkerEffect(void) { +} + +void StalkerEffect::begin(void) { + event_handler_hook_use(eventHandlerHook); + LEDMode::begin(); +} + +void StalkerEffect::init(void) { + memset(map_, 0, sizeof(map_)); +} + +Key StalkerEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { + if (row >= ROWS || col >= COLS) + return mapped_key; + + if (keyIsPressed(key_state)) { + map_[row][col] = 0xff; + } + + return mapped_key; +} + +void StalkerEffect::update(void) { + if (!variant) + return; + + bool time_out = millis() >= step_end_time_; + + for (byte r = 0; r < ROWS; r++) { + for (byte c = 0; c < COLS; c++) { + uint8_t step = map_[r][c]; + if (step) { + LEDControl.setCrgbAt(r, c, variant->compute(&step)); + } + + bool was_zero = (map_[r][c] == 0); + + if (time_out) { + map_[r][c] = step; + } + + if (!was_zero && !map_[r][c]) + LEDControl.setCrgbAt(r, c, (cRGB) { + 0, 0, 0 + }); + } + } + + if (time_out) + step_end_time_ = millis() + step_length; +} + +namespace stalker { + +cRGB Haunt::highlight_color_; + +// Haunt +Haunt::Haunt(const cRGB highlight_color) { + highlight_color_ = highlight_color; +} + +cRGB Haunt::compute(uint8_t *step) { + cRGB color = CRGB((uint8_t)min(*step * highlight_color_.r / 255, 255), + (uint8_t)min(*step * highlight_color_.g / 255, 255), + (uint8_t)min(*step * highlight_color_.b / 255, 255)); + + if (*step >= 0xf0) + *step -= 1; + else if (*step >= 0x40) + *step -= 16; + else if (*step >= 32) + *step -= 32; + else + *step = 0; + + return color; +} + +// BlazingTrail +BlazingTrail::BlazingTrail(void) { +} + +cRGB BlazingTrail::compute(uint8_t *step) { + cRGB color; + + if (*step >= 0xff - 30) { + color = hsvToRgb(0xff - *step, 255, 255); + } else { + color = hsvToRgb(30, 255, 255); + + color.r = min(*step * color.r / 255, 255); + color.g = min(*step * color.g / 255, 255); + } + + if (*step >= 0xf0 - 30) + *step -= 1; + else if (*step >= 0x40) + *step -= 16; + else if (*step >= 32) + *step -= 32; + else + *step = 0; + + return color; +} + +} + +} + +kaleidoscope::StalkerEffect StalkerEffect; diff --git a/src/Kaleidoscope/LED-Stalker.h b/src/Kaleidoscope/LED-Stalker.h new file mode 100644 index 00000000..f4764b11 --- /dev/null +++ b/src/Kaleidoscope/LED-Stalker.h @@ -0,0 +1,72 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them + * Copyright (C) 2017 Gergely Nagy + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include +#include + +#define STALKER(v, ...) ({static kaleidoscope::stalker::v _effect __VA_ARGS__; &_effect;}) + +namespace kaleidoscope { +class StalkerEffect : public LEDMode { + public: + class ColorComputer { + public: + virtual cRGB compute(uint8_t *step) = 0; + }; + + StalkerEffect(void); + + void begin(void) final; + void init(void) final; + void update(void) final; + + static ColorComputer *variant; + static uint16_t step_length; + + private: + static uint32_t step_end_time_; + static uint8_t map_[ROWS][COLS]; + + static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); +}; + +namespace stalker { + +class Haunt : public StalkerEffect::ColorComputer { + public: + explicit Haunt(const cRGB highlight_color); + Haunt(void) : Haunt(CRGB(0x40, 0x80, 0x80)) {} + + cRGB compute(uint8_t *step) final; + private: + static cRGB highlight_color_; +}; + +class BlazingTrail : public StalkerEffect::ColorComputer { + public: + BlazingTrail(void); + + cRGB compute(uint8_t *step) final; +}; + +} +} + +extern kaleidoscope::StalkerEffect StalkerEffect; From b0f6e350d38558c7228f1bda0dc4c0c319337e75 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Fri, 4 Aug 2017 23:34:55 -0600 Subject: [PATCH 02/26] Early working version of wavepool effect... is buggy. --- README.md | 28 +- .../LED-Wavepool.ino} | 12 +- library.properties | 8 +- ...-Stalker.h => Kaleidoscope-LED-Wavepool.h} | 6 +- src/Kaleidoscope/LED-Stalker.cpp | 140 --------- src/Kaleidoscope/LED-Wavepool.cpp | 287 ++++++++++++++++++ .../{LED-Stalker.h => LED-Wavepool.h} | 34 ++- 7 files changed, 338 insertions(+), 177 deletions(-) rename examples/{LED-Stalker/LED-Stalker.ino => LED-Wavepool/LED-Wavepool.ino} (84%) rename src/{Kaleidoscope-LED-Stalker.h => Kaleidoscope-LED-Wavepool.h} (79%) delete mode 100644 src/Kaleidoscope/LED-Stalker.cpp create mode 100644 src/Kaleidoscope/LED-Wavepool.cpp rename src/Kaleidoscope/{LED-Stalker.h => LED-Wavepool.h} (65%) diff --git a/README.md b/README.md index 6ffdec09..1c97f4d7 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ -# Kaleidoscope-LED-Stalker +# Kaleidoscope-LED-Wavepool ![status][st:experimental] [![Build Status][travis:image]][travis:status] - [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Stalker.svg?branch=master - [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Stalker + [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Wavepool.svg?branch=master + [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Wavepool [st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52 [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 -The `StalkerEffect` plugin provides an interesting new typing experience: the +The `WavepoolEffect` plugin provides an interesting new typing experience: the LEDs light up as you tap keys and play one of the selected effects: a haunting trail of ghostly white lights, or a blazing trail of fire. @@ -19,32 +19,32 @@ To use the plugin, one needs to include the header and select the effect. ```c++ #include -#include +#include void setup (){ - Kaleidoscope.use(&StalkerEffect); + Kaleidoscope.use(&WavepoolEffect); Kaleidoscope.setup(); - StalkerEffect.variant = STALKER(Haunt, (CRGB(0, 128, 0))); - StalkerEffect.activate(); + WavepoolEffect.variant = WAVEPOOL(Haunt, (CRGB(0, 128, 0))); + WavepoolEffect.activate(); } ``` It is recommended to place the activation of the plugin (the `USE_PLUGINS` call) as early as possible, so the plugin can catch all relevant key presses. The -configuration can happen at any time and should use the `STALKER` macro to do so. +configuration can happen at any time and should use the `WAVEPOOL` macro to do so. ## Plugin methods -The plugin provides the `StalkerEffect` object, which has the following +The plugin provides the `WavepoolEffect` object, which has the following properties: ### `.variant` > Set the effect to use with the plugin. See below for a list. > -> It is recommended to use the `STALKER` macro to declare the effect itself. +> It is recommended to use the `WAVEPOOL` macro to declare the effect itself. ### `.stepLength` @@ -55,10 +55,10 @@ properties: ## Plugin helpers -### `STALKER(effect, params)` +### `WAVEPOOL(effect, params)` > Returns an effect, to be used to assign a value the `.variant` property of the -> `StalkerEffect` object. Any arguments given to the macro are passed on +> `WavepoolEffect` object. Any arguments given to the macro are passed on > to the effect. If the effect takes no arguments, use an empty `params` list. ## Plugin effects @@ -84,4 +84,4 @@ The plugin provides the following effects: Starting from the [example][plugin:example] is the recommended way of getting started with the plugin. - [plugin:example]: https://github.com/keyboardio/Kaleidoscope-LED-Stalker/blob/master/examples/LED-Stalker/LED-Stalker.ino + [plugin:example]: https://github.com/keyboardio/Kaleidoscope-LED-Wavepool/blob/master/examples/LED-Wavepool/LED-Wavepool.ino diff --git a/examples/LED-Stalker/LED-Stalker.ino b/examples/LED-Wavepool/LED-Wavepool.ino similarity index 84% rename from examples/LED-Stalker/LED-Stalker.ino rename to examples/LED-Wavepool/LED-Wavepool.ino index bbab98f8..e257a2e9 100644 --- a/examples/LED-Stalker/LED-Stalker.ino +++ b/examples/LED-Wavepool/LED-Wavepool.ino @@ -1,6 +1,6 @@ /* -*- mode: c++ -*- - * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them - * Copyright (C) 2017 Gergely Nagy + * Kaleidoscope-LED-Wavepool + * Copyright (C) 2017 Selene Scriven * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ */ #include -#include +#include #include "LED-Off.h" const Key keymaps[][ROWS][COLS] PROGMEM = { @@ -41,12 +41,12 @@ const Key keymaps[][ROWS][COLS] PROGMEM = { }; void setup() { - Kaleidoscope.use(&LEDOff, &StalkerEffect); + Kaleidoscope.use(&LEDOff, &WavepoolEffect); Kaleidoscope.setup(); - StalkerEffect.variant = STALKER(BlazingTrail); - StalkerEffect.activate(); + WavepoolEffect.variant = WAVEPOOL(BlazingTrail); + WavepoolEffect.activate(); } void loop() { diff --git a/library.properties b/library.properties index 8c121e5d..02674a0b 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ -name=Kaleidoscope-LED-Stalker +name=Kaleidoscope-LED-Wavepool version=0.0.0 author=Gergely Nagy maintainer=Gergely Nagy -sentence=Stalk keys pressed by lighting up and fading back the LED under them. -paragraph=Stalk keys pressed by lighting up and fading back the LED under them. +sentence=Splash water on each keypress. +paragraph=Splash water on each keypress. category=Communication -url=https://github.com/keyboardio/Kaleidoscope-LED-Stalker +url=https://github.com/keyboardio/Kaleidoscope-LED-Wavepool architectures=avr dot_a_linkage=true diff --git a/src/Kaleidoscope-LED-Stalker.h b/src/Kaleidoscope-LED-Wavepool.h similarity index 79% rename from src/Kaleidoscope-LED-Stalker.h rename to src/Kaleidoscope-LED-Wavepool.h index e9c84797..6cce33e5 100644 --- a/src/Kaleidoscope-LED-Stalker.h +++ b/src/Kaleidoscope-LED-Wavepool.h @@ -1,6 +1,6 @@ /* -*- mode: c++ -*- - * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them - * Copyright (C) 2017 Gergely Nagy + * Kaleidoscope-LED-Wavepool + * Copyright (C) 2017 Selene Scriven * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,4 +18,4 @@ #pragma once -#include +#include diff --git a/src/Kaleidoscope/LED-Stalker.cpp b/src/Kaleidoscope/LED-Stalker.cpp deleted file mode 100644 index b3d40029..00000000 --- a/src/Kaleidoscope/LED-Stalker.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- mode: c++ -*- - * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them - * Copyright (C) 2017 Gergely Nagy - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -namespace kaleidoscope { - -uint8_t StalkerEffect::map_[ROWS][COLS]; -StalkerEffect::ColorComputer *StalkerEffect::variant; -uint16_t StalkerEffect::step_length = 50; -uint32_t StalkerEffect::step_end_time_; - -StalkerEffect::StalkerEffect(void) { -} - -void StalkerEffect::begin(void) { - event_handler_hook_use(eventHandlerHook); - LEDMode::begin(); -} - -void StalkerEffect::init(void) { - memset(map_, 0, sizeof(map_)); -} - -Key StalkerEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { - if (row >= ROWS || col >= COLS) - return mapped_key; - - if (keyIsPressed(key_state)) { - map_[row][col] = 0xff; - } - - return mapped_key; -} - -void StalkerEffect::update(void) { - if (!variant) - return; - - bool time_out = millis() >= step_end_time_; - - for (byte r = 0; r < ROWS; r++) { - for (byte c = 0; c < COLS; c++) { - uint8_t step = map_[r][c]; - if (step) { - LEDControl.setCrgbAt(r, c, variant->compute(&step)); - } - - bool was_zero = (map_[r][c] == 0); - - if (time_out) { - map_[r][c] = step; - } - - if (!was_zero && !map_[r][c]) - LEDControl.setCrgbAt(r, c, (cRGB) { - 0, 0, 0 - }); - } - } - - if (time_out) - step_end_time_ = millis() + step_length; -} - -namespace stalker { - -cRGB Haunt::highlight_color_; - -// Haunt -Haunt::Haunt(const cRGB highlight_color) { - highlight_color_ = highlight_color; -} - -cRGB Haunt::compute(uint8_t *step) { - cRGB color = CRGB((uint8_t)min(*step * highlight_color_.r / 255, 255), - (uint8_t)min(*step * highlight_color_.g / 255, 255), - (uint8_t)min(*step * highlight_color_.b / 255, 255)); - - if (*step >= 0xf0) - *step -= 1; - else if (*step >= 0x40) - *step -= 16; - else if (*step >= 32) - *step -= 32; - else - *step = 0; - - return color; -} - -// BlazingTrail -BlazingTrail::BlazingTrail(void) { -} - -cRGB BlazingTrail::compute(uint8_t *step) { - cRGB color; - - if (*step >= 0xff - 30) { - color = hsvToRgb(0xff - *step, 255, 255); - } else { - color = hsvToRgb(30, 255, 255); - - color.r = min(*step * color.r / 255, 255); - color.g = min(*step * color.g / 255, 255); - } - - if (*step >= 0xf0 - 30) - *step -= 1; - else if (*step >= 0x40) - *step -= 16; - else if (*step >= 32) - *step -= 32; - else - *step = 0; - - return color; -} - -} - -} - -kaleidoscope::StalkerEffect StalkerEffect; diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp new file mode 100644 index 00000000..9793c0b9 --- /dev/null +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -0,0 +1,287 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LED-Wavepool + * Copyright (C) 2017 Selene Scriven + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +namespace kaleidoscope { + +int8_t WavepoolEffect::map_[2][WP_WID*WP_HGT]; +uint8_t WavepoolEffect::page = 0; +WavepoolEffect::ColorComputer *WavepoolEffect::variant; +uint16_t WavepoolEffect::step_length = 50; +uint32_t WavepoolEffect::step_end_time_; +uint8_t WavepoolEffect::frames_since_event = 0; +uint8_t WavepoolEffect::positions[WP_HGT*WP_WID] = { + 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 64, 64, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 22, 25, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 37, 40, 58, 59, 60, 61, 62, 63, + 64, 64, 7, 23, 39, 55, 54, 57, 56, 40, 24, 8, 64, 64, +}; +uint8_t WavepoolEffect::rc2pos[ROWS*COLS] = { + 0, 1, 2, 3, 4, 5, 6, 58, 67, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 34, 59, 66, 35, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 48, 60, 65, 49, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 62,61,63,64, 50, 51, 52, 53, 54, 55, +}; + +WavepoolEffect::WavepoolEffect(void) { +} + +void WavepoolEffect::begin(void) { + event_handler_hook_use(eventHandlerHook); + LEDMode::begin(); +} + +void WavepoolEffect::init(void) { + memset(map_, 0, sizeof(map_)); +} + +Key WavepoolEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { + if (row >= ROWS || col >= COLS) + return mapped_key; + + if (keyIsPressed(key_state)) { + uint8_t offset = (row*COLS)+col; + map_[page][rc2pos[offset]] = 0x7f; + frames_since_event = 0; + } + + return mapped_key; +} + +void WavepoolEffect::update(void) { + + // limit the frame rate; one frame every 64 ms + static uint8_t prev_time = 0; + uint8_t now = (millis()>>6) % 0xff; + if (now != prev_time) { + prev_time = now; + } else { + return; + } + + // rotate the colors over time + // (side note: it's weird that this is a 16-bit int instead of 8-bit, + // but that's what the library function wants) + //static uint16_t current_hue = 0; + //current_hue ++; + //current_hue &= 0xff; + static uint8_t current_hue = 0; + current_hue ++; + + frames_since_event ++; + + // needs two pages of height map to do the calculations + int8_t *newpg = &map_[page^1][0]; + int8_t *oldpg = &map_[page][0]; + + // rain a bit while idle + if ((frames_since_event & 0x1f) == 0x1f) { + uint8_t x = rand() % WP_WID; + uint8_t y = rand() % WP_HGT; + uint8_t rainspot = (y*WP_WID) + x; + oldpg[rainspot] = 0x7f; + if (y > 0) oldpg[rainspot-WP_WID] = 0x50; + if (y < (WP_HGT-1)) oldpg[rainspot+WP_WID] = 0x50; + if (x > 0) oldpg[rainspot-1] = 0x50; + if (x < (WP_WID-1)) oldpg[rainspot+1] = 0x50; + } + + // calculate water movement + //for (uint8_t y = 1; y < WP_HGT-1; y++) { + // for (uint8_t x = 1; x < WP_WID-1; x++) { + for (uint8_t y = 0; y < WP_HGT; y++) { + for (uint8_t x = 0; x < WP_WID; x++) { + uint8_t offset = (y*WP_WID) + x; + + /* + int8_t value; + int8_t offsets[] = { -WP_WID, WP_WID, -1, 1, }; + if (y==0) offsets[0] = 0; + else if (y==WP_HGT-1) offsets[1] = 0; + if (x==0) offsets[2] = 0; + else if (x==WP_WID-1) offsets[3] = 0; + + value = ((oldpg[offset + offsets[0]] + +oldpg[offset + offsets[1]] + +oldpg[offset + offsets[2]] + +oldpg[offset + offsets[3]] + ) >> 1) + - newpg[offset]; + */ + + int16_t value; + int8_t offsets[] = { -WP_WID, WP_WID, -1, 1, + -WP_WID-1, -WP_WID+1, + WP_WID-1, WP_WID+1 + }; + if (y==0) { + offsets[0] = 0; + offsets[4] = 0; + offsets[5] = 0; + } + else if (y==WP_HGT-1) { + offsets[1] = 0; + offsets[6] = 0; + offsets[7] = 0; + } + if (x==0) { + offsets[2] = 0; + offsets[4] = 0; + offsets[6] = 0; + } + else if (x==WP_WID-1) { + offsets[3] = 0; + offsets[5] = 0; + offsets[7] = 0; + } + + value = ((oldpg[offset + offsets[0]] + +oldpg[offset + offsets[1]] + +oldpg[offset + offsets[2]] + +oldpg[offset + offsets[3]] + +oldpg[offset + offsets[4]] + +oldpg[offset + offsets[5]] + +oldpg[offset + offsets[6]] + +oldpg[offset + offsets[7]] + ) >> 2) + - newpg[offset]; + + //value = oldpg[offset]; + //if (value > 0) value --; + //oldpg[offset] = value; + //newpg[offset] = value; + newpg[offset] = value - (value >> 3); + } + } + + for (byte r = 0; r < ROWS; r++) { + for (byte c = 0; c < COLS; c++) { + uint8_t offset = (r*COLS) + c; + int8_t value = oldpg[rc2pos[offset]]; + uint8_t step; + /* + if (value < 0) step = 0; + else step = value; + step <<= 1; + */ + //step = value; + //LEDControl.setCrgbAt(r, c, CRGB(step,step,step)); + + cRGB color; + + uint16_t intensity; + if (value >= 0) intensity = value * 2; + else intensity = (-value) * 2; + color = hsvToRgb(current_hue + (uint16_t)value + (uint16_t)value, + 0xff - intensity, + (intensity*5)/3); + + LEDControl.setCrgbAt(r, c, color); + //LEDControl.setCrgbAt(r, c, variant->compute(&step)); + /* + if (offset == (now & 63)) { + LEDControl.setCrgbAt(r, c, CRGB(100,100,100)); + } else { + LEDControl.setCrgbAt(r, c, CRGB(0,0,0)); + } + */ + } + } + + page ^= 1; + +} + +namespace wavepool { + +cRGB Haunt::highlight_color_; + +// Haunt +Haunt::Haunt(const cRGB highlight_color) { + highlight_color_ = highlight_color; +} + +cRGB Haunt::compute(uint8_t *step) { + cRGB color = CRGB((uint8_t)min(*step * highlight_color_.r / 255, 255), + (uint8_t)min(*step * highlight_color_.g / 255, 255), + (uint8_t)min(*step * highlight_color_.b / 255, 255)); + + if (*step >= 0xf0) + *step -= 1; + else if (*step >= 0x40) + *step -= 16; + else if (*step >= 32) + *step -= 32; + else + *step = 0; + + return color; +} + +// BlazingTrail +BlazingTrail::BlazingTrail(void) { +} + +cRGB BlazingTrail::compute(uint8_t *step) { + cRGB color; + + if (*step >= 0xff - 30) { + color = hsvToRgb(0xff - *step, 255, 255); + } else { + color = hsvToRgb(30, 255, 255); + + color.r = min(*step * color.r / 255, 255); + color.g = min(*step * color.g / 255, 255); + } + + if (*step >= 0xf0 - 30) + *step -= 1; + else if (*step >= 0x40) + *step -= 16; + else if (*step >= 32) + *step -= 32; + else + *step = 0; + + return color; +} + +// Rainbow +Rainbow::Rainbow(void) { +} + +cRGB Rainbow::compute(uint8_t *step) { + cRGB color; + + uint8_t intensity; + if ((*step) <= 127) intensity = (*step) * 2; + else intensity = (255 - (*step)) * 2; + color = hsvToRgb(intensity, + 0xff - intensity, + intensity); + + return color; +} +} + +} + +kaleidoscope::WavepoolEffect WavepoolEffect; diff --git a/src/Kaleidoscope/LED-Stalker.h b/src/Kaleidoscope/LED-Wavepool.h similarity index 65% rename from src/Kaleidoscope/LED-Stalker.h rename to src/Kaleidoscope/LED-Wavepool.h index f4764b11..b0133ecc 100644 --- a/src/Kaleidoscope/LED-Stalker.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -1,6 +1,6 @@ /* -*- mode: c++ -*- - * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them - * Copyright (C) 2017 Gergely Nagy + * Kaleidoscope-LED-Wavepool + * Copyright (C) 2017 Selene Scriven * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,17 +21,20 @@ #include #include -#define STALKER(v, ...) ({static kaleidoscope::stalker::v _effect __VA_ARGS__; &_effect;}) +#define WAVEPOOL(v, ...) ({static kaleidoscope::wavepool::v _effect __VA_ARGS__; &_effect;}) + +#define WP_WID 14 +#define WP_HGT 5 namespace kaleidoscope { -class StalkerEffect : public LEDMode { +class WavepoolEffect : public LEDMode { public: class ColorComputer { public: virtual cRGB compute(uint8_t *step) = 0; }; - StalkerEffect(void); + WavepoolEffect(void); void begin(void) final; void init(void) final; @@ -41,15 +44,19 @@ class StalkerEffect : public LEDMode { static uint16_t step_length; private: + static uint8_t frames_since_event; static uint32_t step_end_time_; - static uint8_t map_[ROWS][COLS]; + static int8_t map_[2][WP_WID*WP_HGT]; + static uint8_t page; + static uint8_t positions[WP_HGT*WP_WID]; + static uint8_t rc2pos[ROWS*COLS]; static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); }; -namespace stalker { +namespace wavepool { -class Haunt : public StalkerEffect::ColorComputer { +class Haunt : public WavepoolEffect::ColorComputer { public: explicit Haunt(const cRGB highlight_color); Haunt(void) : Haunt(CRGB(0x40, 0x80, 0x80)) {} @@ -59,14 +66,21 @@ class Haunt : public StalkerEffect::ColorComputer { static cRGB highlight_color_; }; -class BlazingTrail : public StalkerEffect::ColorComputer { +class BlazingTrail : public WavepoolEffect::ColorComputer { public: BlazingTrail(void); cRGB compute(uint8_t *step) final; }; +class Rainbow : public WavepoolEffect::ColorComputer { + public: + Rainbow(void); + + cRGB compute(uint8_t *step) final; +}; + } } -extern kaleidoscope::StalkerEffect StalkerEffect; +extern kaleidoscope::WavepoolEffect WavepoolEffect; From d2002565bd79ffaffb9cc34d27edbbbd2ad126c2 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Fri, 4 Aug 2017 23:47:31 -0600 Subject: [PATCH 03/26] cleaned out dead code --- src/Kaleidoscope/LED-Wavepool.cpp | 118 ++---------------------------- src/Kaleidoscope/LED-Wavepool.h | 31 -------- 2 files changed, 6 insertions(+), 143 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 9793c0b9..e39b320e 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -23,9 +23,6 @@ namespace kaleidoscope { int8_t WavepoolEffect::map_[2][WP_WID*WP_HGT]; uint8_t WavepoolEffect::page = 0; -WavepoolEffect::ColorComputer *WavepoolEffect::variant; -uint16_t WavepoolEffect::step_length = 50; -uint32_t WavepoolEffect::step_end_time_; uint8_t WavepoolEffect::frames_since_event = 0; uint8_t WavepoolEffect::positions[WP_HGT*WP_WID] = { 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, @@ -111,27 +108,12 @@ void WavepoolEffect::update(void) { for (uint8_t x = 0; x < WP_WID; x++) { uint8_t offset = (y*WP_WID) + x; - /* - int8_t value; - int8_t offsets[] = { -WP_WID, WP_WID, -1, 1, }; - if (y==0) offsets[0] = 0; - else if (y==WP_HGT-1) offsets[1] = 0; - if (x==0) offsets[2] = 0; - else if (x==WP_WID-1) offsets[3] = 0; - - value = ((oldpg[offset + offsets[0]] - +oldpg[offset + offsets[1]] - +oldpg[offset + offsets[2]] - +oldpg[offset + offsets[3]] - ) >> 1) - - newpg[offset]; - */ - int16_t value; int8_t offsets[] = { -WP_WID, WP_WID, -1, 1, -WP_WID-1, -WP_WID+1, WP_WID-1, WP_WID+1 }; + // don't wrap around edges or go out of bounds if (y==0) { offsets[0] = 0; offsets[4] = 0; @@ -164,10 +146,6 @@ void WavepoolEffect::update(void) { ) >> 2) - newpg[offset]; - //value = oldpg[offset]; - //if (value > 0) value --; - //oldpg[offset] = value; - //newpg[offset] = value; newpg[offset] = value - (value >> 3); } } @@ -176,112 +154,28 @@ void WavepoolEffect::update(void) { for (byte c = 0; c < COLS; c++) { uint8_t offset = (r*COLS) + c; int8_t value = oldpg[rc2pos[offset]]; - uint8_t step; - /* - if (value < 0) step = 0; - else step = value; - step <<= 1; - */ - //step = value; - //LEDControl.setCrgbAt(r, c, CRGB(step,step,step)); cRGB color; - uint16_t intensity; + + // intensity = abs(value) * 2 if (value >= 0) intensity = value * 2; else intensity = (-value) * 2; + // color starts white but gets dimmer and more saturated as it fades, + // with hue wobbling according to height map color = hsvToRgb(current_hue + (uint16_t)value + (uint16_t)value, 0xff - intensity, (intensity*5)/3); LEDControl.setCrgbAt(r, c, color); - //LEDControl.setCrgbAt(r, c, variant->compute(&step)); - /* - if (offset == (now & 63)) { - LEDControl.setCrgbAt(r, c, CRGB(100,100,100)); - } else { - LEDControl.setCrgbAt(r, c, CRGB(0,0,0)); - } - */ } } + // swap pages every frame page ^= 1; } -namespace wavepool { - -cRGB Haunt::highlight_color_; - -// Haunt -Haunt::Haunt(const cRGB highlight_color) { - highlight_color_ = highlight_color; -} - -cRGB Haunt::compute(uint8_t *step) { - cRGB color = CRGB((uint8_t)min(*step * highlight_color_.r / 255, 255), - (uint8_t)min(*step * highlight_color_.g / 255, 255), - (uint8_t)min(*step * highlight_color_.b / 255, 255)); - - if (*step >= 0xf0) - *step -= 1; - else if (*step >= 0x40) - *step -= 16; - else if (*step >= 32) - *step -= 32; - else - *step = 0; - - return color; -} - -// BlazingTrail -BlazingTrail::BlazingTrail(void) { -} - -cRGB BlazingTrail::compute(uint8_t *step) { - cRGB color; - - if (*step >= 0xff - 30) { - color = hsvToRgb(0xff - *step, 255, 255); - } else { - color = hsvToRgb(30, 255, 255); - - color.r = min(*step * color.r / 255, 255); - color.g = min(*step * color.g / 255, 255); - } - - if (*step >= 0xf0 - 30) - *step -= 1; - else if (*step >= 0x40) - *step -= 16; - else if (*step >= 32) - *step -= 32; - else - *step = 0; - - return color; -} - -// Rainbow -Rainbow::Rainbow(void) { -} - -cRGB Rainbow::compute(uint8_t *step) { - cRGB color; - - uint8_t intensity; - if ((*step) <= 127) intensity = (*step) * 2; - else intensity = (255 - (*step)) * 2; - color = hsvToRgb(intensity, - 0xff - intensity, - intensity); - - return color; -} -} - } kaleidoscope::WavepoolEffect WavepoolEffect; diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index b0133ecc..2a991d9e 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -40,12 +40,8 @@ class WavepoolEffect : public LEDMode { void init(void) final; void update(void) final; - static ColorComputer *variant; - static uint16_t step_length; - private: static uint8_t frames_since_event; - static uint32_t step_end_time_; static int8_t map_[2][WP_WID*WP_HGT]; static uint8_t page; static uint8_t positions[WP_HGT*WP_WID]; @@ -54,33 +50,6 @@ class WavepoolEffect : public LEDMode { static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); }; -namespace wavepool { - -class Haunt : public WavepoolEffect::ColorComputer { - public: - explicit Haunt(const cRGB highlight_color); - Haunt(void) : Haunt(CRGB(0x40, 0x80, 0x80)) {} - - cRGB compute(uint8_t *step) final; - private: - static cRGB highlight_color_; -}; - -class BlazingTrail : public WavepoolEffect::ColorComputer { - public: - BlazingTrail(void); - - cRGB compute(uint8_t *step) final; -}; - -class Rainbow : public WavepoolEffect::ColorComputer { - public: - Rainbow(void); - - cRGB compute(uint8_t *step) final; -}; - -} } extern kaleidoscope::WavepoolEffect WavepoolEffect; From a3c6f022bfda23cfa2ce8d797808546dce63caa3 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Fri, 4 Aug 2017 23:53:11 -0600 Subject: [PATCH 04/26] fixed bug where upper corners could get stuck --- src/Kaleidoscope/LED-Wavepool.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index e39b320e..1a35ec60 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -116,23 +116,23 @@ void WavepoolEffect::update(void) { // don't wrap around edges or go out of bounds if (y==0) { offsets[0] = 0; - offsets[4] = 0; - offsets[5] = 0; + offsets[4] += WP_WID; + offsets[5] += WP_WID; } else if (y==WP_HGT-1) { offsets[1] = 0; - offsets[6] = 0; - offsets[7] = 0; + offsets[6] -= WP_WID; + offsets[7] -= WP_WID; } if (x==0) { offsets[2] = 0; - offsets[4] = 0; - offsets[6] = 0; + offsets[4] += 1; + offsets[6] += 1; } else if (x==WP_WID-1) { offsets[3] = 0; - offsets[5] = 0; - offsets[7] = 0; + offsets[5] -= 1; + offsets[7] -= 1; } value = ((oldpg[offset + offsets[0]] From 32a0809929032ea88f8983b62a5299fbe5d2ab96 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 00:15:51 -0600 Subject: [PATCH 05/26] moved logical position of Fn keys, disabled old code --- src/Kaleidoscope/LED-Wavepool.cpp | 24 ++++++++++++++++++------ src/Kaleidoscope/LED-Wavepool.h | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 1a35ec60..83d7c837 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -24,6 +24,8 @@ namespace kaleidoscope { int8_t WavepoolEffect::map_[2][WP_WID*WP_HGT]; uint8_t WavepoolEffect::page = 0; uint8_t WavepoolEffect::frames_since_event = 0; +/* unused +// map geometric space (14x5) into native keyboard coordinates (16x4) uint8_t WavepoolEffect::positions[WP_HGT*WP_WID] = { 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 64, 64, 26, 27, 28, 29, 30, 31, @@ -31,11 +33,13 @@ uint8_t WavepoolEffect::positions[WP_HGT*WP_WID] = { 48, 49, 50, 51, 52, 53, 37, 40, 58, 59, 60, 61, 62, 63, 64, 64, 7, 23, 39, 55, 54, 57, 56, 40, 24, 8, 64, 64, }; +*/ +// map native keyboard coordinates (16x4) into geometric space (14x5) uint8_t WavepoolEffect::rc2pos[ROWS*COLS] = { - 0, 1, 2, 3, 4, 5, 6, 58, 67, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 34, 59, 66, 35, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 48, 60, 65, 49, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 62,61,63,64, 50, 51, 52, 53, 54, 55, + 0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 58,62, 63,67, 50, 51, 52, 53, 54, 55, }; WavepoolEffect::WavepoolEffect(void) { @@ -90,10 +94,15 @@ void WavepoolEffect::update(void) { int8_t *oldpg = &map_[page][0]; // rain a bit while idle - if ((frames_since_event & 0x1f) == 0x1f) { + static uint8_t frames_till_next_drop = 20; + if (frames_since_event >= frames_till_next_drop) { + frames_till_next_drop = rand() & 0x3f; + frames_since_event = 0; + uint8_t x = rand() % WP_WID; uint8_t y = rand() % WP_HGT; uint8_t rainspot = (y*WP_WID) + x; + oldpg[rainspot] = 0x7f; if (y > 0) oldpg[rainspot-WP_WID] = 0x50; if (y < (WP_HGT-1)) oldpg[rainspot+WP_WID] = 0x50; @@ -102,6 +111,7 @@ void WavepoolEffect::update(void) { } // calculate water movement + // (originally skipped edges, but this keyboard is too small for that) //for (uint8_t y = 1; y < WP_HGT-1; y++) { // for (uint8_t x = 1; x < WP_WID-1; x++) { for (uint8_t y = 0; y < WP_HGT; y++) { @@ -109,7 +119,8 @@ void WavepoolEffect::update(void) { uint8_t offset = (y*WP_WID) + x; int16_t value; - int8_t offsets[] = { -WP_WID, WP_WID, -1, 1, + int8_t offsets[] = { -WP_WID, WP_WID, + -1, 1, -WP_WID-1, -WP_WID+1, WP_WID-1, WP_WID+1 }; @@ -150,6 +161,7 @@ void WavepoolEffect::update(void) { } } + // draw the water on the keys for (byte r = 0; r < ROWS; r++) { for (byte c = 0; c < COLS; c++) { uint8_t offset = (r*COLS) + c; diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index 2a991d9e..77a207cc 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -44,7 +44,7 @@ class WavepoolEffect : public LEDMode { static uint8_t frames_since_event; static int8_t map_[2][WP_WID*WP_HGT]; static uint8_t page; - static uint8_t positions[WP_HGT*WP_WID]; + //static uint8_t positions[WP_HGT*WP_WID]; // unused static uint8_t rc2pos[ROWS*COLS]; static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); From 8cc00c119e94e06de45edb4f782cdd324087cb4e Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 00:33:39 -0600 Subject: [PATCH 06/26] updated README and example --- README.md | 44 ++------------------------ examples/LED-Wavepool/LED-Wavepool.ino | 1 - 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 1c97f4d7..f51048da 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,8 @@ [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 -The `WavepoolEffect` plugin provides an interesting new typing experience: the -LEDs light up as you tap keys and play one of the selected effects: a haunting -trail of ghostly white lights, or a blazing trail of fire. +The `WavepoolEffect` plugin makes waves of light splash out from each keypress. +When idle, it will also simulate gentle rainfall on the keyboard. ## Using the plugin @@ -26,55 +25,18 @@ void setup (){ Kaleidoscope.setup(); - WavepoolEffect.variant = WAVEPOOL(Haunt, (CRGB(0, 128, 0))); WavepoolEffect.activate(); } ``` It is recommended to place the activation of the plugin (the `USE_PLUGINS` call) -as early as possible, so the plugin can catch all relevant key presses. The -configuration can happen at any time and should use the `WAVEPOOL` macro to do so. +as early as possible, so the plugin can catch all relevant key presses. ## Plugin methods The plugin provides the `WavepoolEffect` object, which has the following properties: -### `.variant` - -> Set the effect to use with the plugin. See below for a list. -> -> It is recommended to use the `WAVEPOOL` macro to declare the effect itself. - -### `.stepLength` - -> The length - in milliseconds - of each step of the animation. An animation -> lasts 256 steps. -> -> Defaults to 50. - -## Plugin helpers - -### `WAVEPOOL(effect, params)` - -> Returns an effect, to be used to assign a value the `.variant` property of the -> `WavepoolEffect` object. Any arguments given to the macro are passed on -> to the effect. If the effect takes no arguments, use an empty `params` list. - -## Plugin effects - -The plugin provides the following effects: - -### `Haunt([color])` - -> A ghostly haunt effect, that trails the key taps with a ghostly white color -> (or any other color, if specified). Use the `CRGB(r,g,b)` macro to specify the -> color, if you want something else than the ghostly white. - -### `BlazingTrail()` - -> A blazing trail of fire will follow our fingers! - ## Dependencies * [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) diff --git a/examples/LED-Wavepool/LED-Wavepool.ino b/examples/LED-Wavepool/LED-Wavepool.ino index e257a2e9..96f78f7b 100644 --- a/examples/LED-Wavepool/LED-Wavepool.ino +++ b/examples/LED-Wavepool/LED-Wavepool.ino @@ -45,7 +45,6 @@ void setup() { Kaleidoscope.setup(); - WavepoolEffect.variant = WAVEPOOL(BlazingTrail); WavepoolEffect.activate(); } From 485366553f89b1753dab68d6c434190f7089883c Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 00:41:57 -0600 Subject: [PATCH 07/26] made the LEDs a little brighter --- src/Kaleidoscope/LED-Wavepool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 83d7c837..dea177f4 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -177,7 +177,7 @@ void WavepoolEffect::update(void) { // with hue wobbling according to height map color = hsvToRgb(current_hue + (uint16_t)value + (uint16_t)value, 0xff - intensity, - (intensity*5)/3); + intensity*2); LEDControl.setCrgbAt(r, c, color); } From 9634776622f37210766687d2d326cbb638b40656 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 19:53:28 -0600 Subject: [PATCH 08/26] Oops, forgot to change the author/maintainer info. --- library.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library.properties b/library.properties index 02674a0b..c454ae76 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=Kaleidoscope-LED-Wavepool version=0.0.0 -author=Gergely Nagy -maintainer=Gergely Nagy +author=Selene Scriven +maintainer=Selene Scriven sentence=Splash water on each keypress. paragraph=Splash water on each keypress. category=Communication -url=https://github.com/keyboardio/Kaleidoscope-LED-Wavepool +url=https://github.com/ToyKeeper/Kaleidoscope-LED-Wavepool architectures=avr dot_a_linkage=true From 6e5a10a1c34a61f055f0855dd03cfbc1d99988ab Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 19:55:13 -0600 Subject: [PATCH 09/26] Added 'idle_timeout' config option. Moved reference table(s) to ROM. Removed a bit more dead code. --- README.md | 10 +++++++ src/Kaleidoscope/LED-Wavepool.cpp | 47 ++++++++++++++++--------------- src/Kaleidoscope/LED-Wavepool.h | 16 ++++------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index f51048da..879d9375 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ void setup (){ Kaleidoscope.setup(); + WavepoolEffect.idle_timeout = 5000; // 5 seconds WavepoolEffect.activate(); } ``` @@ -37,6 +38,15 @@ as early as possible, so the plugin can catch all relevant key presses. The plugin provides the `WavepoolEffect` object, which has the following properties: +### `.idle_timeout` + +> When to keys are being pressed, light will periodically splash across +> the keyboard. This value sets the delay in ms before that starts. +> +> To disable the idle animation entirely, set this to 0. +> +> Default is 5000 (5 seconds). + ## Dependencies * [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index dea177f4..66b21571 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -21,12 +21,13 @@ namespace kaleidoscope { -int8_t WavepoolEffect::map_[2][WP_WID*WP_HGT]; +int8_t WavepoolEffect::surface[2][WP_WID*WP_HGT]; uint8_t WavepoolEffect::page = 0; uint8_t WavepoolEffect::frames_since_event = 0; +uint16_t WavepoolEffect::idle_timeout = 5000; // 5 seconds /* unused // map geometric space (14x5) into native keyboard coordinates (16x4) -uint8_t WavepoolEffect::positions[WP_HGT*WP_WID] = { +PROGMEM const uint8_t WavepoolEffect::positions[WP_HGT*WP_WID] = { 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 64, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 22, 25, 42, 43, 44, 45, 46, 47, @@ -35,7 +36,7 @@ uint8_t WavepoolEffect::positions[WP_HGT*WP_WID] = { }; */ // map native keyboard coordinates (16x4) into geometric space (14x5) -uint8_t WavepoolEffect::rc2pos[ROWS*COLS] = { +PROGMEM const uint8_t WavepoolEffect::rc2pos[ROWS*COLS] = { 0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41, @@ -51,7 +52,7 @@ void WavepoolEffect::begin(void) { } void WavepoolEffect::init(void) { - memset(map_, 0, sizeof(map_)); + memset(surface, 0, sizeof(surface)); } Key WavepoolEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { @@ -60,7 +61,7 @@ Key WavepoolEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t if (keyIsPressed(key_state)) { uint8_t offset = (row*COLS)+col; - map_[page][rc2pos[offset]] = 0x7f; + surface[page][pgm_read_byte(rc2pos + offset)] = 0x7f; frames_since_event = 0; } @@ -90,24 +91,26 @@ void WavepoolEffect::update(void) { frames_since_event ++; // needs two pages of height map to do the calculations - int8_t *newpg = &map_[page^1][0]; - int8_t *oldpg = &map_[page][0]; + int8_t *newpg = &surface[page^1][0]; + int8_t *oldpg = &surface[page][0]; // rain a bit while idle - static uint8_t frames_till_next_drop = 20; - if (frames_since_event >= frames_till_next_drop) { - frames_till_next_drop = rand() & 0x3f; - frames_since_event = 0; - - uint8_t x = rand() % WP_WID; - uint8_t y = rand() % WP_HGT; - uint8_t rainspot = (y*WP_WID) + x; - - oldpg[rainspot] = 0x7f; - if (y > 0) oldpg[rainspot-WP_WID] = 0x50; - if (y < (WP_HGT-1)) oldpg[rainspot+WP_WID] = 0x50; - if (x > 0) oldpg[rainspot-1] = 0x50; - if (x < (WP_WID-1)) oldpg[rainspot+1] = 0x50; + static uint8_t frames_till_next_drop = 0; + if (idle_timeout > 0) { + if (frames_since_event >= (frames_till_next_drop + (idle_timeout >> 6))) { + frames_till_next_drop = rand() & 0x3f; + frames_since_event = idle_timeout >> 6; + + uint8_t x = rand() % WP_WID; + uint8_t y = rand() % WP_HGT; + uint8_t rainspot = (y*WP_WID) + x; + + oldpg[rainspot] = 0x7f; + if (y > 0) oldpg[rainspot-WP_WID] = 0x50; + if (y < (WP_HGT-1)) oldpg[rainspot+WP_WID] = 0x50; + if (x > 0) oldpg[rainspot-1] = 0x50; + if (x < (WP_WID-1)) oldpg[rainspot+1] = 0x50; + } } // calculate water movement @@ -165,7 +168,7 @@ void WavepoolEffect::update(void) { for (byte r = 0; r < ROWS; r++) { for (byte c = 0; c < COLS; c++) { uint8_t offset = (r*COLS) + c; - int8_t value = oldpg[rc2pos[offset]]; + int8_t value = oldpg[pgm_read_byte(rc2pos+offset)]; cRGB color; uint16_t intensity; diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index 77a207cc..e00cfa54 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -21,31 +21,27 @@ #include #include -#define WAVEPOOL(v, ...) ({static kaleidoscope::wavepool::v _effect __VA_ARGS__; &_effect;}) - #define WP_WID 14 #define WP_HGT 5 namespace kaleidoscope { class WavepoolEffect : public LEDMode { public: - class ColorComputer { - public: - virtual cRGB compute(uint8_t *step) = 0; - }; - WavepoolEffect(void); void begin(void) final; void init(void) final; void update(void) final; + // ms before idle animation starts after last keypress + static uint16_t idle_timeout; + private: static uint8_t frames_since_event; - static int8_t map_[2][WP_WID*WP_HGT]; + static int8_t surface[2][WP_WID*WP_HGT]; static uint8_t page; - //static uint8_t positions[WP_HGT*WP_WID]; // unused - static uint8_t rc2pos[ROWS*COLS]; + //static PROGMEM const uint8_t positions[WP_HGT*WP_WID]; // unused + static PROGMEM const uint8_t rc2pos[ROWS*COLS]; static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); }; From 11c643bba820f11d69020a7a41af298e1f047adf Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 20:02:30 -0600 Subject: [PATCH 10/26] Removed more dead code. --- src/Kaleidoscope/LED-Wavepool.cpp | 4 ---- src/Kaleidoscope/LED-Wavepool.h | 1 - 2 files changed, 5 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 66b21571..413854ba 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -51,10 +51,6 @@ void WavepoolEffect::begin(void) { LEDMode::begin(); } -void WavepoolEffect::init(void) { - memset(surface, 0, sizeof(surface)); -} - Key WavepoolEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { if (row >= ROWS || col >= COLS) return mapped_key; diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index e00cfa54..6c9929f6 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -30,7 +30,6 @@ class WavepoolEffect : public LEDMode { WavepoolEffect(void); void begin(void) final; - void init(void) final; void update(void) final; // ms before idle animation starts after last keypress From e45ffa7735082f80d2a1d774d0746b1f2e308a4f Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 20:09:56 -0600 Subject: [PATCH 11/26] Fixed link in the documentation so it'll be clickable on github. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 879d9375..b2776b62 100644 --- a/README.md +++ b/README.md @@ -56,4 +56,4 @@ properties: Starting from the [example][plugin:example] is the recommended way of getting started with the plugin. - [plugin:example]: https://github.com/keyboardio/Kaleidoscope-LED-Wavepool/blob/master/examples/LED-Wavepool/LED-Wavepool.ino + [plugin:example]: https://github.com/ToyKeeper/Kaleidoscope-LED-Wavepool/blob/master/examples/LED-Wavepool/LED-Wavepool.ino From dde7e6a0d091deb2c2b38fb4003d8fa793d17b1b Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 20:12:17 -0600 Subject: [PATCH 12/26] Forgot to update the example earlier. --- examples/LED-Wavepool/LED-Wavepool.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/LED-Wavepool/LED-Wavepool.ino b/examples/LED-Wavepool/LED-Wavepool.ino index 96f78f7b..2e79039d 100644 --- a/examples/LED-Wavepool/LED-Wavepool.ino +++ b/examples/LED-Wavepool/LED-Wavepool.ino @@ -45,6 +45,7 @@ void setup() { Kaleidoscope.setup(); + WavepoolEffect.idle_timeout = 5000; // 5 seconds WavepoolEffect.activate(); } From 61b5086eb472498ef2f227a735e845e9c1216dca Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 21:09:00 -0600 Subject: [PATCH 13/26] Fixed bug with missing red hues in color rotation. Also made colors a bit less erratic and somewhat more coherent. --- src/Kaleidoscope/LED-Wavepool.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 413854ba..8394e989 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -166,15 +166,18 @@ void WavepoolEffect::update(void) { uint8_t offset = (r*COLS) + c; int8_t value = oldpg[pgm_read_byte(rc2pos+offset)]; - cRGB color; uint16_t intensity; + intensity = abs(value) * 2; + if (intensity > 254) intensity = 254; - // intensity = abs(value) * 2 - if (value >= 0) intensity = value * 2; - else intensity = (-value) * 2; // color starts white but gets dimmer and more saturated as it fades, // with hue wobbling according to height map - color = hsvToRgb(current_hue + (uint16_t)value + (uint16_t)value, + int16_t hue = current_hue; + hue = hue + value + (value>>1); + hue = hue & 0xff; + + cRGB color; + color = hsvToRgb(hue, 0xff - intensity, intensity*2); From e2808220e5c57c46088217b531833249f1e27a41 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 21:41:23 -0600 Subject: [PATCH 14/26] Made idle animation produce somewhat deeper raindrops. (makes idle mode look a little more like a human tapping random keys) --- src/Kaleidoscope/LED-Wavepool.cpp | 28 +++++++++++++++++++++------- src/Kaleidoscope/LED-Wavepool.h | 1 + 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 8394e989..7264624b 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -64,6 +64,16 @@ Key WavepoolEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t return mapped_key; } +void WavepoolEffect::raindrop(uint8_t x, uint8_t y, int8_t *page) { + uint8_t rainspot = (y*WP_WID) + x; + + page[rainspot] = 0x7f; + if (y > 0) page[rainspot-WP_WID] = 0x60; + if (y < (WP_HGT-1)) page[rainspot+WP_WID] = 0x60; + if (x > 0) page[rainspot-1] = 0x60; + if (x < (WP_WID-1)) page[rainspot+1] = 0x60; +} + void WavepoolEffect::update(void) { // limit the frame rate; one frame every 64 ms @@ -92,20 +102,24 @@ void WavepoolEffect::update(void) { // rain a bit while idle static uint8_t frames_till_next_drop = 0; + static int8_t prev_x = -1; + static int8_t prev_y = -1; if (idle_timeout > 0) { + // repeat previous raindrop to give it a slightly better effect + if (prev_x >= 0) { + raindrop(prev_x, prev_y, oldpg); + prev_x = prev_y = -1; + } if (frames_since_event >= (frames_till_next_drop + (idle_timeout >> 6))) { - frames_till_next_drop = rand() & 0x3f; + frames_till_next_drop = 4 + (rand() & 0x3f); frames_since_event = idle_timeout >> 6; uint8_t x = rand() % WP_WID; uint8_t y = rand() % WP_HGT; - uint8_t rainspot = (y*WP_WID) + x; + raindrop(x, y, oldpg); - oldpg[rainspot] = 0x7f; - if (y > 0) oldpg[rainspot-WP_WID] = 0x50; - if (y < (WP_HGT-1)) oldpg[rainspot+WP_WID] = 0x50; - if (x > 0) oldpg[rainspot-1] = 0x50; - if (x < (WP_WID-1)) oldpg[rainspot+1] = 0x50; + prev_x = x; + prev_y = y; } } diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index 6c9929f6..28440075 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -43,6 +43,7 @@ class WavepoolEffect : public LEDMode { static PROGMEM const uint8_t rc2pos[ROWS*COLS]; static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); + static void raindrop(uint8_t x, uint8_t y, int8_t *page); }; } From d4af1ff2f5ab9f55b31ee59467fb86d618be5640 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Sat, 5 Aug 2017 23:20:53 -0600 Subject: [PATCH 15/26] Made Wavepool mode smaller in ROM. (about 300 bytes smaller) Most of this came from replacing rand(). The rest mostly came from smaller height field calculation logic. Also some other small changes which don't seem to make much difference visually. --- src/Kaleidoscope/LED-Wavepool.cpp | 64 +++++++++++++++---------------- src/Kaleidoscope/LED-Wavepool.h | 1 + 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 7264624b..152e0bc5 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -21,6 +21,8 @@ namespace kaleidoscope { +#define MS_PER_FRAME_POW2 6 // one frame every 64 ms + int8_t WavepoolEffect::surface[2][WP_WID*WP_HGT]; uint8_t WavepoolEffect::page = 0; uint8_t WavepoolEffect::frames_since_event = 0; @@ -74,11 +76,19 @@ void WavepoolEffect::raindrop(uint8_t x, uint8_t y, int8_t *page) { if (x < (WP_WID-1)) page[rainspot+1] = 0x60; } +// this is a lot smaller than the standard library's rand(), +// and still looks random-ish +uint8_t WavepoolEffect::wp_rand() { + static uint16_t offset = 0x400; + offset = ((offset + 1) & 0x4fff) | 0x400; + return (millis()>>MS_PER_FRAME_POW2) + pgm_read_byte(offset); +} + void WavepoolEffect::update(void) { // limit the frame rate; one frame every 64 ms static uint8_t prev_time = 0; - uint8_t now = (millis()>>6) % 0xff; + uint8_t now = (millis()>>MS_PER_FRAME_POW2) % 0xff; if (now != prev_time) { prev_time = now; } else { @@ -88,9 +98,6 @@ void WavepoolEffect::update(void) { // rotate the colors over time // (side note: it's weird that this is a 16-bit int instead of 8-bit, // but that's what the library function wants) - //static uint16_t current_hue = 0; - //current_hue ++; - //current_hue &= 0xff; static uint8_t current_hue = 0; current_hue ++; @@ -110,12 +117,14 @@ void WavepoolEffect::update(void) { raindrop(prev_x, prev_y, oldpg); prev_x = prev_y = -1; } - if (frames_since_event >= (frames_till_next_drop + (idle_timeout >> 6))) { - frames_till_next_drop = 4 + (rand() & 0x3f); - frames_since_event = idle_timeout >> 6; - - uint8_t x = rand() % WP_WID; - uint8_t y = rand() % WP_HGT; + if (frames_since_event + >= (frames_till_next_drop + + (idle_timeout >> MS_PER_FRAME_POW2))) { + frames_till_next_drop = 4 + (wp_rand() & 0x3f); + frames_since_event = idle_timeout >> MS_PER_FRAME_POW2; + + uint8_t x = wp_rand() % WP_WID; + uint8_t y = wp_rand() % WP_HGT; raindrop(x, y, oldpg); prev_x = x; @@ -159,17 +168,13 @@ void WavepoolEffect::update(void) { offsets[7] -= 1; } - value = ((oldpg[offset + offsets[0]] - +oldpg[offset + offsets[1]] - +oldpg[offset + offsets[2]] - +oldpg[offset + offsets[3]] - +oldpg[offset + offsets[4]] - +oldpg[offset + offsets[5]] - +oldpg[offset + offsets[6]] - +oldpg[offset + offsets[7]] - ) >> 2) - - newpg[offset]; + // add up all samples, divide, subtract prev frame's center + int8_t *p; + for(p=offsets, value=0; p> 2) - newpg[offset]; + // reduce intensity gradually over time newpg[offset] = value - (value >> 3); } } @@ -178,22 +183,17 @@ void WavepoolEffect::update(void) { for (byte r = 0; r < ROWS; r++) { for (byte c = 0; c < COLS; c++) { uint8_t offset = (r*COLS) + c; - int8_t value = oldpg[pgm_read_byte(rc2pos+offset)]; + int8_t height = oldpg[pgm_read_byte(rc2pos+offset)]; - uint16_t intensity; - intensity = abs(value) * 2; - if (intensity > 254) intensity = 254; + uint8_t intensity = abs(height) * 2; // color starts white but gets dimmer and more saturated as it fades, // with hue wobbling according to height map - int16_t hue = current_hue; - hue = hue + value + (value>>1); - hue = hue & 0xff; - - cRGB color; - color = hsvToRgb(hue, - 0xff - intensity, - intensity*2); + int16_t hue = (current_hue + height + (height>>1)) & 0xff; + + cRGB color = hsvToRgb(hue, + 0xff - intensity, + ((uint16_t)intensity)*2); LEDControl.setCrgbAt(r, c, color); } diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index 28440075..3d8d3d14 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -44,6 +44,7 @@ class WavepoolEffect : public LEDMode { static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); static void raindrop(uint8_t x, uint8_t y, int8_t *page); + static uint8_t wp_rand(); }; } From b026f565235aa58f97bbd2f52ef4ab31bfb3bb8b Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Thu, 10 Aug 2017 22:54:15 -0600 Subject: [PATCH 16/26] Added tweening / frame interpolation for smoother movement. Made frame duration easier to fine-tune. (default 25 fps) --- src/Kaleidoscope/LED-Wavepool.cpp | 49 +++++++++++++++++++++---------- src/Kaleidoscope/LED-Wavepool.h | 1 - 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 152e0bc5..4df7476c 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -21,22 +21,15 @@ namespace kaleidoscope { -#define MS_PER_FRAME_POW2 6 // one frame every 64 ms +#define INTERPOLATE // smoother, slower animation +#define MS_PER_FRAME 40 // 40 = 25 fps +#define FRAMES_PER_DROP 120 // max time between raindrops during idle animation int8_t WavepoolEffect::surface[2][WP_WID*WP_HGT]; uint8_t WavepoolEffect::page = 0; uint8_t WavepoolEffect::frames_since_event = 0; uint16_t WavepoolEffect::idle_timeout = 5000; // 5 seconds -/* unused -// map geometric space (14x5) into native keyboard coordinates (16x4) -PROGMEM const uint8_t WavepoolEffect::positions[WP_HGT*WP_WID] = { - 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 64, 64, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 22, 25, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 37, 40, 58, 59, 60, 61, 62, 63, - 64, 64, 7, 23, 39, 55, 54, 57, 56, 40, 24, 8, 64, 64, -}; -*/ + // map native keyboard coordinates (16x4) into geometric space (14x5) PROGMEM const uint8_t WavepoolEffect::rc2pos[ROWS*COLS] = { 0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13, @@ -81,14 +74,14 @@ void WavepoolEffect::raindrop(uint8_t x, uint8_t y, int8_t *page) { uint8_t WavepoolEffect::wp_rand() { static uint16_t offset = 0x400; offset = ((offset + 1) & 0x4fff) | 0x400; - return (millis()>>MS_PER_FRAME_POW2) + pgm_read_byte(offset); + return (millis()/MS_PER_FRAME) + pgm_read_byte(offset); } void WavepoolEffect::update(void) { // limit the frame rate; one frame every 64 ms static uint8_t prev_time = 0; - uint8_t now = (millis()>>MS_PER_FRAME_POW2) % 0xff; + uint8_t now = millis() / MS_PER_FRAME; if (now != prev_time) { prev_time = now; } else { @@ -111,7 +104,14 @@ void WavepoolEffect::update(void) { static uint8_t frames_till_next_drop = 0; static int8_t prev_x = -1; static int8_t prev_y = -1; + #ifdef INTERPOLATE + // even frames: water movement and page flipping + // odd frames: raindrops and tweening + // (this arrangement seems to look best overall) + if (((now & 1)) && (idle_timeout > 0)) { + #else if (idle_timeout > 0) { + #endif // repeat previous raindrop to give it a slightly better effect if (prev_x >= 0) { raindrop(prev_x, prev_y, oldpg); @@ -119,9 +119,9 @@ void WavepoolEffect::update(void) { } if (frames_since_event >= (frames_till_next_drop - + (idle_timeout >> MS_PER_FRAME_POW2))) { - frames_till_next_drop = 4 + (wp_rand() & 0x3f); - frames_since_event = idle_timeout >> MS_PER_FRAME_POW2; + + (idle_timeout / MS_PER_FRAME))) { + frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP); + frames_since_event = idle_timeout / MS_PER_FRAME; uint8_t x = wp_rand() % WP_WID; uint8_t y = wp_rand() % WP_HGT; @@ -136,6 +136,9 @@ void WavepoolEffect::update(void) { // (originally skipped edges, but this keyboard is too small for that) //for (uint8_t y = 1; y < WP_HGT-1; y++) { // for (uint8_t x = 1; x < WP_WID-1; x++) { + #ifdef INTERPOLATE + if (!(now & 1)) { // even frames only + #endif for (uint8_t y = 0; y < WP_HGT; y++) { for (uint8_t x = 0; x < WP_WID; x++) { uint8_t offset = (y*WP_WID) + x; @@ -178,12 +181,21 @@ void WavepoolEffect::update(void) { newpg[offset] = value - (value >> 3); } } + #ifdef INTERPOLATE + } + #endif // draw the water on the keys for (byte r = 0; r < ROWS; r++) { for (byte c = 0; c < COLS; c++) { uint8_t offset = (r*COLS) + c; int8_t height = oldpg[pgm_read_byte(rc2pos+offset)]; + #ifdef INTERPOLATE + if (now & 1) { // odd frames only + // average height with other frame + height = ((int16_t)height + newpg[pgm_read_byte(rc2pos+offset)]) >> 1; + } + #endif uint8_t intensity = abs(height) * 2; @@ -199,8 +211,13 @@ void WavepoolEffect::update(void) { } } + #ifdef INTERPOLATE + // swap pages every other frame + if (!(now & 1)) page ^= 1; + #else // swap pages every frame page ^= 1; + #endif } diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index 3d8d3d14..102f2f8a 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -39,7 +39,6 @@ class WavepoolEffect : public LEDMode { static uint8_t frames_since_event; static int8_t surface[2][WP_WID*WP_HGT]; static uint8_t page; - //static PROGMEM const uint8_t positions[WP_HGT*WP_WID]; // unused static PROGMEM const uint8_t rc2pos[ROWS*COLS]; static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); From ddd7ce47f71dd9ae4b2a5db997cacafecaf3203c Mon Sep 17 00:00:00 2001 From: "kaleidoscope@gergo.csillger.hu" Date: Tue, 15 Aug 2017 23:06:50 +0200 Subject: [PATCH 17/26] Updated to use the new LEDMode/LEDControl API Signed-off-by: kaleidoscope@gergo.csillger.hu --- src/Kaleidoscope/LED-Wavepool.cpp | 7 +++---- src/Kaleidoscope/LED-Wavepool.h | 7 ++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 152e0bc5..29dd84b0 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -48,9 +48,8 @@ PROGMEM const uint8_t WavepoolEffect::rc2pos[ROWS*COLS] = { WavepoolEffect::WavepoolEffect(void) { } -void WavepoolEffect::begin(void) { - event_handler_hook_use(eventHandlerHook); - LEDMode::begin(); +void WavepoolEffect::setup(void) { + Kaleidoscope.useEventHandlerHook(eventHandlerHook); } Key WavepoolEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { @@ -195,7 +194,7 @@ void WavepoolEffect::update(void) { 0xff - intensity, ((uint16_t)intensity)*2); - LEDControl.setCrgbAt(r, c, color); + ::LEDControl.setCrgbAt(r, c, color); } } diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index 3d8d3d14..082b03d5 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -29,12 +29,13 @@ class WavepoolEffect : public LEDMode { public: WavepoolEffect(void); - void begin(void) final; - void update(void) final; - // ms before idle animation starts after last keypress static uint16_t idle_timeout; + protected: + void setup(void) final; + void update(void) final; + private: static uint8_t frames_since_event; static int8_t surface[2][WP_WID*WP_HGT]; From 4d58d3e6a3b85e4204cb978c1698961c5eb8462a Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 13 Aug 2018 20:51:19 -0400 Subject: [PATCH 18/26] Update plugin interface to be compatible with newer Keyboardio API. --- src/Kaleidoscope/LED-Wavepool.cpp | 15 ++++----------- src/Kaleidoscope/LED-Wavepool.h | 6 +++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 24d90d32..4aa1b289 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -21,7 +21,7 @@ namespace kaleidoscope { -#define INTERPOLATE // smoother, slower animation +#define INTERPOLATE 1 // smoother, slower animation #define MS_PER_FRAME 40 // 40 = 25 fps #define FRAMES_PER_DROP 120 // max time between raindrops during idle animation @@ -38,16 +38,9 @@ PROGMEM const uint8_t WavepoolEffect::rc2pos[ROWS*COLS] = { 42, 43, 44, 45, 46, 47, 58,62, 63,67, 50, 51, 52, 53, 54, 55, }; -WavepoolEffect::WavepoolEffect(void) { -} - -void WavepoolEffect::setup(void) { - Kaleidoscope.useEventHandlerHook(eventHandlerHook); -} - -Key WavepoolEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { +EventHandlerResult WavepoolEffect::onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state) { if (row >= ROWS || col >= COLS) - return mapped_key; + return EventHandlerResult::OK; if (keyIsPressed(key_state)) { uint8_t offset = (row*COLS)+col; @@ -55,7 +48,7 @@ Key WavepoolEffect::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t frames_since_event = 0; } - return mapped_key; + return EventHandlerResult::OK; } void WavepoolEffect::raindrop(uint8_t x, uint8_t y, int8_t *page) { diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/Kaleidoscope/LED-Wavepool.h index a803cdd1..6c4af49a 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/Kaleidoscope/LED-Wavepool.h @@ -27,13 +27,14 @@ namespace kaleidoscope { class WavepoolEffect : public LEDMode { public: - WavepoolEffect(void); + WavepoolEffect(void) {}; + + EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state); // ms before idle animation starts after last keypress static uint16_t idle_timeout; protected: - void setup(void) final; void update(void) final; private: @@ -42,7 +43,6 @@ class WavepoolEffect : public LEDMode { static uint8_t page; static PROGMEM const uint8_t rc2pos[ROWS*COLS]; - static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); static void raindrop(uint8_t x, uint8_t y, int8_t *page); static uint8_t wp_rand(); }; From 00a48d52801b1e476cbb450d11e423abd12a9ab7 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 20 Dec 2018 06:22:00 +0100 Subject: [PATCH 19/26] Update to work with the latest Kaleidoscope Updated the Makefile, the example, and LED-Wavepool.cpp to work with the latest Kaleidoscope. Signed-off-by: Gergely Nagy --- Makefile | 9 +++++---- examples/LED-Wavepool/LED-Wavepool.ino | 10 +++++++--- src/Kaleidoscope/LED-Wavepool.cpp | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 2b04143a..8f830f44 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ # This stub makefile for a Kaleidoscope plugin pulls in # all targets from the Kaleidoscope-Plugin library -MAKEFILE_PREFIX=keyboardio/avr/libraries/Kaleidoscope-Plugin/build UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) -BOARD_HARDWARE_PATH ?= $(HOME)/Documents/Arduino/hardware +SKETCHBOOK_DIR ?= $(HOME)/Documents/Arduino/ else -BOARD_HARDWARE_PATH ?= $(HOME)/Arduino/hardware +SKETCHBOOK_DIR ?= $(HOME)/Arduino endif -include $(BOARD_HARDWARE_PATH)/$(MAKEFILE_PREFIX)/rules.mk +BOARD_HARDWARE_PATH ?= $(SKETCHBOOK_DIR)/hardware +KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= keyboardio/avr/build-tools/makefiles/ +include $(BOARD_HARDWARE_PATH)/$(KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR)/rules.mk diff --git a/examples/LED-Wavepool/LED-Wavepool.ino b/examples/LED-Wavepool/LED-Wavepool.ino index 2e79039d..66a103bc 100644 --- a/examples/LED-Wavepool/LED-Wavepool.ino +++ b/examples/LED-Wavepool/LED-Wavepool.ino @@ -17,8 +17,8 @@ */ #include +#include #include -#include "LED-Off.h" const Key keymaps[][ROWS][COLS] PROGMEM = { [0] = KEYMAP_STACKED @@ -40,9 +40,13 @@ const Key keymaps[][ROWS][COLS] PROGMEM = { Key_NoKey), }; -void setup() { - Kaleidoscope.use(&LEDOff, &WavepoolEffect); +KALEIDOSCOPE_INIT_PLUGINS( + LEDControl, + LEDOff, + WavepoolEffect +); +void setup() { Kaleidoscope.setup(); WavepoolEffect.idle_timeout = 5000; // 5 seconds diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/Kaleidoscope/LED-Wavepool.cpp index 4aa1b289..c4873c49 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/Kaleidoscope/LED-Wavepool.cpp @@ -17,7 +17,6 @@ */ #include -#include namespace kaleidoscope { From fd2327ee7c5a0669ec32d38b7894e68e9960a683 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 20 Dec 2018 06:27:43 +0100 Subject: [PATCH 20/26] Preparations for moving into the Kaleidoscope monorepo Signed-off-by: Gergely Nagy --- .gitignore | 4 - .travis.yml | 21 - COPYING | 674 ------------------ Makefile | 14 - README.md => doc/plugin/LED-Wavepool.md | 22 +- .../{ => LEDs}/LED-Wavepool/LED-Wavepool.ino | 0 library.properties | 10 - src/Kaleidoscope-LED-Wavepool.h | 2 +- .../plugin}/LED-Wavepool.cpp | 4 +- .../plugin}/LED-Wavepool.h | 4 +- 10 files changed, 14 insertions(+), 741 deletions(-) delete mode 100644 .gitignore delete mode 100644 .travis.yml delete mode 100644 COPYING delete mode 100644 Makefile rename README.md => doc/plugin/LED-Wavepool.md (50%) rename examples/{ => LEDs}/LED-Wavepool/LED-Wavepool.ino (100%) delete mode 100644 library.properties rename src/{Kaleidoscope => kaleidoscope/plugin}/LED-Wavepool.cpp (98%) rename src/{Kaleidoscope => kaleidoscope/plugin}/LED-Wavepool.h (94%) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index be16c9be..00000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.#* -*~ -/hardware/ -/output/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e7030acf..00000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -dist: trusty -sudo: false -os: - - linux -install: - - git clone --depth 1 --recurse-submodules https://github.com/keyboardio/Arduino-Boards hardware/keyboardio/avr -script: - - make travis-test BOARD_HARDWARE_PATH=$(pwd)/hardware -notifications: - irc: - channels: - - "chat.freenode.net#keyboardio" - use_notice: true - skip_join: true - template: - - "%{repository_name}/%{branch} %{commit} by %{author}: %{commit_subject} %{build_url} %{message}" - email: - on_success: change - on_failure: change -cache: - ccache: true diff --git a/COPYING b/COPYING deleted file mode 100644 index 94a9ed02..00000000 --- a/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Makefile b/Makefile deleted file mode 100644 index 8f830f44..00000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# This stub makefile for a Kaleidoscope plugin pulls in -# all targets from the Kaleidoscope-Plugin library - -UNAME_S := $(shell uname -s) - -ifeq ($(UNAME_S),Darwin) -SKETCHBOOK_DIR ?= $(HOME)/Documents/Arduino/ -else -SKETCHBOOK_DIR ?= $(HOME)/Arduino -endif - -BOARD_HARDWARE_PATH ?= $(SKETCHBOOK_DIR)/hardware -KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= keyboardio/avr/build-tools/makefiles/ -include $(BOARD_HARDWARE_PATH)/$(KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR)/rules.mk diff --git a/README.md b/doc/plugin/LED-Wavepool.md similarity index 50% rename from README.md rename to doc/plugin/LED-Wavepool.md index b2776b62..44a14796 100644 --- a/README.md +++ b/doc/plugin/LED-Wavepool.md @@ -1,14 +1,5 @@ # Kaleidoscope-LED-Wavepool -![status][st:experimental] [![Build Status][travis:image]][travis:status] - - [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Wavepool.svg?branch=master - [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Wavepool - - [st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52 - [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 - [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 - The `WavepoolEffect` plugin makes waves of light splash out from each keypress. When idle, it will also simulate gentle rainfall on the keyboard. @@ -18,11 +9,12 @@ To use the plugin, one needs to include the header and select the effect. ```c++ #include +#include #include -void setup (){ - Kaleidoscope.use(&WavepoolEffect); +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, WavepoolEffect); +void setup (){ Kaleidoscope.setup(); WavepoolEffect.idle_timeout = 5000; // 5 seconds @@ -30,8 +22,8 @@ void setup (){ } ``` -It is recommended to place the activation of the plugin (the `USE_PLUGINS` call) -as early as possible, so the plugin can catch all relevant key presses. +It is recommended to place the activation of the plugin as early as possible, so +the plugin can catch all relevant key presses. ## Plugin methods @@ -49,11 +41,11 @@ properties: ## Dependencies -* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) +* [Kaleidoscope-LEDControl](LEDControl.md) ## Further reading Starting from the [example][plugin:example] is the recommended way of getting started with the plugin. - [plugin:example]: https://github.com/ToyKeeper/Kaleidoscope-LED-Wavepool/blob/master/examples/LED-Wavepool/LED-Wavepool.ino + [plugin:example]: ../../examples/LEDS/LED-Wavepool/LED-Wavepool.ino diff --git a/examples/LED-Wavepool/LED-Wavepool.ino b/examples/LEDs/LED-Wavepool/LED-Wavepool.ino similarity index 100% rename from examples/LED-Wavepool/LED-Wavepool.ino rename to examples/LEDs/LED-Wavepool/LED-Wavepool.ino diff --git a/library.properties b/library.properties deleted file mode 100644 index c454ae76..00000000 --- a/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=Kaleidoscope-LED-Wavepool -version=0.0.0 -author=Selene Scriven -maintainer=Selene Scriven -sentence=Splash water on each keypress. -paragraph=Splash water on each keypress. -category=Communication -url=https://github.com/ToyKeeper/Kaleidoscope-LED-Wavepool -architectures=avr -dot_a_linkage=true diff --git a/src/Kaleidoscope-LED-Wavepool.h b/src/Kaleidoscope-LED-Wavepool.h index 6cce33e5..093c1ef7 100644 --- a/src/Kaleidoscope-LED-Wavepool.h +++ b/src/Kaleidoscope-LED-Wavepool.h @@ -18,4 +18,4 @@ #pragma once -#include +#include diff --git a/src/Kaleidoscope/LED-Wavepool.cpp b/src/kaleidoscope/plugin/LED-Wavepool.cpp similarity index 98% rename from src/Kaleidoscope/LED-Wavepool.cpp rename to src/kaleidoscope/plugin/LED-Wavepool.cpp index c4873c49..dabf41d9 100644 --- a/src/Kaleidoscope/LED-Wavepool.cpp +++ b/src/kaleidoscope/plugin/LED-Wavepool.cpp @@ -19,6 +19,7 @@ #include namespace kaleidoscope { +namespace plugin { #define INTERPOLATE 1 // smoother, slower animation #define MS_PER_FRAME 40 // 40 = 25 fps @@ -212,6 +213,7 @@ void WavepoolEffect::update(void) { } +} } -kaleidoscope::WavepoolEffect WavepoolEffect; +kaleidoscope::plugin::WavepoolEffect WavepoolEffect; diff --git a/src/Kaleidoscope/LED-Wavepool.h b/src/kaleidoscope/plugin/LED-Wavepool.h similarity index 94% rename from src/Kaleidoscope/LED-Wavepool.h rename to src/kaleidoscope/plugin/LED-Wavepool.h index 6c4af49a..beba6d63 100644 --- a/src/Kaleidoscope/LED-Wavepool.h +++ b/src/kaleidoscope/plugin/LED-Wavepool.h @@ -25,6 +25,7 @@ #define WP_HGT 5 namespace kaleidoscope { +namespace plugin { class WavepoolEffect : public LEDMode { public: WavepoolEffect(void) {}; @@ -47,6 +48,7 @@ class WavepoolEffect : public LEDMode { static uint8_t wp_rand(); }; +} } -extern kaleidoscope::WavepoolEffect WavepoolEffect; +extern kaleidoscope::plugin::WavepoolEffect WavepoolEffect; From 1228c52c1edfde3fa9135d9825c02ac0f57dfa2c Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 20 Dec 2018 06:35:00 +0100 Subject: [PATCH 21/26] LED-Wavepool: Make astyle happy Signed-off-by: Gergely Nagy --- examples/LEDs/LED-Wavepool/LED-Wavepool.ino | 6 +- src/kaleidoscope/plugin/LED-Wavepool.cpp | 140 ++++++++++---------- src/kaleidoscope/plugin/LED-Wavepool.h | 4 +- 3 files changed, 74 insertions(+), 76 deletions(-) diff --git a/examples/LEDs/LED-Wavepool/LED-Wavepool.ino b/examples/LEDs/LED-Wavepool/LED-Wavepool.ino index 66a103bc..430c9bd1 100644 --- a/examples/LEDs/LED-Wavepool/LED-Wavepool.ino +++ b/examples/LEDs/LED-Wavepool/LED-Wavepool.ino @@ -41,9 +41,9 @@ const Key keymaps[][ROWS][COLS] PROGMEM = { }; KALEIDOSCOPE_INIT_PLUGINS( - LEDControl, - LEDOff, - WavepoolEffect + LEDControl, + LEDOff, + WavepoolEffect ); void setup() { diff --git a/src/kaleidoscope/plugin/LED-Wavepool.cpp b/src/kaleidoscope/plugin/LED-Wavepool.cpp index dabf41d9..2c6d6b90 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.cpp +++ b/src/kaleidoscope/plugin/LED-Wavepool.cpp @@ -25,17 +25,17 @@ namespace plugin { #define MS_PER_FRAME 40 // 40 = 25 fps #define FRAMES_PER_DROP 120 // max time between raindrops during idle animation -int8_t WavepoolEffect::surface[2][WP_WID*WP_HGT]; +int8_t WavepoolEffect::surface[2][WP_WID * WP_HGT]; uint8_t WavepoolEffect::page = 0; uint8_t WavepoolEffect::frames_since_event = 0; uint16_t WavepoolEffect::idle_timeout = 5000; // 5 seconds // map native keyboard coordinates (16x4) into geometric space (14x5) -PROGMEM const uint8_t WavepoolEffect::rc2pos[ROWS*COLS] = { - 0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 58,62, 63,67, 50, 51, 52, 53, 54, 55, +PROGMEM const uint8_t WavepoolEffect::rc2pos[ROWS * COLS] = { + 0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 58, 62, 63, 67, 50, 51, 52, 53, 54, 55, }; EventHandlerResult WavepoolEffect::onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state) { @@ -43,7 +43,7 @@ EventHandlerResult WavepoolEffect::onKeyswitchEvent(Key &mapped_key, byte row, b return EventHandlerResult::OK; if (keyIsPressed(key_state)) { - uint8_t offset = (row*COLS)+col; + uint8_t offset = (row * COLS) + col; surface[page][pgm_read_byte(rc2pos + offset)] = 0x7f; frames_since_event = 0; } @@ -52,21 +52,21 @@ EventHandlerResult WavepoolEffect::onKeyswitchEvent(Key &mapped_key, byte row, b } void WavepoolEffect::raindrop(uint8_t x, uint8_t y, int8_t *page) { - uint8_t rainspot = (y*WP_WID) + x; + uint8_t rainspot = (y * WP_WID) + x; page[rainspot] = 0x7f; - if (y > 0) page[rainspot-WP_WID] = 0x60; - if (y < (WP_HGT-1)) page[rainspot+WP_WID] = 0x60; - if (x > 0) page[rainspot-1] = 0x60; - if (x < (WP_WID-1)) page[rainspot+1] = 0x60; + if (y > 0) page[rainspot - WP_WID] = 0x60; + if (y < (WP_HGT - 1)) page[rainspot + WP_WID] = 0x60; + if (x > 0) page[rainspot - 1] = 0x60; + if (x < (WP_WID - 1)) page[rainspot + 1] = 0x60; } // this is a lot smaller than the standard library's rand(), // and still looks random-ish uint8_t WavepoolEffect::wp_rand() { - static uint16_t offset = 0x400; - offset = ((offset + 1) & 0x4fff) | 0x400; - return (millis()/MS_PER_FRAME) + pgm_read_byte(offset); + static uint16_t offset = 0x400; + offset = ((offset + 1) & 0x4fff) | 0x400; + return (millis() / MS_PER_FRAME) + pgm_read_byte(offset); } void WavepoolEffect::update(void) { @@ -75,9 +75,9 @@ void WavepoolEffect::update(void) { static uint8_t prev_time = 0; uint8_t now = millis() / MS_PER_FRAME; if (now != prev_time) { - prev_time = now; + prev_time = now; } else { - return; + return; } // rotate the colors over time @@ -89,38 +89,38 @@ void WavepoolEffect::update(void) { frames_since_event ++; // needs two pages of height map to do the calculations - int8_t *newpg = &surface[page^1][0]; + int8_t *newpg = &surface[page ^ 1][0]; int8_t *oldpg = &surface[page][0]; // rain a bit while idle static uint8_t frames_till_next_drop = 0; static int8_t prev_x = -1; static int8_t prev_y = -1; - #ifdef INTERPOLATE +#ifdef INTERPOLATE // even frames: water movement and page flipping // odd frames: raindrops and tweening // (this arrangement seems to look best overall) if (((now & 1)) && (idle_timeout > 0)) { - #else +#else if (idle_timeout > 0) { - #endif +#endif // repeat previous raindrop to give it a slightly better effect if (prev_x >= 0) { raindrop(prev_x, prev_y, oldpg); prev_x = prev_y = -1; } if (frames_since_event - >= (frames_till_next_drop - + (idle_timeout / MS_PER_FRAME))) { - frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP); - frames_since_event = idle_timeout / MS_PER_FRAME; + >= (frames_till_next_drop + + (idle_timeout / MS_PER_FRAME))) { + frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP); + frames_since_event = idle_timeout / MS_PER_FRAME; - uint8_t x = wp_rand() % WP_WID; - uint8_t y = wp_rand() % WP_HGT; - raindrop(x, y, oldpg); + uint8_t x = wp_rand() % WP_WID; + uint8_t y = wp_rand() % WP_HGT; + raindrop(x, y, oldpg); - prev_x = x; - prev_y = y; + prev_x = x; + prev_y = y; } } @@ -128,88 +128,86 @@ void WavepoolEffect::update(void) { // (originally skipped edges, but this keyboard is too small for that) //for (uint8_t y = 1; y < WP_HGT-1; y++) { // for (uint8_t x = 1; x < WP_WID-1; x++) { - #ifdef INTERPOLATE +#ifdef INTERPOLATE if (!(now & 1)) { // even frames only - #endif - for (uint8_t y = 0; y < WP_HGT; y++) { - for (uint8_t x = 0; x < WP_WID; x++) { - uint8_t offset = (y*WP_WID) + x; - - int16_t value; - int8_t offsets[] = { -WP_WID, WP_WID, - -1, 1, - -WP_WID-1, -WP_WID+1, - WP_WID-1, WP_WID+1 - }; - // don't wrap around edges or go out of bounds - if (y==0) { +#endif + for (uint8_t y = 0; y < WP_HGT; y++) { + for (uint8_t x = 0; x < WP_WID; x++) { + uint8_t offset = (y * WP_WID) + x; + + int16_t value; + int8_t offsets[] = { -WP_WID, WP_WID, + -1, 1, + -WP_WID - 1, -WP_WID + 1, + WP_WID - 1, WP_WID + 1 + }; + // don't wrap around edges or go out of bounds + if (y == 0) { offsets[0] = 0; offsets[4] += WP_WID; offsets[5] += WP_WID; - } - else if (y==WP_HGT-1) { + } else if (y == WP_HGT - 1) { offsets[1] = 0; offsets[6] -= WP_WID; offsets[7] -= WP_WID; - } - if (x==0) { + } + if (x == 0) { offsets[2] = 0; offsets[4] += 1; offsets[6] += 1; - } - else if (x==WP_WID-1) { + } else if (x == WP_WID - 1) { offsets[3] = 0; offsets[5] -= 1; offsets[7] -= 1; - } + } - // add up all samples, divide, subtract prev frame's center - int8_t *p; - for(p=offsets, value=0; p> 2) - newpg[offset]; + value = (value >> 2) - newpg[offset]; - // reduce intensity gradually over time - newpg[offset] = value - (value >> 3); + // reduce intensity gradually over time + newpg[offset] = value - (value >> 3); + } } +#ifdef INTERPOLATE } - #ifdef INTERPOLATE - } - #endif +#endif // draw the water on the keys for (byte r = 0; r < ROWS; r++) { for (byte c = 0; c < COLS; c++) { - uint8_t offset = (r*COLS) + c; - int8_t height = oldpg[pgm_read_byte(rc2pos+offset)]; - #ifdef INTERPOLATE + uint8_t offset = (r * COLS) + c; + int8_t height = oldpg[pgm_read_byte(rc2pos + offset)]; +#ifdef INTERPOLATE if (now & 1) { // odd frames only - // average height with other frame - height = ((int16_t)height + newpg[pgm_read_byte(rc2pos+offset)]) >> 1; + // average height with other frame + height = ((int16_t)height + newpg[pgm_read_byte(rc2pos + offset)]) >> 1; } - #endif +#endif uint8_t intensity = abs(height) * 2; // color starts white but gets dimmer and more saturated as it fades, // with hue wobbling according to height map - int16_t hue = (current_hue + height + (height>>1)) & 0xff; + int16_t hue = (current_hue + height + (height >> 1)) & 0xff; cRGB color = hsvToRgb(hue, 0xff - intensity, - ((uint16_t)intensity)*2); + ((uint16_t)intensity) * 2); ::LEDControl.setCrgbAt(r, c, color); } } - #ifdef INTERPOLATE +#ifdef INTERPOLATE // swap pages every other frame if (!(now & 1)) page ^= 1; - #else +#else // swap pages every frame page ^= 1; - #endif +#endif } diff --git a/src/kaleidoscope/plugin/LED-Wavepool.h b/src/kaleidoscope/plugin/LED-Wavepool.h index beba6d63..4781d721 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.h +++ b/src/kaleidoscope/plugin/LED-Wavepool.h @@ -40,9 +40,9 @@ class WavepoolEffect : public LEDMode { private: static uint8_t frames_since_event; - static int8_t surface[2][WP_WID*WP_HGT]; + static int8_t surface[2][WP_WID * WP_HGT]; static uint8_t page; - static PROGMEM const uint8_t rc2pos[ROWS*COLS]; + static PROGMEM const uint8_t rc2pos[ROWS * COLS]; static void raindrop(uint8_t x, uint8_t y, int8_t *page); static uint8_t wp_rand(); From 0540f965629313105a967a70e2c977239f95ad91 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 20 Dec 2018 06:35:42 +0100 Subject: [PATCH 22/26] LED-Wavepool: Make cpplint happy too Signed-off-by: Gergely Nagy --- src/kaleidoscope/plugin/LED-Wavepool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kaleidoscope/plugin/LED-Wavepool.h b/src/kaleidoscope/plugin/LED-Wavepool.h index 4781d721..e1ad8b69 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.h +++ b/src/kaleidoscope/plugin/LED-Wavepool.h @@ -28,7 +28,7 @@ namespace kaleidoscope { namespace plugin { class WavepoolEffect : public LEDMode { public: - WavepoolEffect(void) {}; + WavepoolEffect(void) {} EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state); From e4689caf8a0fa35e13e6345bbeb33b0c8390f757 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 20 Dec 2018 06:44:45 +0100 Subject: [PATCH 23/26] LED-Wavepool: Smooth out hue transitions Based largely on ToyKeeper/Kaleidoscope-LED-Wavepool#8, this smooths out the hue transitions, so that the ripple is a nice rainbow, without oddly flashing colors while cycling through the effect. Thanks @bjc for the change! Signed-off-by: Gergely Nagy --- src/kaleidoscope/plugin/LED-Wavepool.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/kaleidoscope/plugin/LED-Wavepool.cpp b/src/kaleidoscope/plugin/LED-Wavepool.cpp index 2c6d6b90..7194b960 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.cpp +++ b/src/kaleidoscope/plugin/LED-Wavepool.cpp @@ -188,14 +188,13 @@ void WavepoolEffect::update(void) { #endif uint8_t intensity = abs(height) * 2; - + uint8_t saturation = 0xff - intensity; // color starts white but gets dimmer and more saturated as it fades, // with hue wobbling according to height map int16_t hue = (current_hue + height + (height >> 1)) & 0xff; + uint8_t value = (intensity >= 128) ? 255 : intensity << 1; - cRGB color = hsvToRgb(hue, - 0xff - intensity, - ((uint16_t)intensity) * 2); + cRGB color = hsvToRgb(hue, saturation, value); ::LEDControl.setCrgbAt(r, c, color); } From cae7048f6a6a2184cab2735ba131fd8a9d2a263e Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 20 Dec 2018 06:58:56 +0100 Subject: [PATCH 24/26] LED-Wavepool: Add a way to use an explicit hue for the animation While the rainbow colors are great, some may want to restrict the colors to a single hue. For this purpose, the `ripple_hue` property was introduced. It defaults to `Wavepool.rainbow_hue` (a special value that tells the plugin to use multiple hues). Inspired by @bjc's ToyKeeper/Kaleidoscope-LED-Wavepool#8. Signed-off-by: Gergely Nagy --- doc/plugin/LED-Wavepool.md | 12 +++++++++++- examples/LEDs/LED-Wavepool/LED-Wavepool.ino | 1 + src/kaleidoscope/plugin/LED-Wavepool.cpp | 11 ++++++++--- src/kaleidoscope/plugin/LED-Wavepool.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/plugin/LED-Wavepool.md b/doc/plugin/LED-Wavepool.md index 44a14796..d12fbb49 100644 --- a/doc/plugin/LED-Wavepool.md +++ b/doc/plugin/LED-Wavepool.md @@ -25,7 +25,7 @@ void setup (){ It is recommended to place the activation of the plugin as early as possible, so the plugin can catch all relevant key presses. -## Plugin methods +## Plugin properties The plugin provides the `WavepoolEffect` object, which has the following properties: @@ -39,6 +39,16 @@ properties: > > Default is 5000 (5 seconds). +### `.ripple_hue` + +> The Hue of the ripple animation. If set, the light splashing across the +> keyboard will use this value instead of all colors of the rainbow. +> +> Setting it to the special value of `Wavepool.rainbow_hue` will cause the +> plugin to use all colors again. +> +> Defaults to `Wavepool.rainbow_hue`. + ## Dependencies * [Kaleidoscope-LEDControl](LEDControl.md) diff --git a/examples/LEDs/LED-Wavepool/LED-Wavepool.ino b/examples/LEDs/LED-Wavepool/LED-Wavepool.ino index 430c9bd1..b86e05e9 100644 --- a/examples/LEDs/LED-Wavepool/LED-Wavepool.ino +++ b/examples/LEDs/LED-Wavepool/LED-Wavepool.ino @@ -50,6 +50,7 @@ void setup() { Kaleidoscope.setup(); WavepoolEffect.idle_timeout = 5000; // 5 seconds + WavepoolEffect.ripple_hue = WavepoolEffect.rainbow_hue; WavepoolEffect.activate(); } diff --git a/src/kaleidoscope/plugin/LED-Wavepool.cpp b/src/kaleidoscope/plugin/LED-Wavepool.cpp index 7194b960..0e48f238 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.cpp +++ b/src/kaleidoscope/plugin/LED-Wavepool.cpp @@ -29,6 +29,7 @@ int8_t WavepoolEffect::surface[2][WP_WID * WP_HGT]; uint8_t WavepoolEffect::page = 0; uint8_t WavepoolEffect::frames_since_event = 0; uint16_t WavepoolEffect::idle_timeout = 5000; // 5 seconds +int16_t WavepoolEffect::ripple_hue = WavepoolEffect::rainbow_hue; // automatic hue // map native keyboard coordinates (16x4) into geometric space (14x5) PROGMEM const uint8_t WavepoolEffect::rc2pos[ROWS * COLS] = { @@ -189,10 +190,14 @@ void WavepoolEffect::update(void) { uint8_t intensity = abs(height) * 2; uint8_t saturation = 0xff - intensity; - // color starts white but gets dimmer and more saturated as it fades, - // with hue wobbling according to height map - int16_t hue = (current_hue + height + (height >> 1)) & 0xff; uint8_t value = (intensity >= 128) ? 255 : intensity << 1; + int16_t hue = ripple_hue; + + if (ripple_hue == rainbow_hue) { + // color starts white but gets dimmer and more saturated as it fades, + // with hue wobbling according to height map + hue = (current_hue + height + (height >> 1)) & 0xff; + } cRGB color = hsvToRgb(hue, saturation, value); diff --git a/src/kaleidoscope/plugin/LED-Wavepool.h b/src/kaleidoscope/plugin/LED-Wavepool.h index e1ad8b69..e6e2f4e2 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.h +++ b/src/kaleidoscope/plugin/LED-Wavepool.h @@ -34,7 +34,9 @@ class WavepoolEffect : public LEDMode { // ms before idle animation starts after last keypress static uint16_t idle_timeout; + static int16_t ripple_hue; + static constexpr int16_t rainbow_hue = INT16_MAX; protected: void update(void) final; From bc2aa0a56b8038afb74e6f21e893ff719b3ce7ec Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 20 Dec 2018 07:03:18 +0100 Subject: [PATCH 25/26] LED-Wavepool: Restrict the plugin to the Model01 Due to the plugin needing a key coordinate -> geometric space mapping, it depends on the keyboard used. As such, restrict it to the Keyboard.io Model01, for which the mapping was set up. Signed-off-by: Gergely Nagy --- src/kaleidoscope/plugin/LED-Wavepool.cpp | 4 ++++ src/kaleidoscope/plugin/LED-Wavepool.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/kaleidoscope/plugin/LED-Wavepool.cpp b/src/kaleidoscope/plugin/LED-Wavepool.cpp index 0e48f238..d0a5ee37 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.cpp +++ b/src/kaleidoscope/plugin/LED-Wavepool.cpp @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +#ifdef ARDUINO_AVR_MODEL01 + #include namespace kaleidoscope { @@ -219,3 +221,5 @@ void WavepoolEffect::update(void) { } kaleidoscope::plugin::WavepoolEffect WavepoolEffect; + +#endif diff --git a/src/kaleidoscope/plugin/LED-Wavepool.h b/src/kaleidoscope/plugin/LED-Wavepool.h index e6e2f4e2..c6fed02b 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.h +++ b/src/kaleidoscope/plugin/LED-Wavepool.h @@ -18,6 +18,8 @@ #pragma once +#ifdef ARDUINO_AVR_MODEL01 + #include #include @@ -54,3 +56,5 @@ class WavepoolEffect : public LEDMode { } extern kaleidoscope::plugin::WavepoolEffect WavepoolEffect; + +#endif From 84b39e18d25a98c1db690f1be30a42f31c178713 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 20 Dec 2018 07:07:15 +0100 Subject: [PATCH 26/26] Add a NEWS entry about LED-Wavepool Signed-off-by: Gergely Nagy --- NEWS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.md b/NEWS.md index 52731fb1..5d9e9baa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -106,6 +106,12 @@ The [IdleLEDs](doc/plugin/IdleLEDs.md) plugin is a simple, yet, useful one: it w The [LEDActiveLayerColor][doc/plugin/LEDActiveLayerColor.md] plugin makes it possible to set the color of all LEDs to the same color, depending on which layer is active topmost. +### LED-Wavepool + +We integrated the [LEDWavepool](doc/plugin/LED-Wavepool.md) plugin by [ToyKeeper][wavepool:origin], with a few updates and new features added. + + [wavepool:origin]: https://github.com/ToyKeeper/Kaleidoscope-LED-Wavepool + ### WinKeyToggle The [WinKeyToggle](doc/plugin/WinKeyToggle.md) plugin assists with toggling the Windows key on and off - a little something for those of us who game under Windows and are tired of accidentally popping up the start menu.