Update kuukar_sensors.py

This commit is contained in:
Siwat Sirichai 2022-12-08 20:55:33 +07:00
parent 7e9da402a6
commit f2398dd215
1 changed files with 4 additions and 6 deletions

View File

@ -1,10 +1,8 @@
from telemetrix_rpi_pico import telemetrix_rpi_pico
from kuukar.kuukar_config import DHT22_PIN, SONAR_1_ADC_PIN, SONAR_2_ADC_PIN, SONAR_3_ADC_PIN, LIGHT_ANALOG_PIN
from kuukar.kuukar_config import DHT22_PIN, SONAR_1_ADC_PIN, SONAR_2_ADC_PIN, SONAR_3_ADC_PIN, LIGHT_SENSOR_PIN
class sensors:
__sonar_adc_pins = [SONAR_1_ADC_PIN,
SONAR_2_ADC_PIN, SONAR_3_ADC_PIN]
__sonar_distances = [0, 0, 0]
@ -15,9 +13,9 @@ class sensors:
def __init__(self, mcu: telemetrix_rpi_pico.TelemetrixRpiPico, drv: telemetrix_rpi_pico.TelemetrixRpiPico) -> None:
self.mcu = mcu
self.drv = drv
self.mcu.set_pin_mode_analog_input(SONAR_1_ADC_PIN, 100, self.__sonar_callback)
self.mcu.set_pin_mode_analog_input(SONAR_2_ADC_PIN, 100, self.__sonar_callback)
self.mcu.set_pin_mode_analog_input(SONAR_3_ADC_PIN, 100, self.__sonar_callback)
self.drv.set_pin_mode_analog_input(SONAR_1_ADC_PIN, 100, self.__sonar_callback)
self.drv.set_pin_mode_analog_input(SONAR_2_ADC_PIN, 100, self.__sonar_callback)
self.drv.set_pin_mode_analog_input(SONAR_3_ADC_PIN, 100, self.__sonar_callback)
self.mcu.set_pin_mode_dht(DHT22_PIN, self.__dht22_callback)
self.drv.set_pin_mode_analog_input(LIGHT_ANALOG_PIN, 0, self.__light_sensor_callback)