Skip to content

Commit

Permalink
Add marker for executable script
Browse files Browse the repository at this point in the history
  • Loading branch information
tinue committed Jul 28, 2021
1 parent d21c4c5 commit 8e0b199
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 59 deletions.
68 changes: 37 additions & 31 deletions runcolorcycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,40 @@

NUM_LED = 576

# One Cycle with one step and a pause of three seconds. Hence three seconds of white light
print('Three Seconds of white light')
MY_CYCLE = colorschemes.Solid(num_led=NUM_LED, pause_value=3,
num_steps_per_cycle=1, num_cycles=1, order='rgb')
MY_CYCLE.start()

# Go twice around the clock
print('Go twice around the clock')
MY_CYCLE = colorschemes.RoundAndRound(num_led=NUM_LED, pause_value=0,
num_steps_per_cycle=NUM_LED, num_cycles=2, order='rgb')
MY_CYCLE.start()

# One cycle of red, green and blue each
print('One strandtest of red, green and blue each')
MY_CYCLE = colorschemes.StrandTest(num_led=NUM_LED, pause_value=0,
num_steps_per_cycle=NUM_LED, num_cycles=3, order='rgb')
MY_CYCLE.start()

# One slow trip through the rainbow
print('One slow trip through the rainbow')
MY_CYCLE = colorschemes.Rainbow(num_led=NUM_LED, pause_value=0,
num_steps_per_cycle=255, num_cycles=1, order='rgb')
MY_CYCLE.start()

# Five quick trips through the rainbow
print('Five quick trips through the rainbow')
MY_CYCLE = colorschemes.TheaterChase(num_led=NUM_LED, pause_value=0.04,
num_steps_per_cycle=35, num_cycles=5, order='rgb')
MY_CYCLE.start()

print('Finished the test')

def main():
# One Cycle with one step and a pause of three seconds. Hence three seconds of white light
print('Three Seconds of white light')
my_cycle = colorschemes.Solid(num_led=NUM_LED, pause_value=3,
num_steps_per_cycle=1, num_cycles=1, order='rgb')
my_cycle.start()

# Go twice around the clock
print('Go twice around the clock')
my_cycle = colorschemes.RoundAndRound(num_led=NUM_LED, pause_value=0,
num_steps_per_cycle=NUM_LED, num_cycles=2, order='rgb')
my_cycle.start()

# One cycle of red, green and blue each
print('One strandtest of red, green and blue each')
my_cycle = colorschemes.StrandTest(num_led=NUM_LED, pause_value=0,
num_steps_per_cycle=NUM_LED, num_cycles=3, order='rgb')
my_cycle.start()

# One slow trip through the rainbow
print('One slow trip through the rainbow')
my_cycle = colorschemes.Rainbow(num_led=NUM_LED, pause_value=0,
num_steps_per_cycle=255, num_cycles=1, order='rgb')
my_cycle.start()

# Five quick trips through the rainbow
print('Five quick trips through the rainbow')
my_cycle = colorschemes.TheaterChase(num_led=NUM_LED, pause_value=0.04,
num_steps_per_cycle=35, num_cycles=5, order='rgb')
my_cycle.start()

print('Finished the test')


if __name__ == '__main__':
main()
28 changes: 17 additions & 11 deletions runcolorcycle_blinkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
MOSI = 23 # Hardware SPI uses BCM 10 & 11. Change these values for bit bang mode
SCLK = 24 # e.g. MOSI = 23, SCLK = 24 for Pimoroni Phat Beat or Blinkt!

# Paint white, red, green and blue once for one second
print('White, red, green, blue on all LEDs')
MY_CYCLE = colorschemes.Solid(num_led=NUM_LED, pause_value=1, order='rgb',
num_steps_per_cycle=4, num_cycles=1, mosi=MOSI, sclk=SCLK)
MY_CYCLE.start()

# Five trips through the rainbow
print('Five trips through the rainbow')
MY_CYCLE = colorschemes.Rainbow(num_led=NUM_LED, pause_value=0, order='rgb',
num_steps_per_cycle=255, num_cycles=5, mosi=MOSI, sclk=SCLK)
MY_CYCLE.start()
def main():
# Paint white, red, green and blue once for one second
print('White, red, green, blue on all LEDs')
my_cycle = colorschemes.Solid(num_led=NUM_LED, pause_value=1, order='rgb',
num_steps_per_cycle=4, num_cycles=1, mosi=MOSI, sclk=SCLK)
my_cycle.start()

print('Finished the test')
# Five trips through the rainbow
print('Five trips through the rainbow')
my_cycle = colorschemes.Rainbow(num_led=NUM_LED, pause_value=0, order='rgb',
num_steps_per_cycle=255, num_cycles=5, mosi=MOSI, sclk=SCLK)
my_cycle.start()

print('Finished the test')


if __name__ == '__main__':
main()
40 changes: 23 additions & 17 deletions sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,31 @@
from apa102_pi.driver import apa102
import time

# Initialize the library and the strip
strip = apa102.APA102(num_led=430, mosi=10, sclk=11, order='rbg')

# Increase the brightness to 100% (from the default of 12.5%)
strip.set_global_brightness(31)
# Turn off all pixels (sometimes a few light up when the strip gets power)
strip.clear_strip()
def main():
# Initialize the library and the strip
strip = apa102.APA102(num_led=430, mosi=10, sclk=11, order='rbg')

# Prepare a few individual pixels
strip.set_pixel_rgb(12, 0xFF0000) # Red
strip.set_pixel_rgb(24, 0xFFFFFF) # White
strip.set_pixel_rgb(40, 0x00FF00) # Green
# Increase the brightness to 100% (from the default of 12.5%)
strip.set_global_brightness(31)
# Turn off all pixels (sometimes a few light up when the strip gets power)
strip.clear_strip()

# Copy the buffer to the Strip (i.e. show the prepared pixels)
strip.show()
# Prepare a few individual pixels
strip.set_pixel_rgb(12, 0xFF0000) # Red
strip.set_pixel_rgb(24, 0xFFFFFF) # White
strip.set_pixel_rgb(40, 0x00FF00) # Green

# Wait a few Seconds, to check the result
time.sleep(20)
# Copy the buffer to the Strip (i.e. show the prepared pixels)
strip.show()

# Clear the strip and shut down
strip.clear_strip()
strip.cleanup()
# Wait a few Seconds, to check the result
time.sleep(20)

# Clear the strip and shut down
strip.clear_strip()
strip.cleanup()


if __name__ == '__main__':
main()

0 comments on commit 8e0b199

Please sign in to comment.