]> sigrok.org Git - libsigrokdecode.git/commitdiff
Factor out bcd2int() into common/srdhelper.
authorUwe Hermann <redacted>
Wed, 4 May 2016 17:56:40 +0000 (19:56 +0200)
committerUwe Hermann <redacted>
Thu, 5 May 2016 18:46:34 +0000 (20:46 +0200)
common/srdhelper/__init__.py [new file with mode: 0644]
common/srdhelper/mod.py [new file with mode: 0644]
decoders/dcf77/pd.py
decoders/ds1307/pd.py
decoders/rtc8564/pd.py

diff --git a/common/srdhelper/__init__.py b/common/srdhelper/__init__.py
new file mode 100644 (file)
index 0000000..cf09d9d
--- /dev/null
@@ -0,0 +1,21 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2012-2014 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+##
+
+from .mod import *
diff --git a/common/srdhelper/mod.py b/common/srdhelper/mod.py
new file mode 100644 (file)
index 0000000..e65ab17
--- /dev/null
@@ -0,0 +1,23 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2012-2014 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+##
+
+# Return the specified BCD number (max. 8 bits) as integer.
+def bcd2int(b):
+    return (b & 0x0f) + ((b >> 4) * 10)
index adee4037323df77428d4ed8c8e409d8c3348287f..cbdfa872955aea7d9d3711aba7bc3730636f3f9c 100644 (file)
 
 import sigrokdecode as srd
 import calendar
 
 import sigrokdecode as srd
 import calendar
-
-# Return the specified BCD number (max. 8 bits) as integer.
-def bcd2int(b):
-    return (b & 0x0f) + ((b >> 4) * 10)
+from srdhelper import bcd2int
 
 class SamplerateError(Exception):
     pass
 
 class SamplerateError(Exception):
     pass
index b784b6dd225bfcb6e51a4607cd0ad6d70bfa10c3..cb5fc13207647582cac86b2fb6ae0adc62147e0e 100644 (file)
@@ -21,6 +21,7 @@
 
 import re
 import sigrokdecode as srd
 
 import re
 import sigrokdecode as srd
+from srdhelper import bcd2int
 
 days_of_week = (
     'Sunday', 'Monday', 'Tuesday', 'Wednesday',
 
 days_of_week = (
     'Sunday', 'Monday', 'Tuesday', 'Wednesday',
@@ -51,10 +52,6 @@ def regs_and_bits():
     l += [('bit-' + re.sub('\/| ', '-', b).lower(), b + ' bit') for b in bits]
     return tuple(l)
 
     l += [('bit-' + re.sub('\/| ', '-', b).lower(), b + ' bit') for b in bits]
     return tuple(l)
 
-# Return the specified BCD number (max. 8 bits) as integer.
-def bcd2int(b):
-    return (b & 0x0f) + ((b >> 4) * 10)
-
 class Decoder(srd.Decoder):
     api_version = 2
     id = 'ds1307'
 class Decoder(srd.Decoder):
     api_version = 2
     id = 'ds1307'
index 24a68fbe28da6f50c8d30f4a57ddf1de8f0e8d9f..258ec2781fb81a6796a71bb372cf63f5ff214bea 100644 (file)
 ##
 
 import sigrokdecode as srd
 ##
 
 import sigrokdecode as srd
-
-# Return the specified BCD number (max. 8 bits) as integer.
-def bcd2int(b):
-    return (b & 0x0f) + ((b >> 4) * 10)
+from srdhelper import bcd2int
 
 def reg_list():
     l = []
 
 def reg_list():
     l = []