Skip to content
Merged

Dev #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="cuplcodec",
version="2.0.4",
version="2.0.6",
author="Malcolm Mackay",
author_email="malcolm@plotsensor.com",
description="Package for creating and decoding URLs that contain temperature and humidity samples.",
Expand Down
44 changes: 22 additions & 22 deletions wscodec/encoder/pyencoder/instrumented.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def temp_degc_to_raw(self, degc):
""" Converts degrees C to a raw ADC value for the Texas HDC2010. """
return int((degc + 40) * 4096 / 165)


def rh_percent_to_raw(self, rhpc):
""" Converts from relative humidity in percent to a raw ADC value for the Texas HDC2010. """
return int((rhpc * 4096) / 100)
Expand All @@ -143,6 +142,28 @@ def rhsample(self, countermax, counterstep):
rawrh = self.rh_percent_to_raw(counter)
yield {'adc': rawrh, 'ref': counter}

def pushsamplelist(self, trhlist: list):
"""

:param trhlist: a list of dictionaries each containing temperature and relative humidity keys.
:return: None
"""
for smpldict in trhlist:
tempdegc = smpldict['temp']
rhpc = smpldict['rh']
tempraw = self.temp_degc_to_raw(tempdegc)
rhraw = self.rh_percent_to_raw(rhpc)
# rhraw is ignored (set to -1) inside enc_pushsample if the format is temperature only.
self.ffimodule.lib.enc_pushsample(tempraw, rhraw)

def updateendstop(self, minutes: int):
""" Update the endstop with minutes elapsed since the most recent sample.

:param minutes: Minutes elapsed since the most recent sample.
:return: None
"""
self.ffimodule.lib.enc_setelapsed(minutes)


class InstrumentedSampleT(InstrumentedSample):
FORMAT_HDC2021_TEMPONLY = 2
Expand Down Expand Up @@ -219,26 +240,5 @@ def pushsamples(self, num):
self.ffimodule.lib.enc_pushsample(tempsmpl['adc'], rhsmpl['adc'])
return inlist

def pushsamplelist(self, trhlist: list):
"""

:param trhlist: a list of dictionaries each containing temperature and relative humidity keys.
:return: None
"""
for smpldict in trhlist:
tempdegc = smpldict['temp']
rhpc = smpldict['rh']
tempraw = self.temp_degc_to_raw(tempdegc)
rhraw = self.rh_percent_to_raw(rhpc)
self.ffimodule.lib.enc_pushsample(tempraw, rhraw)

def updateendstop(self, minutes: int):
""" Update the endstop with minutes elapsed since the most recent sample.

:param minutes: Minutes elapsed since the most recent sample.
:return: None
"""
self.ffimodule.lib.enc_setelapsed(minutes)

def geturlqs(self):
return self.eepromba.get_url_parsedqs()