%PDF- %PDF-
Direktori : /lib/python2.7/site-packages/salt/modules/ |
Current File : //lib/python2.7/site-packages/salt/modules/sensehat.pyc |
� ���^c @@ s d Z d d l m Z m Z m Z d d l Z y d d l m Z e Z Wn# e e f k rm d Z e Z n Xe j e � Z d � Z d � Z d � Z d � Z d � Z e d � Z d d d d d � Z d d d � Z d � Z d d � Z d � Z d � Z d � Z d � Z d � Z d S( 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 ( t absolute_importt unicode_literalst print_functionN( t SenseHatc C@ s~ t rt y t � } Wn t k r- t d f SXt d d d � } | d k r` | j | t � n t j d | � t St d f S( 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.getu sensehat:rotationi iZ i� i u3 %s is not a valid rotation. Using default rotation.uW The SenseHat execution module cannot be loaded: 'sense_hat' python library unavailable.( i iZ i� i ( t has_sense_hatR t OSErrort Falset __salt__t set_rotationt logt errort True( t _sensehatt rotation( ( s9 /usr/lib/python2.7/site-packages/salt/modules/sensehat.pyt __virtual__$ s c C@ s t j | � i | d 6S( u� Sets the entire LED matrix based on a list of 64 pixel values pixels A list of 64 ``[R, G, B]`` color values. u pixels( R t set_pixels( t pixels( ( s9 /usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR 9 s c C@ s t j � 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.pyR D s c C@ s t j | | | � i | d 6S( 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]' u color( R t set_pixel( t xt yt color( ( s9 /usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR Y s c C@ s t j | | � 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( R R ( ( s9 /usr/lib/python2.7/site-packages/salt/modules/sensehat.pyR n s c C@ s | t _ i | d 6S( 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�������?c C@ s� | p d d d g } | p'