import grovepi import grovelcd import time grovepi.pinMode(3,"OUTPUT") print "time,ultra,analog" while True: ultra=grovepi.ultrasonicRead(2) ana=grovepi.analogRead(0) digi=grovepi.digitalRead(4) grovepi.analogWrite(3,ultra/2) grovelcd.setRGB(ultra/2,200-ultra/2,0) txt="%d - %d\n wooo yay"%(digi, ana) grovelcd.setText(txt,True) print "%f,%d,%d"%(time.time(),ultra,ana) time.sleep(0.1)
from __future__ import print_function import grovepi import grovelcd import time grovepi.pinMode(3, "OUTPUT") print("time,ultra,analog,digital") while True: ultra = grovepi.ultrasonicRead(2) ana = grovepi.analogRead(0) digi = grovepi.digitalRead(4) timestamp = time.time() grovepi.analogWrite(3, ultra / 2) grovelcd.setRGB(ultra / 2, 200 - ultra / 2, 0) txt = "%d - %d - %d\n wooo yay" % (ultra, digi, ana) grovelcd.setText(txt, False) print("%f,%d,%d,%d" % (timestamp, ultra, ana, digi)) time.sleep(0.1)
def __add_display_lcd(self, text): self.text += text grovelcd.setText(text)
def __set_display_lcd(self, text): self.text = text grovelcd.setText(text)
#!/usr/bin/python3 import grovelcd import time import subprocess import re import socket grovelcd.setRGB(128, 128, 128) cyclePos = 1 grovelcd.setText("No address yet") # changed to only say IP address, so as not to confuse people with gateway addresses def formatAddr(addr, type): retVal = addr if len(retVal) < 14: retVal += " " * (14 - len(retVal)) if len(retVal) == 14: retVal += ":" if len(retVal) < 16: retVal += type return retVal[0:16] countLeft = 60 while countLeft == None or countLeft > 0: # if startTime!=None: # print startTime,time.time(),startTime,startTime+10,time.time()<startTime+30 result = subprocess.check_output(['ip', 'route'])
#!/usr/bin/python3 import grovelcd import time import subprocess import re import socket grovelcd.setRGB(128,128,128) cyclePos=1 grovelcd.setText("No address yet") # changed to only say IP address, so as not to confuse people with gateway addresses def formatAddr(addr,type): retVal=addr if len(retVal)<14: retVal+=" "*(14-len(retVal)) if len(retVal)==14: retVal+=":" if len(retVal)<16: retVal+=type return retVal[0:16] countLeft=60 while countLeft==None or countLeft>0: # if startTime!=None: # print startTime,time.time(),startTime,startTime+10,time.time()<startTime+30 result=subprocess.check_output(['ip','route']) result=result.decode() curPos=0