%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/sensehat.pyc

�
���^c@@s dZddlmZmZmZddlZyddlmZeZ	Wn#e
efk
rmdZ
eZ	nXeje�Zd�Zd�Zd�Zd�Zd	�Zed
�Zddddd�Zddd
�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Z dS(u
Module for controlling the LED matrix or reading environment data on the SenseHat of a Raspberry Pi.

.. versionadded:: 2017.7.0

:maintainer:    Benedikt Werner <1benediktwerner@gmail.com>, Joachim Werner <joe@suse.com>
:maturity:      new
:depends:       sense_hat Python module

The rotation of the Pi can be specified in a pillar.
This is useful if the Pi is used upside down or sideways to correct the orientation of the image being shown.

Example:

.. code-block:: yaml

    sensehat:
        rotation: 90

i(tabsolute_importtunicode_literalstprint_functionN(tSenseHatcC@s~trty
t�}Wntk
r-tdfSXtddd�}|d
kr`|j|t�ntjd|�tStd	fS(u7
    Only load the module if SenseHat is available
    u?This module can only be used on a Raspberry Pi with a SenseHat.u
pillar.getusensehat:rotationiiZi�iu3%s is not a valid rotation. Using default rotation.uWThe SenseHat execution module cannot be loaded: 'sense_hat' python library unavailable.(iiZi�i(	t
has_sense_hatRtOSErrortFalset__salt__tset_rotationtlogterrortTrue(t	_sensehattrotation((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyt__virtual__$s

	cC@stj|�i|d6S(u�
    Sets the entire LED matrix based on a list of 64 pixel values

    pixels
        A list of 64 ``[R, G, B]`` color values.
    upixels(Rt
set_pixels(tpixels((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR9s
cC@s
tj�S(u�
    Returns a list of 64 smaller lists of ``[R, G, B]`` pixels representing the
    the currently displayed image on the LED matrix.

    .. note::
        When using ``set_pixels`` the pixel values can sometimes change when
        you read them again using ``get_pixels``. This is because we specify each
        pixel element as 8 bit numbers (0 to 255) but when they're passed into the
        Linux frame buffer for the LED matrix the numbers are bit shifted down
        to fit into RGB 565. 5 bits for red, 6 bits for green and 5 bits for blue.
        The loss of binary precision when performing this conversion
        (3 bits lost for red, 2 for green and 3 for blue) accounts for the
        discrepancies you see.

        The ``get_pixels`` method provides an accurate representation of how the
        pixels end up in frame buffer memory after you have called ``set_pixels``.
    (Rt
get_pixels(((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyRDscC@stj|||�i|d6S(u�
    Sets a single pixel on the LED matrix to a specified color.

    x
        The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right.
    y
        The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom.
    color
        The new color of the pixel as a list of ``[R, G, B]`` values.

    CLI Example:

    .. code-block:: bash

        salt 'raspberry' sensehat.set_pixel 0 0 '[255, 0, 0]'
    ucolor(Rt	set_pixel(txtytcolor((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyRYscC@stj||�S(u4
    Returns the color of a single pixel on the LED matrix.

    x
        The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right.
    y
        The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom.

    .. note::
        Please read the note for ``get_pixels``
    (Rt	get_pixel(RR((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyRnscC@s|t_i|d6S(u�
    Sets the LED matrix to low light mode. Useful in a dark environment.

    CLI Example:

    .. code-block:: bash

        salt 'raspberry' sensehat.low_light
        salt 'raspberry' sensehat.low_light False
    u	low_light(Rt	low_light(R((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR}s	g�������?cC@s�|pdddg}|p'dddg}idddgd6dddgd6dddgd6dddgd6}||kr�||}ntj||||�i|d6S(	ud
    Displays a message on the LED matrix.

    message
        The message to display
    msg_type
        The type of the message. Changes the appearance of the message.

        Available types are::

            error:      red text
            warning:    orange text
            success:    green text
            info:       blue text

    scroll_speed
        The speed at which the message moves over the LED matrix.
        This value represents the time paused for between shifting the text
        to the left by one column of pixels. Defaults to '0.1'.
    text_color
        The color in which the message is shown. Defaults to '[255, 255, 255]' (white).
    back_color
        The background color of the display. Defaults to '[0, 0, 0]' (black).

    CLI Example:

    .. code-block:: bash

        salt 'raspberry' sensehat.show_message 'Status ok'
        salt 'raspberry' sensehat.show_message 'Something went wrong' error
        salt 'raspberry' sensehat.show_message 'Red' text_color='[255, 0, 0]'
        salt 'raspberry' sensehat.show_message 'Hello world' None '[0, 0, 255]' '[255, 255, 0]' 0.2
    i�iuerroriduwarningusuccessuinfoumessage(Rtshow_message(tmessagetmsg_typet
text_colort
back_colortscroll_speedt
color_by_type((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR�s#
cC@sH|pdddg}|p'dddg}tj|||�i|d6S(u
    Displays a single letter on the LED matrix.

    letter
        The letter to display
    text_color
        The color in which the letter is shown. Defaults to '[255, 255, 255]' (white).
    back_color
        The background color of the display. Defaults to '[0, 0, 0]' (black).

    CLI Example:

    .. code-block:: bash

        salt 'raspberry' sensehat.show_letter O
        salt 'raspberry' sensehat.show_letter X '[255, 0, 0]'
        salt 'raspberry' sensehat.show_letter B '[0, 0, 255]' '[255, 255, 0]'
    i�iuletter(Rtshow_letter(tletterRR((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR�scC@s
tj|�S(u�
    Displays an 8 x 8 image on the LED matrix.

    image
        The path to the image to display. The image must be 8 x 8 pixels in size.

    CLI Example:

    .. code-block:: bash

        salt 'raspberry' sensehat.show_image /tmp/my_image.png
    (Rt
load_image(timage((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyt
show_image�s
cC@s1|dkrtj�n
tj|�i|d6S(u�
    Sets the LED matrix to a single color or turns all LEDs off.

    CLI Example:

    .. code-block:: bash

        salt 'raspberry' sensehat.clear
        salt 'raspberry' sensehat.clear '[255, 0, 0]'
    ucolorN(tNoneRtclear(R((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR%�s

cC@s
tj�S(uK
    Get the percentage of relative humidity from the humidity sensor.
    (Rtget_humidity(((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR&�scC@s
tj�S(uJ
    Gets the current pressure in Millibars from the pressure sensor.
    (Rtget_pressure(((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR'scC@s
tj�S(u�
    Gets the temperature in degrees Celsius from the humidity sensor.
    Equivalent to calling ``get_temperature_from_humidity``.

    If you get strange results try using ``get_temperature_from_pressure``.
    (Rtget_temperature(((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR(
scC@s
tj�S(uK
    Gets the temperature in degrees Celsius from the humidity sensor.
    (Rtget_temperature_from_humidity(((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR)scC@s
tj�S(uK
    Gets the temperature in degrees Celsius from the pressure sensor.
    (Rtget_temperature_from_pressure(((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR*s(!t__doc__t
__future__RRRtloggingt	sense_hatRRRtImportErrort	NameErrorR$RRt	getLoggert__name__R	RRRRRRRRR#R%R&R'R(R)R*(((s9/usr/lib/python2.7/site-packages/salt/modules/sensehat.pyt<module>s2

					3				
	

Zerion Mini Shell 1.0