mirror of
				https://github.com/eclipse/upm.git
				synced 2025-11-04 09:05:34 +03:00 
			
		
		
		
	python_examples: Reformatted, self-checking, executable
* Moved body of each python example to main.  This allows for basic
      load module testing for CI
    * General cleanup of python modules (crlf/tabs/prints/etc)
    * Chmod'ed to 755 to allow running examples without specifying the
      python interpreter
    * Added ctest for loading python2/3 modules
    * Added jniclasscode pragma for java swig interface files.
    * Updated check_examplenames.py module to check all languages vs. a
      cxx example name
    * Added tests for checking python module and test loading
    * Added 'make test' to travis-ci run (run ctests)
    * Print a more meaningful message when not building cxx docs into
      python modules
    * Updated check_clean.py to only check java wrapper files
    * ENABLED ctests for UPM
    * Deleted using_carrays.py python example - this is covered by other
      examples
Signed-off-by: Noel Eck <noel.eck@intel.com>
			
			
This commit is contained in:
		@@ -33,8 +33,10 @@ before_script:
 | 
				
			|||||||
script:
 | 
					script:
 | 
				
			||||||
  - echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
 | 
					  - echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
 | 
				
			||||||
  - git clone https://github.com/intel-iot-devkit/mraa.git $MRAA_ROOT
 | 
					  - git clone https://github.com/intel-iot-devkit/mraa.git $MRAA_ROOT
 | 
				
			||||||
  - mkdir -p $MRAA_BUILD && cd $_ && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=OFF -DFIRMATA=ON -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=$MRAA_INSTALL $MRAA_ROOT && make install
 | 
					  - mkdir -p $MRAA_BUILD && cd $_ && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=ON -DFIRMATA=ON -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=$MRAA_INSTALL $MRAA_ROOT && make install
 | 
				
			||||||
  - cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && PKG_CONFIG_PATH=$MRAA_INSTALL/lib/pkgconfig cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA -DCMAKE_INSTALL_PREFIX:PATH=$UPM_INSTALL .. && make install
 | 
					  - cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && PKG_CONFIG_PATH=$MRAA_INSTALL/lib/pkgconfig cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA -DBUILDTESTS=ON -DCMAKE_INSTALL_PREFIX:PATH=$UPM_INSTALL ..
 | 
				
			||||||
 | 
					  - make install
 | 
				
			||||||
 | 
					  - LD_LIBRARY_PATH=$MRAA_INSTALL/lib:$UPM_INSTALL/lib:$LD_LIBRARY_PATH PYTHONPATH=$UPM_INSTALL/lib/python2.7/site-packages/:$MRAA_INSTALL/lib/python2.7/dist-packages/ ctest --output-on-failure -E examplenames_js
 | 
				
			||||||
addons:
 | 
					addons:
 | 
				
			||||||
  apt:
 | 
					  apt:
 | 
				
			||||||
    sources:
 | 
					    sources:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,73 +1,72 @@
 | 
				
			|||||||
# Mapping C++ sample files to Java sample files
 | 
					# Mapping examples across provided languages
 | 
				
			||||||
a110x-intr.cxx	A110X_intrSample.java
 | 
					a110x.cxx	A110XSample.java	a110x.js	a110x.py
 | 
				
			||||||
a110x.cxx	A110XSample.java
 | 
					a110x-intr.cxx	A110X_intrSample.java	a110x-intr.js	a110x-intr.py
 | 
				
			||||||
adc121c021.cxx	ADC121C021Sample.java
 | 
					adc121c021.cxx	ADC121C021Sample.java	adc121c021.js	adc121c021.py
 | 
				
			||||||
adxl345.cxx	Adxl345Sample.java
 | 
					adxl345.cxx	Adxl345Sample.java	adxl345.js	adxl345.py
 | 
				
			||||||
biss0001.cxx	BISS0001Sample.java
 | 
					biss0001.cxx	BISS0001Sample.java	biss0001.js	biss0001.py
 | 
				
			||||||
bmpx8x.cxx	BMPX8XSample.java
 | 
					bmpx8x.cxx	BMPX8XSample.java	bmpx8x.js	bmpx8x.py
 | 
				
			||||||
buzzer-sound.cxx	Buzzer_soundSample.java
 | 
					button.cxx	ButtonSample.java	button.js	button.py
 | 
				
			||||||
cjq4435.cxx	CJQ4435Sample.java
 | 
					buzzer-sound.cxx	Buzzer_soundSample.java	buzzer-sound.js	buzzer-sound.py
 | 
				
			||||||
ds1307.cxx	DS1307Sample.java
 | 
					cjq4435.cxx	CJQ4435Sample.java	cjq4435.js	cjq4435.py
 | 
				
			||||||
enc03r.cxx	ENC03RSample.java
 | 
					ds1307.cxx	DS1307Sample.java	ds1307.js	ds1307.py
 | 
				
			||||||
es08a.cxx	ES08ASample.java
 | 
					enc03r.cxx	ENC03RSample.java	enc03r.js	enc03r.py
 | 
				
			||||||
button.cxx	ButtonSample.java
 | 
					es08a.cxx	ES08ASample.java	es08a.js	es08a.py
 | 
				
			||||||
groveehr.cxx	GroveEHRSample.java
 | 
					groveehr.cxx	GroveEHRSample.java	groveehr.js	groveehr.py
 | 
				
			||||||
groveled.cxx	GroveLEDSample.java
 | 
					groveledbar.cxx	GroveLEDBar.java	groveledbar.js	groveledbar.py
 | 
				
			||||||
grovelinefinder.cxx	GroveLineFinderSample.java
 | 
					groveled.cxx	GroveLEDSample.java	groveled.js	groveled.py
 | 
				
			||||||
light.cxx	LightSample.java
 | 
					grovelinefinder.cxx	GroveLineFinderSample.java	grovelinefinder.js	grovelinefinder.py
 | 
				
			||||||
grovemoisture.cxx	GroveMoistureSample.java
 | 
					grovemoisture.cxx	GroveMoistureSample.java	grovemoisture.js	grovemoisture.py
 | 
				
			||||||
relay.cxx	RelaySample.java
 | 
					grovescam.cxx	GROVESCAMSample.java	grovescam.js	grovescam.py
 | 
				
			||||||
rotary.cxx	RotarySample.java
 | 
					grovewfs.cxx	GroveWFSSample.java	grovewfs.js	grovewfs.py
 | 
				
			||||||
grovescam.cxx	GROVESCAMSample.java
 | 
					guvas12d.cxx	GUVAS12DSample.java	guvas12d.js	guvas12d.py
 | 
				
			||||||
slide.cxx	SlideSample.java
 | 
					h3lis331dl.cxx	H3LIS331DLSample.java	h3lis331dl.js	h3lis331dl.py
 | 
				
			||||||
speaker.cxx	SpeakerSample.java
 | 
					hcsr04.cxx	HCSR04Sample.java	hcsr04.js	hcsr04.py
 | 
				
			||||||
vdiv.cxx	VDivSample.java
 | 
					hm11.cxx	HM11Sample.java	hm11.js	hm11.py
 | 
				
			||||||
water.cxx	WaterSample.java
 | 
					hmc5883l.cxx	Hmc5883lSample.java	hmc5883l.js	hmc5883l.py
 | 
				
			||||||
grovewfs.cxx	GroveWFSSample.java
 | 
					htu21d.cxx	HTU21DSample.java	htu21d.js	htu21d.py
 | 
				
			||||||
guvas12d.cxx	GUVAS12DSample.java
 | 
					itg3200.cxx	Itg3200Sample.java	itg3200.js	itg3200.py
 | 
				
			||||||
h3lis331dl.cxx	H3LIS331DLSample.java
 | 
					jhd1313m1-lcd.cxx	Jhd1313m1_lcdSample.java	jhd1313m1-lcd.js	jhd1313m1-lcd.py
 | 
				
			||||||
hcsr04.cxx	HCSR04Sample.java
 | 
					joystick12.cxx	Joystick12Sample.java	joystick12.js	joystick12.py
 | 
				
			||||||
hm11.cxx	HM11Sample.java
 | 
					lcm1602-i2c.cxx	Lcm1602_i2cSample.java	lcm1602-i2c.js	lcm1602-i2c.py
 | 
				
			||||||
hmc5883l.cxx	Hmc5883lSample.java
 | 
					ldt0028.cxx	LDT0028Sample.java	ldt0028.js	ldt0028.py
 | 
				
			||||||
htu21d.cxx	HTU21DSample.java
 | 
					light.cxx	LightSample.java	light.js	light.py
 | 
				
			||||||
itg3200.cxx	Itg3200Sample.java
 | 
					lol.cxx	LoLSample.java	lol.js	lol.py
 | 
				
			||||||
jhd1313m1-lcd.cxx	Jhd1313m1_lcdSample.java
 | 
					lsm303.cxx	LSM303Sample.java	lsm303.js	lsm303.py
 | 
				
			||||||
joystick12.cxx	Joystick12Sample.java
 | 
					m24lr64e.cxx	M24LR64ESample.java	m24lr64e.js	m24lr64e.py
 | 
				
			||||||
lcm1602-i2c.cxx	Lcm1602_i2cSample.java
 | 
					max44000.cxx	MAX44000Sample.java	max44000.js	max44000.py
 | 
				
			||||||
ldt0028.cxx	LDT0028Sample.java
 | 
					mic.cxx	MicrophoneSample.java	mic.js	mic.py
 | 
				
			||||||
lol.cxx	LoLSample.java
 | 
					mma7455.cxx	MMA7455Sample.java	mma7455.js	mma7455.py
 | 
				
			||||||
lsm303.cxx	LSM303Sample.java
 | 
					mma7660.cxx	MMA7660Sample.java	mma7660.js	mma7660.py
 | 
				
			||||||
m24lr64e.cxx	M24LR64ESample.java
 | 
					mpl3115a2.cxx	MPL3115A2Sample.java	mpl3115a2.js	mpl3115a2.py
 | 
				
			||||||
max44000.cxx	MAX44000Sample.java
 | 
					mpr121.cxx	MPR121Sample.java	mpr121.js	mpr121.py
 | 
				
			||||||
mic.cxx	MicrophoneSample.java
 | 
					mpu9150.cxx	MPU9150Sample.java	mpu9150.js	mpu9150.py
 | 
				
			||||||
mma7455.cxx	MMA7455Sample.java
 | 
					mq2.cxx	MQ2Sample.java	mq2.js	mq2.py
 | 
				
			||||||
mma7660.cxx	MMA7660Sample.java
 | 
					mq303a.cxx	MQ303ASample.java	mq303a.js	mq303a.py
 | 
				
			||||||
mpl3115a2.cxx	MPL3115A2Sample.java
 | 
					mq5.cxx	MQ5Sample.java	mq5.js	mq5.py
 | 
				
			||||||
mpr121.cxx	MPR121Sample.java
 | 
					nrf24l01-receiver.cxx	NRF24L01_receiverSample.java	nrf24l01-receiver.js	nrf24l01-receiver.py
 | 
				
			||||||
mpu9150.cxx	MPU9150Sample.java
 | 
					nrf24l01-transmitter.cxx	NRF24L01_transmitterSample.java	nrf24l01-transmitter.js	nrf24l01-transmitter.py
 | 
				
			||||||
mq2.cxx	MQ2Sample.java
 | 
					nunchuck.cxx	NUNCHUCKSample.java	nunchuck.js	nunchuck.py
 | 
				
			||||||
mq303a.cxx	MQ303ASample.java
 | 
					otp538u.cxx	OTP538USample.java	otp538u.js	otp538u.py
 | 
				
			||||||
mq5.cxx	MQ5Sample.java
 | 
					ppd42ns.cxx	PPD42NSSample.java	ppd42ns.js	ppd42ns.py
 | 
				
			||||||
groveledbar	GroveLEDBar
 | 
					pulsensor.cxx	PulsensorSample.java	pulsensor.js	pulsensor.py
 | 
				
			||||||
nrf24l01-receiver.cxx	NRF24L01_receiverSample.java
 | 
					relay.cxx	RelaySample.java	relay.js	relay.py
 | 
				
			||||||
nrf24l01-transmitter.cxx	NRF24L01_transmitterSample.java
 | 
					rfr359f.cxx	RFR359FSample.java	rfr359f.js	rfr359f.py
 | 
				
			||||||
nunchuck.cxx	NUNCHUCKSample.java
 | 
					rotary.cxx	RotarySample.java	rotary.js	rotary.py
 | 
				
			||||||
otp538u.cxx	OTP538USample.java
 | 
					rotaryencoder.cxx	RotaryEncoderSample.java	rotaryencoder.js	rotaryencoder.py
 | 
				
			||||||
ppd42ns.cxx	PPD42NSSample.java
 | 
					rpr220.cxx	RPR220Sample.java	rpr220.js	rpr220.py
 | 
				
			||||||
pulsensor.cxx	PulsensorSample.java
 | 
					rpr220-intr.cxx	RPR220_intrSample.java	rpr220-intr.js	rpr220-intr.py
 | 
				
			||||||
rfr359f.cxx	RFR359FSample.java
 | 
					slide.cxx	SlideSample.java	slide.js	slide.py
 | 
				
			||||||
