def main():
    while (1):
        sleep(1)
        print "c : clear ,h : cursorHome , o : cursor on , p : cursorOff , l: CursorBlink, w: write"
        print "sL : Shitleft, sR : ShiftRight ,sAL : shiftAnimLeft , sAR : shiftAnimRight"
        k = str(raw_input("secim gir:"))
        print "", k
        if (k == "c"):
            lcd.lcd_Clear()
        elif (k == "o"):
            lcd.lcd_CursorON()
        elif (k == "p"):
            lcd.lcd_CursorOFF()
        elif (k == "l"):
            lcd.lcd_CursorBlink()
        elif (k == "w"):
            yazi = str(raw_input("1.satır Ekrana Yaz: "))
            lcd.lcd_string(yazi, lcd.LCD_LINE_1)
            yazi = str(raw_input("2.Satır Ekrana Yaz: "))
            lcd.lcd_string(yazi, lcd.LCD_LINE_2)
        elif (k == "sL"):
            lcd.lcd_ShiftLefts(int(raw_input("ne kadar kaydırılıcak : ")))
        elif (k == "sR"):
            lcd.lcd_ShiftRight()
        elif (k == "h"):
            lcd.lcd_CursorHome()
        elif (k == "sAL"):
            lcd.lcd_ShiftAnimLeft(2, 1)
        elif (k == "sAR"):
            lcd.lcd_ShiftAnimRight(2, 2)
Exemple #2
0
 def signal_handler(self, signal, frame):
     print ('SIGINT caught: cleaning GPIOs.')
     lcd.lcd_string('                ', 2)
     lcd.lcd_string('                ', lcd.LCD_LINE_2)
     if self.servo_mode == 0 or self.servo_mode == 'seconds' or self.servo_mode == 1 or self.servo_mode == 'minutes':
         for i in range(60 - self.servo.time):
             self.servo.spinMin()
             self.servo.p_width += 1
     else:
         for i in range(12 - self.servo.time):
             self.servo.spinHour()
             self.servo.p_width += 4
     sys.exit(0)
Exemple #3
0
def dbInsertValidate(now, startTime, timegap, temp):
    LCD.lcd_init()
    if now >= startTime + timedelta(minutes=timegap):
        #mysql insertion
        sql = "insert into TempRecord(rec_year, rec_month, rec_date, rec_time, temp) values(%s, %s, %s, %s, %s)"
        # print sql %(now.year, now.month, now.day, now.strftime('%H:%M:%S'), temp)
        try:
            cursor.execute(sql, (int(now.year), int(now.month), int(now.day), now.strftime('%H:%M:%S'), temp))
            LCD.lcd_string('**db inserted**', 2)
            print '**temp value inserted**'
            buzzer.buzz(1)
        except:
            LCD.lcd_string('**db error!**', 2)
            time.sleep(2)
            db.rollback()
        db.commit()

        global start
        start = now
Exemple #4
0
    def display(self):
        lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)

        if self.lcd_mode == 0:
            lcd.lcd_string('Time is ' + str(self.hours) + ':' + str(self.minutes) +
                           ':' + str(self.seconds), 2)
            print('Time is ' + str(self.hours) + ':' + str(self.minutes) + ':'
                  + str(self.seconds))
            
        elif self.lcd_mode == 1 or self.lcd_mode == "hours":
            lcd.lcd_string('Hours: ' + str(self.hours), 2)
            print ('Hours: ' + str(self.hours))
            
        elif self.lcd_mode == 2 or self.lcd_mode == "minutes":
            lcd.lcd_string('Minutes: ' + str(self.minutes), 2)
            print ('Minutes: ' + str(self.minutes))

        elif self.lcd_mode == 3 or self.lcd_mode == "seconds":
            lcd.lcd_string('Seconds: ' + str(self.seconds), 2)
            print ('Seconds: ' + str(self.seconds))
        lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        lcd.lcd_string("Timezone: " + self.tzone.upper(), lcd.LCD_LINE_2)
