SmoothLED
v1.0.0
Zanduino Arduino Library for controlling 10-bit PWM on any pins
|
Hardware PWM on the Atmel ATMega microprocessors can only be done on certain pins, and these are attached to specific timers and these, in turn, are either 8-bit or 16-bit. The 8-bit timers limit hardware PWM to a resolution of 8-bits, which causes visible flickering when changing PWM values for certain brightness levels (mainly in the lower end).
This library is written to allow 10-bit resolution on all pins, even those not associated with a timer for PWM. It accomplishes this by performing the PWM in software using a high-speed interrupt, using the first 16-bit timer on the Atmel ATMega processor it is compiled on.
Since the PWM is done in software, it "steals" CPU cycles from the main sketch and the more LEDs defined in the library the more CPU cycles it consumes.
User documentation is located at https://github.com/Zanduino/SmoothLED/wiki
This library is built with the standard "Doxyfile", which is located at https://github.com/Zanduino/Common/blob/main/Doxygen. As described on that page, there are only 5 environment variables used, and these are set in the project's actions file, located at https://github.com/Zanduino/SmoothLED/blob/master/.github/workflows/ci-doxygen.yml Edit this file and set the 5 variables: PRETTYNAME, PROJECT_NAME, PROJECT_NUMBER, PROJECT_BRIEF and PROJECT_LOGO so that these values are used in the doxygen documentation. The local copy of the doxyfile should be in the project's root directory in order to do local doxygen testing, but the file is ignored on upload to GitHub.
Part of the GitHub actions for CI is running every source file through "clang-format" to ensure that coding formatting is done the same for all files. The configuration file ".clang-format" is located at https://github.com/Zanduino/Common/tree/main/clang-format and this is used for CI tests when pushing to GitHub. The local file, if present in the root directory, is ignored when committing and uploading.
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 http://www.gnu.org/licenses/.
Written by Arnd Arnd@ at Zand uino. Comhttps://www.github.com/SV-Zanshin
Version | Date | Developer | Comments |
---|---|---|---|
1.0.2 | 2021-01-21 | SV-Zanshin | Issue #2 - use base-2 rather than base-10 for fading |
1.0.2 | 2021-01-20 | SV-Zanshin | Reset _counterPWM when turning PWM on to remove quick flash |
1.0.2 | 2021-01-19 | SV-Zanshin | Issue #1 - check for valid Hertz parameter setting |
1.0.0 | 2021-01-18 | SV-Zanshin | Fixed issues with initializing timer causing spurious hangs |
1.0.0 | 2021-01-17 | SV-Zanshin | Added disabling interrupts when not needed & CIE-Mode disable |
1.0.0 | 2021-01-15 | SV-Zanshin | Optimized instantiation and completed coding and testing |
1.0.0 | 2021-01-10 | SV-Zanshin | Created new library for the class |