Skip to content
Snippets Groups Projects
Commit f00c4634 authored by elagil's avatar elagil
Browse files

added sampler bit width adjustment

parent 595ef44b
No related branches found
No related tags found
No related merge requests found
...@@ -8,11 +8,30 @@ class Sampler(__Extension__): ...@@ -8,11 +8,30 @@ class Sampler(__Extension__):
Extends a platform with ADC sampling capability Extends a platform with ADC sampling capability
""" """
def __init__(self, platform, configHandler, dataHandler): def __init__(self, platform, configHandler, dataHandler, bitWidth = 15):
super().__init__(self, platform, configHandler, "Sampler") super().__init__(self, platform, configHandler, "Sampler")
self.configHandler = configHandler self.configHandler = configHandler
self.dataHandler = dataHandler self.dataHandler = dataHandler
self.adcBitFormatString = bitWidth
@property
def adcBitFormatString(self):
return self._adcBitFormatString
@adcBitFormatString.setter
def adcBitFormatString(self, new_bitWidth):
if new_bitWidth == 7:
self._adcBitFormatString = "int8"
elif new_bitWidth == 8:
self._adcBitFormatString = "uint8"
elif new_bitWidth == 16:
self._adcBitFormatString = "uint16"
else:
self._adcBitFormatString = "int16"
def configDuration(self, duration): def configDuration(self, duration):
""" """
...@@ -43,7 +62,6 @@ class Sampler(__Extension__): ...@@ -43,7 +62,6 @@ class Sampler(__Extension__):
Single shot sampling and storage on this platform Single shot sampling and storage on this platform
""" """
# Do the sampling # Do the sampling
self.adcBitFormatString = "int16"
rawBlock = self.dataHandler.receive(leaveOpen=True, sections=[("uint32", 8), (self.adcBitFormatString, None)]) rawBlock = self.dataHandler.receive(leaveOpen=True, sections=[("uint32", 8), (self.adcBitFormatString, None)])
measurement = np.asarray(rawBlock) measurement = np.asarray(rawBlock)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment