def main(argv): global display, la, lo, debug, idEDU, ipEPU, portEPU ## Parse arguments from the command-line ## Options: debug idU ipEPU portEPU opts, ars = getopt.getopt(argv, "hd:u:i:p:", ["debug=", "idEDU=", "ipEPU=", "portEPU="]) for opt, arg in opts: if opt == "-h": print("edu.py -d <debug> -u <idEDU> -i <ipEPU> -p <portEDU>") sys.exit(1) elif opt in ("-d", "--debug"): if arg == "True": debug = True else: debug = False elif opt in ("-u", "--idEDU"): idEDU = arg elif opt in ("-i", "--ipEPU"): ipEPU = arg elif opt in ("-p", "--portEPU"): portEPU = int(arg) ######## print("Events Detector Unit is initializing... Ready to detect events.") ## Initialize display grovepi.fourDigit_init(display) grovepi.fourDigit_brightness(display, 6) time.sleep(.2) showDisplayNumberEI() ## Get GPS location - only once at startup if debug: print("Obtaining GPS position...") gps = moduleGPS.groveGPS() gps.read() la = gps.latitude lo = gps.longitude if debug: print("EDU at latitude =", la, "and longitude =", lo) ## Initialize EI definitions initializeEI() ## Initialize thread to read all the sensors checkSensors = sensingThread() checkSensors.start() ## Initialize thread to refresh ER refreshER = refreshThread() refreshER.start() atexit.register(exit_handler)
# grovepi.fourDigit_digit(pin,segment,value) # grovepi.fourDigit_segment(pin,segment,leds) # grovepi.fourDigit_score(pin,left,right) # grovepi.fourDigit_monitor(pin,analog,duration) # grovepi.fourDigit_on(pin) # grovepi.fourDigit_off(pin) while True: try: print ("Test 1) Initialise") grovepi.fourDigit_init(display) time.sleep(.5) print ("Test 2) Set brightness") for i in range(0,8): grovepi.fourDigit_brightness(display,i) time.sleep(.2) time.sleep(.3) # set to lowest brightness level grovepi.fourDigit_brightness(display,0) time.sleep(.5) print ("Test 3) Set number without leading zeros") leading_zero = 0 grovepi.fourDigit_number(display,1,leading_zero) time.sleep(.5) grovepi.fourDigit_number(display,12,leading_zero) time.sleep(.5) grovepi.fourDigit_number(display,123,leading_zero) time.sleep(.5)
def setBrightness(self, level): grovepi.fourDigit_brightness(self.__pin, level)
dht_sensor_port = 7 # Connect the DHt sensor to port 7 # Connect the Grove LED to digital port D4 led = 4 pinMode(led,"OUTPUT") # Connect the Grove 4 Digit Display to digital port D5 # CLK,DIO,VCC,GND display1 = 5 display2 = 8 grovepi.pinMode(display1,"OUTPUT") grovepi.pinMode(display2,"OUTPUT") grovepi.fourDigit_init(display1) grovepi.fourDigit_init(display2) grovepi.fourDigit_brightness(display1,0) grovepi.fourDigit_brightness(display2,1) time.sleep(.5) while True: try: [ temp,hum ] = dht(dht_sensor_port,0) #Get the temperature and Humidity from the DHT sensor mydate = datetime.datetime.now() Z = mydate.strftime("%Z") A = mydate.strftime("%a") D = mydate.strftime("%d") O = mydate.strftime("%b") Y = mydate.strftime("%Y") H = '%02d' % mydate.hour M = '%02d' % mydate.minute
dht_sensor_port = 7 # Connect the DHt sensor to port 7 # Connect the Grove LED to digital port D4 led = 4 pinMode(led, "OUTPUT") # Connect the Grove 4 Digit Display to digital port D5 # CLK,DIO,VCC,GND display1 = 5 display2 = 8 grovepi.pinMode(display1, "OUTPUT") grovepi.pinMode(display2, "OUTPUT") grovepi.fourDigit_init(display1) grovepi.fourDigit_init(display2) grovepi.fourDigit_brightness(display1, 0) grovepi.fourDigit_brightness(display2, 1) time.sleep(.5) while True: try: [temp, hum] = dht(dht_sensor_port, 0) #Get the temperature and Humidity from the DHT sensor mydate = datetime.datetime.now() Z = mydate.strftime("%Z") A = mydate.strftime("%a") D = mydate.strftime("%d") O = mydate.strftime("%b") Y = mydate.strftime("%Y")
def setBrightness(self, value=0): """ set brightness of the 4 digit display 0 - 8 brightness set to 0 by default """ grovepi.fourDigit_brightness(self.display, value)
def dim(self, percentage): grovepi.fourDigit_brightness(display, int(7 * (percentage / 100.0)))
def setBrightness(self, brightness): print("set brightness to", brightness) grovepi.fourDigit_brightness(self.port, brightness) return