Adding refactored classes for ble sensing with working data collection again
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
import struct
|
||||
from .wand_utils import chunker
|
||||
from converters import BinToInt, BinToFloat
|
||||
|
||||
class decoder(object):
|
||||
class wand_decoder(object):
|
||||
def __init__(self, int_decoder=BinToInt(48), float_decoder= BinToFloat(16, 31)):
|
||||
self.int_decoder = int_decoder
|
||||
self.float_decoder = float_decoder
|
||||
|
||||
def decode_button(self, data):
|
||||
if int.from_bytes(data, byteorder='big'):
|
||||
print("Button Pressed")
|
||||
else:
|
||||
print("Button Released")
|
||||
return int.from_bytes(data, byteorder='big')
|
||||
|
||||
def decode_nine_axis(self, data):
|
||||
converted = [self.int_decoder.process(x, True) / 10 ** 14 for x in chunker(data, 6)]
|
||||
@@ -21,13 +19,12 @@ class decoder(object):
|
||||
return converted
|
||||
|
||||
def decode_battery(self, data):
|
||||
int.from_bytes(data, byteorder='big')
|
||||
return int.from_bytes(data, byteorder='big')
|
||||
|
||||
def decode_temp(self, data):
|
||||
print(len(data))
|
||||
print(data)
|
||||
print(struct.unpack("h", data))
|
||||
return struct.unpack("h", data)
|
||||
|
||||
def decode_magnet(self, data):
|
||||
print(data)
|
||||
print(len(data))
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user