-
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
0d5f2f8
commit 1b8e1f0
Showing
271 changed files
with
21,808 additions
and
16,352 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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,68 +1,73 @@ | ||
"""Controla el recol·lector de memòria brossa""" | ||
"""Control the garbage collector""" | ||
|
||
from typing import overload | ||
|
||
def enable() -> None: | ||
"""Habilita la recol·lecció automàtica de la memòria brossa (habilita)""" | ||
"""Enable automatic garbage collection.""" | ||
... | ||
|
||
def disable() -> None: | ||
"""Inhabilita la recol·lecció automàtica de la memòria brossa (desactiva) | ||
"""Disable automatic garbage collection. | ||
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: | ||
"""Executa la recol·lecció automàtica de la memòria brossa (Recull)""" | ||
"""Run a garbage collection.""" | ||
... | ||
|
||
def mem_alloc() -> int: | ||
"""Obté el nombre de bytes assignats a la memòria dinàmica. (espai de memòria) | ||
"""Get the number of bytes of heap RAM that are allocated. | ||
: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: | ||
"""Obté el nombre disponible de bytes de la memòria dinàmica, o -1 si no es coneix la quantitat. (memòria lliure) | ||
"""Get the number of bytes of available heap RAM, or -1 if this amount is not known. | ||
: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: | ||
"""Consulta l'assignació del llindar del col·lector d'escombraries. (llindar) | ||
"""Query the additional GC allocation threshold. | ||
: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: | ||
"""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.""" | ||
... | ||
"""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. | ||
""" | ||
... |
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,89 +1,104 @@ | ||
"""Registre dades en la micro:bit V2 (registre)""" | ||
"""Log data to your micro:bit V2.""" | ||
|
||
from typing import Literal, Mapping, Optional, Union, overload | ||
|
||
MILLISECONDS = 1 | ||
"""Format de marca de temps de mil·lisegons. (mil·lisegons)""" | ||
"""Milliseconds timestamp format.""" | ||
|
||
SECONDS = 10 | ||
"""Format de marca de temps de segons. (segons)""" | ||
"""Seconds timestamp format.""" | ||
|
||
MINUTES = 600 | ||
"""Format de marca de temps de minuts. (minuts)""" | ||
"""Minutes timestamp format.""" | ||
|
||
HOURS = 36000 | ||
"""Format de marca de temps d'hores. (hores)""" | ||
"""Hours timestamp format.""" | ||
|
||
DAYS = 864000 | ||
"""Format de marca de temps de dies. (dies)""" | ||
"""Days timestamp format.""" | ||
|
||
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) | ||
def set_labels( | ||
*labels: str, timestamp: Optional[Literal[1, 10, 36000, 864000]] = SECONDS | ||
) -> None: | ||
"""Set up the log file header. | ||
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: 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``.""" | ||
: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``. | ||
""" | ||
... | ||
|
||
@overload | ||
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) | ||
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. | ||
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: (diccionari de dades) Les dades a ser registrades com un diccionari amb una clau per cada capçalera.""" | ||
:param data_dictionary: The data to log as a dictionary with a key for each header. | ||
""" | ||
... | ||
|
||
@overload | ||
def add(**kwargs: Union[str, int, float]) -> None: | ||
"""Afegeix una fila de dades al registre fent servir arguments de paraula clau. (afegeix) | ||
"""Add a data row to the log using keyword arguments. | ||
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): | ||
"""Suprimeix el contingut del registre, incloses les capçaleres. (suprimeix) | ||
"""Deletes the contents of the log, including headers. | ||
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: (ple) ``True`` selecciona un esborrat "total" ``False`` selecciona un mètode d'esborrat "ràpid".""" | ||
:param full: ``True`` selects a “full” erase and ``False`` selects the “fast” erase method. | ||
""" | ||
... | ||
|
||
def set_mirroring(serial: bool): | ||
"""Configura la duplicació de l'activitat de registre de dades a la sortida en sèrie. (estableix mirall) | ||
"""Configure mirroring of the data logging activity to the serial output. | ||
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`` permet la duplicació de les dades a la sortida sèrie.""" | ||
... | ||
:param serial: ``True`` enables mirroring data to the serial output. | ||
""" | ||
... |
Oops, something went wrong.