liveTest for RPi / Bookcheck
- Python3
- C++
LibraryLight for RPI
import serial
import urllib
import urllib.request
import time
import json
import RPi.GPIO as GPIO
red = 17
green = 18
blue = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(red, GPIO.OUT)
GPIO.setup(green, GPIO.OUT)
GPIO.setup(blue, GPIO.OUT)
Freq = 100 #Hz
bookcaseNumber = '1'
data = ["3A 9B AA A7"]
url = "http://henocks.dothome.co.kr/f6.php"
url2 = "https://ll.0o0.moe/API/login"
url_rfid = "https://ll.0o0.moe/API/takeMyBooks"
delaycount = 0
Token = "########################################################################"
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=10)
RED = GPIO.PWM(red, Freq)
RED.start(0)
GREEN = GPIO.PWM(green, Freq)
GREEN.start(0)
BLUE = GPIO.PWM(blue, Freq)
BLUE.start(0)
class RGB:
def on(color):
print("RGB LED on with color : "+color)
this.color(100,100,100)
def off():
print("RGB LED off")
this.color(0,0,0)
def color(R, G, B):
RED.ChangeDutyCycle(R)
GREEN.ChangeDutyCycle(G)
BLUE.ChangeDutyCycle(B)
class server:
def req(dat):
sdata = urllib.parse.urlencode({'flag': dat}).encode('utf-8')
request = urllib.request.Request(url)
request.add_header("Content-Type","application/x-www-form-urlencoded;charset=utf-8")
f = urllib.request.urlopen(request, sdata)
return f.read().decode('utf-8')
def req_rfid(dat, URL):
sdata = urllib.parse.urlencode({'libraryAPIToken': Token, 'bookcaseNumber': bookcaseNumber, "bookCodes" : dat}).encode('utf-8')
request = urllib.request.Request(URL)
request.add_header("Content-Type","application/x-www-form-urlencoded;charset=utf-8")
f = urllib.request.urlopen(request, sdata)
return f.read().decode('utf-8')
def req_login(dat, URL):
sdata = urllib.parse.urlencode({"ID": "abcde12345", "password" : "abcde12345"}).encode('utf-8')
request = urllib.request.Request(URL)
request.add_header("Content-Type","application/x-www-form-urlencoded;charset=utf-8")
f = urllib.request.urlopen(request, sdata)
return f.read().decode('utf-8')
#jsObj = json.loads(server.req_login(data))
#reason = jsObj["reason"]
#succ = jsObj["success"]
def checkRequest(): #서버와 통신해서 서버의 응답에 데이터가 있는지 확인
a = server.req(1)
print("checked server call : " + a)
if(int(a) == 1):
return 1
else:
return 0
def receiveRequest(): #서버에서 명령 데이터를 받아옴
a = server.req(2)
print("received server call : " + a)
return a
def sendData(RfidData): #서버에 데이터 전송
server.req(RfidData)
print("RFID Data Sent")
try:
while 1:
response = ser.readline()
if response != '':
if data.count(response[2:-3]) == 0:
data.append(response[2:-3])
print (response)
if delaycount > 5000000:
if server.checkRequest() == 1:
delaycount = 0
stat = str(server.receiveRequest())
if stat[0:1] == "1":
server.sendData(data)
elif stat[0:1] == "2":
RGB.off()
else:
RGB.on(stat)
delaycount += 1
except KeyboardInterrupt:
print("QUITTTING")
RUNNING = False
ser.close()
GPIO.cleanup()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.