Led¶
Led¶
Internal Red-Green-Blue utilities module. Controls the built-in RGB LED in color and brightness
-
class
led_dev.Led(brightness=0.2, r=0, g=0, b=0)[source]¶ Creates the RBG Led interface
Parameters: - brightness (float) – the Led brightness, (ranges from 0.00 to 1.00), optionnal
- r (int) – the red component value of the color, (ranges from 0 to 255), optionnal
- g (int) – the green component value of the color, (ranges from 0 to 255), optionnal
- b (int) – the blue component value of the color, (ranges from 0 to 255), optionnal
Example usage:
from elevages_numeriques.led import * led = Led() # The Led object can be created without arguments # The available colors are : # RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, ORANGE, PURPLE, TEAL, WHITE AND OFF led.color = RED # Chosen color is red led.brightness = 0.5 # Set brightness to 50%
-
blink(color=None, period=0.5)[source]¶ Sets the internal LED mode to ‘blinking mode’
In blinking mode, you’ll need to call run() regularly You can set the brightness beforehand to blink with a specific brightness :param color: the color to use when blinking :param period: The period during the Led is either On or OFF
Example usage:
from elevages_numeriques.led import * led = Led() led.blink(BLUE, 1.5) # Makes the Led blink in Blue # The Led will turn on for 1.5 second, turn off for 1.5 second (and so on...) until led.static() is called while(True): led.run()
-
brightness¶ Led property returning the current Led brightness (ranges from 0.00 to 1.00)
-
color¶ Property returning the current color of the Led
Logger¶
Logger¶
Logging utility to store and keep messages in the internal memory for later retrieval
-
class
logger_dev.Logger(debug=False)[source]¶ Initialises the Logger object
Parameters: debug (bool) – Will print storage errors when enabled
Example usage:
from elevages_numeriques.logger import * logger = Logger() logger.log_line('logging.txt', "Hello world !")
-
can_log()[source]¶ Checks if the switch is in the LOG position
If it returns True, the module can write to its internal storage and the computer can’t If it returns False, the module can read its internal storage but can’t write on it
-
GPS¶
Gps¶
GPS utilities module. Can interact, control and read data from a GPS module, such as latitude, longitude, and more.
-
class
gps_dev.Gps(debug=False)[source]¶ Creates the Gps interface
Parameters: debug (boolean) – print errors if they occur , optionnal Example usage:
from elevages_numeriques.gps import * gps = Gps() # same as gps = Gps(debug=False) gps.update() print(gps.header) print(gps)
-
enable(val=True)[source]¶ Enables or disables the GPS module to save energy
Parameters: val (bool) – Enables the module if True, disables it otherwise
-
header¶ Property returning the list of currently enabled GPS data fields in CSV format
Returns: A semicolon-separated list of the enabled fields
-
set_logging(field_name, enable)[source]¶ Enables or disables the logging output for the given field
Parameters: - field_name (string) – The field name, examples below
- enable (bool) – Wether to enable or not the given field
Available fields:
'datetime' # Current date and time (formatted as 'day/month/year hour:min:sec') # In UTC time (that's Greenwich timezone) 'latitude' # Current device latitude 'longitude' # Current device longitude 'altitude' # Current device altitude (in m) 'speed' # Current device speed (in km/h) 'fix_quality' # Quality class of the positionning signal # 0 = invalid # 1 = Standard GPS fix # 2 = Differential GPS fix (super precise) 'satellites' # Number of visible satellites, the more the better. # GPS positionning is impossible below 3 satellites 'horizontal_dilution' # How spread are the satellites in the sky ? The lower the better # A high dilution can lead to imprecisions in the GPS signal
-