]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/ds1307/pd.py
Fix incorrect doxygen comment for srd_decoder_list().
[libsigrokdecode.git] / decoders / ds1307 / pd.py
index 97431e01587dd6d4f933cc6f7b5e295153766f0f..77effbf73a36e5d074a87ed3f7606835803e36ea 100644 (file)
@@ -1,6 +1,6 @@
 ##
 ## This file is part of the libsigrokdecode project.
-## 
+##
 ## Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
 ## Copyright (C) 2013 Matt Ranostay <mranostay@gmail.com>
 ##
@@ -36,7 +36,7 @@ def bcd2int(b):
     return (b & 0x0f) + ((b >> 4) * 10)
 
 class Decoder(srd.Decoder):
-    api_version = 1
+    api_version = 2
     id = 'ds1307'
     name = 'DS1307'
     longname = 'Dallas DS1307'
@@ -44,12 +44,9 @@ class Decoder(srd.Decoder):
     license = 'gplv2+'
     inputs = ['i2c']
     outputs = ['ds1307']
-    probes = []
-    optional_probes = []
-    options = {}
-    annotations = [
-        ['text', 'Human-readable text'],
-    ]
+    annotations = (
+        ('text', 'Human-readable text'),
+    )
 
     def __init__(self, **kwargs):
         self.state = 'IDLE'
@@ -84,7 +81,7 @@ class Decoder(srd.Decoder):
         self.putx([0, ['Day of Week: %s' % days_of_week[self.days - 1]]])
 
     def handle_reg_0x04(self, b): # Date
-        self.date =  bcd2int(b & 0x3f)
+        self.date = bcd2int(b & 0x3f)
         self.putx([0, ['Days: %d' % self.date]])
 
     def handle_reg_0x05(self, b): # Month
@@ -92,7 +89,7 @@ class Decoder(srd.Decoder):
         self.putx([0, ['Months: %d' % self.months]])
 
     def handle_reg_0x06(self, b): # Year
-        self.years = bcd2int(b & 0xff) + 2000;
+        self.years = bcd2int(b & 0xff) + 2000
         self.putx([0, ['Years: %d' % self.years]])
 
     def handle_reg_0x07(self, b): # Control Register
@@ -167,6 +164,3 @@ class Decoder(srd.Decoder):
                 self.state = 'IDLE'
             else:
                 pass # TODO?
-        else:
-            raise Exception('Invalid state: %s' % self.state)
-