Remove memory tasks for pressure.
This commit is contained in:
parent
2c951c7324
commit
d4c3060008
@ -12,4 +12,4 @@ LCD_SCL = 1
|
|||||||
ANNOYTING_BUZZER_TONE = 51250
|
ANNOYTING_BUZZER_TONE = 51250
|
||||||
NORMAL_BUZZER_TONE = 200
|
NORMAL_BUZZER_TONE = 200
|
||||||
ADC_RESOLUTION = 65535.0
|
ADC_RESOLUTION = 65535.0
|
||||||
|
MAX_VOTLAGE = 3.3
|
||||||
|
@ -11,7 +11,7 @@ previous_time = time.ticks_ms()
|
|||||||
def hall_sensor_interruption(*args, **kargs):
|
def hall_sensor_interruption(*args, **kargs):
|
||||||
global ii
|
global ii
|
||||||
ii += 1
|
ii += 1
|
||||||
|
|
||||||
|
|
||||||
def start_hall_sensor():
|
def start_hall_sensor():
|
||||||
global previous_time
|
global previous_time
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
from machine import ADC, I2C, Pin, PWM
|
from machine import ADC, I2C, Pin, PWM
|
||||||
import time
|
import time
|
||||||
import hall_sensor
|
import hall_sensor
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""Percentage that the previous pressure can be lower than current one without triggering the hole alarm."""
|
"""Percentage that the previous pressure can be lower than current one without triggering the hole alarm."""
|
||||||
PRESSURE_TOLERANCE_PERCENTAGE = 10
|
PRESSURE_TOLERANCE_PERCENTAGE = 1
|
||||||
|
|
||||||
"""Pressure saturation threshold in mV to trigger the saturation alarm."""
|
"""Pressure saturation threshold in mV to trigger the saturation alarm."""
|
||||||
PRESSURE_SATURATION_THRESHOLD = 2.8
|
PRESSURE_SATURATION_THRESHOLD = 1.65
|
||||||
|
|
||||||
"""Lower limit of frequency in Hz to be considered inside interest rotation interval. (type: float)"""
|
"""Lower limit of frequency in Hz to be considered inside interest rotation interval. (type: float)"""
|
||||||
REFERENCE_ROTATION_DOWN_LIMIT = 250.0
|
REFERENCE_ROTATION_DOWN_LIMIT = 250.0
|
||||||
@ -13,8 +13,5 @@ REFERENCE_ROTATION_UPPER_LIMIT = 270.0
|
|||||||
"""Weather or not the buzzer should be set to an annoying tone (in oder to keep the mental healthness of the developer)."""
|
"""Weather or not the buzzer should be set to an annoying tone (in oder to keep the mental healthness of the developer)."""
|
||||||
ANNOYING_BUZZER_ENABLED = False
|
ANNOYING_BUZZER_ENABLED = False
|
||||||
|
|
||||||
"""Period in milisseconds between each storage event."""
|
|
||||||
PRESSURE_STORE_PREIOD = int(60*1e3)
|
|
||||||
|
|
||||||
"""How many samples of pressure should be used in smoother."""
|
"""How many samples of pressure should be used in smoother."""
|
||||||
PRESSURE_SMOOTH_LENGTH = 10
|
PRESSURE_SMOOTH_LENGTH = 25
|
||||||
|
@ -10,6 +10,5 @@ def get_pressure():
|
|||||||
pressure_value = 0
|
pressure_value = 0
|
||||||
for i in range(parameters.PRESSURE_SMOOTH_LENGTH):
|
for i in range(parameters.PRESSURE_SMOOTH_LENGTH):
|
||||||
pressure_value += pressure_sensor.read_u16()
|
pressure_value += pressure_sensor.read_u16()
|
||||||
print(pressure_value / parameters.PRESSURE_SMOOTH_LENGTH)
|
pressure_measure = float(pressure_value) / parameters.PRESSURE_SMOOTH_LENGTH / constants.ADC_RESOLUTION * constants.MAX_VOTLAGE
|
||||||
pressure_measure = float(pressure_value) / constants.ADC_RESOLUTION * 3.3
|
|
||||||
return pressure_measure
|
return pressure_measure
|
||||||
|
@ -1,31 +1,27 @@
|
|||||||
import time
|
import time
|
||||||
from display import Display
|
|
||||||
import hall_sensor
|
import hall_sensor
|
||||||
import pressure_sensor
|
import pressure_sensor
|
||||||
import parameters
|
import parameters
|
||||||
from alarm import Alarm
|
from alarm import Alarm
|
||||||
from storage import Storage
|
|
||||||
|
|
||||||
|
|
||||||
class StateMachine:
|
class StateMachine:
|
||||||
pressure= None
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
Storage.enable_store_in_next_call()
|
self.previous_pressure = pressure_sensor.get_pressure()
|
||||||
self.__read_previous_pressure()
|
|
||||||
self.__measure_pressure()
|
|
||||||
|
|
||||||
def start_task_loop(self):
|
|
||||||
time.sleep(0.02)
|
time.sleep(0.02)
|
||||||
self.wait_for_correct_rotation_frequency()
|
self.__measure_pressure()
|
||||||
self.handle_pressure()
|
|
||||||
|
def start_task_loop(self):
|
||||||
|
while True:
|
||||||
|
self.wait_for_correct_rotation_frequency()
|
||||||
|
self.handle_pressure()
|
||||||
|
time.sleep(0.03)
|
||||||
|
|
||||||
def wait_for_correct_rotation_frequency(self):
|
def wait_for_correct_rotation_frequency(self):
|
||||||
while self.__rotation_is_within_limits():
|
while not self.__rotation_is_within_limits():
|
||||||
print('waiting correct rotation')
|
time.sleep(0.03)
|
||||||
time.sleep(0.02)
|
|
||||||
continue
|
|
||||||
|
|
||||||
def __measure_pressure(self):
|
def __measure_pressure(self):
|
||||||
self.current_pressure = pressure_sensor.get_pressure()
|
self.current_pressure = pressure_sensor.get_pressure()
|
||||||
|
|
||||||
@ -41,15 +37,6 @@ class StateMachine:
|
|||||||
there_is_a_hole = self.__pressure_is_lower_than_before()
|
there_is_a_hole = self.__pressure_is_lower_than_before()
|
||||||
if there_is_a_hole:
|
if there_is_a_hole:
|
||||||
Alarm.trigger_hole_alarm()
|
Alarm.trigger_hole_alarm()
|
||||||
else:
|
|
||||||
self.__save_current_pressure()
|
|
||||||
|
|
||||||
def __save_current_pressure(self):
|
|
||||||
Storage.save_pressure(self.current_pressure)
|
|
||||||
self.previous_pressure = self.current_pressure
|
|
||||||
|
|
||||||
def __read_previous_pressure(self):
|
|
||||||
self.previous_pressure = Storage.retrieve_pressure()
|
|
||||||
|
|
||||||
def __pressure_is_lower_than_before(self) -> bool:
|
def __pressure_is_lower_than_before(self) -> bool:
|
||||||
pressure_is_lower = (
|
pressure_is_lower = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user