File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed
Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ # App
2+ #
3+ # Copyright (c) 2014 Charles Weir. Shared under the MIT Licence.
4+
5+ import sys , os # Python path kludge - omit these 2 lines if BrickPython is installed.
6+ sys .path .insert (0 , os .path .dirname (os .path .dirname (os .path .abspath (sys .argv [0 ]))))
7+
8+ from BrickPython .TkApplication import TkApplication
9+ from BrickPython .Sensor import Sensor
10+ import logging
11+
12+ class App (TkApplication ):
13+ '''Application to
14+ '''
15+
16+ def __init__ (self ):
17+ TkApplication .__init__ (self , {'1' : Sensor .ULTRASONIC_CONT , '4' : Sensor .TOUCH })
18+ self .doorLocked = False
19+ self .addSensorCoroutine ( self .turnWhenDetected () )
20+ self .root .wm_title ("Trial running" )
21+ for c in "ABCD" :
22+ self .motor (c ).zeroPosition ()
23+
24+ def turnWhenDetected (self ):
25+ while True :
26+ for i in self .waitMilliseconds (500 ): yield
27+ print self .sensor ('4' ).value ()
28+
29+
30+ ## for c in "ABCD":
31+ ## motor= self.motor(c)
32+ ## for i in motor.moveTo(90*2): yield
33+ ## for i in motor.moveTo(0): yield
34+ ##
35+
36+ if __name__ == "__main__" :
37+ logging .basicConfig (format = '%(message)s' , level = logging .DEBUG ) # All log messages printed to console.
38+ logging .info ( "Starting" )
39+ app = App ()
40+ app .mainloop ()
Original file line number Diff line number Diff line change 1+ #! /bin/ksh
2+ # Runs a command remotely on the BrickPi, assuming default credentials and device name.
3+ # Copies whole BrickPython directory structure to the same location on the raspberrypi
4+ # E.g.
5+ # cd ExamplePrograms; ../runbp python SimpleApp.py
6+
7+ # This script lives in the BrickPython project directory
8+ # To make it executable:
9+ # chmod a+x runpb
10+ # To make ssh work without entering passwords, see
11+ # https://www.debian.org/devel/passwordlessssh
12+ # Note - The windows will appear on the BrickPi's screen, not locally to this machine.
13+
14+ # Current working directory relative to home:
15+ WorkingRelDir=${PWD# $HOME / }
16+
17+ # BrickPython project directory relative to home:
18+ BrickPythonDir=$( cd $( dirname $0 ) ; echo $PWD )
19+ BrickPythonRelativeDir=${BrickPythonDir# $HOME / }
20+
21+ (
22+ cd ~
23+ tar cf - $BrickPythonRelativeDir | ssh pi@raspberrypi " (rm -rf $BrickPythonRelativeDir ; tar xf -)"
24+ )
25+ ssh -t pi@raspberrypi " (export DISPLAY=:1.0; cd $WorkingRelDir ; $* )"
You can’t perform that action at this time.
0 commit comments