Exemple #5
0
def printLog(now, temp):
        log = str(now) + ' Temp: %3.3f' %temp
        LCD.lcd_string('Temp: %3.2f C' %temp, 1)
        LCD.lcd_string('Time: %s' %now.strftime('%H:%M:%S'), 2)
        print log
Exemple #6
0
        'is_empty': True,
    }
    log.debug('Payload is %s', str(payload))
    auth = login()

    r = requests.patch(url, json=payload, auth=auth)
    log.debug("Received response status code: %s", r.status_code)
    log.debug("Received response text: %s", r.text)

    r = requests.patch(url, json=payload, auth=auth)
    return r.status_code


if __name__ == "__main__":
    lcd.lcd_init()
    lcd.lcd_string("Welcome", lcd.LCD_LINE_1, "c")
    lcd.lcd_string("to LabPi", lcd.LCD_LINE_2, "c")
    lcd.GPIO.cleanup()
    lcd.time.sleep(3)
    while True:
        try:
            lcd.GPIO.cleanup()
            lcd.lcd_init()
            lcd.lcd_string("Ready:", lcd.LCD_LINE_1)
            barcode = str(input('input:'))
            log.debug("Input received: %s", barcode)
            if barcode == 'EXIT':
                log.info("Received 'EXIT' signal. Exiting.")
                exit()
            if validate(barcode):
                lcd.lcd_string("Recieved:", lcd.LCD_LINE_1)
Exemple #7
0
        'is_empty': True,
        }
    log.debug('Payload is %s', str(payload))
    auth = login()

    r = requests.patch(url, json=payload, auth=auth)
    log.debug("Received response status code: %s", r.status_code)
    log.debug("Received response text: %s", r.text)

    r = requests.patch(url, json=payload, auth=auth)
    return r.status_code  


if __name__ == "__main__":
    lcd.lcd_init()
    lcd.lcd_string("Welcome", lcd.LCD_LINE_1, "c")
    lcd.lcd_string("to LabPi", lcd.LCD_LINE_2, "c")
    lcd.GPIO.cleanup()
    lcd.time.sleep(3)
    while True:
        try:
            lcd.GPIO.cleanup()
            lcd.lcd_init()
            lcd.lcd_string("Ready:", lcd.LCD_LINE_1)
            barcode = str(input('input:'))
            log.debug("Input received: %s", barcode)
            if barcode == 'EXIT':
                log.info("Received 'EXIT' signal. Exiting.")
                exit()
            if validate(barcode):
                lcd.lcd_string("Recieved:", lcd.LCD_LINE_1)
Exemple #8
0
                temp /= 10
                p /= 10
                h /= 10
            except:
                temp = -999
                p = -999
                h = -999
            try:
                write_nano(nanonum)
                if read_nano() == nanonum: nanonum += 1
            except:
                print("error")
            # sleep one second
            pitch = math.degrees(math.atan2(a["y"], a["z"]))
            roll = math.degrees(math.atan2(-a["x"], a["z"]))
            yaw = g["z"]
            alt = get_altitude(p)
            alt_rel = get_altitude(p, baseline_p)
            LCD.lcd_string("Rel. Altitude", LCD.LCD_LINE_1)
            LCD.lcd_string("%.2f" % (alt_rel), LCD.LCD_LINE_2)
            csvwriter.writerow([
                a["x"], a["y"], a["z"], g["x"], g["y"], g["z"], temp, p,
                nanonum, t, yaw, pitch, roll, alt_rel, alt
            ])
            print(a["x"], a["y"], a["z"], g["x"], g["y"], g["z"], temp, p,
                  nanonum, t, yaw, pitch, roll, alt_rel, alt)
            csvfile.close()
except Exception as e:
    exc_type, exc_obj, exc_tb = sys.exc_info()
    print(exc_type, exc_obj, exc_tb.tb_lineno)