-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b8e1f0
commit f4204f1
Showing
264 changed files
with
16,248 additions
and
21,704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,68 @@ | ||
"""Control the garbage collector""" | ||
|
||
"""Controla el recol·lector de memòria brossa""" | ||
from typing import overload | ||
|
||
def enable() -> None: | ||
"""Enable automatic garbage collection.""" | ||
"""Habilita la recol·lecció automàtica de la memòria brossa (habilita)""" | ||
... | ||
|
||
def disable() -> None: | ||
"""Disable automatic garbage collection. | ||
"""Inhabilita la recol·lecció automàtica de la memòria brossa (desactiva) | ||
Heap memory can still be allocated, | ||
and garbage collection can still be initiated manually using ``gc.collect``.""" | ||
Heap memory can still be allocated, | ||
and garbage collection can still be initiated manually using ``gc.collect``.""" | ||
|
||
def collect() -> None: | ||
"""Run a garbage collection.""" | ||
"""Executa la recol·lecció automàtica de la memòria brossa (Recull)""" | ||
... | ||
|
||
def mem_alloc() -> int: | ||
"""Get the number of bytes of heap RAM that are allocated. | ||
"""Obté el nombre de bytes assignats a la memòria dinàmica. (espai de memòria) | ||
:return: The number of bytes allocated. | ||
:return: The number of bytes allocated. | ||
This function is MicroPython extension. | ||
""" | ||
This function is MicroPython extension.""" | ||
... | ||
|
||
def mem_free() -> int: | ||
"""Get the number of bytes of available heap RAM, or -1 if this amount is not known. | ||
"""Obté el nombre disponible de bytes de la memòria dinàmica, o -1 si no es coneix la quantitat. (memòria lliure) | ||
:return: The number of bytes free. | ||
:return: The number of bytes free. | ||
This function is MicroPython extension. | ||
""" | ||
This function is MicroPython extension.""" | ||
... | ||
|
||
@overload | ||
def threshold() -> int: | ||
"""Query the additional GC allocation threshold. | ||
"""Consulta l'assignació del llindar del col·lector d'escombraries. (llindar) | ||
:return: The GC allocation threshold. | ||
:return: The GC allocation threshold. | ||
This function is a MicroPython extension. CPython has a similar | ||
function - ``set_threshold()``, but due to different GC | ||
implementations, its signature and semantics are different. | ||
""" | ||
This function is a MicroPython extension. CPython has a similar | ||
function - ``set_threshold()``, but due to different GC | ||
implementations, its signature and semantics are different.""" | ||
... | ||
|
||
@overload | ||
def threshold(amount: int) -> None: | ||
"""Set the additional GC allocation threshold. | ||
Normally, a collection is triggered only when a new allocation | ||
cannot be satisfied, i.e. on an out-of-memory (OOM) condition. | ||
If this function is called, in addition to OOM, a collection | ||
will be triggered each time after ``amount`` bytes have been | ||
allocated (in total, since the previous time such an amount of bytes | ||
have been allocated). ``amount`` is usually specified as less than the | ||
full heap size, with the intention to trigger a collection earlier than when the | ||
heap becomes exhausted, and in the hope that an early collection will prevent | ||
excessive memory fragmentation. This is a heuristic measure, the effect | ||
of which will vary from application to application, as well as | ||
the optimal value of the ``amount`` parameter. | ||
A value of -1 means a disabled allocation threshold. | ||
This function is a MicroPython extension. CPython has a similar | ||
function - ``set_threshold()``, but due to different GC | ||
implementations, its signature and semantics are different. | ||
:param amount: The number of bytes after which a garbage collection should be triggered. | ||
""" | ||
... | ||
"""Assigna un espai adicional al llindar del col·lector d'escombraries. (llindar) | ||
Normally, a collection is triggered only when a new allocation | ||
cannot be satisfied, i.e. on an out-of-memory (OOM) condition. | ||
If this function is called, in addition to OOM, a collection | ||
will be triggered each time after ``amount`` bytes have been | ||
allocated (in total, since the previous time such an amount of bytes | ||
have been allocated). ``amount`` is usually specified as less than the | ||
full heap size, with the intention to trigger a collection earlier than when the | ||
heap becomes exhausted, and in the hope that an early collection will prevent | ||
excessive memory fragmentation. This is a heuristic measure, the effect | ||
of which will vary from application to application, as well as | ||
the optimal value of the ``amount`` parameter. | ||
A value of -1 means a disabled allocation threshold. | ||
This function is a MicroPython extension. CPython has a similar | ||
function - ``set_threshold()``, but due to different GC | ||
implementations, its signature and semantics are different. | ||
:param amount: (quantitat) El nombre de bytes després del qual s'activarà la recol·lecció de la memòria brossa.""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,89 @@ | ||
"""Log data to your micro:bit V2.""" | ||
|
||
"""Registre dades en la micro:bit V2 (registre)""" | ||
from typing import Literal, Mapping, Optional, Union, overload | ||
|
||
MILLISECONDS = 1 | ||
"""Milliseconds timestamp format.""" | ||
|
||
"""Format de marca de temps de mil·lisegons. (mil·lisegons)""" | ||
SECONDS = 10 | ||
"""Seconds timestamp format.""" | ||
|
||
"""Format de marca de temps de segons. (segons)""" | ||
MINUTES = 600 | ||
"""Minutes timestamp format.""" | ||
|
||
"""Format de marca de temps de minuts. (minuts)""" | ||
HOURS = 36000 | ||
"""Hours timestamp format.""" | ||
|
||
"""Format de marca de temps d'hores. (hores)""" | ||
DAYS = 864000 | ||
"""Days timestamp format.""" | ||
"""Format de marca de temps de dies. (dies)""" | ||
|
||
def set_labels( | ||
*labels: str, timestamp: Optional[Literal[1, 10, 36000, 864000]] = SECONDS | ||
) -> None: | ||
"""Set up the log file header. | ||
def set_labels(*labels: str, timestamp: Optional[Literal[1, 10, 36000, 864000]]=SECONDS) -> None: | ||
"""Defineix la capçalera del fitxer de registre. (Defineix l'etiqueta) | ||
Example: ``log.set_labels('X', 'Y', 'Z', timestamp=log.MINUTES)`` | ||
Example: ``log.set_labels('X', 'Y', 'Z', timestamp=log.MINUTES)`` | ||
Ideally this function should be called a single time, before any data is | ||
logged, to configure the data table header once. | ||
Ideally this function should be called a single time, before any data is | ||
logged, to configure the data table header once. | ||
If a log file already exists when the program starts, or if this function | ||
is called multiple times, it will check the labels already defined in the | ||
log file. If this function call contains any new labels not already | ||
present, it will generate a new header row with the additional columns. | ||
If a log file already exists when the program starts, or if this function | ||
is called multiple times, it will check the labels already defined in the | ||
log file. If this function call contains any new labels not already | ||
present, it will generate a new header row with the additional columns. | ||
By default the first column contains a timestamp for each row. The time | ||
unit can be selected via the timestamp argument. | ||
By default the first column contains a timestamp for each row. The time | ||
unit can be selected via the timestamp argument. | ||
:param *labels: Any number of positional arguments, each corresponding to an entry in the log header. | ||
:param timestamp: Select the timestamp unit that will be automatically added as the first column in every row. Timestamp values can be one of ``log.MILLISECONDS``, ``log.SECONDS``, ``log.MINUTES``, ``log.HOURS``, ``log.DAYS`` or ``None`` to disable the timestamp. The default value is ``log.SECONDS``. | ||
""" | ||
:param *labels: Qualsevol nombre d'arguments posicionals, corresponent cadascun a una entrada en la capçalera del registre. | ||
:param timestamp: (marca horària) Selecciona la unitat de la marca del temps que serà automaticament afegida com a primera columna de cada fila. Els valors de la marca del temps pot ser un de ``log.MILLISECONDS``, ``log.SECONDS``, ``log.MINUTES``, ``log.HOURS``, ``log.DAYS`` o ``None`` per desactivar la marca del temps. El valor per defecte es ``log.SECONDS``.""" | ||
... | ||
|
||
@overload | ||
def add( | ||
data_dictionary: Optional[Mapping[str, Union[str, int, float]]], | ||
) -> None: | ||
"""Add a data row to the log by passing a dictionary of headers and values. | ||
def add(data_dictionary: Optional[Mapping[str, Union[str, int, float]]]) -> None: | ||
"""Afegeix una fila de dades al registre passant un diccionari de capçaleres i valors. (afegeix) | ||
Example: ``log.add({ 'temp': temperature() })`` | ||
Example: ``log.add({ 'temp': temperature() })`` | ||
Each call to this function adds a row to the log. | ||
Each call to this function adds a row to the log. | ||
New labels not previously specified via the set_labels function, or by a | ||
previous call to this function, will trigger a new header entry to be added | ||
to the log with the extra labels. | ||
New labels not previously specified via the set_labels function, or by a | ||
previous call to this function, will trigger a new header entry to be added | ||
to the log with the extra labels. | ||
Labels previously specified and not present in a call to this function will | ||
be skipped with an empty value in the log row. | ||
Labels previously specified and not present in a call to this function will | ||
be skipped with an empty value in the log row. | ||
:param data_dictionary: The data to log as a dictionary with a key for each header. | ||
""" | ||
:param data_dictionary: (diccionari de dades) Les dades a ser registrades com un diccionari amb una clau per cada capçalera.""" | ||
... | ||
|
||
@overload | ||
def add(**kwargs: Union[str, int, float]) -> None: | ||
"""Add a data row to the log using keyword arguments. | ||
"""Afegeix una fila de dades al registre fent servir arguments de paraula clau. (afegeix) | ||
Example: ``log.add(temp=temperature())`` | ||
Example: ``log.add(temp=temperature())`` | ||
Each call to this function adds a row to the log. | ||
Each call to this function adds a row to the log. | ||
New labels not previously specified via the set_labels function, or by a | ||
previous call to this function, will trigger a new header entry to be added | ||
to the log with the extra labels. | ||
New labels not previously specified via the set_labels function, or by a | ||
previous call to this function, will trigger a new header entry to be added | ||
to the log with the extra labels. | ||
Labels previously specified and not present in a call to this function will | ||
be skipped with an empty value in the log row. | ||
""" | ||
Labels previously specified and not present in a call to this function will | ||
be skipped with an empty value in the log row.""" | ||
... | ||
|
||
def delete(full=False): | ||
"""Deletes the contents of the log, including headers. | ||
"""Suprimeix el contingut del registre, incloses les capçaleres. (suprimeix) | ||
Example: ``log.delete()`` | ||
Example: ``log.delete()`` | ||
To add the log headers again the ``set_labels`` function should to be called after this function. | ||
To add the log headers again the ``set_labels`` function should to be called after this function. | ||
There are two erase modes; “full” completely removes the data from the physical storage, | ||
and “fast” invalidates the data without removing it. | ||
There are two erase modes; “full” completely removes the data from the physical storage, | ||
and “fast” invalidates the data without removing it. | ||
:param full: ``True`` selects a “full” erase and ``False`` selects the “fast” erase method. | ||
""" | ||
:param full: (ple) ``True`` selecciona un esborrat "total" ``False`` selecciona un mètode d'esborrat "ràpid".""" | ||
... | ||
|
||
def set_mirroring(serial: bool): | ||
"""Configure mirroring of the data logging activity to the serial output. | ||
"""Configura la duplicació de l'activitat de registre de dades a la sortida en sèrie. (estableix mirall) | ||
Example: ``log.set_mirroring(True)`` | ||
Example: ``log.set_mirroring(True)`` | ||
Serial mirroring is disabled by default. When enabled, it will print to serial each row logged into the log file. | ||
Serial mirroring is disabled by default. When enabled, it will print to serial each row logged into the log file. | ||
:param serial: ``True`` enables mirroring data to the serial output. | ||
""" | ||
... | ||
:param serial: ``True`` permet la duplicació de les dades a la sortida sèrie.""" | ||
... |
Oops, something went wrong.