rotaryencoder.cxx	RotaryEncoderSample.java
 | 
					speaker.cxx	SpeakerSample.java	speaker.js	speaker.py
 | 
				
			||||||
rpr220-intr.cxx	RPR220_intrSample.java
 | 
					ssd1308-oled.cxx	SSD1308_oledSample.java	ssd1308-oled.js	ssd1308-oled.py
 | 
				
			||||||
rpr220.cxx	RPR220Sample.java
 | 
					ssd1327-oled.cxx	SSD1327_oledSample.java	ssd1327-oled.js	ssd1327-oled.py
 | 
				
			||||||
ssd1308-oled.cxx	SSD1308_oledSample.java
 | 
					st7735.cxx	ST7735Sample.java	st7735.js	st7735.py
 | 
				
			||||||
ssd1327-oled.cxx	SSD1327_oledSample.java
 | 
					stepmotor.cxx	StepMotorSample.java	stepmotor.js	stepmotor.py
 | 
				
			||||||
st7735.cxx	ST7735Sample.java
 | 
					tm1637.cxx	TM1637Sample.java	tm1637.js	tm1637.py
 | 
				
			||||||
stepmotor.cxx	StepMotorSample.java
 | 
					tp401.cxx	TP401Sample.java	tp401.js	tp401.py
 | 
				
			||||||
tm1637.cxx	TM1637Sample.java
 | 
					tsl2561.cxx	TSL2561Sample.java	tsl2561.js	tsl2561.py
 | 
				
			||||||
tp401.cxx	TP401Sample.java
 | 
					ttp223.cxx	TTP223Sample.java	ttp223.js	ttp223.py
 | 
				
			||||||
tsl2561.cxx	TSL2561Sample.java
 | 
					uln200xa.cxx	ULN200XASample.java	uln200xa.js	uln200xa.py
 | 
				
			||||||
ttp223.cxx	TTP223Sample.java
 | 
					vdiv.cxx	VDivSample.java	vdiv.js	vdiv.py
 | 
				
			||||||
ublox6.cxx	Ublox6Sample.java
 | 
					water.cxx	WaterSample.java	water.js	water.py
 | 
				
			||||||
uln200xa.cxx	ULN200XASample.java
 | 
					wt5001.cxx	WT5001Sample.java	wt5001.js	wt5001.py
 | 
				
			||||||
wt5001.cxx	WT5001Sample.java
 | 
					yg1006.cxx	YG1006Sample.java	yg1006.js	yg1006.py
 | 
				
			||||||
