]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/nunchuk/pd.py
atsha204a: Shorten self.opcode to op in a few places.
[libsigrokdecode.git] / decoders / nunchuk / pd.py
index afcf1de2d417936b2cd9ea5becb84c7c15940b74..4f006f2f8f0816546124b288982781eec5cb3f49 100644 (file)
 ## 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
+## along with this program; if not, see <http://www.gnu.org/licenses/>.
 ##
 
 import sigrokdecode as srd
 
 class Decoder(srd.Decoder):
-    api_version = 2
+    api_version = 3
     id = 'nunchuk'
     name = 'Nunchuk'
     longname = 'Nintendo Wii Nunchuk'
@@ -47,7 +46,10 @@ class Decoder(srd.Decoder):
         ('warnings', 'Warnings', (14,)),
     )
 
-    def __init__(self, **kwargs):
+    def __init__(self):
+        self.reset()
+
+    def reset(self):
         self.state = 'IDLE'
         self.sx = self.sy = self.ax = self.ay = self.az = self.bz = self.bc = -1
         self.databytecount = 0
@@ -128,8 +130,8 @@ class Decoder(srd.Decoder):
         t = (self.sx, self.sy, self.ax, self.ay, self.az, self.bz, self.bc)
         if -1 in t:
             return
-        bz = 'pressed' if self.bz == 1 else 'not pressed'
-        bc = 'pressed' if self.bc == 1 else 'not pressed'
+        bz = 'pressed' if self.bz == 0 else 'not pressed'
+        bc = 'pressed' if self.bc == 0 else 'not pressed'
         s = 'Analog stick: %d/%d, accelerometer: %d/%d/%d, Z: %s, C: %s' % \
             (self.sx, self.sy, self.ax, self.ay, self.az, bz, bc)
         self.putb([13, [s]])