diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c01859b4..4be23bc1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,6 +19,8 @@ jobs: pip3 install -U wheel pip3 install -U platformio python3 -m platformio update + python3 -m platformio lib -g install "adafruit/DHT sensor library" + python3 -m platformio lib -g install "adafruit/Adafruit Unified Sensor" - name: building examples and running the unit tests run: bash ./.scripts/ci_local.sh diff --git a/.github/workflows/latest.yaml b/.github/workflows/latest.yaml index 8ab0030a..7fcb98b9 100644 --- a/.github/workflows/latest.yaml +++ b/.github/workflows/latest.yaml @@ -7,43 +7,39 @@ on: - 'main' jobs: - doxygen: - runs-on: ubuntu-20.04 - if: "contains(github.event.head_commit.message, '--build-docs')" - steps: - - uses: actions/checkout@v1 - - name: install dependencies - run: sudo apt install doxygen graphviz - - name: gernearte html folder - run: mkdir doc/html - - name: generate docs - run: bash .scripts/doxygen_multilang.sh - - name: Deploy - uses: s0/git-publish-subdir-action@master - env: - REPO: self - BRANCH: gh-pages - FOLDER: doc/html - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - pre-release: + latest-release: name: "Pre Release latest" runs-on: "ubuntu-20.04" steps: - uses: actions/checkout@v1 + + - name: install doc deps + run: sudo apt-get install --yes doxygen graphviz latexmk texlive-latex-extra + - name: install platform io run: | pip3 install -U setuptools pip3 install -U wheel pip3 install -U platformio python3 -m platformio update + python3 -m platformio lib -g install "adafruit/DHT sensor library" + python3 -m platformio lib -g install "adafruit/Adafruit Unified Sensor" - name: building examples and running the unit tests run: bash ./.scripts/ci_local.sh + + - name: prepare for building docs + run: | + mkdir doc/html + mkdir doc/latex + + - name: build documentation + run: bash .scripts/doxygen_multilang.sh - name: pack repo run: | zip -r latest.zip src License README.md library.properties keywords.txt .vscode examples src + - name: Check code meets quality standards id: code-inspector uses: codeinspectorio/github-action@master @@ -58,6 +54,7 @@ jobs: max_long_functions_rate: '0.01' project_name: 'LedController' max_timeout_sec: '600' + - uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" @@ -67,14 +64,18 @@ jobs: files: | License latest.zip - - - name: Discord Commits - uses: Sniddl/discord-commits@v1.2 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - message: "Successful commit to **{{ github.context.payload.repository.owner.name }}/{{ github.context.payload.repository.name}}**.\nDiff: {{ github.context.payload.compare }}" - embed: '{ "title": "{{ commit.title }}", "description": "{{ commit.description }}", "url": "{{ commit.url }}", "author": { "name": "{{ commit.author.name }} ({{ commit.author.username }})", "icon_url": "https://avatars.io/gravatar/{{ commit.author.email }}"} }' - + refman_english.pdf + refman_german.pdf + + - name: Deploy to pages + if: "contains(github.event.head_commit.message, '--build-docs')" + uses: s0/git-publish-subdir-action@master + env: + REPO: self + BRANCH: gh-pages + FOLDER: doc/html + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/upload-artifact@v1 if: failure() with: diff --git a/.github/workflows/rc.yaml b/.github/workflows/rc.yaml index 36c0bb1e..196ce864 100644 --- a/.github/workflows/rc.yaml +++ b/.github/workflows/rc.yaml @@ -6,37 +6,34 @@ on: - 'v*-rc*' jobs: - doxygen: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v1 - - name: install dependencies - run: sudo apt install doxygen graphviz - - name: gernearte html folder - run: mkdir doc/html - - name: generate docs - run: bash .scripts/doxygen_multilang.sh - - name: Deploy - uses: s0/git-publish-subdir-action@master - env: - REPO: self - BRANCH: gh-pages - FOLDER: doc/html - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tagged-release: + tagged-rc-release: name: "Release candidate" runs-on: "ubuntu-20.04" steps: - uses: actions/checkout@v1 + + - name: install doc deps + run: sudo apt-get install --yes doxygen graphviz latexmk texlive-latex-extra + - name: install platform io run: | pip3 install -U setuptools pip3 install -U wheel pip3 install -U platformio python3 -m platformio update + python3 -m platformio lib -g install "adafruit/DHT sensor library" + python3 -m platformio lib -g install "adafruit/Adafruit Unified Sensor" - name: building examples and running the unit tests run: bash ./.scripts/ci_local.sh + + - name: prepare for building docs + run: | + mkdir doc/html + mkdir doc/latex + + - name: build documentation + run: bash .scripts/doxygen_multilang.sh - name: Check code meets quality standards id: code-inspector @@ -56,6 +53,7 @@ jobs: - name: pack repo run: | zip -r release.zip License README.md library.properties keywords.txt .vscode examples src + - uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" @@ -63,6 +61,16 @@ jobs: files: | License release.zip + refman_english.pdf + refman_german.pdf + + - name: Deploy to pages + uses: s0/git-publish-subdir-action@master + env: + REPO: self + BRANCH: gh-pages + FOLDER: doc/html + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v1 if: failure() diff --git a/.github/workflows/stable.yaml b/.github/workflows/stable.yaml index 38a841e7..72b4a7a5 100644 --- a/.github/workflows/stable.yaml +++ b/.github/workflows/stable.yaml @@ -7,38 +7,35 @@ on: - '!*-rc*' jobs: - doxygen: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v1 - - name: install dependencies - run: sudo apt install doxygen graphviz - - name: gernearte html folder - run: mkdir doc/html - - name: generate docs - run: bash .scripts/doxygen_multilang.sh - - name: Deploy - uses: s0/git-publish-subdir-action@master - env: - REPO: self - BRANCH: gh-pages - FOLDER: doc/html - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} tagged-release: name: "Tagged Release" runs-on: "ubuntu-20.04" steps: - uses: actions/checkout@v1 + + - name: install doc deps + run: sudo apt-get install --yes doxygen graphviz latexmk texlive-latex-extra + - name: install platform io run: | pip3 install -U setuptools pip3 install -U wheel pip3 install -U platformio python3 -m platformio update + python3 -m platformio lib -g install "adafruit/DHT sensor library" + python3 -m platformio lib -g install "adafruit/Adafruit Unified Sensor" - name: building examples and running the unit tests run: bash ./.scripts/ci_local.sh - + + - name: prepare for building docs + run: | + mkdir doc/html + mkdir doc/latex + + - name: build documentation + run: bash .scripts/doxygen_multilang.sh + - name: Check code meets quality standards id: code-inspector uses: codeinspectorio/github-action@master @@ -57,6 +54,7 @@ jobs: - name: pack repo run: | zip -r release.zip License README.md library.properties keywords.txt .vscode examples + - uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" @@ -64,6 +62,16 @@ jobs: files: | License release.zip + refman_english.pdf + refman_german.pdf + + - name: Deploy to pages + uses: s0/git-publish-subdir-action@master + env: + REPO: self + BRANCH: gh-pages + FOLDER: doc/html + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v1 if: failure() diff --git a/.gitignore b/.gitignore index 62fcabd0..95515a9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ doc/html doc/man +doc/latex doxywarn*.txt +refman_*.pdf .vscode .idea diff --git a/.scripts/ci_local.sh b/.scripts/ci_local.sh index b0b7b8fc..7966c845 100755 --- a/.scripts/ci_local.sh +++ b/.scripts/ci_local.sh @@ -40,7 +40,7 @@ else echo "doing the full test with 1 board and 6 examles" boards=("esp32dev") fi - examples=("Led-matrix-rocket" "Led-matrix-rocket-multi" "Led-matrix-counting" "Led-matrix-rocket-hwSPI" "Led-matrix-message" "7-Segment-counting") + examples=("Led-matrix-rocket" "Led-matrix-rocket-multi" "Led-matrix-counting" "Led-matrix-rocket-hwSPI" "Led-matrix-message" "7-Segment-counting" "7-Segment-DHT-temp-humid") fi function build(){ diff --git a/.scripts/doxygen_multilang.sh b/.scripts/doxygen_multilang.sh index 25797e7d..e2e8ad9c 100755 --- a/.scripts/doxygen_multilang.sh +++ b/.scripts/doxygen_multilang.sh @@ -11,6 +11,7 @@ OLD_LANGAUGE="English" OUTPUT_LANGUAGE_STRING="OUTPUT_LANGUAGE = " HTML_DIR="HTML_OUTPUT = html" EXAMPLE_DIR="EXAMPLE_PATH = examples" +LATEX_DIR="LATEX_OUTPUT = latex" #the base folder for the doxygen output DOXYGEN_BASE="doc" @@ -25,6 +26,7 @@ build_lang(){ #replace the language and add specific subfolder sed -i "s/$OUTPUT_LANGUAGE_STRING$OLD_LANGAUGE/$OUTPUT_LANGUAGE_STRING$lang/g" Doxyfile.$lang sed -i "s/$HTML_DIR/$HTML_DIR\/$lang/g" Doxyfile.$lang + sed -i "s/$LATEX_DIR/$LATEX_DIR\/$lang/g" Doxyfile.$lang sed -i "s/$EXAMPLE_DIR/$EXAMPLE_DIR\/$lang/g" Doxyfile.$lang sed -i "s/doxywarn.txt/doxywarn.$lang.txt/g" Doxyfile.$lang @@ -35,6 +37,14 @@ build_lang(){ #run doxygen doxygen Doxyfile.$lang + #build pdf file + cd doc/latex/$lang/ + latexmk -f -pdf refman.tex + cd ../../../ + + #copy and rename reference manual + mv doc/latex/$lang/refman.pdf refman_$lang.pdf + #remove lang specific doxygen file rm Doxyfile.$lang diff --git a/Doxyfile b/Doxyfile index 36c1ade1..e353fabc 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.18 +# Doxyfile 1.9.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -227,6 +227,14 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -315,7 +323,10 @@ OPTIMIZE_OUTPUT_SLICE = NO # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = ino=C++ @@ -449,6 +460,19 @@ TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -512,6 +536,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -549,11 +580,18 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# (including Cygwin) ands Mac users are advised to set this option to NO. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. # The default value is: system dependent. CASE_SENSE_NAMES = NO @@ -792,7 +830,10 @@ WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. # The default value is: NO. WARN_AS_ERROR = NO @@ -823,13 +864,22 @@ WARN_LOGFILE = doxywarn.txt # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = . +INPUT = . \ + doc/pages/index.doc \ + doc/pages/install.doc \ + doc/pages/usage.doc \ + doc/pages/migration_notes.doc \ + doc/pages/1.x.y_to_2.0.z.doc \ + doc/pages/movement.doc \ + doc/pages/multi_row.doc \ + doc/pages/controller_configuration.doc \ + doc/pages/language_selection.doc # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: https://www.gnu.org/software/libiconv/) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 @@ -842,18 +892,19 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), -# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen -# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, -# *.vhdl, *.ucf, *.qsf and *.ice. +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.cpp \ *.hpp \ - *.md \ - *.doc + *.md # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -1067,16 +1118,22 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse_libclang=ON option for CMake. # The default value is: NO. CLANG_ASSISTED_PARSING = NO +# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to +# YES then doxygen will add the directory of each input to the include path. +# The default value is: YES. + +CLANG_ADD_INC_PATHS = YES + # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories @@ -1086,10 +1143,13 @@ CLANG_ASSISTED_PARSING = NO CLANG_OPTIONS = # If clang assisted parsing is enabled you can provide the clang parser with the -# path to the compilation database (see: -# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) used when the files -# were built. This is equivalent to specifying the "-p" option to a clang tool, -# such as clang-check. These options will then be passed to the parser. +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse_libclang=ON option for CMake. @@ -1106,13 +1166,6 @@ CLANG_DATABASE_PATH = ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored @@ -1283,10 +1336,11 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: https://developer.apple.com/xcode/), introduced with OSX -# 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy # genXcode/_index.html for more information. @@ -1328,8 +1382,8 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1359,7 +1413,7 @@ CHM_FILE = HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). +# (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1404,7 +1458,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1412,8 +1467,8 @@ QHP_NAMESPACE = de.sakurajin.LedController # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1421,16 +1476,16 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = @@ -1442,9 +1497,9 @@ QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1525,8 +1580,8 @@ EXT_LINKS_IN_WINDOW = NO # tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see # https://inkscape.org) to generate formulas as SVG images instead of PNGs for # the HTML output. These images will generally look nicer at scaled resolutions. -# Possible values are: png The default and svg Looks nicer but requires the -# pdf2svg tool. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). # The default value is: png. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1571,7 +1626,7 @@ USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1601,7 +1656,8 @@ MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1648,7 +1704,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1661,8 +1718,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -1700,7 +1758,7 @@ EXTRA_SEARCH_MAPPINGS = # If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output. # The default value is: YES. -GENERATE_LATEX = NO +GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of @@ -1826,9 +1884,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1841,7 +1901,7 @@ USE_PDFLATEX = YES # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_BATCHMODE = NO +LATEX_BATCHMODE = YES # If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the # index chapters (such as File Index, Compound Index, etc.) in the output. @@ -2339,10 +2399,32 @@ UML_LOOK = YES # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2534,9 +2616,11 @@ DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc and +# plantuml temporary files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/doc/images/Led-matrix-rocket-multi.jpg b/doc/images/Led-matrix-rocket-multi.jpg new file mode 100644 index 00000000..ac17a290 Binary files /dev/null and b/doc/images/Led-matrix-rocket-multi.jpg differ diff --git a/doc/images/Led-matrix-rocket_0.jpg b/doc/images/Led-matrix-rocket_0.jpg new file mode 100644 index 00000000..33180ae7 Binary files /dev/null and b/doc/images/Led-matrix-rocket_0.jpg differ diff --git a/doc/images/Led-matrix-rocket_1.jpg b/doc/images/Led-matrix-rocket_1.jpg new file mode 100644 index 00000000..0636f07f Binary files /dev/null and b/doc/images/Led-matrix-rocket_1.jpg differ diff --git a/doc/images/Led_matrix_counting.jpg b/doc/images/Led_matrix_counting.jpg new file mode 100644 index 00000000..2909eee4 Binary files /dev/null and b/doc/images/Led_matrix_counting.jpg differ diff --git a/doc/images/multi_row_numbering.svg b/doc/images/multi_row_numbering.svg index 00f3f67a..2561876b 100644 --- a/doc/images/multi_row_numbering.svg +++ b/doc/images/multi_row_numbering.svg @@ -1,224 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index 5 - - - - - - - - - - - - - - - - - - - Index 4 - - - - - - - Index 6 - - - - - - - Index 7 - - - - - - - - - - - - - Index 1 - - - - - - - - - - - - - - - - - - - Index 0 - - - - - - - Index 2 - - - - - - - Index 3 - - - - - - - Row 0 - - - - - - - Row 1 - - - - - - - Column 0 - - - - - - - Column 1 - - - - - - - Column 2 - - - - - - - Column 3 - - - - - - - - \ No newline at end of file +Index 5Index 4Index 6Index 7Index 1Index 0Index 2Index 3Row 0Row 1Column 0Column 1Column 2Column 3 \ No newline at end of file diff --git a/doc/pages/1.x.y_to_2.0.z.doc b/doc/pages/1.x.y_to_2.0.z.doc index 9bf384d9..38e744e2 100644 --- a/doc/pages/1.x.y_to_2.0.z.doc +++ b/doc/pages/1.x.y_to_2.0.z.doc @@ -6,7 +6,7 @@ 2.0.0 is not fully released yet but since the release of 2.0.0-rc1 only bug fixes and documentation updates will be pushed so these instructions will apply. Version 2.0.x is no longer a drop in replacement for 1.7.x! -Due to some large changes in the code base, the sakurajin::LedController is now a template class which requires the dimensions of your LED-Matrix as Argument so now instead of having the type `sakurajin::LedController`, the type is `sakurajin::LedController`. +Due to some large changes in the code base, the sakurajin::LedController is now a template class which requires the dimensions of your LED-Matrix as Argument so now instead of having the type `LedController`, the type is `sakurajin::LedController`. This simplifies the whole interface and reduces the need for pointers. The examples are updated and respect these changes and there is now German documentation. Another side effect of this is, that you do not need to specify the total nmber of segments any more, since the dimensions are known. @@ -15,8 +15,8 @@ That is why that argument is removed from all constructors. 2.0.x introduces the sakurajin::controller_configuration as class template. It can be used to set all the properties the controller should have and then be passed as argument to the init function or the constructor of the sakurajin::LedController. It needs the same dimensions as the sakurajin::LedController and provides a simple check for a valid configuration. -You can check [this page](@ref sakurajin::controller_configuration_page) to learn more about the sakurajin::controller_configuration class. -While sakurajin::controller_configuration already existed in 1.7.2, it is used more extensively and it can do a lot more. +You can check [this page](@ref controller_configuration_page) to learn more about the sakurajin::controller_configuration class. +While controller_configuration already existed in 1.7.2, it is used more extensively and it can do a lot more. The next big feature is support for multiple rows of segments. Now you can connect multiple Matricies to different CS Pins and control them all using a single sakurajin::LedController instead of only being able to connect them all in a row. @@ -32,15 +32,15 @@ Check [this page](@ref multi_row) to learn more about how to use multiple rows. Version 2.0.x ist nicht mehr ein einfacher Ersatz für 1.7.x! Wegen einiger großer Änderungen ist der sakurajin::LedController nun eine Template Klasse welche die Dimensionen der Led_Matrix als Argument benötigt. -So wird nun statt dem Typ `sakurajin::LedController` der Typ `sakurajin::LedController` benötigt. +So wird nun statt dem Typ `LedController` der Typ `sakurajin::LedController` benötigt. Dies vereinfacht das Interface und verringert den Bedarf von Pointern. Alle Beispiele wurden mit den Änderungen geupdated und die Dokumentation ist nun auch auf deutsch verfügbar. Da die Dimensionen nun bekannt sind, wird nicht mehr die Anzahl der Sgemente benötigt und sie wurde von allen Kontruktoren entfernt. 2.0.x führt die sakurajin::controller_configuration Template Klasse ein. -Zwar existiert sakurajin::controller_configuration schon in 1.7.2, allerdings ist diese Klasse nun auch ein Template und kann viel mehr. +Zwar existiert controller_configuration schon in 1.7.2, allerdings ist diese Klasse nun auch ein Template und kann viel mehr. Wie der sakurajin::LedController braucht auch diese Klasse die Dimensionen der Matrix und diese müssen auch mit dem sakurajin::LedController übereinstimmen. -Die Klasse wird [aus dieser Seite](@ref sakurajin::controller_configuration_page) im Detail beschrieben. +Die Klasse wird [aus dieser Seite](@ref controller_configuration_page) im Detail beschrieben. Die nächste neue große Änderung ist die Unterstützung von mehreren Reihen von Segmenten. Nun können mehrere Matrizen an verschiedene CS Pins angeschlossen werden und mit einem einzigen sakurajin::LedController gesteuert werden. diff --git a/doc/pages/controller_configuration.doc b/doc/pages/controller_configuration.doc index 15cc0860..87b4cef5 100644 --- a/doc/pages/controller_configuration.doc +++ b/doc/pages/controller_configuration.doc @@ -1,7 +1,7 @@ /*! \~english -\page sakurajin::controller_configuration_page The sakurajin::controller_configuration +\page controller_configuration_page The controller_configuration Check the sakurajin::controller_configuration for more infomation about its functions or look for the [Examples](examples.html). @@ -77,7 +77,7 @@ The following options where removed at some point. \~german -\page sakurajin::controller_configuration_page Die sakurajin::controller_configuration Klasse +\page controller_configuration_page Die controller_configuration Klasse Schau of die Seite der sakurajin::controller_configuration für mehr Informationen oder schau in die [Beispiele](examples.html). diff --git a/doc/pages/multi_row.doc b/doc/pages/multi_row.doc index fa506d6f..6a624105 100644 --- a/doc/pages/multi_row.doc +++ b/doc/pages/multi_row.doc @@ -47,7 +47,7 @@ Below is an example of how the sakurajin::controller_configuration might be crea If you want to use virtual_multi_row (have all of the segments connected in series) then you have to set SPI_CS to you CS pin and set virtual_multi_row to true (which is the default). As long as those conditions are satisfied, the values of row_SPI_CS will be ignored. -Look at the [sakurajin::controller_configuration page](@ref sakurajin::controller_configuration_page) for details on how to use all of the other fields. +Look at the [sakurajin::controller_configuration page](@ref controller_configuration_page) for details on how to use all of the other fields. \section display_multi_data Displaying data on segments @@ -108,7 +108,7 @@ Hier ist ein Beispiel wie eine gültige sakurajin::controller_configuration für Falls virtual_multi_row (alle Segmente in Reihe geschaltet) verwendet werden soll, dann muss SPI_CS auf den gewünschten CS pin gesetzt werden und virtual_multi_row muss true sein (was der Standardwert ist). Solange diese beiden Bedingungen erfüllt sind wird der Wert von row_SPI_CS ignoriert. -Schau die [sakurajin::controller_configuration Seite](@ref sakurajin::controller_configuration_page) für die Details über die anderen Felder an. +Schau die [sakurajin::controller_configuration Seite](@ref controller_configuration_page) für die Details über die anderen Felder an. \section display_multi_data Daten auf den Segmenten anzeigen diff --git a/examples/english/7-Segment-DHT-temp-humid/7-Segment-DHT-temp-humid.ino b/examples/english/7-Segment-DHT-temp-humid/7-Segment-DHT-temp-humid.ino new file mode 100644 index 00000000..a91b34b3 --- /dev/null +++ b/examples/english/7-Segment-DHT-temp-humid/7-Segment-DHT-temp-humid.ino @@ -0,0 +1,252 @@ +// DHT Temperature & Humidity Sensor displayed on a 7-Seegment Display + +// REQUIRES the following Arduino libraries: +// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library +// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor +// - LedController: https://github.com/noah1510/LedController + +//This code is based on the example for the DHT Sensor Library. +//All of the sensor related code is moved into functions to better show the integration of the LedController library. + +#include +#include +#include + +#define DHTPIN 17 // Digital pin connected to the DHT sensor + +// Uncomment the type of sensor in use: +//#define DHTTYPE DHT11 // DHT 11 +#define DHTTYPE DHT22 // DHT 22 (AM2302) +//#define DHTTYPE DHT21 // DHT 21 (AM2301) + +// See guide for details on sensor wiring and usage: +// https://learn.adafruit.com/dht/overview + +DHT_Unified dht(DHTPIN, DHTTYPE); + +uint32_t delayMS; + +//Like alway the library has to be included +#include "LedController.hpp" + +//The variable that is used to store the Controller object. +//The controller has two rows with one Column each. +//Since 7-Segment-Displays are used, every Segment has 8 Disigts that can be addressed. +LedController<1,2> control = LedController<1,2>(); + +//The chip select Pins for each row of the LedController +#define CS_BOTTOM 16 +#define CS_TOP 22 + +//The number of digits used to display each float +const unsigned int NUMBER_OF_DIGITS = 4; + +//The number of values used to smooth the measured values +#define SMOOTHING_BUFFER_SIZE 10 + +//This function returns the raw output from the sensor. +//The unit is degrees Celsius. +//Because of this the retrun values might not represent the actual temperature. +//If there was an error reading the value, a value lower than absolute zero in Celsius is returned (less than -273.15) is returned. +float getRawTemp(){ + sensors_event_t event; + dht.temperature().getEvent(&event); + if (isnan(event.temperature)) { + Serial.println(F("Error reading temperature!")); + return -1000; + } + + return event.temperature; +} + +//This function returns the raw output from the sensor. +//The relative humidity is returned so the value should be between 0 and 100. +//Because of this the retrun values might not represent the actual humidity. +//If there was an error reading the value a negative number is returned. +float getRawHumid(){ + sensors_event_t event; + dht.humidity().getEvent(&event); + if (isnan(event.relative_humidity)) { + Serial.println(F("Error reading humidity!")); + return -1; + } + return event.relative_humidity; +} + +//This function returns a smoothed valued for the temperature. +//The unit is degrees Celsius. +//If you expact fast changes use the raw data and handle the invalid values manually. +//Its return value is always valid but only good after SMOOTHING_BUFFER_SIZE calls. +float getTemp(){ + static float last_temps[SMOOTHING_BUFFER_SIZE]; + static bool firstCall = true; + + float new_temp = getRawTemp(); + float sum = new_temp; + + if(new_temp < -370.0){ + sum = 0; + for(unsigned int i = 0; i < SMOOTHING_BUFFER_SIZE;i++){ + sum += last_temps[i]; + } + }else{ + for(unsigned int i = 0; i < SMOOTHING_BUFFER_SIZE-1;i++){ + last_temps[i] = firstCall ? new_temp : last_temps[i+1]; + sum += last_temps[i]; + } + last_temps[SMOOTHING_BUFFER_SIZE-1] = new_temp; + + if(firstCall){firstCall = false;}; + } + + return sum/SMOOTHING_BUFFER_SIZE; +} + +//This function returns a smoothed valued for the humidity. +//The relative humidity is returned so the value should be between 0 and 100. +//If you expact fast changes use the raw data and handle the invalid values manually. +//Its return value is always valid but only good after SMOOTHING_BUFFER_SIZE calls. +float getHumidity(){ + static float last_humids[SMOOTHING_BUFFER_SIZE]; + static bool firstCall = true; + + float new_humid = getRawHumid(); + float sum = new_humid; + + if(new_humid < 0){ + sum = 0; + for(unsigned int i = 0; i < SMOOTHING_BUFFER_SIZE;i++){ + sum += last_humids[i]; + } + }else{ + + for(unsigned int i = 0; i < SMOOTHING_BUFFER_SIZE-1;i++){ + last_humids[i] = firstCall ? new_humid : last_humids[i+1]; + sum += last_humids[i]; + } + last_humids[SMOOTHING_BUFFER_SIZE-1] = new_humid; + + if(firstCall){firstCall = false;}; + } + + return sum/SMOOTHING_BUFFER_SIZE; +} + +//This function can display a float on a 7-Segment display. +//It assumes the dismension of the LedController is <1,row> and the row can be selected with the second parameter. +//The third parameter is used to specify how many digits you want to after the decimal Place. +//The fourth paramether is an offset moving all digits to the left by the specified amount +void displayFloat(float value, unsigned int row = 0, unsigned int decimalPlaces = 1,unsigned int digitOffset = 0){ + unsigned int total_length = NUMBER_OF_DIGITS; + if(NUMBER_OF_DIGITS conf; + + //disable virtual_muti_row + conf.SPI_CS = 0; + conf.virtual_multi_row = false; + + //These are the chip select pins for each row. + //The bottom row (row 0) is connected to pin 16 and the top row (row 1) is connected to pin 22 + conf.row_SPI_CS[0] = CS_BOTTOM; + conf.row_SPI_CS[1] = CS_TOP; + + //this enables hardware spi check what pins to use for your board + conf.useHardwareSpi = true; + + //this enables debug output (nothing should be printed but it helps to fix possible problems with the config) + conf.debug_output = true; + + //this specifies the transfer speed of the spi interface. If you want to use high values make sure your cables have a good connection + conf.spiTransferSpeed = 600000; + + //initilizing the LedController with the configuration which we just set + control.init(conf); + + //set the lowest possible brightness + control.setIntensity(0); + + //turn every digit off + for(unsigned int i = 0; i < 8;i++){ + control.setRow(0,i,0x00); + control.setRow(1,i,0x00); + } +} + +void loop() { + // Delay between measurements. + delay(delayMS); + + //get and display the temperature in the top row + auto temp = getTemp(); + Serial.print(F("Temperature: ")); + Serial.println(temp); + displayFloat(temp,1,1); + control.setChar(1,7,'t',false); + + //get and display the humidity in the bottom row + auto humid = getHumidity(); + Serial.print(F("Humidity: ")); + Serial.println(humid); + displayFloat(humid,0,1); + control.setChar(0,7,'H',false); + +} diff --git a/examples/german/7-Segment-DHT-temp-humid/7-Segment-DHT-temp-humid.ino b/examples/german/7-Segment-DHT-temp-humid/7-Segment-DHT-temp-humid.ino new file mode 100644 index 00000000..0e2ec620 --- /dev/null +++ b/examples/german/7-Segment-DHT-temp-humid/7-Segment-DHT-temp-humid.ino @@ -0,0 +1,256 @@ +// DTH Temperatur- und Luftfeuchtigkeitssensor auf einem 7-Segment Display angezeigt. + +// Die folgenden Arduino Bibliotheken werden benötigt: +// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library +// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor +// - LedController: https://github.com/noah1510/LedController + +//Dieser Code basiert auf einem Beispiel der DHT Sensor Library. +//All der sensor bezogene Code wurde in Funktionen verpackt, um die integration des LedController besser zu zeigen. + +#include +#include +#include + +#define DHTPIN 17 // Digital pin vebunden mit dem DHT sensor + +// verwendeten Sensortyp auskommentieren: +//#define DHTTYPE DHT11 // DHT 11 +#define DHTTYPE DHT22 // DHT 22 (AM2302) +//#define DHTTYPE DHT21 // DHT 21 (AM2301) + +// Anleitung für Verkabelung und Detials über die Sensoren (auf Englisch): +// https://learn.adafruit.com/dht/overview + +DHT_Unified dht(DHTPIN, DHTTYPE); + +uint32_t delayMS; + +//Wie immer die Bibliothek einbinden +#include "LedController.hpp" + +//Die Variable in der Controller gespeichert ist. +//Der Controller hat zwei Zeilen mit je einer Spalte. +//Bei 7-Segment-Displays hat jedes Segment 8 Ziffern, die angezeigt werden können. +LedController<1,2> control = LedController<1,2>(); + +//Die CS Pins für die einzelnen Zeilen +#define CS_BOTTOM 16 +#define CS_TOP 22 + +//Die Anzahl der Ziffern, die für die Darstellung von floats verwendet werden soll +const unsigned int NUMBER_OF_DIGITS = 4; + +//Wie viele Werte zur Glättung gespeichert werden sollen. +#define SMOOTHING_BUFFER_SIZE 10 + +//Diese Funktion gibt die Rohdaten vom Sensor zurück. +//Die Einheit ist Grad Celsius. +//Weil keine Glättung stattfindet, kann der Wert stark schwanken. +//Falls es einen Fehler beim Auslesen gab, wird ein Wert zurückgegeben der niedriger ist als der absolute Nullpunk (-273.15). +float getRawTemp(){ + sensors_event_t event; + dht.temperature().getEvent(&event); + if (isnan(event.temperature)) { + Serial.println(F("Error reading temperature!")); + return -1000; + } + + return event.temperature; +} + +//Diese Funktion gibt die Rohdaten vom Sensor zurück. +//Die relative Luftfeuchtigkeit wird zurückgegeben, folglich sind die Werte zwischen 0 und 100. +//Weil keine Glättung stattfindet, kann der Wert stark schwanken. +//Falls es einen Fehler beim Auslesen gab, wird ein Wert zurückgegeben der negativ ist. +float getRawHumid(){ + sensors_event_t event; + dht.humidity().getEvent(&event); + if (isnan(event.relative_humidity)) { + Serial.println(F("Error reading humidity!")); + return -1; + } + return event.relative_humidity; +} + +//Diese Funktion gibt geglättete Werte für fie Temperatur zurück. +//Die Einheit ist Grad Celsius. +//Falls man schnelle Änderungen erwartet, sollte man die Rohdaten verwenden. +//Der Rückgabewert ist immer gültig, aber erst gut nach SMOOTHING_BUFFER_SIZE aufrufen. +float getTemp(){ + static float last_temps[SMOOTHING_BUFFER_SIZE]; + static bool firstCall = true; + + float new_temp = getRawTemp(); + float sum = new_temp; + + if(new_temp < -370.0){ + sum = 0; + for(unsigned int i = 0; i < SMOOTHING_BUFFER_SIZE;i++){ + sum += last_temps[i]; + } + }else{ + for(unsigned int i = 0; i < SMOOTHING_BUFFER_SIZE-1;i++){ + last_temps[i] = firstCall ? new_temp : last_temps[i+1]; + sum += last_temps[i]; + } + last_temps[SMOOTHING_BUFFER_SIZE-1] = new_temp; + + if(firstCall){firstCall = false;}; + } + + return sum/SMOOTHING_BUFFER_SIZE; +} + +//Diese Funktion gibt geglättete Werte für fie Luftfeuchtigkeit zurück. +//Die relative Luftfeuchtigkeit wird zurückgegeben, folglich sind die Werte zwischen 0 und 100. +//Falls man schnelle Änderungen erwartet, sollte man die Rohdaten verwenden. +//Der Rückgabewert ist immer gültig, aber erst gut nach SMOOTHING_BUFFER_SIZE aufrufen. +float getHumidity(){ + static float last_humids[SMOOTHING_BUFFER_SIZE]; + static bool firstCall = true; + + float new_humid = getRawHumid(); + float sum = new_humid; + + if(new_humid < 0){ + sum = 0; + for(unsigned int i = 0; i < SMOOTHING_BUFFER_SIZE;i++){ + sum += last_humids[i]; + } + }else{ + + for(unsigned int i = 0; i < SMOOTHING_BUFFER_SIZE-1;i++){ + last_humids[i] = firstCall ? new_humid : last_humids[i+1]; + sum += last_humids[i]; + } + last_humids[SMOOTHING_BUFFER_SIZE-1] = new_humid; + + if(firstCall){firstCall = false;}; + } + + return sum/SMOOTHING_BUFFER_SIZE; +} + +//Diese Funktion kann einen float Wert auf einer 7-Segment-anzeige anzeigen. +//Es wird die Annahme getroffen, dass der LedController nur eine Spalte hat. +//Die gewünschte Zeile kann mit den zweiten Parameter ausgewählt werden. +//Das dritte Parameter bestimmt die Anzahl der Stellen nach dem Komma. +//Das vierte Parameter schiebt die angezeigte Zahl nach links. +void displayFloat(float value, unsigned int row = 0, unsigned int decimalPlaces = 1,unsigned int digitOffset = 0){ + unsigned int total_length = NUMBER_OF_DIGITS; + if(NUMBER_OF_DIGITS conf; + + //deaktivieren von virtual_muti_row + conf.SPI_CS = 0; + conf.virtual_multi_row = false; + + //hier werden die Chip Select Pins der einzelnen Reihen gesetzt. + //Die untere Zeile (Zeile 0) ist an Pin 16 geschlossen und die obere Reihe (Reihe 1) an Pin 22 + conf.row_SPI_CS[0] = CS_BOTTOM; + conf.row_SPI_CS[1] = CS_TOP; + + //Das setzt die nńutzung von harware SPI + //Schaue welche Pins bei deinem Board verwendet werden müssen. + conf.useHardwareSpi = true; + + //Das schaltet die Debug Ausgabe an. + //Es sollte zwar nichts ausgegeben werden, kann aber trotzdem hilfreich sein. + conf.debug_output = true; + + //Das setzt die Übertragungsgeschwindigkeit der SPI Schnittstelle. + //Falls hohe Werte gesetzt werden, sollte eine gute Verbingung sichergestellt werden. + conf.spiTransferSpeed = 600000; + + //Initialisiere den LedController mit der erstellten Konfiguration. + control.init(conf); + + //setzt die Helligkeit auf die niedrigste Helligkeit + control.setIntensity(0); + + //schaltet alle Ziffern aus + for(unsigned int i = 0; i < 8;i++){ + control.setRow(0,i,0x00); + control.setRow(1,i,0x00); + } +} + +void loop() { + //Verzögerung zwischen den Messungen + delay(delayMS); + + //Temperatur holen und auf der oberen Reihe anzeigen anzeigen + auto temp = getTemp(); + Serial.print(F("Temperature: ")); + Serial.println(temp); + displayFloat(temp,1,1); + control.setChar(1,7,'t',false); + + //Luftfeuchtigkeit holen und auf der unteren Reihe anzeigen anzeigen + auto humid = getHumidity(); + Serial.print(F("Humidity: ")); + Serial.println(humid); + displayFloat(humid,0,1); + control.setChar(0,7,'H',false); + +} diff --git a/platformio.ini b/platformio.ini index a281c0fc..babd097a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,6 +27,53 @@ board = esp32dev framework = arduino lib_extra_dirs = ~/Arduino/libraries lib_compat_mode = strict -lib_ignore = - https://github.com/noah1510/pio-native-spi.git - Native SPI + +[env:d1_mini] +platform = espressif8266 +board = d1_mini +framework = arduino +lib_extra_dirs = ~/Arduino/libraries +lib_compat_mode = strict + +[env:uno] +platform = atmelavr +board = uno +framework = arduino +lib_extra_dirs = ~/Arduino/libraries +lib_compat_mode = strict + +[env:ATmega1280] +platform = atmelavr +board = ATmega1280 +framework = arduino +lib_extra_dirs = ~/Arduino/libraries +lib_compat_mode = strict + +[env:leonardo] +platform = atmelavr +board = leonardo +framework = arduino +lib_extra_dirs = ~/Arduino/libraries +lib_compat_mode = strict + +[env:bluefruitmicro] +platform = atmelavr +board = bluefruitmicro +framework = arduino +lib_extra_dirs = ~/Arduino/libraries +lib_compat_mode = strict + +[env:due] +platform = atmelsam +board = due +framework = arduino +lib_extra_dirs = ~/Arduino/libraries +lib_compat_mode = strict + +[env:teensy41] +platform = teensy +board = teensy41 +framework = arduino +lib_extra_dirs = ~/Arduino/libraries +lib_compat_mode = strict + diff --git a/src/LedController_MAX72XX.hpp b/src/LedController_MAX72XX.hpp index 5db44d10..2393a6fb 100644 --- a/src/LedController_MAX72XX.hpp +++ b/src/LedController_MAX72XX.hpp @@ -8,12 +8,12 @@ namespace sakurajin { private: charTable table; - static const MAX72XX& getInstance() { + static const MAX72XX& getInstance() noexcept { static MAX72XX instance = MAX72XX(); return instance; } - MAX72XX(); + MAX72XX() noexcept; public: static const unsigned int OP_NOOP = 0; @@ -31,11 +31,11 @@ namespace sakurajin { static const unsigned int OP_SHUTDOWN = 12; static const unsigned int OP_DISPLAYTEST = 15; - static byte getChar(char c) { + static byte getChar(char c) noexcept { return getInstance().table.getChar(c); } - static const charTable& getTable() { + static const charTable& getTable() noexcept { return getInstance().table; } }; diff --git a/src/LedController_byteblock.hpp b/src/LedController_byteblock.hpp index 02df520f..0aa387ac 100644 --- a/src/LedController_byteblock.hpp +++ b/src/LedController_byteblock.hpp @@ -37,7 +37,7 @@ namespace sakurajin { * * @param newdata Das Array, das zum initialisieren verwendet werden soll. */ - ByteBlock(byte newdata[8]):ByteRow<8>(newdata) {}; + ByteBlock(byte newdata[8]) noexcept:ByteRow<8>(newdata) {}; /** * \~english @@ -48,7 +48,7 @@ namespace sakurajin { * @brief Erstelle ein neues Objekt aus einer Liste von Werten. * So kann {0,0,0,0,0,0,0,0} als Kopierzuweisung verwendet werden. */ - ByteBlock(byte n0,byte n1,byte n2,byte n3,byte n4,byte n5,byte n6,byte n7):ByteBlock() { + ByteBlock(byte n0,byte n1,byte n2,byte n3,byte n4,byte n5,byte n6,byte n7) noexcept:ByteBlock() { _data[0] = n0; _data[1] = n1; _data[2] = n2; @@ -66,7 +66,7 @@ namespace sakurajin { * \~german * @brief Konstruiere ein neuess Objekt mit 0en. */ - ByteBlock():ByteRow<8>() {}; + ByteBlock() noexcept:ByteRow<8>() {}; /** * \~english @@ -79,7 +79,7 @@ namespace sakurajin { * @note Dieser Konstruktor existiert hauptsächlich für Typumwandlungen. * @param data Die daten, die zugewiesen werden sollen */ - ByteBlock(const ByteRow<8>& data):ByteRow<8>(data) {}; + ByteBlock(const ByteRow<8>& data) noexcept:ByteRow<8>(data) {}; /** * \~english @@ -92,7 +92,7 @@ namespace sakurajin { * * @return ByteBlock Die Splaten des gegebenen Blocks */ - ByteBlock transpose() const { + ByteBlock transpose() const noexcept { return ByteBlock::makeColumns(*this); } @@ -107,7 +107,7 @@ namespace sakurajin { * * @return ByteBlock Die Splaten des gegebenen Blocks */ - ByteBlock makeColumns() const { + ByteBlock makeColumns() const noexcept { return this->transpose(); } @@ -122,7 +122,7 @@ namespace sakurajin { * * @return ByteBlock Der umgekehrte ByteBlock. */ - ByteBlock reverse() const { + ByteBlock reverse() const noexcept { return ByteBlock::reverse(*this); } @@ -137,7 +137,7 @@ namespace sakurajin { * * @return ByteBlock Der rotierte byteBlock. */ - ByteBlock rotate180() const { + ByteBlock rotate180() const noexcept { return ByteBlock::rotate180(*this); } @@ -155,7 +155,7 @@ namespace sakurajin { * @param input Das byte, das umgekehrt werden soll. * @return byte Das umgekehrte Byte */ - static byte reverse(byte input) { + static byte reverse(byte input) noexcept { byte ret = 0x00; for (unsigned int i = 0; i < 8; i++) { if (input & (0x01U << i)) { @@ -178,7 +178,7 @@ namespace sakurajin { * @param input Der ByteBlock der umgekehrt werden soll. * @return ByteBlock Der umgekehrte ByteBlock. */ - static ByteBlock reverse(ByteBlock input) { + static ByteBlock reverse(ByteBlock input) noexcept { auto reversedInput = ByteBlock(); for (unsigned int i = 0; i < 8; i++) { @@ -201,7 +201,7 @@ namespace sakurajin { * @param input Der zu rotierende ByteBlock. * @return ByteBlock Der rotierte byteBlock. */ - static ByteBlock rotate180(ByteBlock input) { + static ByteBlock rotate180(ByteBlock input) noexcept { auto rotatedInput = ByteBlock(); for (unsigned int i = 0; i < 8; i++) { @@ -224,7 +224,7 @@ namespace sakurajin { * @param rowArray Der Block aus Zeilen * @return ByteBlock Die Splaten des gegebenen Blocks */ - static ByteBlock makeColumns(ByteBlock rowArray) { + static ByteBlock makeColumns(ByteBlock rowArray) noexcept { auto columnArray = ByteBlock(); for (unsigned int i = 0; i < 8; i++) { @@ -249,7 +249,7 @@ namespace sakurajin { * @param rowArray Der Block aus Zeilen * @return ByteBlock Die Splaten des gegebenen Blocks */ - static ByteBlock transpose(ByteBlock rowArray) { + static ByteBlock transpose(ByteBlock rowArray) noexcept { return ByteBlock::makeColumns(rowArray); } diff --git a/src/LedController_byterow.hpp b/src/LedController_byterow.hpp index f2eab84d..2e010a25 100644 --- a/src/LedController_byterow.hpp +++ b/src/LedController_byterow.hpp @@ -48,7 +48,7 @@ namespace sakurajin { * * @param newdata Das Array, das zum initialisieren verwendet werden soll. */ - ByteRow(byte newdata[SIZE]):ByteRow() { + ByteRow(byte newdata[SIZE]) noexcept:ByteRow() { for(uint64_t i = 0; i < SIZE; i++) { _data[i] = newdata[i]; } @@ -61,7 +61,7 @@ namespace sakurajin { * \~german * @brief Konstruiere ein neuess Objekt mit 0en. */ - ByteRow() { + ByteRow() noexcept { for(uint64_t i = 0; i < SIZE; i++) { _data[i] = 0; } @@ -74,7 +74,7 @@ namespace sakurajin { * \~german * @brief Lösche das Objekt. */ - ~ByteRow() {}; + ~ByteRow() noexcept {}; /** * \~english @@ -89,7 +89,7 @@ namespace sakurajin { * @param index Der Angefragte Index. * @return byte& Die Daten am angefragtem Index. */ - byte& operator[] (uint64_t index) { + byte& operator[] (uint64_t index) noexcept { index %= SIZE; return _data[index]; } @@ -107,7 +107,7 @@ namespace sakurajin { * @param index Der Angefragte Index. * @return byte& Die Daten am angefragtem Index. */ - const byte& operator[] (uint64_t index) const { + const byte& operator[] (uint64_t index) const noexcept { index %= SIZE; return _data[index]; } @@ -125,7 +125,7 @@ namespace sakurajin { * @param index Der Angefragte Index. * @return byte& Die Daten am angefragtem Index. */ - byte at(uint64_t index) const { + byte at(uint64_t index) const noexcept { index %= SIZE; return _data[index]; } @@ -143,7 +143,7 @@ namespace sakurajin { * @param newdata Die Array, das zugewiesen wird. * @return ByteRow& Das modifizierte Objekt. */ - ByteRow& operator= (byte newdata[SIZE]) { + ByteRow& operator= (byte newdata[SIZE]) noexcept { for(uint64_t i = 0; i < SIZE; i++) { _data[i] = newdata[i]; } @@ -163,7 +163,7 @@ namespace sakurajin { * @param other Die ByteRows, welche mit diesem Objekt überladen werden soll * @return ByteRow Die resultierende ByteRow */ - virtual ByteRow operator&(const ByteRow& other) const { + virtual ByteRow operator&(const ByteRow& other) const noexcept { ByteRow block = ByteRow(); for(unsigned int i = 0; i < SIZE; i++) { block[i] = (this->at(i)) | (other.at(i)); @@ -184,7 +184,7 @@ namespace sakurajin { * @param distance Die Distanz die geschoben werden soll * @return ByteRow Die resultierende ByteRow */ - virtual ByteRow operator<<(unsigned int distance) const { + virtual ByteRow operator<<(unsigned int distance) const noexcept { ByteRow block = ByteRow(); for(unsigned int i = 0; i < SIZE; i++) { block[i] = (this->at(i))>>distance; @@ -205,7 +205,7 @@ namespace sakurajin { * @param distance Die Distanz die geschoben werden soll * @return ByteRow Die resultierende ByteRow */ - virtual ByteRow operator>>(unsigned int distance) const { + virtual ByteRow operator>>(unsigned int distance) const noexcept { ByteRow block = ByteRow(); for(unsigned int i = 0; i < SIZE; i++) { block[i] = (this->at(i))< block = ByteRow(); for(unsigned int i = 0; i < SIZE-1; i++) { block[i] = (this->at(i+1)); @@ -239,7 +239,7 @@ namespace sakurajin { * @brief Schiebt die Daten um 1 Distanz nach oben. * @return ByteRow Die resultierende ByteRow */ - virtual ByteRow operator++() const { + virtual ByteRow operator++() const noexcept { ByteRow block = ByteRow(); for(unsigned int i = 1; i < SIZE; i++) { block[i] = (this->at(i-1)); @@ -262,7 +262,7 @@ namespace sakurajin { * @return true die Daten sind identisch * @return false die Daten sind nicht identisch */ - virtual bool operator==(const ByteRow& other) const { + virtual bool operator==(const ByteRow& other) const noexcept { for (size_t i = 0; i < SIZE; i++) { if(this->at(i) != other.at(i)) { return false; @@ -285,7 +285,7 @@ namespace sakurajin { * @return true die Daten sind nicht identisch * @return false die Daten sind identisch */ - virtual bool operator!=(const ByteRow& other) const { + virtual bool operator!=(const ByteRow& other) const noexcept { for (size_t i = 0; i < SIZE; i++) { if(this->at(i) == other.at(i)) { return false; diff --git a/src/LedController_charTable.hpp b/src/LedController_charTable.hpp index bb5fd79f..b587c49a 100644 --- a/src/LedController_charTable.hpp +++ b/src/LedController_charTable.hpp @@ -4,7 +4,7 @@ namespace sakurajin { class charTable:public ByteRow<128> { public: - charTable(byte newdata[128]):ByteRow<128>(newdata) {}; + charTable(byte newdata[128]) noexcept:ByteRow<128>(newdata) {}; charTable( byte n0, byte n1, byte n2, byte n3, byte n4, byte n5, byte n6, byte n7, byte n8, byte n9, @@ -20,7 +20,7 @@ namespace sakurajin { byte n100, byte n101, byte n102, byte n103, byte n104, byte n105, byte n106, byte n107, byte n108, byte n109, byte n110, byte n111, byte n112, byte n113, byte n114, byte n115, byte n116, byte n117, byte n118, byte n119, byte n120, byte n121, byte n122, byte n123, byte n124, byte n125, byte n126, byte n127 - ) { + ) noexcept { _data[0] = n0; _data[1] = n1; _data[2] = n2; @@ -163,7 +163,7 @@ namespace sakurajin { _data[127] = n127; }; - virtual byte getChar(char c) const { + virtual byte getChar(char c) const noexcept { byte index = ((byte)c)%128; return this->at(index); } diff --git a/src/LedController_config.hpp b/src/LedController_config.hpp index 6665064e..313bca78 100644 --- a/src/LedController_config.hpp +++ b/src/LedController_config.hpp @@ -151,7 +151,7 @@ namespace sakurajin { * * @return unsigned int Die Anzahl der Segmente. */ - unsigned int SegmentCount() { + unsigned int SegmentCount() const noexcept { return rows*columns; } @@ -169,7 +169,7 @@ namespace sakurajin { * @return true Die Konfiguration ist gültig. * @return false Die Konfiguration ist ungültig. */ - bool isValid() const { + bool isValid() const noexcept { return isValidConfig(*this); } @@ -186,7 +186,7 @@ namespace sakurajin { * @param segmentNumber Die Segmentnummer des gesuchten Segments. * @return unsigned int Die Zeile in der das Segment ist. */ - unsigned int getRow(unsigned int segmentNumber) const { + unsigned int getRow(unsigned int segmentNumber) const noexcept { unsigned int row = 0; if (rows != 0 && columns != 0) { row = segmentNumber / columns; @@ -212,7 +212,7 @@ namespace sakurajin { * @param segmentNumber Die Segmentnummer des gesuchten Segments. * @return unsigned int Die Spalte in der das Segment ist. */ - unsigned int getColumn(unsigned int segmentNumber) const { + unsigned int getColumn(unsigned int segmentNumber) const noexcept { unsigned int col = 0; if (rows != 0 && columns != 0) { col = segmentNumber % columns; @@ -232,7 +232,7 @@ namespace sakurajin { * * @return unsigned int Die Länge einer Zeile */ - unsigned int getRowLen() const { + unsigned int getRowLen() const noexcept { return columns; } @@ -251,7 +251,7 @@ namespace sakurajin { * @param row Die Zeile in der das Segment ist * @return unsigned int Die Segmentnummer des segments */ - unsigned int getSegmentNumber(unsigned int column, unsigned int row) const { + unsigned int getSegmentNumber(unsigned int column, unsigned int row) const noexcept { row %= rows; column %= columns; return row * columns + column; @@ -268,7 +268,7 @@ namespace sakurajin { * * @return controller_configuration Eine Kopie der Konfiguration */ - controller_configuration copy() const { + controller_configuration copy() const noexcept { controller_configuration conf; conf.IntensityLevel = this->IntensityLevel; conf.onlySendOnChange = this->onlySendOnChange; @@ -297,7 +297,7 @@ namespace sakurajin { * @return true Die Konfiguration ist gültig. * @return false Die Konfiguration ist ungültig. */ - static bool isValidConfig(const controller_configuration &conf) { + static bool isValidConfig(const controller_configuration &conf) noexcept { //check if the dimenstions are valid if (rows == 0 || columns == 0) { return false; @@ -322,7 +322,7 @@ namespace sakurajin { return false; } - if (!conf.virtual_multi_row && conf.SPI_CS == 0) { + if (!conf.virtual_multi_row || conf.SPI_CS == 0) { for(unsigned int i = 0; i < rows; i++) { if(conf.row_SPI_CS[i] == 0) { PRINTLN_IF(conf.debug_output, "Invalid value in row_SPI_CS found. 0 is not allowed."); diff --git a/src/LedController_template.hpp b/src/LedController_template.hpp index 14bb6198..e8dd9f32 100644 --- a/src/LedController_template.hpp +++ b/src/LedController_template.hpp @@ -75,7 +75,7 @@ namespace sakurajin { * @param opcode Der Befehl, der ausgeführt werden soll. * @param data Die Daten, die für den Befehl benötigt werden. */ - void spiTransfer(unsigned int segment, byte opcode, byte data); + void spiTransfer(unsigned int segment, byte opcode, byte data) noexcept; /** * \~english @@ -100,7 +100,7 @@ namespace sakurajin { * @param segmentNumber Die Nummer, des Segemnts. * @param newIntesityLevel Die gewünschte Helligkeit inklusive der Grenzen von 0 & 15. (0..15) */ - void setIntensity(unsigned int segmentNumber, unsigned int newIntesityLevel); + void setIntensity(unsigned int segmentNumber, unsigned int newIntesityLevel) noexcept; /** * \~english @@ -119,7 +119,7 @@ namespace sakurajin { * \~german * @brief Initialisiere die internen Puffer des LedController. */ - void resetBuffers(); + void resetBuffers() noexcept; /** * \~english @@ -128,7 +128,7 @@ namespace sakurajin { * \~german * @brief Initialisiere die SPI Ausgabe. */ - void initSPI(); + void initSPI() noexcept; /** * \~english @@ -137,7 +137,7 @@ namespace sakurajin { * \~german * @brief Initialisiere die Konfiguration */ - void initConf(); + void initConf() noexcept; public: /** @@ -147,7 +147,7 @@ namespace sakurajin { * \~german * @brief Erstelle einen neuen LedController ohne etwas zu initialisieren. */ - LedController(); + LedController() noexcept; /** * \~english @@ -164,7 +164,7 @@ namespace sakurajin { * * @param csPin Der CS Pin über den die Matrix gesteuert wird. */ - LedController(unsigned int csPin); + LedController(unsigned int csPin) noexcept; /** * \~english @@ -190,7 +190,7 @@ namespace sakurajin { * https://www.arduino.cc/en/Reference/SPI für die Pin Konfiguration) */ LedController(unsigned int dataPin, unsigned int clkPin, unsigned int csPin, - bool useHardwareSpi = false); + bool useHardwareSpi = false) noexcept; /** * \~english @@ -204,7 +204,7 @@ namespace sakurajin { * * @param configuration die Konfiguration die zum erstellen verwendet werden soll. */ - LedController(const sakurajin::controller_configuration &configuration); + LedController(const sakurajin::controller_configuration &configuration) noexcept; /** * \~english @@ -213,7 +213,7 @@ namespace sakurajin { * \~german * @brief Zerstöre das Objekt und leere den Speicher. */ - ~LedController(); + ~LedController() noexcept; /** * \~english @@ -226,7 +226,7 @@ namespace sakurajin { * * @param other der LedController, der kopiert werden soll. */ - LedController(const LedController &other); + LedController(const LedController &other) noexcept; /** * \~english @@ -243,7 +243,7 @@ namespace sakurajin { * * @param csPin Der Pin um die LedMatrix auszuwählen. */ - void init(unsigned int csPin); + void init(unsigned int csPin) noexcept; /** * \~english @@ -269,7 +269,7 @@ namespace sakurajin { * https://www.arduino.cc/en/Reference/SPI für die Pin Konfiguration) */ void init(unsigned int dataPin, unsigned int clkPin, unsigned int csPin, - bool useHardwareSpi = false); + bool useHardwareSpi = false) noexcept; /** * \~english @@ -282,7 +282,7 @@ namespace sakurajin { * * @param configuration Die Konfiguration, die verwendet werden soll. */ - void init(const sakurajin::controller_configuration &configuration); + void init(const sakurajin::controller_configuration &configuration) noexcept; /** * \~english @@ -297,7 +297,7 @@ namespace sakurajin { * @return true der LedController ist initialisiert * @return false der LedController ist nicht initialisiert */ - bool isInitilized(); + bool isInitilized() noexcept; /** * \~english @@ -312,7 +312,7 @@ namespace sakurajin { * die nicht benötigt werden oder verringere die Helligkeit. * @param newIntesityLevel the new brightness of the matrix. (0..15) */ - void setIntensity(unsigned int newIntesityLevel); + void setIntensity(unsigned int newIntesityLevel) noexcept; /** * \~english @@ -328,7 +328,7 @@ namespace sakurajin { * @param segmentindex Die Nummer des gewünschten Segments * @param data Die Daten, die angezeigt werden sollen. */ - void displayOnSegment(unsigned int segmentindex, sakurajin::ByteBlock data); + void displayOnSegment(unsigned int segmentindex, sakurajin::ByteBlock data) noexcept; /** * \~english @@ -346,7 +346,7 @@ namespace sakurajin { * @param row_num Die Zeile in der das Segment ist. * @param data Die Daten, die angezeigt werden sollen. */ - void displayOnSegment(unsigned int column, unsigned int row_num, sakurajin::ByteBlock data); + void displayOnSegment(unsigned int column, unsigned int row_num, sakurajin::ByteBlock data) noexcept; /** * \~english @@ -363,7 +363,7 @@ namespace sakurajin { * @param row_num Die Zeile in der das Segment ist. * @return sakurajin::ByteBlock Die Daten, die in dem Segment angezeigt werden. */ - sakurajin::ByteBlock getSegmentData(unsigned int column, unsigned int row_num); + sakurajin::ByteBlock getSegmentData(unsigned int column, unsigned int row_num) noexcept; /** * \~english @@ -378,7 +378,7 @@ namespace sakurajin { * @param segmentindex Die Nummer des gewünschten Segments * @return sakurajin::ByteBlock Die Daten, die in dem Segment angezeigt werden. */ - sakurajin::ByteBlock getSegmentData(unsigned int segmentindex); + sakurajin::ByteBlock getSegmentData(unsigned int segmentindex) noexcept; /** * \~english @@ -387,7 +387,7 @@ namespace sakurajin { * \~german * @brief aktiviere alle Segmente, setzte alle auf die gleiche Helligkeit und leere den Inhalt. */ - void resetMatrix(); + void resetMatrix() noexcept; /** * \~english @@ -396,7 +396,7 @@ namespace sakurajin { * \~german * @brief leere alle Segmente (alle LEDs aus). */ - void clearMatrix(); + void clearMatrix() noexcept; /** * \~english @@ -409,7 +409,7 @@ namespace sakurajin { * * @param segmentNumber Die Nummer des gewünschten Segments. */ - void clearSegment(unsigned int segmentNumber); + void clearSegment(unsigned int segmentNumber) noexcept; /** * \~english @@ -422,7 +422,7 @@ namespace sakurajin { * * @return unsigned int Die Anzahl aller konfigurierten Segemente. */ - unsigned int getSegmentCount(); + unsigned int getSegmentCount() noexcept; /** * \~english @@ -435,7 +435,7 @@ namespace sakurajin { * * @param segmentNumber Die Nummer des gewünschten Segments. */ - void shutdownSegment(unsigned int segmentNumber); + void shutdownSegment(unsigned int segmentNumber) noexcept; /** * \~english @@ -448,7 +448,7 @@ namespace sakurajin { * * @param segmentNumber Die Nummer des gewünschten Segments. */ - void activateSegment(unsigned int segmentNumber); + void activateSegment(unsigned int segmentNumber) noexcept; /** * \~english @@ -457,7 +457,7 @@ namespace sakurajin { * \~german * @brief Deaktiviere alle Segmente. */ - void shutdownAllSegments(); + void shutdownAllSegments() noexcept; /** * \~english @@ -466,7 +466,7 @@ namespace sakurajin { * \~german * @brief Aktiviere alle Segmente. */ - void activateAllSegments(); + void activateAllSegments() noexcept; /** * \~english @@ -482,7 +482,7 @@ namespace sakurajin { * @param segmentNumber Die nummer des gewünschten Segments. * @param limit Die Anzahl der Zeilen/Stellen die angezwigt werden sollen (0..7) */ - void setScanLimit(unsigned int segmentNumber, unsigned int limit); + void setScanLimit(unsigned int segmentNumber, unsigned int limit) noexcept; /** * \~english @@ -499,7 +499,7 @@ namespace sakurajin { * @param row Die Reihe in dem Segment, welche gesetzte werden soll. * @param value Der Wert der gesetzt werden soll. */ - void setRow(unsigned int segmentNumber, unsigned int row, byte value); + void setRow(unsigned int segmentNumber, unsigned int row, byte value) noexcept; /** * \~english @@ -516,7 +516,7 @@ namespace sakurajin { * @param row Die Reihe in dem Segment, welche gewünscht ist. * @return byte Der Wert, der angezeigt wird. */ - byte getRow(unsigned int segmentNumber, unsigned int row); + byte getRow(unsigned int segmentNumber, unsigned int row) noexcept; /** * \~english @@ -536,7 +536,7 @@ namespace sakurajin { * @param state true wenn sie an sein soll, ansonsten false */ void setLed(unsigned int segmentNumber, unsigned int row, unsigned int column, - boolean state); + boolean state) noexcept; /** * \~english @@ -553,7 +553,7 @@ namespace sakurajin { * @param col die Spalte im Segment * @param value Der Wert der gesetzt werden soll. */ - void setColumn(unsigned int segmentNumber, unsigned int col, byte value); + void setColumn(unsigned int segmentNumber, unsigned int col, byte value) noexcept; /** * \~english @@ -573,7 +573,7 @@ namespace sakurajin { * @param dp true wenn der Dezimalpunkt gesetzt werden soll. */ void setDigit(unsigned int segmentNumber, unsigned int digit, byte value, - boolean dp); + boolean dp) noexcept; /** * \~english @@ -599,7 +599,7 @@ namespace sakurajin { * @param dp true wenn der Dezimalpunkt gesetzt werden soll. */ void setChar(unsigned int segmentNumber, unsigned int digit, char value, - boolean dp); + boolean dp) noexcept; /** * \~english @@ -609,7 +609,7 @@ namespace sakurajin { * \~german * @brief Lädt alle Segmente neu (zurücksetzten und dann updaten). */ - void refreshSegments(); + void refreshSegments() noexcept; /** * \~english @@ -623,7 +623,7 @@ namespace sakurajin { * * @param segmentNumber Die Nummer des gewünschten Segments */ - void refreshSegment(unsigned int segmentNumber); + void refreshSegment(unsigned int segmentNumber) noexcept; /** * \~english @@ -633,7 +633,7 @@ namespace sakurajin { * \~german * @brief Lädt den Inhalt der internen Daten auf alle Segmente hoch. */ - void updateSegments(); + void updateSegments() noexcept; /** * \~english @@ -647,7 +647,7 @@ namespace sakurajin { * * @param segmentNumber Die Nummer des gewünschten Segments */ - void updateSegment(unsigned int segmentNumber); + void updateSegment(unsigned int segmentNumber) noexcept; /** * \~english @@ -668,7 +668,7 @@ namespace sakurajin { * @warning Nur EINE ZEILE wird verschoben * @return byte Die Daten, die links rausgeschoben werden. */ - byte moveRowLeft(byte shiftedInColumn = 0x00, unsigned int row_num = 0); + byte moveRowLeft(byte shiftedInColumn = 0x00, unsigned int row_num = 0) noexcept; /** * \~english @@ -689,7 +689,7 @@ namespace sakurajin { * @warning Nur EINE ZEILE wird verschoben * @return byte Die Daten, die rechts rausgeschoben werden. */ - byte moveRowRight(byte shiftedInColumn = 0x00, unsigned int row_num = 0); + byte moveRowRight(byte shiftedInColumn = 0x00, unsigned int row_num = 0) noexcept; /** * \~english @@ -708,7 +708,7 @@ namespace sakurajin { * @warning Nur EINE SPALTE wird verschoben * @return byte Die Daten, die oben rausgeschoben werden. */ - byte moveColumnUp(byte shiftedInRow = 0x00, unsigned int col_num = 0); + byte moveColumnUp(byte shiftedInRow = 0x00, unsigned int col_num = 0) noexcept; /** * \~english @@ -727,7 +727,7 @@ namespace sakurajin { * @warning Nur EINE SPALTE wird verschoben * @return byte Die Daten, die unten rausgeschoben werden. */ - byte moveColumnDown(byte shiftedInRow = 0x00, unsigned int col_num = 0); + byte moveColumnDown(byte shiftedInRow = 0x00, unsigned int col_num = 0) noexcept; /** * \~english @@ -738,7 +738,7 @@ namespace sakurajin { * @brief Schibet die Daten eins nach oben und 0x00 wird unten reingeschoben. * @return sakurajin::ByteRow Die Reihen die rausgeschoben werden. */ - sakurajin::ByteRow moveUp(); + sakurajin::ByteRow moveUp() noexcept; /** * \~english @@ -749,7 +749,7 @@ namespace sakurajin { * @brief Schibet die Daten eins nach unten und 0x00 wird oben reingeschoben. * @return sakurajin::ByteRow Die Reihen die rausgeschoben werden. */ - sakurajin::ByteRow moveDown(); + sakurajin::ByteRow moveDown() noexcept; /** * \~english @@ -760,7 +760,7 @@ namespace sakurajin { * @brief Schibet die Daten eins nach links und 0x00 wird recht reingeschoben. * @return sakurajin::ByteRow Die Splaten die rausgeschoben werden. */ - sakurajin::ByteRow moveLeft(); + sakurajin::ByteRow moveLeft() noexcept; /** * \~english @@ -771,7 +771,7 @@ namespace sakurajin { * @brief Schibet die Daten eins nach rechts und 0x00 wird links reingeschoben. * @return sakurajin::ByteRow Die Splaten die rausgeschoben werden. */ - sakurajin::ByteRow moveRight(); + sakurajin::ByteRow moveRight() noexcept; /** * \~english @@ -786,7 +786,7 @@ namespace sakurajin { * @param shiftedInColumn Die Splaten die reingeschoben werden. * @return sakurajin::ByteRow Die Splaten die rausgeschoben werden. */ - sakurajin::ByteRow moveLeft(const sakurajin::ByteRow& shiftedInColumn); + sakurajin::ByteRow moveLeft(const sakurajin::ByteRow& shiftedInColumn) noexcept; /** * \~english @@ -801,7 +801,7 @@ namespace sakurajin { * @param shiftedInColumn Die Splaten die reingeschoben werden. * @return sakurajin::ByteRow Die Splaten die rausgeschoben werden. */ - sakurajin::ByteRow moveRight(const sakurajin::ByteRow& shiftedInColumn); + sakurajin::ByteRow moveRight(const sakurajin::ByteRow& shiftedInColumn) noexcept; /** * \~english @@ -816,7 +816,7 @@ namespace sakurajin { * @param shiftedInColumn Die Reihen die reingeschoben werden. * @return sakurajin::ByteRow Die Reihen die rausgeschoben werden. */ - sakurajin::ByteRow moveUp(const sakurajin::ByteRow& shiftedInColumn); + sakurajin::ByteRow moveUp(const sakurajin::ByteRow& shiftedInColumn) noexcept; /** * \~english @@ -831,7 +831,7 @@ namespace sakurajin { * @param shiftedInColumn Die Reihen die reingeschoben werden. * @return sakurajin::ByteRow Die Reihen die rausgeschoben werden. */ - sakurajin::ByteRow moveDown(const sakurajin::ByteRow& shiftedInColumn); + sakurajin::ByteRow moveDown(const sakurajin::ByteRow& shiftedInColumn) noexcept; /** * \~english @@ -847,7 +847,7 @@ namespace sakurajin { * @param input Das byte, das umgekehrt werden soll. * @return byte Das umgekehrte Byte */ - byte reverse(byte input); + byte reverse(byte input) noexcept; /** * \~english @@ -862,7 +862,7 @@ namespace sakurajin { * @param input Der sakurajin::ByteBlock der umgekehrt werden soll. * @return sakurajin::ByteBlock Der umgekehrte sakurajin::ByteBlock. */ - sakurajin::ByteBlock reverse(sakurajin::ByteBlock input); + sakurajin::ByteBlock reverse(sakurajin::ByteBlock input) noexcept; /** * \~english @@ -877,7 +877,7 @@ namespace sakurajin { * @param rowArray Der Block aus Zeilen * @return sakurajin::ByteBlock Die Splaten des gegebenen Blocks */ - sakurajin::ByteBlock makeColumns(sakurajin::ByteBlock rowArray); + sakurajin::ByteBlock makeColumns(sakurajin::ByteBlock rowArray) noexcept; /** * \~english @@ -892,7 +892,7 @@ namespace sakurajin { * @param input Der zu rotierende sakurajin::ByteBlock. * @return sakurajin::ByteBlock Der rotierte byteBlock. */ - sakurajin::ByteBlock rotate180(sakurajin::ByteBlock input); + sakurajin::ByteBlock rotate180(sakurajin::ByteBlock input) noexcept; /** * \~english @@ -905,7 +905,7 @@ namespace sakurajin { * * @return controlller_configuration Die aktuelle Konfiguration */ - const sakurajin::controller_configuration& getConfig(); + const sakurajin::controller_configuration& getConfig() noexcept; //The following methods are deprecated and will be removed in the future //They only exist to help the transition to a new version @@ -923,7 +923,7 @@ namespace sakurajin { * @warning ONLY moves row 0, this function exists for backwards compatibility * @return byte The column that gets shifted out on the left */ - byte moveLeft(byte shiftedInColumn); + byte moveLeft(byte shiftedInColumn) noexcept; /** * \~ @@ -937,7 +937,7 @@ namespace sakurajin { * @warning ONLY moves row 0, this function exists for backwards compatibility * @return byte The column that gets shifted out on the right */ - byte moveRight(byte shiftedInColumn); + byte moveRight(byte shiftedInColumn) noexcept; /** * \~ @@ -950,7 +950,7 @@ namespace sakurajin { * @param row_num the row where the wanted segment is * @param resultLocation the location where the data should be stored */ - void getSegmentData(unsigned int column, unsigned int row_num, sakurajin::ByteBlock* resultLocation); + void getSegmentData(unsigned int column, unsigned int row_num, sakurajin::ByteBlock* resultLocation) noexcept; /** * \~ @@ -962,7 +962,7 @@ namespace sakurajin { * @param segmentindex the index of whose data you want to have * @param resultLocation the location where the data should be stored */ - void getSegmentData(unsigned int segmentindex, sakurajin::ByteBlock *resultLocation); + void getSegmentData(unsigned int segmentindex, sakurajin::ByteBlock *resultLocation) noexcept; /** * \~ @@ -974,7 +974,7 @@ namespace sakurajin { * @param rowArray the array of rows of which you want the columns * @param columnArray The address where the result will be stored */ - void makeColumns(sakurajin::ByteBlock rowArray, sakurajin::ByteBlock *columnArray); + void makeColumns(sakurajin::ByteBlock rowArray, sakurajin::ByteBlock *columnArray) noexcept; /** * \~ @@ -986,7 +986,7 @@ namespace sakurajin { * @param input The array that should be mirrored * @param reversedInput The address where the result will be stored */ - void reverse(sakurajin::ByteBlock input, sakurajin::ByteBlock *reversedInput); + void reverse(sakurajin::ByteBlock input, sakurajin::ByteBlock *reversedInput) noexcept; /** * \~ @@ -998,7 +998,7 @@ namespace sakurajin { * @param input the array that will be rotated * @param rotatedInput The address where the result will be stored */ - void rotate180(sakurajin::ByteBlock input, sakurajin::ByteBlock *rotatedInput); + void rotate180(sakurajin::ByteBlock input, sakurajin::ByteBlock *rotatedInput) noexcept; /** * \~ @@ -1012,7 +1012,7 @@ namespace sakurajin { * @param shiftedOutRow The address of the row that will be shifted out on the * bottom */ - void moveUp(const sakurajin::ByteRow& shiftedInRow, sakurajin::ByteRow* shiftedOutRow); + void moveUp(const sakurajin::ByteRow& shiftedInRow, sakurajin::ByteRow* shiftedOutRow) noexcept; /** * \~ @@ -1026,7 +1026,7 @@ namespace sakurajin { * @param shiftedOutRow The address of the row that will be shifted out on the * bottom */ - void moveDown(const sakurajin::ByteRow& shiftedInRow, sakurajin::ByteRow* shiftedOutRow); + void moveDown(const sakurajin::ByteRow& shiftedInRow, sakurajin::ByteRow* shiftedOutRow) noexcept; /** * \~ @@ -1038,7 +1038,7 @@ namespace sakurajin { * @param shiftedOutRow The address of the row that will be shifted out on the * bottom */ - void moveUp(sakurajin::ByteRow* shiftedOutRow); + void moveUp(sakurajin::ByteRow* shiftedOutRow) noexcept; /** * \~ @@ -1050,7 +1050,7 @@ namespace sakurajin { * @param shiftedOutRow The address of the row that will be shifted out on the * bottom */ - void moveDown(sakurajin::ByteRow* shiftedOutRow); + void moveDown(sakurajin::ByteRow* shiftedOutRow) noexcept; /** * \~ @@ -1064,7 +1064,7 @@ namespace sakurajin { * @param shiftedInColumn This Array contains what will be shifted in on each Row and needs to be the same size as number of rows or nullptr. * @param shiftedOutColumn This pointer to an Array will contain the bytes that will be shifted out on each Row, it should be the same size as the number of rows or nullptr. */ - void moveLeft(const sakurajin::ByteRow& shiftedInColumn, sakurajin::ByteRow* shiftedOutColumn); + void moveLeft(const sakurajin::ByteRow& shiftedInColumn, sakurajin::ByteRow* shiftedOutColumn) noexcept; /** * \~ @@ -1078,7 +1078,7 @@ namespace sakurajin { * @param shiftedInColumn This Array contains what will be shifted in on each Row and needs to be the same size as number of rows or nullptr. * @param shiftedOutColumn This pointer to an Array will contain the bytes that will be shifted out on each Row, it should be the same size as the number of rows or nullptr. */ - void moveRight(const sakurajin::ByteRow& shiftedInColumn, sakurajin::ByteRow* shiftedOutColumn); + void moveRight(const sakurajin::ByteRow& shiftedInColumn, sakurajin::ByteRow* shiftedOutColumn) noexcept; }; } @@ -1143,6 +1143,16 @@ namespace sakurajin { * Ein Beispiel wie man den LedController nutzen kann um einen Zähler mit 7-Segment Anzeigen zu erstellen. */ +/** + * @example 7-Segment-DHT-temp-humid.ino + * + * \~english + * An example on how to use the LedController to create a temparature and humidity display with 7-Segment displays. + * + * \~german + * Ein Beispiel wie man den LedController nutzen kann um eine Temperatur- und Luftfeuchtigkeitsanzeige mit 7-Segment Anzeigen zu erstellen. + */ + /** * @example LCDemo7Segment.ino * diff --git a/src/implementations/LedController_MAX72XX.cpp b/src/implementations/LedController_MAX72XX.cpp index 0d0a6aba..c6350d27 100644 --- a/src/implementations/LedController_MAX72XX.cpp +++ b/src/implementations/LedController_MAX72XX.cpp @@ -1,6 +1,6 @@ #include "LedController_MAX72XX.hpp" -sakurajin::MAX72XX::MAX72XX():table( +sakurajin::MAX72XX::MAX72XX() noexcept:table( B01111110, B00110000, B01101101, B01111001, B00110011, B01011011, B01011111, B01110000, B01111111, B01111011, B01110111, B00011111, B00001101, B00111101, B01001111, B01000111, B00000000, B00000000, B00000000, B00000000, B00000000, diff --git a/src/implementations/LedController_core.hpp b/src/implementations/LedController_core.hpp index 370be0dd..44862e04 100644 --- a/src/implementations/LedController_core.hpp +++ b/src/implementations/LedController_core.hpp @@ -1,31 +1,31 @@ #include "LedController.hpp" template -sakurajin::LedController::~LedController() { +sakurajin::LedController::~LedController() noexcept { initilized = false; } template -sakurajin::LedController::LedController() {}; +sakurajin::LedController::LedController() noexcept {}; template -sakurajin::LedController::LedController(unsigned int csPin) { +sakurajin::LedController::LedController(unsigned int csPin) noexcept { init(csPin); }; template sakurajin::LedController::LedController(unsigned int dataPin, unsigned int clkPin, - unsigned int csPin, bool useHardwareSpiParam) { + unsigned int csPin, bool useHardwareSpiParam) noexcept { init(dataPin, clkPin, csPin, useHardwareSpiParam); } template -sakurajin::LedController::LedController(const sakurajin::controller_configuration &config) { +sakurajin::LedController::LedController(const sakurajin::controller_configuration &config) noexcept { init(config); }; template -sakurajin::LedController::LedController(const sakurajin::LedController &other) { +sakurajin::LedController::LedController(const sakurajin::LedController &other) noexcept { if (!other.initilized) { return; } @@ -46,7 +46,7 @@ sakurajin::LedController::LedController(const sakurajin::LedContro } template -void sakurajin::LedController::init(unsigned int csPin) { +void sakurajin::LedController::init(unsigned int csPin) noexcept { sakurajin::controller_configuration config; config.SPI_CS = csPin; @@ -57,7 +57,7 @@ void sakurajin::LedController::init(unsigned int csPin) { template void sakurajin::LedController::init(unsigned int dataPin, unsigned int clkPin, - unsigned int csPin, bool useHardwareSpiParam) { + unsigned int csPin, bool useHardwareSpiParam) noexcept { if (initilized) { return; } @@ -73,7 +73,7 @@ void sakurajin::LedController::init(unsigned int dataPin, unsigned } template -void sakurajin::LedController::init(const sakurajin::controller_configuration &configuration) { +void sakurajin::LedController::init(const sakurajin::controller_configuration &configuration) noexcept { if (initilized) { return; } @@ -91,7 +91,7 @@ void sakurajin::LedController::init(const sakurajin::controller_co } template -void sakurajin::LedController::initConf() { +void sakurajin::LedController::initConf() noexcept { if (conf.useHardwareSpi) { conf.SPI_CLK = SCK; conf.SPI_MOSI = MOSI; @@ -101,7 +101,7 @@ void sakurajin::LedController::initConf() { } template -void sakurajin::LedController::initSPI() { +void sakurajin::LedController::initSPI() noexcept { pinMode(conf.SPI_MOSI, OUTPUT); pinMode(conf.SPI_CLK, OUTPUT); @@ -131,32 +131,30 @@ void sakurajin::LedController::initSPI() { } template -bool sakurajin::LedController::isInitilized() { +bool sakurajin::LedController::isInitilized() noexcept { return initilized; } // to be remvoed for version 2.2.0 template -void sakurajin::LedController::getSegmentData(unsigned int column, unsigned int row_num, sakurajin::ByteBlock* resultLocation) { +void sakurajin::LedController::getSegmentData(unsigned int column, unsigned int row_num, sakurajin::ByteBlock* resultLocation) noexcept { getSegmentData(conf.getSegmentNumber(column,row_num),resultLocation); } // to be removed for version 2.2.0 template void sakurajin::LedController::getSegmentData(unsigned int segmentindex, - sakurajin::ByteBlock *resultLocation) { + sakurajin::ByteBlock *resultLocation) noexcept { if (!initilized || segmentindex >= conf.SegmentCount() || resultLocation == nullptr) { return; } - for (unsigned int i = 0; i < 8; i++) { - (*resultLocation)[i] = LedStates[segmentindex][i]; - } + *resultLocation = getSegmentData(segmentindex); } template -sakurajin::ByteBlock sakurajin::LedController::getSegmentData(unsigned int segmentindex) { +sakurajin::ByteBlock sakurajin::LedController::getSegmentData(unsigned int segmentindex) noexcept { if (!initilized || segmentindex >= conf.SegmentCount()) { return sakurajin::ByteBlock(); }; @@ -164,16 +162,16 @@ sakurajin::ByteBlock sakurajin::LedController::getSegmentData(unsi } template -sakurajin::ByteBlock sakurajin::LedController::getSegmentData(unsigned int column, unsigned int row_num) { +sakurajin::ByteBlock sakurajin::LedController::getSegmentData(unsigned int column, unsigned int row_num) noexcept { return getSegmentData(conf.getSegmentNumber(column,row_num)); } template -unsigned int sakurajin::LedController::getSegmentCount() { +unsigned int sakurajin::LedController::getSegmentCount() noexcept { return columns*rows; } template -const sakurajin::controller_configuration& sakurajin::LedController::getConfig() { +const sakurajin::controller_configuration& sakurajin::LedController::getConfig() noexcept { return conf; } diff --git a/src/implementations/LedController_display.hpp b/src/implementations/LedController_display.hpp index e82b6544..487fef64 100644 --- a/src/implementations/LedController_display.hpp +++ b/src/implementations/LedController_display.hpp @@ -15,7 +15,7 @@ #include "LedController_MAX72XX.hpp" template -void sakurajin::LedController::resetBuffers() { +void sakurajin::LedController::resetBuffers() noexcept { for (unsigned int j = 0; j < rows*columns*2; j++) { spidata[j] = j%2 == 0 ? 0x00 : sakurajin::MAX72XX::OP_NOOP; } @@ -28,7 +28,7 @@ void sakurajin::LedController::resetBuffers() { } template -void sakurajin::LedController::resetMatrix() { +void sakurajin::LedController::resetMatrix() noexcept { if (!initilized) { return; } @@ -39,7 +39,7 @@ void sakurajin::LedController::resetMatrix() { } template -void sakurajin::LedController::clearMatrix() { +void sakurajin::LedController::clearMatrix() noexcept { if (!initilized) { return; } @@ -51,7 +51,7 @@ void sakurajin::LedController::clearMatrix() { template void sakurajin::LedController::displayOnSegment(unsigned int segmentindex, - sakurajin::ByteBlock data) { + sakurajin::ByteBlock data) noexcept { if (!initilized || segmentindex >= conf.SegmentCount()) { return; } @@ -62,13 +62,13 @@ void sakurajin::LedController::displayOnSegment(unsigned int segme } template -void sakurajin::LedController::displayOnSegment(unsigned int column, unsigned int row_num, sakurajin::ByteBlock data) { +void sakurajin::LedController::displayOnSegment(unsigned int column, unsigned int row_num, sakurajin::ByteBlock data) noexcept { displayOnSegment(conf.getSegmentNumber(column,row_num),data); } template -void sakurajin::LedController::shutdownSegment(unsigned int segmentNumber) { +void sakurajin::LedController::shutdownSegment(unsigned int segmentNumber) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount()) { return; } @@ -77,7 +77,7 @@ void sakurajin::LedController::shutdownSegment(unsigned int segmen } template -void sakurajin::LedController::activateSegment(unsigned int segmentNumber) { +void sakurajin::LedController::activateSegment(unsigned int segmentNumber) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount()) { return; } @@ -86,7 +86,7 @@ void sakurajin::LedController::activateSegment(unsigned int segmen } template -void sakurajin::LedController::shutdownAllSegments() { +void sakurajin::LedController::shutdownAllSegments() noexcept { if (!initilized) { return; } @@ -97,7 +97,7 @@ void sakurajin::LedController::shutdownAllSegments() { } template -void sakurajin::LedController::activateAllSegments() { +void sakurajin::LedController::activateAllSegments() noexcept { if (!initilized) { return; } @@ -108,7 +108,7 @@ void sakurajin::LedController::activateAllSegments() { } template -void sakurajin::LedController::clearSegment(unsigned int segmentNumber) { +void sakurajin::LedController::clearSegment(unsigned int segmentNumber) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount()) { return; } @@ -121,7 +121,7 @@ void sakurajin::LedController::clearSegment(unsigned int segmentNu template void sakurajin::LedController::setRow(unsigned int segmentNumber, unsigned int row, - byte value) { + byte value) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount() || row > 7 || (conf.onlySendOnChange && LedStates[segmentNumber][row] == value)) { return; @@ -132,7 +132,7 @@ void sakurajin::LedController::setRow(unsigned int segmentNumber, } template -byte sakurajin::LedController::getRow(unsigned int segmentNumber, unsigned int row) { +byte sakurajin::LedController::getRow(unsigned int segmentNumber, unsigned int row) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount() || row > 7) { return 0x00; } @@ -142,13 +142,13 @@ byte sakurajin::LedController::getRow(unsigned int segmentNumber, template void sakurajin::LedController::setLed(unsigned int segmentNumber, unsigned int row, - unsigned int column, boolean state) { + unsigned int column, boolean state) noexcept { if (!initilized || row > 7 || column > 7 || segmentNumber >= conf.SegmentCount()) { return; }; - byte val = 0x80 >> column; + byte val = 0x01 << column; if (state) val |= LedStates[segmentNumber][row]; @@ -162,25 +162,20 @@ void sakurajin::LedController::setLed(unsigned int segmentNumber, template void sakurajin::LedController::setColumn(unsigned int segmentNumber, unsigned int col, - byte value) { + byte value) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount() || col > 7) { return; }; - byte val; + ByteBlock val = LedStates[segmentNumber].transpose(); + val[col] = value; + displayOnSegment(segmentNumber,val.transpose()); - for (int row = 0; row < 8; row++) { - val = value >> row; - val &= 0x01; - val <<= col; - val |= LedStates[segmentNumber][row]; - setRow(segmentNumber, row, val); - } } template void sakurajin::LedController::setDigit(unsigned int segmentNumber, unsigned int digit, - byte value, boolean dp) { + byte value, boolean dp) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount() || digit > 7) { return; }; @@ -195,7 +190,7 @@ void sakurajin::LedController::setDigit(unsigned int segmentNumber template void sakurajin::LedController::setChar(unsigned int segmentNumber, unsigned int digit, - char value, boolean dp) { + char value, boolean dp) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount() || digit > 7) { return; }; @@ -210,7 +205,7 @@ void sakurajin::LedController::setChar(unsigned int segmentNumber, } template -void sakurajin::LedController::refreshSegments() { +void sakurajin::LedController::refreshSegments() noexcept { if (!initilized) { return; } @@ -221,7 +216,7 @@ void sakurajin::LedController::refreshSegments() { } template -void sakurajin::LedController::updateSegments() { +void sakurajin::LedController::updateSegments() noexcept { if (!initilized) { return; } @@ -232,7 +227,7 @@ void sakurajin::LedController::updateSegments() { } template -void sakurajin::LedController::updateSegment(unsigned int segmentNumber) { +void sakurajin::LedController::updateSegment(unsigned int segmentNumber) noexcept { if (!initilized) { return; } diff --git a/src/implementations/LedController_low_level.hpp b/src/implementations/LedController_low_level.hpp index 677c24db..dbfdf7eb 100644 --- a/src/implementations/LedController_low_level.hpp +++ b/src/implementations/LedController_low_level.hpp @@ -14,7 +14,7 @@ #include "LedController_MAX72XX.hpp" template -void sakurajin::LedController::spiTransfer(unsigned int segment, byte opcode, byte data) { +void sakurajin::LedController::spiTransfer(unsigned int segment, byte opcode, byte data) noexcept { if (!initilized || segment >= conf.SegmentCount()) { return; } @@ -90,7 +90,7 @@ void sakurajin::LedController::spiTransfer(unsigned int segment, b template void sakurajin::LedController::setScanLimit(unsigned int segmentNumber, - unsigned int limit) { + unsigned int limit) noexcept { if (!initilized || segmentNumber >= conf.SegmentCount()) { return; }; @@ -100,7 +100,7 @@ void sakurajin::LedController::setScanLimit(unsigned int segmentNu } template -void sakurajin::LedController::setIntensity(unsigned int newIntesityLevel) { +void sakurajin::LedController::setIntensity(unsigned int newIntesityLevel) noexcept { if (newIntesityLevel > 15 || !initilized) { return; } @@ -115,7 +115,7 @@ void sakurajin::LedController::setIntensity(unsigned int newIntesi template void sakurajin::LedController::setIntensity(unsigned int segmentNumber, - unsigned int newIntesityLevel) { + unsigned int newIntesityLevel) noexcept { if (newIntesityLevel > 15 || !initilized || segmentNumber >= conf.SegmentCount()) { return; @@ -125,7 +125,7 @@ void sakurajin::LedController::setIntensity(unsigned int segmentNu } template -void sakurajin::LedController::refreshSegment(unsigned int segmentNumber) { +void sakurajin::LedController::refreshSegment(unsigned int segmentNumber) noexcept { if (!initilized) { return; } diff --git a/src/implementations/LedController_movement.hpp b/src/implementations/LedController_movement.hpp index 96420432..a7b9c8e4 100644 --- a/src/implementations/LedController_movement.hpp +++ b/src/implementations/LedController_movement.hpp @@ -13,7 +13,7 @@ #include "LedController_template.hpp" template -byte sakurajin::LedController::moveRowRight(byte shiftedInColumn, unsigned int row_num) { +byte sakurajin::LedController::moveRowRight(byte shiftedInColumn, unsigned int row_num) noexcept { if (!initilized || row_num >= rows) { return 0x00; } @@ -46,7 +46,7 @@ byte sakurajin::LedController::moveRowRight(byte shiftedInColumn, } template -byte sakurajin::LedController::moveRowLeft(byte shiftedInColumn, unsigned int row_num) { +byte sakurajin::LedController::moveRowLeft(byte shiftedInColumn, unsigned int row_num) noexcept { if (!initilized || row_num >= rows) { return 0x00; } @@ -79,7 +79,7 @@ byte sakurajin::LedController::moveRowLeft(byte shiftedInColumn, u } template -byte sakurajin::LedController::moveColumnUp(byte shiftedInRow, unsigned int col_num) { +byte sakurajin::LedController::moveColumnUp(byte shiftedInRow, unsigned int col_num) noexcept { if (!initilized) { return 0x00; } @@ -114,7 +114,7 @@ byte sakurajin::LedController::moveColumnUp(byte shiftedInRow, uns } template -byte sakurajin::LedController::moveColumnDown(byte shiftedInRow, unsigned int col_num) { +byte sakurajin::LedController::moveColumnDown(byte shiftedInRow, unsigned int col_num) noexcept { if (!initilized) { return 0x00; } @@ -144,27 +144,27 @@ byte sakurajin::LedController::moveColumnDown(byte shiftedInRow, u //functions that abstract the basic functions above template -sakurajin::ByteRow sakurajin::LedController::moveDown() { +sakurajin::ByteRow sakurajin::LedController::moveDown() noexcept { return moveDown(sakurajin::ByteRow()); } template -sakurajin::ByteRow sakurajin::LedController::moveUp() { +sakurajin::ByteRow sakurajin::LedController::moveUp() noexcept { return moveUp(sakurajin::ByteRow()); } template -sakurajin::ByteRow sakurajin::LedController::moveLeft() { +sakurajin::ByteRow sakurajin::LedController::moveLeft() noexcept { return moveLeft(sakurajin::ByteRow()); } template -sakurajin::ByteRow sakurajin::LedController::moveRight() { +sakurajin::ByteRow sakurajin::LedController::moveRight() noexcept { return moveRight(sakurajin::ByteRow()); } template -sakurajin::ByteRow sakurajin::LedController::moveLeft(const sakurajin::ByteRow& shiftedInColumn) { +sakurajin::ByteRow sakurajin::LedController::moveLeft(const sakurajin::ByteRow& shiftedInColumn) noexcept { sakurajin::ByteRow ret = sakurajin::ByteRow(); for(unsigned int i = 0; i < rows; i++) { ret[i] = moveRowLeft(shiftedInColumn[i],i); @@ -173,7 +173,7 @@ sakurajin::ByteRow sakurajin::LedController::moveLeft(const } template -sakurajin::ByteRow sakurajin::LedController::moveRight(const sakurajin::ByteRow& shiftedInColumn) { +sakurajin::ByteRow sakurajin::LedController::moveRight(const sakurajin::ByteRow& shiftedInColumn) noexcept { sakurajin::ByteRow ret = sakurajin::ByteRow(); for(unsigned int i = 0; i < rows; i++) { ret[i] = moveRowRight(shiftedInColumn[i],i); @@ -182,7 +182,7 @@ sakurajin::ByteRow sakurajin::LedController::moveRight(const } template -sakurajin::ByteRow sakurajin::LedController::moveUp(const sakurajin::ByteRow& shiftedInRow) { +sakurajin::ByteRow sakurajin::LedController::moveUp(const sakurajin::ByteRow& shiftedInRow) noexcept { sakurajin::ByteRow ret = sakurajin::ByteRow(); for(unsigned int i = 0; i < columns; i++) { ret[i] = moveColumnUp(shiftedInRow[i],i); @@ -191,7 +191,7 @@ sakurajin::ByteRow sakurajin::LedController::moveUp(const } template -sakurajin::ByteRow sakurajin::LedController::moveDown(const sakurajin::ByteRow& shiftedInRow) { +sakurajin::ByteRow sakurajin::LedController::moveDown(const sakurajin::ByteRow& shiftedInRow) noexcept { sakurajin::ByteRow ret = sakurajin::ByteRow(); for(unsigned int i = 0; i < columns; i++) { ret[i] = moveColumnDown(shiftedInRow[i],i); @@ -203,31 +203,31 @@ sakurajin::ByteRow sakurajin::LedController::moveDown(con //removed in version 2.1.0 template -byte sakurajin::LedController::moveLeft(byte shiftedInColumn) { +byte sakurajin::LedController::moveLeft(byte shiftedInColumn) noexcept { return moveRowLeft(shiftedInColumn,0); } //removed in version 2.1.0 template -byte sakurajin::LedController::moveRight(byte shiftedInColumn) { +byte sakurajin::LedController::moveRight(byte shiftedInColumn) noexcept { return moveRowRight(shiftedInColumn,0); } // to be removed for version 2.2.0 template -void sakurajin::LedController::moveUp(sakurajin::ByteRow* shiftedOutRow) { +void sakurajin::LedController::moveUp(sakurajin::ByteRow* shiftedOutRow) noexcept { moveUp(sakurajin::ByteRow(), shiftedOutRow); }; // to be removed for version 2.2.0 template -void sakurajin::LedController::moveDown(sakurajin::ByteRow* shiftedOutRow) { +void sakurajin::LedController::moveDown(sakurajin::ByteRow* shiftedOutRow) noexcept { moveDown(sakurajin::ByteRow(), shiftedOutRow); } // to be removed for version 2.2.0 template -void sakurajin::LedController::moveDown(const sakurajin::ByteRow& shiftedInRow, sakurajin::ByteRow* shiftedOutRow) { +void sakurajin::LedController::moveDown(const sakurajin::ByteRow& shiftedInRow, sakurajin::ByteRow* shiftedOutRow) noexcept { if(shiftedOutRow == nullptr) { moveDown(shiftedInRow); } else { @@ -237,7 +237,7 @@ void sakurajin::LedController::moveDown(const sakurajin::ByteRow -void sakurajin::LedController::moveUp(const sakurajin::ByteRow& shiftedInRow, sakurajin::ByteRow* shiftedOutRow) { +void sakurajin::LedController::moveUp(const sakurajin::ByteRow& shiftedInRow, sakurajin::ByteRow* shiftedOutRow) noexcept { if(shiftedOutRow == nullptr) { moveUp(shiftedInRow); } else { @@ -247,7 +247,7 @@ void sakurajin::LedController::moveUp(const sakurajin::ByteRow -void sakurajin::LedController::moveLeft(const sakurajin::ByteRow& shiftedInColumn, sakurajin::ByteRow* shiftedOutColumn) { +void sakurajin::LedController::moveLeft(const sakurajin::ByteRow& shiftedInColumn, sakurajin::ByteRow* shiftedOutColumn) noexcept { if(shiftedOutColumn == nullptr) { moveLeft(shiftedInColumn); } else { @@ -257,7 +257,7 @@ void sakurajin::LedController::moveLeft(const sakurajin::ByteRow -void sakurajin::LedController::moveRight(const sakurajin::ByteRow& shiftedInColumn, sakurajin::ByteRow* shiftedOutColumn) { +void sakurajin::LedController::moveRight(const sakurajin::ByteRow& shiftedInColumn, sakurajin::ByteRow* shiftedOutColumn) noexcept { if(shiftedOutColumn == nullptr) { moveRight(shiftedInColumn); } else { diff --git a/src/implementations/LedController_transformation.hpp b/src/implementations/LedController_transformation.hpp index a0d21d05..8279589d 100644 --- a/src/implementations/LedController_transformation.hpp +++ b/src/implementations/LedController_transformation.hpp @@ -14,28 +14,28 @@ #include "LedController_template.hpp" template -byte sakurajin::LedController::reverse(byte var) { +byte sakurajin::LedController::reverse(byte var) noexcept { return sakurajin::ByteBlock::reverse(var); } template -sakurajin::ByteBlock sakurajin::LedController::makeColumns(sakurajin::ByteBlock rowArray) { +sakurajin::ByteBlock sakurajin::LedController::makeColumns(sakurajin::ByteBlock rowArray) noexcept { return rowArray.makeColumns(); } template -sakurajin::ByteBlock sakurajin::LedController::reverse(sakurajin::ByteBlock input) { +sakurajin::ByteBlock sakurajin::LedController::reverse(sakurajin::ByteBlock input) noexcept { return input.reverse(); } template -sakurajin::ByteBlock sakurajin::LedController::rotate180(sakurajin::ByteBlock input) { +sakurajin::ByteBlock sakurajin::LedController::rotate180(sakurajin::ByteBlock input) noexcept { return input.rotate180(); } // to be removed for version 2.2.0 template -void sakurajin::LedController::makeColumns(sakurajin::ByteBlock rowArray, sakurajin::ByteBlock *columnArray) { +void sakurajin::LedController::makeColumns(sakurajin::ByteBlock rowArray, sakurajin::ByteBlock *columnArray) noexcept { if (columnArray == nullptr) { return; }; @@ -45,7 +45,7 @@ void sakurajin::LedController::makeColumns(sakurajin::ByteBlock ro // to be removed for version 2.2.0 template -void sakurajin::LedController::reverse(sakurajin::ByteBlock input, sakurajin::ByteBlock *reversedInput) { +void sakurajin::LedController::reverse(sakurajin::ByteBlock input, sakurajin::ByteBlock *reversedInput) noexcept { if (reversedInput == nullptr) { return; } @@ -55,7 +55,7 @@ void sakurajin::LedController::reverse(sakurajin::ByteBlock input, // to be removed for version 2.2.0 template -void sakurajin::LedController::rotate180(sakurajin::ByteBlock input, sakurajin::ByteBlock *rotatedInput) { +void sakurajin::LedController::rotate180(sakurajin::ByteBlock input, sakurajin::ByteBlock *rotatedInput) noexcept { if (rotatedInput == nullptr) { return; } diff --git a/test/common/display.cpp b/test/common/display.cpp new file mode 100644 index 00000000..e688eb32 --- /dev/null +++ b/test/common/display.cpp @@ -0,0 +1,37 @@ +#include "display.hpp" + +static void test_setColumn() { + auto lc = LedController<4,1>(get_conf_SPI()); + + lc.setColumn(0,7,B11111111); + sakurajin::ByteBlock r = ByteBlock::rotate180({B00000001,B00000001,B00000001,B00000001,B00000001,B00000001,B00000001,B00000001}); + + lc.setColumn(1,0,B11111111); + sakurajin::ByteBlock s = {B00000001,B00000001,B00000001,B00000001,B00000001,B00000001,B00000001,B00000001}; + + TEST_ASSERT(lc.getSegmentData(0) == r); + TEST_ASSERT(lc.getSegmentData(1) == s); +} + +static void test_setLED(){ + auto lc = LedController<4,1>(get_conf_SPI()); + + lc.setLed(0,0,0,true); + sakurajin::ByteBlock a = ByteBlock::rotate180({B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B10000000}); + + lc.setLed(1,0,4,true); + sakurajin::ByteBlock b = ByteBlock::rotate180({B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00001000}); + + lc.setLed(2,2,0,true); + sakurajin::ByteBlock c = ByteBlock::rotate180({B00000000,B00000000,B00000000,B00000000,B00000000,B10000000,B00000000,B00000000}); + + TEST_ASSERT(lc.getSegmentData(0) == a); + TEST_ASSERT(lc.getSegmentData(1) == b); + TEST_ASSERT(lc.getSegmentData(2) == c); + +} + +void run_display_tests(){ + RUN_TEST(test_setColumn); + RUN_TEST(test_setLED); +} \ No newline at end of file diff --git a/test/common/display.hpp b/test/common/display.hpp new file mode 100644 index 00000000..074f0990 --- /dev/null +++ b/test/common/display.hpp @@ -0,0 +1,3 @@ +#include "common.hpp" + +void run_display_tests(); \ No newline at end of file diff --git a/test/common/main.cpp b/test/common/main.cpp index e23b0038..f488aa34 100644 --- a/test/common/main.cpp +++ b/test/common/main.cpp @@ -1,9 +1,11 @@ #include "Move.hpp" #include "transformation.hpp" #include "config.hpp" +#include "display.hpp" void process() { UNITY_BEGIN(); + run_display_tests(); run_config_tests(); run_transformation_tests(); run_move_tests();