def grove_set_color(lcd, red, green, blue): if device_type == DEVICE_TYPE_MRAA: lcd.setColor(red, green, blue) elif device_type == DEVICE_TYPE_RPI: lcd.setRGB(red, green, blue) elif device_type == DEVICE_TYPE_GPI: raise NotImplementedError
def outcome(bool): lcd.clear() if bool == 0: lcd.setColor(255,255,0) lcd.write('Success!') else: lcd.setColor(255,0,0) lcd.write('Fatal error :( ')
def WelcomAndSetupMic(lcd, delay, myMic): global averageThreshold lcd.write("Que pedo morro") i = delay threshSum = 0 while i >= 0: lcd.setColor(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) time.sleep(0.2) i -= 1 buffer = upmMicrophone.uint16Array(128) len = myMic.getSampledWindow(2, 128, buffer); if len: thresh = myMic.findThreshold(threshContext, 30, buffer, len) # myMic.printGraph(threshContext) if(thresh): # print(thresh) threshSum += thresh # print threshSum averageThreshold = threshSum/float(delay) averageThreshold *= 2 print averageThreshold
def ChangeLcd(lcd, sensorId, message2): lcd.clear() lcd.home() message1 = "" color = (123, 123, 123) if sensorId == buttonId: message1 = buttonMessage color = buttonColor elif sensorId == touchId: message1 = touchMessage color = touchColor elif sensorId == knobId: message1 = knobMessage color = knobColor elif sensorId == micId: message1 = micMessage color = micColor lcd.setColor(color[0], color[1], color[2]) lcd.write(message1) lcd.setCursor(1, 0) lcd.write(message2)
def write(string,red,green,blue): lcd.clear() lcd.setColor(red,green,blue) lcd.write(string)
def write(string, r, g, b): # input is assumed to be a list of 4 lcd.clear() # lcd.setcursor(0,0) lcd.setColor(r, g, b) lcd.write(string)
# https://github.com/intel-iot-devkit/upm/tree/master/examples/python import time import pyupm_biss0001 as upmMotion import pyupm_grove as grove import pyupm_i2clcd as lcd button = grove.GroveButton(8) light = grove.GroveLight(0) motion = upmMotion.BISS0001(3) relay = grove.GroveRelay(2) lcd = lcd.Jhd1313m1(0, 0x3E, 0x62) while True: print 'Button value: ', button.value() print 'Light value: ', light.raw_value() print 'Motion value: ', motion.value() relay.on() lcd.setCursor(0,0) lcd.setColor(255, 0, 0) lcd.write('Hello World') time.sleep(1) relay.off() del button