First speed reader test #4
This commit is contained in:
parent
7e7d90ce68
commit
551e2d3c95
2 changed files with 5 additions and 5 deletions
|
@ -2,7 +2,7 @@ from src.variables.service import get_variable, set_variable
|
|||
from gpiozero import Button
|
||||
import datetime
|
||||
|
||||
|
||||
pulses_per_rotation = 1
|
||||
reader = Button(4)
|
||||
set_variable("speed_reader_last_impulse_time", datetime.datetime.now(), False)
|
||||
|
||||
|
@ -11,11 +11,11 @@ def event():
|
|||
actual = datetime.datetime.now()
|
||||
last = get_variable("speed_reader_last_impulse_time")
|
||||
difference = (actual - last).total_seconds()
|
||||
set_variable("speed_reader_last_impulse_time", actual, False)
|
||||
|
||||
if difference != 0:
|
||||
return
|
||||
rpm = (60 / difference) / pulses_per_rotation
|
||||
|
||||
set_variable("pokus", difference)
|
||||
set_variable("actual_rpm", rpm, False)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ def set_variable(variable: str, params: SetVariable):
|
|||
@router.get("/{variable}", description="Get variable data", response_model=str)
|
||||
def get_variable(variable: str):
|
||||
try:
|
||||
return service.get_variable(variable=variable)
|
||||
return str(service.get_variable(variable=variable))
|
||||
except:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue