This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- # Find the index of the blob with the most pixels. | |
- most_pixels = 0 | |
- largest_blob = 0 | |
- for i in range(len(blobs)): | |
- if blobs[i].pixels() > most_pixels: | |
- most_pixels = blobs[i].pixels() | |
- largest_blob = i | |
+ # Find the blob with the most pixels. | |
+ largest_blob = max(blobs, key=lambda b: b.pixels()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PiStorms import PiStorms | |
from TouchScreenInput import TouchScreenInput | |
from functools import partial | |
psm = PiStorms() | |
textbox = TouchScreenInput(psm.screen) | |
textbox.bind_led_on_func(partial(psm.led, 1, 255, 0, 0)) | |
textbox.bind_led_off_func(partial(psm.led, 1, *[0]*3)) | |
result = textbox.getInput() | |
psm.screen.showMessage(['Your answer', result['response']]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b=`grep homefolder /usr/local/mindsensors/conf/msdev.cfg | cut -d"=" -f2 | cut -c 2-` | |
for f in 'MSDriver.py' 'MSBrowser.py' 'psm_shutdown' 'swarmserver' 'pistorms-diag.sh'; do sudo ln -f $b/sys/$f /usr/local/bin/$f; done | |
chmod +x $b/sys/swarmserver $b/sys/pistorms-diag.sh $b/programs/addresschange | |
for f in 'rmap.py' 'rmapcfg.py' 'scratch.py' 'PiStorms.py' 'PiStormsCom.py' 'TouchScreenInput.py' 'mindsensorsUI.py' 'MS_ILI9341.py' 'mindsensors.py' 'MsDevices.py' 'LegoDevices.py' 'swarmclient.py'; do sudo ln -f $b/sys/$f /usr/local/lib/python2.7/dist-packages/$f; done | |
sudo rm -rf /var/www | |
sudo ln -s $b/www /var/www | |
sudo ln -f $b/sys/msdev.cfg /usr/local/mindsensors/conf/msdev.cfg | |
# skipping images, art, scratch, changing ownerships... programs are still only in /home/pi/PiStorms | |
for f in 'MSDriver.sh' 'MSBrowser.sh' 'MSWeb.sh' 'SwarmServer.sh'; do sudo ln -f $b/setup/$f /etc/init.d/$f; done | |
for f in 'MSDriver.sh' 'MSBrowser.sh' 'MSWeb.sh' 'SwarmServer.sh'; do chmod +x $b/setup/$f; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("/usr/share/dict/words") as f: | |
dict = [word.rstrip('\n') for word in f] | |
import random | |
print random.choice(dict) | |
# or, a one-liner | |
random.choice(open("/usr/share/dict/words").readlines())[:-1] | |
# in an isolated environment: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+-1 | |
--1 | |
-----1 | |
+++++1 | |
++++++++--------1 | |
1*-+-+-+-+-+-+-+-+-+-+-+-1*-+1/+-+-+-+-+-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
admin@roboRIO-1086-FRC:~$ clcp_sd540c scan | |
{"scan":[10,12,13,15,16,17,18]} | |
admin@roboRIO-1086-FRC:~$ for id in 1{0,2,3,{5..8}}; do clcp_sd540c $id name; done | |
status: 0 | |
{"name":"GreenTen"} | |
status: 0 | |
{"name":"YellowTw"} | |
status: 0 | |
{"name":"GreenThi"} | |
status: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PiStorms import PiStorms | |
def calibrate(psm): | |
def generateA(X,Y): | |
for (x,y) in zip(X,Y): | |
psm.screen.fillRect(x,y, 1,1, (255,0,0)) | |
while psm.isKeyPressed(): pass # wait until the button is released from a possible previous press | |
while not psm.isKeyPressed(): pass # wait until the key is pressed down again | |
tsX = int(psm.screen.RAW_X()) # mindsensors_i2c.readInteger should really already return an integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<title>CSS3 Animations Examples</title> | |
<head> | |
<style> | |
@keyframes fadeIn { | |
from { opacity: 0; } | |
to { opacity: 1; } | |
} | |
@keyframes fadeInUp { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PiStorms import PiStorms | |
from TouchScreenInput import TouchScreenInput | |
from functools import partial | |
psm = PiStorms() | |
textbox = TouchScreenInput(psm.screen) | |
textbox.bind_led_on_func(partial(psm.led, 1, 255, 0, 0)) | |
textbox.bind_led_off_func(partial(psm.led, 1, *[0]*3)) | |
result = textbox.getInput() | |
psm.screen.showMessage(['Your answer', result['response']]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LegoDevices.py:298: Compound LegoDevices::EV3ColorSensor | |
swarmclient.py:60: Compound swarmclient::SwarmClient | |
LegoDevices.py:347: Compound LegoDevices::EV3InfraredSensor | |
LegoDevices.py:311: Compound LegoDevices::EV3GyroSensor | |
LegoDevices.py:257: Compound LegoDevices::NXTLightSensor | |
PiStormsCom.py:33: Compound PiStormsCom::PSSensor | |
MS_ILI9341.py:31: Compound MS_ILI9341::ILI9341 | |
LegoDevices.py:199: Compound LegoDevices::EV3TouchSensor | |
scratch.py:9: Compound scratch::Scratch | |
LegoDevices.py:330: Compound LegoDevices::EV3UltrasonicSensor |