def accelerometer(self):
        """
        Read the values of the accelerometer on the microbit
        :return: return a list in the order of x, y & z
        """
        # [16, 0, 64, 0, 32, 252]
        # x=0.16, y=0.024, z=-0.992
        accel_bytes = self._accel_data.value

        return tools.bytes_to_xyz(accel_bytes)
    def magnetometer(self):
        """
        Exposes magnetometer data.
        A magnetometer measures a magnetic field such
        as the earth's magnetic field in 3 axes.
        :return: List of x, y & z value
        """
        mag_bytes = self._magneto_data.value

        return tools.bytes_to_xyz(mag_bytes)
    def read_magnetometer(self):
        """
        Exposes magnetometer data.
        A magnetometer measures a magnetic field such
        as the earth's magnetic field in 3 axes.
        :return: List of x, y & z value
        """
        mag_bytes = self.mag_iface.ReadValue(())

        return tools.bytes_to_xyz(mag_bytes)
Example #4
0
    def magnetometer(self):
        """
        Exposes magnetometer data.
        A magnetometer measures a magnetic field such
        as the earth's magnetic field in 3 axes.
        :return: List of x, y & z value
        """
        mag_bytes = self._magneto_data.value

        return tools.bytes_to_xyz(mag_bytes)
Example #5
0
    def accelerometer(self):
        """
        Read the values of the accelerometer on the microbit
        :return: return a list in the order of x, y & z
        """
        # [16, 0, 64, 0, 32, 252]
        # x=0.16, y=0.024, z=-0.992
        accel_bytes = self._accel_data.value

        return tools.bytes_to_xyz(accel_bytes)
Example #6
0
    def read_magnetometer(self):
        """
        Exposes magnetometer data.
        A magnetometer measures a magnetic field such
        as the earth's magnetic field in 3 axes.
        :return: List of x, y & z value
        """
        mag_obj = tools.get_dbus_obj(constants.BLUEZ_SERVICE_NAME,
                                     self.magneto_data_path)
        mag_iface = tools.get_dbus_iface(constants.GATT_CHRC_IFACE, mag_obj)

        bytes = mag_iface.ReadValue(())

        return tools.bytes_to_xyz(bytes)
Example #7
0
    def read_accelerometer(self):
        """
        Read the values of the accelerometer on the microbit
        :return: return a list in the order of x, y & z
        """
        # [16, 0, 64, 0, 32, 252]
        # x=0.16, y=0.024, z=-0.992
        accel_obj = tools.get_dbus_obj(constants.BLUEZ_SERVICE_NAME,
                                       self.accel_data_path)
        accel_iface = tools.get_dbus_iface(constants.GATT_CHRC_IFACE,
                                           accel_obj)

        # Read button value
        bytes = accel_iface.ReadValue(())

        return tools.bytes_to_xyz(bytes)