[
  {
    "path": ".clang-format",
    "content": "BasedOnStyle: Google\nColumnLimit: 120\nIndentWidth: 4\nTabWidth: 4\nUseTab: ForContinuationAndIndentation\nAccessModifierOffset: -4\n"
  },
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nindent_style = tab\nindent_size = 4\ncharset = utf-8\ntrim_trailing_whitespace = false\ninsert_final_newline = true\n\n[*.{yml,yaml}]\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".github/CONTRIBUTING.md",
    "content": "# How to contribute\n\nYou can contribute in many different ways, for example report a bug or come up with an idea for improvement.\nIf you are good at programming you could also provide a fix for bugs or Pull Requests with improvements.\nIf you want to help others using CLP you are welcome to extend the [Wiki on GitHub](https://github.com/Legion2/CorsairLightingProtocol/wiki).\n\n## Finding information\n\nGeneral information can be found in the [Readme](https://github.com/Legion2/CorsairLightingProtocol) file at the root of the project.\nInformation about specific topics are written in the [Wiki](https://github.com/Legion2/CorsairLightingProtocol/wiki).\nFor developer there is also an [API documentation](https://legion2.github.io/CorsairLightingProtocol/) for all the public methods and types.\n\n## Writing code\n\nFor writing code I recommend [VS Code](https://code.visualstudio.com/) with the [Clang-Format](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format) and [C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) extensions.\nFor uploading to Arduino boards I use the ArduinoIDE.\n\nThis project consists of two major parts, the CLP library itself, for which the source code can be found in `src/` directory and the example sketches in the `examples/` subdirectories.\nThe main logic for processing commands and creating the LED colors is part of the library source code.\nThe examples only show how to use the library and what can be configured.\nThe library is modular so communication with iCUE and the processing of commands is decoupled and can be extended by other developers.\nSingle parts of the library, such as the LEDController can also be used without iCUE, by just calling the public API of these classes.\n\nThe examples are used by most users as a template which they only modified slightly, so the basic examples should be simple and explicitly show the main configuration options.\nNot all users are developers and may not understand the syntax or semantics of the code, they just alter some values and upload the sketches.\nExamples can also be used to show how some additional or special features can be used, these sketches are not meant to be used by the users directly.\nTo verify that the library can be compiled on all supported platforms, all the examples are compiled in the CI pipeline for different boards.\n\n## Coding conventions\n\nPublic methods must be documented with JavaDoc style comments.\nWhen introducing new methods you should think about if the method should be part of the public API or only used internally.\nAlways use descriptive names for variables, only use acronyms if they are well known and frequently used.\nThe coding style is defined using ClangFormat and automatically checked when you submit a Pull Request.\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: Legion2\npatreon: # Replace with a single Patreon username\nopen_collective: # Replace with a single Open Collective username\nko_fi: # Replace with a single Ko-fi username\ntidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel\ncommunity_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry\nliberapay: # Replace with a single Liberapay username\nissuehunt: # Replace with a single IssueHunt username\notechie: # Replace with a single Otechie username\ncustom: paypal.me/LeonKiefer\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "content": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: ''\nlabels: bug\nassignees: ''\n\n---\n\n**Describe the bug**\nA clear and concise description of what the bug is.\n\n**To Reproduce**\nSteps to reproduce the behavior:\n1. Change to '...'\n2. Upload '....'\n3. See error\n\n**Expected behavior**\nA clear and concise description of what you expected to happen.\n\n**Screenshots**\nIf applicable, add screenshots to help explain your problem.\n\n**System (please complete the following information):**\n - OS: [e.g. Windows 10]\n - Board: [e.g. Arduino Leonardo]\n - Device: [e.g. Lighting Node PRO]\n - Version of IDE: [e.g. Arduino IDE 1.8.13]\n - Version of CLP: [e.g. 0.15.0]\n - Version of CLP Boards: [e.g. 0.2.0]\n - Sketch: [e.g. RepeatAndScale]\n\n**Code changes**\nDid you changed the code of the library or the sketch?\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/support.md",
    "content": "---\nname: Support\nabout: You have a problem using this project and need help?\ntitle: ''\nlabels: support\nassignees: ''\n\n---\n\n**Describe the problem**\nA clear and concise description of your problem.\n\n**Screenshots**\nIf applicable, add screenshots to help explain your problem.\n\n**System (please complete the following information):**\n - OS: [e.g. Windows 10]\n - Board: [e.g. Arduino Leonardo]\n - Device: [e.g. Lighting Node PRO]\n - Version of IDE: [e.g. Arduino IDE 1.8.13]\n - Version of CLP: [e.g. 0.15.0]\n - Version of CLP Boards: [e.g. 0.2.0]\n - Sketch: [e.g. RepeatAndScale]\n\n**Code changes**\nDid you changed the code of the library or the sketch?\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"daily\"\n"
  },
  {
    "path": ".github/workflows/documentation.yml",
    "content": "name: Deploy Documentation\n\non:\n  push:\n    branches:\n      - dev\n\njobs:\n  doxygen:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v4\n      - name: Install doxygen\n        run: sudo apt install doxygen graphviz\n      - name: Fix Readme title\n        run: sed -i '1s/ \\[/\\n\\[/' README.md\n      - name: Run doxygen\n        run: doxygen extra/doxygen.conf\n      - name: Deploy to gh-pages\n        uses: peaceiris/actions-gh-pages@v3.9.2\n        with:\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n          publish_branch: gh-pages\n          publish_dir: doxygen/html\n"
  },
  {
    "path": ".github/workflows/lint.yml",
    "content": "name: Check Code Format\n\non: [push, pull_request]\n\njobs:\n  lint:\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v4\n    - name: Check src format\n      uses: DoozyX/clang-format-lint-action@v0.18\n      with:\n        source: './src'\n        extensions: 'h,cpp'\n        clangFormatVersion: 9\n    - name: Check examples format\n      uses: DoozyX/clang-format-lint-action@v0.18 \n      with:\n        source: './examples'\n        extensions: 'h,cpp,ino'\n        clangFormatVersion: 9\n"
  },
  {
    "path": ".github/workflows/push.yml",
    "content": "on: [push, pull_request, workflow_dispatch]\nname: Test\njobs:\n  test:\n    name: Test for Board ${{ matrix.board }}\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        board:\n          [\n            \"Legion2:avr:leonardoclp\",\n            \"Legion2:avr:promicro5vclp\",\n            \"Legion2:avr:promicro3vclp\",\n          ]\n    steps:\n      - uses: actions/checkout@v4\n      - name: Build for ${{ matrix.board }}\n        uses: ArminJo/arduino-test-compile@v3\n        with:\n          cli-version: 0.18.3\n          arduino-board-fqbn: ${{ matrix.board }}\n          platform-url: https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json,https://raw.githubusercontent.com/Legion2/CorsairLightingProtocolBoards/master/package_Legion2_CorsairLightingProtocolBoards_index.json\n          arduino-platform: arduino:avr@1.8.3,SparkFun:avr@1.1.13,Legion2:avr@0.3.1\n          required-libraries: FastLED@3.5.0\n          sketch-names: LightingNodePRO.ino,\n            SingleStripLightingNodePRO.ino,\n            CommanderPRO.ino,\n            DeviceIDTool.ino,\n            RepeatAndScale.ino,\n            TransformLLFansFormatToStrip.ino,\n            LS100.ino,\n            LT100.ino,\n            LightingNodeCORE.ino,\n            NonAddressable.ino,\n            AdditionalFeatures.ino,\n            AmbientBacklight.ino,\n            MultipleFans.ino,\n            DebugSketch.ino,\n            NoEEPROM.ino\n          build-properties: '{\"DebugSketch\": \"-DDEBUG -DVERBOSE -DPRINT_COMMAND=true -DPRINT_RESPONSE=true -DPRINT_LOOP=true -DPRINT_UPDATE=true\"}'\n  testUnoMega:\n    name: Test Arduino Uno/Mega sketches for Board ${{ matrix.board }}\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        board: [\"arduino:avr:uno\", \"arduino:avr:mega:cpu=atmega2560\"]\n    steps:\n      - uses: actions/checkout@v4\n      - name: Build for ${{ matrix.board }}\n        uses: ArminJo/arduino-test-compile@v3\n        with:\n          cli-version: 0.18.3\n          arduino-board-fqbn: ${{ matrix.board }}\n          arduino-platform: arduino:avr@1.8.3\n          required-libraries: FastLED@3.5.0\n          sketch-names: HoodLoader2UnoMegaController.ino\n  test16u2:\n    name: Test 16u2 sketch for Board ${{ matrix.board }}\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        board: [\"Legion2:avr:HoodLoader2atmega16u2clp\"]\n    steps:\n      - uses: actions/checkout@v4\n      - name: Build for ${{ matrix.board }}\n        uses: ArminJo/arduino-test-compile@v3\n        with:\n          cli-version: 0.18.3\n          arduino-board-fqbn: ${{ matrix.board }}\n          platform-url: https://raw.githubusercontent.com/NicoHood/HoodLoader2/master/package_NicoHood_HoodLoader2_index.json,https://raw.githubusercontent.com/Legion2/CorsairLightingProtocolBoards/master/package_Legion2_CorsairLightingProtocolBoards_index.json\n          arduino-platform: arduino:avr@1.8.3,HoodLoader2:avr@2.0.5,Legion2:avr@0.3.1\n          required-libraries: FastLED@3.5.0\n          sketch-names: HoodLoader2CLPBridge.ino\n  testAdafruitSAMD:\n    name: Test for Board ${{ matrix.board }}\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        board:\n          [\n            \"adafruit:samd:adafruit_feather_m0:usbstack=tinyusb\",\n            \"adafruit:samd:adafruit_metro_m0:usbstack=tinyusb\",\n            \"adafruit:samd:adafruit_circuitplayground_m0:usbstack=tinyusb\",\n            \"adafruit:samd:adafruit_gemma_m0:usbstack=tinyusb\",\n            \"adafruit:samd:adafruit_trinket_m0:usbstack=tinyusb\",\n            \"adafruit:samd:adafruit_qtpy_m0:usbstack=tinyusb\",\n            \"adafruit:samd:adafruit_itsybitsy_m0:usbstack=tinyusb\",\n            \"adafruit:samd:adafruit_itsybitsy_m4:usbstack=tinyusb\",\n            \"adafruit:samd:adafruit_metro_m4_airliftlite:usbstack=tinyusb\",\n#           \"adafruit:samd:adafruit_feather_m4:usbstack=tinyusb\", #Should work but doesn't have the pins needed for the sketch \n            \"adafruit:samd:adafruit_matrixportal_m4:usbstack=tinyusb\"\n          ]\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v4\n      - name: Build for ${{ matrix.board }}\n        uses: ArminJo/arduino-test-compile@v3\n        with:\n          cli-version: 0.18.3\n          arduino-board-fqbn: ${{ matrix.board }}\n          platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json\n          arduino-platform: adafruit:samd@1.7.8\n          required-libraries: FastLED@3.5.0,Adafruit TinyUSB Library@1.9.2\n          sketch-names: TinyUSB.ino\n  testAdafruitnRF52:\n    name: Test for Board ${{ matrix.board }}\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        board:\n          [\n            \"adafruit:nrf52:feather52840\",\n            \"adafruit:nrf52:itsybitsy52840\",\n#           \"adafruit:nrf52:cplaynrf52840\", #Should work but doesn't have the pins needed for the sketch\n            \"adafruit:nrf52:metro52840\"\n          ]\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v4\n      - name: Get adafruit-nrfutil\n        run: |\n          pip3 install adafruit-nrfutil --user\n      - name: Build for ${{ matrix.board }}\n        uses: ArminJo/arduino-test-compile@v3\n        with:\n          cli-version: 0.18.3\n          arduino-board-fqbn: ${{ matrix.board }}\n          platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json\n          arduino-platform: adafruit:nrf52@1.3.0\n          required-libraries: FastLED@3.5.0,Adafruit TinyUSB Library@1.9.2\n          sketch-names: TinyUSB.ino"
  },
  {
    "path": ".github/workflows/stale.yaml",
    "content": "name: 'Close stale issues and PRs'\non:\n  schedule:\n    - cron: '30 1 * * *'\n\njobs:\n  stale:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/stale@v9\n        with:\n          days-before-stale: 14\n          days-before-close: 7\n          exempt-issue-labels: bug,enhancement,refactoring,documentation\n          stale-issue-message: >\n            This issue has been automatically marked as stale because it has not had\n            recent activity. It will be closed if no further activity occurs. Thank you\n            for your contributions.\n"
  },
  {
    "path": ".gitignore",
    "content": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n\n# User-specific files\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n\n# Visual Studio 2015 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUNIT\n*.VisualState.xml\nTestResult.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# DNX\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n\n*_i.c\n*_p.c\n*_i.h\n*.ilk\n*.meta\n*.obj\n*.pch\n*.pdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opendb\n*.opensdf\n*.sdf\n*.cachefile\n*.VC.db\n*.VC.VC.opendb\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# JustCode is a .NET coding add-in\n.JustCode\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\nnCrunchTemp_*\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n# TODO: Comment the next line if you want to checkin your web deploy settings\n# but database connection strings (with potential passwords) will be unencrypted\n#*.pubxml\n*.publishproj\n\n# Microsoft Azure Web App publish settings. Comment the next line if you want to\n# checkin your Azure Web App publish settings, but sensitive information contained\n# in these scripts will be unencrypted\nPublishScripts/\n\n# NuGet Packages\n*.nupkg\n# The packages folder can be ignored because of Package Restore\n**/packages/*\n# except build/, which is used as an MSBuild target.\n!**/packages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/packages/repositories.config\n# NuGet v3's project.json files produces more ignoreable files\n*.nuget.props\n*.nuget.targets\n\n# Microsoft Azure Build Output\ncsx/\n*.build.csdef\n\n# Microsoft Azure Emulator\necf/\nrcf/\n\n# Windows Store app package directories and files\nAppPackages/\nBundleArtifacts/\nPackage.StoreAssociation.xml\n_pkginfo.txt\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!*.[Cc]ache/\n\n# Others\nClientBin/\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.jfm\n*.pfx\n*.publishsettings\nnode_modules/\norleans.codegen.cs\n\n# Since there are multiple workflows, uncomment next line to ignore bower_components\n# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)\n#bower_components/\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\n\n# SQL Server files\n*.mdf\n*.ldf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# GhostDoc plugin setting file\n*.GhostDoc.xml\n\n# Node.js Tools for Visual Studio\n.ntvs_analysis.dat\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio LightSwitch build output\n**/*.HTMLClient/GeneratedArtifacts\n**/*.DesktopClient/GeneratedArtifacts\n**/*.DesktopClient/ModelManifest.xml\n**/*.Server/GeneratedArtifacts\n**/*.Server/ModelManifest.xml\n_Pvt_Extensions\n\n# Paket dependency manager\n.paket/paket.exe\npaket-files/\n\n# FAKE - F# Make\n.fake/\n\n# JetBrains Rider\n.idea/\n*.sln.iml\n\n# CodeRush\n.cr/\n\n# Python Tools for Visual Studio (PTVS)\n__pycache__/\n*.pyc\n\n__vm/\n\n # Visual Studio\n*.sln\n*.vcxproj\n*.vcxproj.filters\n*.vcxitems\n\n/doxygen\n\n# VS Code settings\n.vscode/\n\n# Arduino CLI\nbuild/\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# Corsair Lighting Protocol [![arduino-library-badge](https://www.ardu-badge.com/badge/Corsair%20Lighting%20Protocol.svg?)](https://www.ardu-badge.com/Corsair%20Lighting%20Protocol) [![Test Status](https://github.com/Legion2/CorsairLightingProtocol/workflows/Test/badge.svg)](https://github.com/Legion2/CorsairLightingProtocol/actions?query=workflow%3ATest+branch%3Adev+event%3Apush) [![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/Legion2/CorsairLightingProtocol.svg)](https://isitmaintained.com/project/Legion2/CorsairLightingProtocol \"Average time to resolve an issue\")\n\n<a href=\"https://www.corsair.com/icue\"><img src=\"extra/images/iCUEDarkBadge.png\" alt=\"iCUE\" height=\"80\" /></a>\n<a href=\"https://rgbsync.com/\"><img src=\"extra/images/RGBSyncDarkBadge.png\" alt=\"RGBSync\" height=\"80\" /></a>\n<a href=\"https://gitlab.com/CalcProgrammer1/OpenRGB\"><img src=\"extra/images/OpenRGBBadge.png\" alt=\"OpenRGB\" height=\"80\" /></a>\n<a href=\"https://signalrgb.com\"><img src=\"extra/images/SignalRGBBadge.png\" alt=\"SignalRGB\" height=\"80\" /></a>\n\n\n**This library can be used to integrate custom/unofficial RGB strips with iCUE.**\n_This is not an official Corsair project._\n\n## Features\n* Add support of Corsair DIY device protocol to Arduino.\n* Control LEDs with the [Corsair iCUE software](https://www.corsair.com/icue).\n* [Support common LED chipsets](https://github.com/FastLED/FastLED/wiki/Overview#chipsets). (e.g. WS2812B, WS2801)\n* Support [FastLED](http://fastled.io/).\n* Supported platforms: Arduino AVR, [TinyUSB supported cores](https://github.com/adafruit/Adafruit_TinyUSB_Arduino#supported-cores)\n* Hardware Lighting mode.\n* Use multiple devices at the same time.\n* Repeat or scale LED channels to arbitrary size.\n\n### Supported Devices\n* Lighting Node PRO\n* Commander PRO\n* Lighting Node CORE\n* LS100 Smart Lighting Controller\n* LT100 Smart Lighting Towers\n\n![Overview](extra/images/overview.png)\n\n# Getting started\nThis project is an Arduino library called \"Corsair Lighting Protocol\".\nIt can be used to control Arduino boards with iCUE.\nThis project provides example sketches for easy use with Arduino IDE.\n\n- [Requirements](#requirements)\n- [Install the libraries](#install-the-libraries)\n- [Create a Lighting Node PRO with AVR](#create-a-lighting-node-pro-with-avr)\n- [Create a Lighting Node PRO with TinyUSB](#create-a-lighting-node-pro-for-a-raspberry-pi-pico-with-tinyusb)\n- [Use the Lighting Node PRO](#use-the-lighting-node-pro)\n\n## Requirements\nThe library is compatible with all boards using the MCU ATmega32U4.\nThis includes **Arduino Leonardo**, **SparkFun Pro Micro**, **Arduino Micro**, and **Adafruit 32u4 AVR Boards**.\nIt also supports the Arduino Uno and Arduino Mega, **but** this requires the [HoodLoader2](https://github.com/NicoHood/HoodLoader2) bootloader, see [this wiki](https://github.com/Legion2/CorsairLightingProtocol/wiki/How-to-use-on-Arduino-Uno-and-Arduino-Mega) for more details.\n\nIn addition, any board compatible with **Adafruit TinyUSB for Arduino** is also supported without the use of custom board definitions. Be sure to define USE_TINYUSB, which is done automatically when using a supported core and selecting TinyUSB for the USB Stack. See the TinyUSB example for implementation details.\n\nIt is **not** compatible with ATmega328 (Arduino Nano), STM8S103F3, teensy, or ESP8266 see [list of architecture/platform](https://github.com/Legion2/CorsairLightingProtocol/issues?q=is%3Aissue+label%3Aarchitecture%2Fplatform) for a detailed description why they are not supported.\n\nIn the rest of the documentation \"Arduino\" is used as a synonym for all supported boards regardless of the manufacturer.\n\nWhen you have problems with a board not listed here, please open an [Issue](https://github.com/Legion2/CorsairLightingProtocol/issues).\n\n## Install the libraries\nTo use this library you must install it with the Library-Manager.\nOpen the Library-Manager in Arduino IDE via Tools->Manage Libraries...\nSearch for \"Corsair Lighting Protocol\" and install the Corsair Lighting Protocol library.\nThis library also requires the [FastLED](http://fastled.io/) library.\nSearch for \"FastLED\" in the Library-Manager and install the FastLED library.\nIf using TinyUSB, also install the latest \"Adafruit TinyUSB Library\" as it supersedes some of the core versions.\n\n## Create a Lighting Node PRO with AVR\nThis guide will teach you how to create a Lighting Node PRO with an Arduino Leonardo compatible board.\nIf you have an Arduino Uno or Mega, see the [other guide](https://github.com/Legion2/CorsairLightingProtocol/wiki/How-to-use-on-Arduino-Uno-and-Arduino-Mega).\n\n1. Open the example \"LightingNodePRO\", you can find it in Arduino IDE in the File menu->Examples->Corsair Lighting Protocol->LightingNodePRO.\n   If you can't open the LightingNodePRO example the Corsair Lighting Protocol library is not installed correctly.\n\n   ![open example sketch](extra/images/open-example.png)\n1. Install the [CLP Boards](https://github.com/Legion2/CorsairLightingProtocolBoards).\n   They can be installed by following the [CLP Boards installation guide](https://github.com/Legion2/CorsairLightingProtocolBoards#how-to-use-these-boards-in-arduino).\n   After installation it should be possible to select the CLP Boards in the Arduino IDE as shown in the screenshot below.\n   If your are using a Sparkfun Pro Micro also install the [SparkFun Boards definition](https://github.com/sparkfun/Arduino_Boards#installation-instructions).\n\n   ![select CLP Board](extra/images/select-board.png)\n1. Upload the \"LightingNodePRO\" sketch to your Arduino.\n\n   ![upload sketch](extra/images/upload-sketch.png)\n1. Do the wiring.\n   For more information on [how to wire the LEDs](https://github.com/FastLED/FastLED/wiki/Wiring-leds) and [how to set up the LEDs in the code](https://github.com/FastLED/FastLED/wiki/Basic-usage#setting-up-the-leds) see the links.\n   \n   ![the wiring](extra/images/board-wiring.jpg)\n1. Verify your device works as expected.\n   Open the Windows settings->devices->Other devices.\n   Somewhere in the list of devices, there should be a device called \"Lighting Node PRO\".\n1. Now open [iCUE](https://www.corsair.com/icue) there you should see the \"Lighting Node PRO\".\n\n> If you have any problem during setup you may find the solution in the [Troubleshooting section](https://github.com/Legion2/CorsairLightingProtocol/wiki/Troubleshooting).\n\n## Create a Lighting Node PRO for a Raspberry Pi Pico with TinyUSB\n\nThis guide will teach you how to create a Lighting Node PRO with a Raspberry Pi Pico.\n\n**Note:** FastLED currently does not support the RP2040 natively. You must manually merge support by modifying your library to include the [6 RP2040 platform files](https://github.com/FastLED/FastLED/pull/1261/files#diff-fda1710ad90fcc4b2f07be21a834da7d24b00008867655232c84fb0369cfc74b) in the FastLED/src/platforms/arm/rp2040 folder and `#elif defined(ARDUINO_ARCH_RP2040)` / `#include` statements in [led_sysdefs.h](https://github.com/FastLED/FastLED/pull/1261/files#diff-95f6b43a0e6b0e58988e1be3bc6415ded5284082a4f2ce2aaa90f5931d4194af) and [platforms.h](https://github.com/FastLED/FastLED/pull/1261/files#diff-255ea38a6573ed237ea1fe164d5e87ca46811eef21ba6e2cef120fda47c6e62f).\n\n1. Install the [Raspberry Pi Pico Arduino core](https://github.com/earlephilhower/arduino-pico#installing-via-arduino-boards-manager).\n\n1. Open the example \"TinyUSB\", you can find it in Arduino IDE in the File menu->Examples->Corsair Lighting Protocol->TinyUSB.\n   If you can't open the LightingNodePRO example the Corsair Lighting Protocol library is not installed correctly.\n\n1. Select the Raspberry Pi Pico as shown in the screenshot below. Be sure to select the \"Adafruit TinyUSB\" USB Stack.\n\n   ![select Raspberry Pi Pico](extra/images/select-board-pico.png)\n1. Upload the \"TinyUSB\" sketch to your Pico.\n\n1. Do the wiring.\n   For more information on [how to wire the LEDs](https://github.com/FastLED/FastLED/wiki/Wiring-leds) and [how to set up the LEDs in the code](https://github.com/FastLED/FastLED/wiki/Basic-usage#setting-up-the-leds) see the links.\n\n   A level shifter or buffer, like [this one](https://www.ti.com/product/SN74AHCT1G126), is recommended in between the Pico and LEDs to translate the 3.3v logic level of the Pico IO to the 5v logic level of the LEDs. Your setup may not work reliably without one.\n   \n   ![the wiring](extra/images/board-wiring-pico.jpg)\n1. Verify your device works as expected.\n   Open the Windows settings->devices->Other devices.\n   Somewhere in the list of devices, there should be a device called \"Lighting Node PRO\".\n1. Now open [iCUE](https://www.corsair.com/icue) there you should see the \"Lighting Node PRO\".\n\n## Use the Lighting Node PRO\n\n![iCUE RGB Strip example](extra/images/iCUE.jpg)\n\nIn iCUE open the \"Lighting Setup\" tab of the Lighting Node PRO(LNP) and set for both Lighting Channels the device to \"RGB Light Strip\" and the amount to a tenth of the LEDs you have.\niCUE groups the LEDs into groups of ten.\nSo if you have 20 LEDs, set the amount to 2.\nNow you can create lighting effects in the \"Lighting Channel #\" tabs.\n\n# Documentation\n\n- [API Documentation](https://legion2.github.io/CorsairLightingProtocol/)\n- [How it works](#how-it-works)\n- [Use of multiple devices](#use-of-multiple-devices)\n- [Repeat or scale LED channels](#repeat-or-scale-led-channels)\n- [Increase the Brightness of the LEDs](#increase-the-brightness-of-the-leds)\n- [Hardware Lighting mode](#hardware-lighting-mode)\n\n## How it works\nThis library uses the USB HID interface of the ATmega32U4.\nAfter uploading a sketch with the library and selected CLP Boards, iCUE recognizes the Arduino as a Corsair device, because the CLP Boards use USB IDs of Corsair.\nIn iCUE you can then select the device and set some lighting effects.\niCUE sends these via the HID protocol to the Arduino.\nThese commands are understood by the library and converted into lighting effects on the RGB strips connected to the Arduino.\nThe [FastLED](http://fastled.io/) library is used to control the LEDs.\n\n## Use of multiple devices\nEach device has two unique IDs, that is, they should be unique.\nYou must give each device a unique ID.\nThere are two IDs that must be changed `Serial Number` and `DeviceID`.\n\nThe Serial Number can be set in the constructor of `CorsairLightingProtocolHID` and `CLPUSBSerialBridge` as shown in the [example](examples/AdditionalFeatures/AdditionalFeatures.ino).\n```C++\nconst char mySerialNumber[] PROGMEM = \"202B6949A967\";\nCorsairLightingProtocolHID cHID(&cLP, mySerialNumber);\n```\nThe Serial Number MAY only consist of HEX characters (0-9 and A-F).\n\nThe DeviceID can be set with the `setDeviceID` function of `CorsairLightingFirmware`.\n```C++\nvoid setup() {\n    DeviceID deviceId = { 0x9A, 0xDA, 0xA7, 0x8E };\n    firmware.setDeviceID(deviceId);\n    ...\n}\n```\n\n### Alternative\nThe `DeviceID` can be changed with the [DeviceIDTool](examples/DeviceIDTool/DeviceIDTool.ino).\nUpload the DeviceIDTool sketch and then open the Serial monitor with baudrate 115200.\nThe tool displays the current DeviceID, you can type in a new DeviceID that is saved on the Arduino.\nAfter that, you can upload another sketch.\n\n## Repeat or scale LED channels\nYou can repeat or scale LED channel controlled by iCUE onto physical LED strips.\nThis is very useful if you have very long LED strips that are longer than 60/96/135 LEDs, which is the maximum number iCUE supports.\n\nTo repeat or scale a LED channel you must apply the `CLP::repeat` or the `CLP:scale` function in the update hook of the FastLEDController.\nSee the [RepeatAndScale](examples/RepeatAndScale/RepeatAndScale.ino) example for the complete code.\nBoth functions take the FastLEDController pointer and the channel index as arguments.\nAdditionally, the `repeat` function takes as an argument how often the LED channel should be repeated.\nFor example, if you want to duplicate the channel you must pass `2` as argument.\nThe `scale` function takes as third argument the length of the physical LED strip to which it scales the channel using integer scaling.\nFor example you have 144 physical LEDs on you strip and 60 on the LED channel.\nThen the third argument of the `scale` function is `144`.\n\nFor both functions it's **important**, that the CRGB arrays have at least the length of the physical LED strip.\nThis means if your LED channel from iCUE has 50 LEDs and you use the `repeat` function to control 100 physical LEDs you MUST declare the CRGB array at least with a length of 100.\n\n## Increase the Brightness of the LEDs\nWhen using LS100 or LT100 iCUE only uses 50% of the LEDs brightness even if you set the brightness to max in the iCUE Device Settings.\nBut there are good news, we can increase the brightness with the Arduino so we can use the full brightness of our LEDs.\nAdd the `CLP::fixIcueBrightness` function to the `onUpdateHook` in the setup function as shown in the [example](examples/AmbientBacklight/AmbientBacklight.ino).\nIf there are multiple functions called in `onUpdateHook`, `fixIcueBrightness` should be the first.\nOnly use this function with LS100 and LT100 devices!\n```C++\nledController.onUpdateHook(0, []() {\n\tCLP::fixIcueBrightness(&ledController, 0);\n});\n```\n\n## Reverse direction of LED Strip\nIf you want to change the direction of the LEDs of the Strip without physically change the strip, the `CLP::reverse` function can be used.\nThe reverse function must be called be for scaling.\n```C++\nledController.onUpdateHook(0, []() {\n\tCLP::reverse(&ledController, 0);\n});\n```\n## Hardware Lighting mode\nThe [Hardware Lighting mode](https://forum.corsair.com/v3/showthread.php?t=182874) can be configured in iCUE.\nIt allows you the set lighting effects that will be active when iCUE **is not** running.\nThis is the case when the PC is off, in sleep mode, booting or the user is logged out.\nSo if you want to have lighting effects in all these situations, use the Hardware Lighting mode.\nIf you don't want it, configure a static black color.\n\n# License\nThis project is licensed under the Apache 2.0 License.\n\n# DISCLAIMERS\nThis is a DO IT YOURSELF project, use at your own risk!\n\n# Credits\n- [HoodLoader2](https://github.com/NicoHood/HoodLoader2)\n- [Arduino HID Project](https://github.com/NicoHood/HID)\n- [Protocol Information](https://github.com/audiohacked/OpenCorsairLink/issues/70)\n\n## Related projects\n- [CorsairArduinoController](https://github.com/TylerSeiford/CorsairArduinoController)\n- [CorsairLightingProtocolBoards](https://github.com/Legion2/CorsairLightingProtocolBoards)\n- [OpenCorsairLighting](https://github.com/McHauge/OpenCorsairLighting)\n"
  },
  {
    "path": "examples/.clang-format",
    "content": "BasedOnStyle: Google\nColumnLimit: 120\nIndentWidth: 4\nTabWidth: 4\nUseTab: ForContinuationAndIndentation\nAccessModifierOffset: -4\n\nAllowShortBlocksOnASingleLine: false\nAllowShortFunctionsOnASingleLine: false\nAllowShortLambdasOnASingleLine: false\n"
  },
  {
    "path": "examples/AdditionalFeatures/AdditionalFeatures.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\nCRGB ledsChannel1[60];\nCRGB ledsChannel2[60];\n\n// Define a custom SerialNumber for the device\nconst char mySerialNumber[] PROGMEM = \"202B6949A967\";\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\n// Set the SerialNumber here\nCorsairLightingProtocolHID cHID(&cLP, mySerialNumber);\n\nvoid setup() {\n\t// Disable the build in RX and TX LEDs of the Arduino\n\tCLP::disableBuildInLEDs();\n\t// enable reset on DeviceId (FF FF FF FF)\n\tif (CLP::shouldReset(&firmware)) {\n\t\t// reset DeviceId and generate new one\n\t\tCLP::reset(&firmware);\n\t\t// reset the LEDController Settings\n\t\tledController.reset();\n\t}\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 60);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 60);\n\tledController.addLEDs(0, ledsChannel1, 60);\n\tledController.addLEDs(1, ledsChannel2, 60);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t\tCLP::printFps(5000);\n\t}\n}\n"
  },
  {
    "path": "examples/AmbientBacklight/AmbientBacklight.ino",
    "content": "/*\n   Copyright 2020 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n// Hint: The channels are swapped in iCUE, so the first channel in iCUE is here channel 2\n#define DATA_PIN_CHANNEL_1 2  // For the monitor backlight\n#define DATA_PIN_CHANNEL_2 3\n\nCRGB ledsChannel1[84];\nCRGB ledsChannel2[105];\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_SMART_LIGHTING_CONTROLLER, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 84);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 105);\n\tledController.addLEDs(0, ledsChannel1, 84);\n\tledController.addLEDs(1, ledsChannel2, 105);\n\tledController.onUpdateHook(0, []() {\n\t\t// increase the brightness of channel 1 when using iCUE, because iCUE only set brightness to max 50%\n\t\tCLP::fixIcueBrightness(&ledController, 0);\n\t\t// gamma correction with gamma value 2.0. Use napplyGamma_video for other gamma values.\n\t\tCLP::gammaCorrection(&ledController, 0);\n\t\t// napplyGamma_video(ledsChannel1, 84, 2.2);\n\t});\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/CommanderPRO/CommanderPRO.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#include \"SimpleFanController.h\"\n#include \"ThermistorTemperatureController.h\"\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\n#define TEMP_SENSOR_PIN_1 A6\n#define TEMP_SENSOR_PIN_2 A8\n\n#define FAN_UPDATE_RATE 500\n#define PWM_FAN_PIN_1 5\n#define PWM_FAN_PIN_2 6\n#define PWM_FAN_PIN_3 9\n#define PWM_FAN_PIN_4 10\n\n#define CHANNEL_LED_COUNT 96\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_COMMANDER_PRO, &firmwareStorage);\nThermistorTemperatureController temperatureController;\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nSimpleFanController fanController(&temperatureController, FAN_UPDATE_RATE, EEPROM_ADDRESS + storage.getEEPROMSize());\nCorsairLightingProtocolController cLP(&ledController, &temperatureController, &fanController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nCRGB ledsChannel1[CHANNEL_LED_COUNT];\nCRGB ledsChannel2[CHANNEL_LED_COUNT];\n\nPWMFan fan1(PWM_FAN_PIN_1, 0, 2000);\nPWMFan fan2(PWM_FAN_PIN_2, 0, 2000);\nPWMFan fan3(PWM_FAN_PIN_3, 0, 2000);\nPWMFan fan4(PWM_FAN_PIN_4, 0, 2000);\n\nvoid setup() {\n\tCLP::disableBuildInLEDs();\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, CHANNEL_LED_COUNT);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, CHANNEL_LED_COUNT);\n\tledController.addLEDs(0, ledsChannel1, CHANNEL_LED_COUNT);\n\tledController.addLEDs(1, ledsChannel2, CHANNEL_LED_COUNT);\n\ttemperatureController.addSensor(0, TEMP_SENSOR_PIN_1);\n\ttemperatureController.addSensor(1, TEMP_SENSOR_PIN_2);\n\tfanController.addFan(0, &fan1);\n\tfanController.addFan(1, &fan2);\n\tfanController.addFan(2, &fan3);\n\tfanController.addFan(3, &fan4);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n\tfanController.updateFans();\n}\n"
  },
  {
    "path": "examples/CommanderPRO/PWMFan.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"PWMFan.h\"\n\nPWMFan::PWMFan(uint8_t pwmPin, uint16_t minRPM, uint16_t maxRPM) : pwmPin(pwmPin), minRPM(minRPM), maxRPM(maxRPM) {\n\tpinMode(pwmPin, OUTPUT);\n\tanalogWrite(pwmPin, 0);\n\tswitch (digitalPinToTimer(pwmPin)) {\n\t\tcase TIMER0B: /* 3 */\n#ifdef DEBUG\n\t\t\tSerial.println(F(\"Pin not supported as PWM fan pin\"));\n\t\t\tSerial.println(F(\"We don't want to mess up Arduino time functions\"));\n#endif  // DEBUG\n\t\t\tbreak;\n\t\tcase TIMER3A: /* 5 */\n\t\t\tTCCR3B = (TCCR3B & B11111000) | 0x01;\n\t\t\tbreak;\n\t\tcase TIMER4D: /* 6 */\n\t\t\t// PLLFRQ = (PLLFRQ & B11001111) | (0x03 << PLLTM0);\n\t\t\tTCCR4B = (TCCR4B & B11110000) | 0x01;\n\t\t\tbreak;\n\t\tcase TIMER1A: /* 9 */\n\t\t\tTCCR1B = (TCCR1B & B11111000) | 0x01;\n\t\t\tbreak;\n\t\tcase TIMER1B: /* 10 */\n\t\t\tTCCR1B = (TCCR1B & B11111000) | 0x01;\n\t\t\tbreak;\n\t\tdefault:\n#ifdef DEBUG\n\t\t\tSerial.println(F(\"Pin not supported as PWM fan pin\"));\n#endif  // DEBUG\n\t\t\tbreak;\n\t}\n}\n\nvoid PWMFan::setPower(uint8_t percentage) {\n\tanalogWrite(pwmPin, percentage);\n}\n\nuint8_t PWMFan::calculatePowerFromSpeed(uint16_t rpm) {\n\trpm = constrain(rpm, minRPM, maxRPM);\n\treturn ((float)(rpm - minRPM) / (float)(maxRPM - minRPM)) * 255;\n}\n\nuint16_t PWMFan::calculateSpeedFromPower(uint8_t power) {\n\treturn map(power, 0, 255, minRPM, maxRPM);\n}\n"
  },
  {
    "path": "examples/CommanderPRO/PWMFan.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n\nclass PWMFan {\npublic:\n\t/**\n\t * PWM fan which maps speed to power using linear interpolation. This fan does not read the real RPM values. The\n\t * Arduino timer for the given pin will be set to higher speed.\n\t *\n\t * @param pwmPin the Arduino pwm pin for this fan. Not all PWM pins are supported.\n\t * @param minRPM the speed in RPM at 0% power\n\t * @param maxRPM the speed in RPM at 100% power\n\t */\n\tPWMFan(uint8_t pwmPin, uint16_t minRPM, uint16_t maxRPM);\n\tvirtual void setPower(uint8_t percentage);\n\tvirtual uint8_t calculatePowerFromSpeed(uint16_t rpm);\n\tvirtual uint16_t calculateSpeedFromPower(uint8_t power);\n\nprotected:\n\tconst uint8_t pwmPin;\n\tconst uint16_t minRPM;\n\tconst uint16_t maxRPM;\n};\n"
  },
  {
    "path": "examples/CommanderPRO/SimpleFanController.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"SimpleFanController.h\"\n\n#include <EEPROM.h>\n\nSimpleFanController::SimpleFanController(TemperatureController* temperatureController, uint16_t updateRate,\n\t\t\t\t\t\t\t\t\t\t uint16_t eEPROMAdress)\n\t: temperatureController(temperatureController), updateRate(updateRate), eEPROMAdress(eEPROMAdress) {\n\tload();\n}\n\nvoid SimpleFanController::addFan(uint8_t index, PWMFan* fan) {\n\tif (index >= FAN_NUM) {\n\t\treturn;\n\t}\n\tfans[index] = fan;\n\tswitch (fanData[index].mode) {\n\t\tcase FAN_CONTROL_MODE_FIXED_POWER:\n\t\t\tfanData[index].speed = fan->calculateSpeedFromPower(fanData[index].power);\n\t\t\tbreak;\n\t\tcase FAN_CONTROL_MODE_FIXED_RPM:\n\t\t\tfanData[index].power = fan->calculatePowerFromSpeed(fanData[index].speed);\n\t\t\tbreak;\n\t}\n}\n\nbool SimpleFanController::updateFans() {\n\tunsigned long currentUpdate = millis();\n\tunsigned long lastUpdateNumber = lastUpdate / updateRate;\n\tunsigned long currentUpdateNumber = currentUpdate / updateRate;\n\tlastUpdate = currentUpdate;\n\tif (lastUpdateNumber < currentUpdateNumber) {\n\t\tif (triggerSave) {\n\t\t\ttriggerSave = false;\n\t\t\tsave();\n\t\t}\n\n\t\tfor (uint8_t i = 0; i < FAN_NUM; i++) {\n\t\t\tif (fans[i] == nullptr) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (fanData[i].mode == FAN_CONTROL_MODE_FIXED_RPM || fanData[i].mode == FAN_CONTROL_MODE_FIXED_POWER) {\n\t\t\t\tfans[i]->setPower(fanData[i].power);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tuint16_t temp;\n\t\t\tconst uint8_t& group = fanData[i].tempGroup;\n\t\t\tif (group == FAN_CURVE_TEMP_GROUP_EXTERNAL) {\n\t\t\t\ttemp = externalTemp[i];\n\t\t\t} else if (group < TEMPERATURE_NUM) {\n\t\t\t\ttemp = temperatureController->getTemperature(group);\n\t\t\t}\n\n\t\t\tconst FanCurve& fanCurve = fanData[i].fanCurve;\n\t\t\tuint16_t speed;\n\n\t\t\tif (temp <= fanCurve.temperatures[0]) {\n\t\t\t\tspeed = fanCurve.rpms[0];\n\t\t\t} else if (temp > fanCurve.temperatures[FAN_CURVE_POINTS_NUM - 1]) {\n\t\t\t\tspeed = fanCurve.rpms[FAN_CURVE_POINTS_NUM - 1];\n\t\t\t} else {\n\t\t\t\tfor (uint8_t p = 0; p < FAN_CURVE_POINTS_NUM - 1; p++) {\n\t\t\t\t\tif (temp > fanCurve.temperatures[p + 1]) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tspeed = map(temp, fanCurve.temperatures[p], fanCurve.temperatures[p + 1], fanCurve.rpms[p],\n\t\t\t\t\t\t\t\tfanCurve.rpms[p + 1]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfanData[i].speed = speed;\n\t\t\tfanData[i].power = fans[i]->calculatePowerFromSpeed(speed);\n\t\t\tfans[i]->setPower(fanData[i].power);\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nuint16_t SimpleFanController::getFanSpeed(uint8_t fan) {\n\treturn fanData[fan].speed;\n}\n\nvoid SimpleFanController::setFanSpeed(uint8_t fan, uint16_t speed) {\n\tfanData[fan].speed = speed;\n\tfanData[fan].mode = FAN_CONTROL_MODE_FIXED_RPM;\n\tfanData[fan].power = fans[fan] != nullptr ? fans[fan]->calculatePowerFromSpeed(speed) : 0;\n\ttriggerSave = true;\n}\n\nuint8_t SimpleFanController::getFanPower(uint8_t fan) {\n\treturn fanData[fan].power;\n}\n\nvoid SimpleFanController::setFanPower(uint8_t fan, uint8_t percentage) {\n\tfanData[fan].power = percentage;\n\tfanData[fan].mode = FAN_CONTROL_MODE_FIXED_POWER;\n\tfanData[fan].speed = fans[fan] != nullptr ? fans[fan]->calculateSpeedFromPower(percentage) : 0;\n\ttriggerSave = true;\n}\n\nvoid SimpleFanController::setFanCurve(uint8_t fan, uint8_t group, FanCurve& fanCurve) {\n\tfanData[fan].fanCurve = fanCurve;\n\tfanData[fan].tempGroup = group;\n\tfanData[fan].mode = FAN_CONTROL_MODE_CURVE;\n\ttriggerSave = true;\n}\n\nvoid SimpleFanController::setFanExternalTemperature(uint8_t fan, uint16_t temp) {\n\texternalTemp[fan] = temp;\n}\n\nvoid SimpleFanController::setFanForce3PinMode(bool flag) {\n\tforce3PinMode = flag;\n}\n\nFanDetectionType SimpleFanController::getFanDetectionType(uint8_t fan) {\n\treturn fanData[fan].detectionType;\n}\n\nvoid SimpleFanController::setFanDetectionType(uint8_t fan, FanDetectionType type) {\n\tif (fanData[fan].detectionType != type) {\n\t\tfanData[fan].detectionType = type;\n\t\ttriggerSave = true;\n\t}\n}\n\nbool SimpleFanController::load() {\n\tEEPROM.get(eEPROMAdress, fanData);\n\treturn true;\n}\n\nbool SimpleFanController::save() {\n#ifdef DEBUG\n\tSerial.println(F(\"Save fan data to EEPROM.\"));\n#endif\n\tEEPROM.put(eEPROMAdress, fanData);\n\treturn true;\n}\n"
  },
  {
    "path": "examples/CommanderPRO/SimpleFanController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"FanController.h\"\n#include \"PWMFan.h\"\n#include \"TemperatureController.h\"\n\n#define FAN_CONTROL_MODE_FIXED_POWER 0\n#define FAN_CONTROL_MODE_FIXED_RPM 1\n#define FAN_CONTROL_MODE_CURVE 2\n\nstruct FanData {\n\tuint8_t mode = FAN_CONTROL_MODE_FIXED_POWER;\n\tuint8_t power = 0;\n\tuint16_t speed = 0;\n\tFanDetectionType detectionType = FanDetectionType::Disconnected;\n\tuint8_t tempGroup;\n\tFanCurve fanCurve;\n};\n\n/**\n * This simple Fan Controller implementation does not implement all features of a Fan Controller.\n * It should only demonstrate how to implement your own Fan Controller.\n */\nclass SimpleFanController : public FanController {\npublic:\n\t/**\n\t * Fan Controller must use the EEPROM else on startup the fans can't be controlled\n\t *\n\t * @param temperatureController the TemperatureController used to get the temperature to control the fans\n\t * @param updateRate is the time between fan speed updates in ms\n\t * @param eEPROMAdress the address where the data is stored in EEPROM\n\t */\n\tSimpleFanController(TemperatureController* temperatureController, uint16_t updateRate, uint16_t eEPROMAdress);\n\t/**\n\t * Add a fan to the Controller.\n\t *\n\t * @param index the index of the fan\n\t * @param fan the fan object\n\t */\n\tvoid addFan(uint8_t index, PWMFan* fan);\n\t/**\n\t * Update the fan speeds based on the temperature and commands.\n\t */\n\tvirtual bool updateFans();\n\nprotected:\n\tvirtual uint16_t getFanSpeed(uint8_t fan) override;\n\tvirtual void setFanSpeed(uint8_t fan, uint16_t speed) override;\n\tvirtual uint8_t getFanPower(uint8_t fan) override;\n\tvirtual void setFanPower(uint8_t fan, uint8_t percentage) override;\n\tvirtual void setFanCurve(uint8_t fan, uint8_t group, FanCurve& fanCurve) override;\n\tvirtual void setFanExternalTemperature(uint8_t fan, uint16_t temp) override;\n\tvirtual void setFanForce3PinMode(bool flag) override;\n\tvirtual FanDetectionType getFanDetectionType(uint8_t fan) override;\n\tvirtual void setFanDetectionType(uint8_t fan, FanDetectionType type) override;\n\tbool load();\n\tbool save();\n\n\tTemperatureController* const temperatureController;\n\tPWMFan* fans[FAN_NUM] = {nullptr};\n\tbool force3PinMode = false;\n\tFanData fanData[FAN_NUM];\n\tuint16_t externalTemp[FAN_NUM];\n\tuint16_t updateRate;\n\tuint16_t eEPROMAdress;\n\t/**\n\t * Indicates that the configuration of the fans has been changed and should be saved.\n\t */\n\tbool triggerSave = false;\n\tunsigned long lastUpdate = 0;\n};\n"
  },
  {
    "path": "examples/CommanderPRO/ThermistorTemperatureController.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"ThermistorTemperatureController.h\"\n\n#define B_COEFFICIENT 3950\n#define TEMPERATURE_REFERENCE (273.15 + 25)\n#define RESISTENCE_REFERENCE 10000\n#define RESISTENCE_DIVIDER 10000\n#define MAX_TEMP 150\n\nvoid ThermistorTemperatureController::addSensor(uint8_t index, uint8_t pin) {\n\tif (index < sizeof(sensorPins)) {\n\t\tpinMode(pin, INPUT);\n\t\tsensorPins[index] = pin;\n\t}\n}\n\nuint16_t ThermistorTemperatureController::getTemperatureValue(uint8_t temperatureSensor) {\n\tif (!isTemperatureSensorConnected(temperatureSensor)) {\n\t\treturn 0;\n\t}\n\tint read = analogRead(sensorPins[temperatureSensor]);\n\n\tdouble resistence = (RESISTENCE_DIVIDER * (double)(1023 - read)) / read;\n\n\tdouble temp = resistence / RESISTENCE_REFERENCE;  // (R/Ro)\n\ttemp = log(temp);                                 // ln(R/Ro)\n\ttemp /= B_COEFFICIENT;                            // * (1/B)\n\ttemp += 1.0 / TEMPERATURE_REFERENCE;              // + (1/To)\n\ttemp = 1.0 / temp;                                // invert\n\ttemp -= 273.15;                                   // convert to °C\n\n\treturn constrain(temp, 0, MAX_TEMP) * 100;\n}\n\nbool ThermistorTemperatureController::isTemperatureSensorConnected(uint8_t temperatureSensor) {\n\treturn sensorPins[temperatureSensor] != 0;\n}\n\nuint16_t ThermistorTemperatureController::getVoltageRail12V() {\n\treturn 0;\n}\n\nuint16_t ThermistorTemperatureController::getVoltageRail5V() {\n\treturn 0;\n}\n\nuint16_t ThermistorTemperatureController::getVoltageRail3V3() {\n\treturn 0;\n}\n"
  },
  {
    "path": "examples/CommanderPRO/ThermistorTemperatureController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"TemperatureController.h\"\n/**\n * This TemperatureController uses Thermistors and Resistors to messure the temperature. It does not implement the\n * voltage rail measurements.\n *\n * Thermistor Schematic:\n * <pre>\n *     | ---- [10k - Resistor] ---- | ---- [Thermistor] ---- |\n *     |                            |                        |\n *  [Ground]                    Analog Pin                 [+5v]\n * </pre>\n */\nclass ThermistorTemperatureController : public TemperatureController {\npublic:\n\t/**\n\t * Add a Sensor to the TemperatureController using an Arduino analog pin connected as shown in {@link\n\t * ThermistorTemperatureController}.\n\t *\n\t * @param index the index of the sensorPins\n\t * @param pin the Arduino analog pin\n\t */\n\tvoid addSensor(uint8_t index, uint8_t pin);\n\nprotected:\n\tvirtual uint16_t getTemperatureValue(uint8_t temperatureSensor) override;\n\tvirtual bool isTemperatureSensorConnected(uint8_t temperatureSensor) override;\n\tvirtual uint16_t getVoltageRail12V() override;\n\tvirtual uint16_t getVoltageRail5V() override;\n\tvirtual uint16_t getVoltageRail3V3() override;\n\n\tuint8_t sensorPins[TEMPERATURE_NUM] = {0};\n};\n"
  },
  {
    "path": "examples/DebugSketch/DebugSketch.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define CHANNEL_LED_COUNT 96\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cLPS(&cLP);\n\nCRGB ledsChannel1[CHANNEL_LED_COUNT];\nCRGB ledsChannel2[CHANNEL_LED_COUNT];\n\nbool printLoop = PRINT_LOOP;\nbool printUpdate = PRINT_UPDATE;\n\nvoid setup() {\n\tSerial.begin(115200);\n\tSerial.setTimeout(100);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, CHANNEL_LED_COUNT);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, CHANNEL_LED_COUNT);\n\tledController.addLEDs(0, ledsChannel1, CHANNEL_LED_COUNT);\n\tledController.addLEDs(1, ledsChannel2, CHANNEL_LED_COUNT);\n}\n\nvoid loop() {\n\tif (printLoop) Serial.println(F(\"loop\"));\n\tcLPS.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tif (printUpdate) Serial.println(F(\"updateLEDs\"));\n\t\tFastLED.show();\n\t\tCLP::printFps(5000);\n\t}\n\n\tif (Serial.available()) {\n\t\tstatic String cmd = \"\";\n\t\tcmd = Serial.readStringUntil('\\n');\n\t\tprocessCommand(cmd);\n\t}\n}\n\nvoid processCommand(String& cmd) {\n\tif (cmd == F(\"print DeviceID\")) {\n\t\tDeviceID deviceId;\n\t\tfirmware.getDeviceID(deviceId);\n\t\tCLP::printDeviceID(deviceId);\n\t\tSerial.println();\n\t}\n#ifdef VERBOSE\n\telse if (cmd == F(\"toggle command\")) {\n\t\tprintCommand = !printCommand;\n\t} else if (cmd == F(\"toggle response\")) {\n\t\tprintResponse = !printResponse;\n\t}\n#endif  // VERBOSE\n\telse if (cmd == F(\"toggle loop\")) {\n\t\tprintLoop = !printLoop;\n\t} else if (cmd == F(\"toggle update\")) {\n\t\tprintUpdate = !printUpdate;\n\t} else {\n\t\tSerial.println(F(\"Unknown command\"));\n\t}\n}\n"
  },
  {
    "path": "examples/DebugSketch/board.txt",
    "content": "# CorsairLightingProtocol build property overrides\n\nbuild.vid=0x1b1c\nbuild.pid=0x0c0b\nbuild.usb_product=\"Lighting Node PRO\"\nbuild.usb_manufacturer=\"Corsair\"\n\nbuild.extra_flags={build.usb_flags} -DDEBUG -DVERBOSE -DPRINT_COMMAND=true -DPRINT_RESPONSE=true -DPRINT_LOOP=true -DPRINT_UPDATE=true\n"
  },
  {
    "path": "examples/DeviceIDTool/DeviceIDTool.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n//\n// UPLOAD THIS TO THE ARDUINO AND OPEN SERIAL MONITOR WITH BOUDRATE 115200\n//\n#include <CLPUtils.h>\n#include <CorsairLightingFirmwareStorageEEPROM.h>\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\n\nvoid setup() {\n\tSerial.begin(115200);\n\tSerial.setTimeout(100);\n\tDeviceID deviceID;\n\tfirmwareStorage.loadDeviceID(deviceID);\n\n\twhile (!Serial) {\n\t\t;  // wait for serial port to connect. Needed for native USB\n\t}\n\tSerial.print(F(\"Current DeviceID: \"));\n\tCLP::printDeviceID(deviceID);\n\tSerial.println();\n\tSerial.println(\n\t\tF(\"Set a new DeviceID by typing it in the Serial Monitor. The new DeviceID must be in same format as above. 4 \"\n\t\t  \"Blocks with 2 digits separated by white space.\"));\n\tSerial.println();\n}\n\nvoid loop() {\n\tif (Serial.available()) {\n\t\tString inputString = Serial.readStringUntil('\\n');\n\t\tif (inputString.length() < 11) {\n\t\t\tSerial.println(F(\"Input is too short!\"));\n\t\t\tSerial.println(F(\"Do not forget the leading zeroes!\"));\n\t\t\tSerial.println();\n\t\t} else {\n\t\t\tDeviceID newDeviceID;\n\n\t\t\tnewDeviceID.data[0] = strtol(&inputString[0], nullptr, 16);\n\t\t\tnewDeviceID.data[1] = strtol(&inputString[3], nullptr, 16);\n\t\t\tnewDeviceID.data[2] = strtol(&inputString[6], nullptr, 16);\n\t\t\tnewDeviceID.data[3] = strtol(&inputString[9], nullptr, 16);\n\t\t\tSerial.println(F(\"Set DeviceID to: \"));\n\t\t\tCLP::printDeviceID(newDeviceID);\n\t\t\tSerial.println();\n\t\t\tif (CLP::isNullID(newDeviceID)) {\n\t\t\t\tSerial.println(\n\t\t\t\t\tF(\"This is a special DeviceID, it will generate a new random DeviceID next time iCUE controls the \"\n\t\t\t\t\t  \"device!\"));\n\t\t\t}\n\t\t\tif (CLP::isResetID(newDeviceID)) {\n\t\t\t\tSerial.println(\n\t\t\t\t\tF(\"This is a special DeviceID, it will reset the device and then generate a new DeviceID!\"));\n\t\t\t}\n\t\t\tSerial.println();\n\t\t\tfirmwareStorage.saveDeviceID(newDeviceID);\n\t\t}\n\t}\n}"
  },
  {
    "path": "examples/HoodLoader2CLPBridge/CLPUSBSerialBridge.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n\n#include \"CLPUSBSerialBridge.h\"\n\n#include <CorsairLightingProtocolConstants.h>\n#include <RawHID.h>\n\nvoid resetIOMCU() {\n\tdigitalWrite(RESET_PIN, LOW);\n\tdelay(10);\n\tdigitalWrite(RESET_PIN, HIGH);\n#ifdef DEBUG\n\tSerial.println(F(\"R\"));\n#endif  // DEBUG\n}\n\nCLPUSBSerialBridge::CLPUSBSerialBridge(const char* serialNumber) {\n\tCLP::RawHID.setSerialNumber(serialNumber);\n}\n\nvoid CLPUSBSerialBridge::begin() {\n\tSerial1.begin(SERIAL_BAUD);\n\tCLP::RawHID.begin(rawHIDAndSerialBuffer, sizeof(rawHIDAndSerialBuffer));\n}\n\nbool waitForSynchronization() {\n\twhile (Serial1.available()) {\n\t\tSerial1.read();\n\t}\n\tSerial1.setTimeout(SERIAL_SYNCHRONIZATION_TIMEOUT);\n\tbyte value;\n\tsize_t read = Serial1.readBytes(&value, 1);\n\treturn read == 1 && value == 42;\n}\n\nvoid CLPUSBSerialBridge::sendError() {\n\tmemset(rawHIDAndSerialBuffer, 0, RESPONSE_SIZE_16U2);\n\trawHIDAndSerialBuffer[0] = PROTOCOL_RESPONSE_ERROR;\n\tsendResponse();\n}\n\nvoid CLPUSBSerialBridge::sendResponse() {\n#ifdef DEBUG\n\tSerial.print(F(\"R\"));\n\tSerial.println(rawHIDAndSerialBuffer[0], HEX);\n#endif  // DEBUG\n\tCLP::RawHID.write(rawHIDAndSerialBuffer, RESPONSE_SIZE_16U2);\n\t// free the shared buffer to receive new data\n\tCLP::RawHID.enable();\n}\n\nvoid CLPUSBSerialBridge::handleHID() {\n\tif (CLP::RawHID.available()) {\n#ifdef DEBUG\n\t\tSerial.print(F(\"C\"));\n\t\tSerial.println(rawHIDAndSerialBuffer[0], HEX);\n\t\tunsigned long time = micros();\n#endif  // DEBUG\n\t\tif (!waitForSynchronization()) {\n#ifdef DEBUG\n\t\t\tSerial.println(F(\"S\"));\n#endif  // DEBUG\n\t\t\tsendError();\n\t\t\treturn;\n\t\t}\n\n\t\tSerial1.write(rawHIDAndSerialBuffer, COMMAND_SIZE);\n\t\tSerial1.setTimeout(SERIAL_RESPONSE_TIMEOUT);\n\t\tsize_t read = Serial1.readBytes(rawHIDAndSerialBuffer, RESPONSE_SIZE);\n\t\tif (read != RESPONSE_SIZE) {\n#ifdef DEBUG\n\t\t\tSerial.print(F(\"T\"));\n\t\t\tSerial.println(read);\n\t\t\tSerial.println(rawHIDAndSerialBuffer[0], HEX);\n#endif  // DEBUG\n\t\t\tsendError();\n\t\t\treturn;\n\t\t}\n\t\tsendResponse();\n\n#ifdef DEBUG\n\t\tunsigned long duration = micros() - time;\n\t\tSerial.print(F(\"D\"));\n\t\tSerial.println(duration);\n#endif  // DEBUG\n\t}\n}\n"
  },
  {
    "path": "examples/HoodLoader2CLPBridge/CLPUSBSerialBridge.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include <CorsairLightingProtocolConstants.h>\n\n#include \"Arduino.h\"\n\n#if (COMMAND_SIZE >= RESPONSE_SIZE)\n#define RAWHID_AND_SERIAL_BUFFER_SIZE COMMAND_SIZE\n#endif\n\n// Workaround for 16 byte responses don't work on 16U2 see https://github.com/Legion2/CorsairLightingProtocol/pull/152\n#define RESPONSE_SIZE_16U2 64\n\n#define SERIAL_SYNCHRONIZATION_TIMEOUT 20\n#define SERIAL_RESPONSE_TIMEOUT 10\n#define SERIAL_BAUD 1000000\n\n#define RESET_PIN IO_MCU_RESET_PIN\n\nclass CLPUSBSerialBridge {\npublic:\n\t/**\n\t * Create a new CLPUSBSerialBridge with the default Serial Number.\n\t */\n\tCLPUSBSerialBridge(){};\n\t/**\n\t * Create a new CLPUSBSerialBridge and set a Serial Number.\n\t *\n\t * @param serialNumber the Serial Number of the USB device\n\t */\n\tCLPUSBSerialBridge(const char* serialNumber);\n\t/**\n\t * Setup the bridge connections. Must be called in the Arduino setup function.\n\t */\n\tvirtual void begin();\n\t/**\n\t * Reads data from USB and sents it via Serial to the main MCU. Wait for the response and set it back to the USB\n\t * host. MUST be called in the Arduino loop function.\n\t */\n\tvirtual void handleHID();\n\nprivate:\n\tbyte rawHIDAndSerialBuffer[RAWHID_AND_SERIAL_BUFFER_SIZE];\n\n\tvoid sendError();\n\tvoid sendResponse();\n};\n"
  },
  {
    "path": "examples/HoodLoader2CLPBridge/HoodLoader2CLPBridge.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CLPUSBSerialBridge.h\"\n\nCLPUSBSerialBridge usbToSerialBridge;\n\nvoid setup() {\n#ifdef DEBUG\n\tSerial.begin(1000000);\n#endif  // DEBUG\n\tusbToSerialBridge.begin();\n}\n\nvoid loop() {\n\tusbToSerialBridge.handleHID();\n}\n"
  },
  {
    "path": "examples/HoodLoader2UnoMegaController/HoodLoader2UnoMegaController.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n// Hint: The Arduino Uno does not have as much memory as the Arduino Mega, it may be that problems occur when a higher\n// value is set here.\n#define CHANNEL_LED_COUNT 60\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolSerial cLPS(&cLP);\n\nCRGB ledsChannel1[CHANNEL_LED_COUNT];\nCRGB ledsChannel2[CHANNEL_LED_COUNT];\n\nvoid setup() {\n\t/*\n\tYOU MUST NOT USE Serial!\n\tSerial is used by CorsairLightingProtocolSerial!\n\t*/\n\tcLPS.setup();\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, CHANNEL_LED_COUNT);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, CHANNEL_LED_COUNT);\n\tledController.addLEDs(0, ledsChannel1, CHANNEL_LED_COUNT);\n\tledController.addLEDs(1, ledsChannel2, CHANNEL_LED_COUNT);\n}\n\nvoid loop() {\n\tcLPS.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/LS100/LS100.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n// Hint: The channels of the LS100 are swapped in iCUE, so the first channel in iCUE is here channel 2\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\n#define BUTTON_PIN 4\n\n// Hint: The ATmega32U4 does not have enough memory for 135 leds on both channels\nCRGB ledsChannel1[135];\nCRGB ledsChannel2[54];\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_SMART_LIGHTING_CONTROLLER, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 135);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 54);\n\tledController.addLEDs(0, ledsChannel1, 135);\n\tledController.addLEDs(1, ledsChannel2, 54);\n\tpinMode(BUTTON_PIN, INPUT_PULLUP);\n}\n\nvoid loop() {\n\tstatic bool lightingEnabled = true;\n\tcHID.update();\n\n\tif (buttonClicked()) {\n\t\tlightingEnabled = !lightingEnabled;\n\t\tfill_solid(ledsChannel1, 135, CRGB::Black);\n\t\tfill_solid(ledsChannel2, 54, CRGB::Black);\n\t\tFastLED.show();\n\t}\n\n\tif (lightingEnabled && ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n\n/**\n * Handle button of the LS100. The button is optional.\n *\n * @return true if the button was pressed and then released.\n */\nbool buttonClicked() {\n\tstatic bool previousState = 1;\n\tbool state = digitalRead(BUTTON_PIN);\n\tif (previousState == 0 && state == 1) {\n\t\tpreviousState = state;\n\t\treturn true;\n\t}\n\tpreviousState = state;\n\treturn false;\n}\n"
  },
  {
    "path": "examples/LT100/LT100.ino",
    "content": "/*\n   Copyright 2020 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define DATA_PIN_CHANNEL_1 2\n\nCRGB ledsChannel1[108];\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_SMART_LIGHTING_TOWERS, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 108);\n\tledController.addLEDs(0, ledsChannel1, 108);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/LightingNodeCORE/LightingNodeCORE.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define DATA_PIN_CHANNEL_1 2\n\nCRGB ledsChannel1[204];\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_CORE, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 204);\n\tledController.addLEDs(0, ledsChannel1, 204);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/LightingNodePRO/LightingNodePRO.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\nCRGB ledsChannel1[96];\nCRGB ledsChannel2[96];\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 96);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 96);\n\tledController.addLEDs(0, ledsChannel1, 96);\n\tledController.addLEDs(1, ledsChannel2, 96);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/MultipleFans/MultipleFans.ino",
    "content": "/*\n   Copyright 2020 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define NUMBER_OF_LEDS_PER_FAN 8\n\n#define DATA_PIN_FAN_1 2\n#define DATA_PIN_FAN_2 3\n#define DATA_PIN_FAN_3 4\n#define DATA_PIN_FAN_4 5\n#define DATA_PIN_FAN_5 6\n#define DATA_PIN_FAN_6 7\n#define DATA_PIN_CHANNEL_2 8\n\nCRGB ledsChannel1[96];\nCRGB ledsChannel2[96];\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\t// 6 fans on channel 1\n\t//                          FAN_PIN           CRGB array            offset             number of leds per fan\n\tFastLED.addLeds<WS2812B, DATA_PIN_FAN_1, GRB>(ledsChannel1, NUMBER_OF_LEDS_PER_FAN * 0, NUMBER_OF_LEDS_PER_FAN);\n\tFastLED.addLeds<WS2812B, DATA_PIN_FAN_2, GRB>(ledsChannel1, NUMBER_OF_LEDS_PER_FAN * 1, NUMBER_OF_LEDS_PER_FAN);\n\tFastLED.addLeds<WS2812B, DATA_PIN_FAN_3, GRB>(ledsChannel1, NUMBER_OF_LEDS_PER_FAN * 2, NUMBER_OF_LEDS_PER_FAN);\n\tFastLED.addLeds<WS2812B, DATA_PIN_FAN_4, GRB>(ledsChannel1, NUMBER_OF_LEDS_PER_FAN * 3, NUMBER_OF_LEDS_PER_FAN);\n\tFastLED.addLeds<WS2812B, DATA_PIN_FAN_5, GRB>(ledsChannel1, NUMBER_OF_LEDS_PER_FAN * 4, NUMBER_OF_LEDS_PER_FAN);\n\tFastLED.addLeds<WS2812B, DATA_PIN_FAN_6, GRB>(ledsChannel1, NUMBER_OF_LEDS_PER_FAN * 5, NUMBER_OF_LEDS_PER_FAN);\n\n\t// normal strip on channel 2\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 96);\n\tledController.addLEDs(0, ledsChannel1, 96);\n\tledController.addLEDs(1, ledsChannel2, 96);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/NoEEPROM/NoEEPROM.ino",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\nCRGB ledsChannel1[96];\nCRGB ledsChannel2[96];\n\nDeviceID deviceID = {0x9A, 0xDA, 0xA7, 0x8E};\nCorsairLightingFirmwareStorageStatic firmwareStorage(deviceID);\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDController ledController(nullptr);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 96);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 96);\n\tledController.addLEDs(0, ledsChannel1, 96);\n\tledController.addLEDs(1, ledsChannel2, 96);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/NonAddressable/NonAddressable.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n// The Arduino pin where the physical LEDs are connected.\n// Must be PWM pins\n#define RED_PIN 3\n#define GREEN_PIN 5\n#define BLUE_PIN 6\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nCRGB ledsChannel1[10];\n\nvoid setup() {\n\tpinMode(RED_PIN, OUTPUT);\n\tpinMode(GREEN_PIN, OUTPUT);\n\tpinMode(BLUE_PIN, OUTPUT);\n\tledController.addLEDs(0, ledsChannel1, 10);\n\tledController.onUpdateHook(0, []() {\n\t\t// use color of first LED of the first channel\n\t\tset4PinLEDs(ledsChannel1[0]);\n\t});\n}\n\nvoid loop() {\n\tcHID.update();\n\tledController.updateLEDs();\n}\n\nvoid set4PinLEDs(const CRGB& color) {\n\tanalogWrite(RED_PIN, color.r);\n\tanalogWrite(GREEN_PIN, color.g);\n\tanalogWrite(BLUE_PIN, color.b);\n}\n"
  },
  {
    "path": "examples/RepeatAndScale/RepeatAndScale.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\nCRGB ledsChannel1[100];\nCRGB ledsChannel2[144];\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 100);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 144);\n\tledController.addLEDs(0, ledsChannel1, 50);\n\tledController.addLEDs(1, ledsChannel2, 60);\n\tledController.onUpdateHook(0, []() {\n\t\tCLP::repeat(&ledController, 0, 2);\n\t});\n\tledController.onUpdateHook(1, []() {\n\t\tCLP::scale(&ledController, 1, 144);\n\t});\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/SingleStripLightingNodePRO/SingleStripLightingNodePRO.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n// The number of LEDs per channel.\n#define CHANNEL_LED_COUNT 50\n\n// Total count of LEDs on all channels, the value is calculated based on the LEDs per channel.\n#define NUM_LEDS (CHANNEL_LED_COUNT * 2)\n\n// The Arduino pin where the physical LEDs are connected.\n// You can use two pins, one for each channel.\n// In this example we use only one pin where both channel are connected in series.\n#define DATA_PIN 2\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\n// This array conatins all RGB values for the LEDs of the both channels.\nCRGB leds[NUM_LEDS];\n\nvoid setup() {\n#ifdef DEBUG\n\tSerial.begin(115200);\n#endif\n\tCLP::disableBuildInLEDs();\n\tFastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);\n\tledController.addLEDs(0, leds, CHANNEL_LED_COUNT);\n\tledController.addLEDs(1, &(leds[CHANNEL_LED_COUNT]), CHANNEL_LED_COUNT);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/TinyUSB/TinyUSB.ino",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\nCRGB ledsChannel1[96];\nCRGB ledsChannel2[96];\n\n// Most ARM devices do not contain an EEPROM; we will use static storage for the Device ID\nDeviceID deviceID = {0x9A, 0xDA, 0xA7, 0x8E};\nCorsairLightingFirmwareStorageStatic firmwareStorage(deviceID);\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDController ledController(nullptr);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolTinyUSBHID cHID(&cLP);\n\nvoid setup() {\n\tcHID.setup();\n\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 96);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 96);\n\tledController.addLEDs(0, ledsChannel1, 96);\n\tledController.addLEDs(1, ledsChannel2, 96);\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/TransformLLFansFormatToStrip/TransformLLFansFormatToStrip.ino",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include <CorsairLightingProtocol.h>\n#include <FastLED.h>\n\n#define DATA_PIN_CHANNEL_1 2\n#define DATA_PIN_CHANNEL_2 3\n\nCRGB ledsChannel1[96];\nCRGB ledsChannel2[60];\n\nCorsairLightingFirmwareStorageEEPROM firmwareStorage;\nCorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);\nFastLEDControllerStorageEEPROM storage;\nFastLEDController ledController(&storage);\nCorsairLightingProtocolController cLP(&ledController, &firmware);\nCorsairLightingProtocolHID cHID(&cLP);\n\nvoid setup() {\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 96);\n\tFastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 60);\n\tledController.addLEDs(0, ledsChannel1, 96);\n\tledController.addLEDs(1, ledsChannel2, 60);\n\tledController.onUpdateHook(0, []() {\n\t\tCLP::transformLLFanToStrip(&ledController, 0);\n\t});\n}\n\nvoid loop() {\n\tcHID.update();\n\n\tif (ledController.updateLEDs()) {\n\t\tFastLED.show();\n\t}\n}\n"
  },
  {
    "path": "examples/UnitTests/UnitTests.ino",
    "content": "/*\n   Copyright 2020 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#line 17 \"UnitTests.ino\"\n\n#include <AUnit.h>\n\n#include \"FastLEDControllerUtils.h\"\n\nusing namespace aunit;\n\nclass FastLEDControllerTest : public TestOnce {\nprotected:\n\tvoid assertCRGB(const CRGB& actual, const CRGB& expected) {\n\t\tassertEqual(actual.r, expected.r);\n\t\tassertEqual(actual.g, expected.g);\n\t\tassertEqual(actual.b, expected.b);\n\t}\n\tvoid assertCRGBArray(const CRGB* const leds, int from, int to, const CRGB& expected) {\n\t\tfor (int i = from; i <= to; i++) {\n\t\t\tassertCRGB(leds[i], expected);\n\t\t}\n\t}\n};\n\ntest(getLEDs) {\n\tCRGB leds[10];\n\tFastLEDController ledController(nullptr);\n\tledController.addLEDs(0, leds, 10);\n\tassertEqual(ledController.getLEDs(0), leds);\n\tassertEqual(ledController.getLEDs(1), nullptr);\n}\n\ntestF(FastLEDControllerTest, simpleScaleUp) {\n\tCRGB leds[20];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 20, CRGB::Black);\n\tledController.addLEDs(0, leds, 10);\n\n\tfill_solid(leds, 10, CRGB::White);\n\tCLP::scale(&ledController, 0, 20);\n\n\tassertCRGBArray(leds, 0, 19, CRGB::White);\n}\n\ntestF(FastLEDControllerTest, simpleScaleDown) {\n\tCRGB leds[20];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 20, CRGB::Black);\n\tledController.addLEDs(0, leds, 20);\n\n\tfill_solid(leds, 10, CRGB::White);\n\tCLP::scale(&ledController, 0, 10);\n\n\tassertCRGBArray(leds, 0, 4, CRGB::White);\n\tassertCRGBArray(leds, 5, 9, CRGB::Black);\n}\n\ntestF(FastLEDControllerTest, simpleScaleDownBoundaries) {\n\tCRGB leds[20];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 20, CRGB::Black);\n\tledController.addLEDs(0, leds, 20);\n\n\tleds[0] = CRGB::White;\n\tleds[19] = CRGB::Red;\n\tCLP::scale(&ledController, 0, 5);\n\n\tassertCRGBArray(leds, 0, 0, CRGB::White);\n\tassertCRGBArray(leds, 1, 3, CRGB::Black);\n\tassertCRGBArray(leds, 4, 4, CRGB::Red);\n}\n\ntestF(FastLEDControllerTest, simpleScaleIdentity) {\n\tCRGB leds[20];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 20, CRGB::Black);\n\tledController.addLEDs(0, leds, 10);\n\n\tfill_solid(leds, 10, CRGB::White);\n\tCLP::scale(&ledController, 0, 10);\n\n\tassertCRGBArray(leds, 0, 9, CRGB::White);\n\tassertCRGBArray(leds, 10, 19, CRGB::Black);\n}\n\ntestF(FastLEDControllerTest, scaleLongStrip) {\n\tCRGB leds[41];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 41, CRGB::Black);\n\tledController.addLEDs(0, leds, 27);\n\n\tfill_solid(leds, 27, CRGB::White);\n\tCLP::scale(&ledController, 0, 41);\n\n\tassertCRGBArray(leds, 0, 40, CRGB::White);\n}\n\ntestF(FastLEDControllerTest, LT100) {\n\tCRGB leds[30];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 30, CRGB::Black);\n\tledController.addLEDs(0, leds, 30);\n\n\tleds[0] = CRGB::White;\n\tfill_solid(leds + 1, 26, CRGB::Blue);\n\tCLP::SegmentScaling segments[2] = {{1, 4}, {26, 26}};\n\tCLP::scaleSegments(&ledController, 0, segments, 2);\n\n\tassertCRGBArray(leds, 0, 3, CRGB::White);\n\tassertCRGBArray(leds, 4, 29, CRGB::Blue);\n}\n\ntestF(FastLEDControllerTest, singleSegmentScaleUp) {\n\tCRGB leds[20];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 20, CRGB::Black);\n\tledController.addLEDs(0, leds, 10);\n\n\tfill_solid(leds, 10, CRGB::White);\n\tCLP::SegmentScaling segments[] = {{10, 20}};\n\tCLP::scaleSegments(&ledController, 0, segments, 1);\n\n\tassertCRGBArray(leds, 0, 19, CRGB::White);\n}\n\ntestF(FastLEDControllerTest, multiScaleUp) {\n\tCRGB leds[30];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 30, CRGB::Black);\n\tledController.addLEDs(0, leds, 10);\n\n\tfill_solid(leds + 5, 5, CRGB::White);\n\tCLP::SegmentScaling segments[] = {{5, 10}, {5, 20}};\n\tCLP::scaleSegments(&ledController, 0, segments, 2);\n\n\tassertCRGBArray(leds, 0, 9, CRGB::Black);\n\tassertCRGBArray(leds, 10, 29, CRGB::White);\n}\n\ntestF(FastLEDControllerTest, multiScaleDown) {\n\tCRGB leds[30];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 30, CRGB::Black);\n\tledController.addLEDs(0, leds, 30);\n\n\tfill_solid(leds + 10, 20, CRGB::White);\n\tCLP::SegmentScaling segments[] = {{10, 5}, {20, 5}};\n\tCLP::scaleSegments(&ledController, 0, segments, 2);\n\n\tassertCRGBArray(leds, 0, 4, CRGB::Black);\n\tassertCRGBArray(leds, 5, 9, CRGB::White);\n}\n\ntestF(FastLEDControllerTest, singleSegmentScaleDown) {\n\tCRGB leds[20];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 20, CRGB::Black);\n\tledController.addLEDs(0, leds, 20);\n\n\tfill_solid(leds, 10, CRGB::White);\n\tCLP::SegmentScaling segments[] = {{20, 10}};\n\tCLP::scaleSegments(&ledController, 0, segments, 1);\n\n\tassertCRGBArray(leds, 0, 4, CRGB::White);\n\tassertCRGBArray(leds, 5, 9, CRGB::Black);\n}\n\ntestF(FastLEDControllerTest, SegmentScaleOverlap) {\n\tCRGB leds[15];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 15, CRGB::Black);\n\tledController.addLEDs(0, leds, 15);\n\n\tfill_solid(leds, 5, CRGB::White);\n\tCLP::SegmentScaling segments[] = {{5, 10}, {10, 5}};\n\tCLP::scaleSegments(&ledController, 0, segments, 2);\n\n\tassertCRGBArray(leds, 0, 9, CRGB::White);\n\tassertCRGBArray(leds, 10, 14, CRGB::Black);\n}\n\ntestF(FastLEDControllerTest, SegmentScaleOverlapInverted) {\n\tCRGB leds[15];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 15, CRGB::Black);\n\tledController.addLEDs(0, leds, 15);\n\n\tfill_solid(leds, 10, CRGB::White);\n\tCLP::SegmentScaling segments[] = {{10, 5}, {5, 10}};\n\tCLP::scaleSegments(&ledController, 0, segments, 2);\n\n\tassertCRGBArray(leds, 0, 4, CRGB::White);\n\tassertCRGBArray(leds, 5, 14, CRGB::Black);\n}\n\ntestF(FastLEDControllerTest, SegmentScaleMix) {\n\tCRGB leds[30];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 30, CRGB::Black);\n\tledController.addLEDs(0, leds, 30);\n\n\tfill_solid(leds, 5, CRGB::White);\n\tfill_solid(leds + 5, 20, CRGB::Red);\n\tfill_solid(leds + 25, 5, CRGB::Blue);\n\tCLP::SegmentScaling segments[] = {{5, 10}, {20, 5}, {5, 10}};\n\tCLP::scaleSegments(&ledController, 0, segments, 3);\n\n\tassertCRGBArray(leds, 0, 9, CRGB::White);\n\tassertCRGBArray(leds, 10, 14, CRGB::Red);\n\tassertCRGBArray(leds, 15, 24, CRGB::Blue);\n}\n\ntestF(FastLEDControllerTest, SegmentScaleMixInverted) {\n\tCRGB leds[30];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 30, CRGB::Black);\n\tledController.addLEDs(0, leds, 25);\n\n\tfill_solid(leds, 10, CRGB::White);\n\tfill_solid(leds + 10, 5, CRGB::Red);\n\tfill_solid(leds + 15, 10, CRGB::Blue);\n\tCLP::SegmentScaling segments[] = {{10, 5}, {5, 20}, {10, 5}};\n\tCLP::scaleSegments(&ledController, 0, segments, 3);\n\n\tassertCRGBArray(leds, 0, 4, CRGB::White);\n\tassertCRGBArray(leds, 5, 24, CRGB::Red);\n\tassertCRGBArray(leds, 25, 29, CRGB::Blue);\n}\n\ntestF(FastLEDControllerTest, SegmentScaleMonitor) {\n\tCRGB leds[130];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 130, CRGB::Black);\n\tledController.addLEDs(0, leds, 84);\n\n\tfill_solid(leds, 15, CRGB::White);\n\tfill_solid(leds + 15, 27, CRGB::Red);\n\tfill_solid(leds + 42, 15, CRGB::Blue);\n\tfill_solid(leds + 57, 27, CRGB::Green);\n\tCLP::SegmentScaling segments[] = {{15, 24}, {27, 41}, {15, 24}, {27, 41}};\n\tCLP::scaleSegments(&ledController, 0, segments, 4);\n\n\tassertCRGBArray(leds, 0, 23, CRGB::White);\n\tassertCRGBArray(leds, 24, 64, CRGB::Red);\n\tassertCRGBArray(leds, 65, 88, CRGB::Blue);\n\tassertCRGBArray(leds, 89, 129, CRGB::Green);\n}\n\ntestF(FastLEDControllerTest, SegmentScaleLongStrip) {\n\tCRGB leds[41];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 41, CRGB::Black);\n\tledController.addLEDs(0, leds, 27);\n\n\tfill_solid(leds, 27, CRGB::White);\n\tCLP::SegmentScaling segments[] = {{27, 41}};\n\tCLP::scaleSegments(&ledController, 0, segments, 1);\n\n\tassertCRGBArray(leds, 0, 40, CRGB::White);\n}\n\nvoid setup() {\n\tdelay(1000);\n\tSerial.begin(115200);\n\twhile (!Serial)\n\t\t;\n}\n\nvoid loop() {\n\tTestRunner::run();\n}\n"
  },
  {
    "path": "examples/UnitTests2/UnitTests2.ino",
    "content": "/*\n   Copyright 2020 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#line 17 \"UnitTests2.ino\"\n\n#include <AUnit.h>\n\n#include \"FastLEDController.h\"\n#include \"FastLEDControllerUtils.h\"\n\nusing namespace aunit;\n\nclass FastLEDControllerTest : public TestOnce {\nprotected:\n\tvoid assertCRGB(const CRGB& actual, const CRGB& expected) {\n\t\tassertEqual(actual.r, expected.r);\n\t\tassertEqual(actual.g, expected.g);\n\t\tassertEqual(actual.b, expected.b);\n\t}\n\tvoid assertCRGBArray(const CRGB* const leds, int from, int to, const CRGB& expected) {\n\t\tfor (int i = from; i <= to; i++) {\n\t\t\tassertCRGB(leds[i], expected);\n\t\t}\n\t}\n};\n\nclass TestFastLEDController : public FastLEDController {\npublic:\n\tTestFastLEDController() : FastLEDController(nullptr) {\n\t}\n\n\tvoid setLastUpdate(unsigned long time) {\n\t\tlastUpdate = time;\n\t}\n\n\tvoid setCurrentUpdate(unsigned long time) {\n\t\tcurrentUpdate = time;\n\t}\n\n\tusing FastLEDController::animation_step;\n\tusing FastLEDController::animation_step_count;\n};\n\ntest(getLEDs) {\n\tCRGB leds[10];\n\tFastLEDController ledController(nullptr);\n\tledController.addLEDs(0, leds, 10);\n\tassertEqual(ledController.getLEDs(0), leds);\n\tassertEqual(ledController.getLEDs(1), nullptr);\n}\n\ntestF(FastLEDControllerTest, simpleScaleUp) {\n\tCRGB leds[20];\n\tFastLEDController ledController(nullptr);\n\tfill_solid(leds, 20, CRGB::Black);\n\tledController.addLEDs(0, leds, 20);\n\n\tfill_solid(leds, 10, CRGB::White);\n\tCLP::reverse(&ledController, 0);\n\n\tassertCRGBArray(leds, 0, 9, CRGB::Black);\n\tassertCRGBArray(leds, 10, 19, CRGB::White);\n}\n\ntest(animation_step) {\n\tTestFastLEDController ledController;\n\tledController.setLastUpdate(155);\n\tledController.setCurrentUpdate(165);\n\tassertEqual(ledController.animation_step(5, 100), 0);\n\tassertEqual(ledController.animation_step(10, 100), 50);\n\tassertEqual(ledController.animation_step(20, 100), 25);\n\tassertEqual(ledController.animation_step(40, 100), 12);\n\tassertEqual(ledController.animation_step(5000, 100), 3);\n}\n\ntest(animation_step_long) {\n\tTestFastLEDController ledController;\n\tledController.setLastUpdate(3000000000);\n\tledController.setCurrentUpdate(300000005);\n\tassertEqual(ledController.animation_step(5, 100), 0);\n\tassertEqual(ledController.animation_step(10, 100), 50);\n\tassertEqual(ledController.animation_step(20, 100), 25);\n\tassertEqual(ledController.animation_step(40, 100), 12);\n\tassertEqual(ledController.animation_step(5000, 100), 0);\n}\n\ntest(animation_step_count) {\n\tTestFastLEDController ledController;\n\tledController.setLastUpdate(155);\n\tledController.setCurrentUpdate(165);\n\tassertEqual(ledController.animation_step_count(5, 100), 200);\n\tassertEqual(ledController.animation_step_count(10, 100), 100);\n\tassertEqual(ledController.animation_step_count(20, 100), 50);\n\tassertEqual(ledController.animation_step_count(40, 100), 25);\n\tassertEqual(ledController.animation_step_count(5000, 100), 0);\n}\n\ntest(animation_step_count_offset) {\n\tTestFastLEDController ledController;\n\tledController.setLastUpdate(195);\n\tledController.setCurrentUpdate(205);\n\tassertEqual(ledController.animation_step_count(10000, 100), 1);\n}\n\ntest(animation_step_count_long) {\n\tTestFastLEDController ledController;\n\tledController.setLastUpdate(3000000000);\n\tledController.setCurrentUpdate(3000000010);\n\tassertEqual(ledController.animation_step_count(5, 100), 200);\n\tassertEqual(ledController.animation_step_count(10, 100), 100);\n\tassertEqual(ledController.animation_step_count(20, 100), 50);\n\tassertEqual(ledController.animation_step_count(40, 100), 25);\n\tassertEqual(ledController.animation_step_count(5000, 100), 0);\n}\n\nvoid setup() {\n\tdelay(1000);\n\tSerial.begin(115200);\n\twhile (!Serial)\n\t\t;\n}\n\nvoid loop() {\n\tTestRunner::run();\n}\n"
  },
  {
    "path": "extra/doxygen.conf",
    "content": "# Doxyfile 1.8.13\n\n# This file describes the settings to be used by the documentation system\n# doxygen (www.doxygen.org) for a project.\n#\n# All text after a double hash (##) is considered a comment and is placed in\n# front of the TAG it is preceding.\n#\n# All text after a single hash (#) is considered a comment and will be ignored.\n# The format is:\n# TAG = value [value, ...]\n# For lists, items can also be appended using:\n# TAG += value [value, ...]\n# Values that contain spaces should be placed between quotes (\\\" \\\").\n\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\n\n# This tag specifies the encoding used for all characters in the config file\n# that follow. The default is UTF-8 which is also the encoding used for all text\n# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv\n# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv\n# for the list of possible encodings.\n# The default value is: UTF-8.\n\nDOXYFILE_ENCODING      = UTF-8\n\n# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by\n# double-quotes, unless you are using Doxywizard) that should identify the\n# project for which the documentation is generated. This name is used in the\n# title of most generated pages and in a few other places.\n# The default value is: My Project.\n\nPROJECT_NAME           = \"Corsair Lighting Protocol\"\n\n# The PROJECT_NUMBER tag can be used to enter a project or revision number. This\n# could be handy for archiving the generated documentation or if some version\n# control system is used.\n\nPROJECT_NUMBER         = 0.15.0\n\n# Using the PROJECT_BRIEF tag one can provide an optional one line description\n# for a project that appears at the top of each page and should give viewer a\n# quick idea about the purpose of the project. Keep the description short.\n\nPROJECT_BRIEF          = \"Control LEDs connected to an Arduino with iCUE\"\n\n# With the PROJECT_LOGO tag one can specify a logo or an icon that is included\n# in the documentation. The maximum height of the logo should not exceed 55\n# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy\n# the logo to the output directory.\n\nPROJECT_LOGO           =\n\n# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path\n# into which the generated documentation will be written. If a relative path is\n# entered, it will be relative to the location where doxygen was started. If\n# left blank the current directory will be used.\n\nOUTPUT_DIRECTORY       = doxygen\n\n# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-\n# directories (in 2 levels) under the output directory of each output format and\n# will distribute the generated files over these directories. Enabling this\n# option can be useful when feeding doxygen a huge amount of source files, where\n# putting all generated files in the same directory would otherwise causes\n# performance problems for the file system.\n# The default value is: NO.\n\nCREATE_SUBDIRS         = NO\n\n# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII\n# characters to appear in the names of generated files. If set to NO, non-ASCII\n# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode\n# U+3044.\n# The default value is: NO.\n\nALLOW_UNICODE_NAMES    = NO\n\n# The OUTPUT_LANGUAGE tag is used to specify the language in which all\n# documentation generated by doxygen is written. Doxygen will use this\n# information to generate all constant output in the proper language.\n# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,\n# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),\n# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,\n# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),\n# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,\n# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,\n# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,\n# Ukrainian and Vietnamese.\n# The default value is: English.\n\nOUTPUT_LANGUAGE        = English\n\n# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member\n# descriptions after the members that are listed in the file and class\n# documentation (similar to Javadoc). Set to NO to disable this.\n# The default value is: YES.\n\nBRIEF_MEMBER_DESC      = YES\n\n# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief\n# description of a member or function before the detailed description\n#\n# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the\n# brief descriptions will be completely suppressed.\n# The default value is: YES.\n\nREPEAT_BRIEF           = YES\n\n# This tag implements a quasi-intelligent brief description abbreviator that is\n# used to form the text in various listings. Each string in this list, if found\n# as the leading text of the brief description, will be stripped from the text\n# and the result, after processing the whole list, is used as the annotated\n# text. Otherwise, the brief description is used as-is. If left blank, the\n# following values are used ($name is automatically replaced with the name of\n# the entity):The $name class, The $name widget, The $name file, is, provides,\n# specifies, contains, represents, a, an and the.\n\nABBREVIATE_BRIEF       = \"The $name class\" \\\n                         \"The $name widget\" \\\n                         \"The $name file\" \\\n                         is \\\n                         provides \\\n                         specifies \\\n                         contains \\\n                         represents \\\n                         a \\\n                         an \\\n                         the\n\n# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then\n# doxygen will generate a detailed section even if there is only a brief\n# description.\n# The default value is: NO.\n\nALWAYS_DETAILED_SEC    = NO\n\n# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all\n# inherited members of a class in the documentation of that class as if those\n# members were ordinary class members. Constructors, destructors and assignment\n# operators of the base classes will not be shown.\n# The default value is: NO.\n\nINLINE_INHERITED_MEMB  = NO\n\n# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path\n# before files name in the file list and in the header files. If set to NO the\n# shortest path that makes the file name unique will be used\n# The default value is: YES.\n\nFULL_PATH_NAMES        = YES\n\n# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.\n# Stripping is only done if one of the specified strings matches the left-hand\n# part of the path. The tag can be used to show relative paths in the file list.\n# If left blank the directory from which doxygen is run is used as the path to\n# strip.\n#\n# Note that you can specify absolute paths here, but also relative paths, which\n# will be relative from the directory where doxygen is started.\n# This tag requires that the tag FULL_PATH_NAMES is set to YES.\n\nSTRIP_FROM_PATH        =\n\n# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the\n# path mentioned in the documentation of a class, which tells the reader which\n# header file to include in order to use a class. If left blank only the name of\n# the header file containing the class definition is used. Otherwise one should\n# specify the list of include paths that are normally passed to the compiler\n# using the -I flag.\n\nSTRIP_FROM_INC_PATH    =\n\n# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but\n# less readable) file names. This can be useful is your file systems doesn't\n# support long names like on DOS, Mac, or CD-ROM.\n# The default value is: NO.\n\nSHORT_NAMES            = NO\n\n# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the\n# first line (until the first dot) of a Javadoc-style comment as the brief\n# description. If set to NO, the Javadoc-style will behave just like regular Qt-\n# style comments (thus requiring an explicit @brief command for a brief\n# description.)\n# The default value is: NO.\n\nJAVADOC_AUTOBRIEF      = NO\n\n# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first\n# line (until the first dot) of a Qt-style comment as the brief description. If\n# set to NO, the Qt-style will behave just like regular Qt-style comments (thus\n# requiring an explicit \\brief command for a brief description.)\n# The default value is: NO.\n\nQT_AUTOBRIEF           = NO\n\n# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a\n# multi-line C++ special comment block (i.e. a block of //! or /// comments) as\n# a brief description. This used to be the default behavior. The new default is\n# to treat a multi-line C++ comment block as a detailed description. Set this\n# tag to YES if you prefer the old behavior instead.\n#\n# Note that setting this tag to YES also means that rational rose comments are\n# not recognized any more.\n# The default value is: NO.\n\nMULTILINE_CPP_IS_BRIEF = NO\n\n# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the\n# documentation from any documented member that it re-implements.\n# The default value is: YES.\n\nINHERIT_DOCS           = YES\n\n# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new\n# page for each member. If set to NO, the documentation of a member will be part\n# of the file/class/namespace that contains it.\n# The default value is: NO.\n\nSEPARATE_MEMBER_PAGES  = NO\n\n# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen\n# uses this value to replace tabs by spaces in code fragments.\n# Minimum value: 1, maximum value: 16, default value: 4.\n\nTAB_SIZE               = 4\n\n# This tag can be used to specify a number of aliases that act as commands in\n# the documentation. An alias has the form:\n# name=value\n# For example adding\n# \"sideeffect=@par Side Effects:\\n\"\n# will allow you to put the command \\sideeffect (or @sideeffect) in the\n# documentation, which will result in a user-defined paragraph with heading\n# \"Side Effects:\". You can put \\n's in the value part of an alias to insert\n# newlines.\n\nALIASES                =\n\n# This tag can be used to specify a number of word-keyword mappings (TCL only).\n# A mapping has the form \"name=value\". For example adding \"class=itcl::class\"\n# will allow you to use the command class in the itcl::class meaning.\n\nTCL_SUBST              =\n\n# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources\n# only. Doxygen will then generate output that is more tailored for C. For\n# instance, some of the names that are used will be different. The list of all\n# members will be omitted, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_FOR_C  = NO\n\n# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or\n# Python sources only. Doxygen will then generate output that is more tailored\n# for that language. For instance, namespaces will be presented as packages,\n# qualified scopes will look different, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_JAVA   = NO\n\n# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran\n# sources. Doxygen will then generate output that is tailored for Fortran.\n# The default value is: NO.\n\nOPTIMIZE_FOR_FORTRAN   = NO\n\n# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL\n# sources. Doxygen will then generate output that is tailored for VHDL.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_VHDL   = NO\n\n# Doxygen selects the parser to use depending on the extension of the files it\n# parses. With this tag you can assign which parser to use for a given\n# extension. Doxygen has a built-in mapping, but you can override or extend it\n# using this tag. The format is ext=language, where ext is a file extension, and\n# language is one of the parsers supported by doxygen: IDL, Java, Javascript,\n# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:\n# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:\n# Fortran. In the later case the parser tries to guess whether the code is fixed\n# or free formatted code, this is the default for Fortran type files), VHDL. For\n# instance to make doxygen treat .inc files as Fortran files (default is PHP),\n# and .f files as C (default is Fortran), use: inc=Fortran f=C.\n#\n# Note: For files without extension you can use no_extension as a placeholder.\n#\n# Note that for custom extensions you also need to set FILE_PATTERNS otherwise\n# the files are not read by doxygen.\n\nEXTENSION_MAPPING      =\n\n# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments\n# according to the Markdown format, which allows for more readable\n# documentation. See http://daringfireball.net/projects/markdown/ for details.\n# The output of markdown processing is further processed by doxygen, so you can\n# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in\n# case of backward compatibilities issues.\n# The default value is: YES.\n\nMARKDOWN_SUPPORT       = YES\n\n# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up\n# to that level are automatically included in the table of contents, even if\n# they do not have an id attribute.\n# Note: This feature currently applies only to Markdown headings.\n# Minimum value: 0, maximum value: 99, default value: 0.\n# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.\n\nTOC_INCLUDE_HEADINGS   = 0\n\n# When enabled doxygen tries to link words that correspond to documented\n# classes, or namespaces to their corresponding documentation. Such a link can\n# be prevented in individual cases by putting a % sign in front of the word or\n# globally by setting AUTOLINK_SUPPORT to NO.\n# The default value is: YES.\n\nAUTOLINK_SUPPORT       = YES\n\n# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want\n# to include (a tag file for) the STL sources as input, then you should set this\n# tag to YES in order to let doxygen match functions declarations and\n# definitions whose arguments contain STL classes (e.g. func(std::string);\n# versus func(std::string) {}). This also make the inheritance and collaboration\n# diagrams that involve STL classes more complete and accurate.\n# The default value is: NO.\n\nBUILTIN_STL_SUPPORT    = NO\n\n# If you use Microsoft's C++/CLI language, you should set this option to YES to\n# enable parsing support.\n# The default value is: NO.\n\nCPP_CLI_SUPPORT        = NO\n\n# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:\n# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen\n# will parse them like normal C++ but will assume all classes use public instead\n# of private inheritance when no explicit protection keyword is present.\n# The default value is: NO.\n\nSIP_SUPPORT            = NO\n\n# For Microsoft's IDL there are propget and propput attributes to indicate\n# getter and setter methods for a property. Setting this option to YES will make\n# doxygen to replace the get and set methods by a property in the documentation.\n# This will only work if the methods are indeed getting or setting a simple\n# type. If this is not the case, or you want to show the methods anyway, you\n# should set this option to NO.\n# The default value is: YES.\n\nIDL_PROPERTY_SUPPORT   = YES\n\n# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC\n# tag is set to YES then doxygen will reuse the documentation of the first\n# member in the group (if any) for the other members of the group. By default\n# all members of a group must be documented explicitly.\n# The default value is: NO.\n\nDISTRIBUTE_GROUP_DOC   = NO\n\n# If one adds a struct or class to a group and this option is enabled, then also\n# any nested class or struct is added to the same group. By default this option\n# is disabled and one has to add nested compounds explicitly via \\ingroup.\n# The default value is: NO.\n\nGROUP_NESTED_COMPOUNDS = NO\n\n# Set the SUBGROUPING tag to YES to allow class member groups of the same type\n# (for instance a group of public functions) to be put as a subgroup of that\n# type (e.g. under the Public Functions section). Set it to NO to prevent\n# subgrouping. Alternatively, this can be done per class using the\n# \\nosubgrouping command.\n# The default value is: YES.\n\nSUBGROUPING            = YES\n\n# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions\n# are shown inside the group in which they are included (e.g. using \\ingroup)\n# instead of on a separate page (for HTML and Man pages) or section (for LaTeX\n# and RTF).\n#\n# Note that this feature does not work in combination with\n# SEPARATE_MEMBER_PAGES.\n# The default value is: NO.\n\nINLINE_GROUPED_CLASSES = NO\n\n# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions\n# with only public data fields or simple typedef fields will be shown inline in\n# the documentation of the scope in which they are defined (i.e. file,\n# namespace, or group documentation), provided this scope is documented. If set\n# to NO, structs, classes, and unions are shown on a separate page (for HTML and\n# Man pages) or section (for LaTeX and RTF).\n# The default value is: NO.\n\nINLINE_SIMPLE_STRUCTS  = NO\n\n# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or\n# enum is documented as struct, union, or enum with the name of the typedef. So\n# typedef struct TypeS {} TypeT, will appear in the documentation as a struct\n# with name TypeT. When disabled the typedef will appear as a member of a file,\n# namespace, or class. And the struct will be named TypeS. This can typically be\n# useful for C code in case the coding convention dictates that all compound\n# types are typedef'ed and only the typedef is referenced, never the tag name.\n# The default value is: NO.\n\nTYPEDEF_HIDES_STRUCT   = NO\n\n# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This\n# cache is used to resolve symbols given their name and scope. Since this can be\n# an expensive process and often the same symbol appears multiple times in the\n# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small\n# doxygen will become slower. If the cache is too large, memory is wasted. The\n# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range\n# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536\n# symbols. At the end of a run doxygen will report the cache usage and suggest\n# the optimal cache size from a speed point of view.\n# Minimum value: 0, maximum value: 9, default value: 0.\n\nLOOKUP_CACHE_SIZE      = 0\n\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\n\n# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in\n# documentation are documented, even if no documentation was available. Private\n# class members and static file members will be hidden unless the\n# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.\n# Note: This will also disable the warnings about undocumented members that are\n# normally produced when WARNINGS is set to YES.\n# The default value is: NO.\n\nEXTRACT_ALL            = NO\n\n# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will\n# be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PRIVATE        = NO\n\n# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal\n# scope will be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PACKAGE        = NO\n\n# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be\n# included in the documentation.\n# The default value is: NO.\n\nEXTRACT_STATIC         = YES\n\n# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined\n# locally in source files will be included in the documentation. If set to NO,\n# only classes defined in header files are included. Does not have any effect\n# for Java sources.\n# The default value is: YES.\n\nEXTRACT_LOCAL_CLASSES  = YES\n\n# This flag is only useful for Objective-C code. If set to YES, local methods,\n# which are defined in the implementation section but not in the interface are\n# included in the documentation. If set to NO, only methods in the interface are\n# included.\n# The default value is: NO.\n\nEXTRACT_LOCAL_METHODS  = NO\n\n# If this flag is set to YES, the members of anonymous namespaces will be\n# extracted and appear in the documentation as a namespace called\n# 'anonymous_namespace{file}', where file will be replaced with the base name of\n# the file that contains the anonymous namespace. By default anonymous namespace\n# are hidden.\n# The default value is: NO.\n\nEXTRACT_ANON_NSPACES   = NO\n\n# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all\n# undocumented members inside documented classes or files. If set to NO these\n# members will be included in the various overviews, but no documentation\n# section is generated. This option has no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_MEMBERS     = NO\n\n# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all\n# undocumented classes that are normally visible in the class hierarchy. If set\n# to NO, these classes will be included in the various overviews. This option\n# has no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_CLASSES     = NO\n\n# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend\n# (class|struct|union) declarations. If set to NO, these declarations will be\n# included in the documentation.\n# The default value is: NO.\n\nHIDE_FRIEND_COMPOUNDS  = NO\n\n# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any\n# documentation blocks found inside the body of a function. If set to NO, these\n# blocks will be appended to the function's detailed documentation block.\n# The default value is: NO.\n\nHIDE_IN_BODY_DOCS      = NO\n\n# The INTERNAL_DOCS tag determines if documentation that is typed after a\n# \\internal command is included. If the tag is set to NO then the documentation\n# will be excluded. Set it to YES to include the internal documentation.\n# The default value is: NO.\n\nINTERNAL_DOCS          = NO\n\n# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file\n# names in lower-case letters. If set to YES, upper-case letters are also\n# allowed. This is useful if you have classes or files whose names only differ\n# in case and if your file system supports case sensitive file names. Windows\n# and Mac users are advised to set this option to NO.\n# The default value is: system dependent.\n\nCASE_SENSE_NAMES       = YES\n\n# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with\n# their full class and namespace scopes in the documentation. If set to YES, the\n# scope will be hidden.\n# The default value is: NO.\n\nHIDE_SCOPE_NAMES       = NO\n\n# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will\n# append additional text to a page's title, such as Class Reference. If set to\n# YES the compound reference will be hidden.\n# The default value is: NO.\n\nHIDE_COMPOUND_REFERENCE= NO\n\n# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of\n# the files that are included by a file in the documentation of that file.\n# The default value is: YES.\n\nSHOW_INCLUDE_FILES     = YES\n\n# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each\n# grouped member an include statement to the documentation, telling the reader\n# which file to include in order to use the member.\n# The default value is: NO.\n\nSHOW_GROUPED_MEMB_INC  = NO\n\n# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include\n# files with double quotes in the documentation rather than with sharp brackets.\n# The default value is: NO.\n\nFORCE_LOCAL_INCLUDES   = NO\n\n# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the\n# documentation for inline members.\n# The default value is: YES.\n\nINLINE_INFO            = YES\n\n# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the\n# (detailed) documentation of file and class members alphabetically by member\n# name. If set to NO, the members will appear in declaration order.\n# The default value is: YES.\n\nSORT_MEMBER_DOCS       = YES\n\n# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief\n# descriptions of file, namespace and class members alphabetically by member\n# name. If set to NO, the members will appear in declaration order. Note that\n# this will also influence the order of the classes in the class list.\n# The default value is: NO.\n\nSORT_BRIEF_DOCS        = NO\n\n# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the\n# (brief and detailed) documentation of class members so that constructors and\n# destructors are listed first. If set to NO the constructors will appear in the\n# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.\n# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief\n# member documentation.\n# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting\n# detailed member documentation.\n# The default value is: NO.\n\nSORT_MEMBERS_CTORS_1ST = NO\n\n# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy\n# of group names into alphabetical order. If set to NO the group names will\n# appear in their defined order.\n# The default value is: NO.\n\nSORT_GROUP_NAMES       = NO\n\n# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by\n# fully-qualified names, including namespaces. If set to NO, the class list will\n# be sorted only by class name, not including the namespace part.\n# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\n# Note: This option applies only to the class list, not to the alphabetical\n# list.\n# The default value is: NO.\n\nSORT_BY_SCOPE_NAME     = NO\n\n# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper\n# type resolution of all parameters of a function it will reject a match between\n# the prototype and the implementation of a member function even if there is\n# only one candidate or it is obvious which candidate to choose by doing a\n# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still\n# accept a match between prototype and implementation in such cases.\n# The default value is: NO.\n\nSTRICT_PROTO_MATCHING  = NO\n\n# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo\n# list. This list is created by putting \\todo commands in the documentation.\n# The default value is: YES.\n\nGENERATE_TODOLIST      = YES\n\n# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test\n# list. This list is created by putting \\test commands in the documentation.\n# The default value is: YES.\n\nGENERATE_TESTLIST      = YES\n\n# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug\n# list. This list is created by putting \\bug commands in the documentation.\n# The default value is: YES.\n\nGENERATE_BUGLIST       = YES\n\n# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)\n# the deprecated list. This list is created by putting \\deprecated commands in\n# the documentation.\n# The default value is: YES.\n\nGENERATE_DEPRECATEDLIST= YES\n\n# The ENABLED_SECTIONS tag can be used to enable conditional documentation\n# sections, marked by \\if <section_label> ... \\endif and \\cond <section_label>\n# ... \\endcond blocks.\n\nENABLED_SECTIONS       =\n\n# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the\n# initial value of a variable or macro / define can have for it to appear in the\n# documentation. If the initializer consists of more lines than specified here\n# it will be hidden. Use a value of 0 to hide initializers completely. The\n# appearance of the value of individual variables and macros / defines can be\n# controlled using \\showinitializer or \\hideinitializer command in the\n# documentation regardless of this setting.\n# Minimum value: 0, maximum value: 10000, default value: 30.\n\nMAX_INITIALIZER_LINES  = 30\n\n# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at\n# the bottom of the documentation of classes and structs. If set to YES, the\n# list will mention the files that were used to generate the documentation.\n# The default value is: YES.\n\nSHOW_USED_FILES        = YES\n\n# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This\n# will remove the Files entry from the Quick Index and from the Folder Tree View\n# (if specified).\n# The default value is: YES.\n\nSHOW_FILES             = YES\n\n# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces\n# page. This will remove the Namespaces entry from the Quick Index and from the\n# Folder Tree View (if specified).\n# The default value is: YES.\n\nSHOW_NAMESPACES        = YES\n\n# The FILE_VERSION_FILTER tag can be used to specify a program or script that\n# doxygen should invoke to get the current version for each file (typically from\n# the version control system). Doxygen will invoke the program by executing (via\n# popen()) the command command input-file, where command is the value of the\n# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided\n# by doxygen. Whatever the program writes to standard output is used as the file\n# version. For an example see the documentation.\n\nFILE_VERSION_FILTER    =\n\n# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed\n# by doxygen. The layout file controls the global structure of the generated\n# output files in an output format independent way. To create the layout file\n# that represents doxygen's defaults, run doxygen with the -l option. You can\n# optionally specify a file name after the option, if omitted DoxygenLayout.xml\n# will be used as the name of the layout file.\n#\n# Note that if you run doxygen from a directory containing a file called\n# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE\n# tag is left empty.\n\nLAYOUT_FILE            =\n\n# The CITE_BIB_FILES tag can be used to specify one or more bib files containing\n# the reference definitions. This must be a list of .bib files. The .bib\n# extension is automatically appended if omitted. This requires the bibtex tool\n# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.\n# For LaTeX the style of the bibliography can be controlled using\n# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the\n# search path. See also \\cite for info how to create references.\n\nCITE_BIB_FILES         =\n\n#---------------------------------------------------------------------------\n# Configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\n\n# The QUIET tag can be used to turn on/off the messages that are generated to\n# standard output by doxygen. If QUIET is set to YES this implies that the\n# messages are off.\n# The default value is: NO.\n\nQUIET                  = NO\n\n# The WARNINGS tag can be used to turn on/off the warning messages that are\n# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES\n# this implies that the warnings are on.\n#\n# Tip: Turn warnings on while writing the documentation.\n# The default value is: YES.\n\nWARNINGS               = YES\n\n# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate\n# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag\n# will automatically be disabled.\n# The default value is: YES.\n\nWARN_IF_UNDOCUMENTED   = YES\n\n# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for\n# potential errors in the documentation, such as not documenting some parameters\n# in a documented function, or documenting parameters that don't exist or using\n# markup commands wrongly.\n# The default value is: YES.\n\nWARN_IF_DOC_ERROR      = YES\n\n# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that\n# are documented, but have no documentation for their parameters or return\n# value. If set to NO, doxygen will only warn about wrong or incomplete\n# parameter documentation, but not about the absence of documentation.\n# The default value is: NO.\n\nWARN_NO_PARAMDOC       = YES\n\n# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when\n# a warning is encountered.\n# The default value is: NO.\n\nWARN_AS_ERROR          = NO\n\n# The WARN_FORMAT tag determines the format of the warning messages that doxygen\n# can produce. The string should contain the $file, $line, and $text tags, which\n# will be replaced by the file and line number from which the warning originated\n# and the warning text. Optionally the format may contain $version, which will\n# be replaced by the version of the file (if it could be obtained via\n# FILE_VERSION_FILTER)\n# The default value is: $file:$line: $text.\n\nWARN_FORMAT            = \"$file:$line: $text\"\n\n# The WARN_LOGFILE tag can be used to specify a file to which warning and error\n# messages should be written. If left blank the output is written to standard\n# error (stderr).\n\nWARN_LOGFILE           =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the input files\n#---------------------------------------------------------------------------\n\n# The INPUT tag is used to specify the files and/or directories that contain\n# documented source files. You may enter file names like myfile.cpp or\n# directories like /usr/src/myproject. Separate the files or directories with\n# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING\n# Note: If this tag is empty the current directory is searched.\n\nINPUT                  = src examples README.md\n\n# This tag can be used to specify the character encoding of the source files\n# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses\n# libiconv (or the iconv built into libc) for the transcoding. See the libiconv\n# documentation (see: http://www.gnu.org/software/libiconv) for the list of\n# possible encodings.\n# The default value is: UTF-8.\n\nINPUT_ENCODING         = UTF-8\n\n# If the value of the INPUT tag contains directories, you can use the\n# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and\n# *.h) to filter out the source-files in the directories.\n#\n# Note that for custom extensions or not directly supported extensions you also\n# need to set EXTENSION_MAPPING for the extension otherwise the files are not\n# read by doxygen.\n#\n# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,\n# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,\n# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,\n# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,\n# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf.\n\nFILE_PATTERNS          = *.c \\\n                         *.cc \\\n                         *.cxx \\\n                         *.cpp \\\n                         *.c++ \\\n                         *.java \\\n                         *.ii \\\n                         *.ixx \\\n                         *.ipp \\\n                         *.i++ \\\n                         *.inl \\\n                         *.idl \\\n                         *.ddl \\\n                         *.odl \\\n                         *.h \\\n                         *.hh \\\n                         *.hxx \\\n                         *.hpp \\\n                         *.h++ \\\n                         *.cs \\\n                         *.d \\\n                         *.php \\\n                         *.php4 \\\n                         *.php5 \\\n                         *.phtml \\\n                         *.inc \\\n                         *.m \\\n                         *.markdown \\\n                         *.md \\\n                         *.mm \\\n                         *.dox \\\n                         *.py \\\n                         *.pyw \\\n                         *.f90 \\\n                         *.f95 \\\n                         *.f03 \\\n                         *.f08 \\\n                         *.f \\\n                         *.for \\\n                         *.tcl \\\n                         *.vhd \\\n                         *.vhdl \\\n                         *.ucf \\\n                         *.qsf\n\n# The RECURSIVE tag can be used to specify whether or not subdirectories should\n# be searched for input files as well.\n# The default value is: NO.\n\nRECURSIVE              = YES\n\n# The EXCLUDE tag can be used to specify files and/or directories that should be\n# excluded from the INPUT source files. This way you can easily exclude a\n# subdirectory from a directory tree whose root is specified with the INPUT tag.\n#\n# Note that relative paths are relative to the directory from which doxygen is\n# run.\n\nEXCLUDE                =\n\n# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\n# directories that are symbolic links (a Unix file system feature) are excluded\n# from the input.\n# The default value is: NO.\n\nEXCLUDE_SYMLINKS       = NO\n\n# If the value of the INPUT tag contains directories, you can use the\n# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude\n# certain files from those directories.\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories for example use the pattern */test/*\n\nEXCLUDE_PATTERNS       =\n\n# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names\n# (namespaces, classes, functions, etc.) that should be excluded from the\n# output. The symbol name can be a fully qualified name, a word, or if the\n# wildcard * is used, a substring. Examples: ANamespace, AClass,\n# AClass::ANamespace, ANamespace::*Test\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories use the pattern */test/*\n\nEXCLUDE_SYMBOLS        =\n\n# The EXAMPLE_PATH tag can be used to specify one or more files or directories\n# that contain example code fragments that are included (see the \\include\n# command).\n\nEXAMPLE_PATH           = examples\n\n# If the value of the EXAMPLE_PATH tag contains directories, you can use the\n# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank all\n# files are included.\n\nEXAMPLE_PATTERNS       = *\n\n# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be\n# searched for input files to be used with the \\include or \\dontinclude commands\n# irrespective of the value of the RECURSIVE tag.\n# The default value is: NO.\n\nEXAMPLE_RECURSIVE      = YES\n\n# The IMAGE_PATH tag can be used to specify one or more files or directories\n# that contain images that are to be included in the documentation (see the\n# \\image command).\n\nIMAGE_PATH             = extra/images\n\n# The INPUT_FILTER tag can be used to specify a program that doxygen should\n# invoke to filter for each input file. Doxygen will invoke the filter program\n# by executing (via popen()) the command:\n#\n# <filter> <input-file>\n#\n# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the\n# name of an input file. Doxygen will then use the output that the filter\n# program writes to standard output. If FILTER_PATTERNS is specified, this tag\n# will be ignored.\n#\n# Note that the filter must not add or remove lines; it is applied before the\n# code is scanned, but not when the output code is generated. If lines are added\n# or removed, the anchors will not be placed correctly.\n#\n# Note that for custom extensions or not directly supported extensions you also\n# need to set EXTENSION_MAPPING for the extension otherwise the files are not\n# properly processed by doxygen.\n\nINPUT_FILTER           =\n\n# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern\n# basis. Doxygen will compare the file name with each pattern and apply the\n# filter if there is a match. The filters are a list of the form: pattern=filter\n# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how\n# filters are used. If the FILTER_PATTERNS tag is empty or if none of the\n# patterns match the file name, INPUT_FILTER is applied.\n#\n# Note that for custom extensions or not directly supported extensions you also\n# need to set EXTENSION_MAPPING for the extension otherwise the files are not\n# properly processed by doxygen.\n\nFILTER_PATTERNS        =\n\n# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using\n# INPUT_FILTER) will also be used to filter the input files that are used for\n# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).\n# The default value is: NO.\n\nFILTER_SOURCE_FILES    = NO\n\n# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file\n# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and\n# it is also possible to disable source filtering for a specific pattern using\n# *.ext= (so without naming a filter).\n# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.\n\nFILTER_SOURCE_PATTERNS =\n\n# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that\n# is part of the input, its contents will be placed on the main page\n# (index.html). This can be useful if you have a project on for instance GitHub\n# and want to reuse the introduction page also for the doxygen output.\n\nUSE_MDFILE_AS_MAINPAGE = README.md\n\n#---------------------------------------------------------------------------\n# Configuration options related to source browsing\n#---------------------------------------------------------------------------\n\n# If the SOURCE_BROWSER tag is set to YES then a list of source files will be\n# generated. Documented entities will be cross-referenced with these sources.\n#\n# Note: To get rid of all source code in the generated output, make sure that\n# also VERBATIM_HEADERS is set to NO.\n# The default value is: NO.\n\nSOURCE_BROWSER         = NO\n\n# Setting the INLINE_SOURCES tag to YES will include the body of functions,\n# classes and enums directly into the documentation.\n# The default value is: NO.\n\nINLINE_SOURCES         = NO\n\n# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any\n# special comment blocks from generated source code fragments. Normal C, C++ and\n# Fortran comments will always remain visible.\n# The default value is: YES.\n\nSTRIP_CODE_COMMENTS    = YES\n\n# If the REFERENCED_BY_RELATION tag is set to YES then for each documented\n# function all documented functions referencing it will be listed.\n# The default value is: NO.\n\nREFERENCED_BY_RELATION = NO\n\n# If the REFERENCES_RELATION tag is set to YES then for each documented function\n# all documented entities called/used by that function will be listed.\n# The default value is: NO.\n\nREFERENCES_RELATION    = NO\n\n# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set\n# to YES then the hyperlinks from functions in REFERENCES_RELATION and\n# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will\n# link to the documentation.\n# The default value is: YES.\n\nREFERENCES_LINK_SOURCE = YES\n\n# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the\n# source code will show a tooltip with additional information such as prototype,\n# brief description and links to the definition and documentation. Since this\n# will make the HTML file larger and loading of large files a bit slower, you\n# can opt to disable this feature.\n# The default value is: YES.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nSOURCE_TOOLTIPS        = YES\n\n# If the USE_HTAGS tag is set to YES then the references to source code will\n# point to the HTML generated by the htags(1) tool instead of doxygen built-in\n# source browser. The htags tool is part of GNU's global source tagging system\n# (see http://www.gnu.org/software/global/global.html). You will need version\n# 4.8.6 or higher.\n#\n# To use it do the following:\n# - Install the latest version of global\n# - Enable SOURCE_BROWSER and USE_HTAGS in the config file\n# - Make sure the INPUT points to the root of the source tree\n# - Run doxygen as normal\n#\n# Doxygen will invoke htags (and that will in turn invoke gtags), so these\n# tools must be available from the command line (i.e. in the search path).\n#\n# The result: instead of the source browser generated by doxygen, the links to\n# source code will now point to the output of htags.\n# The default value is: NO.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nUSE_HTAGS              = NO\n\n# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a\n# verbatim copy of the header file for each class for which an include is\n# specified. Set to NO to disable this.\n# See also: Section \\class.\n# The default value is: YES.\n\nVERBATIM_HEADERS       = YES\n\n# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the\n# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the\n# cost of reduced performance. This can be particularly helpful with template\n# rich C++ code for which doxygen's built-in parser lacks the necessary type\n# information.\n# Note: The availability of this option depends on whether or not doxygen was\n# generated with the -Duse-libclang=ON option for CMake.\n# The default value is: NO.\n\nCLANG_ASSISTED_PARSING = NO\n\n# If clang assisted parsing is enabled you can provide the compiler with command\n# line options that you would normally use when invoking the compiler. Note that\n# the include paths will already be set by doxygen for the files and directories\n# specified with INPUT and INCLUDE_PATH.\n# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.\n\nCLANG_OPTIONS          =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\n\n# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all\n# compounds will be generated. Enable this if the project contains a lot of\n# classes, structs, unions or interfaces.\n# The default value is: YES.\n\nALPHABETICAL_INDEX     = YES\n\n# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in\n# which the alphabetical index list will be split.\n# Minimum value: 1, maximum value: 20, default value: 5.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nCOLS_IN_ALPHA_INDEX    = 5\n\n# In case all classes in a project start with a common prefix, all classes will\n# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag\n# can be used to specify a prefix (or a list of prefixes) that should be ignored\n# while generating the index headers.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nIGNORE_PREFIX          =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the HTML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output\n# The default value is: YES.\n\nGENERATE_HTML          = YES\n\n# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_OUTPUT            = html\n\n# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each\n# generated HTML page (for example: .htm, .php, .asp).\n# The default value is: .html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FILE_EXTENSION    = .html\n\n# The HTML_HEADER tag can be used to specify a user-defined HTML header file for\n# each generated HTML page. If the tag is left blank doxygen will generate a\n# standard header.\n#\n# To get valid HTML the header file that includes any scripts and style sheets\n# that doxygen needs, which is dependent on the configuration options used (e.g.\n# the setting GENERATE_TREEVIEW). It is highly recommended to start with a\n# default header using\n# doxygen -w html new_header.html new_footer.html new_stylesheet.css\n# YourConfigFile\n# and then modify the file new_header.html. See also section \"Doxygen usage\"\n# for information on how to generate the default header that doxygen normally\n# uses.\n# Note: The header is subject to change so you typically have to regenerate the\n# default header when upgrading to a newer version of doxygen. For a description\n# of the possible markers and block names see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_HEADER            =\n\n# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each\n# generated HTML page. If the tag is left blank doxygen will generate a standard\n# footer. See HTML_HEADER for more information on how to generate a default\n# footer and what special commands can be used inside the footer. See also\n# section \"Doxygen usage\" for information on how to generate the default footer\n# that doxygen normally uses.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FOOTER            =\n\n# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style\n# sheet that is used by each HTML page. It can be used to fine-tune the look of\n# the HTML output. If left blank doxygen will generate a default style sheet.\n# See also section \"Doxygen usage\" for information on how to generate the style\n# sheet that doxygen normally uses.\n# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as\n# it is more robust and this tag (HTML_STYLESHEET) will in the future become\n# obsolete.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_STYLESHEET        =\n\n# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined\n# cascading style sheets that are included after the standard style sheets\n# created by doxygen. Using this option one can overrule certain style aspects.\n# This is preferred over using HTML_STYLESHEET since it does not replace the\n# standard style sheet and is therefore more robust against future updates.\n# Doxygen will copy the style sheet files to the output directory.\n# Note: The order of the extra style sheet files is of importance (e.g. the last\n# style sheet in the list overrules the setting of the previous ones in the\n# list). For an example see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_STYLESHEET  =\n\n# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the HTML output directory. Note\n# that these files will be copied to the base HTML output directory. Use the\n# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these\n# files. In the HTML_STYLESHEET file, use the file name only. Also note that the\n# files will be copied as-is; there are no commands or markers available.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_FILES       =\n\n# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen\n# will adjust the colors in the style sheet and background images according to\n# this color. Hue is specified as an angle on a colorwheel, see\n# http://en.wikipedia.org/wiki/Hue for more information. For instance the value\n# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300\n# purple, and 360 is red again.\n# Minimum value: 0, maximum value: 359, default value: 220.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_HUE    = 220\n\n# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors\n# in the HTML output. For a value of 0 the output will use grayscales only. A\n# value of 255 will produce the most vivid colors.\n# Minimum value: 0, maximum value: 255, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_SAT    = 100\n\n# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the\n# luminance component of the colors in the HTML output. Values below 100\n# gradually make the output lighter, whereas values above 100 make the output\n# darker. The value divided by 100 is the actual gamma applied, so 80 represents\n# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not\n# change the gamma.\n# Minimum value: 40, maximum value: 240, default value: 80.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_GAMMA  = 80\n\n# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML\n# page will contain the date and time when the page was generated. Setting this\n# to YES can help to show when doxygen was last run and thus if the\n# documentation is up to date.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_TIMESTAMP         = NO\n\n# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML\n# documentation will contain sections that can be hidden and shown after the\n# page has loaded.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_DYNAMIC_SECTIONS  = YES\n\n# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries\n# shown in the various tree structured indices initially; the user can expand\n# and collapse entries dynamically later on. Doxygen will expand the tree to\n# such a level that at most the specified number of entries are visible (unless\n# a fully collapsed tree already exceeds this amount). So setting the number of\n# entries 1 will produce a full collapsed tree by default. 0 is a special value\n# representing an infinite number of entries and will result in a full expanded\n# tree by default.\n# Minimum value: 0, maximum value: 9999, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_INDEX_NUM_ENTRIES = 100\n\n# If the GENERATE_DOCSET tag is set to YES, additional index files will be\n# generated that can be used as input for Apple's Xcode 3 integrated development\n# environment (see: http://developer.apple.com/tools/xcode/), introduced with\n# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a\n# Makefile in the HTML output directory. Running make will produce the docset in\n# that directory and running make install will install the docset in\n# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at\n# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html\n# for more information.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_DOCSET        = NO\n\n# This tag determines the name of the docset feed. A documentation feed provides\n# an umbrella under which multiple documentation sets from a single provider\n# (such as a company or product suite) can be grouped.\n# The default value is: Doxygen generated docs.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\n\n# This tag specifies a string that should uniquely identify the documentation\n# set bundle. This should be a reverse domain-name style string, e.g.\n# com.mycompany.MyDocSet. Doxygen will append .docset to the name.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_BUNDLE_ID       = org.doxygen.Project\n\n# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify\n# the documentation publisher. This should be a reverse domain-name style\n# string, e.g. com.mycompany.MyDocSet.documentation.\n# The default value is: org.doxygen.Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\n\n# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.\n# The default value is: Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_NAME  = Publisher\n\n# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three\n# additional HTML index files: index.hhp, index.hhc, and index.hhk. The\n# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop\n# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on\n# Windows.\n#\n# The HTML Help Workshop contains a compiler that can convert all HTML output\n# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML\n# files are now used as the Windows 98 help format, and will replace the old\n# Windows help format (.hlp) on all Windows platforms in the future. Compressed\n# HTML files also contain an index, a table of contents, and you can search for\n# words in the documentation. The HTML workshop also contains a viewer for\n# compressed HTML files.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_HTMLHELP      = NO\n\n# The CHM_FILE tag can be used to specify the file name of the resulting .chm\n# file. You can add a path in front of the file if the result should not be\n# written to the html output directory.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_FILE               =\n\n# The HHC_LOCATION tag can be used to specify the location (absolute path\n# including file name) of the HTML help compiler (hhc.exe). If non-empty,\n# doxygen will try to run the HTML help compiler on the generated index.hhp.\n# The file has to be specified with full path.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nHHC_LOCATION           =\n\n# The GENERATE_CHI flag controls if a separate .chi index file is generated\n# (YES) or that it should be included in the master .chm file (NO).\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nGENERATE_CHI           = NO\n\n# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)\n# and project file content.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_INDEX_ENCODING     =\n\n# The BINARY_TOC flag controls whether a binary table of contents is generated\n# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it\n# enables the Previous and Next buttons.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nBINARY_TOC             = NO\n\n# The TOC_EXPAND flag can be set to YES to add extra items for group members to\n# the table of contents of the HTML help documentation and to the tree view.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nTOC_EXPAND             = NO\n\n# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and\n# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that\n# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help\n# (.qch) of the generated HTML documentation.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_QHP           = NO\n\n# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify\n# the file name of the resulting .qch file. The path specified is relative to\n# the HTML output folder.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQCH_FILE               =\n\n# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help\n# Project output. For more information please see Qt Help Project / Namespace\n# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_NAMESPACE          = org.doxygen.Project\n\n# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt\n# Help Project output. For more information please see Qt Help Project / Virtual\n# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-\n# folders).\n# The default value is: doc.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_VIRTUAL_FOLDER     = doc\n\n# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom\n# filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_NAME   =\n\n# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the\n# custom filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_ATTRS  =\n\n# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this\n# project's filter section matches. Qt Help Project / Filter Attributes (see:\n# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_SECT_FILTER_ATTRS  =\n\n# The QHG_LOCATION tag can be used to specify the location of Qt's\n# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the\n# generated .qhp file.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHG_LOCATION           =\n\n# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be\n# generated, together with the HTML files, they form an Eclipse help plugin. To\n# install this plugin and make it available under the help contents menu in\n# Eclipse, the contents of the directory containing the HTML and XML files needs\n# to be copied into the plugins directory of eclipse. The name of the directory\n# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.\n# After copying Eclipse needs to be restarted before the help appears.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_ECLIPSEHELP   = NO\n\n# A unique identifier for the Eclipse help plugin. When installing the plugin\n# the directory name containing the HTML and XML files should also have this\n# name. Each documentation set should have its own identifier.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.\n\nECLIPSE_DOC_ID         = org.doxygen.Project\n\n# If you want full control over the layout of the generated HTML pages it might\n# be necessary to disable the index and replace it with your own. The\n# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top\n# of each HTML page. A value of NO enables the index and the value YES disables\n# it. Since the tabs in the index contain the same information as the navigation\n# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nDISABLE_INDEX          = NO\n\n# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\n# structure should be generated to display hierarchical information. If the tag\n# value is set to YES, a side panel will be generated containing a tree-like\n# index structure (just like the one that is generated for HTML Help). For this\n# to work a browser that supports JavaScript, DHTML, CSS and frames is required\n# (i.e. any modern browser). Windows users are probably better off using the\n# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can\n# further fine-tune the look of the index. As an example, the default style\n# sheet generated by doxygen has an example that shows how to put an image at\n# the root of the tree instead of the PROJECT_NAME. Since the tree basically has\n# the same information as the tab index, you could consider setting\n# DISABLE_INDEX to YES when enabling this option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_TREEVIEW      = YES\n\n# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that\n# doxygen will group on one line in the generated HTML documentation.\n#\n# Note that a value of 0 will completely suppress the enum values from appearing\n# in the overview section.\n# Minimum value: 0, maximum value: 20, default value: 4.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nENUM_VALUES_PER_LINE   = 4\n\n# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used\n# to set the initial width (in pixels) of the frame in which the tree is shown.\n# Minimum value: 0, maximum value: 1500, default value: 250.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nTREEVIEW_WIDTH         = 250\n\n# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to\n# external symbols imported via tag files in a separate window.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nEXT_LINKS_IN_WINDOW    = NO\n\n# Use this tag to change the font size of LaTeX formulas included as images in\n# the HTML documentation. When you change the font size after a successful\n# doxygen run you need to manually remove any form_*.png images from the HTML\n# output directory to force them to be regenerated.\n# Minimum value: 8, maximum value: 50, default value: 10.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_FONTSIZE       = 10\n\n# Use the FORMULA_TRANPARENT tag to determine whether or not the images\n# generated for formulas are transparent PNGs. Transparent PNGs are not\n# supported properly for IE 6.0, but are supported on all modern browsers.\n#\n# Note that when changing this option you need to delete any form_*.png files in\n# the HTML output directory before the changes have effect.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_TRANSPARENT    = YES\n\n# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see\n# http://www.mathjax.org) which uses client side Javascript for the rendering\n# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX\n# installed or if you want to formulas look prettier in the HTML output. When\n# enabled you may also need to install MathJax separately and configure the path\n# to it using the MATHJAX_RELPATH option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nUSE_MATHJAX            = NO\n\n# When MathJax is enabled you can set the default output format to be used for\n# the MathJax output. See the MathJax site (see:\n# http://docs.mathjax.org/en/latest/output.html) for more details.\n# Possible values are: HTML-CSS (which is slower, but has the best\n# compatibility), NativeMML (i.e. MathML) and SVG.\n# The default value is: HTML-CSS.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_FORMAT         = HTML-CSS\n\n# When MathJax is enabled you need to specify the location relative to the HTML\n# output directory using the MATHJAX_RELPATH option. The destination directory\n# should contain the MathJax.js script. For instance, if the mathjax directory\n# is located at the same level as the HTML output directory, then\n# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax\n# Content Delivery Network so you can quickly see the result without installing\n# MathJax. However, it is strongly recommended to install a local copy of\n# MathJax from http://www.mathjax.org before deployment.\n# The default value is: http://cdn.mathjax.org/mathjax/latest.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest\n\n# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax\n# extension names that should be enabled during MathJax rendering. For example\n# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_EXTENSIONS     =\n\n# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces\n# of code that will be used on startup of the MathJax code. See the MathJax site\n# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an\n# example see the documentation.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_CODEFILE       =\n\n# When the SEARCHENGINE tag is enabled doxygen will generate a search box for\n# the HTML output. The underlying search engine uses javascript and DHTML and\n# should work on any modern browser. Note that when using HTML help\n# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)\n# there is already a search function so this one should typically be disabled.\n# For large projects the javascript based search engine can be slow, then\n# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to\n# search using the keyboard; to jump to the search box use <access key> + S\n# (what the <access key> is depends on the OS and browser, but it is typically\n# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down\n# key> to jump into the search results window, the results can be navigated\n# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel\n# the search. The filter options can be selected when the cursor is inside the\n# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>\n# to select a filter and <Enter> or <escape> to activate or cancel the filter\n# option.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nSEARCHENGINE           = YES\n\n# When the SERVER_BASED_SEARCH tag is enabled the search engine will be\n# implemented using a web server instead of a web client using Javascript. There\n# are two flavors of web server based searching depending on the EXTERNAL_SEARCH\n# setting. When disabled, doxygen will generate a PHP script for searching and\n# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing\n# and searching needs to be provided by external tools. See the section\n# \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSERVER_BASED_SEARCH    = NO\n\n# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP\n# script for searching. Instead the search results are written to an XML file\n# which needs to be processed by an external indexer. Doxygen will invoke an\n# external search engine pointed to by the SEARCHENGINE_URL option to obtain the\n# search results.\n#\n# Doxygen ships with an example indexer (doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/).\n#\n# See the section \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH        = NO\n\n# The SEARCHENGINE_URL should point to a search engine hosted by a web server\n# which will return the search results when EXTERNAL_SEARCH is enabled.\n#\n# Doxygen ships with an example indexer (doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/). See the section \"External Indexing and\n# Searching\" for details.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHENGINE_URL       =\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed\n# search data is written to a file for indexing by an external tool. With the\n# SEARCHDATA_FILE tag the name of this file can be specified.\n# The default file is: searchdata.xml.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHDATA_FILE        = searchdata.xml\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the\n# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is\n# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple\n# projects and redirect the results back to the right project.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH_ID     =\n\n# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen\n# projects other than the one defined by this configuration file, but that are\n# all added to the same external search index. Each project needs to have a\n# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of\n# to a relative location where the documentation can be found. The format is:\n# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTRA_SEARCH_MAPPINGS  =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.\n# The default value is: YES.\n\nGENERATE_LATEX         = NO\n\n# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_OUTPUT           = latex\n\n# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be\n# invoked.\n#\n# Note that when enabling USE_PDFLATEX this option is only used for generating\n# bitmaps for formulas in the HTML output, but not in the Makefile that is\n# written to the output directory.\n# The default file is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_CMD_NAME         = latex\n\n# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate\n# index for LaTeX.\n# The default file is: makeindex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nMAKEINDEX_CMD_NAME     = makeindex\n\n# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nCOMPACT_LATEX          = NO\n\n# The PAPER_TYPE tag can be used to set the paper type that is used by the\n# printer.\n# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x\n# 14 inches) and executive (7.25 x 10.5 inches).\n# The default value is: a4.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPAPER_TYPE             = a4\n\n# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names\n# that should be included in the LaTeX output. The package can be specified just\n# by its name or with the correct syntax as to be used with the LaTeX\n# \\usepackage command. To get the times font for instance you can specify :\n# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}\n# To use the option intlimits with the amsmath package you can specify:\n# EXTRA_PACKAGES=[intlimits]{amsmath}\n# If left blank no extra packages will be included.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nEXTRA_PACKAGES         =\n\n# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the\n# generated LaTeX document. The header should contain everything until the first\n# chapter. If it is left blank doxygen will generate a standard header. See\n# section \"Doxygen usage\" for information on how to let doxygen write the\n# default header to a separate file.\n#\n# Note: Only use a user-defined header if you know what you are doing! The\n# following commands have a special meaning inside the header: $title,\n# $datetime, $date, $doxygenversion, $projectname, $projectnumber,\n# $projectbrief, $projectlogo. Doxygen will replace $title with the empty\n# string, for the replacement values of the other commands the user is referred\n# to HTML_HEADER.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HEADER           =\n\n# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the\n# generated LaTeX document. The footer should contain everything after the last\n# chapter. If it is left blank doxygen will generate a standard footer. See\n# LATEX_HEADER for more information on how to generate a default footer and what\n# special commands can be used inside the footer.\n#\n# Note: Only use a user-defined footer if you know what you are doing!\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_FOOTER           =\n\n# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined\n# LaTeX style sheets that are included after the standard style sheets created\n# by doxygen. Using this option one can overrule certain style aspects. Doxygen\n# will copy the style sheet files to the output directory.\n# Note: The order of the extra style sheet files is of importance (e.g. the last\n# style sheet in the list overrules the setting of the previous ones in the\n# list).\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_EXTRA_STYLESHEET =\n\n# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the LATEX_OUTPUT output\n# directory. Note that the files will be copied as-is; there are no commands or\n# markers available.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_EXTRA_FILES      =\n\n# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is\n# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will\n# contain links (just like the HTML output) instead of page references. This\n# makes the output suitable for online browsing using a PDF viewer.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPDF_HYPERLINKS         = YES\n\n# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate\n# the PDF file directly from the LaTeX files. Set this option to YES, to get a\n# higher quality PDF documentation.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nUSE_PDFLATEX           = YES\n\n# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode\n# command to the generated LaTeX files. This will instruct LaTeX to keep running\n# if errors occur, instead of asking the user for help. This option is also used\n# when generating formulas in HTML.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BATCHMODE        = NO\n\n# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the\n# index chapters (such as File Index, Compound Index, etc.) in the output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HIDE_INDICES     = NO\n\n# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source\n# code with syntax highlighting in the LaTeX output.\n#\n# Note that which sources are shown also depends on other settings such as\n# SOURCE_BROWSER.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_SOURCE_CODE      = NO\n\n# The LATEX_BIB_STYLE tag can be used to specify the style to use for the\n# bibliography, e.g. plainnat, or ieeetr. See\n# http://en.wikipedia.org/wiki/BibTeX and \\cite for more info.\n# The default value is: plain.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BIB_STYLE        = plain\n\n# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated\n# page will contain the date and time when the page was generated. Setting this\n# to NO can help when comparing the output of multiple runs.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_TIMESTAMP        = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the RTF output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The\n# RTF output is optimized for Word 97 and may not look too pretty with other RTF\n# readers/editors.\n# The default value is: NO.\n\nGENERATE_RTF           = NO\n\n# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: rtf.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_OUTPUT             = rtf\n\n# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nCOMPACT_RTF            = NO\n\n# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will\n# contain hyperlink fields. The RTF file will contain links (just like the HTML\n# output) instead of page references. This makes the output suitable for online\n# browsing using Word or some other Word compatible readers that support those\n# fields.\n#\n# Note: WordPad (write) and others do not support links.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_HYPERLINKS         = NO\n\n# Load stylesheet definitions from file. Syntax is similar to doxygen's config\n# file, i.e. a series of assignments. You only have to provide replacements,\n# missing definitions are set to their default value.\n#\n# See also section \"Doxygen usage\" for information on how to generate the\n# default style sheet that doxygen normally uses.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_STYLESHEET_FILE    =\n\n# Set optional variables used in the generation of an RTF document. Syntax is\n# similar to doxygen's config file. A template extensions file can be generated\n# using doxygen -e rtf extensionFile.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_EXTENSIONS_FILE    =\n\n# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code\n# with syntax highlighting in the RTF output.\n#\n# Note that which sources are shown also depends on other settings such as\n# SOURCE_BROWSER.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_SOURCE_CODE        = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the man page output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for\n# classes and files.\n# The default value is: NO.\n\nGENERATE_MAN           = NO\n\n# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it. A directory man3 will be created inside the directory specified by\n# MAN_OUTPUT.\n# The default directory is: man.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_OUTPUT             = man\n\n# The MAN_EXTENSION tag determines the extension that is added to the generated\n# man pages. In case the manual section does not start with a number, the number\n# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is\n# optional.\n# The default value is: .3.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_EXTENSION          = .3\n\n# The MAN_SUBDIR tag determines the name of the directory created within\n# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by\n# MAN_EXTENSION with the initial . removed.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_SUBDIR             =\n\n# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it\n# will generate one additional man file for each entity documented in the real\n# man page(s). These additional files only source the real man page, but without\n# them the man command would be unable to find the correct page.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_LINKS              = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the XML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that\n# captures the structure of the code including all documentation.\n# The default value is: NO.\n\nGENERATE_XML           = NO\n\n# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: xml.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_OUTPUT             = xml\n\n# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program\n# listings (including syntax highlighting and cross-referencing information) to\n# the XML output. Note that enabling this will significantly increase the size\n# of the XML output.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_PROGRAMLISTING     = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to the DOCBOOK output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files\n# that can be used to generate PDF.\n# The default value is: NO.\n\nGENERATE_DOCBOOK       = NO\n\n# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in\n# front of it.\n# The default directory is: docbook.\n# This tag requires that the tag GENERATE_DOCBOOK is set to YES.\n\nDOCBOOK_OUTPUT         = docbook\n\n# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the\n# program listings (including syntax highlighting and cross-referencing\n# information) to the DOCBOOK output. Note that enabling this will significantly\n# increase the size of the DOCBOOK output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_DOCBOOK is set to YES.\n\nDOCBOOK_PROGRAMLISTING = NO\n\n#---------------------------------------------------------------------------\n# Configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an\n# AutoGen Definitions (see http://autogen.sf.net) file that captures the\n# structure of the code including all documentation. Note that this feature is\n# still experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_AUTOGEN_DEF   = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the Perl module output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module\n# file that captures the structure of the code including all documentation.\n#\n# Note that this feature is still experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_PERLMOD       = NO\n\n# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary\n# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI\n# output from the Perl module output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_LATEX          = NO\n\n# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely\n# formatted so it can be parsed by a human reader. This is useful if you want to\n# understand what is going on. On the other hand, if this tag is set to NO, the\n# size of the Perl module output will be much smaller and Perl will parse it\n# just the same.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_PRETTY         = YES\n\n# The names of the make variables in the generated doxyrules.make file are\n# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful\n# so different doxyrules.make files included by the same Makefile don't\n# overwrite each other's variables.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_MAKEVAR_PREFIX =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\n\n# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all\n# C-preprocessor directives found in the sources and include files.\n# The default value is: YES.\n\nENABLE_PREPROCESSING   = YES\n\n# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names\n# in the source code. If set to NO, only conditional compilation will be\n# performed. Macro expansion can be done in a controlled way by setting\n# EXPAND_ONLY_PREDEF to YES.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nMACRO_EXPANSION        = NO\n\n# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then\n# the macro expansion is limited to the macros specified with the PREDEFINED and\n# EXPAND_AS_DEFINED tags.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_ONLY_PREDEF     = NO\n\n# If the SEARCH_INCLUDES tag is set to YES, the include files in the\n# INCLUDE_PATH will be searched if a #include is found.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSEARCH_INCLUDES        = YES\n\n# The INCLUDE_PATH tag can be used to specify one or more directories that\n# contain include files that are not input files but should be processed by the\n# preprocessor.\n# This tag requires that the tag SEARCH_INCLUDES is set to YES.\n\nINCLUDE_PATH           =\n\n# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard\n# patterns (like *.h and *.hpp) to filter out the header-files in the\n# directories. If left blank, the patterns specified with FILE_PATTERNS will be\n# used.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nINCLUDE_FILE_PATTERNS  =\n\n# The PREDEFINED tag can be used to specify one or more macro names that are\n# defined before the preprocessor is started (similar to the -D option of e.g.\n# gcc). The argument of the tag is a list of macros of the form: name or\n# name=definition (no spaces). If the definition and the \"=\" are omitted, \"=1\"\n# is assumed. To prevent a macro definition from being undefined via #undef or\n# recursively expanded use the := operator instead of the = operator.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nPREDEFINED             = USBCON ARDUINO_ARCH_AVR\n\n# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this\n# tag can be used to specify a list of macro names that should be expanded. The\n# macro definition that is found in the sources will be used. Use the PREDEFINED\n# tag if you want to use a different macro definition that overrules the\n# definition found in the source code.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_AS_DEFINED      =\n\n# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will\n# remove all references to function-like macros that are alone on a line, have\n# an all uppercase name, and do not end with a semicolon. Such function macros\n# are typically used for boiler-plate code, and will confuse the parser if not\n# removed.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSKIP_FUNCTION_MACROS   = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to external references\n#---------------------------------------------------------------------------\n\n# The TAGFILES tag can be used to specify one or more tag files. For each tag\n# file the location of the external documentation should be added. The format of\n# a tag file without this location is as follows:\n# TAGFILES = file1 file2 ...\n# Adding location for the tag files is done as follows:\n# TAGFILES = file1=loc1 \"file2 = loc2\" ...\n# where loc1 and loc2 can be relative or absolute paths or URLs. See the\n# section \"Linking to external documentation\" for more information about the use\n# of tag files.\n# Note: Each tag file must have a unique name (where the name does NOT include\n# the path). If a tag file is not located in the directory in which doxygen is\n# run, you must also specify the path to the tagfile here.\n\nTAGFILES               =\n\n# When a file name is specified after GENERATE_TAGFILE, doxygen will create a\n# tag file that is based on the input files it reads. See section \"Linking to\n# external documentation\" for more information about the usage of tag files.\n\nGENERATE_TAGFILE       =\n\n# If the ALLEXTERNALS tag is set to YES, all external class will be listed in\n# the class index. If set to NO, only the inherited external classes will be\n# listed.\n# The default value is: NO.\n\nALLEXTERNALS           = NO\n\n# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed\n# in the modules index. If set to NO, only the current project's groups will be\n# listed.\n# The default value is: YES.\n\nEXTERNAL_GROUPS        = YES\n\n# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in\n# the related pages index. If set to NO, only the current project's pages will\n# be listed.\n# The default value is: YES.\n\nEXTERNAL_PAGES         = YES\n\n# The PERL_PATH should be the absolute path and name of the perl script\n# interpreter (i.e. the result of 'which perl').\n# The default file (with absolute path) is: /usr/bin/perl.\n\nPERL_PATH              = /usr/bin/perl\n\n#---------------------------------------------------------------------------\n# Configuration options related to the dot tool\n#---------------------------------------------------------------------------\n\n# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram\n# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to\n# NO turns the diagrams off. Note that this option also works with HAVE_DOT\n# disabled, but it is recommended to install and use dot, since it yields more\n# powerful graphs.\n# The default value is: YES.\n\nCLASS_DIAGRAMS         = YES\n\n# You can define message sequence charts within doxygen comments using the \\msc\n# command. Doxygen will then run the mscgen tool (see:\n# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the\n# documentation. The MSCGEN_PATH tag allows you to specify the directory where\n# the mscgen tool resides. If left empty the tool is assumed to be found in the\n# default search path.\n\nMSCGEN_PATH            =\n\n# You can include diagrams made with dia in doxygen documentation. Doxygen will\n# then run dia to produce the diagram and insert it in the documentation. The\n# DIA_PATH tag allows you to specify the directory where the dia binary resides.\n# If left empty dia is assumed to be found in the default search path.\n\nDIA_PATH               =\n\n# If set to YES the inheritance and collaboration graphs will hide inheritance\n# and usage relations if the target is undocumented or is not a class.\n# The default value is: YES.\n\nHIDE_UNDOC_RELATIONS   = YES\n\n# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is\n# available from the path. This tool is part of Graphviz (see:\n# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent\n# Bell Labs. The other options in this section have no effect if this option is\n# set to NO\n# The default value is: YES.\n\nHAVE_DOT               = YES\n\n# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed\n# to run in parallel. When set to 0 doxygen will base this on the number of\n# processors available in the system. You can set it explicitly to a value\n# larger than 0 to get control over the balance between CPU load and processing\n# speed.\n# Minimum value: 0, maximum value: 32, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_NUM_THREADS        = 0\n\n# When you want a differently looking font in the dot files that doxygen\n# generates you can specify the font name using DOT_FONTNAME. You need to make\n# sure dot is able to find the font, which can be done by putting it in a\n# standard location or by setting the DOTFONTPATH environment variable or by\n# setting DOT_FONTPATH to the directory containing the font.\n# The default value is: Helvetica.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTNAME           = Helvetica\n\n# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of\n# dot graphs.\n# Minimum value: 4, maximum value: 24, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTSIZE           = 10\n\n# By default doxygen will tell dot to use the default font as specified with\n# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set\n# the path where dot can find it using this tag.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTPATH           =\n\n# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for\n# each documented class showing the direct and indirect inheritance relations.\n# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCLASS_GRAPH            = YES\n\n# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a\n# graph for each documented class showing the direct and indirect implementation\n# dependencies (inheritance, containment, and class references variables) of the\n# class with other documented classes.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCOLLABORATION_GRAPH    = YES\n\n# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for\n# groups, showing the direct groups dependencies.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGROUP_GRAPHS           = YES\n\n# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and\n# collaboration diagrams in a style similar to the OMG's Unified Modeling\n# Language.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LOOK               = NO\n\n# If the UML_LOOK tag is enabled, the fields and methods are shown inside the\n# class node. If there are many fields or methods and many nodes the graph may\n# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the\n# number of items for each type to make the size more manageable. Set this to 0\n# for no limit. Note that the threshold may be exceeded by 50% before the limit\n# is enforced. So when you set the threshold to 10, up to 15 fields may appear,\n# but if the number exceeds 15, the total amount of fields shown is limited to\n# 10.\n# Minimum value: 0, maximum value: 100, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LIMIT_NUM_FIELDS   = 10\n\n# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and\n# collaboration graphs will show the relations between templates and their\n# instances.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nTEMPLATE_RELATIONS     = NO\n\n# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to\n# YES then doxygen will generate a graph for each documented file showing the\n# direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDE_GRAPH          = YES\n\n# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are\n# set to YES then doxygen will generate a graph for each documented file showing\n# the direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDED_BY_GRAPH      = YES\n\n# If the CALL_GRAPH tag is set to YES then doxygen will generate a call\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable call graphs for selected\n# functions only using the \\callgraph command. Disabling a call graph can be\n# accomplished by means of the command \\hidecallgraph.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALL_GRAPH             = NO\n\n# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable caller graphs for selected\n# functions only using the \\callergraph command. Disabling a caller graph can be\n# accomplished by means of the command \\hidecallergraph.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALLER_GRAPH           = NO\n\n# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical\n# hierarchy of all classes instead of a textual one.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGRAPHICAL_HIERARCHY    = YES\n\n# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the\n# dependencies a directory has on other directories in a graphical way. The\n# dependency relations are determined by the #include relations between the\n# files in the directories.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDIRECTORY_GRAPH        = YES\n\n# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images\n# generated by dot. For an explanation of the image formats see the section\n# output formats in the documentation of the dot tool (Graphviz (see:\n# http://www.graphviz.org/)).\n# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order\n# to make the SVG files visible in IE 9+ (other browsers do not have this\n# requirement).\n# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,\n# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,\n# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo,\n# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and\n# png:gdiplus:gdiplus.\n# The default value is: png.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_IMAGE_FORMAT       = svg\n\n# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to\n# enable generation of interactive SVG images that allow zooming and panning.\n#\n# Note that this requires a modern browser other than Internet Explorer. Tested\n# and working are Firefox, Chrome, Safari, and Opera.\n# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make\n# the SVG files visible. Older versions of IE do not have SVG support.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINTERACTIVE_SVG        = YES\n\n# The DOT_PATH tag can be used to specify the path where the dot tool can be\n# found. If left blank, it is assumed the dot tool can be found in the path.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_PATH               =\n\n# The DOTFILE_DIRS tag can be used to specify one or more directories that\n# contain dot files that are included in the documentation (see the \\dotfile\n# command).\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOTFILE_DIRS           =\n\n# The MSCFILE_DIRS tag can be used to specify one or more directories that\n# contain msc files that are included in the documentation (see the \\mscfile\n# command).\n\nMSCFILE_DIRS           =\n\n# The DIAFILE_DIRS tag can be used to specify one or more directories that\n# contain dia files that are included in the documentation (see the \\diafile\n# command).\n\nDIAFILE_DIRS           =\n\n# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the\n# path where java can find the plantuml.jar file. If left blank, it is assumed\n# PlantUML is not used or called during a preprocessing step. Doxygen will\n# generate a warning when it encounters a \\startuml command in this case and\n# will not generate output for the diagram.\n\nPLANTUML_JAR_PATH      =\n\n# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a\n# configuration file for plantuml.\n\nPLANTUML_CFG_FILE      =\n\n# When using plantuml, the specified paths are searched for files specified by\n# the !include statement in a plantuml block.\n\nPLANTUML_INCLUDE_PATH  =\n\n# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes\n# that will be shown in the graph. If the number of nodes in a graph becomes\n# larger than this value, doxygen will truncate the graph, which is visualized\n# by representing a node as a red box. Note that doxygen if the number of direct\n# children of the root node in a graph is already larger than\n# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that\n# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\n# Minimum value: 0, maximum value: 10000, default value: 50.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_GRAPH_MAX_NODES    = 50\n\n# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs\n# generated by dot. A depth value of 3 means that only nodes reachable from the\n# root by following a path via at most 3 edges will be shown. Nodes that lay\n# further from the root node will be omitted. Note that setting this option to 1\n# or 2 may greatly reduce the computation time needed for large code bases. Also\n# note that the size of a graph can be further restricted by\n# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\n# Minimum value: 0, maximum value: 1000, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nMAX_DOT_GRAPH_DEPTH    = 0\n\n# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent\n# background. This is disabled by default, because dot on Windows does not seem\n# to support this out of the box.\n#\n# Warning: Depending on the platform used, enabling this option may lead to\n# badly anti-aliased labels on the edges of a graph (i.e. they become hard to\n# read).\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_TRANSPARENT        = NO\n\n# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output\n# files in one run (i.e. multiple -o and -T options on the command line). This\n# makes dot run faster, but since only newer versions of dot (>1.8.10) support\n# this, this feature is disabled by default.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_MULTI_TARGETS      = NO\n\n# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page\n# explaining the meaning of the various boxes and arrows in the dot generated\n# graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGENERATE_LEGEND        = YES\n\n# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot\n# files that are used to generate the various graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_CLEANUP            = YES\n"
  },
  {
    "path": "keywords.txt",
    "content": "#######################################\n# Syntax Coloring Map For Corsair Lighting Protocol\n#######################################\n\n#######################################\n# Datatypes (KEYWORD1)\n#######################################\n\nILEDController\tKEYWORD1\nLEDController\tKEYWORD1\nFastLEDController\tKEYWORD1\nCorsairLightingProtocolController\tKEYWORD1\nCorsairLightingProtocolHID\tKEYWORD1\nCorsairLightingProtocolTinyUSBHID\tKEYWORD1\nCorsairLightingProtocolSerial\tKEYWORD1\nCorsairLightingProtocolResponse\tKEYWORD1\nCorsairLightingFirmware\tKEYWORD1\nIFanController\tKEYWORD1\nFanController\tKEYWORD1\nITemperatureController\tKEYWORD1\nTemperatureController\tKEYWORD1\n\n#######################################\n# Methods and Functions (KEYWORD2)\n#######################################\n\n\n#######################################\n# Instances (KEYWORD1)\n#######################################\n\n\n#######################################\n# Structures (KEYWORD3)\n#######################################\n\nChannelData\tKEYWORD3\nCommand\tKEYWORD3\nFanCurve\tKEYWORD3\nLEDChannel\tKEYWORD3\nLEDGroup\tKEYWORD3\nSegmentScaling  KEYWORD3\n\n#######################################\n# Constants (LITERAL1)\n#######################################\n\n"
  },
  {
    "path": "library.properties",
    "content": "name=Corsair Lighting Protocol\nversion=0.15.0\nauthor=Leon Kiefer\nmaintainer=Leon Kiefer\nsentence=Control LED strips via USB from a PC.\nparagraph=The library mimics Corsair LED Controller devices and can be controlled via USB in iCUE.\ncategory=Device Control\nurl=https://github.com/Legion2/CorsairLightingProtocol\narchitectures=avr,samd,rp2040\nincludes=CorsairLightingProtocol.h\ndepends=FastLED\n"
  },
  {
    "path": "src/CLPAdditionalFeatures.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CLPAdditionalFeatures.h\"\n\n#include \"CLPUtils.h\"\n\nbool CLP::shouldReset(const CorsairLightingFirmware* firmware) {\n\tDeviceID deviceId;\n\tfirmware->getDeviceID(deviceId);\n\treturn CLP::isResetID(deviceId);\n}\n\nvoid CLP::reset(CorsairLightingFirmware* firmware) {\n\tDeviceID deviceId = {0x00};\n\tfirmware->setDeviceID(deviceId);\n}\n"
  },
  {
    "path": "src/CLPAdditionalFeatures.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingFirmware.h\"\n\nnamespace CLP {\n/**\n * Check if the device should be reseted. The check is based on the DeviceID from the firmware.\n *\n * @param firmware the firmware used by this device\n * @return if the device should be reset\n */\nbool shouldReset(const CorsairLightingFirmware* firmware);\n\n/**\n * Reset the DeviceID of the firmware.\n *\n * @param firmware reset this firmware\n */\nvoid reset(CorsairLightingFirmware* firmware);\n}  // namespace CLP\n"
  },
  {
    "path": "src/CLPUtils.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CLPUtils.h\"\n\nuint16_t CLP::fromBigEndian(const byte& byte1, const byte& byte2) {\n\tuint16_t t = byte1;\n\tt = t << 8;\n\tt |= byte2;\n\treturn t;\n}\n\nvoid CLP::disableBuildInLEDs() {\n#ifndef DEBUG\n#ifdef LED_BUILTIN_RX\n\tpinMode(LED_BUILTIN_RX, INPUT);\n#endif\n#ifdef LED_BUILTIN_TX\n\tpinMode(LED_BUILTIN_TX, INPUT);\n#endif\n#endif\n}\n\nbool CLP::isNullID(const DeviceID& deviceId) {\n\treturn !(deviceId.data[0] | deviceId.data[1] | deviceId.data[2] | deviceId.data[3]);\n}\n\nbool CLP::isResetID(const DeviceID& deviceId) {\n\treturn deviceId.data[0] == 0xFF && deviceId.data[1] == 0xFF && deviceId.data[2] == 0xFF && deviceId.data[3] == 0xFF;\n}\n\nvoid CLP::printDeviceID(const DeviceID& deviceId) {\n\tchar tmp[16];\n\tfor (size_t i = 0; i < 4; i++) {\n\t\tsprintf(tmp, \"%.2X\", deviceId.data[i]);\n\t\tSerial.print(tmp);\n\t\tif (i < 3) Serial.print(F(\" \"));\n\t}\n}\n\nvoid CLP::printFps(const int interval) {\n\t// Create static variables so that the code and variables can\n\t// all be declared inside a function\n\tstatic unsigned long lastMillis;\n\tstatic unsigned long frameCount;\n\n\tunsigned long now = millis();\n\tframeCount++;\n\tif (now - lastMillis >= (unsigned int)interval) {\n\t\tdouble framesPerSecond = (frameCount * 1000.0) / interval;\n\t\tSerial.print(F(\"FPS: \"));\n\t\tSerial.println(framesPerSecond, 1);\n\t\tframeCount = 0;\n\t\tlastMillis = now;\n\t}\n}\n\n#if CLP_DEBUG\n#if defined(CLP_DEBUG_PORT)\n\nint CLP::printf(const char* __restrict format, ...) {\n\tchar buf[64];\n\tint len;\n\tva_list ap;\n\tva_start(ap, format);\n\tlen = vsnprintf(buf, sizeof(buf), format, ap);\n\tCLP_DEBUG_PORT.write(buf);\n\tva_end(ap);\n\treturn len;\n}\n\nint CLP::printf(const __FlashStringHelper* __restrict format, ...) {\n\tchar buf[64];\n\tchar fmt[64];\n\tint len;\n\tva_list ap;\n\tva_start(ap, format);\n\tstrcpy_P(fmt, (const char*)format);\n\tlen = vsnprintf(buf, sizeof(buf), fmt, ap);\n\tCLP_DEBUG_PORT.write(buf);\n\tva_end(ap);\n\treturn len;\n}\n\n#endif  // defined(CLP_DEBUG_PORT)\n\nvoid CLP::printData(uint8_t const* buf, uint32_t bufsize, bool address_table) {\n\tif (address_table) {\n\t\tclpPrintf(\"\\t>>>> \");\n\t\tfor (uint32_t i = 0; i < 16; i++) clpPrintf(\"0x%X \", i);\n\t\tclpPrintf(\"\\r\\n\");\n\t}\n\tfor (uint32_t i = 0; i < bufsize; i++) {\n\t\tif (address_table && (i % 16 == 0)) clpPrintf(\"\\t0x%02X \", (i / 16) << 4);\n\t\tclpPrintf(\" %02X \", buf[i]);\n\t\tif ((i + 1) % 16 == 0 || (i + 1) == bufsize) clpPrintf(\"\\r\\n\");\n\t}\n}\n\n#endif  // CLP_DEBUG\n"
  },
  {
    "path": "src/CLPUtils.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingFirmware.h\"\n\n#define toBigEndian(a) highByte(a), lowByte(a)\n\n#if CLP_DEBUG\n\n#define CLP_STRCAT(a, b) a##b\n#define CLP_STRCAT3(a, b, c) a##b##c\n\n#define CLP_XSTRCAT(a, b) CLP_STRCAT(a, b)\n#define CLP_XSTRCAT3(a, b, c) CLP_STRCAT3(a, b, c)\n\n#if defined(CLP_DEBUG_PORT)\nnamespace CLP {\nextern int printf(const char* format, ...);\nextern int printf(const __FlashStringHelper* format, ...);\n}  // namespace CLP\n#define clpPrintf CLP::printf\n#else\n#define clpPrintf printf\n#endif\n\nnamespace CLP {\nstatic inline void printVar(uint8_t const* buf, uint32_t bufsize) {\n\tfor (uint32_t i = 0; i < bufsize; i++) clpPrintf(\"%02X \", buf[i]);\n}\nextern void printData(uint8_t const* buf, uint32_t bufsize, bool address_table);\n}  // namespace CLP\n\n/* clang-format off */\n#define CLP_LOG(n, ...)               CLP_XSTRCAT(CLP_LOG, n)(__VA_ARGS__)\n#define CLP_LOG_VAR(n, ...)           CLP_XSTRCAT3(CLP_LOG, n, _VAR)(__VA_ARGS__)\n#define CLP_LOG_HEX(n, ...)           CLP_XSTRCAT3(CLP_LOG, n, _HEX)(__VA_ARGS__)\n#define CLP_LOG_DAT(n, buf, size, at) CLP_XSTRCAT3(CLP_LOG, n, _DAT)(buf, size, at)\n#define CLP_LOG_LOCATION()            clpPrintf(\"%s: %d:\\r\\n\", __PRETTY_FUNCTION__, __LINE__)\n#define CLP_LOG_FAILED()              clpPrintf(\"%s: %d: Failed\\r\\n\", __PRETTY_FUNCTION__, __LINE__)\n#define CLP_LOG_FUNC(func)            func\n\n// Log Level 1: Error\n#define CLP_LOG1                      clpPrintf\n#define CLP_LOG1_VAR(_x)              CLP::printVar((uint8_t const*)(_x), sizeof(*(_x)))\n#define CLP_LOG1_HEX(_x)              clpPrintf(#_x \" = %lX\\r\\n\", (unsigned long) (_x) )\n#define CLP_LOG1_DAT(_x, _y, _z)      CLP::printData((uint8_t const*)(_x), _y, _z)\n\n// Log Level 2: Warn\n#if CLP_DEBUG >= 2\n#define CLP_LOG2                      CLP_LOG1\n#define CLP_LOG2_VAR                  CLP_LOG1_VAR\n#define CLP_LOG2_HEX                  CLP_LOG1_HEX\n#define CLP_LOG2_DAT                  CLP_LOG1_DAT\n#endif\n\n// Log Level 3: Info\n#if CLP_DEBUG >= 3\n#define CLP_LOG3                      CLP_LOG1\n#define CLP_LOG3_VAR                  CLP_LOG1_VAR\n#define CLP_LOG3_HEX                  CLP_LOG1_HEX\n#define CLP_LOG3_DAT                  CLP_LOG1_DAT\n#endif\n\n// Log Level 4: Data\n#if CLP_DEBUG >= 4\n#define CLP_LOG4                      CLP_LOG1\n#define CLP_LOG4_VAR                  CLP_LOG1_VAR\n#define CLP_LOG4_HEX                  CLP_LOG1_HEX\n#define CLP_LOG4_DAT                  CLP_LOG1_DAT\n#endif\n/* clang-format on */\n\n#endif  // CLP_DEBUG\n\n#ifndef CLP_LOG\n#define CLP_LOG(n, ...)\n#define CLP_LOG_VAR(n, ...)\n#define CLP_LOG_HEX(n, ...)\n#define CLP_LOG_DAT(n, buf, size, at)\n#define CLP_LOG_FUNC(n)\n#endif\n\n#define CLP_LOG0(...)\n#define CLP_LOG0_VAR(...)\n#define CLP_LOG0_HEX(...)\n#define CLP_LOG0_DAT(...)\n\n#ifndef CLP_LOG1\n#define CLP_LOG1(...)\n#define CLP_LOG1_VAR(...)\n#define CLP_LOG1_HEX(...)\n#define CLP_LOG1_DAT(...)\n#endif\n\n#ifndef CLP_LOG2\n#define CLP_LOG2(...)\n#define CLP_LOG2_VAR(...)\n#define CLP_LOG2_HEX(...)\n#define CLP_LOG2_DAT(...)\n#endif\n\n#ifndef CLP_LOG3\n#define CLP_LOG3(...)\n#define CLP_LOG3_VAR(...)\n#define CLP_LOG3_HEX(...)\n#define CLP_LOG3_DAT(...)\n#endif\n\n#ifndef CLP_LOG4\n#define CLP_LOG4(...)\n#define CLP_LOG4_VAR(...)\n#define CLP_LOG4_HEX(...)\n#define CLP_LOG4_DAT(...)\n#endif\n\nnamespace CLP {\n\ntemplate <typename T>\nvoid swap(T a, T b) {\n\tauto temp = *a;\n\t*a = *b;\n\t*b = temp;\n}\n\ntemplate <typename T>\nvoid reverse(T first, T last) {\n\twhile ((first != last) && (first != --last)) {\n\t\tCLP::swap(first++, last);\n\t}\n}\n\ntemplate <typename T>\nvoid rotate(T first, T n_first, T last) {\n\tif (first == n_first) return;\n\tif (n_first == last) return;\n\n\tT read = n_first;\n\tT write = first;\n\tT next_read = first;\n\n\twhile (read != last) {\n\t\tif (write == next_read) next_read = read;\n\t\tCLP::swap(read++, write++);\n\t}\n\n\t(rotate)(write, next_read, last);\n\treturn;\n}\n\nuint16_t fromBigEndian(const byte& byte1, const byte& byte2);\n\n/**\n * Convert value from range 0-100 to 0-255\n *\n * @param value the value which should be converted\n */\ninline uint8_t convert100To255(uint8_t value) { return value * 2.5546875f; }\n\n/**\n * Convert value from range 0-255 to 0-100.\n *\n * @param value the value which should be converted\n */\ninline uint8_t convert255To100(uint8_t value) { return value / 2.5546875f; }\n\n/**\n * Check if a device id is the special null id (00 00 00 00).\n *\n * @param deviceId the device id to check\n */\nbool isNullID(const DeviceID& deviceId);\n\n/**\n * Check if a device id is the special reset id (FF FF FF FF).\n *\n * @param deviceId the device id to check\n */\nbool isResetID(const DeviceID& deviceId);\n\n/**\n * This will disable the RX and TX built in LEDs on Arduino Leonardo, Micro and Pro Micro.\n */\nvoid disableBuildInLEDs();\n\n/**\n * Print the given DeviceID to Serial\n *\n * @param deviceId the device id to print\n */\nvoid printDeviceID(const DeviceID& deviceId);\n\n/*\n * Measure and print the framerate at the given interval in milliseconds. The higher this value the more precise the\n * result will be. This function should be called after FastLED.show() to count the FPS.\n *\n * @param interval the measurement interval in milliseconds\n */\nvoid printFps(const int interval);\n}  // namespace CLP\n"
  },
  {
    "path": "src/CorsairLightingFirmware.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CorsairLightingFirmware.h\"\n\nconst uint8_t bootloader_version[] PROGMEM = {0x00, 0x02};\n\nCorsairLightingFirmware::CorsairLightingFirmware(corsair_product_enum_t product,\n\t\t\t\t\t\t\t\t\t\t\t\t CorsairLightingFirmwareStorage* storage)\n\t: storage(storage), product(product) {\n\tstorage->loadDeviceID(deviceId);\n}\n\nvoid CorsairLightingFirmware::handleFirmwareCommand(const Command& command,\n\t\t\t\t\t\t\t\t\t\t\t\t\tconst CorsairLightingProtocolResponse* response) {\n\tswitch (command.command) {\n\t\tcase READ_STATUS: {\n\t\t\tuint8_t statusData[] = {status};\n\t\t\tresponse->send(statusData, sizeof(statusData));\n\t\t\tbreak;\n\t\t}\n\t\tcase READ_FIRMWARE_VERSION: {\n\t\t\tresponse->send_P(firmwareVersions[product], FIRMWARE_VERSION_SIZE);\n\t\t\tbreak;\n\t\t}\n\t\tcase READ_DEVICE_ID: {\n\t\t\tresponse->send(deviceId.data, sizeof(deviceId));\n\t\t\tbreak;\n\t\t}\n\t\tcase WRITE_DEVICE_ID: {\n\t\t\tDeviceID deviceID = {command.data[0], command.data[1], command.data[2], command.data[3]};\n\t\t\tsetDeviceID(deviceID);\n\t\t\tresponse->send(deviceId.data, sizeof(deviceId));\n\t\t\tbreak;\n\t\t}\n\t\tcase READ_BOOTLOADER_VERSION: {\n\t\t\tresponse->send_P(bootloader_version, sizeof(bootloader_version));\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tresponse->sendError();\n\t\t}\n\t}\n}\n\nvoid CorsairLightingFirmware::getDeviceID(DeviceID& deviceID) const { deviceID = deviceId; }\n\nvoid CorsairLightingFirmware::setDeviceID(const DeviceID& deviceID) {\n\tdeviceId = deviceID;\n\tstorage->saveDeviceID(deviceID);\n}\n\nuint8_t CorsairLightingFirmware::getStatus() { return status; }\n\nvoid CorsairLightingFirmware::setStatus(uint8_t a_status) { status = a_status; }\n\nuint8_t CorsairLightingFirmware::getProduct() { return product; }\n"
  },
  {
    "path": "src/CorsairLightingFirmware.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n\n#define FIRMWARE_VERSION_SIZE 3\n\nconst uint8_t corsairLightingNodePROFirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x00, 0x0A, 0x04};\n\n#define corsairLightingNodeCOREFirmwareVersion corsairLightingNodePROFirmwareVersion\n\n#define corsairLS100FirmwareVersion corsairLightingNodePROFirmwareVersion\n\nconst uint8_t corsairCommanderPROFirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x00, 0x09, 0xD4};\n\nconst uint8_t corsairLT100FirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x01, 0x01, 0x38};\n\nconst uint8_t corsairCommanderCOREFirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x02, 0x06, 0xC9};\n\nconst uint8_t* const firmwareVersions[] PROGMEM = {\n\tcorsairLightingNodePROFirmwareVersion, corsairCommanderPROFirmwareVersion, corsairLightingNodeCOREFirmwareVersion,\n\tcorsairLS100FirmwareVersion,           corsairLT100FirmwareVersion,        corsairCommanderCOREFirmwareVersion};\n\nstruct DeviceID {\n\tuint8_t data[4];\n};\n\n/**\n * Interface to store the device id\n */\nclass CorsairLightingFirmwareStorage {\npublic:\n\tvirtual void loadDeviceID(DeviceID& deviceID) const = 0;\n\tvirtual void saveDeviceID(const DeviceID& deviceID) = 0;\n};\n\nclass CorsairLightingFirmware {\npublic:\n\tCorsairLightingFirmware(corsair_product_enum_t product, CorsairLightingFirmwareStorage* storage);\n\tvoid handleFirmwareCommand(const Command& command, const CorsairLightingProtocolResponse* response);\n\tvoid getDeviceID(DeviceID& deviceID) const;\n\tvoid setDeviceID(const DeviceID& deviceID);\n\tuint8_t getStatus();\n\tvoid setStatus(uint8_t status);\n\tuint8_t getProduct();\n\nprotected:\n\tCorsairLightingFirmwareStorage* const storage;\n\tconst corsair_product_enum_t product;\n\tDeviceID deviceId;\n\nprivate:\n\tuint8_t status = PROTOCOL_STATUS_OK;\n};\n"
  },
  {
    "path": "src/CorsairLightingFirmwareStorageEEPROM.cpp",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CorsairLightingFirmwareStorageEEPROM.h\"\n\n#if defined(ARDUINO_ARCH_AVR)\n\n#include <EEPROM.h>\n\nvoid CorsairLightingFirmwareStorageEEPROM::loadDeviceID(DeviceID& deviceID) const {\n\tEEPROM.get(EEPROM_ADDRESS_DEVICE_ID, deviceID);\n}\nvoid CorsairLightingFirmwareStorageEEPROM::saveDeviceID(const DeviceID& deviceID) {\n\tEEPROM.put(EEPROM_ADDRESS_DEVICE_ID, deviceID);\n}\n\n#endif\n"
  },
  {
    "path": "src/CorsairLightingFirmwareStorageEEPROM.h",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#if defined(ARDUINO_ARCH_AVR)\n\n#include \"CorsairLightingFirmware.h\"\n\n#ifndef EEPROM_ADDRESS_DEVICE_ID\n#define EEPROM_ADDRESS_DEVICE_ID 0\n#endif\n\nclass CorsairLightingFirmwareStorageEEPROM : public CorsairLightingFirmwareStorage {\npublic:\n\tvirtual void loadDeviceID(DeviceID& deviceID) const override;\n\tvirtual void saveDeviceID(const DeviceID& deviceID) override;\n};\n\n#endif\n"
  },
  {
    "path": "src/CorsairLightingFirmwareStorageStatic.cpp",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CorsairLightingFirmwareStorageStatic.h\"\n\nCorsairLightingFirmwareStorageStatic::CorsairLightingFirmwareStorageStatic(DeviceID& deviceID) : deviceID(deviceID) {}\n\nvoid CorsairLightingFirmwareStorageStatic::loadDeviceID(DeviceID& deviceID) const { deviceID = this->deviceID; }\nvoid CorsairLightingFirmwareStorageStatic::saveDeviceID(const DeviceID& deviceID) {\n\t// DeviceID can not be updated\n}\n"
  },
  {
    "path": "src/CorsairLightingFirmwareStorageStatic.h",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"CorsairLightingFirmware.h\"\n\nclass CorsairLightingFirmwareStorageStatic : public CorsairLightingFirmwareStorage {\nprivate:\n\tconst DeviceID deviceID;\n\npublic:\n\tCorsairLightingFirmwareStorageStatic(DeviceID& deviceID);\n\tvirtual void loadDeviceID(DeviceID& deviceID) const override;\n\tvirtual void saveDeviceID(const DeviceID& deviceID) override;\n};\n"
  },
  {
    "path": "src/CorsairLightingProtocol.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n/**\n * @file\n * The central include file for CorsairLightingProtocol.\n */\n#include \"CLPAdditionalFeatures.h\"\n#include \"CLPUtils.h\"\n#include \"CorsairLightingFirmware.h\"\n#include \"CorsairLightingFirmwareStorageEEPROM.h\"\n#include \"CorsairLightingFirmwareStorageStatic.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolController.h\"\n#include \"CorsairLightingProtocolHID.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n#include \"CorsairLightingProtocolSerial.h\"\n#include \"CorsairLightingProtocolTinyUSBHID.h\"\n#include \"FanController.h\"\n#include \"FastLEDController.h\"\n#include \"FastLEDControllerStorage.h\"\n#include \"FastLEDControllerStorageEEPROM.h\"\n#include \"FastLEDControllerUtils.h\"\n#include \"IFanController.h\"\n#include \"ILEDController.h\"\n#include \"ITemperatureController.h\"\n#include \"LEDController.h\"\n#include \"TemperatureController.h\"\n"
  },
  {
    "path": "src/CorsairLightingProtocolConstants.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n\n// CLP_DEBUG:      0=Off, 1=Error, 2=Warning, 3=Info, 4=Data\n// CLP_DEBUG_BAUD: Setting too low will severely affect performance depending on debug level;\n//                 2000000 needed when CLP_DEBUG is 4\n#define CLP_DEBUG 0\n#define CLP_DEBUG_PORT Serial1\n#define CLP_DEBUG_BAUD 115200\n\n#define COMMAND_SIZE 64\n#define RESPONSE_SIZE 16\n\n#define READ_STATUS 0x01\n#define READ_FIRMWARE_VERSION 0x02\n#define READ_DEVICE_ID 0x03\n#define WRITE_DEVICE_ID 0x04\n#define START_FIRMWARE_UPDATE 0x05\n#define READ_BOOTLOADER_VERSION 0x06\n#define WRITE_TEST_FLAG 0x07\n\n#define READ_TEMPERATURE_MASK 0x10\n#define READ_TEMPERATURE_VALUE 0x11\n#define READ_VOLTAGE_VALUE 0x12\n\n#define READ_FAN_MASK 0x20\n#define READ_FAN_SPEED 0x21\n#define READ_FAN_POWER 0x22\n#define WRITE_FAN_POWER 0x23\n#define WRITE_FAN_SPEED 0x24\n#define WRITE_FAN_CURVE 0x25\n#define WRITE_FAN_EXTERNAL_TEMP 0x26\n#define WRITE_FAN_FORCE_THREE_PIN_MODE 0x27\n#define WRITE_FAN_DETECTION_TYPE 0x28\n#define READ_FAN_DETECTION_TYPE 0x29\n\n#define READ_LED_STRIP_MASK 0x30\n#define WRITE_LED_RGB_VALUE 0x31\n#define WRITE_LED_COLOR_VALUES 0x32\n#define WRITE_LED_TRIGGER 0x33\n#define WRITE_LED_CLEAR 0x34\n#define WRITE_LED_GROUP_SET 0x35\n#define WRITE_LED_EXTERNAL_TEMP 0x36\n#define WRITE_LED_GROUPS_CLEAR 0x37\n#define WRITE_LED_MODE 0x38\n#define WRITE_LED_BRIGHTNESS 0x39\n#define WRITE_LED_COUNT 0x3A\n#define WRITE_LED_PORT_TYPE 0x3B\n#define WRITE_LED_START_AUTODETECTION 0x3C\n#define READ_LED_AUTODETECTION_RESULTS 0x3D\n\n#define PROTOCOL_RESPONSE_OK 0x00\n#define PROTOCOL_RESPONSE_ERROR 0x01\n#define PROTOCOL_STATUS_OK 0x00\n#define PROTOCOL_STATUS_ERROR 0xFF\n\n#ifndef SERIAL_NUMBER\n#define SERIAL_NUMBER \"FB66DF55421900F5\"\n#endif\n\n#define CORSAIR_MANUFACTURER \"Corsair\"\n#define CORSAIR_VID 0x1B1C\n#define CORSAIR_LNP_PRODUCT \"Lighting Node PRO\"  // Antigua\n#define CORSAIR_LNP_PID 0x0C0B\n#define CORSAIR_CP_PRODUCT \"Commander PRO\"  // Barbuda\n#define CORSAIR_CP_PID 0x0C10\n#define CORSAIR_LNC_PRODUCT \"Lighting Node CORE\"  // Kauai\n#define CORSAIR_LNC_PID 0x0C1A\n#define CORSAIR_SLC_PRODUCT \"Smart Lighting Controller\"  // Borealis\n#define CORSAIR_SLC_PID 0x0C1E\n#define CORSAIR_SLT_PRODUCT \"Smart Lighting Towers\"  // Lightsabers\n#define CORSAIR_SLT_PID 0x0C23\n#define CORSAIR_CC_PRODUCT \"CORSAIR iCUE Commander CORE\"\n#define CORSAIR_CC_PID 0x0C1C\n\n#define QL_FAN_LEDS 34\n#define LL_FAN_LEDS 16\n#define HD_FAN_LEDS 12\n#define EIGHT_LED_FAN_LEDS 8\n#define ML_PRO_FAN_LEDS 4\n\n#define LC100_LEDS 9\n#define LC100_FIRST_LED_OFFSET 3\n\ntypedef enum {\n\tCORSAIR_LIGHTING_NODE_PRO = 0,\n\tCORSAIR_COMMANDER_PRO,\n\tCORSAIR_LIGHTING_NODE_CORE,\n\tCORSAIR_SMART_LIGHTING_CONTROLLER,\n\tCORSAIR_SMART_LIGHTING_TOWERS,\n\tCORSAIR_COMMANDER_CORE  // Currently not functional\n} corsair_product_enum_t;\n\nstruct Command {\n\tunion {\n\t\tstruct {\n\t\t\tuint8_t command;\n\t\t\tuint8_t data[COMMAND_SIZE - 1];\n\t\t};\n\t\tuint8_t raw[COMMAND_SIZE];\n\t};\n};\n"
  },
  {
    "path": "src/CorsairLightingProtocolController.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CorsairLightingProtocolController.h\"\n\n#include \"LEDController.h\"\n\nCorsairLightingProtocolController::CorsairLightingProtocolController(ILEDController* aLEDController,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t CorsairLightingFirmware* corsairLightingFirmware)\n\t: corsairLightingFirmware(corsairLightingFirmware),\n\t  ledController(aLEDController),\n\t  temperatureController(nullptr),\n\t  fanController(nullptr) {}\n\nCorsairLightingProtocolController::CorsairLightingProtocolController(ILEDController* aLEDController,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ITemperatureController* temperatureController,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IFanController* fanController,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t CorsairLightingFirmware* corsairLightingFirmware)\n\t: corsairLightingFirmware(corsairLightingFirmware),\n\t  ledController(aLEDController),\n\t  temperatureController(temperatureController),\n\t  fanController(fanController) {}\n\nvoid CorsairLightingProtocolController::handleCommand(const Command& command,\n\t\t\t\t\t\t\t\t\t\t\t\t\t  CorsairLightingProtocolResponse* response) {\n\tif (command.command < 0x10) {\n\t\tcorsairLightingFirmware->handleFirmwareCommand(command, response);\n\t} else if (command.command >= 0x10 && command.command < 0x20) {\n\t\tif (temperatureController != nullptr) {\n\t\t\ttemperatureController->handleTemperatureControl(command, response);\n\t\t} else {\n\t\t\tresponse->sendError();\n\t\t}\n\t} else if (command.command >= 0x20 && command.command < 0x30) {\n\t\tif (fanController != nullptr) {\n\t\t\tfanController->handleFanControl(command, response);\n\t\t} else {\n\t\t\tresponse->sendError();\n\t\t}\n\t} else if (command.command >= 0x30 && command.command < 0x40) {\n\t\tledController->handleLEDControl(command, response);\n\t} else {\n\t\tresponse->sendError();\n\t}\n}\n\nCorsairLightingFirmware* CorsairLightingProtocolController::getFirmware(void) { return corsairLightingFirmware; }"
  },
  {
    "path": "src/CorsairLightingProtocolController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingFirmware.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n#include \"IFanController.h\"\n#include \"ILEDController.h\"\n#include \"ITemperatureController.h\"\n\n/**\n * The central Controller which integrates all components. The main components of the CorsairLightingProtocolController\n * are the CorsairLightingFirmware and the LEDController. There can also be an optional TemperatureController and\n * FanController which are required if the device should be an Commander PRO.\n */\nclass CorsairLightingProtocolController {\npublic:\n\t/**\n\t * The constructor used to create a Lighting only device.\n\t *\n\t * @param l The LEDController which should be used to control the LEDs of the created Lighting Node PRO\n\t * @param c The CorsairLightingFirmware used to handle Firmware related commands\n\t */\n\tCorsairLightingProtocolController(ILEDController* l, CorsairLightingFirmware* c);\n\t/**\n\t * The constructor used to create a device with lighting, temperature and fan controller functionality (Commander\n\t * PRO).\n\t *\n\t * @param l The LEDController which should be used to control the LEDs of the created Commander PRO\n\t * @param t The TemperatureController which used to messure the temperature of the created Commander PRO\n\t * @param f The FanController used to control the fans of the created Commander PRO\n\t * @param c The CorsairLightingFirmware used to handle Firmware related commands\n\t */\n\tCorsairLightingProtocolController(ILEDController* l, ITemperatureController* t, IFanController* f,\n\t\t\t\t\t\t\t\t\t  CorsairLightingFirmware* c);\n\t/**\n\t * The only public function of the CorsairLightingProtocolController. It must be called to process a command which\n\t * was received from iCUE. This function is normally called by CorsairLightingProtocolHID and\n\t * CorsairLightingProtocolSerial adapters.\n\t *\n\t * @param command The command received from iCUE\n\t * @param response The response callback which can be called to response to the command\n\t */\n\tvoid handleCommand(const Command& command, CorsairLightingProtocolResponse* response);\n\n\tCorsairLightingFirmware* getFirmware(void);\n\nprivate:\n\tCorsairLightingFirmware* const corsairLightingFirmware;\n\tILEDController* const ledController;\n\tITemperatureController* const temperatureController;\n\tIFanController* const fanController;\n};\n"
  },
  {
    "path": "src/CorsairLightingProtocolHID.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CorsairLightingProtocolHID.h\"\n\n#if defined(SUPPORT_RAW_HID)\n\n#if defined(DEBUG) && defined(VERBOSE)\nbool printCommand = PRINT_COMMAND;\nbool printResponse = PRINT_RESPONSE;\n#endif\n\nCorsairLightingProtocolHID::CorsairLightingProtocolHID(CorsairLightingProtocolController* controller)\n\t: controller(controller) {\n\tCLP::RawHID.begin(rawhidData, sizeof(rawhidData));\n}\n\nCorsairLightingProtocolHID::CorsairLightingProtocolHID(CorsairLightingProtocolController* controller,\n\t\t\t\t\t\t\t\t\t\t\t\t\t   const char* serialNumber)\n\t: CorsairLightingProtocolHID(controller) {\n\tCLP::RawHID.setSerialNumber(serialNumber);\n}\n\nvoid CorsairLightingProtocolHID::update() {\n\tif (available()) {\n\t\tCommand command;\n\t\tgetCommand(command);\n\t\tcontroller->handleCommand(command, this);\n\t}\n}\n\nbool CorsairLightingProtocolHID::available() const { return CLP::RawHID.available() > 0; }\n\nvoid CorsairLightingProtocolHID::getCommand(Command& command) {\n\tauto bytesAvailable = CLP::RawHID.available();\n\tif (bytesAvailable) {\n\t\tCLP::RawHID.readBytes(command.raw, sizeof(command.raw));\n#if defined(DEBUG) && defined(VERBOSE)\n\t\tif (printCommand) {\n\t\t\tSerial.print(F(\"Received Command: \"));\n\t\t\tSerial.print(command.command, HEX);\n\t\t\tSerial.print(\" \");\n\t\t\tSerial.println(command.data[0], HEX);\n\t\t}\n#endif\n\t}\n}\n\nvoid CorsairLightingProtocolHID::sendX(const uint8_t* data, const size_t x) const {\n#if defined(DEBUG) && defined(VERBOSE)\n\tif (printResponse) {\n\t\tSerial.print(F(\"Send Response: \"));\n\t\tSerial.println(data[0], HEX);\n\t}\n#endif\n\tCLP::RawHID.write(data, x);\n}\n\n#endif\n"
  },
  {
    "path": "src/CorsairLightingProtocolHID.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolController.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n#include \"RawHID.h\"\n\n#if defined(SUPPORT_RAW_HID)\n\n#if defined(DEBUG) && defined(VERBOSE)\nextern bool printCommand;\nextern bool printResponse;\n#endif\n\n/**\n * The HID Adapter for CorsairLightingProtocolController. This adapter uses the USB HID interface directly to mimic a\n * corsair device. This adapter can only be used when the USB interface is accessable by the sketch.\n */\nclass CorsairLightingProtocolHID : CorsairLightingProtocolResponse {\npublic:\n\t/**\n\t * Create a new adapter for CorsairLightingProtocolController using the default Serial Number.\n\t *\n\t * @param controller the CorsairLightingProtocolController\n\t */\n\tCorsairLightingProtocolHID(CorsairLightingProtocolController* controller);\n\t/**\n\t * Create a new adapter for using the given Serial Number for the usb interface.\n\t *\n\t * @param controller the CorsairLightingProtocolController\n\t * @param serialNumber the Serial Number used for the USB interface\n\t */\n\tCorsairLightingProtocolHID(CorsairLightingProtocolController* controller, const char* serialNumber);\n\t/**\n\t * Read commands form HID interface and pass them to the contoller. This function must be called in loop.\n\t */\n\tvoid update();\n\nprotected:\n\tuint8_t rawhidData[COMMAND_SIZE];\n\tCorsairLightingProtocolController* const controller;\n\n\tbool available() const;\n\tvoid getCommand(Command& command);\n\tvoid sendX(const uint8_t* data, const size_t x) const override;\n};\n\n#endif\n"
  },
  {
    "path": "src/CorsairLightingProtocolResponse.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CorsairLightingProtocolResponse.h\"\n\n#include \"CLPUtils.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n\nvoid CorsairLightingProtocolResponse::send(const uint8_t* data, size_t size) const {\n\tuint8_t response[RESPONSE_SIZE] = {0x00};\n\tif (size + 1 > sizeof(response)) {\n\t\treturn;\n\t}\n\tresponse[0] = PROTOCOL_RESPONSE_OK;\n\tmemcpy(response + 1, data, size);\n\tsendX(response, sizeof(response));\n\tCLP_LOG(3, F(\"Sent response %02X: OK\\r\\n\"), response[0]);\n}\n\nvoid CorsairLightingProtocolResponse::sendError() const {\n\tuint8_t response[RESPONSE_SIZE] = {0x00};\n\tresponse[0] = PROTOCOL_RESPONSE_ERROR;\n\tsendX(response, sizeof(response));\n\tCLP_LOG(3, F(\"Sent response %02X: Error\\r\\n\"), response[0]);\n}\n\nvoid CorsairLightingProtocolResponse::send_P(const uint8_t* data, size_t size) const {\n\tuint8_t response[RESPONSE_SIZE] = {0x00};\n\tif (size + 1 > sizeof(response)) {\n\t\treturn;\n\t}\n\tresponse[0] = PROTOCOL_RESPONSE_OK;\n\tmemcpy_P(response + 1, data, size);\n\tsendX(response, sizeof(response));\n\tCLP_LOG(3, F(\"Sent response %02X: OK\\r\\n\"), response[0]);\n}\n"
  },
  {
    "path": "src/CorsairLightingProtocolResponse.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n\nclass CorsairLightingProtocolResponse {\npublic:\n\t/**\n\t * Send 64 bytes via the CorsairLightingProtocol. All unset bytes will be filled with zeros.\n\t *\n\t * @param data the array with the data\n\t * @param size the length of the array\n\t */\n\tvirtual void send(const uint8_t* data, size_t size) const;\n\t/**\n\t * Send an error.\n\t */\n\tvirtual void sendError() const;\n\t/**\n\t * Send data from program memory.\n\t *\n\t * @param data the array with the data, the pointer must point to program memory\n\t * @param size the length of the array which should be send.\n\t */\n\tvirtual void send_P(const uint8_t* data, size_t size) const;\n\t/**\n\t * Send some bytes data via the CorsairLightingProtocol.\n\t *\n\t * @param data the array with the data\n\t * @param x the length of the array which should be send.\n\t */\n\tvirtual void sendX(const uint8_t* data, const size_t x) const = 0;\n};\n"
  },
  {
    "path": "src/CorsairLightingProtocolSerial.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"CorsairLightingProtocolSerial.h\"\n\nCorsairLightingProtocolSerial::CorsairLightingProtocolSerial(CorsairLightingProtocolController* controller)\n\t: controller(controller) {}\n\nvoid CorsairLightingProtocolSerial::setup() {\n\tSerial.begin(SERIAL_BAUD);\n\tSerial.setTimeout(SERIAL_TIMEOUT);\n}\n\nvoid CorsairLightingProtocolSerial::update() {\n\tbool available = handleSerial();\n\tif (available) {\n\t\tCommand command;\n\t\tmemcpy(command.raw, rawCommand, sizeof(command.raw));\n\t\tcontroller->handleCommand(command, this);\n\t}\n}\n\nbool CorsairLightingProtocolSerial::handleSerial() {\n\tif (Serial.available()) {\n\t\tdelay(SERIAL_TIMEOUT);\n\t\twhile (Serial.available()) {\n\t\t\tSerial.read();\n\t\t}\n\t}\n\n\tSerial.write(42);\n\tSerial.flush();\n\tdelayMicroseconds(100);\n\n\tif (Serial.available()) {\n\t\tsize_t read = Serial.readBytes((char*)rawCommand, sizeof(rawCommand));\n\t\tif (read == sizeof(rawCommand)) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tbyte data[] = {PROTOCOL_RESPONSE_ERROR, (byte)read};\n\t\t\tsendX(data, sizeof(data));\n\t\t}\n\t}\n\treturn false;\n}\n\nvoid CorsairLightingProtocolSerial::sendX(const uint8_t* data, const size_t x) const { Serial.write(data, x); }\n"
  },
  {
    "path": "src/CorsairLightingProtocolSerial.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolController.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n\n// The maximum time in milliseconds needed to receive 64-byte data\n#define SERIAL_TIMEOUT 2\n#define SERIAL_BAUD 1000000\n\n/**\n * The Serial adapter for CorsairLightingProtocolController. This adapter uses a Serial bridge to access\n * the USB interface of another Arduino board. This is usefull for boards that don't have the USB\n * functionality build in.\n */\nclass CorsairLightingProtocolSerial : CorsairLightingProtocolResponse {\npublic:\n\t/**\n\t * Create a new adapter for the controller.\n\t *\n\t * @param controller the CorsairLightingProtocolController\n\t */\n\tCorsairLightingProtocolSerial(CorsairLightingProtocolController* controller);\n\t/**\n\t * Setup the Serial connection.\n\t * This function must be called in setup.\n\t */\n\tvoid setup();\n\t/**\n\t * Read commands from Serial connection and pass them to the controller\n\t * This function must be called in loop.\n\t */\n\tvoid update();\n\nprivate:\n\tbyte rawCommand[COMMAND_SIZE];\n\tCorsairLightingProtocolController* const controller;\n\n\tbool handleSerial();\n\tvoid sendX(const uint8_t* data, const size_t x) const override;\n};\n"
  },
  {
    "path": "src/CorsairLightingProtocolTinyUSBHID.cpp",
    "content": "#include \"CorsairLightingProtocolTinyUSBHID.h\"\n\n#if defined(USE_TINYUSB)\n\nconst char* corsairProducts[] = {CORSAIR_LNP_PRODUCT, CORSAIR_CP_PRODUCT,  CORSAIR_LNC_PRODUCT,\n\t\t\t\t\t\t\t\t CORSAIR_SLC_PRODUCT, CORSAIR_SLT_PRODUCT, CORSAIR_CC_PRODUCT};\nconst int corsairPIDs[] = {CORSAIR_LNP_PID, CORSAIR_CP_PID,  CORSAIR_LNC_PID,\n\t\t\t\t\t\t   CORSAIR_SLC_PID, CORSAIR_SLT_PID, CORSAIR_CC_PID};\n\nCommand CorsairLightingProtocolTinyUSBHID::command;\nint CorsairLightingProtocolTinyUSBHID::newData;\n\n/* clang-format off */\nuint8_t const hid_report[] = {HID_USAGE_PAGE_N (HID_USAGE_PAGE_VENDOR | 0xC0, 2),\n\t\t\t\t\t\t\t  HID_USAGE_N      (0x0C00,                       2),\n\t\t\t\t\t\t\t  HID_COLLECTION   (HID_COLLECTION_APPLICATION     ),\n\t\t\t\t\t\t\t  HID_REPORT_SIZE  (8                              ),\n\t\t\t\t\t\t\t  HID_LOGICAL_MIN  (0x00                           ),\n\t\t\t\t\t\t\t  HID_LOGICAL_MAX_N(0xff,                         2),\n\t\t\t\t\t\t\t  HID_REPORT_COUNT (RESPONSE_SIZE                  ),\n\t\t\t\t\t\t\t  HID_USAGE        (0x01                           ),\n\t\t\t\t\t\t\t  HID_INPUT        (HID_DATA | HID_VARIABLE | HID_ABSOLUTE),\n\t\t\t\t\t\t\t  HID_REPORT_COUNT (COMMAND_SIZE                   ),\n\t\t\t\t\t\t\t  HID_USAGE        (0x02                           ),\n\t\t\t\t\t\t\t  HID_OUTPUT       (HID_DATA | HID_VARIABLE | HID_ABSOLUTE),\n\t\t\t\t\t\t\t  HID_COLLECTION_END};\n/* clang-format on */\n\nAdafruit_USBD_HID tudHid(hid_report, sizeof(hid_report), HID_ITF_PROTOCOL_NONE, 1, true);\n\nuint16_t get_report_callback(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) {\n\t(void)report_id;\n\t(void)report_type;\n\t(void)buffer;\n\t(void)reqlen;\n\n\tCLP_LOG(2, F(\"Get report callback!\\r\\n\"));\n\n\treturn 0;\n}\n\nvoid set_report_callback(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) {\n\t(void)report_id;\n\t(void)report_type;\n\n\tif (bufsize <= sizeof(Command)) {\n\t\tmemcpy(&CorsairLightingProtocolTinyUSBHID::command.raw, buffer, bufsize);\n\t\tCorsairLightingProtocolTinyUSBHID::newData = 1;\n\t\tCLP_LOG(4, F(\"Data received:\\r\\n\"));\n\t\tCLP_LOG_DAT(4, &CorsairLightingProtocolTinyUSBHID::command.raw,\n\t\t\t\t\tsizeof(CorsairLightingProtocolTinyUSBHID::command), true);\n\t} else {\n\t\tCLP_LOG(2, F(\"Command too large\\r\\n\"));\n\t}\n}\n\nCorsairLightingProtocolTinyUSBHID::CorsairLightingProtocolTinyUSBHID(CorsairLightingProtocolController* controller)\n\t: controller(controller), serialNumber(SERIAL_NUMBER) {}\n\nCorsairLightingProtocolTinyUSBHID::CorsairLightingProtocolTinyUSBHID(CorsairLightingProtocolController* controller,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t const char* serialNumber)\n\t: controller(controller), serialNumber(serialNumber) {}\n\nvoid CorsairLightingProtocolTinyUSBHID::setup(void) {\n\tCLP_LOG_FUNC(CLP_DEBUG_PORT.begin(CLP_DEBUG_BAUD));\n\n\tTinyUSBDevice.setManufacturerDescriptor(CORSAIR_MANUFACTURER);\n\tTinyUSBDevice.setProductDescriptor(corsairProducts[controller->getFirmware()->getProduct()]);\n\tTinyUSBDevice.setID(CORSAIR_VID, corsairPIDs[controller->getFirmware()->getProduct()]);\n\tTinyUSBDevice.setSerialDescriptor(serialNumber);\n\n\ttudHid.setReportCallback(get_report_callback, set_report_callback);\n\ttudHid.begin();\n\n\twhile (!TinyUSBDevice.mounted()) delay(1);\n}\n\nvoid CorsairLightingProtocolTinyUSBHID::update(void) {\n\tif (newData) {\n\t\tcontroller->handleCommand(command, this);\n\t\tnewData = 0;\n\t}\n}\n\nvoid CorsairLightingProtocolTinyUSBHID::sendX(const uint8_t* data, const size_t x) const {\n\ttudHid.sendReport(0, data, x);\n\tCLP_LOG(4, F(\"Data sent:\\r\\n\"));\n\tCLP_LOG_DAT(4, data, x, true);\n}\n\n#endif"
  },
  {
    "path": "src/CorsairLightingProtocolTinyUSBHID.h",
    "content": "#pragma once\n\n#include \"CLPUtils.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolController.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n\n#if defined(USE_TINYUSB)\n\n#include \"Adafruit_TinyUSB.h\"\n\nclass CorsairLightingProtocolTinyUSBHID : CorsairLightingProtocolResponse {\npublic:\n\t/**\n\t * Create a new adapter for CorsairLightingProtocolController using the default Serial Number.\n\t *\n\t * @param controller the CorsairLightingProtocolController\n\t */\n\tCorsairLightingProtocolTinyUSBHID(CorsairLightingProtocolController* controller);\n\t/**\n\t * Create a new adapter for CorsairLightingProtocolController using the given Serial Number for the usb interface.\n\t *\n\t * @param controller the CorsairLightingProtocolController\n\t * @param serialNumber the Serial Number used for the USB interface\n\t */\n\tCorsairLightingProtocolTinyUSBHID(CorsairLightingProtocolController* controller, const char* serialNumber);\n\t/**\n\t * Setup the TinyUSB HID connection.\n\t * This function must be called in setup.\n\t */\n\tvoid setup(void);\n\t/**\n\t * Read commands form HID interface and pass them to the contoller. This function must be called in loop.\n\t */\n\tvoid update(void);\n\n\tstatic Command command;\n\n\tstatic int newData;\n\nprotected:\n\tCorsairLightingProtocolController* const controller;\n\tconst char* serialNumber;\n\tvoid sendX(const uint8_t* data, const size_t x) const override;\n};\n\n#endif"
  },
  {
    "path": "src/FanController.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"FanController.h\"\n\n#include \"CLPUtils.h\"\n\nbool isValidFanMask(const FanMask fanMask) {\n\treturn fanMask == FanMask::Disconnected || fanMask == FanMask::ThreePin || fanMask == FanMask::FourPin;\n}\n\nbool isValidFanDetectionType(const FanDetectionType type) {\n\treturn type == FanDetectionType::Auto || type == FanDetectionType::ThreePin || type == FanDetectionType::FourPin ||\n\t\t   type == FanDetectionType::Disconnected;\n}\n\nvoid FanController::handleFanControl(const Command& command, const CorsairLightingProtocolResponse* response) {\n\tCLP_LOG(3, F(\"Received fan command %02X: \"), command.command);\n\tswitch (command.command) {\n\t\tcase READ_FAN_MASK: {\n\t\t\tCLP_LOG(3, F(\"Read mask\\r\\n\"));\n\t\t\tFanMask mask[FAN_NUM];\n\t\t\tfor (uint8_t i = 0; i < FAN_NUM; i++) {\n\t\t\t\tswitch (getFanDetectionType(i)) {\n\t\t\t\t\tcase FanDetectionType::Auto:\n\t\t\t\t\t\tmask[i] = FanMask::Disconnected;  // TODO\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FanDetectionType::ThreePin:\n\t\t\t\t\t\tmask[i] = FanMask::ThreePin;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FanDetectionType::FourPin:\n\t\t\t\t\t\tmask[i] = FanMask::FourPin;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FanDetectionType::Disconnected:\n\t\t\t\t\t\tmask[i] = FanMask::Disconnected;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tresponse->send(reinterpret_cast<byte*>(mask), sizeof(mask));\n\t\t\tbreak;\n\t\t}\n\t\tcase READ_FAN_SPEED: {\n\t\t\tCLP_LOG(3, F(\"Read speed\\r\\n\"));\n\t\t\tconst uint8_t& fan = command.data[0];\n\t\t\tif (fan >= FAN_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan: %d\\r\\n\"), fan);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tuint16_t speed = getFanSpeed(fan);\n\t\t\tuint8_t fanData[] = {toBigEndian(speed)};\n\t\t\tresponse->send(fanData, sizeof(fanData));\n\t\t\tbreak;\n\t\t}\n\t\tcase READ_FAN_POWER: {\n\t\t\tCLP_LOG(3, F(\"Read power\\r\\n\"));\n\t\t\tconst uint8_t& fan = command.data[0];\n\t\t\tif (fan >= FAN_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan: %d\\r\\n\"), fan);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tuint8_t power = getFanPower(fan);\n\t\t\tuint8_t powerData[] = {CLP::convert255To100(power)};\n\t\t\tresponse->send(powerData, sizeof(powerData));\n\t\t\tbreak;\n\t\t}\n\t\tcase WRITE_FAN_POWER: {\n\t\t\tCLP_LOG(3, F(\"Write power\\r\\n\"));\n\t\t\tconst uint8_t& fan = command.data[0];\n\t\t\tif (fan >= FAN_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan: %d\\r\\n\"), fan);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tuint8_t percentage = CLP::convert100To255(command.data[1]);\n\t\t\tsetFanPower(fan, percentage);\n\t\t\tresponse->send(nullptr, 0);\n\t\t\tbreak;\n\t\t}\n\t\tcase WRITE_FAN_SPEED: {\n\t\t\tCLP_LOG(3, F(\"Write speed\\r\\n\"));\n\t\t\tconst uint8_t& fan = command.data[0];\n\t\t\tif (fan >= FAN_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan: %d\\r\\n\"), fan);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tuint16_t speed = CLP::fromBigEndian(command.data[1], command.data[2]);\n\t\t\tsetFanSpeed(fan, speed);\n\t\t\tresponse->send(nullptr, 0);\n\t\t\tbreak;\n\t\t}\n\t\tcase WRITE_FAN_CURVE: {\n\t\t\tCLP_LOG(3, F(\"Write curve\\r\\n\"));\n\t\t\tconst uint8_t& fan = command.data[0];\n\t\t\tif (fan >= FAN_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan: %d\\r\\n\"), fan);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst uint8_t& group = command.data[1];\n\t\t\tFanCurve fanCurve;\n\t\t\tfor (uint8_t i = 0; i < FAN_CURVE_POINTS_NUM; i++) {\n\t\t\t\tfanCurve.temperatures[i] = CLP::fromBigEndian(command.data[2 + i * 2], command.data[3 + i * 2]);\n\t\t\t\tfanCurve.rpms[i] = CLP::fromBigEndian(command.data[14 + i * 2], command.data[15 + i * 2]);\n\t\t\t}\n\t\t\tsetFanCurve(fan, group, fanCurve);\n\t\t\tresponse->send(nullptr, 0);\n\t\t\tbreak;\n\t\t}\n\t\tcase WRITE_FAN_EXTERNAL_TEMP: {\n\t\t\tCLP_LOG(3, F(\"Write external temp\\r\\n\"));\n\t\t\tconst uint8_t& fan = command.data[0];\n\t\t\tif (fan >= FAN_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan: %d\\r\\n\"), fan);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tuint16_t temp = CLP::fromBigEndian(command.data[1], command.data[2]);\n\t\t\tsetFanExternalTemperature(fan, temp);\n\t\t\tresponse->send(nullptr, 0);\n\t\t\tbreak;\n\t\t}\n\t\tcase WRITE_FAN_FORCE_THREE_PIN_MODE: {\n\t\t\tCLP_LOG(3, F(\"Write 3-pin mode\\r\\n\"));\n\t\t\tif (command.data[0] == FAN_FORCE_THREE_PIN_MODE_ON) {\n\t\t\t\tsetFanForce3PinMode(true);\n\t\t\t} else if (command.data[0] == FAN_FORCE_THREE_PIN_MODE_OFF) {\n\t\t\t\tsetFanForce3PinMode(false);\n\t\t\t} else {\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresponse->send(nullptr, 0);\n\t\t\tbreak;\n\t\t}\n\t\tcase WRITE_FAN_DETECTION_TYPE: {\n\t\t\tCLP_LOG(3, F(\"Write detect type\\r\\n\"));\n\t\t\tif (command.data[0] != 0x02) {\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst uint8_t& fan = command.data[1];\n\t\t\tif (fan >= FAN_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan: %d\\r\\n\"), fan);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst FanDetectionType type = static_cast<FanDetectionType>(command.data[2]);\n\t\t\tif (!isValidFanDetectionType(type)) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan detection type: %d\\r\\n\"), type);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetFanDetectionType(fan, type);\n\t\t\tresponse->send(nullptr, 0);\n\t\t\tbreak;\n\t\t}\n\t\tcase READ_FAN_DETECTION_TYPE: {\n\t\t\tCLP_LOG(3, F(\"Read detect type\\r\\n\"));\n\t\t\tif (command.data[0] != 0x01) {\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst uint8_t& fan = command.data[1];\n\t\t\tif (fan >= FAN_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Invalid fan: %d\\r\\n\"), fan);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tFanDetectionType type = getFanDetectionType(fan);\n\t\t\tbyte typeData[] = {static_cast<byte>(type)};\n\t\t\tresponse->send(typeData, sizeof(typeData));\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tCLP_LOG(1, F(\"Unkown command\\r\\n\"));\n\t\t\tresponse->sendError();\n\t\t\treturn;\n\t}\n}\n"
  },
  {
    "path": "src/FanController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n/**\n * @file\n * Defines types and constants of the fan protocol\n */\n\n#include \"Arduino.h\"\n#include \"IFanController.h\"\n\n#define FAN_NUM 6\n\n/**\n * The actual state of a fan port.\n *\n * @see FanDetectionType\n */\nenum class FanMask : byte {\n\t/** No fan connected */\n\tDisconnected = 0x00,\n\t/** A three pin fan is connected */\n\tThreePin = 0x01,\n\t/** A four pin fan is connected */\n\tFourPin = 0x02\n};\n\nbool isValidFanMask(const FanMask fanMask);\n\n/**\n * The virtual state of a fan port.\n *\n * @see FanMask\n */\nenum class FanDetectionType : byte {\n\t/** Auto detect the type of fan which is connected */\n\tAuto = 0x00,\n\t/** A three pin fan is connected */\n\tThreePin = 0x01,\n\t/** A four pin fan is connected */\n\tFourPin = 0x02,\n\t/** No fan connected */\n\tDisconnected = 0x03\n};\n\nbool isValidFanDetectionType(const FanDetectionType type);\n\n#define FAN_FORCE_THREE_PIN_MODE_ON 0x01\n#define FAN_FORCE_THREE_PIN_MODE_OFF 0x00\n\n#define FAN_CURVE_POINTS_NUM 6\n\n#define FAN_CURVE_TEMP_GROUP_EXTERNAL 255\n\n/**\n * The definition of a fan curve to control fan speeds depending on the temperature.\n * The fan curve is a mapping of temperature values to fan speed.\n */\nstruct FanCurve {\n\t/**\n\t * The temperatures in hundredths of a degree Celsius.\n\t */\n\tuint16_t temperatures[FAN_CURVE_POINTS_NUM];\n\t/**\n\t * The fan speeds in RPM.\n\t */\n\tuint16_t rpms[FAN_CURVE_POINTS_NUM];\n};\n\n/**\n * The abstract implementation of IFanController. This implementation handles the parsing and interpretation of incoming\n * commands.\n */\nclass FanController : public IFanController {\npublic:\n\tvirtual void handleFanControl(const Command& command, const CorsairLightingProtocolResponse* response) override;\n\nprotected:\n\t/**\n\t * Get the fan speed.\n\t *\n\t * @param fan index of the fan\n\t * @return fan speed in RPM.\n\t */\n\tvirtual uint16_t getFanSpeed(uint8_t fan) = 0;\n\t/**\n\t * Set the fan speed to a fixed value.\n\t *\n\t * @param fan index of the fan\n\t * @param speed fan speed in RPM.\n\t */\n\tvirtual void setFanSpeed(uint8_t fan, uint16_t speed) = 0;\n\t/**\n\t * Get the power percentage of a fan.\n\t *\n\t * @param fan index of the fan\n\t * @return power percentage, in range 0-255 with 255 mean 100%.\n\t */\n\tvirtual uint8_t getFanPower(uint8_t fan) = 0;\n\t/**\n\t * @param fan index of the fan\n\t * @param percentage 255 mean 100%.\n\t */\n\tvirtual void setFanPower(uint8_t fan, uint8_t percentage) = 0;\n\t/**\n\t * Set a FanCure for a fan.\n\t *\n\t * @param fan index of the fan\n\t * @param group the temperature group used for getting the temperature for this fan\n\t * @param fanCurve the fan curve data\n\t */\n\tvirtual void setFanCurve(uint8_t fan, uint8_t group, FanCurve& fanCurve) = 0;\n\t/**\n\t * Set the external temperature for a fan. The external temperature is provied by the iCUE.\n\t *\n\t * @param fan index of the fan\n\t * @param temp The temperature in hundredths of a degree Celsius.\n\t */\n\tvirtual void setFanExternalTemperature(uint8_t fan, uint16_t temp) = 0;\n\t/**\n\t * TODO not sure what this does, currently unused\n\t *\n\t * @param flag the value\n\t */\n\tvirtual void setFanForce3PinMode(bool flag) = 0;\n\t/**\n\t * Get the fan DetectionType for a fan.\n\t *\n\t * @param fan index of the fan\n\t * @return the FanDetectionType\n\t */\n\tvirtual FanDetectionType getFanDetectionType(uint8_t fan) = 0;\n\t/**\n\t * Set the fan DetectionType for a fan.\n\t *\n\t * @param fan index of the fan\n\t * @param type the FanDetectionType\n\t */\n\tvirtual void setFanDetectionType(uint8_t fan, FanDetectionType type) = 0;\n};\n"
  },
  {
    "path": "src/FastLEDController.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"FastLEDController.h\"\n\nFastLEDController::FastLEDController(FastLEDControllerStorage* storage)\n\t: temperatureController(nullptr), storage(storage) {\n\tload();\n}\n\nFastLEDController::FastLEDController(TemperatureController* temperatureController, FastLEDControllerStorage* storage)\n\t: temperatureController(temperatureController), storage(storage) {\n\tload();\n}\n\nFastLEDController::~FastLEDController() {\n\tfor (auto& data : channelData) {\n\t\tfor (uint8_t*& buffer : data.valuesBuffer) {\n\t\t\tdelete[] buffer;\n\t\t}\n\t}\n}\n\nvoid FastLEDController::addLEDs(uint8_t channel, CRGB* leds, uint8_t count) {\n\tif (channel >= CHANNEL_NUM || leds == nullptr || channelData[channel].leds != nullptr) {\n\t\treturn;\n\t}\n\tchannelData[channel].ledCount = count;\n\tchannelData[channel].leds = leds;\n\tfor (uint8_t*& buffer : channelData[channel].valuesBuffer) {\n\t\tbuffer = new uint8_t[count];\n\t}\n}\n\nCRGB* FastLEDController::getLEDs(uint8_t channel) {\n\tif (channel >= CHANNEL_NUM) {\n\t\treturn nullptr;\n\t}\n\treturn channelData[channel].leds;\n}\n\nuint8_t FastLEDController::getLEDCount(uint8_t channel) {\n\tif (channel >= CHANNEL_NUM) {\n\t\treturn 0;\n\t}\n\treturn channelData[channel].ledCount;\n}\n\nint FastLEDController::applySpeed(int duration, const GroupSpeed speed) {\n\tswitch (speed) {\n\t\tcase GroupSpeed::High:\n\t\t\treturn duration / 2;\n\t\tcase GroupSpeed::Medium:\n\t\t\treturn duration;\n\t\tcase GroupSpeed::Low:\n\t\t\treturn duration * 2;\n\t\tdefault:\n\t\t\treturn duration;\n\t}\n}\n\nint FastLEDController::animation_step(int duration, int steps) {\n\tint currentStep = ((currentUpdate % (unsigned int)duration) / ((float)duration)) * steps;\n\treturn currentStep;\n}\n\nint FastLEDController::animation_step_count(int duration, int steps) {\n\tunsigned long lastAnimationNumber = lastUpdate / (unsigned int)duration;\n\tunsigned long currentAnimationNumber = currentUpdate / (unsigned int)duration;\n\tint lastStep = ((lastUpdate % (unsigned int)duration) / ((float)duration)) * steps;\n\tint currentStep = ((currentUpdate % (unsigned int)duration) / ((float)duration)) * steps;\n\n\treturn currentStep - lastStep + (currentAnimationNumber - lastAnimationNumber) * steps;\n}\n\nCRGB FastLEDController::randomColor() { return ColorFromPalette(RainbowColors_p, random8(), 255, NOBLEND); }\n\nbool FastLEDController::renderRainbowWave(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(3300, group.speed);\n\tint count = animation_step_count(duration, 256);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, 256);\n\t\tint move = group.direction == GroupDirection::Forward ? -3 : 3;\n\t\tfor (int i = 0; i < groupLedCount; i++) {\n\t\t\tchannelData.leds[group.ledIndex + i] = CHSV(step + (i * move), 255, 255);\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderColorShift(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(3000, group.speed);\n\tint count = animation_step_count(duration, 512);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, 512);\n\t\tif (count > step) {\n\t\t\tif (group.extra == GroupExtra::Random) {\n\t\t\t\tgroup.color1 = group.color2;\n\t\t\t\tgroup.color2 = randomColor();\n\t\t\t} else if (group.extra == GroupExtra::Alternating) {\n\t\t\t\tgroup.color3 = group.color1;\n\t\t\t\tgroup.color1 = group.color2;\n\t\t\t\tgroup.color2 = group.color3;\n\t\t\t}\n\t\t}\n\t\tuint8_t scale;\n\t\tif (step < 128) {\n\t\t\tscale = 0;\n\t\t} else if (step < 384) {\n\t\t\tscale = ease8InOutApprox(step - 128);\n\t\t} else {\n\t\t\tscale = 255;\n\t\t}\n\n\t\tfill_solid(&channelData.leds[group.ledIndex], groupLedCount, group.color1.lerp8(group.color2, scale));\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderColorPulse(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(3000, group.speed);\n\tint count = animation_step_count(duration, 512);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, 512);\n\t\tif (count > step) {\n\t\t\tif (group.extra == GroupExtra::Random) {\n\t\t\t\tgroup.color1 = randomColor();\n\t\t\t} else if (group.extra == GroupExtra::Alternating) {\n\t\t\t\tgroup.color3 = group.color1;\n\t\t\t\tgroup.color1 = group.color2;\n\t\t\t\tgroup.color2 = group.color3;\n\t\t\t}\n\t\t}\n\t\tuint8_t scale = ease8InOutApprox((uint8_t)step);\n\t\tif (step >= 256) {\n\t\t\tscale = 255 - scale;\n\t\t}\n\n\t\tfill_solid(&channelData.leds[group.ledIndex], groupLedCount, group.color1 % scale);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderColorWave(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(3000, group.speed);\n\tint count = animation_step_count(duration, 10000);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, 10000);\n\t\tif (count > step) {\n\t\t\tif (group.extra == GroupExtra::Random) {\n\t\t\t\tgroup.color1 = group.color2;\n\t\t\t\tgroup.color2 = randomColor();\n\t\t\t} else if (group.extra == GroupExtra::Alternating) {\n\t\t\t\tgroup.color3 = group.color1;\n\t\t\t\tgroup.color1 = group.color2;\n\t\t\t\tgroup.color2 = group.color3;\n\t\t\t}\n\t\t}\n\t\tfloat valley = step / 10000.0;\n\t\tfor (int i = 0; i < groupLedCount; i++) {\n\t\t\tfloat pos = (i % 17) / 17.0;\n\n\t\t\tfloat distanceWave;\n\t\t\tCRGB color;\n\t\t\tconst bool flag = (i % 34) < 17;\n\t\t\tif (pos < valley) {\n\t\t\t\tcolor = flag ? group.color1 : group.color2;\n\t\t\t\tdistanceWave = abs(valley - 0.5 - pos);\n\t\t\t} else {\n\t\t\t\tcolor = flag ? group.color2 : group.color1;\n\t\t\t\tdistanceWave = abs(valley + 0.5 - pos);\n\t\t\t}\n\n\t\t\tuint8_t scale;\n\t\t\tif (distanceWave > 0.25) {\n\t\t\t\tscale = 0;\n\t\t\t} else {\n\t\t\t\tscale = 255 - ease8InOutApprox((distanceWave * 4) * 256);\n\t\t\t}\n\t\t\tchannelData.leds[group.ledIndex + i] = (color % scale);\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderStatic(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(100, group.speed);\n\tint count = animation_step_count(duration, 1);\n\tif (count > 0) {\n\t\tfill_solid(&channelData.leds[group.ledIndex], groupLedCount, group.color1);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderTemperature(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tuint16_t currentTemperature;\n\tconst uint8_t& tempGroup = group.tempGroup;\n\tif (tempGroup == GROUP_TEMP_GROUP_EXTERNAL) {\n\t\tcurrentTemperature = channelData.temp;\n\t} else if (tempGroup < TEMPERATURE_NUM && temperatureController != nullptr) {\n\t\tcurrentTemperature = temperatureController->getTemperature(tempGroup);\n\t} else {\n\t\treturn false;\n\t}\n\n\tCRGB color;\n\tif (currentTemperature < group.temp1) {\n\t\tcolor = group.color1;\n\t} else if (currentTemperature < group.temp2) {\n\t\tcolor = group.color1.lerp16(\n\t\t\tgroup.color2, ((currentTemperature - group.temp1) / ((float)(group.temp2 - group.temp1))) * 65535);\n\t} else if (currentTemperature < group.temp3) {\n\t\tcolor = group.color2.lerp16(\n\t\t\tgroup.color3, ((currentTemperature - group.temp2) / ((float)(group.temp3 - group.temp2))) * 65535);\n\t} else {\n\t\tcolor = group.color3;\n\t}\n\n\tfill_solid(&channelData.leds[group.ledIndex], groupLedCount, color);\n\treturn true;\n}\n\nbool FastLEDController::renderVisor(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(120 * groupLedCount, group.speed);\n\tconst int resolution = 64;\n\tint steps = groupLedCount * 2 * resolution;\n\tint count = animation_step_count(duration, steps);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, steps);\n\t\tif (step >= steps / 2 ? count > step - steps / 2 : count > step) {\n\t\t\tif (group.extra == GroupExtra::Random) {\n\t\t\t\tgroup.color1 = randomColor();\n\t\t\t\tgroup.color2 = randomColor();\n\t\t\t} else if (group.extra == GroupExtra::Alternating) {\n\t\t\t\tauto temp = group.color1;\n\t\t\t\tgroup.color1 = group.color2;\n\t\t\t\tgroup.color2 = temp;\n\t\t\t}\n\t\t}\n\t\tconst float gradientLength = 3.0f;\n\t\tfloat pos = step / (float)resolution;\n\t\tfloat gradientMiddlePosition = (pos >= groupLedCount) ? (groupLedCount * 2) - pos : pos;\n\t\tgradientMiddlePosition -= 0.5f;\n\t\tconst float gradientStartPosition = gradientMiddlePosition - (gradientLength / 2);\n\t\tconst float gradientEndPosition = gradientMiddlePosition + (gradientLength / 2);\n\t\tfor (int i = 0; i < groupLedCount; i++) {\n\t\t\tCRGB color = CRGB::Black;\n\t\t\tif (i >= gradientStartPosition - 1 && i < gradientStartPosition) {\n\t\t\t\tcolor = group.color1;\n\t\t\t\tcolor.nscale8((i - (gradientStartPosition - 1)) * 256.0);\n\t\t\t} else if (i >= gradientStartPosition && i < gradientEndPosition) {\n\t\t\t\tcolor = blend(group.color1, group.color2, ((i - gradientStartPosition) / gradientLength) * 256);\n\t\t\t} else if (i >= gradientEndPosition && i < gradientEndPosition + 1) {\n\t\t\t\tcolor = group.color2;\n\t\t\t\tcolor.nscale8((1 - (i - gradientEndPosition)) * 256.0);\n\t\t\t}\n\t\t\tchannelData.leds[group.ledIndex + i] = color;\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderMarquee(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(700, group.speed);\n\tint count = animation_step_count(duration, 3);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, 3);\n\t\tfor (int i = 0; i < groupLedCount; i++) {\n\t\t\tchannelData.leds[group.ledIndex + i] = (i + step) % 3 > 0 ? group.color1 : CRGB::Black;\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderBlink(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(3000, group.speed);\n\tint count = animation_step_count(duration, 2);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, 2);\n\t\tif (count > step) {\n\t\t\tif (group.extra == GroupExtra::Random) {\n\t\t\t\tgroup.color1 = randomColor();\n\t\t\t} else if (group.extra == GroupExtra::Alternating) {\n\t\t\t\tgroup.color3 = group.color1;\n\t\t\t\tgroup.color1 = group.color2;\n\t\t\t\tgroup.color2 = group.color3;\n\t\t\t}\n\t\t}\n\n\t\tfill_solid(&channelData.leds[group.ledIndex], groupLedCount, step == 0 ? group.color1 : CRGB::Black);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderSequential(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint steps = groupLedCount;\n\tint duration = applySpeed(60 * steps, group.speed);\n\tint count = animation_step_count(duration, steps);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, steps);\n\t\tif (count > step) {\n\t\t\tif (group.extra == GroupExtra::Random) {\n\t\t\t\tgroup.color2 = group.color1;\n\t\t\t\tgroup.color1 = randomColor();\n\t\t\t}\n\t\t}\n\n\t\tif (group.direction == GroupDirection::Forward) {\n\t\t\tfill_solid(&channelData.leds[group.ledIndex + groupLedCount - (step + 1)], step + 1, group.color1);\n\t\t\tfill_solid(&channelData.leds[group.ledIndex], groupLedCount - (step + 1), group.color2);\n\t\t} else {\n\t\t\tfill_solid(&channelData.leds[group.ledIndex], step + 1, group.color1);\n\t\t\tfill_solid(&channelData.leds[group.ledIndex + step + 1], groupLedCount - (step + 1), group.color2);\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::renderRainbow(ChannelData& channelData, LEDGroup& group, int groupLedCount) {\n\tint duration = applySpeed(3000, group.speed);\n\tint count = animation_step_count(duration, 256);\n\tif (count > 0) {\n\t\tint step = animation_step(duration, 256);\n\t\tfill_solid(&channelData.leds[group.ledIndex], groupLedCount, CHSV(step, 255, 255));\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool FastLEDController::updateLEDs() {\n\tlastUpdate = currentUpdate;\n\tcurrentUpdate = millis();\n\tif (currentUpdate - lastCommand > LED_CONTROLLER_TIMEOUT) {\n\t\ttimeoutAction();\n\t}\n\n\tbool anyUpdate = false;\n\n\tfor (int channelId = 0; channelId < CHANNEL_NUM; channelId++) {\n\t\tif (channelData[channelId].leds == nullptr) {\n\t\t\tcontinue;\n\t\t}\n\t\tbool updated = false;\n\t\tLEDChannel& channel = channels[channelId];\n\n\t\tswitch (channel.mode) {\n\t\t\tcase ChannelMode::Disabled: {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChannelMode::HardwarePlayback: {\n\t\t\t\tfor (uint8_t groupIndex = 0; groupIndex < channel.groupsSet; groupIndex++) {\n\t\t\t\t\tLEDGroup& group = channel.groups[groupIndex];\n\t\t\t\t\tint groupLedCount = min((int)channelData[channelId].ledCount - group.ledIndex, (int)group.ledCount);\n\t\t\t\t\tif (groupLedCount <= 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tbool groupUpdated = false;\n\n\t\t\t\t\tswitch (group.mode) {\n\t\t\t\t\t\tcase GROUP_MODE_Rainbow_Wave: {\n\t\t\t\t\t\t\tgroupUpdated = renderRainbowWave(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Color_Shift: {\n\t\t\t\t\t\t\tgroupUpdated = renderColorShift(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Color_Pulse: {\n\t\t\t\t\t\t\tgroupUpdated = renderColorPulse(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Color_Wave: {\n\t\t\t\t\t\t\tgroupUpdated = renderColorWave(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Static: {\n\t\t\t\t\t\t\tgroupUpdated = renderStatic(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Temperature: {\n\t\t\t\t\t\t\tgroupUpdated = renderTemperature(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Visor: {\n\t\t\t\t\t\t\tgroupUpdated = renderVisor(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Marquee: {\n\t\t\t\t\t\t\tgroupUpdated = renderMarquee(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Blink: {\n\t\t\t\t\t\t\tgroupUpdated = renderBlink(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Sequential: {\n\t\t\t\t\t\t\tgroupUpdated = renderSequential(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase GROUP_MODE_Rainbow: {\n\t\t\t\t\t\t\tgroupUpdated = renderRainbow(channelData[channelId], group, groupLedCount);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tCLP_LOG(3, F(\"Unkown group mode: %02X\\r\\n\"), group.mode);\n#ifdef DEBUG\n\t\t\t\t\t\t\tSerial.print(F(\"unkown group mode: \"));\n\t\t\t\t\t\t\tSerial.print(group.mode, HEX);\n\t\t\t\t\t\t\tSerial.println();\n#endif\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (groupUpdated) {\n\t\t\t\t\t\tnscale8_video(&channelData[channelId].leds[group.ledIndex], groupLedCount, channel.brightness);\n\t\t\t\t\t\tupdated = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChannelMode::SoftwarePlayback: {\n\t\t\t\tif (trigger_update) {\n\t\t\t\t\tauto& data = channelData[channelId];\n\t\t\t\t\tfor (int i = 0; i < data.ledCount; i++) {\n\t\t\t\t\t\tdata.leds[i] = CRGB(data.valuesBuffer[0][i], data.valuesBuffer[1][i], data.valuesBuffer[2][i]);\n\t\t\t\t\t}\n\t\t\t\t\tupdated = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (updated) {\n\t\t\tanyUpdate = true;\n\t\t\tif (channelData[channelId].onUpdateCallback != nullptr) {\n\t\t\t\tchannelData[channelId].onUpdateCallback();\n\t\t\t}\n\t\t}\n\t}\n\ttrigger_update = false;\n\treturn anyUpdate;\n}\n\nvoid FastLEDController::onUpdateHook(uint8_t channel, void (*callback)(void)) {\n\tchannelData[channel].onUpdateCallback = callback;\n}\n\nbool FastLEDController::load() {\n\tif (storage == nullptr) {\n\t\treturn false;\n\t}\n\n\tfor (int i = 0; i < CHANNEL_NUM; i++) {\n\t\tstorage->load(i, channels[i]);\n\t}\n\n\tfor (LEDChannel& channel : channels) {\n\t\tif (!isValidLEDChannel(channel)) {\n\t\t\tchannel = LEDChannel();\n\t\t}\n\t}\n\treturn true;\n}\n\nbool FastLEDController::save() {\n\tif (storage == nullptr) {\n\t\treturn false;\n\t}\n\n\tfor (int i = 0; i < CHANNEL_NUM; i++) {\n\t\tstorage->save(i, channels[i]);\n\t}\n\treturn true;\n}\n\nvoid FastLEDController::triggerLEDUpdate() { trigger_update = true; }\n\nvoid FastLEDController::setLEDExternalTemperature(uint8_t channel, uint16_t temp) { channelData[channel].temp = temp; }\n\nvoid FastLEDController::setLEDColorValues(uint8_t channel, uint8_t color, uint8_t offset, const uint8_t* values,\n\t\t\t\t\t\t\t\t\t\t  size_t len) {\n\tint copyLength = min((int)channelData[channel].ledCount - offset, (int)len);\n\tif (copyLength > 0) {\n\t\tmemcpy(channelData[channel].valuesBuffer[color] + offset, values, copyLength);\n\t}\n}\n\nvoid FastLEDController::clearLEDColorValues(uint8_t channel) {\n\tfor (uint8_t*& buffer : channelData[channel].valuesBuffer) {\n\t\tmemset(buffer, 0, channelData[channel].ledCount);\n\t}\n}\n\nuint8_t FastLEDController::getLEDAutodetectionResult(uint8_t channel) { return channelData[channel].ledCount; }\n\nvoid FastLEDController::timeoutAction() {\n\tfor (int channelId = 0; channelId < CHANNEL_NUM; channelId++) {\n\t\ttriggerSave |= setLEDMode(channelId, ChannelMode::HardwarePlayback);\n\t}\n\tsaveIfNeeded();\n}\n"
  },
  {
    "path": "src/FastLEDController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include <FastLED.h>\n\n#include \"Arduino.h\"\n#include \"FastLEDControllerStorage.h\"\n#include \"LEDController.h\"\n#include \"TemperatureController.h\"\n\n#ifndef LED_CONTROLLER_TIMEOUT\n#define LED_CONTROLLER_TIMEOUT 30000\n#endif\n\n/**\n * The default LEDController. This controller uses the FastLED library to implement the Hardware Lighting effects. Also\n * all RGB values of the LEDs are stored into CRGB arrays which can be used by the FastLED library to show them on the\n * real LED strips. This controller can stores the internal state to EEPROM and support HW playback without USB\n * connection.\n *\n * @see FastLED\n */\nclass FastLEDController : public LEDController {\n\t/**\n\t * Internal data stored for each Channel. These data are not persistent.\n\t */\n\tstruct ChannelData {\n\t\tuint8_t ledCount = 0;\n\t\tCRGB* leds = nullptr;\n\t\t/**\n\t\t * store an array for each color, used for software playback\n\t\t */\n\t\tuint8_t* valuesBuffer[3] = {nullptr};\n\t\t/**\n\t\t * External temperature value used by this channel for temperature based lighting.\n\t\t */\n\t\tuint16_t temp;\n\t\tvoid (*onUpdateCallback)(void) = nullptr;\n\t};\n\npublic:\n\t/**\n\t * Create a new FastLEDController and specify which storage should be used. The EEPROM of the Arduino can be used as\n\t * Storage. See the other contructor for more details.\n\t *\n\t * @param storage specify the storage which should be used, e.g. EEPROM\n\t */\n\tFastLEDController(FastLEDControllerStorage* storage);\n\t/**\n\t * Create a new FastLEDController and specify which storage should be used. If the EEPROM of the Arduino should be\n\t * used to store persistent information like the Hardware Lighting use {@code FastLEDControllerStorageEEPROM}. If\n\t * enabled, the hardware lighting configured in iCUE works without a USB connection and even after a restart of the\n\t * Arduino. Also the the TemperatureController used for temperature related lighting can be passed here.\n\t *\n\t * @param temperatureController used for temperature based lighting\n\t * @param storage specify the storage which should be used, e.g. EEPROM\n\t */\n\tFastLEDController(TemperatureController* temperatureController, FastLEDControllerStorage* storage);\n\t~FastLEDController();\n\t/**\n\t * Add a LED array on a channel with a given length. The length define how many LEDs iCUE can control. The actual\n\t * length of the array can be longer, but iCUE only writes up to the specified length.\n\t *\n\t * @param channel the index of the channel\n\t * @param leds the array to store the LED data in\n\t * @param length the length of the array used by iCUE to write LED data\n\t */\n\tvirtual void addLEDs(uint8_t channel, CRGB* leds, uint8_t length);\n\t/**\n\t * Get the LED data array for a channel.\n\t *\n\t * @param channel the index of the channel\n\t * @return the pointer to the LED array or nullptr if there is no array\n\t * @see getLEDCount()\n\t */\n\tCRGB* getLEDs(uint8_t channel);\n\t/**\n\t * Get the length of the LED data array.\n\t *\n\t * @param channel the index of the channel\n\t * @return the length of the array\n\t * @see getLEDs()\n\t */\n\tuint8_t getLEDCount(uint8_t channel);\n\t/**\n\t * Update the displayed RGB values for the LEDs. This will write to the LED data array of each Channel.\n\t * This method does not call {@code FastLED.show()}. This function must be called in loop.\n\t *\n\t * @return true if the LED data of a channel was updated, false otherwise\n\t */\n\tvirtual bool updateLEDs();\n\t/**\n\t * Register an update hook, which is executed after a channel has been updated. This can be used to apply\n\t * transforamtions to the channel before the data is displayed by FastLED.\n\t *\n\t * @param channel the channel for which the hook is registered\n\t * @param callback the callback, which is executed after the update\n\t */\n\tvoid onUpdateHook(uint8_t channel, void (*callback)(void));\n\nprotected:\n\tTemperatureController* const temperatureController;\n\tFastLEDControllerStorage* const storage;\n\n\tbool trigger_update = false;\n\n\tChannelData channelData[CHANNEL_NUM];\n\n\tunsigned long lastUpdate = 0;\n\tunsigned long currentUpdate = 0;\n\n\tint applySpeed(int duration, const GroupSpeed speed);\n\t/**\n\t * Calculates the index of the current step of the animation.\n\t *\n\t * @param duration the duration on the animation\n\t * @param steps the number of steps of the animation\n\t * @return the current step of the animation\n\t */\n\tint animation_step(int duration, int steps);\n\t/**\n\t * Calculates the number of steps of the animation, since the last update of the animation.\n\t *\n\t * @param duration the duration on the animation\n\t * @param steps the number of steps of the animation\n\t * @return the number of steps since the last update\n\t */\n\tint animation_step_count(int duration, int steps);\n\n\t/**\n\t * Generate a rainbow random color from predefined color palette.\n\t *\n\t * @return a random color\n\t */\n\tCRGB randomColor();\n\n\tbool renderRainbowWave(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderColorShift(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderColorPulse(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderColorWave(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderStatic(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderTemperature(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderVisor(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderMarquee(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderBlink(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderSequential(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\tbool renderRainbow(ChannelData& channelData, LEDGroup& group, int groupLedCount);\n\n\tbool load() override;\n\tbool save() override;\n\n\tvirtual void triggerLEDUpdate() override;\n\tvirtual void setLEDExternalTemperature(uint8_t channel, uint16_t temp) override;\n\tvirtual void setLEDColorValues(uint8_t channel, uint8_t color, uint8_t offset, const uint8_t* values,\n\t\t\t\t\t\t\t\t   size_t len) override;\n\tvirtual void clearLEDColorValues(uint8_t channel) override;\n\tvirtual uint8_t getLEDAutodetectionResult(uint8_t channel) override;\n\t/**\n\t * This function is called when a timeout occurs.\n\t */\n\tvirtual void timeoutAction();\n};\n"
  },
  {
    "path": "src/FastLEDControllerStorage.h",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"LEDController.h\"\n\nclass FastLEDControllerStorage {\npublic:\n\tvirtual bool load(const int index, LEDChannel& channel) = 0;\n\tvirtual bool save(const int index, const LEDChannel& channel) = 0;\n};\n"
  },
  {
    "path": "src/FastLEDControllerStorageEEPROM.cpp",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"FastLEDControllerStorageEEPROM.h\"\n\n#if defined(ARDUINO_ARCH_AVR)\n\n#include <EEPROM.h>\n\nbool FastLEDControllerStorageEEPROM::load(const int index, LEDChannel& channel) {\n\tEEPROM.get(EEPROM_ADDRESS + (sizeof(LEDChannel) * index), channel);\n\treturn true;\n}\n\nbool FastLEDControllerStorageEEPROM::save(const int index, const LEDChannel& channel) {\n\tCLP_LOG(3, F(\"Save to EEPROM.\\r\\n\"));\n#ifdef DEBUG\n\tSerial.println(F(\"Save to EEPROM.\"));\n#endif\n\tEEPROM.put(EEPROM_ADDRESS + (sizeof(LEDChannel) * index), channel);\n\treturn true;\n}\n\nsize_t FastLEDControllerStorageEEPROM::getEEPROMSize() { return sizeof(LEDChannel) * CHANNEL_NUM; }\n\n#endif\n"
  },
  {
    "path": "src/FastLEDControllerStorageEEPROM.h",
    "content": "/*\n   Copyright 2021 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#if defined(ARDUINO_ARCH_AVR)\n\n#include \"FastLEDControllerStorage.h\"\n\n#ifndef EEPROM_ADDRESS\n#define EEPROM_ADDRESS 4\n#endif\n\nclass FastLEDControllerStorageEEPROM : public FastLEDControllerStorage {\npublic:\n\tvirtual bool load(const int index, LEDChannel& channel) override;\n\tvirtual bool save(const int index, const LEDChannel& channel) override;\n\t/**\n\t * Get the total size of all data stored in EEPROM by this LEDController.\n\t *\n\t * @return the size in bytes\n\t */\n\tvirtual size_t getEEPROMSize();\n};\n\n#endif\n"
  },
  {
    "path": "src/FastLEDControllerUtils.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"FastLEDControllerUtils.h\"\n\n#include <FastLED.h>\n#include <math.h>\n\n#include \"CLPUtils.h\"\n\nvoid CLP::transformLLFanToStrip(FastLEDController* controller, uint8_t channelIndex) {\n\tauto& channel = controller->getChannel(channelIndex);\n\tif (channel.mode == ChannelMode::SoftwarePlayback) {\n\t\tauto leds = controller->getLEDs(channelIndex);\n\t\tauto count = controller->getLEDCount(channelIndex);\n\t\tfor (uint8_t fanIndex = 0; fanIndex < count / LL_FAN_LEDS; fanIndex++) {\n\t\t\tCLP::reverse(&leds[fanIndex * LL_FAN_LEDS], &leds[fanIndex * LL_FAN_LEDS + LL_FAN_LEDS - 1] + 1);\n\t\t}\n\t}\n}\n\nvoid CLP::transformLC100ToStrip(FastLEDController* controller, uint8_t channelIndex) {\n\tauto& channel = controller->getChannel(channelIndex);\n\tif (channel.mode == ChannelMode::SoftwarePlayback) {\n\t\tauto leds = controller->getLEDs(channelIndex);\n\t\tauto count = controller->getLEDCount(channelIndex);\n\t\tfor (uint8_t lc100Index = 0; lc100Index < count / LC100_LEDS; lc100Index++) {\n\t\t\tCLP::rotate(&leds[lc100Index * LC100_LEDS], &leds[lc100Index * LC100_LEDS + LC100_FIRST_LED_OFFSET],\n\t\t\t\t\t\t&leds[lc100Index * LC100_LEDS + LC100_LEDS - 1] + 1);  //  End address after the last element\n\t\t}\n\t}\n}\n\n/**\n * @param index the index which should be scaled\n * @param scaleFactor the factor for the scaling\n * @return the scaled index\n */\ninline int scaleIndex(const int index, const float scaleFactor) { return round(index * scaleFactor); }\n\nfloat scaleFactorOf(const int numberLEDsBefore, const int numberLEDsAfter) {\n\treturn (float)(numberLEDsBefore - 1) / (numberLEDsAfter - 1);\n}\n\nvoid CLP::scale(FastLEDController* controller, uint8_t channelIndex, int scaleToSize) {\n\tauto leds = controller->getLEDs(channelIndex);\n\tconst float scaleFactor = scaleFactorOf(controller->getLEDCount(channelIndex), scaleToSize);\n\tif (scaleFactor < 1.0f) {\n\t\tfor (int ledIndex = scaleToSize - 1; ledIndex >= 0; ledIndex--) {\n\t\t\tleds[ledIndex] = leds[scaleIndex(ledIndex, scaleFactor)];\n\t\t}\n\t} else {\n\t\tfor (int ledIndex = 0; ledIndex < scaleToSize; ledIndex++) {\n\t\t\tleds[ledIndex] = leds[scaleIndex(ledIndex, scaleFactor)];\n\t\t}\n\t}\n}\n\nvoid CLP::repeat(FastLEDController* controller, uint8_t channelIndex, uint8_t times) {\n\tauto leds = controller->getLEDs(channelIndex);\n\tauto count = controller->getLEDCount(channelIndex);\n\t// skip first iteration, because LEDs already contains the data at the first position\n\tfor (int i = 1; i < times; i++) {\n\t\tmemcpy(leds + (count * i), leds, sizeof(CRGB) * count);\n\t}\n}\n\nvoid CLP::scaleSegments(FastLEDController* controller, uint8_t channelIndex, const SegmentScaling* const segments,\n\t\t\t\t\t\tint segmentsCount) {\n\tauto leds = controller->getLEDs(channelIndex);\n\tint ledStripIndexAfterScaling = 0;\n\tint ledStripIndexBeforeScaling = 0;\n\tint totalLengthAfterScaling = 0;\n\tSegmentScaling downScaledSegments[segmentsCount];\n\t// scale down segments and move all segments together so there is space for upscaling\n\tfor (int i = 0; i < segmentsCount; i++) {\n\t\tconst int segmentLength = segments[i].segmentLength;\n\t\tconst int scaleToSize = min(segments[i].scaleToSize, segmentLength);\n\t\tconst float scaleFactor = scaleFactorOf(segmentLength, scaleToSize);\n\n\t\tfor (int ledIndex = 0; ledIndex < scaleToSize; ledIndex++) {\n\t\t\tleds[ledStripIndexAfterScaling + ledIndex] =\n\t\t\t\tleds[ledStripIndexBeforeScaling + scaleIndex(ledIndex, scaleFactor)];\n\t\t}\n\t\tledStripIndexAfterScaling += scaleToSize;\n\t\tledStripIndexBeforeScaling += segmentLength;\n\t\tdownScaledSegments[i].segmentLength = scaleToSize;\n\t\tdownScaledSegments[i].scaleToSize = segments[i].scaleToSize;\n\t\ttotalLengthAfterScaling += segments[i].scaleToSize;\n\t}\n\n\tledStripIndexBeforeScaling = ledStripIndexAfterScaling;\n\tledStripIndexAfterScaling = totalLengthAfterScaling;\n\t// scale up segments beginning with the last segment to not override other segments\n\tfor (int i = segmentsCount - 1; i >= 0; i--) {\n\t\tconst float scaleFactor = scaleFactorOf(downScaledSegments[i].segmentLength, downScaledSegments[i].scaleToSize);\n\t\tledStripIndexAfterScaling -= downScaledSegments[i].scaleToSize;\n\t\tledStripIndexBeforeScaling -= downScaledSegments[i].segmentLength;\n\t\tfor (int ledIndex = downScaledSegments[i].scaleToSize - 1; ledIndex >= 0; ledIndex--) {\n\t\t\tleds[ledStripIndexAfterScaling + ledIndex] =\n\t\t\t\tleds[ledStripIndexBeforeScaling + scaleIndex(ledIndex, scaleFactor)];\n\t\t}\n\t}\n}\n\nvoid CLP::reverse(FastLEDController* controller, uint8_t channelIndex) {\n\tauto leds = controller->getLEDs(channelIndex);\n\tauto maxIndex = controller->getLEDCount(channelIndex) - 1;\n\tfor (int ledIndex = 0; ledIndex < maxIndex - ledIndex; ledIndex++) {\n\t\tCRGB temp = leds[ledIndex];\n\t\tleds[ledIndex] = leds[maxIndex - ledIndex];\n\t\tleds[maxIndex - ledIndex] = temp;\n\t}\n}\n\nvoid CLP::gammaCorrection(FastLEDController* controller, uint8_t channelIndex) {\n\tauto leds = controller->getLEDs(channelIndex);\n\tauto count = controller->getLEDCount(channelIndex);\n\tfor (int ledIndex = 0; ledIndex < count; ledIndex++) {\n\t\tleds[ledIndex].r = dim8_video(leds[ledIndex].r);\n\t\tleds[ledIndex].g = dim8_video(leds[ledIndex].g);\n\t\tleds[ledIndex].b = dim8_video(leds[ledIndex].b);\n\t}\n}\n\nvoid CLP::fixIcueBrightness(FastLEDController* controller, uint8_t channelIndex) {\n\tauto& channel = controller->getChannel(channelIndex);\n\tif (channel.mode == ChannelMode::SoftwarePlayback) {\n\t\tauto leds = controller->getLEDs(channelIndex);\n\t\tauto count = controller->getLEDCount(channelIndex);\n\t\tfor (int ledIndex = 0; ledIndex < count; ledIndex++) {\n\t\t\tleds[ledIndex].r = leds[ledIndex].r * 2;\n\t\t\tleds[ledIndex].g = leds[ledIndex].g * 2;\n\t\t\tleds[ledIndex].b = leds[ledIndex].b * 2;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FastLEDControllerUtils.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"FastLEDController.h\"\n\nnamespace CLP {\n/**\n * Make it possible to use up to 96 LEDs per channel from iCUE by using the LL Fan option. This function transforms the\n * LL fans layout to a normal strip layout. This function can be combined with scale and repeat function but must be\n * invoked first.\n *\n * @param controller the FastLEDController controlling the LEDs\n * @param channelIndex the index of the channel\n */\nvoid transformLLFanToStrip(FastLEDController* controller, uint8_t channelIndex);\n/**\n * Puts the LC100 LEDs in order for use as a strip.\n *\n * @param controller the FastLEDController controlling the LEDs\n * @param channelIndex the index of the channel\n */\nvoid transformLC100ToStrip(FastLEDController* controller, uint8_t channelIndex);\n/**\n * Scales a channel's length to a given size, the size can be larger or smaller than the default length given to the\n * FastLEDController::addLEDs function Integer scaling is used, so no interpolation between color values is done and the\n * animation don't look blurry.\n *\n * @param controller the FastLEDController controlling the LEDs\n * @param channelIndex the index of the channel\n * @param scaleToSize the final size after scaling\n */\nvoid scale(FastLEDController* controller, uint8_t channelIndex, int scaleToSize);\n/**\n * Repeat a channel's LEDs color to control more LEDs than provided by iCUE.\n *\n * @param controller the FastLEDController controlling the LEDs\n * @param channelIndex the index of the channel\n * @param times the number of time the colors should be repeated\n */\nvoid repeat(FastLEDController* controller, uint8_t channelIndex, uint8_t times);\n\n/**\n * Define the scaling information for a segment of a channel. A segment is a part of a channel that can be scale\n * independently of other segments.\n */\nstruct SegmentScaling {\n\t/**\n\t * The length of the segment in iCUE for example 10 for the normal LED strips\n\t */\n\tint segmentLength;\n\t/**\n\t * The size to which the segment will be scaled using Integer scaling\n\t */\n\tint scaleToSize;\n};\n/**\n * Scales a channel's segments to given sizes. This can be used to apply different scaling factors to the different\n * parts of a LED strip. Integer scaling is used.\n *\n * @param controller the FastLEDController controlling the LEDs\n * @param channelIndex the index of the channel you want to scale the segments on\n * @param segments the segments defining the size before and after scaling\n * @param segmentsCount the number of segments\n */\nvoid scaleSegments(FastLEDController* controller, uint8_t channelIndex, const SegmentScaling* const segments,\n\t\t\t\t   int segmentsCount);\n\n/**\n * Reverse the LEDs of a channel, after this operation, the first LED is the last and the last is the first.\n *\n * @param controller the FastLEDController controlling the LEDs\n * @param channelIndex the index of the channel you want to reverse\n */\nvoid reverse(FastLEDController* controller, uint8_t channelIndex);\n\n/**\n * Simple gamma correction with gamma value 2. This approximation of the gamma correction is sufficient for most LED\n * strips.\n *\n * @param controller the FastLEDController controlling the LEDs\n * @param channelIndex the index of the channel\n */\nvoid gammaCorrection(FastLEDController* controller, uint8_t channelIndex);\n\n/**\n * Increase the brightness of a LED channel when using LS100 and LT100 with iCUE Software lighting, because iCUE only\n * send the RGB value in the range (0 - 127) which is only 50% of max possible brightness. This function doubles the\n * received RGB value. Only use this function with LS100 and LT100.\n *\n * @param controller the FastLEDController controlling the LEDs\n * @param channelIndex the index of the channel\n */\nvoid fixIcueBrightness(FastLEDController* controller, uint8_t channelIndex);\n}  // namespace CLP\n"
  },
  {
    "path": "src/IFanController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n\n/**\n * The interface of a FanController.\n */\nclass IFanController {\npublic:\n\t/**\n\t * Handle a command and send back a response. This method is called if a new command for the FanController is\n\t * received.\n\t *\n\t * @param command the command which must be handled\n\t * @param response the callback used for the response\n\t */\n\tvirtual void handleFanControl(const Command& command, const CorsairLightingProtocolResponse* response) = 0;\n};\n"
  },
  {
    "path": "src/ILEDController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n\n/**\n * The interface of a LEDController.\n */\nclass ILEDController {\npublic:\n\t/**\n\t * Handle LED commands and send a response. This method is called for each received command.\n\t *\n\t * @param command the command which must be handled\n\t * @param response the callback for the response\n\t */\n\tvirtual void handleLEDControl(const Command& command, const CorsairLightingProtocolResponse* response) = 0;\n};\n"
  },
  {
    "path": "src/ITemperatureController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n#include \"CorsairLightingProtocolResponse.h\"\n\n/**\n * The interface of a TemperatureController.\n */\nclass ITemperatureController {\npublic:\n\t/**\n\t * Handle a temperature command and send a response.\n\t *\n\t * @param command the command which should be handled\n\t * @param response the callback for the response\n\t */\n\tvirtual void handleTemperatureControl(const Command& command, const CorsairLightingProtocolResponse* response) = 0;\n};\n"
  },
  {
    "path": "src/LEDController.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"LEDController.h\"\n\n#include \"TemperatureController.h\"\n\nvoid LEDController::handleLEDControl(const Command& command, const CorsairLightingProtocolResponse* response) {\n\tlastCommand = millis();\n\tauto& data = command.data;\n\tCLP_LOG(3, F(\"Received LED command %02X: \"), command.command);\n\tif (command.command == WRITE_LED_TRIGGER) {\n\t\tCLP_LOG(3, F(\"Write trigger\\r\\n\"));\n\t\ttriggerLEDUpdate();\n\t\tsaveIfNeeded();\n\t} else {\n\t\tif (data[0] >= CHANNEL_NUM) {\n\t\t\tresponse->sendError();\n\t\t\treturn;\n\t\t}\n\t\tconst uint8_t& channel = data[0];\n\t\tswitch (command.command) {\n\t\t\tcase READ_LED_STRIP_MASK: {\n\t\t\t\tCLP_LOG(3, F(\"Read strip mask\\r\\n\"));\n\t\t\t\tuint8_t ledMask[GROUPS_NUM];\n\t\t\t\tfor (uint8_t i = 0; i < GROUPS_NUM; i++) {\n\t\t\t\t\tif (i < channels[channel].groupsSet) {\n\t\t\t\t\t\tledMask[i] = getLEDStripMask(channel, i);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tledMask[i] = 0x00;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresponse->send(ledMask, sizeof(ledMask));\n\t\t\t\t// don't send default response\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase WRITE_LED_RGB_VALUE: {\n\t\t\t\tCLP_LOG(1, F(\"Write RGB value!\\r\\n\"));\n#ifdef DEBUG\n\t\t\t\tSerial.println(F(\"WriteLedRgbValue\"));\n#endif\n\t\t\t\t// TODO\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase WRITE_LED_COLOR_VALUES: {\n\t\t\t\tCLP_LOG(3, F(\"Write color values\\r\\n\"));\n\t\t\t\tconst uint8_t offset = data[1];\n\t\t\t\tconst size_t inputLength = min((size_t)data[2], sizeof(data) - 4);\n\t\t\t\tconst uint8_t color = data[3];\n\t\t\t\tif (color >= 3) {\n\t\t\t\t\tCLP_LOG(1, F(\"Invalid color: %d\\r\\n\"), color);\n\t\t\t\t\tresponse->sendError();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetLEDColorValues(channel, color, offset, data + 4, inputLength);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_CLEAR: {\n\t\t\t\tCLP_LOG(3, F(\"Write clear\\r\\n\"));\n\t\t\t\tclearLEDColorValues(channel);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_GROUP_SET: {\n\t\t\t\tCLP_LOG(3, F(\"Write group set\\r\\n\"));\n\t\t\t\tif (channels[channel].groupsSet >= GROUPS_NUM) {\n\t\t\t\t\tCLP_LOG(1, F(\"Invalid LED group: %d\\r\\n\"), channels[channel].groupsSet);\n\t\t\t\t\tresponse->sendError();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tLEDGroup group;\n\t\t\t\tgroup.ledIndex = data[1];\n\t\t\t\tgroup.ledCount = data[2];\n\t\t\t\tgroup.mode = data[3];\n\t\t\t\tgroup.speed = static_cast<GroupSpeed>(data[4]);\n\t\t\t\tgroup.direction = static_cast<GroupDirection>(data[5]);\n\t\t\t\tgroup.extra = static_cast<GroupExtra>(data[6]);\n\t\t\t\tgroup.tempGroup = data[7];\n\t\t\t\tgroup.color1.r = data[8];\n\t\t\t\tgroup.color1.g = data[9];\n\t\t\t\tgroup.color1.b = data[10];\n\t\t\t\tgroup.color2.r = data[11];\n\t\t\t\tgroup.color2.g = data[12];\n\t\t\t\tgroup.color2.b = data[13];\n\t\t\t\tgroup.color3.r = data[14];\n\t\t\t\tgroup.color3.g = data[15];\n\t\t\t\tgroup.color3.b = data[16];\n\t\t\t\tgroup.temp1 = CLP::fromBigEndian(data[17], data[18]);\n\t\t\t\tgroup.temp2 = CLP::fromBigEndian(data[19], data[20]);\n\t\t\t\tgroup.temp3 = CLP::fromBigEndian(data[21], data[22]);\n\n\t\t\t\tif (!isValidLEDGroup(group)) {\n\t\t\t\t\tCLP_LOG(1, F(\"Invalid LED config received\\r\\n\"));\n\t\t\t\t\tresponse->sendError();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttriggerSave |= setLEDGroup(channel, channels[channel].groupsSet++, group);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_EXTERNAL_TEMP: {\n\t\t\t\tCLP_LOG(3, F(\"Write external temp\\r\\n\"));\n\t\t\t\tsetLEDExternalTemperature(channel, CLP::fromBigEndian(data[2], data[3]));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_GROUPS_CLEAR: {\n\t\t\t\tCLP_LOG(3, F(\"Write groups clear\\r\\n\"));\n\t\t\t\ttriggerSave |= clearLEDGroups(channel);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_MODE: {\n\t\t\t\tCLP_LOG(3, F(\"Write mode\\r\\n\"));\n\t\t\t\tconst ChannelMode mode = static_cast<ChannelMode>(data[1]);\n\t\t\t\tif (!isValidChannelMode(mode)) {\n\t\t\t\t\tCLP_LOG(1, F(\"Unkown LED channel mode: %02X\\r\\n\"), data[1]);\n#ifdef DEBUG\n\t\t\t\t\tSerial.print(F(\"unkown LED channel mode: \"));\n\t\t\t\t\tSerial.print(data[1], HEX);\n\t\t\t\t\tSerial.println();\n#endif\n\t\t\t\t\tresponse->sendError();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttriggerSave |= setLEDMode(channel, mode);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_BRIGHTNESS: {\n\t\t\t\tCLP_LOG(3, F(\"Write brightness\\r\\n\"));\n\t\t\t\tuint8_t brightness = CLP::convert100To255(data[1]);\n\t\t\t\ttriggerSave |= setLEDBrightness(channel, brightness);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_COUNT: {\n\t\t\t\tCLP_LOG(2, F(\"Write count!\\r\\n\"));\n#ifdef DEBUG\n\t\t\t\tSerial.print(F(\"WRITE_LED_COUNT: \"));\n\t\t\t\tSerial.print(data[1], HEX);\n\t\t\t\tSerial.println();\n#endif\n\t\t\t\t// TODO\n\t\t\t\tchannels[channel].ledCount = data[1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_PORT_TYPE: {\n\t\t\t\tCLP_LOG(3, F(\"Write port type\\r\\n\"));\n\t\t\t\tconst PortType portType = static_cast<PortType>(data[1]);\n\t\t\t\tif (!isValidPortType(portType)) {\n\t\t\t\t\tCLP_LOG(1, F(\"Invalid port type: %d\\r\\n\"), portType);\n\t\t\t\t\tresponse->sendError();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttriggerSave |= setLEDPortType(channel, portType);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase WRITE_LED_START_AUTODETECTION: {\n\t\t\t\tCLP_LOG(3, F(\"Write start autodet\\r\\n\"));\n\t\t\t\tstartLEDAutodetection(channel);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase READ_LED_AUTODETECTION_RESULTS: {\n\t\t\t\tCLP_LOG(3, F(\"Write get autodet results\\r\\n\"));\n\t\t\t\tconst uint8_t result = getLEDAutodetectionResult(channel);\n\t\t\t\tuint8_t buffer[] = {result};\n\t\t\t\tresponse->send(buffer, sizeof(buffer));\n\t\t\t\t// don't send default response\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tCLP_LOG(1, F(\"Unkown command\\r\\n\"));\n#ifdef DEBUG\n\t\t\t\tSerial.print(F(\"unkown command: \"));\n\t\t\t\tSerial.print(command.command, HEX);\n\t\t\t\tSerial.println();\n#endif\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tresponse->send(nullptr, 0);\n}\n\nbool LEDController::isValidLEDChannel(const LEDChannel& ledChannel) {\n\tif (isValidChannelMode(ledChannel.mode) && isValidPortType(ledChannel.ledPortType) &&\n\t\tledChannel.groupsSet < GROUPS_NUM) {\n\t\tfor (uint8_t i = 0; i < ledChannel.groupsSet; i++) {\n\t\t\tif (!isValidLEDGroup(ledChannel.groups[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool LEDController::isValidLEDGroup(const LEDGroup& ledGroup) {\n\treturn ledGroup.mode <= GROUP_MODE_Rainbow && isValidGroupSpeed(ledGroup.speed) &&\n\t\t   isValidGroupDirection(ledGroup.direction) && isValidGroupExtra(ledGroup.extra) &&\n\t\t   (ledGroup.tempGroup == GROUP_TEMP_GROUP_EXTERNAL || ledGroup.tempGroup < TEMPERATURE_NUM);\n}\n\nconst LEDChannel& LEDController::getChannel(uint8_t channelIndex) { return channels[channelIndex]; }\n\nvoid LEDController::reset() {\n\tfor (auto& channel : channels) {\n\t\tchannel = LEDChannel();\n\t}\n\tsave();\n}\n\nuint8_t LEDController::getLEDStripMask(uint8_t channel, uint8_t groupIndex) {\n\treturn channels[channel].groups[groupIndex].ledCount;\n}\n\nbool LEDController::setLEDGroup(uint8_t channel, uint8_t groupIndex, LEDGroup& group) {\n\tchannels[channel].groups[groupIndex] = group;\n\treturn true;\n}\n\nbool LEDController::clearLEDGroups(uint8_t channel) {\n\tif (channels[channel].groupsSet != 0) {\n\t\tchannels[channel].groupsSet = 0;\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool LEDController::setLEDMode(uint8_t channel, ChannelMode mode) {\n\tif (channels[channel].mode != mode) {\n\t\tchannels[channel].mode = mode;\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool LEDController::setLEDBrightness(uint8_t channel, uint8_t brightness) {\n\tif (channels[channel].brightness != brightness) {\n\t\tchannels[channel].brightness = brightness;\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nbool LEDController::setLEDPortType(uint8_t channel, PortType ledPortType) {\n\tif (channels[channel].ledPortType != ledPortType) {\n\t\tchannels[channel].ledPortType = ledPortType;\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nvoid LEDController::startLEDAutodetection(uint8_t channel) {\n\t// Nothing to do here\n}\n\nbool LEDController::saveIfNeeded() {\n\tif (triggerSave) {\n\t\ttriggerSave = false;\n\t\treturn save();\n\t}\n\treturn false;\n}\n"
  },
  {
    "path": "src/LEDController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n/**\n * @file\n * Defines types and constants of the LED part of the protocol\n */\n\n#include <FastLED.h>\n\n#include \"Arduino.h\"\n#include \"CLPUtils.h\"\n#include \"ILEDController.h\"\n\n#define CHANNEL_NUM 2\n#define GROUPS_NUM 6\n\n/**\n * The mode of an LEDChannel. The mode describes how the LED lighting is done.\n *\n * @see LEDController#setLEDMode()\n */\nenum class ChannelMode : byte {\n\t/** No lighting is active for the channel. The LEDs will not be updated. */\n\tDisabled = 0x00,\n\t/** The Hardware Playback uses lighting effects defined by LEDGroups and LEDController renders the effects themself.\n\t   This mode works even without an USB connection.  */\n\tHardwarePlayback = 0x01,\n\t/** All lighting effects are rendered by iCUE and only the RGB values are transferred via USB to the device. This\n\t   requires an USB connection. */\n\tSoftwarePlayback = 0x02\n};\n\nbool inline isValidChannelMode(const ChannelMode channelMode) {\n\treturn channelMode == ChannelMode::Disabled || channelMode == ChannelMode::HardwarePlayback ||\n\t\t   channelMode == ChannelMode::SoftwarePlayback;\n}\n\n/**\n * The type of LED Chipset connected to a channel. These are the types implicitly defined by iCUE when doing the\n * lighting setup in iCUE. These type is ignored by the LEDController.\n */\nenum class PortType : byte {\n\t/** WS2812B used by all new Corsair devices */\n\tWS2812B = 0x01,\n\t/** UCS1903 Only used for the SP fan */\n\tUCS1903 = 0x02\n};\n\nbool inline isValidPortType(const PortType portType) {\n\treturn portType == PortType::WS2812B || portType == PortType::UCS1903;\n}\n\n// LED group mode\n#define GROUP_MODE_Rainbow_Wave 0x00\n#define GROUP_MODE_Color_Shift 0x01\n#define GROUP_MODE_Color_Pulse 0x02\n#define GROUP_MODE_Color_Wave 0x03\n#define GROUP_MODE_Static 0x04\n#define GROUP_MODE_Temperature 0x05\n#define GROUP_MODE_Visor 0x06\n#define GROUP_MODE_Marquee 0x07\n#define GROUP_MODE_Blink 0x08\n#define GROUP_MODE_Sequential 0x09\n#define GROUP_MODE_Rainbow 0x0A\n\n/**\n * The animation speed of a LEDGroup.\n */\nenum class GroupSpeed : byte { High = 0x00, Medium = 0x01, Low = 0x02 };\n\nbool inline isValidGroupSpeed(const GroupSpeed groupSpeed) {\n\treturn groupSpeed == GroupSpeed::High || groupSpeed == GroupSpeed::Medium || groupSpeed == GroupSpeed::Low;\n}\n\n/**\n * The animation direction of a LEDGroup.\n */\nenum class GroupDirection : byte { Backward = 0x00, Forward = 0x01 };\n\nbool inline isValidGroupDirection(const GroupDirection groupDirection) {\n\treturn groupDirection == GroupDirection::Backward || groupDirection == GroupDirection::Forward;\n}\n\n/**\n * Extra information for animations of a LEDGroup.\n */\nenum class GroupExtra : byte { Alternating = 0x00, Random = 0x01 };\n\nbool inline isValidGroupExtra(const GroupExtra groupExtra) {\n\treturn groupExtra == GroupExtra::Alternating || groupExtra == GroupExtra::Random;\n}\n\n#define GROUP_TEMP_GROUP_EXTERNAL 255\n\n/**\n * A LEDGroup is a contiguous range of LEDs on a strip. The LEDGroup defines the size, position and lighting effects of\n * the LED range.\n */\nstruct LEDGroup {\n\t/**\n\t * start index of the LEDs of this group\n\t */\n\tuint8_t ledIndex = 0;\n\t/**\n\t * number of LEDs in this group\n\t */\n\tuint8_t ledCount = 0;\n\tbyte mode = GROUP_MODE_Rainbow_Wave;\n\tGroupSpeed speed = GroupSpeed::High;\n\tGroupDirection direction = GroupDirection::Forward;\n\tGroupExtra extra = GroupExtra::Alternating;\n\tbyte tempGroup = GROUP_TEMP_GROUP_EXTERNAL;\n\n\tCRGB color1;\n\tCRGB color2;\n\tCRGB color3;\n\n\tuint16_t temp1;\n\tuint16_t temp2;\n\tuint16_t temp3;\n};\n\n/**\n * The definition of a Channel.\n */\nstruct LEDChannel {\n\t/**\n\t * Brightness of the channel in range 0-255.\n\t */\n\tuint8_t brightness = 255;\n\tChannelMode mode = ChannelMode::HardwarePlayback;\n\t/**\n\t * The number of LEDs on this channel.\n\t */\n\tuint8_t ledCount = 0;\n\tPortType ledPortType = PortType::WS2812B;\n\n\tLEDGroup groups[GROUPS_NUM];\n\tuint8_t groupsSet = 0;\n};\n\n/**\n * The abstract implemenation of an LEDController. This implementation handles the parsing and interpretation of\n * incoming commands. It also defines the data model to store the all required data from the commands.\n */\nclass LEDController : public ILEDController {\npublic:\n\tvirtual void handleLEDControl(const Command& command, const CorsairLightingProtocolResponse* response) override;\n\t/**\n\t * Validates a LEDChannel by checking all constrains on the values. This function should be used after non type-safe\n\t * operations on a LEDChannel.\n\t *\n\t * @param ledChannel the LEDChannel to validate\n\t * @return true if the LEDChannel is valid, false otherwise\n\t */\n\tvirtual bool isValidLEDChannel(const LEDChannel& ledChannel);\n\t/**\n\t * Validates a LEDGroup by checking all constrains on the values. This function should be used after non type-safe\n\t * operations on a LEDGroup.\n\t *\n\t * @param ledGroup the LEDGroup to validate\n\t * @return true if the LEDGroup is valid, false otherwise\n\t */\n\tvirtual bool isValidLEDGroup(const LEDGroup& ledGroup);\n\t/**\n\t * Get the data of a Channel from this LEDController.\n\t *\n\t * @param channelIndex the index of the channel\n\t * @return a reference to the LEDChannel\n\t */\n\tconst LEDChannel& getChannel(uint8_t channelIndex);\n\t/**\n\t * Reset all persistent data to default values of the LEDController.\n\t */\n\tvirtual void reset();\n\nprotected:\n\tLEDChannel channels[CHANNEL_NUM];\n\t/**\n\t * Indicates that the configuration of the channels has been changed and should be saved.\n\t */\n\tbool triggerSave = false;\n\t/**\n\t * Stores the time at which the last command was received by the LEDController.\n\t */\n\tunsigned long lastCommand = 0;\n\n\t/**\n\t * Trigger update of the LEDs\n\t */\n\tvirtual void triggerLEDUpdate() = 0;\n\t/**\n\t * Get the LED count of the group.\n\t *\n\t * @param channel the channel index\n\t * @param group the group index\n\t * @return the number of LEDs in the group\n\t */\n\tvirtual uint8_t getLEDStripMask(uint8_t channel, uint8_t group);\n\t/**\n\t *  Set the external temperature for a channel.\n\t *\n\t * @param channel the channel index\n\t * @param temp the temperature in hundredths of a degree Celsius.\n\t */\n\tvirtual void setLEDExternalTemperature(uint8_t channel, uint16_t temp) = 0;\n\tvirtual bool setLEDGroup(uint8_t channel, uint8_t groupIndex, LEDGroup& group);\n\t/**\n\t * Set the LED color values for one color-channel (red, green or blue) of the given channel.\n\t *\n\t * @param channel the channel index\n\t * @param color the color index to set the values for red(0), green(1), blue(2)\n\t * @param offset the offset in the LED colors buffer to write to\n\t * @param values the array of values to write\n\t * @param len the length of the array of values to write\n\t * @see clearLEDColorValues()\n\t */\n\tvirtual void setLEDColorValues(uint8_t channel, uint8_t color, uint8_t offset, const uint8_t* values,\n\t\t\t\t\t\t\t\t   size_t len) = 0;\n\t/**\n\t * Set the Channel mode.\n\t *\n\t * @param channel the channel index\n\t * @param mode the new mode\n\t * @return true if the mode was changed, false otherwise\n\t */\n\tvirtual bool setLEDMode(uint8_t channel, ChannelMode mode);\n\t/**\n\t * The brightness of the channel. This only applies to HW lighting.\n\t *\n\t * @param channel the channel index\n\t * @param brightness the brightness in the range 0-255\n\t * @return true if the brightness was changed\n\t */\n\tvirtual bool setLEDBrightness(uint8_t channel, uint8_t brightness);\n\t/**\n\t * Set the type of LED chipset: WS2812B or UCS1903\n\t *\n\t * @param channel the channel index\n\t * @param ledPortType the port type\n\t * @return true if the port type was changed\n\t */\n\tvirtual bool setLEDPortType(uint8_t channel, PortType ledPortType);\n\t/**\n\t * Clear the LED color buffer for the given channel.\n\t *\n\t * @param channel the channel index\n\t * @see setLEDColorValues()\n\t */\n\tvirtual void clearLEDColorValues(uint8_t channel) = 0;\n\tvirtual bool clearLEDGroups(uint8_t channel);\n\t/**\n\t * Start the potentially long running process to detect the current number of LEDs connected to given channel.\n\t *\n\t * @param channel the channel index\n\t * @see getLEDAutodetectionResult()\n\t */\n\tvirtual void startLEDAutodetection(uint8_t channel);\n\t/**\n\t * Get the result of the LED number autodetection on the given channel.\n\t * Potential values for LT100: 27, 54, 81, 108\n\t *\n\t * @param channel the channel index\n\t * @return the number of LEDs currently connected to the channel\n\t * @see startLEDAutodetection()\n\t */\n\tvirtual uint8_t getLEDAutodetectionResult(uint8_t channel) = 0;\n\tvirtual bool save() = 0;\n\tvirtual bool load() = 0;\n\t/**\n\t * Save if triggerSave is true and then reset triggerSave.\n\t */\n\tbool saveIfNeeded();\n};\n"
  },
  {
    "path": "src/RawHID.cpp",
    "content": "/*\nCopyright (c) 2014-2015 NicoHood\nmodified by Leon Kiefer\nSee the readme for credit to other people.\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n#include \"RawHID.h\"\n\n#if defined(ARDUINO_ARCH_AVR) && defined(USBCON)\n\n#ifndef HID_ENDPOINT_INTERVAL_RAWHID\n#define HID_ENDPOINT_INTERVAL_RAWHID 0x01\n#endif\n/* clang-format off */\nstatic const uint8_t  _hidReportDescriptorRawHID[] PROGMEM = {\n\t/*    RAW HID */\n    0x06, lowByte(RAWHID_USAGE_PAGE), highByte(RAWHID_USAGE_PAGE),      /* 30 */\n    0x0A, lowByte(RAWHID_USAGE), highByte(RAWHID_USAGE),\n\n    0xA1, 0x01,                  /* Collection 0x01 */\n    0x75, 0x08,                  /* report size = 8 bits */\n    0x15, 0x00,                  /* logical minimum = 0 */\n    0x26, 0xFF, 0x00,            /* logical maximum = 255 */\n\n    0x95, RAWHID_TX_SIZE,        /* report count TX */\n    0x09, 0x01,                  /* usage */\n    0x81, 0x02,                  /* Input (array) */\n\n    0x95, RAWHID_RX_SIZE,        /* report count RX */\n    0x09, 0x02,                  /* usage */\n    0x91, 0x02,                  /* Output (array) */\n    0xC0                         /* end collection */\n};\n/* clang-format on */\n\nconst char defaultSerialNumber[] PROGMEM = SERIAL_NUMBER;\n\nCLP::RawHID_::RawHID_(void)\n\t: PluggableUSBModule(ENDPOINT_COUNT, 1, epType),\n\t  protocol(HID_REPORT_PROTOCOL),\n\t  idle(1),\n\t  dataLength(0),\n\t  dataAvailable(0),\n\t  data(nullptr),\n\t  serialNumber(defaultSerialNumber),\n\t  featureReport(nullptr),\n\t  featureLength(0) {\n\tsetTimeout(10);\n\tepType[0] = EP_TYPE_INTERRUPT_IN;\n\tPluggableUSB().plug(this);\n}\n\nvoid CLP::RawHID_::setSerialNumber(const char* argSerialNumber) { serialNumber = argSerialNumber; }\n\nint CLP::RawHID_::getInterface(uint8_t* interfaceCount) {\n\t// Maybe as optional device FastRawHID with different USAGE PAGE\n\t*interfaceCount += 1;  // uses 1\n\tHIDDescriptor hidInterface = {D_INTERFACE(pluggedInterface, ENDPOINT_COUNT, USB_DEVICE_CLASS_HUMAN_INTERFACE,\n\t\t\t\t\t\t\t\t\t\t\t  HID_SUBCLASS_NONE, HID_PROTOCOL_NONE),\n\t\t\t\t\t\t\t\t  D_HIDREPORT(sizeof(_hidReportDescriptorRawHID)),\n\t\t\t\t\t\t\t\t  D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT,\n\t\t\t\t\t\t\t\t\t\t\t RAWHID_TX_SIZE, HID_ENDPOINT_INTERVAL_RAWHID)};\n\treturn USB_SendControl(0, &hidInterface, sizeof(hidInterface));\n}\n\nint CLP::RawHID_::getDescriptor(USBSetup& setup) {\n\t// Check if this is a HID Class Descriptor request\n\tif (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) {\n\t\treturn 0;\n\t}\n\tif (setup.wValueH != HID_REPORT_DESCRIPTOR_TYPE) {\n\t\treturn 0;\n\t}\n\n\t// In a HID Class Descriptor wIndex cointains the interface number\n\tif (setup.wIndex != pluggedInterface) {\n\t\treturn 0;\n\t}\n\n\t// Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol\n\t// due to the USB specs, but Windows and Linux just assumes its in report mode.\n\tprotocol = HID_REPORT_PROTOCOL;\n\n\treturn USB_SendControl(TRANSFER_PGM, _hidReportDescriptorRawHID, sizeof(_hidReportDescriptorRawHID));\n}\n\nbool CLP::RawHID_::setup(USBSetup& setup) {\n\tif (pluggedInterface != setup.wIndex) {\n\t\treturn false;\n\t}\n\n\tuint8_t request = setup.bRequest;\n\tuint8_t requestType = setup.bmRequestType;\n\n\tif (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE) {\n\t\tif (request == HID_GET_REPORT) {\n\t\t\t// TODO: HID_GetReport();\n\t\t\treturn true;\n\t\t}\n\t\tif (request == HID_GET_PROTOCOL) {\n\t\t\t// TODO: Send8(protocol);\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tif (requestType == REQUEST_HOSTTODEVICE_CLASS_INTERFACE) {\n\t\tif (request == HID_SET_PROTOCOL) {\n\t\t\tprotocol = setup.wValueL;\n\t\t\treturn true;\n\t\t}\n\t\tif (request == HID_SET_IDLE) {\n\t\t\tidle = setup.wValueL;\n\t\t\treturn true;\n\t\t}\n\t\tif (request == HID_SET_REPORT) {\n\t\t\t// Check if data has the correct length afterwards\n\t\t\tint length = setup.wLength;\n\n\t\t\t// Feature (set feature report)\n\t\t\tif (setup.wValueH == HID_REPORT_TYPE_FEATURE) {\n\t\t\t\t// No need to check for negative featureLength values,\n\t\t\t\t// except the host tries to send more then 32k bytes.\n\t\t\t\t// We dont have that much ram anyways.\n\t\t\t\tif (length == featureLength) {\n\t\t\t\t\tUSB_RecvControl(featureReport, featureLength);\n\n\t\t\t\t\t// Block until data is read (make length negative)\n\t\t\t\t\tdisableFeatureReport();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Output (set out report)\n\t\t\telse if (setup.wValueH == HID_REPORT_TYPE_OUTPUT) {\n\t\t\t\tif (!dataAvailable && length <= dataLength) {\n\t\t\t\t\t// Write data to fit to the end (not the beginning) of the array\n\t\t\t\t\tUSB_RecvControl(data + dataLength - length, length);\n\t\t\t\t\tdataAvailable = length;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n\nuint8_t CLP::RawHID_::getShortName(char* name) {\n\tname[0] = '\\0';\n\tstrncat_P(name, serialNumber, ISERIAL_MAX_LEN - 1);\n\treturn strlen(name);\n}\nnamespace CLP {\nRawHID_ RawHID;\n}\n#endif"
  },
  {
    "path": "src/RawHID.h",
    "content": "/*\nCopyright (c) 2014-2015 NicoHood\nmodified by Leon Kiefer\nSee the readme for credit to other people.\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n#pragma once\n\n#include \"Arduino.h\"\n#include \"CorsairLightingProtocolConstants.h\"\n\n#if defined(ARDUINO_ARCH_AVR)\n#include \"HID.h\"\n#endif\n\n#if defined(ARDUINO_ARCH_AVR) && defined(USBCON)\n#define SUPPORT_RAW_HID\n#endif\n\n#if defined(SUPPORT_RAW_HID)\n// RawHID might never work with multireports, because of OS problems\n// therefore we have to make it a single report with no idea. No other HID device will be supported then.\n#undef RAWHID_USAGE_PAGE\n#define RAWHID_USAGE_PAGE 0xFFC0  // recommended: 0xFF00 to 0xFFFF\n\n#undef RAWHID_USAGE\n#define RAWHID_USAGE 0x0C00  // recommended: 0x0100 to 0xFFFF\n\n#if defined(__AVR_ATmega16U2__)\n#define RAWHID_TX_SIZE 64\n#else\n#define RAWHID_TX_SIZE 16\n#endif\n#define RAWHID_RX_SIZE 64\n\n#endif\n\n#if defined(ARDUINO_ARCH_AVR) && defined(USBCON)  // Arduino Core\n\n#define EPTYPE_DESCRIPTOR_SIZE uint8_t\n// HID Functional Characteristics HID1.11 Page 10 4.4 Interfaces\n// Interrupt Out Endpoint is optional, control endpoint is used by default\n#define ENDPOINT_COUNT 1\nnamespace CLP {\nclass RawHID_ : public PluggableUSBModule, public Stream {\npublic:\n\tRawHID_(void);\n\t/**\n\t * Set the Serial Number of the USB device. Else a default Serial Number.\n\t *\n\t * @param serialNumber the Serial Number. The Serial Number string must be located in program space (flash).\n\t */\n\tvoid setSerialNumber(const char* serialNumber);\n\n\tvoid setFeatureReport(void* report, int length) {\n\t\tif (length > 0) {\n\t\t\tfeatureReport = (uint8_t*)report;\n\t\t\tfeatureLength = length;\n\n\t\t\t// Disable feature report by default\n\t\t\tdisableFeatureReport();\n\t\t}\n\t}\n\n\tint availableFeatureReport(void) {\n\t\tif (featureLength < 0) {\n\t\t\treturn featureLength & ~0x8000;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tvoid enableFeatureReport(void) { featureLength &= ~0x8000; }\n\n\tvoid disableFeatureReport(void) { featureLength |= 0x8000; }\n\n\tvoid begin(void* report, int length) {\n\t\tif (length > 0) {\n\t\t\tdata = (uint8_t*)report;\n\t\t\tdataLength = length;\n\t\t\tdataAvailable = 0;\n\t\t}\n\t}\n\n\tvoid end(void) {\n\t\tdisable();\n\t\tdataLength = 0;\n\t}\n\n\tvoid enable(void) { dataAvailable = 0; }\n\n\tvoid disable(void) { dataAvailable = -1; }\n\n\tvirtual int available(void) {\n\t\tif (dataAvailable < 0) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn dataAvailable;\n\t}\n\n\tvirtual int read() {\n\t\t// Check if we have data available\n\t\tif (dataAvailable > 0) {\n\t\t\t// Get next data byte (from the start to the end)\n\t\t\treturn data[dataLength - dataAvailable--];\n\t\t}\n\t\treturn -1;\n\t}\n\n\tvirtual int peek() {\n\t\t// Check if we have data available\n\t\tif (dataAvailable > 0) {\n\t\t\treturn data[dataLength - dataAvailable];\n\t\t}\n\t\treturn -1;\n\t}\n\n\tvirtual void flush(void) {\n\t\t// Writing will always flush by the USB driver\n\t}\n\n\t/**\n\t * Wrapper for a single byte\n\t */\n\tvirtual size_t write(uint8_t b) { return write(&b, 1); }\n\n\tvirtual size_t write(const uint8_t* buffer, size_t size) {\n\t\treturn USB_Send(pluggedEndpoint | TRANSFER_RELEASE, buffer, size);\n\t}\n\nprotected:\n\t// Implementation of the PUSBListNode\n\tint getInterface(uint8_t* interfaceCount) override;\n\tint getDescriptor(USBSetup& setup) override;\n\tbool setup(USBSetup& setup) override;\n\tuint8_t getShortName(char* name) override;\n\n\tEPTYPE_DESCRIPTOR_SIZE epType[ENDPOINT_COUNT];\n\tuint8_t protocol;\n\tuint8_t idle;\n\n\t// Buffer pointers to hold the received data\n\tint dataLength;\n\tint dataAvailable;\n\tuint8_t* data;\n\tconst char* serialNumber;\n\n\tuint8_t* featureReport;\n\tint featureLength;\n};\nextern RawHID_ RawHID;\n}  // namespace CLP\n#endif"
  },
  {
    "path": "src/TemperatureController.cpp",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#include \"TemperatureController.h\"\n\n#include \"CLPUtils.h\"\n\nvoid TemperatureController::handleTemperatureControl(const Command& command,\n\t\t\t\t\t\t\t\t\t\t\t\t\t const CorsairLightingProtocolResponse* response) {\n\tCLP_LOG(3, F(\"Received command %02X: \"), command.command);\n\tswitch (command.command) {\n\t\tcase READ_TEMPERATURE_MASK: {\n\t\t\tCLP_LOG(3, F(\"Read temp mask\\r\\n\"));\n\t\t\tuint8_t mask[TEMPERATURE_NUM];\n\t\t\tfor (uint8_t i = 0; i < TEMPERATURE_NUM; i++) {\n\t\t\t\tmask[i] = isTemperatureSensorConnected(i) ? TEMPERATURE_MASK_CONNECTED : TEMPERATURE_MASK_NOT_CONNECTED;\n\t\t\t}\n\t\t\tresponse->send(mask, sizeof(mask));\n\t\t\tbreak;\n\t\t}\n\t\tcase READ_TEMPERATURE_VALUE: {\n\t\t\tCLP_LOG(3, F(\"Read temp value\\r\\n\"));\n\t\t\tconst uint8_t& tempSensor = command.data[0];\n\t\t\tif (tempSensor >= TEMPERATURE_NUM) {\n\t\t\t\tCLP_LOG(1, F(\"Unknown temp sensor: %d\\r\\n\"), tempSensor);\n\t\t\t\tresponse->sendError();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tuint16_t temp = getTemperatureValue(tempSensor);\n\t\t\tuint8_t tempData[] = {toBigEndian(temp)};\n\t\t\tresponse->send(tempData, sizeof(tempData));\n\t\t\tbreak;\n\t\t}\n\t\tcase READ_VOLTAGE_VALUE: {\n\t\t\tCLP_LOG(3, F(\"Read voltage\\r\\n\"));\n\t\t\tconst uint8_t& rail = command.data[0];\n\t\t\tuint16_t voltage;\n\t\t\tswitch (rail) {\n\t\t\t\tcase VOLTAGE_RAIL_12V: {\n\t\t\t\t\tvoltage = getVoltageRail12V();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase VOLTAGE_RAIL_5V: {\n\t\t\t\t\tvoltage = getVoltageRail5V();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase VOLTAGE_RAIL_3V3: {\n\t\t\t\t\tvoltage = getVoltageRail3V3();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tCLP_LOG(1, F(\"Unkown voltage rail: %d\\r\\n\"), rail);\n\t\t\t\t\tresponse->sendError();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tuint8_t voltageData[] = {toBigEndian(voltage)};\n\t\t\tresponse->send(voltageData, sizeof(voltageData));\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tCLP_LOG(1, F(\"Unkown command\\r\\n\"));\n\t\t\tresponse->sendError();\n\t\t\treturn;\n\t}\n}\n\nuint16_t TemperatureController::getTemperature(uint8_t temperatureSensor) {\n\tif (temperatureSensor >= TEMPERATURE_NUM) {\n\t\treturn 0;\n\t}\n\treturn getTemperatureValue(temperatureSensor);\n}\n"
  },
  {
    "path": "src/TemperatureController.h",
    "content": "/*\n   Copyright 2019 Leon Kiefer\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n#pragma once\n\n/**\n * @file\n */\n\n#include \"Arduino.h\"\n#include \"ITemperatureController.h\"\n\n#define TEMPERATURE_NUM 4\n\n#define TEMPERATURE_MASK_CONNECTED 0x01\n#define TEMPERATURE_MASK_NOT_CONNECTED 0x00\n\n#define VOLTAGE_RAIL_12V 0\n#define VOLTAGE_RAIL_5V 1\n#define VOLTAGE_RAIL_3V3 2\n\n/**\n * The abstract implementation of the ITemperatureController. This implementation handles the commands parsing and\n * processing.\n */\nclass TemperatureController : public ITemperatureController {\npublic:\n\tvirtual void handleTemperatureControl(const Command& command,\n\t\t\t\t\t\t\t\t\t\t  const CorsairLightingProtocolResponse* response) override;\n\t/**\n\t * Get the temperature of a sensor.\n\t *\n\t * @param temperatureSensor the index of the temperature sensor\n\t * @return the temperature in hundredths of a degree Celsius.\n\t */\n\tvirtual uint16_t getTemperature(uint8_t temperatureSensor);\n\nprotected:\n\t/**\n\t * Get the temperature of a sensor.\n\t *\n\t * @param temperatureSensor the index of the temperature sensor\n\t * @return the temperature in hundredths of a degree Celsius.\n\t */\n\tvirtual uint16_t getTemperatureValue(uint8_t temperatureSensor) = 0;\n\t/**\n\t * Check if a temperature sensor is connected.\n\t *\n\t * @param temperatureSensor the index of the temperature sensor\n\t * @return true if a temperature sensor is connected\n\t */\n\tvirtual bool isTemperatureSensorConnected(uint8_t temperatureSensor) = 0;\n\t/**\n\t * Get the voltage of the 12V rail.\n\t *\n\t * @return the voltage in mV\n\t */\n\tvirtual uint16_t getVoltageRail12V() = 0;\n\t/**\n\t * Get the voltage of the 5V rail.\n\t *\n\t * @return the voltage in mV\n\t */\n\tvirtual uint16_t getVoltageRail5V() = 0;\n\t/**\n\t * Get the voltage of the 3.3V rail.\n\t *\n\t * @return the voltage in mV\n\t */\n\tvirtual uint16_t getVoltageRail3V3() = 0;\n};\n"
  }
]