Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • card10/firmware
  • annejan/firmware
  • astro/firmware
  • fpletz/firmware
  • gerd/firmware
  • fleur/firmware
  • swym/firmware
  • l/firmware
  • uberardy/firmware
  • wink/firmware
  • madonius/firmware
  • mot/firmware
  • filid/firmware
  • q3k/firmware
  • hauke/firmware
  • Woazboat/firmware
  • pink/firmware
  • mossmann/firmware
  • omniskop/firmware
  • zenox/firmware
  • trilader/firmware
  • Danukeru/firmware
  • shoragan/firmware
  • zlatko/firmware
  • sistason/firmware
  • datenwolf/firmware
  • bene/firmware
  • amedee/firmware
  • martinling/firmware
  • griffon/firmware
  • chris007/firmware
  • adisbladis/firmware
  • dbrgn/firmware
  • jelly/firmware
  • rnestler/firmware
  • mh/firmware
  • ln/firmware
  • penguineer/firmware
  • monkeydom/firmware
  • jens/firmware
  • jnaulty/firmware
  • jeffmakes/firmware
  • marekventur/firmware
  • pete/firmware
  • h2obrain/firmware
  • DooMMasteR/firmware
  • jackie/firmware
  • prof_r/firmware
  • Draradech/firmware
  • Kartoffel/firmware
  • hinerk/firmware
  • abbradar/firmware
  • JustTB/firmware
  • LuKaRo/firmware
  • iggy/firmware
  • ente/firmware
  • flgr/firmware
  • Lorphos/firmware
  • matejo/firmware
  • ceddral7/firmware
  • danb/firmware
  • joshi/firmware
  • melle/firmware
  • fitch/firmware
  • deurknop/firmware
  • sargon/firmware
  • markus/firmware
  • kloenk/firmware
  • lucaswerkmeister/firmware
  • derf/firmware
  • meh/firmware
  • dx/card10-firmware
  • torben/firmware
  • yuvadm/firmware
  • AndyBS/firmware
  • klausdieter1/firmware
  • katzenparadoxon/firmware
  • xiretza/firmware
  • ole/firmware
  • techy/firmware
  • thor77/firmware
  • TilCreator/firmware
  • fuchsi/firmware
  • dos/firmware
  • yrlf/firmware
  • PetePriority/firmware
  • SuperVirus/firmware
  • sur5r/firmware
  • tazz/firmware
  • Alienmaster/firmware
  • flo_h/firmware
  • baldo/firmware
  • mmu_man/firmware
  • Foaly/firmware
  • sodoku/firmware
  • Guinness/firmware
  • ssp/firmware
  • led02/firmware
  • Stormwind/firmware
  • arist/firmware
  • coon/firmware
  • mdik/firmware
  • pippin/firmware
  • royrobotiks/firmware
  • zigot83/firmware
  • mo_k/firmware
