Esempio n. 1
0
 def get(self):
     return InputModule.concat_bytearrays((
         InputModule.uint16_to_bytearray(self.sensor.get_x_acceleration()),
         InputModule.uint16_to_bytearray(self.sensor.get_y_acceleration()),
         InputModule.uint16_to_bytearray(self.sensor.get_z_acceleration()),
     ))
Esempio n. 2
0
 def get(self):
     return InputModule.uint16_to_bytearray(self.sensor.measure())
Esempio n. 3
0
 def decode(array):
     s = "\t\"MB7092\":\n\t{\n"
     s += "\t\t\"distance_cm\": " + str(
         InputModule.bytearray_to_uint16(array, 0)) + "\n\t}"
     return s
Esempio n. 4
0
 def get(self):
     try:
         data = self.sensor.getData()
         return InputModule.concat_bytearrays(
             (
                 InputModule.uint16_to_bytearray(data[0][2]*10),
                 InputModule.uint16_to_bytearray(data[1][2]*10),
                 InputModule.uint16_to_bytearray(data[2][2]*10),
                 InputModule.uint16_to_bytearray(data[3][2]*10),
                 InputModule.uint16_to_bytearray(data[4][2]*10),
                 InputModule.uint16_to_bytearray(data[5][2]*10),
                 InputModule.uint16_to_bytearray(data[6][2]*10),
                 InputModule.uint16_to_bytearray(data[7][2]*10),
                 InputModule.uint16_to_bytearray(data[8][2]*10),
                 InputModule.uint16_to_bytearray(data[9][2]*100)
             )
         )
     except:
         b = bytearray(20)
         for i in range(0, len(b)):
             b[i] = 0
         return b
Esempio n. 5
0
 def __init__(self):
     InputModule.__init__(self)
     UART_Device.__init__(self, "SPS30")
     from modules.input.SPS30.dep.SPS30 import SPS30 as SPS30_drv
     self.sensor = SPS30_drv(port=self.uart_port(), pins=("P" + str(self.config().get("pin_rx")), "P" + str(self.config().get("pin_tx"))))
Esempio n. 6
0
 def decode(array):
     s = "\t\"SDS011\":\n\t{\n"
     s += "\t\t\"pm25\": " + str(InputModule.bytearray_to_uint16(array, 0) / 10) + ",\n"
     s += "\t\t\"pm10\": " + str(InputModule.bytearray_to_uint16(array, 2) / 10) + ",\n"
     s += "\t}"
     return s
Esempio n. 7
0
 def __init__(self):
     InputModule.__init__(self)
     UART_Device.__init__(self, "SDS011")
     from modules.input.SDS011.dep.SDS011 import SDS011 as SDS011_drv
     self.sensor = SDS011_drv(port=self.uart_port(), pins=("P" + str(self.config().get("pin_rx")), "P" + str(self.config().get("pin_tx"))))