├── examples ├── onboard │ ├── .funhouse.test.only │ ├── .gemma_m0.test.only │ ├── .trinket_m0.test.only │ └── onboard.ino └── strandtest │ └── strandtest.ino ├── .gitignore ├── README.md ├── library.properties ├── .github ├── workflows │ └── githubci.yml ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── keywords.txt ├── code-of-conduct.md ├── Adafruit_DotStar.h ├── Adafruit_DotStar.cpp ├── license.txt └── COPYING /examples/onboard/.funhouse.test.only: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/onboard/.gemma_m0.test.only: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/onboard/.trinket_m0.test.only: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Our handy .gitignore for automation ease 2 | Doxyfile* 3 | doxygen_sqlite3.db 4 | html 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adafruit DotStar [![Build Status](https://github.com/adafruit/Adafruit_DotStar/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_DotStar/actions) 2 | 3 | Arduino library for controlling two-wire-based LED pixels and strips such as Adafruit DotStar LEDs and other APA102-compatible devices. 4 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit DotStar 2 | version=1.2.5 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Adafruit DotStar LED Library 6 | paragraph=Adafruit DotStar LED Library 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit_DotStar 9 | architectures=* 10 | depends=Adafruit BusIO 11 | -------------------------------------------------------------------------------- /.github/workflows/githubci.yml: -------------------------------------------------------------------------------- 1 | name: Arduino Library CI 2 | 3 | on: [pull_request, push, repository_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/setup-python@v4 11 | with: 12 | python-version: '3.x' 13 | - uses: actions/checkout@v3 14 | - uses: actions/checkout@v3 15 | with: 16 | repository: adafruit/ci-arduino 17 | path: ci 18 | 19 | - name: pre-install 20 | run: bash ci/actions_install.sh 21 | 22 | - name: test platforms 23 | run: python3 ci/build_platform.py main_platforms 24 | 25 | - name: clang 26 | run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . 27 | 28 | - name: doxygen 29 | env: 30 | GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 31 | PRETTYNAME : "Adafruit DotStar Arduino Library" 32 | run: bash ci/doxy_gen_and_deploy.sh 33 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Adafruit_DotStar 3 | ####################################### 4 | # Class 5 | ####################################### 6 | 7 | Adafruit_DotStar KEYWORD1 8 | 9 | ####################################### 10 | # Methods and Functions 11 | ####################################### 12 | 13 | begin KEYWORD2 14 | show KEYWORD2 15 | setPixelColor KEYWORD2 16 | fill KEYWORD2 17 | setBrightness KEYWORD2 18 | clear KEYWORD2 19 | updateLength KEYWORD2 20 | updatePins KEYWORD2 21 | getPixels KEYWORD2 22 | getBrightness KEYWORD2 23 | numPixels KEYWORD2 24 | getPixelColor KEYWORD2 25 | sine8 KEYWORD2 26 | gamma8 KEYWORD2 27 | Color KEYWORD2 28 | ColorHSV KEYWORD2 29 | gamma32 KEYWORD2 30 | 31 | ####################################### 32 | # Constants 33 | ####################################### 34 | 35 | DOTSTAR_RGB LITERAL1 36 | DOTSTAR_RBG LITERAL1 37 | DOTSTAR_GRB LITERAL1 38 | DOTSTAR_GBR LITERAL1 39 | DOTSTAR_BRG LITERAL1 40 | DOTSTAR_BGR LITERAL1 41 | DOTSTAR_MONO LITERAL1 42 | 43 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /examples/onboard/onboard.ino: -------------------------------------------------------------------------------- 1 | // An example demonstrating how to control the onboard DotStar RGB LED 2 | // Works for the following boards: 3 | // Adafruit ItsyBitsy M0 Express 4 | // Adafruit ItsyBitsy M4 5 | // Adafruit ItsyBitsy nRF52840 6 | // Adafruit Trinket M0 7 | // Adafruit PyRuler 8 | // Adafruit FunHouse 9 | // Adafruit GEMMA M0 10 | 11 | #include 12 | 13 | // Everything is defined in the Board Support Package 14 | // DOTSTAR_NUM number of onboard DotStars (typically just 1) 15 | // PIN_DOTSTAR_DATA onboard DotStar data pin 16 | // PIN_DOTSTAR_CLK onboard DotStar clock pin 17 | Adafruit_DotStar strip(DOTSTAR_NUM, PIN_DOTSTAR_DATA, PIN_DOTSTAR_CLK, DOTSTAR_BRG); 18 | 19 | void setup() { 20 | strip.begin(); // Initialize pins for output 21 | strip.setBrightness(80); 22 | strip.show(); // Turn all LEDs off ASAP 23 | } 24 | 25 | void loop() { 26 | rainbow(10); // Flowing rainbow cycle along the whole strip 27 | } 28 | 29 | 30 | // Rainbow cycle along whole strip. Pass delay time (in ms) between frames. 31 | void rainbow(int wait) { 32 | // Hue of first pixel runs 5 complete loops through the color wheel. 33 | // Color wheel has a range of 65536 but it's OK if we roll over, so 34 | // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time 35 | // means we'll make 5*65536/256 = 1280 passes through this outer loop: 36 | for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { 37 | for(int i=0; i 9 | // Because conditional #includes don't work w/Arduino sketches... 10 | #include // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET 11 | //#include // ENABLE THIS LINE FOR GEMMA OR TRINKET 12 | 13 | #define NUMPIXELS 30 // Number of LEDs in strip 14 | 15 | // Here's how to control the LEDs from any two pins: 16 | #define DATAPIN 4 17 | #define CLOCKPIN 5 18 | Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG); 19 | // The last parameter is optional -- this is the color data order of the 20 | // DotStar strip, which has changed over time in different production runs. 21 | // Your code just uses R,G,B colors, the library then reassigns as needed. 22 | // Default is DOTSTAR_BRG, so change this if you have an earlier strip. 23 | 24 | // Hardware SPI is a little faster, but must be wired to specific pins 25 | // (Arduino Uno = pin 11 for data, 13 for clock, other boards are different). 26 | //Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG); 27 | 28 | void setup() { 29 | 30 | #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L) 31 | clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket 32 | #endif 33 | 34 | strip.begin(); // Initialize pins for output 35 | strip.show(); // Turn all LEDs off ASAP 36 | } 37 | 38 | // Runs 10 LEDs at a time along strip, cycling through red, green and blue. 39 | // This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel. 40 | 41 | int head = 0, tail = -10; // Index of first 'on' and 'off' pixels 42 | uint32_t color = 0xFF0000; // 'On' color (starts red) 43 | 44 | void loop() { 45 | 46 | strip.setPixelColor(head, color); // 'On' pixel at head 47 | strip.setPixelColor(tail, 0); // 'Off' pixel at tail 48 | strip.show(); // Refresh strip 49 | delay(20); // Pause 20 milliseconds (~50 FPS) 50 | 51 | if(++head >= NUMPIXELS) { // Increment head index. Off end of strip? 52 | head = 0; // Yes, reset head index to start 53 | if((color >>= 8) == 0) // Next color (R->G->B) ... past blue now? 54 | color = 0xFF0000; // Yes, reset to red 55 | } 56 | if(++tail >= NUMPIXELS) tail = 0; // Increment, reset tail index 57 | } 58 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Adafruit Community Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and leaders pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level or type of 9 | experience, education, socio-economic status, nationality, personal appearance, 10 | race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | We are committed to providing a friendly, safe and welcoming environment for 15 | all. 16 | 17 | Examples of behavior that contributes to creating a positive environment 18 | include: 19 | 20 | * Be kind and courteous to others 21 | * Using welcoming and inclusive language 22 | * Being respectful of differing viewpoints and experiences 23 | * Collaborating with other community members 24 | * Gracefully accepting constructive criticism 25 | * Focusing on what is best for the community 26 | * Showing empathy towards other community members 27 | 28 | Examples of unacceptable behavior by participants include: 29 | 30 | * The use of sexualized language or imagery and sexual attention or advances 31 | * The use of inappropriate images, including in a community member's avatar 32 | * The use of inappropriate language, including in a community member's nickname 33 | * Any spamming, flaming, baiting or other attention-stealing behavior 34 | * Excessive or unwelcome helping; answering outside the scope of the question 35 | asked 36 | * Trolling, insulting/derogatory comments, and personal or political attacks 37 | * Public or private harassment 38 | * Publishing others' private information, such as a physical or electronic 39 | address, without explicit permission 40 | * Other conduct which could reasonably be considered inappropriate 41 | 42 | The goal of the standards and moderation guidelines outlined here is to build 43 | and maintain a respectful community. We ask that you don’t just aim to be 44 | "technically unimpeachable", but rather try to be your best self. 45 | 46 | We value many things beyond technical expertise, including collaboration and 47 | supporting others within our community. Providing a positive experience for 48 | other community members can have a much more significant impact than simply 49 | providing the correct answer. 50 | 51 | ## Our Responsibilities 52 | 53 | Project leaders are responsible for clarifying the standards of acceptable 54 | behavior and are expected to take appropriate and fair corrective action in 55 | response to any instances of unacceptable behavior. 56 | 57 | Project leaders have the right and responsibility to remove, edit, or 58 | reject messages, comments, commits, code, issues, and other contributions 59 | that are not aligned to this Code of Conduct, or to ban temporarily or 60 | permanently any community member for other behaviors that they deem 61 | inappropriate, threatening, offensive, or harmful. 62 | 63 | ## Moderation 64 | 65 | Instances of behaviors that violate the Adafruit Community Code of Conduct 66 | may be reported by any member of the community. Community members are 67 | encouraged to report these situations, including situations they witness 68 | involving other community members. 69 | 70 | You may report in the following ways: 71 | 72 | In any situation, you may send an email to . 73 | 74 | On the Adafruit Discord, you may send an open message from any channel 75 | to all Community Helpers by tagging @community helpers. You may also send an 76 | open message from any channel, or a direct message to @kattni#1507, 77 | @tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or 78 | @Andon#8175. 79 | 80 | Email and direct message reports will be kept confidential. 81 | 82 | In situations on Discord where the issue is particularly egregious, possibly 83 | illegal, requires immediate action, or violates the Discord terms of service, 84 | you should also report the message directly to Discord. 85 | 86 | These are the steps for upholding our community’s standards of conduct. 87 | 88 | 1. Any member of the community may report any situation that violates the 89 | Adafruit Community Code of Conduct. All reports will be reviewed and 90 | investigated. 91 | 2. If the behavior is an egregious violation, the community member who 92 | committed the violation may be banned immediately, without warning. 93 | 3. Otherwise, moderators will first respond to such behavior with a warning. 94 | 4. Moderators follow a soft "three strikes" policy - the community member may 95 | be given another chance, if they are receptive to the warning and change their 96 | behavior. 97 | 5. If the community member is unreceptive or unreasonable when warned by a 98 | moderator, or the warning goes unheeded, they may be banned for a first or 99 | second offense. Repeated offenses will result in the community member being 100 | banned. 101 | 102 | ## Scope 103 | 104 | This Code of Conduct and the enforcement policies listed above apply to all 105 | Adafruit Community venues. This includes but is not limited to any community 106 | spaces (both public and private), the entire Adafruit Discord server, and 107 | Adafruit GitHub repositories. Examples of Adafruit Community spaces include 108 | but are not limited to meet-ups, audio chats on the Adafruit Discord, or 109 | interaction at a conference. 110 | 111 | This Code of Conduct applies both within project spaces and in public spaces 112 | when an individual is representing the project or its community. As a community 113 | member, you are representing our community, and are expected to behave 114 | accordingly. 115 | 116 | ## Attribution 117 | 118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 119 | version 1.4, available at 120 | , 121 | and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). 122 | 123 | For other projects adopting the Adafruit Community Code of 124 | Conduct, please contact the maintainers of those projects for enforcement. 125 | If you wish to use this code of conduct for your own project, consider 126 | explicitly mentioning your moderation policy or making a copy with your 127 | own moderation policy so as to avoid confusion. 128 | -------------------------------------------------------------------------------- /Adafruit_DotStar.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_DotStar.h 3 | * 4 | * This file is part of the Adafruit_DotStar library. 5 | * 6 | * Adafruit_DotStar is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * Adafruit_DotStar is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with DotStar. If not, see . 18 | * 19 | */ 20 | 21 | #ifndef _ADAFRUIT_DOT_STAR_H_ 22 | #define _ADAFRUIT_DOT_STAR_H_ 23 | 24 | #include "Arduino.h" 25 | 26 | #include 27 | 28 | // Color-order flag for LED pixels (optional extra parameter to constructor): 29 | // Bits 0,1 = R index (0-2), bits 2,3 = G index, bits 4,5 = B index 30 | #define DOTSTAR_RGB (0 | (1 << 2) | (2 << 4)) ///< Transmit as R,G,B 31 | #define DOTSTAR_RBG (0 | (2 << 2) | (1 << 4)) ///< Transmit as R,B,G 32 | #define DOTSTAR_GRB (1 | (0 << 2) | (2 << 4)) ///< Transmit as G,R,B 33 | #define DOTSTAR_GBR (2 | (0 << 2) | (1 << 4)) ///< Transmit as G,B,R 34 | #define DOTSTAR_BRG (1 | (2 << 2) | (0 << 4)) ///< Transmit as B,R,G 35 | #define DOTSTAR_BGR (2 | (1 << 2) | (0 << 4)) ///< Transmit as B,G,R 36 | #define DOTSTAR_MONO 0 ///< Single-color strip WIP DO NOT USE, use RGB for now 37 | 38 | // These two tables are declared outside the Adafruit_DotStar class 39 | // because some boards may require oldschool compilers that don't 40 | // handle the C++11 constexpr keyword. 41 | 42 | /* A PROGMEM (flash mem) table containing 8-bit unsigned sine wave (0-255). 43 | Copy & paste this snippet into a Python REPL to regenerate: 44 | import math 45 | for x in range(256): 46 | print("{:3},".format(int((math.sin(x/128.0*math.pi)+1.0)*127.5+0.5))), 47 | if x&15 == 15: print 48 | */ 49 | static const uint8_t PROGMEM _DotStarSineTable[256] = { 50 | 128, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 162, 165, 167, 170, 51 | 173, 176, 179, 182, 185, 188, 190, 193, 196, 198, 201, 203, 206, 208, 211, 52 | 213, 215, 218, 220, 222, 224, 226, 228, 230, 232, 234, 235, 237, 238, 240, 53 | 241, 243, 244, 245, 246, 248, 249, 250, 250, 251, 252, 253, 253, 254, 254, 54 | 254, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 253, 253, 252, 251, 55 | 250, 250, 249, 248, 246, 245, 244, 243, 241, 240, 238, 237, 235, 234, 232, 56 | 230, 228, 226, 224, 222, 220, 218, 215, 213, 211, 208, 206, 203, 201, 198, 57 | 196, 193, 190, 188, 185, 182, 179, 176, 173, 170, 167, 165, 162, 158, 155, 58 | 152, 149, 146, 143, 140, 137, 134, 131, 128, 124, 121, 118, 115, 112, 109, 59 | 106, 103, 100, 97, 93, 90, 88, 85, 82, 79, 76, 73, 70, 67, 65, 60 | 62, 59, 57, 54, 52, 49, 47, 44, 42, 40, 37, 35, 33, 31, 29, 61 | 27, 25, 23, 21, 20, 18, 17, 15, 14, 12, 11, 10, 9, 7, 6, 62 | 5, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 63 | 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9, 10, 11, 64 | 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 65 | 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76, 66 | 79, 82, 85, 88, 90, 93, 97, 100, 103, 106, 109, 112, 115, 118, 121, 67 | 124}; 68 | 69 | /* Similar to above, but for an 8-bit gamma-correction table. 70 | Copy & paste this snippet into a Python REPL to regenerate: 71 | import math 72 | gamma=2.6 73 | for x in range(256): 74 | print("{:3},".format(int(math.pow((x)/255.0,gamma)*255.0+0.5))), 75 | if x&15 == 15: print 76 | */ 77 | static const uint8_t PROGMEM _DotStarGammaTable[256] = { 78 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 80 | 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 81 | 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 82 | 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 83 | 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 84 | 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25, 85 | 25, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35, 86 | 36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 48, 87 | 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 88 | 64, 65, 66, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81, 89 | 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 96, 97, 99, 100, 102, 90 | 103, 105, 106, 108, 109, 111, 112, 114, 115, 117, 119, 120, 122, 124, 125, 91 | 127, 129, 130, 132, 134, 136, 137, 139, 141, 143, 145, 146, 148, 150, 152, 92 | 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 93 | 184, 186, 188, 191, 193, 195, 197, 199, 202, 204, 206, 209, 211, 213, 215, 94 | 218, 220, 223, 225, 227, 230, 232, 235, 237, 240, 242, 245, 247, 250, 252, 95 | 255}; 96 | 97 | /*! 98 | @brief Class that stores state and functions for interacting with 99 | Adafruit DotStars and compatible devices. 100 | */ 101 | class Adafruit_DotStar { 102 | 103 | public: 104 | #if !defined(SPI_INTERFACES_COUNT) || \ 105 | (defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0)) 106 | // HW SPI available 107 | Adafruit_DotStar(uint16_t n, uint8_t o = DOTSTAR_BRG, SPIClass *spi = &SPI); 108 | #else 109 | Adafruit_DotStar(uint16_t n, uint8_t o = DOTSTAR_BRG, SPIClass *spi = NULL); 110 | #endif 111 | Adafruit_DotStar(uint16_t n, uint8_t d, uint8_t c, uint8_t o = DOTSTAR_BRG); 112 | ~Adafruit_DotStar(void); 113 | 114 | void begin(void); 115 | void show(void); 116 | void setPixelColor(uint16_t n, uint32_t c); 117 | void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b); 118 | void fill(uint32_t c = 0, uint16_t first = 0, uint16_t count = 0); 119 | void setBrightness(uint8_t); 120 | void clear(); 121 | void updateLength(uint16_t n); 122 | void updatePins(void); 123 | void updatePins(uint8_t d, uint8_t c); 124 | /*! 125 | @brief Get a pointer directly to the DotStar data buffer in RAM. 126 | Pixel data is stored in a device-native format (a la the 127 | DOTSTAR_* constants) and is not translated here. Applications 128 | that access this buffer will need to be aware of the specific 129 | data format and handle colors appropriately. 130 | @return Pointer to DotStar buffer (uint8_t* array). 131 | @note This is for high-performance applications where calling 132 | setPixelColor() on every single pixel would be too slow (e.g. 133 | POV or light-painting projects). There is no bounds checking 134 | on the array, creating tremendous potential for mayhem if one 135 | writes past the ends of the buffer. Great power, great 136 | responsibility and all that. 137 | */ 138 | uint8_t *getPixels(void) const { return pixels; }; 139 | uint8_t getBrightness(void) const; 140 | /*! 141 | @brief Return the number of pixels in an Adafruit_DotStar strip object. 142 | @return Pixel count (0 if not set). 143 | */ 144 | uint16_t numPixels(void) const { return numLEDs; }; 145 | uint32_t getPixelColor(uint16_t n) const; 146 | /*! 147 | @brief An 8-bit integer sine wave function, not directly compatible 148 | with standard trigonometric units like radians or degrees. 149 | @param x Input angle, 0-255; 256 would loop back to zero, completing 150 | the circle (equivalent to 360 degrees or 2 pi radians). 151 | One can therefore use an unsigned 8-bit variable and simply 152 | add or subtract, allowing it to overflow/underflow and it 153 | still does the expected contiguous thing. 154 | @return Sine result, 0 to 255, or -128 to +127 if type-converted to 155 | a signed int8_t, but you'll most likely want unsigned as this 156 | output is often used for pixel brightness in animation effects. 157 | */ 158 | static uint8_t sine8(uint8_t x) { 159 | return pgm_read_byte(&_DotStarSineTable[x]); // 0-255 in, 0-255 out 160 | } 161 | /*! 162 | @brief An 8-bit gamma-correction function for basic pixel brightness 163 | adjustment. Makes color transitions appear more perceptially 164 | correct. 165 | @param x Input brightness, 0 (minimum or off/black) to 255 (maximum). 166 | @return Gamma-adjusted brightness, can then be passed to one of the 167 | setPixelColor() functions. This uses a fixed gamma correction 168 | exponent of 2.6, which seems reasonably okay for average 169 | DotStars in average tasks. If you need finer control you'll 170 | need to provide your own gamma-correction function instead. 171 | */ 172 | static uint8_t gamma8(uint8_t x) { 173 | return pgm_read_byte(&_DotStarGammaTable[x]); // 0-255 in, 0-255 out 174 | } 175 | /*! 176 | @brief Convert separate red, green and blue values into a single 177 | "packed" 32-bit RGB color. 178 | @param r Red brightness, 0 to 255. 179 | @param g Green brightness, 0 to 255. 180 | @param b Blue brightness, 0 to 255. 181 | @return 32-bit packed RGB value, which can then be assigned to a 182 | variable for later use or passed to the setPixelColor() 183 | function. Packed RGB format is predictable, regardless of 184 | LED strand color order. 185 | */ 186 | static uint32_t Color(uint8_t r, uint8_t g, uint8_t b) { 187 | return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b; 188 | } 189 | static uint32_t ColorHSV(uint16_t hue, uint8_t sat = 255, uint8_t val = 255); 190 | static uint32_t gamma32(uint32_t x); 191 | 192 | void rainbow(uint16_t first_hue = 0, int8_t reps = 1, 193 | uint8_t saturation = 255, uint8_t brightness = 255, 194 | boolean gammify = true); 195 | 196 | private: 197 | Adafruit_SPIDevice *spi_dev = NULL; ///< Pointer to SPI bus interface 198 | uint16_t numLEDs; ///< Number of pixels 199 | uint8_t brightness; ///< Global brightness setting 200 | uint8_t *pixels; ///< LED RGB values (3 bytes ea.) 201 | uint8_t rOffset; ///< Index of red in 3-byte pixel 202 | uint8_t gOffset; ///< Index of green byte 203 | uint8_t bOffset; ///< Index of blue byte 204 | }; 205 | 206 | #endif // _ADAFRUIT_DOT_STAR_H_ 207 | -------------------------------------------------------------------------------- /Adafruit_DotStar.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_DotStar.cpp 3 | * 4 | * @mainpage Arduino Library for driving Adafruit DotStar addressable LEDs 5 | * and compatible devicess -- APA102, etc. 6 | * 7 | * @section intro_sec Introduction 8 | * 9 | * This is the documentation for Adafruit's DotStar library for the 10 | * Arduino platform, allowing a broad range of microcontroller boards 11 | * (most AVR boards, many ARM devices, ESP8266 and ESP32, among others) 12 | * to control Adafruit DotStars and compatible devices -- APA102, etc. 13 | * 14 | * Adafruit invests time and resources providing this open source code, 15 | * please support Adafruit and open-source hardware by purchasing products 16 | * from Adafruit! 17 | * 18 | * @section author Author 19 | * 20 | * Written by Limor Fried and Phil Burgess for Adafruit Industries with 21 | * contributions from members of the open source community. 22 | * 23 | * @section license License 24 | * 25 | * This file is part of the Adafruit_DotStar library. 26 | * 27 | * Adafruit_DotStar is free software: you can redistribute it and/or 28 | * modify it under the terms of the GNU Lesser General Public License as 29 | * published by the Free Software Foundation, either version 3 of the 30 | * License, or (at your option) any later version. 31 | * 32 | * Adafruit_DotStar is distributed in the hope that it will be useful, 33 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 | * GNU Lesser General Public License for more details. 36 | * 37 | * You should have received a copy of the GNU Lesser General Public 38 | * License along with DotStar. If not, see . 39 | * 40 | */ 41 | 42 | #include "Adafruit_DotStar.h" 43 | 44 | /*! 45 | @brief DotStar constructor for hardware SPI. Must be connected to 46 | MOSI, SCK pins. 47 | @param n Number of DotStars in strand. 48 | @param o Pixel type -- one of the DOTSTAR_* constants defined in 49 | Adafruit_DotStar.h, for example DOTSTAR_BRG for DotStars 50 | expecting color bytes expressed in blue, red, green order 51 | per pixel. Default if unspecified is DOTSTAR_BRG. 52 | @param spi Pointer to hardware SPIClass object (default is primary 53 | SPI device 'SPI' if defined, else MUST pass in device). 54 | @return Adafruit_DotStar object. Call the begin() function before use. 55 | */ 56 | Adafruit_DotStar::Adafruit_DotStar(uint16_t n, uint8_t o, SPIClass *spi) 57 | : numLEDs(n), brightness(0), pixels(NULL), rOffset(o & 3), 58 | gOffset((o >> 2) & 3), bOffset((o >> 4) & 3) { 59 | spi_dev = new Adafruit_SPIDevice(-1, 8000000, SPI_BITORDER_MSBFIRST, 60 | SPI_MODE0, spi); 61 | updateLength(n); 62 | } 63 | 64 | /*! 65 | @brief DotStar constructor for 'soft' (bitbang) SPI. Any two pins 66 | can be used. 67 | @param n Number of DotStars in strand. 68 | @param data Arduino pin number for data out. 69 | @param clock Arduino pin number for clock out. 70 | @param o Pixel type -- one of the DOTSTAR_* constants defined in 71 | Adafruit_DotStar.h, for example DOTSTAR_BRG for DotStars 72 | expecting color bytes expressed in blue, red, green order 73 | per pixel. Default if unspecified is DOTSTAR_BRG. 74 | @return Adafruit_DotStar object. Call the begin() function before use. 75 | */ 76 | Adafruit_DotStar::Adafruit_DotStar(uint16_t n, uint8_t data, uint8_t clock, 77 | uint8_t o) 78 | : brightness(0), pixels(NULL), rOffset(o & 3), gOffset((o >> 2) & 3), 79 | bOffset((o >> 4) & 3) { 80 | spi_dev = new Adafruit_SPIDevice(-1, clock, -1, data, 8000000); 81 | updateLength(n); 82 | } 83 | 84 | /*! 85 | @brief Deallocate Adafruit_DotStar object, set data and clock pins 86 | back to INPUT. 87 | */ 88 | Adafruit_DotStar::~Adafruit_DotStar(void) { 89 | free(pixels); 90 | if (spi_dev) 91 | delete (spi_dev); 92 | } 93 | 94 | /*! 95 | @brief Initialize Adafruit_DotStar object -- sets data and clock pins 96 | to outputs and initializes hardware SPI if necessary. 97 | */ 98 | void Adafruit_DotStar::begin(void) { spi_dev->begin(); } 99 | 100 | // Pins may be reassigned post-begin(), so a sketch can store hardware 101 | // config in flash, SD card, etc. rather than hardcoded. Also permits 102 | // "recycling" LED ram across multiple strips: set pins to first strip, 103 | // render & write all data, reassign pins to next strip, render & write, 104 | // etc. They won't update simultaneously, but usually unnoticeable. 105 | 106 | /*! 107 | @brief Switch over to hardware SPI. DotStars must be connected to 108 | MOSI, SCK pins. Data in pixel buffer is unaffected and can 109 | continue to be used. 110 | */ 111 | void Adafruit_DotStar::updatePins(void) { 112 | if (spi_dev) 113 | delete (spi_dev); 114 | spi_dev = new Adafruit_SPIDevice(-1, 8000000); 115 | spi_dev->begin(); 116 | } 117 | 118 | /*! 119 | @brief Switch over to 'soft' (bitbang) SPI. DotStars can be connected 120 | to any two pins. Data in pixel buffer is unaffected and can 121 | continue to be used. 122 | @param data Arduino pin number for data out. 123 | @param clock Arduino pin number for clock out. 124 | */ 125 | void Adafruit_DotStar::updatePins(uint8_t data, uint8_t clock) { 126 | if (spi_dev) 127 | delete (spi_dev); 128 | spi_dev = new Adafruit_SPIDevice(-1, clock, -1, data, 8000000); 129 | spi_dev->begin(); 130 | } 131 | 132 | /*! 133 | @brief Change the length of a previously-declared Adafruit_DotStar 134 | strip object. Old data is deallocated and new data is cleared. 135 | Pin numbers and pixel format are unchanged. 136 | @param n New length of strip, in pixels. 137 | @note This function is deprecated, here only for old projects that 138 | may still be calling it. New projects should instead use the 139 | 'new' keyword. 140 | */ 141 | void Adafruit_DotStar::updateLength(uint16_t n) { 142 | free(pixels); 143 | uint16_t bytes = (rOffset == gOffset) 144 | ? n + ((n + 3) / 4) 145 | : // MONO: 10 bits/pixel, round up to next byte 146 | n * 3; // COLOR: 3 bytes/pixel 147 | if ((pixels = (uint8_t *)malloc(bytes))) { 148 | numLEDs = n; 149 | clear(); 150 | } else { 151 | numLEDs = 0; 152 | } 153 | } 154 | 155 | // SPI STUFF --------------------------------------------------------------- 156 | 157 | /* ISSUE DATA TO LED STRIP ------------------------------------------------- 158 | 159 | Although the LED driver has an additional per-pixel 5-bit brightness 160 | setting, it is NOT used or supported here. On APA102, the normally 161 | very fast PWM is gated through a much slower PWM (about 400 Hz), 162 | rendering it useless for POV or other high-speed things that are 163 | probably why one is using DotStars instead of NeoPixels in the first 164 | place. I'm told that some APA102 clones use current control rather than 165 | PWM for this, which would be much more worthwhile. Still, no support 166 | here, no plans for it. If you really can't live without it, you can fork 167 | the library and add it for your own use, but any pull requests for this 168 | are unlikely be merged for the foreseeable future. 169 | */ 170 | 171 | /*! 172 | @brief Transmit pixel data in RAM to DotStars. 173 | */ 174 | void Adafruit_DotStar::show(void) { 175 | if (!pixels) 176 | return; 177 | 178 | uint8_t *ptr = pixels, i; // -> LED data 179 | uint16_t n = numLEDs; // Counter 180 | uint16_t b16 = (uint16_t)brightness; // Type-convert for fixed-point math 181 | 182 | // Begin transaction, setting SPI frequency 183 | spi_dev->beginTransaction(); 184 | 185 | // [START FRAME] 186 | for (i = 0; i < 4; i++) 187 | spi_dev->transfer(0x00); 188 | 189 | // [PIXEL DATA] 190 | if (brightness) { // Scale pixel brightness on output 191 | do { // For each pixel... 192 | spi_dev->transfer(0xFF); // Pixel start 193 | for (i = 0; i < 3; i++) 194 | spi_dev->transfer((*ptr++ * b16) >> 8); // Scale, write 195 | } while (--n); 196 | } else { // Full brightness (no scaling) 197 | do { // For each pixel... 198 | spi_dev->transfer(0xFF); // Pixel start 199 | for (i = 0; i < 3; i++) 200 | spi_dev->transfer(*ptr++); // R,G,B 201 | } while (--n); 202 | } 203 | 204 | // [END FRAME] 205 | // Four end-frame bytes are seemingly indistinguishable from a white 206 | // pixel, and empirical testing suggests it can be left out...but it's 207 | // always a good idea to follow the datasheet, in case future hardware 208 | // revisions are more strict (e.g. might mandate use of end-frame 209 | // before start-frame marker). i.e. let's not remove this. But after 210 | // testing a bit more the suggestion is to use at least (numLeds+1)/2 211 | // high values (1) or (numLeds+15)/16 full bytes as EndFrame. For details 212 | // see also: 213 | // https://cpldcpu.wordpress.com/2014/11/30/understanding-the-apa102-superled/ 214 | for (i = 0; i < ((numLEDs + 15) / 16); i++) 215 | spi_dev->transfer(0xFF); 216 | 217 | // Finish SPI transaction 218 | spi_dev->endTransaction(); 219 | } 220 | 221 | /*! 222 | @brief Fill the whole DotStar strip with 0 / black / off. 223 | */ 224 | void Adafruit_DotStar::clear() { 225 | memset(pixels, 0, 226 | (rOffset == gOffset) ? numLEDs + ((numLEDs + 3) / 4) 227 | : // MONO: 10 bits/pixel 228 | numLEDs * 3); // COLOR: 3 bytes/pixel 229 | } 230 | 231 | /*! 232 | @brief Set a pixel's color using separate red, green and blue components. 233 | @param n Pixel index, starting from 0. 234 | @param r Red brightness, 0 = minimum (off), 255 = maximum. 235 | @param g Green brightness, 0 = minimum (off), 255 = maximum. 236 | @param b Blue brightness, 0 = minimum (off), 255 = maximum. 237 | */ 238 | void Adafruit_DotStar::setPixelColor(uint16_t n, uint8_t r, uint8_t g, 239 | uint8_t b) { 240 | if (n < numLEDs) { 241 | uint8_t *p = &pixels[n * 3]; 242 | p[rOffset] = r; 243 | p[gOffset] = g; 244 | p[bOffset] = b; 245 | } 246 | } 247 | 248 | /*! 249 | @brief Set a pixel's color using a 32-bit 'packed' RGB value. 250 | @param n Pixel index, starting from 0. 251 | @param c 32-bit color value. Most significant byte is 0, second is 252 | red, then green, and least significant byte is blue. 253 | e.g. 0x00RRGGBB 254 | */ 255 | void Adafruit_DotStar::setPixelColor(uint16_t n, uint32_t c) { 256 | if (n < numLEDs) { 257 | uint8_t *p = &pixels[n * 3]; 258 | p[rOffset] = (uint8_t)(c >> 16); 259 | p[gOffset] = (uint8_t)(c >> 8); 260 | p[bOffset] = (uint8_t)c; 261 | } 262 | } 263 | 264 | /*! 265 | @brief Fill all or part of the DotStar strip with a color. 266 | @param c 32-bit color value. Most significant byte is 0, second 267 | is red, then green, and least significant byte is blue. 268 | e.g. 0x00RRGGBB. If all arguments are unspecified, this 269 | will be 0 (off). 270 | @param first Index of first pixel to fill, starting from 0. Must be 271 | in-bounds, no clipping is performed. 0 if unspecified. 272 | @param count Number of pixels to fill, as a positive value. Passing 273 | 0 or leaving unspecified will fill to end of strip. 274 | */ 275 | void Adafruit_DotStar::fill(uint32_t c, uint16_t first, uint16_t count) { 276 | uint16_t i, end; 277 | 278 | if (first >= numLEDs) { 279 | return; // If first LED is past end of strip, nothing to do 280 | } 281 | 282 | // Calculate the index ONE AFTER the last pixel to fill 283 | if (count == 0) { 284 | // Fill to end of strip 285 | end = numLEDs; 286 | } else { 287 | // Ensure that the loop won't go past the last pixel 288 | end = first + count; 289 | if (end > numLEDs) 290 | end = numLEDs; 291 | } 292 | 293 | for (i = first; i < end; i++) { 294 | this->setPixelColor(i, c); 295 | } 296 | } 297 | 298 | /*! 299 | @brief Convert hue, saturation and value into a packed 32-bit RGB color 300 | that can be passed to setPixelColor() or other RGB-compatible 301 | functions. 302 | @param hue An unsigned 16-bit value, 0 to 65535, representing one full 303 | loop of the color wheel, which allows 16-bit hues to "roll 304 | over" while still doing the expected thing (and allowing 305 | more precision than the wheel() function that was common to 306 | prior DotStar and NeoPixel examples). 307 | @param sat Saturation, 8-bit value, 0 (min or pure grayscale) to 255 308 | (max or pure hue). Default of 255 if unspecified. 309 | @param val Value (brightness), 8-bit value, 0 (min / black / off) to 310 | 255 (max or full brightness). Default of 255 if unspecified. 311 | @return Packed 32-bit RGB color. Result is linearly but not perceptually 312 | correct, so you may want to pass the result through the gamma32() 313 | function (or your own gamma-correction operation) else colors may 314 | appear washed out. This is not done automatically by this 315 | function because coders may desire a more refined gamma- 316 | correction function than the simplified one-size-fits-all 317 | operation of gamma32(). Diffusing the LEDs also really seems to 318 | help when using low-saturation colors. 319 | */ 320 | uint32_t Adafruit_DotStar::ColorHSV(uint16_t hue, uint8_t sat, uint8_t val) { 321 | 322 | uint8_t r, g, b; 323 | 324 | // Remap 0-65535 to 0-1529. Pure red is CENTERED on the 64K rollover; 325 | // 0 is not the start of pure red, but the midpoint...a few values above 326 | // zero and a few below 65536 all yield pure red (similarly, 32768 is the 327 | // midpoint, not start, of pure cyan). The 8-bit RGB hexcone (256 values 328 | // each for red, green, blue) really only allows for 1530 distinct hues 329 | // (not 1536, more on that below), but the full unsigned 16-bit type was 330 | // chosen for hue so that one's code can easily handle a contiguous color 331 | // wheel by allowing hue to roll over in either direction. 332 | hue = (hue * 1530L + 32768) / 65536; 333 | // Because red is centered on the rollover point (the +32768 above, 334 | // essentially a fixed-point +0.5), the above actually yields 0 to 1530, 335 | // where 0 and 1530 would yield the same thing. Rather than apply a 336 | // costly modulo operator, 1530 is handled as a special case below. 337 | 338 | // So you'd think that the color "hexcone" (the thing that ramps from 339 | // pure red, to pure yellow, to pure green and so forth back to red, 340 | // yielding six slices), and with each color component having 256 341 | // possible values (0-255), might have 1536 possible items (6*256), 342 | // but in reality there's 1530. This is because the last element in 343 | // each 256-element slice is equal to the first element of the next 344 | // slice, and keeping those in there this would create small 345 | // discontinuities in the color wheel. So the last element of each 346 | // slice is dropped...we regard only elements 0-254, with item 255 347 | // being picked up as element 0 of the next slice. Like this: 348 | // Red to not-quite-pure-yellow is: 255, 0, 0 to 255, 254, 0 349 | // Pure yellow to not-quite-pure-green is: 255, 255, 0 to 1, 255, 0 350 | // Pure green to not-quite-pure-cyan is: 0, 255, 0 to 0, 255, 254 351 | // and so forth. Hence, 1530 distinct hues (0 to 1529), and hence why 352 | // the constants below are not the multiples of 256 you might expect. 353 | 354 | // Convert hue to R,G,B (nested ifs faster than divide+mod+switch): 355 | if (hue < 510) { // Red to Green-1 356 | b = 0; 357 | if (hue < 255) { // Red to Yellow-1 358 | r = 255; 359 | g = hue; // g = 0 to 254 360 | } else { // Yellow to Green-1 361 | r = 510 - hue; // r = 255 to 1 362 | g = 255; 363 | } 364 | } else if (hue < 1020) { // Green to Blue-1 365 | r = 0; 366 | if (hue < 765) { // Green to Cyan-1 367 | g = 255; 368 | b = hue - 510; // b = 0 to 254 369 | } else { // Cyan to Blue-1 370 | g = 1020 - hue; // g = 255 to 1 371 | b = 255; 372 | } 373 | } else if (hue < 1530) { // Blue to Red-1 374 | g = 0; 375 | if (hue < 1275) { // Blue to Magenta-1 376 | r = hue - 1020; // r = 0 to 254 377 | b = 255; 378 | } else { // Magenta to Red-1 379 | r = 255; 380 | b = 1530 - hue; // b = 255 to 1 381 | } 382 | } else { // Last 0.5 Red (quicker than % operator) 383 | r = 255; 384 | g = b = 0; 385 | } 386 | 387 | // Apply saturation and value to R,G,B, pack into 32-bit result: 388 | uint32_t v1 = 1 + val; // 1 to 256; allows >>8 instead of /255 389 | uint16_t s1 = 1 + sat; // 1 to 256; same reason 390 | uint8_t s2 = 255 - sat; // 255 to 0 391 | return ((((((r * s1) >> 8) + s2) * v1) & 0xff00) << 8) | 392 | (((((g * s1) >> 8) + s2) * v1) & 0xff00) | 393 | (((((b * s1) >> 8) + s2) * v1) >> 8); 394 | } 395 | 396 | /*! 397 | @brief Query the color of a previously-set pixel. 398 | @param n Index of pixel to read (0 = first). 399 | @return 'Packed' 32-bit RGB value. Most significant byte is 0, second is 400 | is red, then green, and least significant byte is blue. 401 | */ 402 | uint32_t Adafruit_DotStar::getPixelColor(uint16_t n) const { 403 | if (n >= numLEDs) 404 | return 0; 405 | uint8_t *p = &pixels[n * 3]; 406 | return ((uint32_t)p[rOffset] << 16) | ((uint32_t)p[gOffset] << 8) | 407 | (uint32_t)p[bOffset]; 408 | } 409 | 410 | /*! 411 | @brief Adjust output brightness. Does not immediately affect what's 412 | currently displayed on the LEDs. The next call to show() will 413 | refresh the LEDs at this level. 414 | @param b Brightness setting, 0=minimum (off), 255=brightest. 415 | @note For various reasons I think brightness is better handled in 416 | one's sketch, but it's here for parity with the NeoPixel 417 | library. Good news is that brightness setting in this library 418 | is 'non destructive' -- it's applied as color data is being 419 | issued to the strip, not during setPixelColor(), and also 420 | means that getPixelColor() returns the exact value originally 421 | stored. 422 | */ 423 | void Adafruit_DotStar::setBrightness(uint8_t b) { 424 | // Stored brightness value is different than what's passed. This 425 | // optimizes the actual scaling math later, allowing a fast 8x8-bit 426 | // multiply and taking the MSB. 'brightness' is a uint8_t, adding 1 427 | // here may (intentionally) roll over...so 0 = max brightness (color 428 | // values are interpreted literally; no scaling), 1 = min brightness 429 | // (off), 255 = just below max brightness. 430 | brightness = b + 1; 431 | } 432 | 433 | /*! 434 | @brief Retrieve the last-set brightness value for the strip. 435 | @return Brightness value: 0 = minimum (off), 255 = maximum. 436 | */ 437 | uint8_t Adafruit_DotStar::getBrightness(void) const { 438 | return brightness - 1; // Reverse above operation 439 | } 440 | 441 | /*! 442 | @brief A gamma-correction function for 32-bit packed RGB colors. 443 | Makes color transitions appear more perceptially correct. 444 | @param x 32-bit packed RGB color. 445 | @return Gamma-adjusted packed color, can then be passed in one of the 446 | setPixelColor() functions. Like gamma8(), this uses a fixed 447 | gamma correction exponent of 2.6, which seems reasonably okay 448 | for average DotStars in average tasks. If you need finer 449 | control you'll need to provide your own gamma-correction 450 | function instead. 451 | */ 452 | uint32_t Adafruit_DotStar::gamma32(uint32_t x) { 453 | uint8_t *y = (uint8_t *)&x; 454 | // All four bytes of a 32-bit value are filtered to avoid a bunch of 455 | // shifting and masking that would be necessary for properly handling 456 | // different endianisms (and each byte is a fairly trivial operation, 457 | // so it might not even be wasting cycles vs a check and branch. 458 | // In theory this might cause trouble *if* someone's storing information 459 | // in the unused most significant byte of an RGB value, but this seems 460 | // exceedingly rare and if it's encountered in reality they can mask 461 | // values going in or coming out. 462 | for (uint8_t i = 0; i < 4; i++) 463 | y[i] = gamma8(y[i]); 464 | return x; // Packed 32-bit return 465 | } 466 | 467 | /*! 468 | @brief Fill DotStar strip with one or more cycles of hues. 469 | Everyone loves the rainbow swirl so much, now it's canon! 470 | @param first_hue Hue of first pixel, 0-65535, representing one full 471 | cycle of the color wheel. Each subsequent pixel will 472 | be offset to complete one or more cycles over the 473 | length of the strip. 474 | @param reps Number of cycles of the color wheel over the length 475 | of the strip. Default is 1. Negative values can be 476 | used to reverse the hue order. 477 | @param saturation Saturation (optional), 0-255 = gray to pure hue, 478 | default = 255. 479 | @param brightness Brightness/value (optional), 0-255 = off to max, 480 | default = 255. This is distinct and in combination 481 | with any configured global strip brightness. 482 | @param gammify If true (default), apply gamma correction to colors 483 | for better appearance. 484 | */ 485 | void Adafruit_DotStar::rainbow(uint16_t first_hue, int8_t reps, 486 | uint8_t saturation, uint8_t brightness, 487 | bool gammify) { 488 | for (uint16_t i = 0; i < numLEDs; i++) { 489 | uint16_t hue = first_hue + (i * reps * 65536) / numLEDs; 490 | uint32_t color = ColorHSV(hue, saturation, brightness); 491 | if (gammify) 492 | color = gamma32(color); 493 | setPixelColor(i, color); 494 | } 495 | } 496 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | 2 | GNU GENERAL PUBLIC LICENSE 3 | Version 3, 29 June 2007 4 | 5 | Copyright (C) 2007 Free Software Foundation, Inc. 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The GNU General Public License is a free, copyleft license for 12 | software and other kinds of works. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | the GNU General Public License is intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. We, the Free Software Foundation, use the 19 | GNU General Public License for most of our software; it applies also to 20 | any other work released this way by its authors. You can apply it to 21 | your programs, too. 22 | 23 | When we speak of free software, we are referring to freedom, not 24 | price. Our General Public Licenses are designed to make sure that you 25 | have the freedom to distribute copies of free software (and charge for 26 | them if you wish), that you receive source code or can get it if you 27 | want it, that you can change the software or use pieces of it in new 28 | free programs, and that you know you can do these things. 29 | 30 | To protect your rights, we need to prevent others from denying you 31 | these rights or asking you to surrender the rights. Therefore, you have 32 | certain responsibilities if you distribute copies of the software, or if 33 | you modify it: responsibilities to respect the freedom of others. 34 | 35 | For example, if you distribute copies of such a program, whether 36 | gratis or for a fee, you must pass on to the recipients the same 37 | freedoms that you received. You must make sure that they, too, receive 38 | or can get the source code. And you must show them these terms so they 39 | know their rights. 40 | 41 | Developers that use the GNU GPL protect your rights with two steps: 42 | (1) assert copyright on the software, and (2) offer you this License 43 | giving you legal permission to copy, distribute and/or modify it. 44 | 45 | For the developers' and authors' protection, the GPL clearly explains 46 | that there is no warranty for this free software. For both users' and 47 | authors' sake, the GPL requires that modified versions be marked as 48 | changed, so that their problems will not be attributed erroneously to 49 | authors of previous versions. 50 | 51 | Some devices are designed to deny users access to install or run 52 | modified versions of the software inside them, although the manufacturer 53 | can do so. This is fundamentally incompatible with the aim of 54 | protecting users' freedom to change the software. The systematic 55 | pattern of such abuse occurs in the area of products for individuals to 56 | use, which is precisely where it is most unacceptable. Therefore, we 57 | have designed this version of the GPL to prohibit the practice for those 58 | products. If such problems arise substantially in other domains, we 59 | stand ready to extend this provision to those domains in future versions 60 | of the GPL, as needed to protect the freedom of users. 61 | 62 | Finally, every program is threatened constantly by software patents. 63 | States should not allow patents to restrict development and use of 64 | software on general-purpose computers, but in those that do, we wish to 65 | avoid the special danger that patents applied to a free program could 66 | make it effectively proprietary. To prevent this, the GPL assures that 67 | patents cannot be used to render the program non-free. 68 | 69 | The precise terms and conditions for copying, distribution and 70 | modification follow. 71 | 72 | TERMS AND CONDITIONS 73 | 74 | 0. Definitions. 75 | 76 | "This License" refers to version 3 of the GNU General Public License. 77 | 78 | "Copyright" also means copyright-like laws that apply to other kinds of 79 | works, such as semiconductor masks. 80 | 81 | "The Program" refers to any copyrightable work licensed under this 82 | License. Each licensee is addressed as "you". "Licensees" and 83 | "recipients" may be individuals or organizations. 84 | 85 | To "modify" a work means to copy from or adapt all or part of the work 86 | in a fashion requiring copyright permission, other than the making of an 87 | exact copy. The resulting work is called a "modified version" of the 88 | earlier work or a work "based on" the earlier work. 89 | 90 | A "covered work" means either the unmodified Program or a work based 91 | on the Program. 92 | 93 | To "propagate" a work means to do anything with it that, without 94 | permission, would make you directly or secondarily liable for 95 | infringement under applicable copyright law, except executing it on a 96 | computer or modifying a private copy. Propagation includes copying, 97 | distribution (with or without modification), making available to the 98 | public, and in some countries other activities as well. 99 | 100 | To "convey" a work means any kind of propagation that enables other 101 | parties to make or receive copies. Mere interaction with a user through 102 | a computer network, with no transfer of a copy, is not conveying. 103 | 104 | An interactive user interface displays "Appropriate Legal Notices" 105 | to the extent that it includes a convenient and prominently visible 106 | feature that (1) displays an appropriate copyright notice, and (2) 107 | tells the user that there is no warranty for the work (except to the 108 | extent that warranties are provided), that licensees may convey the 109 | work under this License, and how to view a copy of this License. If 110 | the interface presents a list of user commands or options, such as a 111 | menu, a prominent item in the list meets this criterion. 112 | 113 | 1. Source Code. 114 | 115 | The "source code" for a work means the preferred form of the work 116 | for making modifications to it. "Object code" means any non-source 117 | form of a work. 118 | 119 | A "Standard Interface" means an interface that either is an official 120 | standard defined by a recognized standards body, or, in the case of 121 | interfaces specified for a particular programming language, one that 122 | is widely used among developers working in that language. 123 | 124 | The "System Libraries" of an executable work include anything, other 125 | than the work as a whole, that (a) is included in the normal form of 126 | packaging a Major Component, but which is not part of that Major 127 | Component, and (b) serves only to enable use of the work with that 128 | Major Component, or to implement a Standard Interface for which an 129 | implementation is available to the public in source code form. A 130 | "Major Component", in this context, means a major essential component 131 | (kernel, window system, and so on) of the specific operating system 132 | (if any) on which the executable work runs, or a compiler used to 133 | produce the work, or an object code interpreter used to run it. 134 | 135 | The "Corresponding Source" for a work in object code form means all 136 | the source code needed to generate, install, and (for an executable 137 | work) run the object code and to modify the work, including scripts to 138 | control those activities. However, it does not include the work's 139 | System Libraries, or general-purpose tools or generally available free 140 | programs which are used unmodified in performing those activities but 141 | which are not part of the work. For example, Corresponding Source 142 | includes interface definition files associated with source files for 143 | the work, and the source code for shared libraries and dynamically 144 | linked subprograms that the work is specifically designed to require, 145 | such as by intimate data communication or control flow between those 146 | subprograms and other parts of the work. 147 | 148 | The Corresponding Source need not include anything that users 149 | can regenerate automatically from other parts of the Corresponding 150 | Source. 151 | 152 | The Corresponding Source for a work in source code form is that 153 | same work. 154 | 155 | 2. Basic Permissions. 156 | 157 | All rights granted under this License are granted for the term of 158 | copyright on the Program, and are irrevocable provided the stated 159 | conditions are met. This License explicitly affirms your unlimited 160 | permission to run the unmodified Program. The output from running a 161 | covered work is covered by this License only if the output, given its 162 | content, constitutes a covered work. This License acknowledges your 163 | rights of fair use or other equivalent, as provided by copyright law. 164 | 165 | You may make, run and propagate covered works that you do not 166 | convey, without conditions so long as your license otherwise remains 167 | in force. You may convey covered works to others for the sole purpose 168 | of having them make modifications exclusively for you, or provide you 169 | with facilities for running those works, provided that you comply with 170 | the terms of this License in conveying all material for which you do 171 | not control copyright. Those thus making or running the covered works 172 | for you must do so exclusively on your behalf, under your direction 173 | and control, on terms that prohibit them from making any copies of 174 | your copyrighted material outside their relationship with you. 175 | 176 | Conveying under any other circumstances is permitted solely under 177 | the conditions stated below. Sublicensing is not allowed; section 10 178 | makes it unnecessary. 179 | 180 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 181 | 182 | No covered work shall be deemed part of an effective technological 183 | measure under any applicable law fulfilling obligations under article 184 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 185 | similar laws prohibiting or restricting circumvention of such 186 | measures. 187 | 188 | When you convey a covered work, you waive any legal power to forbid 189 | circumvention of technological measures to the extent such circumvention 190 | is effected by exercising rights under this License with respect to 191 | the covered work, and you disclaim any intention to limit operation or 192 | modification of the work as a means of enforcing, against the work's 193 | users, your or third parties' legal rights to forbid circumvention of 194 | technological measures. 195 | 196 | 4. Conveying Verbatim Copies. 197 | 198 | You may convey verbatim copies of the Program's source code as you 199 | receive it, in any medium, provided that you conspicuously and 200 | appropriately publish on each copy an appropriate copyright notice; 201 | keep intact all notices stating that this License and any 202 | non-permissive terms added in accord with section 7 apply to the code; 203 | keep intact all notices of the absence of any warranty; and give all 204 | recipients a copy of this License along with the Program. 205 | 206 | You may charge any price or no price for each copy that you convey, 207 | and you may offer support or warranty protection for a fee. 208 | 209 | 5. Conveying Modified Source Versions. 210 | 211 | You may convey a work based on the Program, or the modifications to 212 | produce it from the Program, in the form of source code under the 213 | terms of section 4, provided that you also meet all of these conditions: 214 | 215 | a) The work must carry prominent notices stating that you modified 216 | it, and giving a relevant date. 217 | 218 | b) The work must carry prominent notices stating that it is 219 | released under this License and any conditions added under section 220 | 7. This requirement modifies the requirement in section 4 to 221 | "keep intact all notices". 222 | 223 | c) You must license the entire work, as a whole, under this 224 | License to anyone who comes into possession of a copy. This 225 | License will therefore apply, along with any applicable section 7 226 | additional terms, to the whole of the work, and all its parts, 227 | regardless of how they are packaged. This License gives no 228 | permission to license the work in any other way, but it does not 229 | invalidate such permission if you have separately received it. 230 | 231 | d) If the work has interactive user interfaces, each must display 232 | Appropriate Legal Notices; however, if the Program has interactive 233 | interfaces that do not display Appropriate Legal Notices, your 234 | work need not make them do so. 235 | 236 | A compilation of a covered work with other separate and independent 237 | works, which are not by their nature extensions of the covered work, 238 | and which are not combined with it such as to form a larger program, 239 | in or on a volume of a storage or distribution medium, is called an 240 | "aggregate" if the compilation and its resulting copyright are not 241 | used to limit the access or legal rights of the compilation's users 242 | beyond what the individual works permit. Inclusion of a covered work 243 | in an aggregate does not cause this License to apply to the other 244 | parts of the aggregate. 245 | 246 | 6. Conveying Non-Source Forms. 247 | 248 | You may convey a covered work in object code form under the terms 249 | of sections 4 and 5, provided that you also convey the 250 | machine-readable Corresponding Source under the terms of this License, 251 | in one of these ways: 252 | 253 | a) Convey the object code in, or embodied in, a physical product 254 | (including a physical distribution medium), accompanied by the 255 | Corresponding Source fixed on a durable physical medium 256 | customarily used for software interchange. 257 | 258 | b) Convey the object code in, or embodied in, a physical product 259 | (including a physical distribution medium), accompanied by a 260 | written offer, valid for at least three years and valid for as 261 | long as you offer spare parts or customer support for that product 262 | model, to give anyone who possesses the object code either (1) a 263 | copy of the Corresponding Source for all the software in the 264 | product that is covered by this License, on a durable physical 265 | medium customarily used for software interchange, for a price no 266 | more than your reasonable cost of physically performing this 267 | conveying of source, or (2) access to copy the 268 | Corresponding Source from a network server at no charge. 269 | 270 | c) Convey individual copies of the object code with a copy of the 271 | written offer to provide the Corresponding Source. This 272 | alternative is allowed only occasionally and noncommercially, and 273 | only if you received the object code with such an offer, in accord 274 | with subsection 6b. 275 | 276 | d) Convey the object code by offering access from a designated 277 | place (gratis or for a charge), and offer equivalent access to the 278 | Corresponding Source in the same way through the same place at no 279 | further charge. You need not require recipients to copy the 280 | Corresponding Source along with the object code. If the place to 281 | copy the object code is a network server, the Corresponding Source 282 | may be on a different server (operated by you or a third party) 283 | that supports equivalent copying facilities, provided you maintain 284 | clear directions next to the object code saying where to find the 285 | Corresponding Source. Regardless of what server hosts the 286 | Corresponding Source, you remain obligated to ensure that it is 287 | available for as long as needed to satisfy these requirements. 288 | 289 | e) Convey the object code using peer-to-peer transmission, provided 290 | you inform other peers where the object code and Corresponding 291 | Source of the work are being offered to the general public at no 292 | charge under subsection 6d. 293 | 294 | A separable portion of the object code, whose source code is excluded 295 | from the Corresponding Source as a System Library, need not be 296 | included in conveying the object code work. 297 | 298 | A "User Product" is either (1) a "consumer product", which means any 299 | tangible personal property which is normally used for personal, family, 300 | or household purposes, or (2) anything designed or sold for incorporation 301 | into a dwelling. In determining whether a product is a consumer product, 302 | doubtful cases shall be resolved in favor of coverage. For a particular 303 | product received by a particular user, "normally used" refers to a 304 | typical or common use of that class of product, regardless of the status 305 | of the particular user or of the way in which the particular user 306 | actually uses, or expects or is expected to use, the product. A product 307 | is a consumer product regardless of whether the product has substantial 308 | commercial, industrial or non-consumer uses, unless such uses represent 309 | the only significant mode of use of the product. 310 | 311 | "Installation Information" for a User Product means any methods, 312 | procedures, authorization keys, or other information required to install 313 | and execute modified versions of a covered work in that User Product from 314 | a modified version of its Corresponding Source. The information must 315 | suffice to ensure that the continued functioning of the modified object 316 | code is in no case prevented or interfered with solely because 317 | modification has been made. 318 | 319 | If you convey an object code work under this section in, or with, or 320 | specifically for use in, a User Product, and the conveying occurs as 321 | part of a transaction in which the right of possession and use of the 322 | User Product is transferred to the recipient in perpetuity or for a 323 | fixed term (regardless of how the transaction is characterized), the 324 | Corresponding Source conveyed under this section must be accompanied 325 | by the Installation Information. But this requirement does not apply 326 | if neither you nor any third party retains the ability to install 327 | modified object code on the User Product (for example, the work has 328 | been installed in ROM). 329 | 330 | The requirement to provide Installation Information does not include a 331 | requirement to continue to provide support service, warranty, or updates 332 | for a work that has been modified or installed by the recipient, or for 333 | the User Product in which it has been modified or installed. Access to a 334 | network may be denied when the modification itself materially and 335 | adversely affects the operation of the network or violates the rules and 336 | protocols for communication across the network. 337 | 338 | Corresponding Source conveyed, and Installation Information provided, 339 | in accord with this section must be in a format that is publicly 340 | documented (and with an implementation available to the public in 341 | source code form), and must require no special password or key for 342 | unpacking, reading or copying. 343 | 344 | 7. Additional Terms. 345 | 346 | "Additional permissions" are terms that supplement the terms of this 347 | License by making exceptions from one or more of its conditions. 348 | Additional permissions that are applicable to the entire Program shall 349 | be treated as though they were included in this License, to the extent 350 | that they are valid under applicable law. If additional permissions 351 | apply only to part of the Program, that part may be used separately 352 | under those permissions, but the entire Program remains governed by 353 | this License without regard to the additional permissions. 354 | 355 | When you convey a copy of a covered work, you may at your option 356 | remove any additional permissions from that copy, or from any part of 357 | it. (Additional permissions may be written to require their own 358 | removal in certain cases when you modify the work.) You may place 359 | additional permissions on material, added by you to a covered work, 360 | for which you have or can give appropriate copyright permission. 361 | 362 | Notwithstanding any other provision of this License, for material you 363 | add to a covered work, you may (if authorized by the copyright holders of 364 | that material) supplement the terms of this License with terms: 365 | 366 | a) Disclaiming warranty or limiting liability differently from the 367 | terms of sections 15 and 16 of this License; or 368 | 369 | b) Requiring preservation of specified reasonable legal notices or 370 | author attributions in that material or in the Appropriate Legal 371 | Notices displayed by works containing it; or 372 | 373 | c) Prohibiting misrepresentation of the origin of that material, or 374 | requiring that modified versions of such material be marked in 375 | reasonable ways as different from the original version; or 376 | 377 | d) Limiting the use for publicity purposes of names of licensors or 378 | authors of the material; or 379 | 380 | e) Declining to grant rights under trademark law for use of some 381 | trade names, trademarks, or service marks; or 382 | 383 | f) Requiring indemnification of licensors and authors of that 384 | material by anyone who conveys the material (or modified versions of 385 | it) with contractual assumptions of liability to the recipient, for 386 | any liability that these contractual assumptions directly impose on 387 | those licensors and authors. 388 | 389 | All other non-permissive additional terms are considered "further 390 | restrictions" within the meaning of section 10. If the Program as you 391 | received it, or any part of it, contains a notice stating that it is 392 | governed by this License along with a term that is a further 393 | restriction, you may remove that term. If a license document contains 394 | a further restriction but permits relicensing or conveying under this 395 | License, you may add to a covered work material governed by the terms 396 | of that license document, provided that the further restriction does 397 | not survive such relicensing or conveying. 398 | 399 | If you add terms to a covered work in accord with this section, you 400 | must place, in the relevant source files, a statement of the 401 | additional terms that apply to those files, or a notice indicating 402 | where to find the applicable terms. 403 | 404 | Additional terms, permissive or non-permissive, may be stated in the 405 | form of a separately written license, or stated as exceptions; 406 | the above requirements apply either way. 407 | 408 | 8. Termination. 409 | 410 | You may not propagate or modify a covered work except as expressly 411 | provided under this License. Any attempt otherwise to propagate or 412 | modify it is void, and will automatically terminate your rights under 413 | this License (including any patent licenses granted under the third 414 | paragraph of section 11). 415 | 416 | However, if you cease all violation of this License, then your 417 | license from a particular copyright holder is reinstated (a) 418 | provisionally, unless and until the copyright holder explicitly and 419 | finally terminates your license, and (b) permanently, if the copyright 420 | holder fails to notify you of the violation by some reasonable means 421 | prior to 60 days after the cessation. 422 | 423 | Moreover, your license from a particular copyright holder is 424 | reinstated permanently if the copyright holder notifies you of the 425 | violation by some reasonable means, this is the first time you have 426 | received notice of violation of this License (for any work) from that 427 | copyright holder, and you cure the violation prior to 30 days after 428 | your receipt of the notice. 429 | 430 | Termination of your rights under this section does not terminate the 431 | licenses of parties who have received copies or rights from you under 432 | this License. If your rights have been terminated and not permanently 433 | reinstated, you do not qualify to receive new licenses for the same 434 | material under section 10. 435 | 436 | 9. Acceptance Not Required for Having Copies. 437 | 438 | You are not required to accept this License in order to receive or 439 | run a copy of the Program. Ancillary propagation of a covered work 440 | occurring solely as a consequence of using peer-to-peer transmission 441 | to receive a copy likewise does not require acceptance. However, 442 | nothing other than this License grants you permission to propagate or 443 | modify any covered work. These actions infringe copyright if you do 444 | not accept this License. Therefore, by modifying or propagating a 445 | covered work, you indicate your acceptance of this License to do so. 446 | 447 | 10. Automatic Licensing of Downstream Recipients. 448 | 449 | Each time you convey a covered work, the recipient automatically 450 | receives a license from the original licensors, to run, modify and 451 | propagate that work, subject to this License. You are not responsible 452 | for enforcing compliance by third parties with this License. 453 | 454 | An "entity transaction" is a transaction transferring control of an 455 | organization, or substantially all assets of one, or subdividing an 456 | organization, or merging organizations. If propagation of a covered 457 | work results from an entity transaction, each party to that 458 | transaction who receives a copy of the work also receives whatever 459 | licenses to the work the party's predecessor in interest had or could 460 | give under the previous paragraph, plus a right to possession of the 461 | Corresponding Source of the work from the predecessor in interest, if 462 | the predecessor has it or can get it with reasonable efforts. 463 | 464 | You may not impose any further restrictions on the exercise of the 465 | rights granted or affirmed under this License. For example, you may 466 | not impose a license fee, royalty, or other charge for exercise of 467 | rights granted under this License, and you may not initiate litigation 468 | (including a cross-claim or counterclaim in a lawsuit) alleging that 469 | any patent claim is infringed by making, using, selling, offering for 470 | sale, or importing the Program or any portion of it. 471 | 472 | 11. Patents. 473 | 474 | A "contributor" is a copyright holder who authorizes use under this 475 | License of the Program or a work on which the Program is based. The 476 | work thus licensed is called the contributor's "contributor version". 477 | 478 | A contributor's "essential patent claims" are all patent claims 479 | owned or controlled by the contributor, whether already acquired or 480 | hereafter acquired, that would be infringed by some manner, permitted 481 | by this License, of making, using, or selling its contributor version, 482 | but do not include claims that would be infringed only as a 483 | consequence of further modification of the contributor version. For 484 | purposes of this definition, "control" includes the right to grant 485 | patent sublicenses in a manner consistent with the requirements of 486 | this License. 487 | 488 | Each contributor grants you a non-exclusive, worldwide, royalty-free 489 | patent license under the contributor's essential patent claims, to 490 | make, use, sell, offer for sale, import and otherwise run, modify and 491 | propagate the contents of its contributor version. 492 | 493 | In the following three paragraphs, a "patent license" is any express 494 | agreement or commitment, however denominated, not to enforce a patent 495 | (such as an express permission to practice a patent or covenant not to 496 | sue for patent infringement). To "grant" such a patent license to a 497 | party means to make such an agreement or commitment not to enforce a 498 | patent against the party. 499 | 500 | If you convey a covered work, knowingly relying on a patent license, 501 | and the Corresponding Source of the work is not available for anyone 502 | to copy, free of charge and under the terms of this License, through a 503 | publicly available network server or other readily accessible means, 504 | then you must either (1) cause the Corresponding Source to be so 505 | available, or (2) arrange to deprive yourself of the benefit of the 506 | patent license for this particular work, or (3) arrange, in a manner 507 | consistent with the requirements of this License, to extend the patent 508 | license to downstream recipients. "Knowingly relying" means you have 509 | actual knowledge that, but for the patent license, your conveying the 510 | covered work in a country, or your recipient's use of the covered work 511 | in a country, would infringe one or more identifiable patents in that 512 | country that you have reason to believe are valid. 513 | 514 | If, pursuant to or in connection with a single transaction or 515 | arrangement, you convey, or propagate by procuring conveyance of, a 516 | covered work, and grant a patent license to some of the parties 517 | receiving the covered work authorizing them to use, propagate, modify 518 | or convey a specific copy of the covered work, then the patent license 519 | you grant is automatically extended to all recipients of the covered 520 | work and works based on it. 521 | 522 | A patent license is "discriminatory" if it does not include within 523 | the scope of its coverage, prohibits the exercise of, or is 524 | conditioned on the non-exercise of one or more of the rights that are 525 | specifically granted under this License. You may not convey a covered 526 | work if you are a party to an arrangement with a third party that is 527 | in the business of distributing software, under which you make payment 528 | to the third party based on the extent of your activity of conveying 529 | the work, and under which the third party grants, to any of the 530 | parties who would receive the covered work from you, a discriminatory 531 | patent license (a) in connection with copies of the covered work 532 | conveyed by you (or copies made from those copies), or (b) primarily 533 | for and in connection with specific products or compilations that 534 | contain the covered work, unless you entered into that arrangement, 535 | or that patent license was granted, prior to 28 March 2007. 536 | 537 | Nothing in this License shall be construed as excluding or limiting 538 | any implied license or other defenses to infringement that may 539 | otherwise be available to you under applicable patent law. 540 | 541 | 12. No Surrender of Others' Freedom. 542 | 543 | If conditions are imposed on you (whether by court order, agreement or 544 | otherwise) that contradict the conditions of this License, they do not 545 | excuse you from the conditions of this License. If you cannot convey a 546 | covered work so as to satisfy simultaneously your obligations under this 547 | License and any other pertinent obligations, then as a consequence you may 548 | not convey it at all. For example, if you agree to terms that obligate you 549 | to collect a royalty for further conveying from those to whom you convey 550 | the Program, the only way you could satisfy both those terms and this 551 | License would be to refrain entirely from conveying the Program. 552 | 553 | 13. Use with the GNU Affero General Public License. 554 | 555 | Notwithstanding any other provision of this License, you have 556 | permission to link or combine any covered work with a work licensed 557 | under version 3 of the GNU Affero General Public License into a single 558 | combined work, and to convey the resulting work. The terms of this 559 | License will continue to apply to the part which is the covered work, 560 | but the special requirements of the GNU Affero General Public License, 561 | section 13, concerning interaction through a network will apply to the 562 | combination as such. 563 | 564 | 14. Revised Versions of this License. 565 | 566 | The Free Software Foundation may publish revised and/or new versions of 567 | the GNU General Public License from time to time. Such new versions will 568 | be similar in spirit to the present version, but may differ in detail to 569 | address new problems or concerns. 570 | 571 | Each version is given a distinguishing version number. If the 572 | Program specifies that a certain numbered version of the GNU General 573 | Public License "or any later version" applies to it, you have the 574 | option of following the terms and conditions either of that numbered 575 | version or of any later version published by the Free Software 576 | Foundation. If the Program does not specify a version number of the 577 | GNU General Public License, you may choose any version ever published 578 | by the Free Software Foundation. 579 | 580 | If the Program specifies that a proxy can decide which future 581 | versions of the GNU General Public License can be used, that proxy's 582 | public statement of acceptance of a version permanently authorizes you 583 | to choose that version for the Program. 584 | 585 | Later license versions may give you additional or different 586 | permissions. However, no additional obligations are imposed on any 587 | author or copyright holder as a result of your choosing to follow a 588 | later version. 589 | 590 | 15. Disclaimer of Warranty. 591 | 592 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 593 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 594 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 595 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 596 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 597 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 598 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 599 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 600 | 601 | 16. Limitation of Liability. 602 | 603 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 604 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 605 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 606 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 607 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 608 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 609 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 610 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 611 | SUCH DAMAGES. 612 | 613 | 17. Interpretation of Sections 15 and 16. 614 | 615 | If the disclaimer of warranty and limitation of liability provided 616 | above cannot be given local legal effect according to their terms, 617 | reviewing courts shall apply local law that most closely approximates 618 | an absolute waiver of all civil liability in connection with the 619 | Program, unless a warranty or assumption of liability accompanies a 620 | copy of the Program in return for a fee. 621 | 622 | END OF TERMS AND CONDITIONS 623 | 624 | 625 | 626 | LGPL ADDENDUM: 627 | 628 | 629 | 630 | GNU LESSER GENERAL PUBLIC LICENSE 631 | Version 3, 29 June 2007 632 | 633 | Copyright (C) 2007 Free Software Foundation, Inc. 634 | Everyone is permitted to copy and distribute verbatim copies 635 | of this license document, but changing it is not allowed. 636 | 637 | 638 | This version of the GNU Lesser General Public License incorporates 639 | the terms and conditions of version 3 of the GNU General Public 640 | License, supplemented by the additional permissions listed below. 641 | 642 | 0. Additional Definitions. 643 | 644 | As used herein, "this License" refers to version 3 of the GNU Lesser 645 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 646 | General Public License. 647 | 648 | "The Library" refers to a covered work governed by this License, 649 | other than an Application or a Combined Work as defined below. 650 | 651 | An "Application" is any work that makes use of an interface provided 652 | by the Library, but which is not otherwise based on the Library. 653 | Defining a subclass of a class defined by the Library is deemed a mode 654 | of using an interface provided by the Library. 655 | 656 | A "Combined Work" is a work produced by combining or linking an 657 | Application with the Library. The particular version of the Library 658 | with which the Combined Work was made is also called the "Linked 659 | Version". 660 | 661 | The "Minimal Corresponding Source" for a Combined Work means the 662 | Corresponding Source for the Combined Work, excluding any source code 663 | for portions of the Combined Work that, considered in isolation, are 664 | based on the Application, and not on the Linked Version. 665 | 666 | The "Corresponding Application Code" for a Combined Work means the 667 | object code and/or source code for the Application, including any data 668 | and utility programs needed for reproducing the Combined Work from the 669 | Application, but excluding the System Libraries of the Combined Work. 670 | 671 | 1. Exception to Section 3 of the GNU GPL. 672 | 673 | You may convey a covered work under sections 3 and 4 of this License 674 | without being bound by section 3 of the GNU GPL. 675 | 676 | 2. Conveying Modified Versions. 677 | 678 | If you modify a copy of the Library, and, in your modifications, a 679 | facility refers to a function or data to be supplied by an Application 680 | that uses the facility (other than as an argument passed when the 681 | facility is invoked), then you may convey a copy of the modified 682 | version: 683 | 684 | a) under this License, provided that you make a good faith effort to 685 | ensure that, in the event an Application does not supply the 686 | function or data, the facility still operates, and performs 687 | whatever part of its purpose remains meaningful, or 688 | 689 | b) under the GNU GPL, with none of the additional permissions of 690 | this License applicable to that copy. 691 | 692 | 3. Object Code Incorporating Material from Library Header Files. 693 | 694 | The object code form of an Application may incorporate material from 695 | a header file that is part of the Library. You may convey such object 696 | code under terms of your choice, provided that, if the incorporated 697 | material is not limited to numerical parameters, data structure 698 | layouts and accessors, or small macros, inline functions and templates 699 | (ten or fewer lines in length), you do both of the following: 700 | 701 | a) Give prominent notice with each copy of the object code that the 702 | Library is used in it and that the Library and its use are 703 | covered by this License. 704 | 705 | b) Accompany the object code with a copy of the GNU GPL and this license 706 | document. 707 | 708 | 4. Combined Works. 709 | 710 | You may convey a Combined Work under terms of your choice that, 711 | taken together, effectively do not restrict modification of the 712 | portions of the Library contained in the Combined Work and reverse 713 | engineering for debugging such modifications, if you also do each of 714 | the following: 715 | 716 | a) Give prominent notice with each copy of the Combined Work that 717 | the Library is used in it and that the Library and its use are 718 | covered by this License. 719 | 720 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 721 | document. 722 | 723 | c) For a Combined Work that displays copyright notices during 724 | execution, include the copyright notice for the Library among 725 | these notices, as well as a reference directing the user to the 726 | copies of the GNU GPL and this license document. 727 | 728 | d) Do one of the following: 729 | 730 | 0) Convey the Minimal Corresponding Source under the terms of this 731 | License, and the Corresponding Application Code in a form 732 | suitable for, and under terms that permit, the user to 733 | recombine or relink the Application with a modified version of 734 | the Linked Version to produce a modified Combined Work, in the 735 | manner specified by section 6 of the GNU GPL for conveying 736 | Corresponding Source. 737 | 738 | 1) Use a suitable shared library mechanism for linking with the 739 | Library. A suitable mechanism is one that (a) uses at run time 740 | a copy of the Library already present on the user's computer 741 | system, and (b) will operate properly with a modified version 742 | of the Library that is interface-compatible with the Linked 743 | Version. 744 | 745 | e) Provide Installation Information, but only if you would otherwise 746 | be required to provide such information under section 6 of the 747 | GNU GPL, and only to the extent that such information is 748 | necessary to install and execute a modified version of the 749 | Combined Work produced by recombining or relinking the 750 | Application with a modified version of the Linked Version. (If 751 | you use option 4d0, the Installation Information must accompany 752 | the Minimal Corresponding Source and Corresponding Application 753 | Code. If you use option 4d1, you must provide the Installation 754 | Information in the manner specified by section 6 of the GNU GPL 755 | for conveying Corresponding Source.) 756 | 757 | 5. Combined Libraries. 758 | 759 | You may place library facilities that are a work based on the 760 | Library side by side in a single library together with other library 761 | facilities that are not Applications and are not covered by this 762 | License, and convey such a combined library under terms of your 763 | choice, if you do both of the following: 764 | 765 | a) Accompany the combined library with a copy of the same work based 766 | on the Library, uncombined with any other library facilities, 767 | conveyed under the terms of this License. 768 | 769 | b) Give prominent notice with the combined library that part of it 770 | is a work based on the Library, and explaining where to find the 771 | accompanying uncombined form of the same work. 772 | 773 | 6. Revised Versions of the GNU Lesser General Public License. 774 | 775 | The Free Software Foundation may publish revised and/or new versions 776 | of the GNU Lesser General Public License from time to time. Such new 777 | versions will be similar in spirit to the present version, but may 778 | differ in detail to address new problems or concerns. 779 | 780 | Each version is given a distinguishing version number. If the 781 | Library as you received it specifies that a certain numbered version 782 | of the GNU Lesser General Public License "or any later version" 783 | applies to it, you have the option of following the terms and 784 | conditions either of that published version or of any later version 785 | published by the Free Software Foundation. If the Library as you 786 | received it does not specify a version number of the GNU Lesser 787 | General Public License, you may choose any version of the GNU Lesser 788 | General Public License ever published by the Free Software Foundation. 789 | 790 | If the Library as you received it specifies that a proxy can decide 791 | whether future versions of the GNU Lesser General Public License shall 792 | apply, that proxy's public statement of acceptance of any version is 793 | permanent authorization for you to choose that version for the 794 | Library. 795 | --------------------------------------------------------------------------------