wok-current rev 16529

python-rpi-pyglow: small improvment to PiGlow vortex example
author Christophe Lincoln <pankso@slitaz.org>
date Sat Apr 26 11:12:31 2014 +0200 (2014-04-26)
parents 906854cfa70d
children caba70b580d2
files python-rpi-pyglow/stuff/vortex.py
line diff
     1.1 --- a/python-rpi-pyglow/stuff/vortex.py	Sat Apr 26 11:02:15 2014 +0200
     1.2 +++ b/python-rpi-pyglow/stuff/vortex.py	Sat Apr 26 11:12:31 2014 +0200
     1.3 @@ -1,8 +1,8 @@
     1.4  # Sample script for PiGlow that creates a continuous whirly vortex animation
     1.5  #
     1.6 -# Please see our GitHub repository for more information: https://github.com/pimoroni/piglow
     1.7 +# Official Pimorini example modified by Christophe Lincoln for SliTaz ARM
     1.8 +# See our GitHub repository for more information: https://github.com/pimoroni/piglow
     1.9  #
    1.10 -# Once running you'll need to press ctrl-C to cancel stop the script
    1.11  
    1.12  import time
    1.13  from smbus import SMBus
    1.14 @@ -27,7 +27,6 @@
    1.15  		self.write_i2c(CMD_ENABLE_LEDS, [0xFF, 0xFF, 0xFF])
    1.16  
    1.17  	def update_leds(self, values):
    1.18 -		print "update pwm"
    1.19  		self.write_i2c(CMD_SET_PWM_VALUES, values)
    1.20  		self.write_i2c(CMD_UPDATE, 0xFF)
    1.21  
    1.22 @@ -54,18 +53,19 @@
    1.23  # loop forever, i mean why would we ever want to stop now the party has started?
    1.24  # you can however use Ctrl+C to stop the script and reset the LEDs to off state
    1.25  try:
    1.26 -        while True:
    1.27 -                # pop the first value off then drop it back on again - this just cycles the values around
    1.28 -                values.append(values.pop(0))
    1.29 +	print "Use Ctrl-C to stop"
    1.30 +	while True:
    1.31 +		# pop the first value off then drop it back on again - this just cycles the values around
    1.32 +		values.append(values.pop(0))
    1.33  
    1.34 -                # update the piglow with current values
    1.35 -                piglow.update_leds(values)
    1.36 +		# update the piglow with current values
    1.37 +		piglow.update_leds(values)
    1.38  
    1.39 -                # sleep for a bit, don't go too fast!
    1.40 -                time.sleep(0.1)
    1.41 +		# sleep for a bit, don't go too fast!
    1.42 +		time.sleep(0.1)
    1.43                  
    1.44  except KeyboardInterrupt:
    1.45  	# set all the LEDs to "off" when Ctrl+C is pressed before exiting
    1.46 -        values = [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
    1.47 -        piglow.update_leds(values)
    1.48 +	values = [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
    1.49 +	piglow.update_leds(values)
    1.50