From: Uwe Hermann Date: Sun, 12 Oct 2014 12:31:21 +0000 (+0200) Subject: am230x: Minor cosmetics. X-Git-Tag: libsigrokdecode-0.4.0~166 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=47405f47db235c06d9f2ad26ae51791136b62a91;p=libsigrokdecode.git am230x: Minor cosmetics. --- diff --git a/decoders/am230x/__init__.py b/decoders/am230x/__init__.py index 84e36c2..782c095 100644 --- a/decoders/am230x/__init__.py +++ b/decoders/am230x/__init__.py @@ -19,11 +19,11 @@ ## ''' -This decoder handles the proprietary single wire communication protocol used by -the AM230x series of digital humidity and temperature sensors. +This decoder handles the proprietary single wire communication protocol used +by the Aosong AM230x/DHTxx series of digital humidity and temperature sensors. Sample rate: -A sample rate of at least 200 kHz is recommended to properly detect all the +A sample rate of at least 200kHz is recommended to properly detect all the elements of the protocol. Options: diff --git a/decoders/am230x/pd.py b/decoders/am230x/pd.py index 05489d9..d7cbad2 100644 --- a/decoders/am230x/pd.py +++ b/decoders/am230x/pd.py @@ -37,9 +37,9 @@ class SamplerateError(Exception): class Decoder(srd.Decoder): api_version = 2 id = 'am230x' - name = 'AM230x' - longname = 'AM230x humidity and temperature sensors' - desc = 'Proprietary single wire communication bus.' + name = 'AM230x/DHTxx' + longname = 'Aosong AM230x/DHTxx' + desc = 'Aosong AM230x/DHTxx humidity/temperature sensor protocol.' license = 'gplv2+' inputs = ['logic'] outputs = ['am230x'] @@ -95,8 +95,8 @@ class Decoder(srd.Decoder): def bits2num(self, bitlist): number = 0 - for i in range(0, len(bitlist)): - number += bitlist[-1-i] * 2**i + for i in range(len(bitlist)): + number += bitlist[-1 - i] * 2**i return number def calculate_humidity(self, bitlist): @@ -119,7 +119,7 @@ class Decoder(srd.Decoder): def calculate_checksum(self, bitlist): checksum = 0 - for i in range(8, len(bitlist)+1, 8): + for i in range(8, len(bitlist) + 1, 8): checksum += self.bits2num(bitlist[i-8:i]) return checksum % 256