yg1006.cxx	YG1006Sample.java
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/a110x.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/a110x.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_a110x as upmA110x
 | 
					import pyupm_a110x as upmA110x
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Hall Effect magnet sensor on digital pin D2
 | 
					    # Instantiate a Hall Effect magnet sensor on digital pin D2
 | 
				
			||||||
    myHallEffectSensor = upmA110x.A110X(2)
 | 
					    myHallEffectSensor = upmA110x.A110X(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -42,10 +42,12 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        if (myHallEffectSensor.magnetDetected()):
 | 
					        if (myHallEffectSensor.magnetDetected()):
 | 
				
			||||||
            print "Magnet (south polarity) detected."
 | 
					            print "Magnet (south polarity) detected."
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print "No magnet detected."
 | 
					            print "No magnet detected."
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/ad8232.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/ad8232.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ad8232 as upmAD8232
 | 
					import pyupm_ad8232 as upmAD8232
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a AD8232 sensor on digital pins 10 (LO+), 11 (LO-)
 | 
					    # Instantiate a AD8232 sensor on digital pins 10 (LO+), 11 (LO-)
 | 
				
			||||||
    # and an analog pin, 0 (OUTPUT)
 | 
					    # and an analog pin, 0 (OUTPUT)
 | 
				
			||||||
    myAD8232 = upmAD8232.AD8232(10, 11, 0)
 | 
					    myAD8232 = upmAD8232.AD8232(10, 11, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -43,7 +43,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Output the raw numbers from the ADC, for plotting elsewhere.
 | 
					    # Output the raw numbers from the ADC, for plotting elsewhere.
 | 
				
			||||||
    # A return of 0 indicates a Lead Off (LO) condition.
 | 
					    # A return of 0 indicates a Lead Off (LO) condition.
 | 
				
			||||||
    # In theory, this data could be fed to software like Processing
 | 
					    # In theory, this data could be fed to software like Processing
 | 
				
			||||||
@@ -52,3 +51,6 @@ signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			|||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        print myAD8232.value()
 | 
					        print myAD8232.value()
 | 
				
			||||||
        time.sleep(.001)
 | 
					        time.sleep(.001)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								examples/python/adafruitms1438-stepper.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										8
									
								
								examples/python/adafruitms1438-stepper.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,7 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_adafruitms1438 as upmAdafruitms1438
 | 
					import pyupm_adafruitms1438 as upmAdafruitms1438
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Import header values
 | 
					    # Import header values
 | 
				
			||||||
    I2CBus = upmAdafruitms1438.ADAFRUITMS1438_I2C_BUS
 | 
					    I2CBus = upmAdafruitms1438.ADAFRUITMS1438_I2C_BUS
 | 
				
			||||||
    I2CAddr = upmAdafruitms1438.ADAFRUITMS1438_DEFAULT_I2C_ADDR
 | 
					    I2CAddr = upmAdafruitms1438.ADAFRUITMS1438_DEFAULT_I2C_ADDR
 | 
				
			||||||
@@ -33,11 +33,9 @@ M12Motor = upmAdafruitms1438.AdafruitMS1438.STEPMOTOR_M12
 | 
				
			|||||||
    MotorDirCW = upmAdafruitms1438.AdafruitMS1438.DIR_CW
 | 
					    MotorDirCW = upmAdafruitms1438.AdafruitMS1438.DIR_CW
 | 
				
			||||||
    MotorDirCCW = upmAdafruitms1438.AdafruitMS1438.DIR_CCW
 | 
					    MotorDirCCW = upmAdafruitms1438.AdafruitMS1438.DIR_CCW
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Instantiate an Adafruit MS 1438 on I2C bus 0
 | 
					    # Instantiate an Adafruit MS 1438 on I2C bus 0
 | 
				
			||||||
    myMotorShield = upmAdafruitms1438.AdafruitMS1438(I2CBus, I2CAddr)
 | 
					    myMotorShield = upmAdafruitms1438.AdafruitMS1438(I2CBus, I2CAddr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -54,7 +52,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Setup for use with a stepper motor connected to the M1 & M2 ports
 | 
					    # Setup for use with a stepper motor connected to the M1 & M2 ports
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # set a PWM period of 50Hz
 | 
					    # set a PWM period of 50Hz
 | 
				
			||||||
@@ -86,3 +83,6 @@ myMotorShield.stepperSteps(M12Motor, 100)
 | 
				
			|||||||
    print "Disabling..."
 | 
					    print "Disabling..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # exitHandler runs automatically
 | 
					    # exitHandler runs automatically
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								examples/python/adafruitms1438.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										8
									
								
								examples/python/adafruitms1438.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,7 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_adafruitms1438 as upmAdafruitms1438
 | 
					import pyupm_adafruitms1438 as upmAdafruitms1438
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Import header values
 | 
					    # Import header values
 | 
				
			||||||
    I2CBus = upmAdafruitms1438.ADAFRUITMS1438_I2C_BUS
 | 
					    I2CBus = upmAdafruitms1438.ADAFRUITMS1438_I2C_BUS
 | 
				
			||||||
    I2CAddr = upmAdafruitms1438.ADAFRUITMS1438_DEFAULT_I2C_ADDR
 | 
					    I2CAddr = upmAdafruitms1438.ADAFRUITMS1438_DEFAULT_I2C_ADDR
 | 
				
			||||||
@@ -33,11 +33,9 @@ M3Motor = upmAdafruitms1438.AdafruitMS1438.MOTOR_M3
 | 
				
			|||||||
    MotorDirCW = upmAdafruitms1438.AdafruitMS1438.DIR_CW
 | 
					    MotorDirCW = upmAdafruitms1438.AdafruitMS1438.DIR_CW
 | 
				
			||||||
    MotorDirCCW = upmAdafruitms1438.AdafruitMS1438.DIR_CCW
 | 
					    MotorDirCCW = upmAdafruitms1438.AdafruitMS1438.DIR_CCW
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Instantiate an Adafruit MS 1438 on I2C bus 0
 | 
					    # Instantiate an Adafruit MS 1438 on I2C bus 0
 | 
				
			||||||
    myMotorShield = upmAdafruitms1438.AdafruitMS1438(I2CBus, I2CAddr)
 | 
					    myMotorShield = upmAdafruitms1438.AdafruitMS1438(I2CBus, I2CAddr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -54,7 +52,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Setup for use with a DC motor connected to the M3 port
 | 
					    # Setup for use with a DC motor connected to the M3 port
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # set a PWM period of 50Hz
 | 
					    # set a PWM period of 50Hz
 | 
				
			||||||
@@ -81,3 +78,6 @@ time.sleep(3)
 | 
				
			|||||||
    print "Stopping M3"
 | 
					    print "Stopping M3"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # exitHandler runs automatically
 | 
					    # exitHandler runs automatically
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/adc121c021.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/adc121c021.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,13 +24,13 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_adc121c021 as upmAdc121c021
 | 
					import pyupm_adc121c021 as upmAdc121c021
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate an ADC121C021 on I2C bus 0
 | 
					    # Instantiate an ADC121C021 on I2C bus 0
 | 
				
			||||||
    busID = upmAdc121c021.ADC121C021_I2C_BUS
 | 
					    busID = upmAdc121c021.ADC121C021_I2C_BUS
 | 
				
			||||||
    I2CAddr = upmAdc121c021.ADC121C021_DEFAULT_I2C_ADDR
 | 
					    I2CAddr = upmAdc121c021.ADC121C021_DEFAULT_I2C_ADDR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    myAnalogDigitalConv = upmAdc121c021.ADC121C021(busID, I2CAddr)
 | 
					    myAnalogDigitalConv = upmAdc121c021.ADC121C021(busID, I2CAddr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -46,10 +46,12 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # get the data every 50 milliseconds
 | 
					    # get the data every 50 milliseconds
 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        val = myAnalogDigitalConv.value()
 | 
					        val = myAnalogDigitalConv.value()
 | 
				
			||||||
        voltsVal = myAnalogDigitalConv.valueToVolts(val)
 | 
					        voltsVal = myAnalogDigitalConv.valueToVolts(val)
 | 
				
			||||||
        print "ADC value: %s Volts = %s" % (val, voltsVal)
 | 
					        print "ADC value: %s Volts = %s" % (val, voltsVal)
 | 
				
			||||||
        time.sleep(.05)
 | 
					        time.sleep(.05)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/adxl335.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/adxl335.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,13 +24,13 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_adxl335 as upmAdxl335
 | 
					import pyupm_adxl335 as upmAdxl335
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    myAnalogAccel = upmAdxl335.ADXL335(0, 1, 2)
 | 
					    myAnalogAccel = upmAdxl335.ADXL335(0, 1, 2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print "Please make sure the sensor is completely still."
 | 
					    print "Please make sure the sensor is completely still."
 | 
				
			||||||
    print "Sleeping for 2 seconds"
 | 
					    print "Sleeping for 2 seconds"
 | 
				
			||||||
    time.sleep(2)
 | 
					    time.sleep(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -46,7 +46,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    print "Calibrating..."
 | 
					    print "Calibrating..."
 | 
				
			||||||
    myAnalogAccel.calibrate()
 | 
					    myAnalogAccel.calibrate()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -76,3 +75,6 @@ while (1):
 | 
				
			|||||||
        print " "
 | 
					        print " "
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(.2)
 | 
					        time.sleep(.2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/adxl345.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/adxl345.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,12 +23,12 @@
 | 
				
			|||||||
from time import sleep
 | 
					from time import sleep
 | 
				
			||||||
import pyupm_adxl345 as adxl345
 | 
					import pyupm_adxl345 as adxl345
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create an I2C accelerometer object
 | 
					    # Create an I2C accelerometer object
 | 
				
			||||||
    adxl = adxl345.Adxl345(0)
 | 
					    adxl = adxl345.Adxl345(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Loop indefinitely
 | 
					    # Loop indefinitely
 | 
				
			||||||
    while True:
 | 
					    while True:
 | 
				
			||||||
 | 
					 | 
				
			||||||
        adxl.update() # Update the data
 | 
					        adxl.update() # Update the data
 | 
				
			||||||
        raw = adxl.getRawValues() # Read raw sensor data
 | 
					        raw = adxl.getRawValues() # Read raw sensor data
 | 
				
			||||||
        force = adxl.getAcceleration() # Read acceleration force (g)
 | 
					        force = adxl.getAcceleration() # Read acceleration force (g)
 | 
				
			||||||
@@ -39,3 +39,6 @@ while True:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # Sleep for 1 s
 | 
					        # Sleep for 1 s
 | 
				
			||||||
        sleep(1)
 | 
					        sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/adxrs610.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/adxrs610.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_adxrs610 as sensorObj
 | 
					import pyupm_adxrs610 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a ADXRS610 sensor on analog pin A0 (dataout), and
 | 
					    # Instantiate a ADXRS610 sensor on analog pin A0 (dataout), and
 | 
				
			||||||
    # analog A1 (temp out) with an analog reference voltage of
 | 
					    # analog A1 (temp out) with an analog reference voltage of
 | 
				
			||||||
    # 5.0
 | 
					    # 5.0
 | 
				
			||||||
@@ -53,3 +54,6 @@ while (1):
 | 
				
			|||||||
        print "Vel (deg/s):", sensor.getAngularVelocity()
 | 
					        print "Vel (deg/s):", sensor.getAngularVelocity()
 | 
				
			||||||
        print "Temp (C):", sensor.getTemperature()
 | 
					        print "Temp (C):", sensor.getTemperature()
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										37
									
								
								examples/python/aeotecdsb09104.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										37
									
								
								examples/python/aeotecdsb09104.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ozw as sensorObj
 | 
					import pyupm_ozw as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # This function lets you run code on exit
 | 
					    # This function lets you run code on exit
 | 
				
			||||||
    def exitHandler():
 | 
					    def exitHandler():
 | 
				
			||||||
        print "Exiting"
 | 
					        print "Exiting"
 | 
				
			||||||
@@ -57,32 +58,16 @@ print "Querying data..."
 | 
				
			|||||||
    while (True):
 | 
					    while (True):
 | 
				
			||||||
        sensor.update()
 | 
					        sensor.update()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        print "Watts, Channel 1:",
 | 
					        print "Watts, Channel 1: %0.03f W" % sensor.getWattsC1()
 | 
				
			||||||
        print sensor.getWattsC1(),
 | 
					        print "Watts, Channel 2: %0.03f W" % sensor.getWattsC2()
 | 
				
			||||||
        print "W"
 | 
					        print "Watts, Channel 3: %0.03f W" % sensor.getWattsC3()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        print "Watts, Channel 2:",
 | 
					        print "Energy, Channel 1: %0.03f kWh" % sensor.getEnergyC1()
 | 
				
			||||||
        print sensor.getWattsC2(),
 | 
					        print "Energy, Channel 2: %0.03f kWh" % sensor.getEnergyC2()
 | 
				
			||||||
        print "W"
 | 
					        print "Energy, Channel 3: %0.03f kWh" % sensor.getEnergyC3()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        print "Watts, Channel 3:",
 | 
					        print "Battery Level: %d\n" % sensor.getBatteryLevel()
 | 
				
			||||||
        print sensor.getWattsC3(),
 | 
					 | 
				
			||||||
        print "W"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        print "Energy, Channel 1:",
 | 
					 | 
				
			||||||
        print sensor.getEnergyC1(),
 | 
					 | 
				
			||||||
        print "kWh"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        print "Energy, Channel 2:",
 | 
					 | 
				
			||||||
        print sensor.getEnergyC2(),
 | 
					 | 
				
			||||||
        print "kWh"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        print "Energy, Channel 3:",
 | 
					 | 
				
			||||||
        print sensor.getEnergyC3(),
 | 
					 | 
				
			||||||
        print "kWh"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        print "Battery Level:",
 | 
					 | 
				
			||||||
        print sensor.getBatteryLevel(),
 | 
					 | 
				
			||||||
        print "%"
 | 
					 | 
				
			||||||
        print
 | 
					 | 
				
			||||||
        time.sleep(3)
 | 
					        time.sleep(3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/aeotecdw2e.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/aeotecdw2e.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ozw as sensorObj
 | 
					import pyupm_ozw as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # This function lets you run code on exit
 | 
					    # This function lets you run code on exit
 | 
				
			||||||
    def exitHandler():
 | 
					    def exitHandler():
 | 
				
			||||||
        print "Exiting"
 | 
					        print "Exiting"
 | 
				
			||||||
@@ -56,7 +57,6 @@ print "Initialization complete"
 | 
				
			|||||||
    print "Querying data..."
 | 
					    print "Querying data..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (True):
 | 
					    while (True):
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (sensor.isDeviceAvailable()):
 | 
					        if (sensor.isDeviceAvailable()):
 | 
				
			||||||
            print "Alarm status:",
 | 
					            print "Alarm status:",
 | 
				
			||||||
            print sensor.isAlarmTripped()
 | 
					            print sensor.isAlarmTripped()
 | 
				
			||||||
@@ -76,5 +76,7 @@ while (True):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            print
 | 
					            print
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/aeotecsdg2.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/aeotecsdg2.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ozw as sensorObj
 | 
					import pyupm_ozw as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # This function lets you run code on exit
 | 
					    # This function lets you run code on exit
 | 
				
			||||||
    def exitHandler():
 | 
					    def exitHandler():
 | 
				
			||||||
        print "Turning switch off and sleeping for 5 seconds..."
 | 
					        print "Turning switch off and sleeping for 5 seconds..."
 | 
				
			||||||
@@ -94,3 +95,6 @@ while (True):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(5)
 | 
					        time.sleep(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/aeotecss6.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/aeotecss6.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ozw as sensorObj
 | 
					import pyupm_ozw as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # This function lets you run code on exit
 | 
					    # This function lets you run code on exit
 | 
				
			||||||
    def exitHandler():
 | 
					    def exitHandler():
 | 
				
			||||||
        print "Turning switch off and sleeping for 5 seconds..."
 | 
					        print "Turning switch off and sleeping for 5 seconds..."
 | 
				
			||||||
@@ -85,3 +86,6 @@ while (True):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(3)
 | 
					        time.sleep(3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/ak8975.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/ak8975.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_mpu9150 as sensorObj
 | 
					import pyupm_mpu9150 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate an AK8975 on I2C bus 0
 | 
					    # Instantiate an AK8975 on I2C bus 0
 | 
				
			||||||
    sensor = sensorObj.AK8975()
 | 
					    sensor = sensorObj.AK8975()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -57,3 +58,6 @@ while (1):
 | 
				
			|||||||
        print
 | 
					        print
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(.5)
 | 
					        time.sleep(.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/apa102.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/apa102.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -21,10 +21,10 @@
 | 
				
			|||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
					# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
				
			||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
					# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_apa102 as mylib
 | 
					import pyupm_apa102 as mylib
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a strip of 30 LEDs on SPI bus 0
 | 
					    # Instantiate a strip of 30 LEDs on SPI bus 0
 | 
				
			||||||
    ledStrip = mylib.APA102(30, 0, False)
 | 
					    ledStrip = mylib.APA102(30, 0, False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -45,4 +45,5 @@ ledStrip.setLeds(10, 20, 31, 255, 0, 0)
 | 
				
			|||||||
    print "Setting LED 15 to Blue"
 | 
					    print "Setting LED 15 to Blue"
 | 
				
			||||||
    ledStrip.setLed(15, 31, 0, 0, 255)
 | 
					    ledStrip.setLed(15, 31, 0, 0, 255)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/apds9002.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/apds9002.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_apds9002 as upmApds9002
 | 
					import pyupm_apds9002 as upmApds9002
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Luminance sensor on analog pin A0
 | 
					    # Instantiate a Grove Luminance sensor on analog pin A0
 | 
				
			||||||
    myLuminance = upmApds9002.APDS9002(0)
 | 
					    myLuminance = upmApds9002.APDS9002(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -42,9 +42,11 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        print "Luminance value is {0}".format(
 | 
					        print "Luminance value is {0}".format(
 | 
				
			||||||
        myLuminance.value())
 | 
					        myLuminance.value())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								examples/python/at42qt1070.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										8
									
								
								examples/python/at42qt1070.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_at42qt1070 as upmAt42qt1070
 | 
					import pyupm_at42qt1070 as upmAt42qt1070
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # functions
 | 
					    # functions
 | 
				
			||||||
    def printButtons(touchObj):
 | 
					    def printButtons(touchObj):
 | 
				
			||||||
        buttonPressed = False
 | 
					        buttonPressed = False
 | 
				
			||||||
@@ -46,7 +47,6 @@ def printButtons(touchObj):
 | 
				
			|||||||
        if (touchObj.isOverflowed()):
 | 
					        if (touchObj.isOverflowed()):
 | 
				
			||||||
            print "Overflow was detected."
 | 
					            print "Overflow was detected."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Global code that runs on startup
 | 
					    # Global code that runs on startup
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    I2C_BUS = upmAt42qt1070.AT42QT1070_I2C_BUS
 | 
					    I2C_BUS = upmAt42qt1070.AT42QT1070_I2C_BUS
 | 
				
			||||||
@@ -56,7 +56,6 @@ DEFAULT_I2C_ADDR = upmAt42qt1070.AT42QT1070_DEFAULT_I2C_ADDR
 | 
				
			|||||||
    myTouchSensor = upmAt42qt1070.AT42QT1070(I2C_BUS,
 | 
					    myTouchSensor = upmAt42qt1070.AT42QT1070(I2C_BUS,
 | 
				
			||||||
                                             DEFAULT_I2C_ADDR)
 | 
					                                             DEFAULT_I2C_ADDR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Exit handlers
 | 
					    # Exit handlers
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
        raise SystemExit
 | 
					        raise SystemExit
 | 
				
			||||||
@@ -65,15 +64,16 @@ def exitHandler():
 | 
				
			|||||||
        print "Exiting"
 | 
					        print "Exiting"
 | 
				
			||||||
        sys.exit(0)
 | 
					        sys.exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # This function lets you run code on exit, including functions from myTouchSensor
 | 
					    # This function lets you run code on exit, including functions from myTouchSensor
 | 
				
			||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Print the button being touched every 0.1 seconds
 | 
					    # Print the button being touched every 0.1 seconds
 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        myTouchSensor.updateState()
 | 
					        myTouchSensor.updateState()
 | 
				
			||||||
        printButtons(myTouchSensor)
 | 
					        printButtons(myTouchSensor)
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bh1750.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bh1750.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bh1750 as sensorObj
 | 
					import pyupm_bh1750 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BH1750 sensor using defaults (I2C bus (0), using
 | 
					    # Instantiate a BH1750 sensor using defaults (I2C bus (0), using
 | 
				
			||||||
    # the default I2C address (0x23), and setting the mode to highest
 | 
					    # the default I2C address (0x23), and setting the mode to highest
 | 
				
			||||||
    # resolution, lowest power mode).
 | 
					    # resolution, lowest power mode).
 | 
				
			||||||
@@ -48,3 +49,6 @@ signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			|||||||
    while (True):
 | 
					    while (True):
 | 
				
			||||||
        print "Detected Light Level (lux):", sensor.getLux()
 | 
					        print "Detected Light Level (lux):", sensor.getLux()
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/biss0001.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/biss0001.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_biss0001 as upmMotion
 | 
					import pyupm_biss0001 as upmMotion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Motion sensor on GPIO pin D2
 | 
					    # Instantiate a Grove Motion sensor on GPIO pin D2
 | 
				
			||||||
    myMotion = upmMotion.BISS0001(2)
 | 
					    myMotion = upmMotion.BISS0001(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -42,7 +42,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Read the value every second and detect motion
 | 
					    # Read the value every second and detect motion
 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        if (myMotion.value()):
 | 
					        if (myMotion.value()):
 | 
				
			||||||
@@ -50,3 +49,6 @@ while(1):
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print "No moving objects detected"
 | 
					            print "No moving objects detected"
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bma220.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bma220.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bma220 as sensorObj
 | 
					import pyupm_bma220 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate an BMA220 using default parameters (bus 0, addr 0x0a)
 | 
					    # Instantiate an BMA220 using default parameters (bus 0, addr 0x0a)
 | 
				
			||||||
    sensor = sensorObj.BMA220()
 | 
					    sensor = sensorObj.BMA220()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -53,3 +54,6 @@ while (1):
 | 
				
			|||||||
        print " AZ:", sensorObj.floatp_value(z)
 | 
					        print " AZ:", sensorObj.floatp_value(z)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(.5)
 | 
					        time.sleep(.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bma250e.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bma250e.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmx055 as sensorObj
 | 
					import pyupm_bmx055 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BMP250E instance using default i2c bus and address
 | 
					    # Instantiate a BMP250E instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BMA250E()
 | 
					    sensor = sensorObj.BMA250E()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -64,3 +65,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(.250)
 | 
					        time.sleep(.250)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bmc150.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bmc150.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmx055 as sensorObj
 | 
					import pyupm_bmx055 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BMC150 instance using default i2c bus and address
 | 
					    # Instantiate a BMC150 instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BMC150()
 | 
					    sensor = sensorObj.BMC150()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,3 +64,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(.250)
 | 
					        time.sleep(.250)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bme280.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bme280.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmp280 as sensorObj
 | 
					import pyupm_bmp280 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BME280 instance using default i2c bus and address
 | 
					    # Instantiate a BME280 instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BME280()
 | 
					    sensor = sensorObj.BME280()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -58,3 +59,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bmg160.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bmg160.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmx055 as sensorObj
 | 
					import pyupm_bmx055 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BMP250E instance using default i2c bus and address
 | 
					    # Instantiate a BMP250E instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BMG160()
 | 
					    sensor = sensorObj.BMG160()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -64,3 +65,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(.250)
 | 
					        time.sleep(.250)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bmi055.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bmi055.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmx055 as sensorObj
 | 
					import pyupm_bmx055 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BMI055 instance using default i2c bus and address
 | 
					    # Instantiate a BMI055 instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BMI055()
 | 
					    sensor = sensorObj.BMI055()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,3 +64,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(.250)
 | 
					        time.sleep(.250)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bmi160.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bmi160.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmi160 as sensorObj
 | 
					import pyupm_bmi160 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BMI160 instance using default i2c bus and address
 | 
					    # Instantiate a BMI160 instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BMI160()
 | 
					    sensor = sensorObj.BMI160()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -64,3 +65,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(.5)
 | 
					        time.sleep(.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bmm150.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bmm150.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmx055 as sensorObj
 | 
					import pyupm_bmx055 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BMP250E instance using default i2c bus and address
 | 
					    # Instantiate a BMP250E instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BMM150()
 | 
					    sensor = sensorObj.BMM150()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -60,3 +61,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(.250)
 | 
					        time.sleep(.250)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bmp280.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bmp280.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmp280 as sensorObj
 | 
					import pyupm_bmp280 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BMP280 instance using default i2c bus and address
 | 
					    # Instantiate a BMP280 instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BMP280()
 | 
					    sensor = sensorObj.BMP280()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -56,3 +57,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/bmpx8x.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/bmpx8x.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmpx8x as upmBmpx8x
 | 
					import pyupm_bmpx8x as upmBmpx8x
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Load Barometer module on i2c
 | 
					    # Load Barometer module on i2c
 | 
				
			||||||
    myBarometer = upmBmpx8x.BMPX8X(0, upmBmpx8x.ADDR);
 | 
					    myBarometer = upmBmpx8x.BMPX8X(0, upmBmpx8x.ADDR);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -42,7 +42,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Print the pressure, altitude, sea level, and
 | 
					    # Print the pressure, altitude, sea level, and
 | 
				
			||||||
    # temperature values every 0.1 seconds
 | 
					    # temperature values every 0.1 seconds
 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
@@ -57,3 +56,6 @@ while(1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print outputStr
 | 
					        print outputStr
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bmx055.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bmx055.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bmx055 as sensorObj
 | 
					import pyupm_bmx055 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a BMX055 instance using default i2c bus and address
 | 
					    # Instantiate a BMX055 instance using default i2c bus and address
 | 
				
			||||||
    sensor = sensorObj.BMX055()
 | 
					    sensor = sensorObj.BMX055()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -69,3 +70,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(.250)
 | 
					        time.sleep(.250)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/bno055.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/bno055.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_bno055 as sensorObj
 | 
					import pyupm_bno055 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate an BNO055 using default parameters (bus 0, addr
 | 
					    # Instantiate an BNO055 using default parameters (bus 0, addr
 | 
				
			||||||
    # 0x28).  The default running mode is NDOF absolute orientation
 | 
					    # 0x28).  The default running mode is NDOF absolute orientation
 | 
				
			||||||
    # mode.
 | 
					    # mode.
 | 
				
			||||||
@@ -103,3 +104,6 @@ while (True):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(.25);
 | 
					        time.sleep(.25);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/button.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/button.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_grove as grove
 | 
					import pyupm_grove as grove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create the button object using GPIO pin 0
 | 
					    # Create the button object using GPIO pin 0
 | 
				
			||||||
    button = grove.Button(0)
 | 
					    button = grove.Button(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -33,3 +34,6 @@ while 1:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the button object
 | 
					    # Delete the button object
 | 
				
			||||||
    del button
 | 
					    del button
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/buzzer.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/buzzer.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_buzzer as upmBuzzer
 | 
					import pyupm_buzzer as upmBuzzer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create the buzzer object using GPIO pin 5
 | 
					    # Create the buzzer object using GPIO pin 5
 | 
				
			||||||
    buzzer = upmBuzzer.Buzzer(5)
 | 
					    buzzer = upmBuzzer.Buzzer(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -43,3 +44,6 @@ print "exiting application"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the buzzer object
 | 
					    # Delete the buzzer object
 | 
				
			||||||
    del buzzer
 | 
					    del buzzer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/cjq4435.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/cjq4435.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -25,10 +25,10 @@ from __future__ import division
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_cjq4435 as upmCjq4435
 | 
					import pyupm_cjq4435 as upmCjq4435
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
 | 
					    # Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
 | 
				
			||||||
    myMOSFETsensor = upmCjq4435.CJQ4435(3)
 | 
					    myMOSFETsensor = upmCjq4435.CJQ4435(3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    myMOSFETsensor.setPeriodMS(10)
 | 
					    myMOSFETsensor.setPeriodMS(10)
 | 
				
			||||||
    myMOSFETsensor.enable(True)
 | 
					    myMOSFETsensor.enable(True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -44,3 +44,6 @@ for i in range(10, -1, -1):
 | 
				
			|||||||
        myMOSFETsensor.setDutyCycle(i / 10)
 | 
					        myMOSFETsensor.setDutyCycle(i / 10)
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
    time.sleep(1)
 | 
					    time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/collision.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/collision.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_collision as upmcollision
 | 
					import pyupm_collision as upmcollision
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # The was tested with the Collision Sensor
 | 
					    # The was tested with the Collision Sensor
 | 
				
			||||||
    # Instantiate a Collision on digital pin D2
 | 
					    # Instantiate a Collision on digital pin D2
 | 
				
			||||||
    mycollision = upmcollision.Collision(2)
 | 
					    mycollision = upmcollision.Collision(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -44,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    collisionState = False
 | 
					    collisionState = False
 | 
				
			||||||
    print "No collision"
 | 
					    print "No collision"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,3 +54,6 @@ while(1):
 | 
				
			|||||||
        elif (not mycollision.isColliding() and collisionState):
 | 
					        elif (not mycollision.isColliding() and collisionState):
 | 
				
			||||||
            print "No collision"
 | 
					            print "No collision"
 | 
				
			||||||
            collisionState = False
 | 
					            collisionState = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/curieimu.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/curieimu.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -30,6 +30,8 @@ mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_curieimu as curieimu
 | 
					import pyupm_curieimu as curieimu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    sensor = curieimu.CurieImu()
 | 
					    sensor = curieimu.CurieImu()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
@@ -44,7 +46,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        sensor.updateAccel();
 | 
					        sensor.updateAccel();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -54,3 +55,6 @@ while(1):
 | 
				
			|||||||
        print outputStr
 | 
					        print outputStr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/cwlsxxa.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/cwlsxxa.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_cwlsxxa as sensorObj
 | 
					import pyupm_cwlsxxa as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -59,3 +60,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/dfrec.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/dfrec.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_dfrec as sensorObj
 | 
					import pyupm_dfrec as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a DFRobot EC sensor on analog pin A0, with a ds18b20
 | 
					    # Instantiate a DFRobot EC sensor on analog pin A0, with a ds18b20
 | 
				
			||||||
    # temperature sensor connected to UART 0, and a device index (for
 | 
					    # temperature sensor connected to UART 0, and a device index (for
 | 
				
			||||||
    # the ds1820b uart bus) of 0, and an analog reference voltage of
 | 
					    # the ds1820b uart bus) of 0, and an analog reference voltage of
 | 
				
			||||||
@@ -54,3 +55,6 @@ while (True):
 | 
				
			|||||||
        print
 | 
					        print
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(2)
 | 
					        time.sleep(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/dfrorp.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/dfrorp.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_dfrorp as sensorObj
 | 
					import pyupm_dfrorp as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a DFRobot ORP sensor on analog pin A0 with an analog
 | 
					    # Instantiate a DFRobot ORP sensor on analog pin A0 with an analog
 | 
				
			||||||
    # reference voltage of 5.0.
 | 
					    # reference voltage of 5.0.
 | 
				
			||||||
    sensor = sensorObj.DFRORP(0, 5.0)
 | 
					    sensor = sensorObj.DFRORP(0, 5.0)
 | 
				
			||||||
@@ -66,3 +67,6 @@ while (True):
 | 
				
			|||||||
        print
 | 
					        print
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/dfrph.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/dfrph.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_dfrph as sensorObj
 | 
					import pyupm_dfrph as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a DFRPH sensor on analog pin A0, with an analog
 | 
					    # Instantiate a DFRPH sensor on analog pin A0, with an analog
 | 
				
			||||||
    # reference voltage of 5.0
 | 
					    # reference voltage of 5.0
 | 
				
			||||||
    sensor = sensorObj.DFRPH(0, 5.0)
 | 
					    sensor = sensorObj.DFRPH(0, 5.0)
 | 
				
			||||||
@@ -54,3 +55,6 @@ while (1):
 | 
				
			|||||||
        print "Detected volts: ", sensor.volts()
 | 
					        print "Detected volts: ", sensor.volts()
 | 
				
			||||||
        print "pH value: ", sensor.pH()
 | 
					        print "pH value: ", sensor.pH()
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/ds1307.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/ds1307.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ds1307 as upmDs1307
 | 
					import pyupm_ds1307 as upmDs1307
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # load RTC clock on i2c bus 0
 | 
					    # load RTC clock on i2c bus 0
 | 
				
			||||||
    myRTCClock = upmDs1307.DS1307(0)
 | 
					    myRTCClock = upmDs1307.DS1307(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -40,7 +41,6 @@ def printTime(RTCObj):
 | 
				
			|||||||
        print "Clock is in", ("AM/PM mode"
 | 
					        print "Clock is in", ("AM/PM mode"
 | 
				
			||||||
        if RTCObj.amPmMode else "24hr mode")
 | 
					        if RTCObj.amPmMode else "24hr mode")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # always do this first
 | 
					    # always do this first
 | 
				
			||||||
    print "Loading the current time... "
 | 
					    print "Loading the current time... "
 | 
				
			||||||
    result = myRTCClock.loadTime()
 | 
					    result = myRTCClock.loadTime()
 | 
				
			||||||
@@ -58,3 +58,6 @@ myRTCClock.setTime()
 | 
				
			|||||||
    # reload the time and print it
 | 
					    # reload the time and print it
 | 
				
			||||||
    myRTCClock.loadTime()
 | 
					    myRTCClock.loadTime()
 | 
				
			||||||
    printTime(myRTCClock)
 | 
					    printTime(myRTCClock)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/ds18b20.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/ds18b20.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ds18b20 as sensorObj
 | 
					import pyupm_ds18b20 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -62,3 +63,6 @@ while (1):
 | 
				
			|||||||
        print sensor.getTemperature(0, True), "F"
 | 
					        print sensor.getTemperature(0, True), "F"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/ds2413.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/ds2413.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ds2413 as sensorObj
 | 
					import pyupm_ds2413 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
 | 
					    # Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
 | 
				
			||||||
    sensor = sensorObj.DS2413(0)
 | 
					    sensor = sensorObj.DS2413(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,3 +56,6 @@ print "GPIO device 0 values:", sensor.readGpios(0)
 | 
				
			|||||||
    # set the gpio latch values of the first device
 | 
					    # set the gpio latch values of the first device
 | 
				
			||||||
    print "Setting GPIO latches to on"
 | 
					    print "Setting GPIO latches to on"
 | 
				
			||||||
    sensor.writeGpios(0, 0x03);
 | 
					    sensor.writeGpios(0, 0x03);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/e50hx.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/e50hx.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_e50hx as sensorObj
 | 
					import pyupm_e50hx as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -93,3 +94,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(5)
 | 
					        time.sleep(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/eboled.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/eboled.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -25,6 +25,7 @@ import time, sys
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import pyupm_i2clcd as lcdObj
 | 
					import pyupm_i2clcd as lcdObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # setup with default values
 | 
					    # setup with default values
 | 
				
			||||||
    lcd = lcdObj.EBOLED();
 | 
					    lcd = lcdObj.EBOLED();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -37,5 +38,5 @@ lcd.refresh();
 | 
				
			|||||||
    print "Sleeping for 5 seconds..."
 | 
					    print "Sleeping for 5 seconds..."
 | 
				
			||||||
    time.sleep(5)
 | 
					    time.sleep(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								examples/python/ehr.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										7
									
								
								examples/python/ehr.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -21,14 +21,13 @@
 | 
				
			|||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
					# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
				
			||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
					# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ehr as upmehr
 | 
					import pyupm_ehr as upmehr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a  Ear-clip Heart Rate sensor on digital pin D2
 | 
					    # Instantiate a  Ear-clip Heart Rate sensor on digital pin D2
 | 
				
			||||||
    myHeartRateSensor = upmehr.EHR(2)
 | 
					    myHeartRateSensor = upmehr.EHR(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -45,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # set the beat counter to 0, init the clock and start counting beats
 | 
					    # set the beat counter to 0, init the clock and start counting beats
 | 
				
			||||||
    myHeartRateSensor.clearBeatCounter()
 | 
					    myHeartRateSensor.clearBeatCounter()
 | 
				
			||||||
    myHeartRateSensor.initClock()
 | 
					    myHeartRateSensor.initClock()
 | 
				
			||||||
@@ -66,3 +64,6 @@ while(1):
 | 
				
			|||||||
        millis, beats, fr)
 | 
					        millis, beats, fr)
 | 
				
			||||||
        print outputStr
 | 
					        print outputStr
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/eldriver.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/eldriver.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_eldriver as upmeldriver
 | 
					import pyupm_eldriver as upmeldriver
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # The was tested with the  El Driver Module
 | 
					    # The was tested with the  El Driver Module
 | 
				
			||||||
    # Instantiate a  El Driver on digital pin D2
 | 
					    # Instantiate a  El Driver on digital pin D2
 | 
				
			||||||
    myEldriver = upmeldriver.ElDriver(2)
 | 
					    myEldriver = upmeldriver.ElDriver(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -44,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    lightState = True
 | 
					    lightState = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
@@ -55,3 +54,6 @@ while(1):
 | 
				
			|||||||
        lightState = not lightState
 | 
					        lightState = not lightState
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/electromagnet.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/electromagnet.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_electromagnet as upmelectromagnet
 | 
					import pyupm_electromagnet as upmelectromagnet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # This was tested with the  Electromagnetic Module
 | 
					    # This was tested with the  Electromagnetic Module
 | 
				
			||||||
    # Instantiate a  Electromagnet on digital pin D2
 | 
					    # Instantiate a  Electromagnet on digital pin D2
 | 
				
			||||||
    myElectromagnet = upmelectromagnet.Electromagnet(2)
 | 
					    myElectromagnet = upmelectromagnet.Electromagnet(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -45,7 +45,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    magnetState = False
 | 
					    magnetState = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Turn magnet on and off every 5 seconds
 | 
					    # Turn magnet on and off every 5 seconds
 | 
				
			||||||
@@ -58,3 +57,6 @@ while(1):
 | 
				
			|||||||
        print "Turning magnet", ("on" if magnetState else "off")
 | 
					        print "Turning magnet", ("on" if magnetState else "off")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(5)
 | 
					        time.sleep(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/emg.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/emg.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_emg as upmEmg
 | 
					import pyupm_emg as upmEmg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Tested with the EMG Muscle Signal Reader Sensor Module
 | 
					    # Tested with the EMG Muscle Signal Reader Sensor Module
 | 
				
			||||||
    # Instantiate a EMG on analog pin A0
 | 
					    # Instantiate a EMG on analog pin A0
 | 
				
			||||||
    myEMG = upmEmg.EMG(0)
 | 
					    myEMG = upmEmg.EMG(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -43,10 +43,12 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    print "Calibrating...."
 | 
					    print "Calibrating...."
 | 
				
			||||||
    myEMG.calibrate()
 | 
					    myEMG.calibrate()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (1):
 | 
					    while (1):
 | 
				
			||||||
        print myEMG.value()
 | 
					        print myEMG.value()
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/enc03r.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/enc03r.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_enc03r as upmEnc03r
 | 
					import pyupm_enc03r as upmEnc03r
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate an ENC03R on analog pin A0
 | 
					    # Instantiate an ENC03R on analog pin A0
 | 
				
			||||||
    myAnalogGyro = upmEnc03r.ENC03R(0)
 | 
					    myAnalogGyro = upmEnc03r.ENC03R(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -43,7 +43,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    CALIBRATION_SAMPLES = 1000
 | 
					    CALIBRATION_SAMPLES = 1000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print ("Please place the sensor in a stable location,\n"
 | 
					    print ("Please place the sensor in a stable location,\n"
 | 
				
			||||||
@@ -62,3 +61,6 @@ while(1):
 | 
				
			|||||||
        print outputStr
 | 
					        print outputStr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/es08a.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/es08a.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_servo as servo
 | 
					import pyupm_servo as servo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create the servo object using D5
 | 
					    # Create the servo object using D5
 | 
				
			||||||
    gServo = servo.ES08A(5)
 | 
					    gServo = servo.ES08A(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -44,3 +45,6 @@ for i in range(0,10):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the servo object
 | 
					    # Delete the servo object
 | 
				
			||||||
    del gServo
 | 
					    del gServo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/gp2y0a.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/gp2y0a.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,13 +24,13 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_gp2y0a as upmGp2y0a
 | 
					import pyupm_gp2y0a as upmGp2y0a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Note, for the Grove 80cm version of this sensor, due to the way it is wired,
 | 
					    # Note, for the Grove 80cm version of this sensor, due to the way it is wired,
 | 
				
			||||||
    # you need to plug this into the A0 port, where it will use the available
 | 
					    # you need to plug this into the A0 port, where it will use the available
 | 
				
			||||||
    # A1 pin for data.
 | 
					    # A1 pin for data.
 | 
				
			||||||
    # Instantiate a GP2Y0A on analog pin A1
 | 
					    # Instantiate a GP2Y0A on analog pin A1
 | 
				
			||||||
    myIRProximity = upmGp2y0a.GP2Y0A(1)
 | 
					    myIRProximity = upmGp2y0a.GP2Y0A(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -46,7 +46,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # analog voltage, usually 3.3 or 5.0
 | 
					    # analog voltage, usually 3.3 or 5.0
 | 
				
			||||||
    GP2Y0A_AREF = 5.0;
 | 
					    GP2Y0A_AREF = 5.0;
 | 
				
			||||||
    SAMPLES_PER_QUERY = 20;
 | 
					    SAMPLES_PER_QUERY = 20;
 | 
				
			||||||
@@ -60,3 +59,6 @@ while (1):
 | 
				
			|||||||
        GP2Y0A_AREF,
 | 
					        GP2Y0A_AREF,
 | 
				
			||||||
        myIRProximity.value(GP2Y0A_AREF, SAMPLES_PER_QUERY))
 | 
					        myIRProximity.value(GP2Y0A_AREF, SAMPLES_PER_QUERY))
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/gprs.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/gprs.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_gprs as sensorObj
 | 
					import pyupm_gprs as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a GPRS Module on UART 0
 | 
					    # Instantiate a GPRS Module on UART 0
 | 
				
			||||||
    sensor = sensorObj.GPRS(0)
 | 
					    sensor = sensorObj.GPRS(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -46,7 +47,6 @@ if (sensor.setBaudRate(19200)):
 | 
				
			|||||||
        print "Failed to set baud rate"
 | 
					        print "Failed to set baud rate"
 | 
				
			||||||
        sys.exit(0)
 | 
					        sys.exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    usageStr = ("Usage:\n"
 | 
					    usageStr = ("Usage:\n"
 | 
				
			||||||
    "If an argument is supplied on the command line, that argument is\n"
 | 
					    "If an argument is supplied on the command line, that argument is\n"
 | 
				
			||||||
    "sent to the module and the response is printed out.\n\n"
 | 
					    "sent to the module and the response is printed out.\n\n"
 | 
				
			||||||
@@ -67,7 +67,6 @@ def sendCommand(sensor, cmd):
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print "Timed out waiting for response"
 | 
					            print "Timed out waiting for response"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (len(sys.argv) > 1):
 | 
					    if (len(sys.argv) > 1):
 | 
				
			||||||
        print "Sending command line argument (" + sys.argv[1] + ")..."
 | 
					        print "Sending command line argument (" + sys.argv[1] + ")..."
 | 
				
			||||||
        sendCommand(sensor, sys.argv[1])
 | 
					        sendCommand(sensor, sys.argv[1])
 | 
				
			||||||
@@ -84,3 +83,6 @@ else:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # A comprehensive list is available from the datasheet at:
 | 
					        # A comprehensive list is available from the datasheet at:
 | 
				
			||||||
        # http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
 | 
					        # http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/grovebutton.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/grovebutton.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_grove as grove
 | 
					import pyupm_grove as grove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create the button object using GPIO pin 0
 | 
					    # Create the button object using GPIO pin 0
 | 
				
			||||||
    button = grove.GroveButton(0)
 | 
					    button = grove.GroveButton(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -33,3 +34,6 @@ while 1:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the button object
 | 
					    # Delete the button object
 | 
				
			||||||
    del button
 | 
					    del button
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/grovecircularled.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/grovecircularled.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -25,6 +25,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_my9221 as upmGroveCircularLED
 | 
					import pyupm_my9221 as upmGroveCircularLED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Exit handlers
 | 
					    # Exit handlers
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
        raise SystemExit
 | 
					        raise SystemExit
 | 
				
			||||||
@@ -48,3 +49,6 @@ while(1):
 | 
				
			|||||||
        circle.setSpinner(level)
 | 
					        circle.setSpinner(level)
 | 
				
			||||||
        level = (level + 1) % 24
 | 
					        level = (level + 1) % 24
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/grovecollision.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/grovecollision.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovecollision as upmGrovecollision
 | 
					import pyupm_grovecollision as upmGrovecollision
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # The was tested with the Grove Collision Sensor
 | 
					    # The was tested with the Grove Collision Sensor
 | 
				
			||||||
    # Instantiate a Grove Collision on digital pin D2
 | 
					    # Instantiate a Grove Collision on digital pin D2
 | 
				
			||||||
    myGrovecollision = upmGrovecollision.GroveCollision(2)
 | 
					    myGrovecollision = upmGrovecollision.GroveCollision(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -44,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    collisionState = False
 | 
					    collisionState = False
 | 
				
			||||||
    print "No collision"
 | 
					    print "No collision"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,3 +54,6 @@ while(1):
 | 
				
			|||||||
        elif (not myGrovecollision.isColliding() and collisionState):
 | 
					        elif (not myGrovecollision.isColliding() and collisionState):
 | 
				
			||||||
            print "No collision"
 | 
					            print "No collision"
 | 
				
			||||||
            collisionState = False
 | 
					            collisionState = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								examples/python/groveehr.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										7
									
								
								examples/python/groveehr.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -21,14 +21,13 @@
 | 
				
			|||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
					# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
				
			||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
					# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_groveehr as upmGroveehr
 | 
					import pyupm_groveehr as upmGroveehr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
 | 
					    # Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
 | 
				
			||||||
    myHeartRateSensor = upmGroveehr.GroveEHR(2)
 | 
					    myHeartRateSensor = upmGroveehr.GroveEHR(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -45,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # set the beat counter to 0, init the clock and start counting beats
 | 
					    # set the beat counter to 0, init the clock and start counting beats
 | 
				
			||||||
    myHeartRateSensor.clearBeatCounter()
 | 
					    myHeartRateSensor.clearBeatCounter()
 | 
				
			||||||
    myHeartRateSensor.initClock()
 | 
					    myHeartRateSensor.initClock()
 | 
				
			||||||
@@ -66,3 +64,6 @@ while(1):
 | 
				
			|||||||
        millis, beats, fr)
 | 
					        millis, beats, fr)
 | 
				
			||||||
        print outputStr
 | 
					        print outputStr
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/groveeldriver.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/groveeldriver.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_groveeldriver as upmGroveeldriver
 | 
					import pyupm_groveeldriver as upmGroveeldriver
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # The was tested with the Grove El Driver Module
 | 
					    # The was tested with the Grove El Driver Module
 | 
				
			||||||
    # Instantiate a Grove El Driver on digital pin D2
 | 
					    # Instantiate a Grove El Driver on digital pin D2
 | 
				
			||||||
    myEldriver = upmGroveeldriver.GroveElDriver(2)
 | 
					    myEldriver = upmGroveeldriver.GroveElDriver(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -44,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    lightState = True
 | 
					    lightState = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
@@ -55,3 +54,6 @@ while(1):
 | 
				
			|||||||
        lightState = not lightState
 | 
					        lightState = not lightState
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/groveelectromagnet.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/groveelectromagnet.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_groveelectromagnet as upmGroveelectromagnet
 | 
					import pyupm_groveelectromagnet as upmGroveelectromagnet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # This was tested with the Grove Electromagnetic Module
 | 
					    # This was tested with the Grove Electromagnetic Module
 | 
				
			||||||
    # Instantiate a Grove Electromagnet on digital pin D2
 | 
					    # Instantiate a Grove Electromagnet on digital pin D2
 | 
				
			||||||
    myElectromagnet = upmGroveelectromagnet.GroveElectromagnet(2)
 | 
					    myElectromagnet = upmGroveelectromagnet.GroveElectromagnet(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -45,7 +45,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    magnetState = False
 | 
					    magnetState = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Turn magnet on and off every 5 seconds
 | 
					    # Turn magnet on and off every 5 seconds
 | 
				
			||||||
@@ -58,3 +57,6 @@ while(1):
 | 
				
			|||||||
        print "Turning magnet", ("on" if magnetState else "off")
 | 
					        print "Turning magnet", ("on" if magnetState else "off")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(5)
 | 
					        time.sleep(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/groveemg.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/groveemg.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_groveemg as upmGroveemg
 | 
					import pyupm_groveemg as upmGroveemg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Tested with the GroveEMG Muscle Signal Reader Sensor Module
 | 
					    # Tested with the GroveEMG Muscle Signal Reader Sensor Module
 | 
				
			||||||
    # Instantiate a GroveEMG on analog pin A0
 | 
					    # Instantiate a GroveEMG on analog pin A0
 | 
				
			||||||
    myEMG = upmGroveemg.GroveEMG(0)
 | 
					    myEMG = upmGroveemg.GroveEMG(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -43,10 +43,12 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    print "Calibrating...."
 | 
					    print "Calibrating...."
 | 
				
			||||||
    myEMG.calibrate()
 | 
					    myEMG.calibrate()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (1):
 | 
					    while (1):
 | 
				
			||||||
        print myEMG.value()
 | 
					        print myEMG.value()
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/grovegprs.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/grovegprs.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovegprs as sensorObj
 | 
					import pyupm_grovegprs as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a GroveGPRS Module on UART 0
 | 
					    # Instantiate a GroveGPRS Module on UART 0
 | 
				
			||||||
    sensor = sensorObj.GroveGPRS(0)
 | 
					    sensor = sensorObj.GroveGPRS(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -46,7 +47,6 @@ if (sensor.setBaudRate(19200)):
 | 
				
			|||||||
        print "Failed to set baud rate"
 | 
					        print "Failed to set baud rate"
 | 
				
			||||||
        sys.exit(0)
 | 
					        sys.exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    usageStr = ("Usage:\n"
 | 
					    usageStr = ("Usage:\n"
 | 
				
			||||||
    "If an argument is supplied on the command line, that argument is\n"
 | 
					    "If an argument is supplied on the command line, that argument is\n"
 | 
				
			||||||
    "sent to the module and the response is printed out.\n\n"
 | 
					    "sent to the module and the response is printed out.\n\n"
 | 
				
			||||||
@@ -67,7 +67,6 @@ def sendCommand(sensor, cmd):
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print "Timed out waiting for response"
 | 
					            print "Timed out waiting for response"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (len(sys.argv) > 1):
 | 
					    if (len(sys.argv) > 1):
 | 
				
			||||||
        print "Sending command line argument (" + sys.argv[1] + ")..."
 | 
					        print "Sending command line argument (" + sys.argv[1] + ")..."
 | 
				
			||||||
        sendCommand(sensor, sys.argv[1])
 | 
					        sendCommand(sensor, sys.argv[1])
 | 
				
			||||||
@@ -84,3 +83,6 @@ else:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # A comprehensive list is available from the datasheet at:
 | 
					        # A comprehensive list is available from the datasheet at:
 | 
				
			||||||
        # http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
 | 
					        # http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/grovegsr.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/grovegsr.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,12 +24,12 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovegsr as upmGrovegsr
 | 
					import pyupm_grovegsr as upmGrovegsr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Tested with the GroveGSR Galvanic Skin Response Sensor module.
 | 
					    # Tested with the GroveGSR Galvanic Skin Response Sensor module.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Instantiate a GroveGSR on analog pin A0
 | 
					    # Instantiate a GroveGSR on analog pin A0
 | 
				
			||||||
    myGSR = upmGrovegsr.GroveGSR(0)
 | 
					    myGSR = upmGrovegsr.GroveGSR(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -44,10 +44,12 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    print "Calibrating...."
 | 
					    print "Calibrating...."
 | 
				
			||||||
    myGSR.calibrate()
 | 
					    myGSR.calibrate()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (1):
 | 
					    while (1):
 | 
				
			||||||
        print myGSR.value()
 | 
					        print myGSR.value()
 | 
				
			||||||
        time.sleep(.5)
 | 
					        time.sleep(.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/groveled.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/groveled.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_grove as grove
 | 
					import pyupm_grove as grove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create the Grove LED object using GPIO pin 2
 | 
					    # Create the Grove LED object using GPIO pin 2
 | 
				
			||||||
    led = grove.GroveLed(2)
 | 
					    led = grove.GroveLed(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -39,3 +40,6 @@ for i in range (0,10):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the Grove LED object
 | 
					    # Delete the Grove LED object
 | 
				
			||||||
    del led
 | 
					    del led
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/groveledbar.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/groveledbar.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_my9221 as upmMy9221
 | 
					import pyupm_my9221 as upmMy9221
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a MY9221, we use D8 for the data, and D9 for the
 | 
					    # Instantiate a MY9221, we use D8 for the data, and D9 for the
 | 
				
			||||||
    # data clock.  This was tested with a Grove LED bar.
 | 
					    # data clock.  This was tested with a Grove LED bar.
 | 
				
			||||||
    myLEDBar = upmMy9221.GroveLEDBar(8, 9)
 | 
					    myLEDBar = upmMy9221.GroveLEDBar(8, 9)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Exit handlers
 | 
					    # Exit handlers
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
        raise SystemExit
 | 
					        raise SystemExit
 | 
				
			||||||
@@ -43,7 +43,6 @@ atexit.register(exitHandler)
 | 
				
			|||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    directionBool = True
 | 
					    directionBool = True
 | 
				
			||||||
    level = 1
 | 
					    level = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -62,3 +61,6 @@ while(1):
 | 
				
			|||||||
            time.sleep(1)
 | 
					            time.sleep(1)
 | 
				
			||||||
        time.sleep(.05)
 | 
					        time.sleep(.05)
 | 
				
			||||||
        x += 1
 | 
					        x += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/grovelight.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/grovelight.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_grove as grove
 | 
					import pyupm_grove as grove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create the light sensor object using AIO pin 0
 | 
					    # Create the light sensor object using AIO pin 0
 | 
				
			||||||
    light = grove.GroveLight(0)
 | 
					    light = grove.GroveLight(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -35,3 +36,6 @@ while 1:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the light sensor object
 | 
					    # Delete the light sensor object
 | 
				
			||||||
    del light
 | 
					    del light
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/grovelinefinder.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/grovelinefinder.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovelinefinder as upmGrovelinefinder
 | 
					import pyupm_grovelinefinder as upmGrovelinefinder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove line finder sensor on digital pin D2
 | 
					    # Instantiate a Grove line finder sensor on digital pin D2
 | 
				
			||||||
    myLineFinder = upmGrovelinefinder.GroveLineFinder(2)
 | 
					    myLineFinder = upmGrovelinefinder.GroveLineFinder(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -42,10 +42,12 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        if (myLineFinder.whiteDetected()):
 | 
					        if (myLineFinder.whiteDetected()):
 | 
				
			||||||
            print "White detected."
 | 
					            print "White detected."
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print "Black detected."
 | 
					            print "Black detected."
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								examples/python/grovemd-stepper.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										3
									
								
								examples/python/grovemd-stepper.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_grovemd as upmGrovemd
 | 
					import pyupm_grovemd as upmGrovemd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
 | 
					    I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
 | 
				
			||||||
    I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
 | 
					    I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -50,3 +51,5 @@ myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CCW, 10)
 | 
				
			|||||||
    # now disable
 | 
					    # now disable
 | 
				
			||||||
    myMotorDriver.disableStepper()
 | 
					    myMotorDriver.disableStepper()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/grovemd.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/grovemd.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,13 +24,13 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_grovemd as upmGrovemd
 | 
					import pyupm_grovemd as upmGrovemd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
 | 
					    I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
 | 
				
			||||||
    I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
 | 
					    I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Instantiate an I2C Grove Motor Driver on I2C bus 0
 | 
					    # Instantiate an I2C Grove Motor Driver on I2C bus 0
 | 
				
			||||||
    myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR)
 | 
					    myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # set direction to CW and set speed to 50%
 | 
					    # set direction to CW and set speed to 50%
 | 
				
			||||||
    print "Spin M1 and M2 at half speed for 3 seconds"
 | 
					    print "Spin M1 and M2 at half speed for 3 seconds"
 | 
				
			||||||
    myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CW, upmGrovemd.GroveMD.DIR_CW)
 | 
					    myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CW, upmGrovemd.GroveMD.DIR_CW)
 | 
				
			||||||
@@ -45,3 +45,6 @@ time.sleep(3)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    print "Stopping motors"
 | 
					    print "Stopping motors"
 | 
				
			||||||
    myMotorDriver.setMotorSpeeds(0, 0)
 | 
					    myMotorDriver.setMotorSpeeds(0, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/grovemoisture.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/grovemoisture.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovemoisture as upmMoisture
 | 
					import pyupm_grovemoisture as upmMoisture
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Moisture sensor on analog pin A0
 | 
					    # Instantiate a Grove Moisture sensor on analog pin A0
 | 
				
			||||||
    myMoisture = upmMoisture.GroveMoisture(0)
 | 
					    myMoisture = upmMoisture.GroveMoisture(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -42,7 +42,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Values (approximate):
 | 
					    # Values (approximate):
 | 
				
			||||||
    # 0-300,   sensor in air or dry soil
 | 
					    # 0-300,   sensor in air or dry soil
 | 
				
			||||||
    # 300-600, sensor in humid soil
 | 
					    # 300-600, sensor in humid soil
 | 
				
			||||||
@@ -59,3 +58,6 @@ while(1):
 | 
				
			|||||||
            result = "Wet"
 | 
					            result = "Wet"
 | 
				
			||||||
        print "Moisture value: {0}, {1}".format(moisture_val, result)
 | 
					        print "Moisture value: {0}, {1}".format(moisture_val, result)
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/groveo2.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/groveo2.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,11 +24,11 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_groveo2 as upmGroveo2
 | 
					import pyupm_groveo2 as upmGroveo2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # This was tested with the O2 Oxygen Concentration Sensor Module
 | 
					    # This was tested with the O2 Oxygen Concentration Sensor Module
 | 
				
			||||||
    # Instantiate a GroveO2 on analog pin A0
 | 
					    # Instantiate a GroveO2 on analog pin A0
 | 
				
			||||||
    myGroveO2 = upmGroveo2.GroveO2(0)
 | 
					    myGroveO2 = upmGroveo2.GroveO2(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -43,9 +43,11 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        print "The output voltage is: {0}mV".format(
 | 
					        print "The output voltage is: {0}mV".format(
 | 
				
			||||||
        myGroveO2.voltageValue())
 | 
					        myGroveO2.voltageValue())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/groverelay.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/groverelay.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_grove as grove
 | 
					import pyupm_grove as grove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create the relay switch object using GPIO pin 0
 | 
					    # Create the relay switch object using GPIO pin 0
 | 
				
			||||||
    relay = grove.GroveRelay(0)
 | 
					    relay = grove.GroveRelay(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -42,3 +43,6 @@ for i in range (0,3):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the relay switch object
 | 
					    # Delete the relay switch object
 | 
				
			||||||
    del relay
 | 
					    del relay
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/groverotary.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/groverotary.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,12 +23,12 @@
 | 
				
			|||||||
from time import sleep
 | 
					from time import sleep
 | 
				
			||||||
import pyupm_grove as grove
 | 
					import pyupm_grove as grove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # New knob on AIO pin 0
 | 
					    # New knob on AIO pin 0
 | 
				
			||||||
    knob = grove.GroveRotary(0)
 | 
					    knob = grove.GroveRotary(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Loop indefinitely
 | 
					    # Loop indefinitely
 | 
				
			||||||
    while True:
 | 
					    while True:
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Read values
 | 
					        # Read values
 | 
				
			||||||
        abs = knob.abs_value()
 | 
					        abs = knob.abs_value()
 | 
				
			||||||
        absdeg = knob.abs_deg()
 | 
					        absdeg = knob.abs_deg()
 | 
				
			||||||
@@ -43,3 +43,6 @@ while True:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # Sleep for 2.5 s
 | 
					        # Sleep for 2.5 s
 | 
				
			||||||
        sleep(2.5)
 | 
					        sleep(2.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/grovescam.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/grovescam.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -25,6 +25,7 @@
 | 
				
			|||||||
import sys
 | 
					import sys
 | 
				
			||||||
import pyupm_grovescam as upmGrovescam
 | 
					import pyupm_grovescam as upmGrovescam
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Serial Camera on UART 0
 | 
					    # Instantiate a Grove Serial Camera on UART 0
 | 
				
			||||||
    camera = upmGrovescam.GROVESCAM(0)
 | 
					    camera = upmGrovescam.GROVESCAM(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -59,3 +60,6 @@ if (camera.getImageSize() > 0):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    print "Exiting."
 | 
					    print "Exiting."
 | 
				
			||||||
    sys.exit(0)
 | 
					    sys.exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/groveslide.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/groveslide.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,12 +23,12 @@
 | 
				
			|||||||
from time import sleep
 | 
					from time import sleep
 | 
				
			||||||
import pyupm_grove as grove
 | 
					import pyupm_grove as grove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # New Grove Slider on AIO pin 0
 | 
					    # New Grove Slider on AIO pin 0
 | 
				
			||||||
    slider = grove.GroveSlide(0)
 | 
					    slider = grove.GroveSlide(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Loop indefinitely
 | 
					    # Loop indefinitely
 | 
				
			||||||
    while True:
 | 
					    while True:
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Read values
 | 
					        # Read values
 | 
				
			||||||
        raw = slider.raw_value()
 | 
					        raw = slider.raw_value()
 | 
				
			||||||
        volts = slider.voltage_value()
 | 
					        volts = slider.voltage_value()
 | 
				
			||||||
@@ -37,3 +37,6 @@ while True:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # Sleep for 2.5 s
 | 
					        # Sleep for 2.5 s
 | 
				
			||||||
        sleep(2.5)
 | 
					        sleep(2.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/grovespeaker.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/grovespeaker.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovespeaker as upmGrovespeaker
 | 
					import pyupm_grovespeaker as upmGrovespeaker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Speaker on digital pin D2
 | 
					    # Instantiate a Grove Speaker on digital pin D2
 | 
				
			||||||
    mySpeaker = upmGrovespeaker.GroveSpeaker(2)
 | 
					    mySpeaker = upmGrovespeaker.GroveSpeaker(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -32,3 +33,6 @@ mySpeaker.playAll()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Play a medium C-sharp
 | 
					    # Play a medium C-sharp
 | 
				
			||||||
    mySpeaker.playSound('c', True, "med")
 | 
					    mySpeaker.playSound('c', True, "med")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/grovetemp.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/grovetemp.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_grove as grove
 | 
					import pyupm_grove as grove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create the temperature sensor object using AIO pin 0
 | 
					    # Create the temperature sensor object using AIO pin 0
 | 
				
			||||||
    temp = grove.GroveTemp(0)
 | 
					    temp = grove.GroveTemp(0)
 | 
				
			||||||
    print temp.name()
 | 
					    print temp.name()
 | 
				
			||||||
@@ -39,3 +40,6 @@ for i in range(0, 10):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the temperature sensor object
 | 
					    # Delete the temperature sensor object
 | 
				
			||||||
    del temp
 | 
					    del temp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/grovevdiv.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/grovevdiv.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovevdiv as upmGrovevdiv
 | 
					import pyupm_grovevdiv as upmGrovevdiv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Voltage Divider sensor on analog pin A0
 | 
					    # Instantiate a Grove Voltage Divider sensor on analog pin A0
 | 
				
			||||||
    myVoltageDivider = upmGrovevdiv.GroveVDiv(0)
 | 
					    myVoltageDivider = upmGrovevdiv.GroveVDiv(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -43,7 +43,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        val = myVoltageDivider.value(100)
 | 
					        val = myVoltageDivider.value(100)
 | 
				
			||||||
        gain3val = myVoltageDivider.computedValue(3, val)
 | 
					        gain3val = myVoltageDivider.computedValue(3, val)
 | 
				
			||||||
@@ -52,3 +51,6 @@ while(1):
 | 
				
			|||||||
        val,  gain3val, gain10val)
 | 
					        val,  gain3val, gain10val)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/grovewater.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/grovewater.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovewater as upmGrovewater
 | 
					import pyupm_grovewater as upmGrovewater
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Water sensor on digital pin D2
 | 
					    # Instantiate a Grove Water sensor on digital pin D2
 | 
				
			||||||
    myWaterSensor = upmGrovewater.GroveWater(2)
 | 
					    myWaterSensor = upmGrovewater.GroveWater(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -42,10 +42,12 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        if (myWaterSensor.isWet()):
 | 
					        if (myWaterSensor.isWet()):
 | 
				
			||||||
            print "Sensor is wet"
 | 
					            print "Sensor is wet"
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print "Sensor is dry"
 | 
					            print "Sensor is dry"
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/grovewfs.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/grovewfs.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_grovewfs as upmGrovewfs
 | 
					import pyupm_grovewfs as upmGrovewfs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Grove Water Flow Sensor on digital pin D2
 | 
					    # Instantiate a Grove Water Flow Sensor on digital pin D2
 | 
				
			||||||
    myWaterFlow = upmGrovewfs.GroveWFS(2)
 | 
					    myWaterFlow = upmGrovewfs.GroveWFS(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -44,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # set the flow counter to 0 and start counting
 | 
					    # set the flow counter to 0 and start counting
 | 
				
			||||||
    myWaterFlow.clearFlowCounter()
 | 
					    myWaterFlow.clearFlowCounter()
 | 
				
			||||||
    myWaterFlow.startFlowCounter()
 | 
					    myWaterFlow.startFlowCounter()
 | 
				
			||||||
@@ -62,3 +61,6 @@ while (1):
 | 
				
			|||||||
        millis, flowCount, fr)
 | 
					        millis, flowCount, fr)
 | 
				
			||||||
        print outputStr
 | 
					        print outputStr
 | 
				
			||||||
        time.sleep(2)
 | 
					        time.sleep(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/gsr.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/gsr.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,12 +24,12 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_gsr as upmGsr
 | 
					import pyupm_gsr as upmGsr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Tested with the GSR Galvanic Skin Response Sensor module.
 | 
					    # Tested with the GSR Galvanic Skin Response Sensor module.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Instantiate a GSR on analog pin A0
 | 
					    # Instantiate a GSR on analog pin A0
 | 
				
			||||||
    myGSR = upmGsr.GSR(0)
 | 
					    myGSR = upmGsr.GSR(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -44,10 +44,12 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    print "Calibrating...."
 | 
					    print "Calibrating...."
 | 
				
			||||||
    myGSR.calibrate()
 | 
					    myGSR.calibrate()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (1):
 | 
					    while (1):
 | 
				
			||||||
        print myGSR.value()
 | 
					        print myGSR.value()
 | 
				
			||||||
        time.sleep(.5)
 | 
					        time.sleep(.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/guvas12d.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/guvas12d.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_guvas12d as upmUV
 | 
					import pyupm_guvas12d as upmUV
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a UV sensor on analog pin A0
 | 
					    # Instantiate a UV sensor on analog pin A0
 | 
				
			||||||
    myUVSensor = upmUV.GUVAS12D(0);
 | 
					    myUVSensor = upmUV.GUVAS12D(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,7 +32,6 @@ myUVSensor = upmUV.GUVAS12D(0);
 | 
				
			|||||||
    GUVAS12D_AREF = 5.0;
 | 
					    GUVAS12D_AREF = 5.0;
 | 
				
			||||||
    SAMPLES_PER_QUERY = 1024;
 | 
					    SAMPLES_PER_QUERY = 1024;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -46,7 +46,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        s = ("AREF:  {0}, "
 | 
					        s = ("AREF:  {0}, "
 | 
				
			||||||
        "Voltage value (higher means more UV): "
 | 
					        "Voltage value (higher means more UV): "
 | 
				
			||||||
@@ -54,3 +53,6 @@ while(1):
 | 
				
			|||||||
        myUVSensor.value(GUVAS12D_AREF, SAMPLES_PER_QUERY)))
 | 
					        myUVSensor.value(GUVAS12D_AREF, SAMPLES_PER_QUERY)))
 | 
				
			||||||
        print s
 | 
					        print s
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/h3lis331dl.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/h3lis331dl.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,12 +24,12 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_h3lis331dl as upmH3LIS331DL
 | 
					import pyupm_h3lis331dl as upmH3LIS331DL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate an H3LIS331DL on I2C bus 0
 | 
					    # Instantiate an H3LIS331DL on I2C bus 0
 | 
				
			||||||
    myDigitalAccelerometer = upmH3LIS331DL.H3LIS331DL(
 | 
					    myDigitalAccelerometer = upmH3LIS331DL.H3LIS331DL(
 | 
				
			||||||
            upmH3LIS331DL.H3LIS331DL_I2C_BUS,
 | 
					            upmH3LIS331DL.H3LIS331DL_I2C_BUS,
 | 
				
			||||||
            upmH3LIS331DL.H3LIS331DL_DEFAULT_I2C_ADDR);
 | 
					            upmH3LIS331DL.H3LIS331DL_DEFAULT_I2C_ADDR);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -44,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Initialize the device with default values
 | 
					    # Initialize the device with default values
 | 
				
			||||||
    myDigitalAccelerometer.init()
 | 
					    myDigitalAccelerometer.init()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -74,3 +73,6 @@ while (1):
 | 
				
			|||||||
        upmH3LIS331DL.floatp_value(az))
 | 
					        upmH3LIS331DL.floatp_value(az))
 | 
				
			||||||
        print outputStr
 | 
					        print outputStr
 | 
				
			||||||
        time.sleep(.5)
 | 
					        time.sleep(.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/h803x.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/h803x.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_h803x as sensorObj
 | 
					import pyupm_h803x as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -104,3 +105,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(2)
 | 
					        time.sleep(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/hdxxvxta.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/hdxxvxta.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_hdxxvxta as sensorObj
 | 
					import pyupm_hdxxvxta as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -57,3 +58,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/hka5.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/hka5.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_hka5 as sensorObj
 | 
					import pyupm_hka5 as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a HKA5 sensor on uart 0.  We don't use the set or
 | 
					    # Instantiate a HKA5 sensor on uart 0.  We don't use the set or
 | 
				
			||||||
    # reset pins, so we pass -1 for them.
 | 
					    # reset pins, so we pass -1 for them.
 | 
				
			||||||
    sensor = sensorObj.HKA5(0, -1, -1)
 | 
					    sensor = sensorObj.HKA5(0, -1, -1)
 | 
				
			||||||
@@ -60,3 +61,6 @@ while (True):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(2)
 | 
					        time.sleep(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								examples/python/hm11.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										7
									
								
								examples/python/hm11.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_hm11 as upmHm11
 | 
					import pyupm_hm11 as upmHm11
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a HM11 BLE Module on UART 0
 | 
					    # Instantiate a HM11 BLE Module on UART 0
 | 
				
			||||||
    my_ble_obj = upmHm11.HM11(0)
 | 
					    my_ble_obj = upmHm11.HM11(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -43,7 +43,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    bufferLength = 256
 | 
					    bufferLength = 256
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # make sure port is initialized properly. 9600 baud is the default.
 | 
					    # make sure port is initialized properly. 9600 baud is the default.
 | 
				
			||||||
@@ -51,7 +50,6 @@ if (not my_ble_obj.setupTty(upmHm11.cvar.int_B9600)):
 | 
				
			|||||||
        print "Failed to setup tty port parameters"
 | 
					        print "Failed to setup tty port parameters"
 | 
				
			||||||
        sys.exit(0)
 | 
					        sys.exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    usageStr = ("Usage:\n"
 | 
					    usageStr = ("Usage:\n"
 | 
				
			||||||
    "Pass a commandline argument (any argument) to this program\n"
 | 
					    "Pass a commandline argument (any argument) to this program\n"
 | 
				
			||||||
    "to query the radio configuration and output it.  NOTE: the\n"
 | 
					    "to query the radio configuration and output it.  NOTE: the\n"
 | 
				
			||||||
@@ -81,7 +79,6 @@ def sendCommand(bleObj, cmd):
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print "Timed out waiting for response"
 | 
					            print "Timed out waiting for response"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (len(sys.argv) > 1):
 | 
					    if (len(sys.argv) > 1):
 | 
				
			||||||
        print "Sending command line argument (" + sys.argv[1] + ")..."
 | 
					        print "Sending command line argument (" + sys.argv[1] + ")..."
 | 
				
			||||||
        sendCommand(my_ble_obj, sys.argv[1])
 | 
					        sendCommand(my_ble_obj, sys.argv[1])
 | 
				
			||||||
@@ -108,3 +105,5 @@ else:
 | 
				
			|||||||
        # A comprehensive list is available from the datasheet at:
 | 
					        # A comprehensive list is available from the datasheet at:
 | 
				
			||||||
        # http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf
 | 
					        # http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/hmc5883l.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/hmc5883l.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,13 +23,13 @@
 | 
				
			|||||||
from time import sleep
 | 
					from time import sleep
 | 
				
			||||||
import pyupm_hmc5883l as hmc5883l
 | 
					import pyupm_hmc5883l as hmc5883l
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create an I2C compass object and set declination
 | 
					    # Create an I2C compass object and set declination
 | 
				
			||||||
    hmc = hmc5883l.Hmc5883l(0)
 | 
					    hmc = hmc5883l.Hmc5883l(0)
 | 
				
			||||||
    hmc.set_declination(0.2749)
 | 
					    hmc.set_declination(0.2749)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Loop indefinitely
 | 
					    # Loop indefinitely
 | 
				
			||||||
    while True:
 | 
					    while True:
 | 
				
			||||||
 | 
					 | 
				
			||||||
        hmc.update() # Update the data
 | 
					        hmc.update() # Update the data
 | 
				
			||||||
        pos = hmc.coordinates() # Read raw coordinates
 | 
					        pos = hmc.coordinates() # Read raw coordinates
 | 
				
			||||||
        hdg = hmc.heading() # Read heading
 | 
					        hdg = hmc.heading() # Read heading
 | 
				
			||||||
@@ -42,3 +42,6 @@ while True:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # Sleep for 1 s
 | 
					        # Sleep for 1 s
 | 
				
			||||||
        sleep(1)
 | 
					        sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								examples/python/hmtrp.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										8
									
								
								examples/python/hmtrp.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_hmtrp as upmHmtrp
 | 
					import pyupm_hmtrp as upmHmtrp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a HMTRP radio device on uart 0
 | 
					    # Instantiate a HMTRP radio device on uart 0
 | 
				
			||||||
    my_HMTRP_Radio = upmHmtrp.HMTRP(0)
 | 
					    my_HMTRP_Radio = upmHmtrp.HMTRP(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -43,7 +43,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    myCounter = 0
 | 
					    myCounter = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # normal read/write mode
 | 
					    # normal read/write mode
 | 
				
			||||||
@@ -55,7 +54,6 @@ if (not my_HMTRP_Radio.setupTty(upmHmtrp.cvar.int_B9600)):
 | 
				
			|||||||
        print "Failed to setup tty port parameters"
 | 
					        print "Failed to setup tty port parameters"
 | 
				
			||||||
        sys.exit(0)
 | 
					        sys.exit(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    usageStr = ("Usage:\n"
 | 
					    usageStr = ("Usage:\n"
 | 
				
			||||||
    "Pass a commandline argument (any argument) to this program\n"
 | 
					    "Pass a commandline argument (any argument) to this program\n"
 | 
				
			||||||
    "to query the radio configuration and output it.  NOTE: the\n"
 | 
					    "to query the radio configuration and output it.  NOTE: the\n"
 | 
				
			||||||
@@ -79,7 +77,6 @@ If any argument was specified on the command line, do a simple
 | 
				
			|||||||
    configuration query and output the results.  The radio must be in
 | 
					    configuration query and output the results.  The radio must be in
 | 
				
			||||||
    CONFIG mode for this to work.
 | 
					    CONFIG mode for this to work.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    Note that the first command-line argument should be "hmtry.py"
 | 
					    Note that the first command-line argument should be "hmtry.py"
 | 
				
			||||||
    The data we want would be the second... if it exists
 | 
					    The data we want would be the second... if it exists
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
@@ -141,3 +138,6 @@ else:
 | 
				
			|||||||
                my_HMTRP_Radio.writeData(msg, (len(msg) + 1))
 | 
					                my_HMTRP_Radio.writeData(msg, (len(msg) + 1))
 | 
				
			||||||
                myCounter = 0
 | 
					                myCounter = 0
 | 
				
			||||||
            time.sleep(.1)
 | 
					            time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								examples/python/hp20x.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										3
									
								
								examples/python/hp20x.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_hp20x as barometerObj
 | 
					import pyupm_hp20x as barometerObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -52,3 +53,5 @@ while(1):
 | 
				
			|||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								examples/python/ht9170.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5
									
								
								examples/python/ht9170.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ht9170 as upmHt9170
 | 
					import pyupm_ht9170 as upmHt9170
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a DTMF decoder
 | 
					    # Instantiate a DTMF decoder
 | 
				
			||||||
    myDTMF = upmHt9170.HT9170(12, 11, 10, 9, 8)
 | 
					    myDTMF = upmHt9170.HT9170(12, 11, 10, 9, 8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -41,7 +42,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Now we just spin in a loop, sleeping every 100ms, checking to see
 | 
					    # Now we just spin in a loop, sleeping every 100ms, checking to see
 | 
				
			||||||
    # if a digit is available.  If so, we decode and print the digit,
 | 
					    # if a digit is available.  If so, we decode and print the digit,
 | 
				
			||||||
    # and continue looping.
 | 
					    # and continue looping.
 | 
				
			||||||
@@ -52,3 +52,6 @@ while (1):
 | 
				
			|||||||
            while (dtmf.digitReady()):
 | 
					            while (dtmf.digitReady()):
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
        time.sleep(.1)
 | 
					        time.sleep(.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/hwxpxx.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/hwxpxx.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_hwxpxx as sensorObj
 | 
					import pyupm_hwxpxx as sensorObj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -77,3 +78,6 @@ while (1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        print
 | 
					        print
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/ili9341.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/ili9341.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,6 +24,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_ili9341 as ili9341
 | 
					import pyupm_ili9341 as ili9341
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Pins (Edison)
 | 
					    # Pins (Edison)
 | 
				
			||||||
    # CS_LCD   GP44 (MRAA 31)
 | 
					    # CS_LCD   GP44 (MRAA 31)
 | 
				
			||||||
    # CS_SD    GP43 (MRAA 38) unused
 | 
					    # CS_SD    GP43 (MRAA 38) unused
 | 
				
			||||||
@@ -73,3 +74,6 @@ lcd.invertDisplay(False)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Don't forget to free up that memory!
 | 
					    # Don't forget to free up that memory!
 | 
				
			||||||
    del lcd
 | 
					    del lcd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								examples/python/ina132.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										7
									
								
								examples/python/ina132.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -21,15 +21,14 @@
 | 
				
			|||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
					# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
				
			||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
					# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_ina132 as upmIna132
 | 
					import pyupm_ina132 as upmIna132
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Tested with the INA132 Differential Amplifier Sensor module.
 | 
					    # Tested with the INA132 Differential Amplifier Sensor module.
 | 
				
			||||||
    # Instantiate an INA132 on analog pin A0
 | 
					    # Instantiate an INA132 on analog pin A0
 | 
				
			||||||
    myDifferentialAmplifier = upmIna132.INA132(0)
 | 
					    myDifferentialAmplifier = upmIna132.INA132(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -45,7 +44,9 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        print myDifferentialAmplifier.value()
 | 
					        print myDifferentialAmplifier.value()
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								examples/python/isd1820.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										9
									
								
								examples/python/isd1820.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,17 +24,16 @@
 | 
				
			|||||||
import time, sys, atexit
 | 
					import time, sys, atexit
 | 
				
			||||||
import pyupm_isd1820 as upmIsd1820
 | 
					import pyupm_isd1820 as upmIsd1820
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a ISD1820 on digital pins 2 (play) and 3 (record)
 | 
					    # Instantiate a ISD1820 on digital pins 2 (play) and 3 (record)
 | 
				
			||||||
    # This example was tested on the Grove Recorder.
 | 
					    # This example was tested on the Grove Recorder.
 | 
				
			||||||
    myRecorder = upmIsd1820.ISD1820(2, 3)
 | 
					    myRecorder = upmIsd1820.ISD1820(2, 3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    doRecord = False
 | 
					    doRecord = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if len(sys.argv) > 1:
 | 
					    if len(sys.argv) > 1:
 | 
				
			||||||
        doRecord = True
 | 
					        doRecord = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # This lets you run code on exit,
 | 
					    # This lets you run code on exit,
 | 
				
			||||||
    # including functions from myRecorder
 | 
					    # including functions from myRecorder
 | 
				
			||||||
    def exitHandler():
 | 
					    def exitHandler():
 | 
				
			||||||
@@ -49,7 +48,6 @@ def exitHandler():
 | 
				
			|||||||
    # Register exit handlers
 | 
					    # Register exit handlers
 | 
				
			||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # if an argument was specified (any argument), go into record mode,
 | 
					    # if an argument was specified (any argument), go into record mode,
 | 
				
			||||||
    # else playback a previously recorded sample
 | 
					    # else playback a previously recorded sample
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -58,7 +56,6 @@ print "Running this example without arguments will play back any "
 | 
				
			|||||||
    print "previously recorded sound."
 | 
					    print "previously recorded sound."
 | 
				
			||||||
    print "There is approximately 10 seconds of recording time.\n"
 | 
					    print "There is approximately 10 seconds of recording time.\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # depending on what was selected, do it, and sleep for 15 seconds
 | 
					    # depending on what was selected, do it, and sleep for 15 seconds
 | 
				
			||||||
    if (doRecord):
 | 
					    if (doRecord):
 | 
				
			||||||
        myRecorder.record(True)
 | 
					        myRecorder.record(True)
 | 
				
			||||||
@@ -70,5 +67,7 @@ else:
 | 
				
			|||||||
    print "Sleeping for 15 seconds..."
 | 
					    print "Sleeping for 15 seconds..."
 | 
				
			||||||
    time.sleep(15)
 | 
					    time.sleep(15)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # exitHandler runs automatically
 | 
					    # exitHandler runs automatically
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/itg3200.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/itg3200.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import pyupm_itg3200 as itg3200
 | 
					import pyupm_itg3200 as itg3200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Create an I2C gyro object
 | 
					    # Create an I2C gyro object
 | 
				
			||||||
    gyro = itg3200.Itg3200(0)
 | 
					    gyro = itg3200.Itg3200(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -40,3 +41,6 @@ while(1):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Delete the gyro object
 | 
					    # Delete the gyro object
 | 
				
			||||||
    del gyro
 | 
					    del gyro
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								examples/python/jhd1313m1-lcd.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								examples/python/jhd1313m1-lcd.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -23,6 +23,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import pyupm_i2clcd as lcd
 | 
					import pyupm_i2clcd as lcd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
 | 
					    # Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
 | 
				
			||||||
    myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
 | 
					    myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -36,3 +37,6 @@ myLcd.setColor(255, 0, 0)
 | 
				
			|||||||
    myLcd.write('Hello World')
 | 
					    myLcd.write('Hello World')
 | 
				
			||||||
    myLcd.setCursor(1,2)
 | 
					    myLcd.setCursor(1,2)
 | 
				
			||||||
    myLcd.write('Hello World')
 | 
					    myLcd.write('Hello World')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								examples/python/joystick12.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								examples/python/joystick12.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -24,10 +24,10 @@
 | 
				
			|||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_joystick12 as upmJoystick12
 | 
					import pyupm_joystick12 as upmJoystick12
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a joystick on analog pins A0 and A1
 | 
					    # Instantiate a joystick on analog pins A0 and A1
 | 
				
			||||||
    myJoystick = upmJoystick12.Joystick12(0, 1)
 | 
					    myJoystick = upmJoystick12.Joystick12(0, 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This function stops python from printing a stacktrace when you hit control-C
 | 
					    # This function stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -42,7 +42,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Print the X and Y input values every second
 | 
					    # Print the X and Y input values every second
 | 
				
			||||||
    while(1):
 | 
					    while(1):
 | 
				
			||||||
        XString = "Driving X:" + str(myJoystick.getXInput())
 | 
					        XString = "Driving X:" + str(myJoystick.getXInput())
 | 
				
			||||||
@@ -50,3 +49,6 @@ while(1):
 | 
				
			|||||||
        print XString + YString
 | 
					        print XString + YString
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time.sleep(1)
 | 
					        time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								examples/python/l298-stepper.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										7
									
								
								examples/python/l298-stepper.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -21,15 +21,14 @@
 | 
				
			|||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
					# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
				
			||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
					# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_l298 as upmL298
 | 
					import pyupm_l298 as upmL298
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate a Stepper motor on a L298 Dual H-Bridge.
 | 
					    # Instantiate a Stepper motor on a L298 Dual H-Bridge.
 | 
				
			||||||
    # This was tested with the NEMA-17 12V, 350mA, with 200 steps per rev.
 | 
					    # This was tested with the NEMA-17 12V, 350mA, with 200 steps per rev.
 | 
				
			||||||
    myHBridge = upmL298.L298(200, 3, 4, 7, 8, 9)
 | 
					    myHBridge = upmL298.L298(200, 3, 4, 7, 8, 9)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -45,7 +44,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    myHBridge.setSpeed(10) # 10 RPMs
 | 
					    myHBridge.setSpeed(10) # 10 RPMs
 | 
				
			||||||
    myHBridge.setDirection(upmL298.L298.DIR_CW)
 | 
					    myHBridge.setDirection(upmL298.L298.DIR_CW)
 | 
				
			||||||
    myHBridge.enable(True)
 | 
					    myHBridge.enable(True)
 | 
				
			||||||
@@ -65,3 +63,6 @@ myHBridge.stepperSteps(100)
 | 
				
			|||||||
    myHBridge.enable(False)
 | 
					    myHBridge.enable(False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # exitHandler is called automatically
 | 
					    # exitHandler is called automatically
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								examples/python/l298.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										7
									
								
								examples/python/l298.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -21,16 +21,15 @@
 | 
				
			|||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
					# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
				
			||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
					# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
import time, sys, signal, atexit
 | 
					import time, sys, signal, atexit
 | 
				
			||||||
import pyupm_l298 as upmL298
 | 
					import pyupm_l298 as upmL298
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
    # Instantiate one of the 2 possible DC motors on a L298 Dual
 | 
					    # Instantiate one of the 2 possible DC motors on a L298 Dual
 | 
				
			||||||
    # H-Bridge.  For controlling a stepper motor, see the l298-stepper
 | 
					    # H-Bridge.  For controlling a stepper motor, see the l298-stepper
 | 
				
			||||||
    # example.
 | 
					    # example.
 | 
				
			||||||
    myHBridge = upmL298.L298(3, 4, 7)
 | 
					    myHBridge = upmL298.L298(3, 4, 7)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ## Exit handlers ##
 | 
					    ## Exit handlers ##
 | 
				
			||||||
    # This stops python from printing a stacktrace when you hit control-C
 | 
					    # This stops python from printing a stacktrace when you hit control-C
 | 
				
			||||||
    def SIGINTHandler(signum, frame):
 | 
					    def SIGINTHandler(signum, frame):
 | 
				
			||||||
@@ -46,7 +45,6 @@ def exitHandler():
 | 
				
			|||||||
    atexit.register(exitHandler)
 | 
					    atexit.register(exitHandler)
 | 
				
			||||||
    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
					    signal.signal(signal.SIGINT, SIGINTHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    print "Starting motor at 50% for 3 seconds..."
 | 
					    print "Starting motor at 50% for 3 seconds..."
 | 
				
			||||||
    myHBridge.setSpeed(50)
 | 
					    myHBridge.setSpeed(50)
 | 
				
			||||||
    myHBridge.setDirection(upmL298.L298.DIR_CW)
 | 
					    myHBridge.setDirection(upmL298.L298.DIR_CW)
 | 
				
			||||||
@@ -63,3 +61,6 @@ myHBridge.setSpeed(0)
 | 
				
			|||||||
    myHBridge.enable(False)
 | 
					    myHBridge.enable(False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # exitHandler is called automatically
 | 
					    # exitHandler is called automatically
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user