##
## 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>
##
return (b & 0x0f) + ((b >> 4) * 10)
class Decoder(srd.Decoder):
- api_version = 1
+ api_version = 2
id = 'ds1307'
name = 'DS1307'
longname = 'Dallas DS1307'
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'
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
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
self.state = 'IDLE'
else:
pass # TODO?
- else:
- raise Exception('Invalid state: %s' % self.state)
-