def do_POST(self): form = cgi.FieldStorage( fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD':'POST', 'CONTENT_TYPE':self.headers['Content-Type'], }) if 'line1' in form: line1 = '' try: line1 = form['line1'].value[0:16] except: pass lcd.lcd_string(line1, lcd.LCD_LINE_1) if 'line2' in form: line2 = '' try: line2 = form['line2'].value[0:16] except: pass lcd.lcd_string(line2, lcd.LCD_LINE_2) self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write('OK')
def initialize(): global pre_state pre_state = '---------' lcd.setup() button.setup() lcd.lcd_string('Initializing ..', 0) setup_serial_port()
def ResetTempRange(): webiopi.debug("Reset All Temp Range Macro...") global tShopHigh global tShopLo global tGpuHigh global tGpuLow global tCpuHigh global tCpuLow fahrenheit = t.getFahrenheit() GPUfahrenheit = float(get_gpu_temp()) CPUfahrenheit = float(get_cpu_temp()) tShopHigh = fahrenheit tShopLow = fahrenheit tGpuHigh = GPUfahrenheit tGpuLow = GPUfahrenheit tCpuHigh = CPUfahrenheit tCpuLow = CPUfahrenheit # LCD Background Cyan GPIO.pwmWrite(RED, 1.0) GPIO.pwmWrite(GREEN, 0.0) GPIO.pwmWrite(BLUE, 0.0) # Display current temperature on LCD display lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Temp Ranges Reset") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("( HTTP Request )")
def setEpoch(self, t): global epoch epoch = t if epoch < time.time(): lcd.lcd_string("TIME IN PAST", lcd.LCD_LINE_1) GPIO.cleanup() raise Exception("Current epoch is greater than time given")
def get_ack(): lcd.lcd_clear() lcd.lcd_string('waiting for ack', 0) data = ser_port.readline() if len(data) > 0 and data == b'Done\n': lcd.lcd_clear() lcd.lcd_string('ack recieved', 0) return
def main(): d = identify.Identify() lcd.lcd_init() if d == -1: lcd.lcd_print("No Face Found") time.sleep(1) return 1 if d == -2: lcd.lcd_print("No Internet Connection") return 1 name = d['name'] gender = d['gender'] age = findAge(d['age']) smile = isSmiling(d['smile']) glasses = d['glasses'] confidence = d['confidence'] emotion = findMaxEmotion(d['emotion']) lcd.lcd_string("Uploading Data...") with open("index.xml", 'r+') as f: line = f.readline() index = int(line) fb = firebase.FirebaseApplication(URL) imageName = str(index)+".jpg" result = fb.put('/',index,{'name':name, 'gender':gender ,'age':age, 'smile':smile, 'glasses':glasses, 'confidence':confidence, 'emotion':emotion}) status = 1 try: status = subprocess.check_call(["./storage.sh",imageName]) except: pass while status!=0: try: status = subprocess.check_call(["./storage.sh",imageName]) except: pass index += 1 with open("index.xml", 'w+') as f: f.write(str(index)) lcd.lcd_string(name) if smile == "Yes": smile = "Smiling" else: smile = "Not Smiling" printString = "Age Range:" + str(age) + " " + str(gender) + " " + str(smile) + " " + str(glasses) + " Emotion:" + str(emotion) lcd.lcd_print(printString,2) lcd.lcd_clear() return 0
def displayOnLcd(line1, line2): clearLcd() # Send some centred test lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string(str("".join(line1)),2) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(str("".join(line2)),2) GPIO.output(lcd.LED_ON, False) return
def mov_print(str): counter = 0 str_len = len(str) while stopper == 1: lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(str[counter:str_len] + str[0:counter], 2) counter += 1 if counter == str_len: counter = 0 time.sleep(0.2)
def mode_select(): print "select number" print "1)new user" print "2)withdraw money" Lprint.lcd_string("press 1)new user", LCD_LINE_1) #syntax for printing on lcd screen Lprint.lcd_string("press 2)payment", LCD_LINE_2) #syntax for printing on lcd screen k = keyboard.keyboard_value() return k
def GetSensorTemp(): webiopi.debug("GetSensorTemp Macro...") # Get current temperature fahrenheit = t.getFahrenheit() setColor(Colors['Purple']) # Display current temperature on LCD display lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Current: %0.1f" % (fahrenheit) + chr(223) + "F") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("( HTTP Request )") return "Current: %0.1f°F\r\nLow: %0.1f°F\r\nHigh: %0.1f°F" % (fahrenheit, tLow, tHigh)
def ResetTempRange(): webiopi.debug("Reset Temp Range Macro...") global tHigh global tLow fahrenheit = t.getFahrenheit() tHigh = fahrenheit tLow = fahrenheit setColor(Colors['Cyan']) # Display current temperature on LCD display lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Temp Range Reset") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("( HTTP Request )")
def on_message(client, userdata, msg): if msg.payload.decode() == "Hello world!": print("H W") else: #print("Yes!") a = msg.payload.decode() print(a) lcd.lcd_init() lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("SMART AGRICULTURE", 2) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(a, 2) if (a == "END"): client.disconnect()
def unauthorized(): global num_unauth print("global num_unauth eh =" + str(num_unauth)) if num_unauth >= 2: error_light() lcd.lcd_init() lcd.lcd_string("Can't Access!",2) print("unauthorized light") num_unauth = 0 else: num_unauth += 1 lcd.lcd_init() lcd.lcd_string("Can't Access!",2) return make_response(jsonify({'Error': 'Unauthorized Access'}), 401)
def main(self): lcd.lcd_init() lcd.lcd_string("###SETTING UP###", LINE_1) lcd.lcd_string("###SETTING UP###", LINE_2) lcd.lcd_string(text, LINE_1) while(True): time.sleep(.05); # this is to give the pi a cool down temp_time = epoch - time.time() """ Calculating the number of days until the specified time """ days = int(math.floor((epoch - time.time()) / 86400)) temp_time -= days * 86400 # updating the temp time """ Calculating the number of hours until the specified time """ hours = int(math.floor(temp_time / 3600)) temp_time -= hours * 3600 # updating temp_time """ Calculating the number of minutes until the specified time """ minutes = int(math.floor(temp_time / 60)) seconds = int(temp_time - minutes * 60) lcd.lcd_string(" %02d:%02d:%02d:%02d" % (days,hours,minutes,seconds), LINE_2)
def delete_fav(): global num_unauth # Example: curl -u pikachu:electric -X DELETE 'http://localhost:5000/favs/delete?Name=What&Poketype=Whatsapp3' print("delete called") name_del = request.args.get('Name', None) type_del = request.args.get('Poketype', None) if name_del == None: error_light() num_unauth = 0 lcd.lcd_init() lcd.lcd_string("Bad Name passed",2) return jsonify({'Error': 'Name not passed for deletion'}) elif type_del == None: error_light() num_unauth = 0 lcd.lcd_init() lcd.lcd_string("Bad Type passed",2) return jsonify({'Error': 'Type not passed for deletion'}) elif db.session.query(Favs_table).filter_by(Name = name_del, Poketype = type_del).first(): processing_light() db.session.query(Favs_table).filter_by(Name = name_del, Poketype = type_del).delete() db.session.commit() success_light() lcd.lcd_init() lcd.lcd_string("Success!",2) num_unauth = 0 return jsonify({'Entry': 'Deleted'}) else: error_light() num_unauth = 0 lcd.lcd_init() lcd.lcd_string("Can't find entry",2) return jsonify({'Entry': 'Not Found'})
def yaz(satır1, satır2, a=2): lcd.lcd_init() lcd.GPIO.output(lcd.LED_ON, True) time.sleep(1) lcd.GPIO.output(lcd.LED_ON, False) time.sleep(1) lcd.GPIO.output(lcd.LED_ON, True) time.sleep(1) # set cursor to line 1 lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) # display text centered on line 1 lcd.lcd_string(satır1, a) # set cursor to line 2 lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) # display additional text on line 2 lcd.lcd_string(satır2, a)
def main(): while (1): k = mode_select() #selecting mode for :1)new user 2)payment if (k == '1'): #for enrollment of new user finger print scan_finger() #function used to store the finger print of the user if (k == '2'): #mode selection for payment y = verify() #store the id of the user in the variable if (k == '#'): ''' send req. to server to update the database press # ''' Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string("database updated..", LCD_LINE_1) #syntax for printing on lcd screen time.sleep(2)
def GetSensorTemp(): webiopi.debug("GetSensorTemp Macro...") # Get current temperature fahrenheit = t.getFahrenheit() GPUfahrenheit = round(get_gpu_temp()) CPUfahrenheit = round(get_cpu_temp()) # LCD Background Purple GPIO.pwmWrite(RED, 0.0) GPIO.pwmWrite(GREEN, 1.0) GPIO.pwmWrite(BLUE, 0.0) # Display current temperature on LCD display lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("W: %0.1f" % (fahrenheit) + chr(223) + "F" + "G: %0.1f" % (GPUfahrenheit) + chr(223) + "F" + "W: %0.1f" % (CPUfahrenheit) + chr(223) + "F") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("( HTTP Request )") return "Shop: %0.1f°F\r\nLow: %0.1f°F\r\nHigh: %0.1f°F\r\n' *************** '\r\nGraphics Processor: %0.1f°F\r\nLow: %0.1f°F\r\nHigh: %0.1f°F\r\n' *************** '\r\nCentral Processor: %0.1f°F\r\nLow: %0.1f°F\r\nHigh: %0.1f°F" % (fahrenheit, tShopLow, tShopHigh, GPUfahrenheit, tGpuLow, tGpuHigh, CPUfahrenheit, tCpuLow, tCpuHigh)
def mensajes_lcd(mensaje1, mensaje2, mensaje3, mensaje4): lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string(mensaje1, 2) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(mensaje2, 2) time.sleep(10) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string(mensaje3, 2) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(mensaje4, 2)
def main(): signal.signal(signal.SIGINT, allLightsOff) ppmQueue = deque(maxlen=SLIDING_WINDOWS_SIZE) while True: try: ppm = getPollutionData() ppmQueue.append(ppm) mov_average_ppm = int(sum(ppmQueue) / SLIDING_WINDOWS_SIZE) ##### alter Teil von Hannes # temperature_c = dhtDevice.temperature # humidity = dhtDevice.humidity # msg1 = "ppm: " + str(mov_average_ppm) # msg2 = "{:.1f}C {}% ".format(temperature_c, humidity) # print(msg1 + ", " + msg2) # lcd.lcd_string(msg1, lcd.LCD_LINE_1) # lcd.lcd_string(msg2, lcd.LCD_LINE_2) ##### Ende alter Teil ## neu von Michi msg1 = "Aktuell: " + str(ppm) msg2 = "CO2 Wert: " + str(mov_average_ppm) temperatur = str(Adafruit_DHT.read_retry(11, 4)) now = datetime.now() uhrzeit = now.strftime("%H:%M") msg3 = temperatur[7:-1] +"C " + uhrzeit + " Uhr" print(msg1 + ", " + msg2 + ", " + msg3) lcd.lcd_string(msg2, 1) lcd.lcd_string(msg3, 0xC0) ### Ende neuer Teil if mov_average_ppm in range(0, 1000): green() elif mov_average_ppm in range(1001, 2000): yellow() else: red() time.sleep(1) except Exception as error: print(error)
def subscribe_topic(): # Initialise display lcd.lcd_init() lcd.lcd_string("IP " + IPAddr, lcd.LCD_LINE_1) lcd.lcd_string("Alarm UNKNOWN", lcd.LCD_LINE_2) lcd.lcd_string("Garage Door UNKNOWN", lcd.LCD_LINE_3) lcd.lcd_string("Unsure where you are", lcd.LCD_LINE_4) client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message client.username_pw_set(username=priv.username, password=priv.password) client.connect(priv.MQTT_HOST, 1883) client.loop_forever()
def get_poketype(): # Example: curl -i 'http://localhost:5000/poketype?Poketype=shadow' poketype_arg = request.args.get('Poketype', None) pokeapi_entry = "" if poketype_arg == None: error_light() print("GET error light 1") lcd.lcd_init() lcd.lcd_string("Invalid Find",2) pokeapi_entry = jsonify({'Pokeapi_Type': 'Not Found'}) elif poketype_arg not in ['normal', 'fighting', 'poison', 'flying', 'ground', 'bug', 'ghost', 'steel', 'fire', 'rock', 'water', 'grass', 'electric', 'psychic', 'ice', 'dragon', 'dark', 'fairy', 'unknown', 'shadow']: error_light() print("GET error light 2") lcd.lcd_init() lcd.lcd_string("Invalid Find",128) pokeapi_entry = jsonify({'Pokeapi_Type': 'Not Found'}) else: processing_light() pokeapi_url = "https://pokeapi.co/api/v2/type/" + poketype_arg + "/" print(pokeapi_url) pokeapi_entry = jsonify(requests.get(pokeapi_url).json()) lcd.lcd_init() lcd.lcd_string("Success!",2) success_light() return pokeapi_entry
def get_table(): # Example: curl -i 'http://localhost:5000/favs?Poketype=shadow' fav_arg = request.args.get('Poketype', None) favsArr = [] if fav_arg == None: error_light() print("GET /favs error light 1") lcd.lcd_init() lcd.lcd_string("Invalid Type",2) return jsonify({'Error': 'Invalid Type Passed in favs GET'}) elif fav_arg not in ['normal', 'fighting', 'poison', 'flying', 'ground', 'bug', 'ghost', 'steel', 'fire', 'rock', 'water', 'grass', 'electric', 'psychic', 'ice', 'dragon', 'dark', 'fairy', 'unknown', 'shadow']: error_light() print("GET /favs error light 2") lcd.lcd_init() lcd.lcd_string("Invalid Type",2) return jsonify({'Error': 'Invalid Type Passed in favs GET'}) else: processing_light() favs = db.session.query(Favs_table).filter_by(Poketype = fav_arg) for fav in favs: favsArr.append(fav.toDict()) success_light() lcd.lcd_init() lcd.lcd_string("Success!",2) print(jsonify(favsArr)) return jsonify(favsArr)
def main(): # signal.signal(signal.SIGINT, allLightsOff) ppmQueue = deque(maxlen=SLIDING_WINDOWS_SIZE) while True: try: ppm = getPollutionData() ppmQueue.append(ppm) mov_average_ppm = int(sum(ppmQueue) / SLIDING_WINDOWS_SIZE) msg1 = "Aktuell: " + str(ppm) msg2 = "CO2 Wert: " + str(mov_average_ppm) humidity, temperature = Adafruit_DHT.read_retry(11, 4) humidity = round(humidity, 2) temperature = round(temperature, 2) uhrzeit = datetime.now().strftime("%H:%M") msg3 = str(temperature) + "C " + uhrzeit + " Uhr" print(msg1 + ", " + msg2 + ", " + msg3) lcd.lcd_string(msg2, lcd.LCD_LINE_1) lcd.lcd_string(msg3, lcd.LCD_LINE_2) if mov_average_ppm in range(0, 1001): green() elif mov_average_ppm in range(1001, 2001): yellow() elif mov_average_ppm in range(2001, 3000): red() else: led_r.blink() data = {"co2": ppm, "temp": temperature, "humidity": humidity} log_to_influxdb(data) time.sleep(1) except Exception as error: print(error)
def choose_start(): lcd.lcd_clear() lcd.lcd_string('press the button', 1) for i in range(7): lcd.lcd_string('to starts %s' % str(i), 2) time.sleep(0.5) if button.check(): #change with button input turn = 1 lcd.lcd_clear() lcd.lcd_string('You start (X)', 0) return time.sleep(0.5) lcd.lcd_clear() lcd.lcd_string('I start (O)', 0)
def classify_nut(self): if self.stop_motor: self.stop() self.clear_buffer() s1, img1 = self.camera1.read() s2, img2 = self.camera2.read() img = np.concatenate((img1, img2), axis=1) img = cv2.resize(img, (4 * self.size, 2 * self.size)) pred = self.model.predict_classes(img.reshape([-1, 300, 600, 3]), batch_size=1) if pred == 1: print("BAD :(") self.bad() else: print("GOOD :)") size1 = size_classification.findRadius(img1, self.empty1_org) size2 = size_classification.findRadius(img2, self.empty2_org) print("pixeles camara 1:" + str(size1)) print("pixeles camara 2:" + str(size2)) diametro = round(size_classification.sizes2rad(size1, size2, 120), 2) print("Diametro: " + str(diametro)) lcd.lcd_string("Calibre: " + str(diametro), 0xD4) self.good() self.open() cv2.imwrite( 'data/nuez' + str(self.ind_camera1) + '_' + self.zero_pad(self.counter, 6) + '.png', img1) cv2.imwrite( 'data/nuez' + str(self.ind_camera2) + '_' + self.zero_pad(self.counter, 6) + '.png', img2) time.sleep(self.open_sleep_time) self.close() self.clear_buffer() if self.stop_motor: self.go() self.counter += 1 lcd.lcd_string("Nueces IZQ: " + str(self.counter), self.lcd_line) print('END thread')
def update_display(self): if self.show_text: message = self.show_text elif self.button_pressed: # don't change the display while button is pressed - it's confusing return elif self.mode == MODE_ALWAYS_OFF: if self.showing_line == 1: message = 'Off' elif self.showing_line == 2: message = 'Please empty' else: message = 'Water buckets' elif self.mode == MODE_VENTING: if self.venting: message = 'Venting' else: if self.showing_line == 1: message = 'Standby' else: message = 'Temp now %.1f%sC' % (current_temperature(), CUSTOM_CHAR_DEGREE) else: if self.showing_line == 1: if not self.large_tank_bottom_float: message = 'No water in tank' else: message = 'Misting active' else: message = 'Temp now %.1f%sC' % (current_temperature(), CUSTOM_CHAR_DEGREE) if message != self.current_text: lcd_string(message, LCD_LINE_1) print(message) self.current_text = message
def lcd_upd(): global stid, stlist while (1): try: nm = stlist[stid][1] if(nm == ""): nm = pl.cur_media.get_meta(vlc.Meta.Title) lcd.lcd_string(nm, lcd.LCD_LINE_1) except Exception: lcd.lcd_string("--- Loading ---", lcd.LCD_LINE_1) tmp = "%d %b %H:%M:%S" if(int((time.clock()/3))%2): tmp = "%d %b %a %M:%S" lcd.lcd_string(str(time.strftime(tmp, time.localtime())), lcd.LCD_LINE_2)
def setup_serial_port(): global ser_port for i in range(5): time.sleep(1) lcd.lcd_clear() lcd.lcd_string('trying port %s' % str(i), 0) time.sleep(2) try: ser_port = serial.Serial('/dev/ttyACM%s' % str(i), 9600) lcd.lcd_clear() lcd.lcd_string('port %s up' % str(i), 0) break except: lcd.lcd_clear() lcd.lcd_string('port %s empty' % str(i), 0)
def add_fav(): # Example: curl -u pikachu:electric -i -H "Content-Type: application/json" -X POST -d '{"Name":"What", "Poketype":"Whatsapp5"}' http://localhost:5000/favs global num_unauth if not request.json or not 'Name' in request.json or not 'Poketype' in request.json: error_light() print("POST error light 1") print("either Name or Poketype not in request light") lcd.lcd_init() lcd.lcd_string("Input Invalid",2) num_unauth = 0 abort(400) entry = "" if db.session.query(Favs_table).filter_by(Name = request.json['Name'], Poketype = request.json['Poketype']).first(): error_light() print("POST error light 2") print("entry already exists light") new_fav_json = {'Error': 'Entry Already Exists'} lcd.lcd_init() lcd.lcd_string("Entry Exists",2) entry = jsonify(new_fav_json) num_unauth = 0 else: processing_light() new_fav_json = { 'Name': request.json['Name'], 'Poketype': request.json['Poketype'] } new_fav = Favs_table(0, request.json['Name'], request.json['Poketype']) print(new_fav) db.session.add(new_fav) db.session.commit() entry = jsonify({'New Entry': new_fav_json}) print("global num_unauth suc =" + str(num_unauth)) success_light() lcd.lcd_init() lcd.lcd_string("Success!",2) num_unauth = 0 return entry, 201
for frame1 in camera.capture_continuous(rawCapture, format="bgr",use_video_port=True): t1 = cv2.getTickCount() # Acquire frame and expand frame dimensions to have shape: [1, None, None, 3] # i.e. a single-column array, where each item in the column has the pixel RGB value frame = frame1.array frame.setflags(write=1) frame_expanded = np.expand_dims(frame, axis=0) # Perform the actual detection by running the model with the image as input (boxes, scores, classes, num) = sess.run( [detection_boxes, detection_scores, detection_classes, num_detections], feed_dict={image_tensor: frame_expanded}) lcd.lcd_init() lcd.lcd_string(max(scores) + ' ' + max(classes), 1) lcd.GPIO.cleanup() #import lcd, lcd.lcd_init() # lcd.lcd_string(scores + ' ' + classes, 1) #try max(scores) and max(classes) #send scores to lcd plate #lcd.GPIO.cleanup() when done # Draw the results of the detection (aka 'visulaize the results') vis_util.visualize_boxes_and_labels_on_image_array( frame, np.squeeze(boxes), np.squeeze(classes).astype(np.int32), np.squeeze(scores), category_index, use_normalized_coordinates=True,
import sys sys.path.append('/home/pi/Projects/lcd') import lcd import time import RPi.GPIO as GPIO BD = 0.05 #The delay for the text to work LED_ON = 15 #GPIO the LCD Backlight is on D = .1 #Delay for flahsing the screen k = 0 lcd.lcd_init() GPIO.setup(LED_ON,GPIO.OUT) time.sleep(BD) lcd.lcd_string("Flashing....",1) while k < 10: GPIO.output(LED_ON, True) time.sleep(D) GPIO.output(LED_ON, False) time.sleep(D) k = k + 1
def on_message(client, userdata, msg): print("Message received-> " + msg.topic + " " + str(msg.payload)) log.info("Message received-> " + msg.topic + " " + str(msg.payload)) if 'door-up' in msg.topic: if 'off' in msg.payload: GPIO.output(priv.pinup, 1) elif 'on' in msg.payload: GPIO.output(priv.pinup, 0) elif 'door-down' in msg.topic: if 'off' in msg.payload: GPIO.output(priv.pindown, 1) elif 'on' in msg.payload: GPIO.output(priv.pindown, 0) elif 'alarm' in msg.topic: if 'off' in msg.payload: lcd.lcd_string("Alarm DISARMED", lcd.LCD_LINE_2) elif 'on' in msg.payload: lcd.lcd_string("Alarm ARMED", lcd.LCD_LINE_2) elif 'garagesensor' in msg.topic: if 'off' in msg.payload: lcd.lcd_string("Garage Door OPEN", lcd.LCD_LINE_3) elif 'on' in msg.payload: lcd.lcd_string("Garage Door CLOSED", lcd.LCD_LINE_3) elif 'home' in msg.topic: if 'off' in msg.payload: lcd.lcd_string("Everyone is AWAY", lcd.LCD_LINE_4) elif 'on' in msg.payload: lcd.lcd_string("Someone is HOME", lcd.LCD_LINE_4)
import sys sys.path.append('/home/pi/Projects/lcd') import lcd import time import RPi.GPIO as GPIO DELAY = 0.00005 LED_ON = 15 lcd.lcd_init() GPIO.setwarnings(False) GPIO.setup(LED_ON,GPIO.OUT) time.sleep(0.00005) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Raspberry Pi", 1) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) time.sleep(.005) lcd.lcd_string("Model B+", 1) lcd.lcd_byte(lcd.LCD_LINE_3, lcd.LCD_CMD) time.sleep(.005) lcd.lcd_string("On a",1) lcd.lcd_byte(lcd.LCD_LINE_4, lcd.LCD_CMD) lcd.lcd_string("4x16 DOWG",1) #lcd.GPIO.cleanup()
#!/usr/bin/env python import sys from lcd import lcd_string, tn pipe_contents = sys.stdin.read() pipe_contents = pipe_contents.replace('\n', ' ') lcd_string(pipe_contents, tn)
#!/usr/bin/env python from lcd import lcd_string, tn while(True): s = raw_input(">") lcd_string(s, tn, 0)
def loop(): print ("GPIO 21 = ", GPIO.digitalRead(26) ) print ("GPIO 24 = ", GPIO.digitalRead(19) ) print ("GPIO 21 = ", GPIO.digitalRead(13) ) print ("GPIO 24 = ", GPIO.digitalRead(6) ) # Run every 3 seconds try: global tShopHigh global tShopLow global tGpuHigh global tGpuLow global tCpuHigh global tCpuLow # Get current Shop temperature fahrenheit = t.getFahrenheit() webiopi.debug("Shop: %0.1f°F" % fahrenheit) # Get GPU temperature GPUfahrenheit = float(get_gpu_temp()) webiopi.debug("GPU Temp: %0.1f°F" % GPUfahrenheit) # Get CPU temperature CPUfahrenheit = float(get_cpu_temp()) webiopi.debug("CPU Temp: %0.1f°F" % CPUfahrenheit) # Set high & low for GPU if GPUfahrenheit > tGpuHigh: tGpuHigh = GPUfahrenheit elif GPUfahrenheit < tGpuLow: tGpuLow = GPUfahrenheit if CPUfahrenheit > tCpuHigh: tCpuHigh = CPUfahrenheit elif CPUfahrenheit < tCpuLow: tCpuLow = CPUfahrenheit if fahrenheit > tShopHigh: tShopHigh = fahrenheit elif fahrenheit < tShopLow: tShopLow = fahrenheit webiopi.debug("GPU Low: %0.1f°F" % tGpuLow) webiopi.debug("GPU High: %0.1f°F" % tGpuHigh) webiopi.debug("CPU Low: %0.1f°F" % tCpuLow) webiopi.debug("CPU High: %0.1f°F" % tCpuHigh) webiopi.debug("Shop Low: %0.1f°F" % tShopLow) webiopi.debug("Shop High: %0.1f°F" % tShopHigh) # Temperature thresholds webiopi.debug("Shop Cold Threshold: %0.1f°F" % COLD_shop) webiopi.debug("Shop Hot Threshold: %0.1f°F" % HOT_shop) webiopi.debug("GPU Cold Threshold: %0.1f°F" % COLD_gpu) webiopi.debug("GPU Hot Threshold: %0.1f°F" % HOT_gpu) webiopi.debug("CPU Cold Threshold: %0.1f°F" % COLD_cpu) webiopi.debug("CPU Hot Threshold: %0.1f°F" % HOT_cpu) readouts = ['shopTemp', 'shopRange', 'GPUtemp', 'GPUrange', 'CPUtemp', 'CPUrange'] for output in readouts: if GPIO.digitalRead(SWITCH) == GPIO.LOW: # Reset switch pressed tShopHigh = fahrenheit tShopLow = fahrenheit tGpuHigh = GPUfahrenheit tGpuLow = GPUfahrenheit tCpuHigh = CPUfahrenheit tCpuLow = CPUfahrenheit # LCD background white GPIO.pwmWrite(RED, 0.0) GPIO.pwmWrite(GREEN, 0.6) GPIO.pwmWrite(BLUE, 0.8) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("Temp Ranges Reset") elif output == 'shopTemp': # LCD background for Shop state if fahrenheit >= HOT_shop: red() elif fahrenheit <= COLD_shop: blue() else: green() # Display Shop temp lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Shop Temperature") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(" %0.1f" % (fahrenheit) + chr(223) + "F") elif output == 'shopRange': # LCD background for Shop range state if fahrenheit >= HOT_shop: red() elif fahrenheit <= COLD_shop: blue() else: white() # Display Shop range lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Shop Low: %0.1f" % (tShopLow) + chr(223) + "F") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(" High: %0.1f" % (tShopHigh) + chr(223) + "F") elif output == 'GPUtemp': # LCD background for GPU state if GPUfahrenheit >= HOT_gpu: red() elif GPUfahrenheit <= COLD_gpu: blue() else: green() # Display GPU temp lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("GPU Temperature") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(" %0.1f" % (GPUfahrenheit) + chr(223) + "F") elif output == 'GPUrange': # LCD background for Shop range state if GPUfahrenheit >= HOT_gpu: red() elif GPUfahrenheit <= COLD_gpu: blue() else: white() # Display Shop range lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("GPU Low: %0.1f" % (tGpuLow) + chr(223) + "F") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(" High: %0.1f" % (tGpuHigh) + chr(223) + "F") elif output == 'CPUtemp': # LCD background for Shop state if CPUfahrenheit >= HOT_cpu: red() elif CPUfahrenheit <= COLD_cpu: blue() else: green() # Display CPU temp lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("CPU Temperature") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(" %0.1f" % (CPUfahrenheit) + chr(223) + "F") else: if output == 'CPUrange': # LCD background for CPU range state if CPUfahrenheit >= HOT_cpu: red() elif CPUfahrenheit <= COLD_cpu: blue() else: white() # Display CPU range lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("CPU Low: %0.1f" % (tCpuLow) + chr(223) + "F") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(" High: %0.1f" % (tCpuHigh) + chr(223) + "F") webiopi.sleep(1) except: webiopi.debug("error: " + str(sys.exc_info()[0]))
import sys sys.path.append('/home/pi/fire') import lcd lcd.lcd_init() lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Raspberry Pi", 2) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("Model B+", 2) lcd.GPIO.cleanup()
def loop(): # Run every 5 seconds try: # Get current temperature fahrenheit = t.getFahrenheit() webiopi.debug("Current: %0.1f°F" % fahrenheit) # Set high & low global tHigh global tLow if fahrenheit > tHigh: tHigh = fahrenheit if fahrenheit < tLow: tLow = fahrenheit webiopi.debug("Low: %0.1f°F" % tLow) webiopi.debug("High: %0.1f°F" % tHigh) # Temperature thresholds webiopi.debug("Cold Threshold: %0.1f°F" % COLD) webiopi.debug("Hot Threshold: %0.1f°F" % HOT) # Toggle State (Current or Range) global displayCurrent displayCurrent = not displayCurrent # Check for reset switch press if GPIO.digitalRead(SWITCH) == GPIO.LOW: tHigh = fahrenheit tLow = fahrenheit setColor(Colors['White']) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Current: %0.1f" % (fahrenheit) + chr(223) + "F") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("Temp Range Reset") elif displayCurrent: # Current temp state (text color based on thresholds) if fahrenheit >= HOT: setColor(Colors['Red']) elif fahrenheit <= COLD: setColor(Colors['Blue']) else: setColor(Colors['Green']) # Display current temp lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Current: %0.1f" % (fahrenheit) + chr(223) + "F") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(" ") else: # Temp range state (text color based on thresholds) if fahrenheit >= HOT: setColor(Colors['Orange']) elif fahrenheit <= COLD: setColor(Colors['Violet']) else: setColor(Colors['Aquamarine']) # Display temp range lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Low: %0.1f" % (tLow) + chr(223) + "F") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("High: %0.1f" % (tHigh) + chr(223) + "F") except: webiopi.debug("error: " + str(sys.exc_info()[0])) finally: webiopi.sleep(5)
import os import time os.chdir('/home/pi') import lcd lcd.lcd_init() try: while(1>0): if(lcd.GPIO.input(lcd.pir)==1): lcd.GPIO.output(lcd.led,lcd.GPIO.LOW) lcd.GPIO.output(16,lcd.GPIO.HIGH) lcd.lcd_string('Detection',lcd.LCD_LINE_1) lcd.lcd_string('Sector 1',lcd.LCD_LINE_2) time.sleep(1) lcd.GPIO.output(16,lcd.GPIO.LOW) else: lcd.lcd_string(time.strftime('It is %d.%m.%Y'),lcd.LCD_LINE_1) lcd.lcd_string(time.strftime('%H:%M:%S'),lcd.LCD_LINE_2) lcd.GPIO.output(lcd.led,lcd.GPIO.LOW) time.sleep(1) lcd.GPIO.output(lcd.led,lcd.GPIO.HIGH) except KeyboardInterrupt: lcd.lcd_string('Program stop',lcd.LCD_LINE_1) lcd.lcd_string('',lcd.LCD_LINE_2) lcd.lcd_string('3',lcd.LCD_LINE_2) time.sleep(1) lcd.lcd_string('2',lcd.LCD_LINE_2) time.sleep(1) lcd.lcd_string('1',lcd.LCD_LINE_2) time.sleep(1) lcd.lcd_init() lcd.GPIO.cleanup()
import sys sys.path.append('`/.python/lcd') import lcd lcd.lcd_init() lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Raspberry Pi", 2) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("Model B+", 2) lcd.GPIO.cleanup()
def verify(): f.start_led() #call the function to start the led of finger-print sensor print 'press finger' Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string("press finger..", LCD_LINE_1) #syntax for printing on lcd screen while (f.ispressfinger() == 2): #varify if finger is pressed or not time.sleep(0.1) if (f.capture_image() == 1): #varify if image is captured successfully detected_id = f.identify() #to store the id of the user if (detected_id != 785): #syntax if proper id is obtained detected_id = int(detected_id, 16) print 'remove finger' Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string("enter ammount ", LCD_LINE_1) #syntax for printing on lcd screen val = '' val1 = 'ammount' ammount = 0 while (val != 'D'): val = keyboard.keyboard_value( ) #function for reading the switch press by the user in keypad time.sleep(0.05) val1 = val1 + val #storing the amount in string Lprint.lcd_string( "Press D ", LCD_LINE_2) #syntax for printing on lcd screen if (val == 'c'): #varify cancel command val = '' val1 = 'ammount' ammount = 0 Lprint.lcd_string( "enter again", LCD_LINE_1) #syntax for printing on lcd screen time.sleep(1.5) elif (val != 'D'): #press d for exiting temp = int(val) ammount = ammount * 10 + temp #store the amount entered by the user in string Lprint.lcd_string(val1, LCD_LINE_1) detectedid = f.identify( ) #store the id of detected user finger print in the variable if (detectedid != 785): print 'remove finger' Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string("enter ammount ", LCD_LINE_1) #syntax for printing on lcd screen val = keyboard.keyboard_value() i = 0 while (val != 'D'): ammount.insert(i, val) i = i + 1 Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string( "press D ", LCD_LINE_2) #syntax for printing on lcd screen val = keyboard.keyboard_value() val = '' i = 0 val_string = 'ammount:' Lprint.lcd_string(" then press D ", LCD_LINE_2) #syntax for printing on lcd screen while (val != 'D'): ammount.insert(i, val) i = i + 1 val = keyboard.keyboard_value() val_string = val_string + val Lprint.lcd_string(val_string, LCD_LINE_1) #print the string on lcd Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string("sending data... ", LCD_LINE_1) #syntax for printing on lcd screen ''' detected id and ammount send to server 1) success remaining balance display and message 2) insufficinet balance and message ''' url = "http://malgadi.co.in/touch-n-pay/do_payment.php?fid=" + str( detected_id) + "&cost=" + str(ammount) print 'response from website' content = urllib2.urlopen(url).read() print content Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string("enter ammount ", LCD_LINE_1) #syntax for printing on lcd screen if content == '1': Lprint.lcd_string( "payment successfull", LCD_LINE_1) #syntax for printing on lcd screen time.sleep(1.5) if content == '2': Lprint.lcd_string( "insufficent", LCD_LINE_1) #syntax for printing on lcd screen Lprint.lcd_string( "balance", LCD_LINE_2) #syntax for printing on lcd screen time.sleep(1.5) else: Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string("user not found", LCD_LINE_1) #syntax for printing on lcd screen time.sleep(2) else: Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string("sorry....", LCD_LINE_1) #syntax for printing on lcd screen Lprint.lcd_string("try again", LCD_LINE_2) #syntax for printing on lcd screen time.sleep(2) f.stop_led()
import sys sys.path.append('/home/pi/Projects/lcd') import lcd import time import RPi.GPIO as GPIO DELAY = 0.00005 LED_ON = 15 ##### INIT BLOCK START ##### lcd.lcd_init() GPIO.setwarnings(False) GPIO.setup(LED_ON,GPIO.OUT) time.sleep(DELAY) ##### INIT BLOCK END ##### lcd.lcd_string("this is text", 1)
#!/usr/bin/env python # -*- coding: utf-8 -*- import lcd as LCD import time LCD.main() LCD.lcd_init() time.sleep(1) LCD.lcd_string("line 1",LCD.LCD_LINE_1) LCD.lcd_string("line 2",LCD.LCD_LINE_2) time.sleep(2) LCD.lcd_string("Animation test",LCD.LCD_LINE_2) LCD.lcd_string(" T",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1) LCD.lcd_string(" T ",LCD.LCD_LINE_1)
# Hook the SIGINT signal.signal(signal.SIGINT, end_read) # Create an object of the class MFRC522 MIFAREReader = MFRC522.MFRC522() # Welcome message # This loop keeps checking for RFID cards. If one is near it will get the UID and authenticate while continue_reading: #Using lcd to display on line 1 lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Welcome to LACS",1) #Setting default Trigger for Relay GPIO.output(29,True) # Scan for cards (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL) # If a card is found if status == MIFAREReader.MI_OK: print "Card detected" #Using lcd to display on line 1 lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Card detected",1) #log into lcd # Get the UID of the card time.sleep(0.6) (status,uid) = MIFAREReader.MFRC522_Anticoll() print uid
def loop(): try: #LCD background white GPIO.pwmWrite(RED, 0.0) GPIO.pwmWrite(GREEN, 0.6) GPIO.pwmWrite(BLUE, 0.8) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("openbuilds.com") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("Build Anything") time.sleep(2) GPIO.pwmWrite(RED, 1.0) GPIO.pwmWrite(GREEN, 1.0) GPIO.pwmWrite(BLUE, 0.0) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Dream It") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("") time.sleep(1) GPIO.pwmWrite(RED, 0.0) GPIO.pwmWrite(GREEN, 1.0) GPIO.pwmWrite(BLUE, 1.0) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Build It") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("") time.sleep(1) GPIO.pwmWrite(RED, 1.0) GPIO.pwmWrite(GREEN, 0.0) GPIO.pwmWrite(BLUE, 1.0) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Share It") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("") time.sleep(2) GPIO.pwmWrite(RED, 1.0) GPIO.pwmWrite(GREEN, 1.0) GPIO.pwmWrite(BLUE, 1.0) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("") lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("") finally: webiopi.sleep(5)
#!/usr/bin/env python """Just print temperature""" import glob from time import sleep from lcd import lcd_string, tn base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave' try: while True: lines = open(device_file, 'r').readlines() string = lines[1][-6:].replace('=', '') t = int(string) temp_c = t / 1000.0 temp_f = temp_c * 9.0 / 5.0 + 32.0 print temp_f lcd_string(str(temp_f), tn, 1) lcd_string(" " + str(temp_f), tn, 1) # sleep(1) except KeyboardInterrupt: pass
def scan_finger(): f.start() #function to start the sensor f.start_led() #function to start the led current_id = int(f.current_count(), 16) f.start_enroll(f.current_count( )) #function for starting enrollment for storing the finger-print of user Lprint.lcd_byte(0x01, LCD_CMD) #clear lcd Lprint.lcd_string("put your finger", LCD_LINE_1) #syntax for printing on lcd screen print 'press finger 1' while (f.ispressfinger() == 2): #check if finger is pressed or not time.sleep(0.1) if (f.capture_image() == 1): #capture image if (f.enroll1() == 1 ): #check if successfull enrollment of user has done or not print 'remove finger 1' Lprint.lcd_string("remove your finger", LCD_LINE_1) #syntax for printing on lcd screen while (f.ispressfinger() == 1): #check if finger is pressed or not time.sleep(0.1) print 'press finger 2' Lprint.lcd_string("put your finger again", LCD_LINE_1) #syntax for printing on lcd screen while (f.ispressfinger() == 2): #check if finger is pressed or not time.sleep(0.1) if (f.capture_image() == 1): #capture image if ( f.enroll2() == 1 ): #check if successfull enrollment of user has done or not print 'remove finger 2' Lprint.lcd_string( "remove your finger", LCD_LINE_1) #syntax for printing on lcd screen while (f.ispressfinger() == 1 ): #check if finger is pressed or not time.sleep(0.1) print 'press finger 3' Lprint.lcd_string( "put your finger again", LCD_LINE_1) #syntax for printing on lcd screen while (f.ispressfinger() == 2 ): #check if finger is pressed or not time.sleep(0.1) if (f.capture_image() == 1): #capture image if ( f.enroll3() == 1 ): #check if successfull enrollment of user has done or not print 'remove finger 3' Lprint.lcd_string( "successfull scanned:)", LCD_LINE_1) #syntax for printing on lcd screen time.sleep(1) Lprint.lcd_string( "enter your mobile no", LCD_LINE_1) #syntax for printing on lcd screen val1 = '' val = '' number = 0 while (val != 'D'): Lprint.lcd_string( "then Press D ", LCD_LINE_2 ) #syntax for printing on lcd screen val = keyboard.keyboard_value( ) #calling the function to read the key pressed by the user on keypad time.sleep(0.05) val1 = val1 + val if (val == 'C'): #cancel command val1 = '' val = '' number = 0 Lprint.lcd_string( "enter again", LCD_LINE_1 ) #syntax for printing on lcd screen time.sleep(1.5) elif (val != 'D'): #varify end of mobile numer temp = int(val) number = number * 10 + temp #store the number in variable Lprint.lcd_string(val1, LCD_LINE_1) Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string( "thank you..", LCD_LINE_1) #syntax for printing on lcd screen time.sleep(1) Lprint.lcd_byte(0x01, LCD_CMD) Lprint.lcd_string( "check sms in", LCD_LINE_1) #syntax for printing on lcd screen Lprint.lcd_string( "your mobile", LCD_LINE_2) #syntax for printing on lcd screen time.sleep(2) ''' send req. to server.... send Current_id and number ''' url = "http://malgadi.co.in/touch-n-pay/register_new_user.php?fid=" + str( current_id) + "&mobileno=" + str(number) content = urllib2.urlopen( url).read() #syntax to update the web server if (content == '1'): Lprint.lcd_string( "registered successfully", LCD_LINE_1 ) #syntax for printing on lcd screen time.sleep(2) '''if internet is not working then delete id if not upload on portal''' while (f.ispressfinger() == 1 ): #syntax if finger id pressed or not time.sleep(0.1) for i in range( 0, 10): # to store 10 digit mobile number val = keyboard.keyboard_value() val1 = '' for i in range(0, 10): val = keyboard.keyboard_value() val1 = val1 + val #to store number in string Lprint.lcd_string(val1, LCD_LINE_2) num.insert(i, val) print num[i] Lprint.lcd_string( "check message in", LCD_LINE_1) #syntax for printing on lcd screen Lprint.lcd_string( "your phone", LCD_LINE_2) #syntax for printing on lcd screen time.sleep(2) userid = f.current_count( ) # userid is in 'hex' format, covert it in decimal and minus 1 print 'user id is:' print userid ''' send req. to server.... send userid and num array ''' while (f.ispressfinger() == 1): time.sleep(0.1) else: Lprint.lcd_string( "enroll 3 fail", LCD_LINE_1 ) #syntax for printing error message on lcd screen Lprint.lcd_string( "please try again", LCD_LINE_2) #syntax for printing on lcd screen time.sleep(2) else: Lprint.lcd_string( "3rd capture fail", LCD_LINE_1 ) #syntax for printing error message on lcd screen Lprint.lcd_string( "please try again", LCD_LINE_2) #syntax for printing on lcd screen time.sleep(2) else: Lprint.lcd_string( "enroll 2 fail", LCD_LINE_1 ) #syntax for printing error message on lcd screen Lprint.lcd_string( "please try again", LCD_LINE_2) #syntax for printing on lcd screen time.sleep(2) else: Lprint.lcd_string( "2nd capture fail", LCD_LINE_1 ) #syntax for printing error message on lcd screen Lprint.lcd_string( "please try again", LCD_LINE_2 ) #syntax for printing error message on lcd screen time.sleep(2) else: Lprint.lcd_string( "enroll 1 fail", LCD_LINE_1) #syntax for printing error message on lcd screen Lprint.lcd_string( "please try again", LCD_LINE_2) #syntax for printing error message on lcd screen time.sleep(2) else: Lprint.lcd_string( "1st capture fail", LCD_LINE_1) #syntax for printing error message on lcd screen Lprint.lcd_string( "please try again", LCD_LINE_2) #syntax for printing error message on lcd screen time.sleep(2) f.stop_led()
try: P = round(float(a['price']), 1) except ValueError: P = '_' try: C = a['change'] except ValueError: C = '_' try: H52 = int(round(float(a['fifty_two_week_high']), 0)) except ValueError: H52 = '_' try: PE = round(float(a['price_earnings_ratio']), 1) except ValueError: PE = '_' try: Cp = int(round(float(C) / float(P) * 100)) except ValueError: Cp = '_' return '{} {} {}% [{} {}] PE {}'.format(symbol, P, Cp, L52, H52, PE)[0:31] while(True): try: for s in symbols: printme = compact_quote(s) print printme lcd_string(printme, tn, 15) except KeyboardInterrupt: break
def main(): global stopper lcd.lcd_init() kb.keyboard_init() try: while True: num = '' lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string('Enter Stock Num:', 2) while True: print("get:") key = kb.get_key() time.sleep(0.3) if key == 'A': print('A') elif key == 'B': num = num[:len(num) - 1] print('Back, Cur num : ' + num) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(num, 2) elif key == 'C': num = '' print('Clear, Cur num : ' + num) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(num, 2) elif key == 'D': print('D') elif key == 'E' or key == 'F': print('Searching : ' + num) lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string(num, 2) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string('Searching...', 2) break else: num += key print('Cur num : ' + num) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(num, 2) stock = twstock.realtime.get(num) if not stock['success']: lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string('Stock Not Found', 2) continue stock_his = twstock.Stock(num) print(stock) yes = stock_his.price[-2:][0] op = stock['realtime']['open'] now = stock['realtime']["latest_trade_price"] high = stock['realtime']['high'] low = stock['realtime']['low'] a_s = float(now) - float(yes) output = now + ' ' if a_s > 0: output += '+' output += "%.2f" % a_s lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string(num, 2) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(output, 2) while True: print("get:") key = kb.get_key() time.sleep(0.3) if key == 'E' or key == 'F': stopper = 0 lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string('', 2) break elif key == 'A': stopper = 0 lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(output, 2) elif key == 'B': if stopper == 1: stopper = 0 t.join() stopper = 1 s = ' open: ' + op + ' high: ' + high + ' low: ' + low t = threading.Thread(target=mov_print, args=[s]) t.start() elif key == 'C': if stopper == 1: stopper = 0 t.join() stopper = 1 s = ' '.join(str(x) for x in stock_his.price[-5:]) + ' ' t = threading.Thread(target=mov_print, args=[s]) t.start() except KeyboardInterrupt: GPIO.cleanup()
import aplayer as P import time import vlc from threading import Thread import lcd import hardware as hw hw.Init() bb = hw.GPIOButton(8) bp = hw.GPIOButton(10) bf = hw.GPIOButton(12) lcd.lcd_init() lcd.lcd_string("Hello!", lcd.LCD_LINE_1); pl = P.Aplayer("hw"); #Станции можно брать отсюда: http://nevremya.narod.ru/transmission/ stid = 0 stlist = [] with open("stations.txt", "r") as fl: cont = fl.readlines() for c in cont: c = c.strip() if c[0] != "#" and c != "": f = c.split(" ") nm = "" if(len(f) > 1):