First speed reader test

This commit is contained in:
Jan Beníček 2025-01-14 18:30:53 +01:00
parent 85c87b1b2a
commit 3fa0e0f8f6
5 changed files with 57 additions and 4 deletions

1
.pdm-python Normal file
View file

@ -0,0 +1 @@
/home/jbenicek/Programovani/SequentMicrosystems_API/.venv/bin/python

31
pdm.lock generated
View file

@ -3,9 +3,12 @@
[metadata]
groups = ["default"]
strategy = ["cross_platform", "inherit_metadata"]
lock_version = "4.4.1"
content_hash = "sha256:46b66a4e3fd5632663e1dc2463271c94fb141dc874868edc93adc853429d6466"
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
content_hash = "sha256:2c6777666234648e5ed3ca6ed92de71161a091b6c1d1b5f38f72529dc52e9caf"
[[metadata.targets]]
requires_python = ">=3.12"
[[package]]
name = "annotated-types"
@ -13,6 +16,9 @@ version = "0.7.0"
requires_python = ">=3.8"
summary = "Reusable constraint types to use with typing.Annotated"
groups = ["default"]
dependencies = [
"typing-extensions>=4.0.0; python_version < \"3.9\"",
]
files = [
{file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"},
{file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"},
@ -25,8 +31,10 @@ requires_python = ">=3.9"
summary = "High level compatibility layer for multiple asynchronous event loop implementations"
groups = ["default"]
dependencies = [
"exceptiongroup>=1.0.2; python_version < \"3.11\"",
"idna>=2.8",
"sniffio>=1.1",
"typing-extensions>=4.1; python_version < \"3.11\"",
]
files = [
{file = "anyio-4.6.2.post1-py3-none-any.whl", hash = "sha256:6d170c36fba3bdd840c73d3868c1e777e33676a69c3a72cf0a0d5d6d8009b61d"},
@ -40,6 +48,7 @@ requires_python = ">=3.8"
summary = "In-process task scheduler with Cron-like capabilities"
groups = ["default"]
dependencies = [
"backports-zoneinfo; python_version < \"3.9\"",
"tzlocal>=3.0",
]
files = [
@ -55,6 +64,7 @@ summary = "Composable command line interface toolkit"
groups = ["default"]
dependencies = [
"colorama; platform_system == \"Windows\"",
"importlib-metadata; python_version < \"3.8\"",
]
files = [
{file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"},
@ -95,6 +105,9 @@ version = "0.14.0"
requires_python = ">=3.7"
summary = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"
groups = ["default"]
dependencies = [
"typing-extensions; python_version < \"3.8\"",
]
files = [
{file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"},
{file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"},
@ -197,6 +210,15 @@ files = [
{file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"},
]
[[package]]
name = "rpi-gpio"
version = "0.7.1"
summary = "A module to control Raspberry Pi GPIO channels"
groups = ["default"]
files = [
{file = "RPi.GPIO-0.7.1.tar.gz", hash = "sha256:cd61c4b03c37b62bba4a5acfea9862749c33c618e0295e7e90aa4713fb373b70"},
]
[[package]]
name = "sm4relind"
version = "1.0.3"
@ -265,6 +287,7 @@ summary = "The little ASGI library that shines."
groups = ["default"]
dependencies = [
"anyio<5,>=3.4.0",
"typing-extensions>=3.10.0; python_version < \"3.10\"",
]
files = [
{file = "starlette-0.41.3-py3-none-any.whl", hash = "sha256:44cedb2b7c77a9de33a8b74b2b90e9f50d11fcf25d8270ea525ad71a25374ff7"},
@ -301,6 +324,7 @@ requires_python = ">=3.8"
summary = "tzinfo object for the local timezone"
groups = ["default"]
dependencies = [
"backports-zoneinfo; python_version < \"3.9\"",
"tzdata; platform_system == \"Windows\"",
]
files = [
@ -317,6 +341,7 @@ groups = ["default"]
dependencies = [
"click>=7.0",
"h11>=0.8",
"typing-extensions>=4.0; python_version < \"3.11\"",
]
files = [
{file = "uvicorn-0.32.1-py3-none-any.whl", hash = "sha256:82ad92fd58da0d12af7482ecdb5f2470a04c9c9a53ced65b9bbb4a205377602e"},

View file

@ -13,6 +13,7 @@ dependencies = [
"python-dotenv>=1.0.1",
"SMmegaind>=1.0.3",
"apscheduler>=3.11.0",
"RPi-GPIO>=0.7.1",
]
requires-python = ">=3.12"
readme = "README.md"

25
scripts/speed_reader.py Normal file
View file

@ -0,0 +1,25 @@
from src.variables.service import get_variable, set_variable
import RPi.GPIO as GPIO
import datetime
pin = 7
GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
set_variable("speed_reader_last_impulse_time", datetime.datetime.now(), False)
def event(pin):
actual = datetime.datetime.now()
last = get_variable("speed_reader_last_impulse_time")
difference = (actual - last).total_seconds()
if difference != 0:
return
print(difference)
GPIO.add_event_detect(pin, GPIO.RISING, callback=event)

View file

@ -18,6 +18,7 @@ scheduler.add_job(rpm_control, trigger=IntervalTrigger(seconds=0.2))
from scripts.fan_controller import fan_control
scheduler.add_job(fan_control, trigger=IntervalTrigger(minutes=1))
#speed_reader
import scripts.speed_reader