106 results
Select Git revision
Loading items
Show changes
Showing
with 943 additions and 92 deletions
...@@ -52,7 +52,10 @@ class CAutoDocDirective(Directive): ...@@ -52,7 +52,10 @@ class CAutoDocDirective(Directive):
env = self.state.document.settings.env env = self.state.document.settings.env
for (severity, filename, lineno, msg) in errors: for (severity, filename, lineno, msg) in errors:
if filename:
toprint = '{}:{}: {}'.format(filename, lineno, msg) toprint = '{}:{}: {}'.format(filename, lineno, msg)
else:
toprint = '{}'.format(msg)
if severity.value <= env.app.verbosity: if severity.value <= env.app.verbosity:
self.logger.log(self._log_lvl[severity], toprint, self.logger.log(self._log_lvl[severity], toprint,
...@@ -109,7 +112,7 @@ class CAutoDocDirective(Directive): ...@@ -109,7 +112,7 @@ class CAutoDocDirective(Directive):
return node.children return node.children
def setup(app): def setup(app):
app.require_sphinx('1.8') app.require_sphinx('3.0')
app.add_config_value('cautodoc_root', app.confdir, 'env') app.add_config_value('cautodoc_root', app.confdir, 'env')
app.add_config_value('cautodoc_compat', None, 'env') app.add_config_value('cautodoc_compat', None, 'env')
app.add_config_value('cautodoc_clang', None, 'env') app.add_config_value('cautodoc_clang', None, 'env')
......
...@@ -39,7 +39,10 @@ def main(): ...@@ -39,7 +39,10 @@ def main():
print(doc) print(doc)
for (severity, filename, lineno, msg) in errors: for (severity, filename, lineno, msg) in errors:
if filename:
print('{}: {}:{}: {}'.format(severity.name, print('{}: {}:{}: {}'.format(severity.name,
filename, lineno, msg), file=sys.stderr) filename, lineno, msg), file=sys.stderr)
else:
print('{}: {}'.format(severity.name, msg), file=sys.stderr)
main() main()
# Copyright (c) 2016-2017 Jani Nikula <jani@nikula.org> # Copyright (c) 2016-2017 Jani Nikula <jani@nikula.org>
# Copyright (c) 2018-2019 Bruno Santos <brunomanuelsantos@tecnico.ulisboa.pt> # Copyright (c) 2018-2020 Bruno Santos <brunomanuelsantos@tecnico.ulisboa.pt>
# Licensed under the terms of BSD 2-Clause, see LICENSE for details. # Licensed under the terms of BSD 2-Clause, see LICENSE for details.
""" """
Documentation comment extractor Documentation comment extractor
...@@ -34,7 +34,7 @@ Otherwise, documentation comments are passed through verbatim. ...@@ -34,7 +34,7 @@ Otherwise, documentation comments are passed through verbatim.
""" """
import enum import enum
import itertools import re
import sys import sys
from clang.cindex import CursorKind, TypeKind from clang.cindex import CursorKind, TypeKind
...@@ -75,18 +75,22 @@ def comment_extract(tu): ...@@ -75,18 +75,22 @@ def comment_extract(tu):
current_comment = token current_comment = token
continue continue
# Store off the token's cursor for a slight performance improvement
# instead of accessing the `cursor` property multiple times.
token_cursor = token.cursor
# cursors that are 1) never documented themselves, and 2) allowed # cursors that are 1) never documented themselves, and 2) allowed
# between comment and the actual cursor being documented # between comment and the actual cursor being documented
if (token.cursor.kind == CursorKind.INVALID_FILE or if (token_cursor.kind == CursorKind.INVALID_FILE or
token.cursor.kind == CursorKind.TYPE_REF or token_cursor.kind == CursorKind.TYPE_REF or
token.cursor.kind == CursorKind.PREPROCESSING_DIRECTIVE or token_cursor.kind == CursorKind.PREPROCESSING_DIRECTIVE or
token.cursor.kind == CursorKind.MACRO_INSTANTIATION): token_cursor.kind == CursorKind.MACRO_INSTANTIATION):
continue continue
if cursor is not None and token.cursor == cursor: if cursor is not None and token_cursor == cursor:
continue continue
cursor = token.cursor cursor = token_cursor
# Note: current_comment may be None # Note: current_comment may be None
if current_comment != None and docstr.is_doc(current_comment.spelling): if current_comment != None and docstr.is_doc(current_comment.spelling):
...@@ -125,16 +129,18 @@ def _get_macro_args(cursor): ...@@ -125,16 +129,18 @@ def _get_macro_args(cursor):
if cursor.kind != CursorKind.MACRO_DEFINITION: if cursor.kind != CursorKind.MACRO_DEFINITION:
return None return None
tokens = cursor.get_tokens()
# Use the first two tokens to make sure this starts with 'IDENTIFIER(' # Use the first two tokens to make sure this starts with 'IDENTIFIER('
x = [token for token in itertools.islice(cursor.get_tokens(), 2)] one = next(tokens)
if (len(x) != 2 or x[0].spelling != cursor.spelling or two = next(tokens, None)
x[1].spelling != '(' or x[0].extent.end != x[1].extent.start): if two is None or one.extent.end != two.extent.start or two.spelling != '(':
return None return None
# Naïve parsing of macro arguments # Naïve parsing of macro arguments
# FIXME: This doesn't handle GCC named vararg extension FOO(vararg...) # FIXME: This doesn't handle GCC named vararg extension FOO(vararg...)
args = [] args = []
for token in itertools.islice(cursor.get_tokens(), 2, None): for token in tokens:
if token.spelling == ')': if token.spelling == ')':
return args return args
elif token.spelling == ',': elif token.spelling == ',':
...@@ -161,8 +167,26 @@ def _recursive_parse(comments, cursor, nest, compat): ...@@ -161,8 +167,26 @@ def _recursive_parse(comments, cursor, nest, compat):
return _result(comment, cursor=cursor, fmt=fmt, return _result(comment, cursor=cursor, fmt=fmt,
nest=nest, name=name, args=args, compat=compat) nest=nest, name=name, args=args, compat=compat)
elif cursor.kind == CursorKind.VAR_DECL: elif cursor.kind in [CursorKind.VAR_DECL, CursorKind.FIELD_DECL]:
if cursor.kind == CursorKind.VAR_DECL:
fmt = docstr.Type.VAR fmt = docstr.Type.VAR
else:
fmt = docstr.Type.MEMBER
# If this is an array, the dimensions should be applied to the name, not
# the type.
dims = ttype.rsplit(' ', 1)[-1]
if dims.startswith('[') and dims.endswith(']'):
ttype = ttype.rsplit(' ', 1)[0]
name = name + dims
# If this is a function pointer, or an array of function pointers, the
# name should be within the parenthesis as in (*name) or (*name[N]).
fptr_type = re.sub(r'\((\*+)(\[[^]]*\])?\)', r'(\1{}\2)'.format(name),
ttype, count=1)
if fptr_type != ttype:
name = fptr_type
ttype = ''
return _result(comment, cursor=cursor, fmt=fmt, return _result(comment, cursor=cursor, fmt=fmt,
nest=nest, name=name, ttype=ttype, compat=compat) nest=nest, name=name, ttype=ttype, compat=compat)
...@@ -188,9 +212,15 @@ def _recursive_parse(comments, cursor, nest, compat): ...@@ -188,9 +212,15 @@ def _recursive_parse(comments, cursor, nest, compat):
# FIXME: Handle anonymous enumerators. # FIXME: Handle anonymous enumerators.
fmt = docstr.Type.TYPE fmts = {CursorKind.STRUCT_DECL: docstr.Type.STRUCT,
CursorKind.UNION_DECL: docstr.Type.UNION,
CursorKind.ENUM_DECL: docstr.Type.ENUM}
fmt = fmts[cursor.kind]
# name may be empty for typedefs
result = _result(comment, cursor=cursor, fmt=fmt, result = _result(comment, cursor=cursor, fmt=fmt,
nest=nest, name=ttype, compat=compat) nest=nest, name=name if name else ttype, compat=compat)
nest += 1 nest += 1
for c in cursor.get_children(): for c in cursor.get_children():
...@@ -205,12 +235,6 @@ def _recursive_parse(comments, cursor, nest, compat): ...@@ -205,12 +235,6 @@ def _recursive_parse(comments, cursor, nest, compat):
return _result(comment, cursor=cursor, fmt=fmt, return _result(comment, cursor=cursor, fmt=fmt,
nest=nest, name=name, compat=compat) nest=nest, name=name, compat=compat)
elif cursor.kind == CursorKind.FIELD_DECL:
fmt = docstr.Type.MEMBER
return _result(comment, cursor=cursor, fmt=fmt,
nest=nest, name=name, ttype=ttype, compat=compat)
elif cursor.kind == CursorKind.FUNCTION_DECL: elif cursor.kind == CursorKind.FUNCTION_DECL:
# FIXME: check args against comment # FIXME: check args against comment
# FIXME: children may contain extra stuff if the return type is a # FIXME: children may contain extra stuff if the return type is a
...@@ -261,7 +285,8 @@ def clang_diagnostics(errors, diagnostics): ...@@ -261,7 +285,8 @@ def clang_diagnostics(errors, diagnostics):
4: ErrorLevel.ERROR} 4: ErrorLevel.ERROR}
for diag in diagnostics: for diag in diagnostics:
errors.extend([(sev[diag.severity], diag.location.file.name, filename = diag.location.file.name if diag.location.file else None
errors.extend([(sev[diag.severity], filename,
diag.location.line, diag.spelling)]) diag.location.line, diag.spelling)])
# return a list of (comment, metadata) tuples # return a list of (comment, metadata) tuples
......
# Copyright (c) 2016-2017 Jani Nikula <jani@nikula.org> # Copyright (c) 2016-2020 Jani Nikula <jani@nikula.org>
# Copyright (c) 2018-2019 Bruno Santos <brunomanuelsantos@tecnico.ulisboa.pt> # Copyright (c) 2018-2020 Bruno Santos <brunomanuelsantos@tecnico.ulisboa.pt>
# Licensed under the terms of BSD 2-Clause, see LICENSE for details. # Licensed under the terms of BSD 2-Clause, see LICENSE for details.
""" """
Documentation strings manipulation library Documentation strings manipulation library
...@@ -17,6 +17,9 @@ class Type(Enum): ...@@ -17,6 +17,9 @@ class Type(Enum):
TEXT = auto() TEXT = auto()
VAR = auto() VAR = auto()
TYPE = auto() TYPE = auto()
STRUCT = auto()
UNION = auto()
ENUM = auto()
ENUM_VAL = auto() ENUM_VAL = auto()
MEMBER = auto() MEMBER = auto()
MACRO = auto() MACRO = auto()
...@@ -31,10 +34,13 @@ _doc_fmt = { ...@@ -31,10 +34,13 @@ _doc_fmt = {
Type.TEXT: (0, '\n{text}\n'), Type.TEXT: (0, '\n{text}\n'),
Type.VAR: (1, '\n.. c:var:: {ttype} {name}\n\n{text}\n'), Type.VAR: (1, '\n.. c:var:: {ttype} {name}\n\n{text}\n'),
Type.TYPE: (1, '\n.. c:type:: {name}\n\n{text}\n'), Type.TYPE: (1, '\n.. c:type:: {name}\n\n{text}\n'),
Type.ENUM_VAL: (1, '\n.. c:macro:: {name}\n\n{text}\n'), Type.STRUCT: (1, '\n.. c:struct:: {name}\n\n{text}\n'),
Type.UNION: (1, '\n.. c:union:: {name}\n\n{text}\n'),
Type.ENUM: (1, '\n.. c:enum:: {name}\n\n{text}\n'),
Type.ENUM_VAL: (1, '\n.. c:enumerator:: {name}\n\n{text}\n'),
Type.MEMBER: (1, '\n.. c:member:: {ttype} {name}\n\n{text}\n'), Type.MEMBER: (1, '\n.. c:member:: {ttype} {name}\n\n{text}\n'),
Type.MACRO: (1, '\n.. c:macro:: {name}\n\n{text}\n'), Type.MACRO: (1, '\n.. c:macro:: {name}\n\n{text}\n'),
Type.MACRO_FUNC: (1, '\n.. c:function:: {name}({args})\n\n{text}\n'), Type.MACRO_FUNC: (1, '\n.. c:macro:: {name}({args})\n\n{text}\n'),
Type.FUNC: (1, '\n.. c:function:: {ttype} {name}({args})\n\n{text}\n') Type.FUNC: (1, '\n.. c:function:: {ttype} {name}({args})\n\n{text}\n')
} }
......
# Copyright (c) 2021, Jani Nikula <jani@nikula.org>
# Licensed under the terms of BSD 2-Clause, see LICENSE for details.
"""
Read the Docs Helpers
=====================
Helpers for setting up and using Hawkmoth on Read the Docs.
"""
import os
import subprocess
def clang_setup(force=False):
"""Try to find and configure libclang location on RTD."""
if 'READTHEDOCS' in os.environ or force:
try:
result = subprocess.run(['llvm-config', '--libdir'],
check=True, capture_output=True, encoding='utf-8')
libdir = result.stdout.strip()
# For some reason there is no plain libclang.so symlink on RTD.
from clang.cindex import Config
Config.set_library_file(os.path.join(libdir, 'libclang.so.1'))
except Exception as e:
print(e)
...@@ -71,14 +71,42 @@ Dependencies ...@@ -71,14 +71,42 @@ Dependencies
brew install ninja brew install ninja
pip3 install --user meson # see https://mesonbuild.com/Getting-meson.html - you will have to add ~/.local/bin to your PATH. pip3 install --user meson # see https://mesonbuild.com/Getting-meson.html - you will have to add ~/.local/bin to your PATH.
* **python3-crc16**: Install with ``pip3 install --user crc16``. * One of two CRC packages is required. Pick one:
* **python3-pillow**: Python Image Library ``pip3 install --user pillow``.
- Ubuntu / Debian / macOS
.. code-block:: shell-session
pip3 install --user crc16
or
.. code-block:: shell-session
apt install python3-crcmod
or
.. code-block:: shell-session
pip3 install --user crcmod
- Arch - Arch
.. code-block:: shell-session .. code-block:: shell-session
pacman -S python-crc16 python-pillow pacman -S python-crc16
* **python3-pillow**: Python Image Library
.. code-block:: shell-session
pip3 install --user pillow
- Arch
.. code-block:: shell-session
pacman -S python-pillow
.. _ARM's GNU toolchain: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads .. _ARM's GNU toolchain: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads
...@@ -161,3 +189,25 @@ Otherwise, rerunning ``./bootstrap.sh`` will also clean the build-directory. ...@@ -161,3 +189,25 @@ Otherwise, rerunning ``./bootstrap.sh`` will also clean the build-directory.
(it's supposed to create a large file with 0xff in it) - this requires the (it's supposed to create a large file with 0xff in it) - this requires the
LC_ALL environment variable to be not set, or set to "C" LC_ALL environment variable to be not set, or set to "C"
(but not UTF8 or similar). (but not UTF8 or similar).
Docker
======
Alternatively, clone the ``master`` branch of the firmware repository and enter it:
.. code-block:: shell-session
$ git clone https://git.card10.badge.events.ccc.de/card10/firmware.git
$ cd firmware
Afterwards, build a docker-container which will build the firmware via:
.. code-block:: shell-session
$ docker build -f docker/Dockerfile_fwbuild -t card10-firmware-builder .
Now, you can start the container with the firmware directory mounted, which will build the
firmware into the firmware/build directory:
.. code-block:: shell-session
$ docker run -v $(pwd):/firmware card10-firmware-builder
...@@ -23,16 +23,20 @@ Last but not least, if you want to start hacking the lower-level firmware, the ...@@ -23,16 +23,20 @@ Last but not least, if you want to start hacking the lower-level firmware, the
pycardium/overview pycardium/overview
pycardium/stdlib pycardium/stdlib
pycardium/bhi160 pycardium/bhi160
pycardium/ble_hid
pycardium/bme680 pycardium/bme680
pycardium/max30001 pycardium/max30001
pycardium/max86150
pycardium/buttons pycardium/buttons
pycardium/color pycardium/color
pycardium/config
pycardium/display pycardium/display
pycardium/gpio pycardium/gpio
pycardium/leds pycardium/leds
pycardium/light-sensor pycardium/light-sensor
pycardium/os pycardium/os
pycardium/personal_state pycardium/personal_state
pycardium/png
pycardium/power pycardium/power
pycardium/pride pycardium/pride
pycardium/simple_menu pycardium/simple_menu
...@@ -52,6 +56,7 @@ Last but not least, if you want to start hacking the lower-level firmware, the ...@@ -52,6 +56,7 @@ Last but not least, if you want to start hacking the lower-level firmware, the
debugger debugger
pycardium-guide pycardium-guide
memorymap memorymap
epicardium/mutex
epicardium/sensor-streams epicardium/sensor-streams
.. toctree:: .. toctree::
...@@ -61,13 +66,18 @@ Last but not least, if you want to start hacking the lower-level firmware, the ...@@ -61,13 +66,18 @@ Last but not least, if you want to start hacking the lower-level firmware, the
epicardium/overview epicardium/overview
epicardium/api epicardium/api
epicardium-guide epicardium-guide
epicardium/internal
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
:caption: Bluetooth :caption: Bluetooth
bluetooth/overview
bluetooth/ess
bluetooth/file-transfer bluetooth/file-transfer
bluetooth/card10 bluetooth/card10
bluetooth/ecg
bluetooth/nimble
Indices and tables Indices and tables
================== ==================
......
...@@ -14,31 +14,32 @@ Epicardium ...@@ -14,31 +14,32 @@ Epicardium
Epicardium is based on `FreeRTOS <https://www.freertos.org/>`_. There are a Epicardium is based on `FreeRTOS <https://www.freertos.org/>`_. There are a
number of tasks that will have been keeping card10 running. These are: number of tasks that will have been keeping card10 running. These are:
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
| Name | ID Global | Priority | Description | | Name | ID Global | Priority | Description |
+===================+===============================+==========+===========================================+ +====================+===============================+==========+===========================================+
| `vPmicTask`_ | ``pmic_task_id`` (static) | +4 | Power Management (and Reset Button) | | `vPmicTask`_ | ``pmic_task_id`` (static) | +4 | Power Management (and Reset Button) |
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
| `vLifecycleTask`_ | ``lifecycle_task`` (static) | +3 | Control of the payload running on core 1. | | `vLifecycleTask`_ | ``lifecycle_task`` (static) | +3 | Control of the payload running on core 1. |
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
| `vBleTask`_ | ``ble_task_id`` (static) | +3 | Bluetooth Low Energy Stack | | `vBleTask`_ | ``ble_task_id`` (static) | +3 | Bluetooth Low Energy Stack |
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
| `vSerialTask`_ | ``serial_task_id`` | +3 | Serial Output via UART/CDC-ACM/BLE | | `vSerialTask`_ | ``serial_task_id`` | +3 | Serial Output via UART/CDC-ACM/BLE |
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
| `vApiDispatcher`_ | ``dispatcher_task_id`` | +2 | Epicardium API dispatcher | | `vApiDispatcher`_ | ``dispatcher_task_id`` | +2 | Epicardium API dispatcher |
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
| `vLedTask`_ | -/- | +1 | LED Animations | | `vInterruptsTask`_ | ``interrupts_task`` (static) | +2 | Interrupt dispatcher worker |
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
| `vMAX30001Task`_ | ``max30001_task_id`` (static) | +1 | `MAX30001`_ ECG driver | | `vMAX30001Task`_ | ``max30001_task_id`` (static) | +1 | `MAX30001`_ ECG driver |
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
| `vBhi160Task`_ | ``bhi160_task_id`` (static) | +1 | `BHI160`_ sensor fusion driver | | `vBhi160Task`_ | ``bhi160_task_id`` (static) | +1 | `BHI160`_ sensor fusion driver |
+-------------------+-------------------------------+----------+-------------------------------------------+ +--------------------+-------------------------------+----------+-------------------------------------------+
.. _vPmicTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/pmic.c#L281 .. _vPmicTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/pmic.c#L281
.. _vLifecycleTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/lifecycle.c#L361 .. _vLifecycleTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/lifecycle.c#L361
.. _vBleTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/ble/ble.c#L237 .. _vBleTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/ble/ble.c#L237
.. _vSerialTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/serial.c#L289 .. _vSerialTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/serial.c#L289
.. _vApiDispatcher: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/dispatcher.c#L25 .. _vApiDispatcher: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/dispatcher.c#L25
.. _vInterruptsTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/interrupts.c#L119
.. _vLedTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/personal_state.c#L58 .. _vLedTask: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/personal_state.c#L58
.. _vMAX30001Task: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/max30001.c#L378 .. _vMAX30001Task: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/max30001.c#L378
.. _vBhi160Task: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/bhi.c#L419 .. _vBhi160Task: https://git.card10.badge.events.ccc.de/card10/firmware/blob/master/epicardium/modules/bhi.c#L419
...@@ -72,11 +73,13 @@ interface with the :ref:`epicardium_api`. ...@@ -72,11 +73,13 @@ interface with the :ref:`epicardium_api`.
Note: this feature is disabled by default and has to be enabled in :ref:`card10_cfg`. A :ref:`card10_cfg` file dropped into the :ref:`usb_file_transfer` of the badge containing ``execute_elf = true`` is enough. Note: this feature is disabled by default and has to be enabled in :ref:`card10_cfg`. A :ref:`card10_cfg` file dropped into the :ref:`usb_file_transfer` of the badge containing ``execute_elf = true`` is enough.
l0dables are currently built within the source tree of the main repository. See ``l0dables/blinky`` for an example of a hello-world-like program. Within those programs, you can access the :ref:`epicardium_api` to control the hardware and behaviour of the badge. l0dables are currently built within the source tree of the main repository. See |l0dables_blinky|_ for an example of a hello-world-like program. Within those programs, you can access the :ref:`epicardium_api` to control the hardware and behaviour of the badge.
Once you have a built ELF file, you can drop it into the FAT filesystem of the flash (eg. via :ref:`usb_file_transfer`) and it will be available from the menu program of the badge. Once you have a built ELF file, you can drop it into the FAT filesystem of the flash (eg. via :ref:`usb_file_transfer`) and it will be available from the menu program of the badge.
.. _Rustcardium: https://git.card10.badge.events.ccc.de/astro/rust-card10 .. _Rustcardium: https://git.card10.badge.events.ccc.de/astro/rust-card10
.. |l0dables_blinky| replace:: ``l0dables/blinky``
.. _l0dables_blinky: https://git.card10.badge.events.ccc.de/card10/firmware/-/tree/master/l0dables
Program Flow Diagram Program Flow Diagram
-------------------- --------------------
......
...@@ -12,42 +12,56 @@ The coordinate system of the BHI160 sensor data looks like this: ...@@ -12,42 +12,56 @@ The coordinate system of the BHI160 sensor data looks like this:
.. image:: ../static/bhi160-coordinates.png .. image:: ../static/bhi160-coordinates.png
All angles and angular velocities (like gyroscope, orientation) rotate counter * The **accelerometer** axes are just the ones shown in the picture.
clockwise around their respective axis. * The **gyroscope**'s angular velocities rotate counter clockwise around
their respective axis.
* The **orientation** sensor uses the following mapping:
+---------------------+----------------------+-------------------+
| X | Y | Z |
+=====================+======================+===================+
| Azimuth (0° - 360°) | Pitch (-180° - 180°) | Roll (-90° - 90°) |
+---------------------+----------------------+-------------------+
**Example**: **Example**:
.. code-block:: python .. code-block:: python
import bhi160 import bhi160
import utime import time
bhi = bhi160.BHI160Orientation() bhi = bhi160.BHI160Orientation()
while True: while True:
samples = bhi.read() samples = bhi.read()
if len(samples) == 0: if len(samples) == 0:
utime.sleep(0.25) time.sleep(0.25)
continue continue
# print the latest sample # print the latest sample
print(samples[-1]) print(samples[-1])
utime.sleep(0.25) time.sleep(0.25)
.. autoclass:: bhi160.BHI160
Orientation
-----------
.. autoclass:: bhi160.BHI160Orientation .. autoclass:: bhi160.BHI160Orientation
:members: :members:
:inherited-members: :inherited-members:
Accelerometer
-------------
.. autoclass:: bhi160.BHI160Accelerometer .. autoclass:: bhi160.BHI160Accelerometer
:members: :members:
:inherited-members: :inherited-members:
Gyroscope
---------
.. autoclass:: bhi160.BHI160Gyroscope .. autoclass:: bhi160.BHI160Gyroscope
:members: :members:
:inherited-members: :inherited-members:
Magnetometer
------------
.. autoclass:: bhi160.BHI160Magnetometer .. autoclass:: bhi160.BHI160Magnetometer
:members: :members:
:inherited-members: :inherited-members:
``ble_hid`` - BLE HID
=====================
The ``ble_hid`` module provides access to the BLE Human Interface Device functionality.
.. note::
Make sure to enable the BLE HID functionality in :ref:`card10_cfg` and reboot your card10
if you want to use BLE HID.
Also make sure that the ``adafruit_hid`` folder from the card10 release archive is placed
on the file system of your card10.
.. warning::
At least Ubuntu Linux will keep auto connecting to BLE HID devices once they are
paired to the host computer. If you want to connect your card10 to a phone again,
you might have to temporarily turn off Bluetooth on your computer.
An example application can be found in the preload directory (named ``HID Demo``). It provides
examples how to use the card10 as keyboard, mouse or volume control.
Please refer to the Adafruit CircuitPython HID library for examples how to use the HID service.
The card10 implements the same HID descriptors as the Adafruit CircuitPython BLE library and
should be compatible with all uses of the Adafruit CircuitPython HID library.
**Example emulating a keyboard**:
Adapted from https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/CPB_Keybutton_BLE/cpb_keybutton_ble.py
A more complete version of this example can be found in the HID Demo app on your card10.
.. code-block:: python
import ble_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode
k = Keyboard(ble_hid.devices)
kl = KeyboardLayoutUS(k)
k.send(Keycode.BACKSPACE)
# use keyboard_layout for words
kl.write("Demo with a long text to show how fast a card10 can type!")
# add shift modifier
k.send(Keycode.SHIFT, Keycode.F19)
**Example emulating a mouse**:
.. code-block:: python
import ble_hid
import bhi160
import buttons
from adafruit_hid.mouse import Mouse
m = Mouse(ble_hid.devices)
def send_report(samples):
if len(samples) > 0:
x = -int(samples[0].z)
y = -int(samples[0].y)
m.move(x, y)
sensor = bhi160.BHI160Orientation(sample_rate=10, callback=send_report)
b_old = buttons.read()
while True:
b_new = buttons.read()
if not b_old == b_new:
print(b_new)
b_old = b_new
if b_new == buttons.TOP_RIGHT:
m.click(Mouse.MIDDLE_BUTTON)
elif b_new == buttons.BOTTOM_RIGHT:
m.click(Mouse.RIGHT_BUTTON)
elif b_new == buttons.BOTTOM_LEFT:
m.click(Mouse.LEFT_BUTTON)
.. note::
Make sure to catch ``OSError`` exceptions in real applications. The exception will be thrown if
there is connection to the host (or if it is lost) and you want to send an event.
.. automodule:: ble_hid
:members:
...@@ -4,11 +4,50 @@ ...@@ -4,11 +4,50 @@
================================= =================================
Allows access to environmental data of card10's surroundings. Allows access to environmental data of card10's surroundings.
If ``bsec_enable`` is set in :ref:`card10_cfg`, the proprietary Bosch BSEC
library will be activated which offers the following extra functionality:
- Manual temperature offset compensation
The ``bsec_offset`` configuration allows to configure a static temperature
offset. Please use a reference thermometer to determine the offset of your
card10. If no offset is provided a default offset for a card10 which is
connected to USB, has BLE active and is without a case is used.
- A fixed measurement interval of 3 seconds
This helps to stabilize the temperature of the card10.
- An indoor air quality (IAQ) and equivalent CO2 estimation algorithm
Please refer to the :ref:`bsec_api` API documentation to get more information
about how to interpret these estimates.
.. note::
Please keep in mind that the BME680 can not directly measure CO2. It measures
Volatile Organic Compounds (VOCs). The BSEC library uses this measurement
to compute an Indoor Air Quality (IAQ) indication. It also assumes that all VOCs
in the air are from human breath and computes an equivalent CO2 (eCO2)
value from this. Please be aware of these facts when judging the accuracy
of the IAQ and eCO2 values. Some more information can be found in the
:ref:`bsec_api` API documentation.
.. warning::
For the BSEC library to properly work the card10 should be kept running
for at least 10 hours at least once. This is needed as the BSEC library
periodically writes calibration information about the sensor to the
card10's file system.
Please make sure to observe the IAQ accuracy field. It will tell you if the
IAQ and eCO2 measurements are deemed "accurate" by the BSEC library. Your
application should either inform the user about the current accuracy (e.g.
by color coding) or simply not show any values if the accuracy is below 2.
.. note::
See also the BLE :ref:`ESS`.
**Example**: **Example**:
.. code-block:: python .. code-block:: python
import bme680, utime import bme680, time
with bme680.Bme680() as environment: with bme680.Bme680() as environment:
while True: while True:
...@@ -19,7 +58,15 @@ Allows access to environmental data of card10's surroundings. ...@@ -19,7 +58,15 @@ Allows access to environmental data of card10's surroundings.
print("Pressure: {:10.2f} hPa".format(d.pressure)) print("Pressure: {:10.2f} hPa".format(d.pressure))
print("Gas Resistance: {:10.2f} Ω".format(d.resistance)) print("Gas Resistance: {:10.2f} Ω".format(d.resistance))
utime.sleep(1) time.sleep(1)
You can use the return type of :py:meth:`~bme680.Bme680.get_data` to decide
if you want to use/display the additonal fields returned if BSEC is enabled.
.. code-block:: python
if isinstance(d, bme680.BSECData):
print("Air quality: {:7d}".format(d.iaq))
Sensor Class Sensor Class
------------ ------------
......
...@@ -14,23 +14,65 @@ The color module also contains a few constanst for commonly used colors: ...@@ -14,23 +14,65 @@ The color module also contains a few constanst for commonly used colors:
Camp Colors Camp Colors
~~~~~~~~~~~ ~~~~~~~~~~~
.. py:data:: CHAOSBLUE .. py:data:: CHAOSBLUE
.. color-example:: #0076BA
.. py:data:: CHAOSBLUE_DARK .. py:data:: CHAOSBLUE_DARK
.. color-example:: #005383
.. py:data:: COMMYELLOW .. py:data:: COMMYELLOW
.. color-example:: #FFC600
.. py:data:: COMMYELLOW_DARK .. py:data:: COMMYELLOW_DARK
.. color-example:: #D39A00
.. py:data:: CAMPGREEN .. py:data:: CAMPGREEN
.. color-example:: #99BA00
.. py:data:: CAMPGREEN_DARK .. py:data:: CAMPGREEN_DARK
.. color-example:: #6F8700
General General
~~~~~~~ ~~~~~~~
.. py:data:: BLACK .. py:data:: BLACK
.. color-example:: #000
.. py:data:: WHITE .. py:data:: WHITE
.. color-example:: #fff
.. py:data:: RED .. py:data:: RED
.. color-example:: #f00
.. py:data:: GREEN .. py:data:: GREEN
.. color-example:: #0f0
.. py:data:: YELLOW .. py:data:: YELLOW
.. color-example:: #ff0
.. py:data:: BLUE .. py:data:: BLUE
.. color-example:: #00f
.. py:data:: MAGENTA .. py:data:: MAGENTA
.. color-example:: #f0f
.. py:data:: CYAN .. py:data:: CYAN
.. color-example:: #0ff
.. py:module:: htmlcolor .. py:module:: htmlcolor
``htmlcolor`` - Color Constants ``htmlcolor`` - Color Constants
...@@ -39,142 +81,561 @@ The ``htmlcolor`` module contains even more color constants. Note ...@@ -39,142 +81,561 @@ The ``htmlcolor`` module contains even more color constants. Note
that loading the ``htmlcolor`` module will require ~12K of RAM. that loading the ``htmlcolor`` module will require ~12K of RAM.
.. py:data:: ALICEBLUE .. py:data:: ALICEBLUE
.. color-example:: aliceblue
.. py:data:: ANTIQUEWHITE .. py:data:: ANTIQUEWHITE
.. color-example:: antiquewhite
.. py:data:: AQUA .. py:data:: AQUA
.. color-example:: aqua
.. py:data:: AQUAMARINE .. py:data:: AQUAMARINE
.. color-example:: aquamarine
.. py:data:: AZURE .. py:data:: AZURE
.. color-example:: azure
.. py:data:: BEIGE .. py:data:: BEIGE
.. color-example:: beige
.. py:data:: BISQUE .. py:data:: BISQUE
.. color-example:: bisque
.. py:data:: BLACK .. py:data:: BLACK
.. color-example:: black
.. py:data:: BLANCHEDALMOND .. py:data:: BLANCHEDALMOND
.. color-example:: blanchedalmond
.. py:data:: BLUE .. py:data:: BLUE
.. color-example:: blue
.. py:data:: BLUEVIOLET .. py:data:: BLUEVIOLET
.. color-example:: blueviolet
.. py:data:: BROWN .. py:data:: BROWN
.. color-example:: brown
.. py:data:: BURLYWOOD .. py:data:: BURLYWOOD
.. color-example:: burlywood
.. py:data:: CADETBLUE .. py:data:: CADETBLUE
.. color-example:: cadetblue
.. py:data:: CHARTREUSE .. py:data:: CHARTREUSE
.. color-example:: chartreuse
.. py:data:: CHOCOLATE .. py:data:: CHOCOLATE
.. color-example:: chocolate
.. py:data:: CORAL .. py:data:: CORAL
.. color-example:: coral
.. py:data:: CORNFLOWERBLUE .. py:data:: CORNFLOWERBLUE
.. color-example:: cornflowerblue
.. py:data:: CORNSILK .. py:data:: CORNSILK
.. color-example:: cornsilk
.. py:data:: CRIMSON .. py:data:: CRIMSON
.. color-example:: crimson
.. py:data:: CYAN .. py:data:: CYAN
.. color-example:: cyan
.. py:data:: DARKBLUE .. py:data:: DARKBLUE
.. color-example:: darkblue
.. py:data:: DARKCYAN .. py:data:: DARKCYAN
.. color-example:: darkcyan
.. py:data:: DARKGOLDENROD .. py:data:: DARKGOLDENROD
.. color-example:: darkgoldenrod
.. py:data:: DARKGRAY .. py:data:: DARKGRAY
.. color-example:: darkgray
.. py:data:: DARKGREEN .. py:data:: DARKGREEN
.. color-example:: darkgreen
.. py:data:: DARKKHAKI .. py:data:: DARKKHAKI
.. color-example:: darkkhaki
.. py:data:: DARKMAGENTA .. py:data:: DARKMAGENTA
.. color-example:: darkmagenta
.. py:data:: DARKOLIVEGREEN .. py:data:: DARKOLIVEGREEN
.. color-example:: darkolivegreen
.. py:data:: DARKORANGE .. py:data:: DARKORANGE
.. color-example:: darkorange
.. py:data:: DARKORCHID .. py:data:: DARKORCHID
.. color-example:: darkorchid
.. py:data:: DARKRED .. py:data:: DARKRED
.. color-example:: darkred
.. py:data:: DARKSALMON .. py:data:: DARKSALMON
.. color-example:: darksalmon
.. py:data:: DARKSEAGREEN .. py:data:: DARKSEAGREEN
.. color-example:: darkseagreen
.. py:data:: DARKSLATEBLUE .. py:data:: DARKSLATEBLUE
.. color-example:: darkslateblue
.. py:data:: DARKSLATEGRAY .. py:data:: DARKSLATEGRAY
.. color-example:: darkslategray
.. py:data:: DARKTURQUOISE .. py:data:: DARKTURQUOISE
.. color-example:: darkturquoise
.. py:data:: DARKVIOLET .. py:data:: DARKVIOLET
.. color-example:: darkviolet
.. py:data:: DEEPPINK .. py:data:: DEEPPINK
.. color-example:: deeppink
.. py:data:: DEEPSKYBLUE .. py:data:: DEEPSKYBLUE
.. color-example:: deepskyblue
.. py:data:: DIMGRAY .. py:data:: DIMGRAY
.. color-example:: dimgray
.. py:data:: DODGERBLUE .. py:data:: DODGERBLUE
.. color-example:: dodgerblue
.. py:data:: FIREBRICK .. py:data:: FIREBRICK
.. color-example:: firebrick
.. py:data:: FLORALWHITE .. py:data:: FLORALWHITE
.. color-example:: floralwhite
.. py:data:: FORESTGREEN .. py:data:: FORESTGREEN
.. color-example:: forestgreen
.. py:data:: FUCHSIA .. py:data:: FUCHSIA
.. color-example:: fuchsia
.. py:data:: GAINSBORO .. py:data:: GAINSBORO
.. color-example:: gainsboro
.. py:data:: GHOSTWHITE .. py:data:: GHOSTWHITE
.. color-example:: ghostwhite
.. py:data:: GOLD .. py:data:: GOLD
.. color-example:: gold
.. py:data:: GOLDENROD .. py:data:: GOLDENROD
.. color-example:: goldenrod
.. py:data:: GRAY .. py:data:: GRAY
.. color-example:: gray
.. py:data:: GREEN .. py:data:: GREEN
.. color-example:: green
.. py:data:: GREENYELLOW .. py:data:: GREENYELLOW
.. color-example:: greenyellow
.. py:data:: HONEYDEW .. py:data:: HONEYDEW
.. color-example:: honeydew
.. py:data:: HOTPINK .. py:data:: HOTPINK
.. color-example:: hotpink
.. py:data:: INDIANRED .. py:data:: INDIANRED
.. color-example:: indianred
.. py:data:: INDIGO .. py:data:: INDIGO
.. color-example:: indigo
.. py:data:: IVORY .. py:data:: IVORY
.. color-example:: ivory
.. py:data:: KHAKI .. py:data:: KHAKI
.. color-example:: khaki
.. py:data:: LAVENDER .. py:data:: LAVENDER
.. color-example:: lavender
.. py:data:: LAVENDERBLUSH .. py:data:: LAVENDERBLUSH
.. color-example:: lavenderblush
.. py:data:: LAWNGREEN .. py:data:: LAWNGREEN
.. color-example:: lawngreen
.. py:data:: LEMONCHIFFON .. py:data:: LEMONCHIFFON
.. color-example:: lemonchiffon
.. py:data:: LIGHTBLUE .. py:data:: LIGHTBLUE
.. color-example:: lightblue
.. py:data:: LIGHTCORAL .. py:data:: LIGHTCORAL
.. color-example:: lightcoral
.. py:data:: LIGHTCYAN .. py:data:: LIGHTCYAN
.. color-example:: lightcyan
.. py:data:: LIGHTGOLDENRODYELLOW .. py:data:: LIGHTGOLDENRODYELLOW
.. color-example:: lightgoldenrodyellow
.. py:data:: LIGHTGRAY .. py:data:: LIGHTGRAY
.. color-example:: lightgray
.. py:data:: LIGHTGREEN .. py:data:: LIGHTGREEN
.. color-example:: lightgreen
.. py:data:: LIGHTPINK .. py:data:: LIGHTPINK
.. color-example:: lightpink
.. py:data:: LIGHTSALMON .. py:data:: LIGHTSALMON
.. color-example:: lightsalmon
.. py:data:: LIGHTSEAGREEN .. py:data:: LIGHTSEAGREEN
.. color-example:: lightseagreen
.. py:data:: LIGHTSKYBLUE .. py:data:: LIGHTSKYBLUE
.. color-example:: lightskyblue
.. py:data:: LIGHTSLATEGRAY .. py:data:: LIGHTSLATEGRAY
.. color-example:: lightslategray
.. py:data:: LIGHTSTEELBLUE .. py:data:: LIGHTSTEELBLUE
.. color-example:: lightsteelblue
.. py:data:: LIGHTYELLOW .. py:data:: LIGHTYELLOW
.. color-example:: lightyellow
.. py:data:: LIME .. py:data:: LIME
.. color-example:: lime
.. py:data:: LIMEGREEN .. py:data:: LIMEGREEN
.. color-example:: limegreen
.. py:data:: LINEN .. py:data:: LINEN
.. color-example:: linen
.. py:data:: MAGENTA .. py:data:: MAGENTA
.. color-example:: magenta
.. py:data:: MAROON .. py:data:: MAROON
.. color-example:: maroon
.. py:data:: MEDIUMAQUAMARINE .. py:data:: MEDIUMAQUAMARINE
.. color-example:: mediumaquamarine
.. py:data:: MEDIUMBLUE .. py:data:: MEDIUMBLUE
.. color-example:: mediumblue
.. py:data:: MEDIUMORCHID .. py:data:: MEDIUMORCHID
.. color-example:: mediumorchid
.. py:data:: MEDIUMPURPLE .. py:data:: MEDIUMPURPLE
.. color-example:: mediumpurple
.. py:data:: MEDIUMSEAGREEN .. py:data:: MEDIUMSEAGREEN
.. color-example:: mediumseagreen
.. py:data:: MEDIUMSLATEBLUE .. py:data:: MEDIUMSLATEBLUE
.. color-example:: mediumslateblue
.. py:data:: MEDIUMSPRINGGREEN .. py:data:: MEDIUMSPRINGGREEN
.. color-example:: mediumspringgreen
.. py:data:: MEDIUMTURQUOISE .. py:data:: MEDIUMTURQUOISE
.. color-example:: mediumturquoise
.. py:data:: MEDIUMVIOLETRED .. py:data:: MEDIUMVIOLETRED
.. color-example:: mediumvioletred
.. py:data:: MIDNIGHTBLUE .. py:data:: MIDNIGHTBLUE
.. color-example:: midnightblue
.. py:data:: MINTCREAM .. py:data:: MINTCREAM
.. color-example:: mintcream
.. py:data:: MISTYROSE .. py:data:: MISTYROSE
.. color-example:: mistyrose
.. py:data:: MOCCASIN .. py:data:: MOCCASIN
.. color-example:: moccasin
.. py:data:: NAVAJOWHITE .. py:data:: NAVAJOWHITE
.. color-example:: navajowhite
.. py:data:: NAVY .. py:data:: NAVY
.. color-example:: navy
.. py:data:: OLDLACE .. py:data:: OLDLACE
.. color-example:: oldlace
.. py:data:: OLIVE .. py:data:: OLIVE
.. color-example:: olive
.. py:data:: OLIVEDRAB .. py:data:: OLIVEDRAB
.. color-example:: olivedrab
.. py:data:: ORANGE .. py:data:: ORANGE
.. color-example:: orange
.. py:data:: ORANGERED .. py:data:: ORANGERED
.. color-example:: orangered
.. py:data:: ORCHID .. py:data:: ORCHID
.. color-example:: orchid
.. py:data:: PALEGOLDENROD .. py:data:: PALEGOLDENROD
.. color-example:: palegoldenrod
.. py:data:: PALEGREEN .. py:data:: PALEGREEN
.. color-example:: palegreen
.. py:data:: PALETURQUOISE .. py:data:: PALETURQUOISE
.. color-example:: paleturquoise
.. py:data:: PALEVIOLETRED .. py:data:: PALEVIOLETRED
.. color-example:: palevioletred
.. py:data:: PAPAYAWHIP .. py:data:: PAPAYAWHIP
.. color-example:: papayawhip
.. py:data:: PEACHPUFF .. py:data:: PEACHPUFF
.. color-example:: peachpuff
.. py:data:: PERU .. py:data:: PERU
.. color-example:: peru
.. py:data:: PINK .. py:data:: PINK
.. color-example:: pink
.. py:data:: PLUM .. py:data:: PLUM
.. color-example:: plum
.. py:data:: POWDERBLUE .. py:data:: POWDERBLUE
.. color-example:: powderblue
.. py:data:: PURPLE .. py:data:: PURPLE
.. color-example:: purple
.. py:data:: RED .. py:data:: RED
.. color-example:: red
.. py:data:: ROSYBROWN .. py:data:: ROSYBROWN
.. color-example:: rosybrown
.. py:data:: ROYALBLUE .. py:data:: ROYALBLUE
.. color-example:: royalblue
.. py:data:: SADDLEBROWN .. py:data:: SADDLEBROWN
.. color-example:: saddlebrown
.. py:data:: SALMON .. py:data:: SALMON
.. color-example:: salmon
.. py:data:: SANDYBROWN .. py:data:: SANDYBROWN
.. color-example:: sandybrown
.. py:data:: SEAGREEN .. py:data:: SEAGREEN
.. color-example:: seagreen
.. py:data:: SEASHELL .. py:data:: SEASHELL
.. color-example:: seashell
.. py:data:: SIENNA .. py:data:: SIENNA
.. color-example:: sienna
.. py:data:: SILVER .. py:data:: SILVER
.. color-example:: silver
.. py:data:: SKYBLUE .. py:data:: SKYBLUE
.. color-example:: skyblue
.. py:data:: SLATEBLUE .. py:data:: SLATEBLUE
.. color-example:: slateblue
.. py:data:: SLATEGRAY .. py:data:: SLATEGRAY
.. color-example:: slategray
.. py:data:: SNOW .. py:data:: SNOW
.. color-example:: snow
.. py:data:: SPRINGGREEN .. py:data:: SPRINGGREEN
.. color-example:: springgreen
.. py:data:: STEELBLUE .. py:data:: STEELBLUE
.. color-example:: steelblue
.. py:data:: TAN .. py:data:: TAN
.. color-example:: tan
.. py:data:: TEAL .. py:data:: TEAL
.. color-example:: teal
.. py:data:: THISTLE .. py:data:: THISTLE
.. color-example:: thistle
.. py:data:: TOMATO .. py:data:: TOMATO
.. color-example:: tomato
.. py:data:: TURQUOISE .. py:data:: TURQUOISE
.. color-example:: turquoise
.. py:data:: VIOLET .. py:data:: VIOLET
.. color-example:: violet
.. py:data:: WHEAT .. py:data:: WHEAT
.. color-example:: wheat
.. py:data:: WHITE .. py:data:: WHITE
.. color-example:: white
.. py:data:: WHITESMOKE .. py:data:: WHITESMOKE
.. color-example:: whitesmoke
.. py:data:: YELLOW .. py:data:: YELLOW
.. color-example:: yellow
.. py:data:: YELLOWGREEN .. py:data:: YELLOWGREEN
.. color-example:: yellowgreen
``config`` - Configuration
==========================
The ``config`` module provides functions to interact with card10's
configuration file (:ref:`card10_cfg`).
.. automodule:: config
:members:
``max86150`` - MAX86150
=======================
.. automodule:: max86150
:members:
...@@ -8,12 +8,6 @@ functions found in CPythons ``os`` module. ...@@ -8,12 +8,6 @@ functions found in CPythons ``os`` module.
CPython-Like CPython-Like
------------ ------------
.. py:function:: unlink(path)
Unlink (remove) a file.
:param str path: The file to remove.
.. py:function:: listdir(dir) .. py:function:: listdir(dir)
List contents of a directory. List contents of a directory.
...@@ -22,6 +16,28 @@ CPython-Like ...@@ -22,6 +16,28 @@ CPython-Like
:returns: A list of entities (files or subdirectories) in the directory :returns: A list of entities (files or subdirectories) in the directory
``dir``. ``dir``.
.. py:function:: mkdir(path)
Create a directory named *path*.
:param str path: Path to the directory to create. Only the last component
of this path will be created.
.. py:function:: rename(src, dst)
Rename the file or directory *src* to *dst*. If *dst* exists, the operation
will fail.
:param str src: Path to source file to rename.
:param str dst: Destination path to rename to. Must not exist before
calling :py:func:`os.rename`.
.. py:function:: unlink(path)
Unlink (remove) a file.
:param str path: The file to remove.
.. py:function:: urandom(n) .. py:function:: urandom(n)
Return ``n`` random bytes. Return ``n`` random bytes.
...@@ -99,3 +115,17 @@ Card10-Specific ...@@ -99,3 +115,17 @@ Card10-Specific
.. py:data:: USB_FLASH .. py:data:: USB_FLASH
Mass-Storage device active. Mass-Storage device active.
.. py:function:: fs_is_attached()
Check whether the filesystem is currently attached to card10 (or whether a connected
USB host is currently holding control over it and possibly writing to it).
:returns:
- ``True`` if the filesystem is attached to card10 and an app can read and
write files.
- ``False`` if the filesystem is not available to card10 because a USB
host is currently controlling it.
.. versionadded: 1.18
``png`` - PNG Decoder
=====================
The ``png`` module provides functions to decode PNG files into raw pixel data
which can be displayed using the card10's display or its LEDs.
.. automodule:: png
:members:
MicroPython Standard Library MicroPython Standard Library
============================ ============================
Pycardium contains some modules from the MicroPython standard library. These Pycardium contains some modules from the MicroPython standard library.
are:
Some modules below use a standard Python name, but prefixed with “u”,
e.g. ujson instead of json. This is to signify that such a module is a
micro-library, i.e. implements only a subset of CPython module
functionality. Please refer to the official `MicroPython docs`_ for an
explanation why.
All u-name modules can also be imported using their non-u-name. E.g.
``import utime`` and import ``import time`` will both work.
.. _MicroPython docs: http://docs.micropython.org/en/latest/library/index.html#python-standard-libraries-and-micro-libraries
.. py:module:: framebuf
``framebuf``
------------
Refer to the official `MicroPython docs for framebuf`_.
.. _MicroPython docs for framebuf: https://docs.micropython.org/en/latest/library/framebuf.html
.. py:module:: ubinascii .. py:module:: ubinascii
...@@ -219,7 +237,7 @@ Struct module. ...@@ -219,7 +237,7 @@ Struct module.
UUID version accordiung to RFC 4122 UUID version accordiung to RFC 4122
.. py:function:: uuid4(): .. py:function:: uuid4()
Generate a new UUID version 4 (random UUID). Generate a new UUID version 4 (random UUID).
......
...@@ -8,6 +8,9 @@ CPython but wouldn't fit anywhere else in our implementation. Most ...@@ -8,6 +8,9 @@ CPython but wouldn't fit anywhere else in our implementation. Most
prominently, this is the :py:func:`utime.alarm` function for setting an RTC prominently, this is the :py:func:`utime.alarm` function for setting an RTC
alarm. alarm.
Like all other u-name modules, ``utime`` can also imported using the standard
``import time`` statement.
.. |time| replace:: ``time`` .. |time| replace:: ``time``
.. _time: https://docs.python.org/3/library/time.html .. _time: https://docs.python.org/3/library/time.html
...@@ -45,6 +48,36 @@ alarm. ...@@ -45,6 +48,36 @@ alarm.
.. versionadded:: 1.11 .. versionadded:: 1.11
.. py:function:: ticks_ms()
Return processor ticks (converted to milliseconds) since Pycardium startup.
This function should be the preferred method for timing and profiling
because it does not need an API call and thus is very fast.
.. versionadded:: 1.13
.. py:function:: ticks_us()
Return processor ticks (converted to microseconds) since Pycardium startup.
This function should be the preferred method for timing and profiling
because it does not need an API call and thus is very fast.
.. versionadded:: 1.13
.. py:function:: unix_time()
Return the current unix time as seconds since the epoch.
.. versionadded:: 1.12
.. py:function:: unix_time_ms()
Return the current unix time as milliseconds since the epoch.
.. versionadded:: 1.12
.. py:function:: set_time(secs) .. py:function:: set_time(secs)
Sets the time to ``secs`` seconds since 2000-01-01 00:00 in the local Sets the time to ``secs`` seconds since 2000-01-01 00:00 in the local
...@@ -54,6 +87,13 @@ alarm. ...@@ -54,6 +87,13 @@ alarm.
:py:func:`utime.set_time` previously applied a wrong timezone offset, :py:func:`utime.set_time` previously applied a wrong timezone offset,
thus leading to wrong results. thus leading to wrong results.
.. py:function:: set_time_ms(msecs)
Set the time to ``msecs`` seconds since 2000-01-01 00:00 in the local
timezone.
.. versionadded:: 1.12
.. py:function:: set_unix_time(secs) .. py:function:: set_unix_time(secs)
Sets the time to ``secs`` seconds since 1970-01-01 00:00 UTC. Sets the time to ``secs`` seconds since 1970-01-01 00:00 UTC.
...@@ -61,6 +101,12 @@ alarm. ...@@ -61,6 +101,12 @@ alarm.
by running ``date +%s`` in a command line or ``int(time.time())`` by running ``date +%s`` in a command line or ``int(time.time())``
in Python. in Python.
.. py:function:: set_unix_time_ms(msecs)
Set the time to ``msecs`` milliseconds since the unix epoch.
.. versionadded:: 1.12
.. py:function:: localtime([secs]) .. py:function:: localtime([secs])
Return the current time as a timestruct tuple. If ``secs`` is given, return Return the current time as a timestruct tuple. If ``secs`` is given, return
...@@ -92,13 +138,13 @@ alarm. ...@@ -92,13 +138,13 @@ alarm.
.. code-block:: python .. code-block:: python
import utime import time
def minute_timer(x): def minute_timer(x):
current = utime.time() current = time.time()
print("Current: " + str(current)) print("Current: " + str(current))
alarm = (current // 60 + 1) * 60 alarm = (current // 60 + 1) * 60
utime.alarm(alarm, minute_timer) time.alarm(alarm, minute_timer)
minute_timer(None) minute_timer(None)
...@@ -107,13 +153,13 @@ alarm. ...@@ -107,13 +153,13 @@ alarm.
.. code-block:: python .. code-block:: python
import interrupt, utime import interrupt, time
def 5_second_timer(x): def 5_second_timer(x):
current = utime.time() current = time.time()
print("Current: " + str(current)) print("Current: " + str(current))
alarm = (current // 10) * 10 + 5 alarm = (current // 10) * 10 + 5
utime.alarm(alarm) time.alarm(alarm)
# This time, we need to register and enable the callback manually # This time, we need to register and enable the callback manually
interrupt.set_callback(interrupt.RTC_ALARM, 5_second_timer) interrupt.set_callback(interrupt.RTC_ALARM, 5_second_timer)
......
...@@ -19,7 +19,9 @@ The ``ws2812`` module controls LEDs of the WS2812 type. Just as the ``leds`` mod ...@@ -19,7 +19,9 @@ The ``ws2812`` module controls LEDs of the WS2812 type. Just as the ``leds`` mod
.. code-block:: python .. code-block:: python
import color, utime, ws2812, gpio import color, time, ws2812, gpio
gpio.set_mode(gpio.WRISTBAND_2, gpio.mode.OUTPUT)
i = 0 i = 0
while True: while True:
...@@ -28,6 +30,6 @@ The ``ws2812`` module controls LEDs of the WS2812 type. Just as the ``leds`` mod ...@@ -28,6 +30,6 @@ The ``ws2812`` module controls LEDs of the WS2812 type. Just as the ``leds`` mod
col3 = color.from_hsv((i + 40) % 360, 1.0, 0.1) col3 = color.from_hsv((i + 40) % 360, 1.0, 0.1)
ws2812.set_all(gpio.WRISTBAND_2, [col1, col2, col3]) ws2812.set_all(gpio.WRISTBAND_2, [col1, col2, col3])
i += 1 i += 1
utime.sleep_ms(10) time.sleep_ms(10)
.. versionadded:: 1.10 .. versionadded:: 1.10
...@@ -8,13 +8,12 @@ ...@@ -8,13 +8,12 @@
static void bootloader_display_splash(void) static void bootloader_display_splash(void)
{ {
gfx_copy_region( gfx_copy_region_rle_mono(
&display_screen, &display_screen,
0, 0,
0, 0,
160, 160,
80, 80,
GFX_RLE_MONO,
sizeof(splash), sizeof(splash),
(const void *)(splash) (const void *)(splash)
); );
......