Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- samp = [1 ,1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]
- state = 1
- db0 = 0
- db1 = 0
- print("samp = button state 0 is pressed")
- print("delta = samp ^ state difference between sample and state")
- print("db0 = ~(db0) & delta first bit of 2 bit counter")
- print("db1 = (db1 ^ db0) & delta second bit of 2 bit counter")
- print("changes = ~(~delta | db0 | db1) if a change has happened")
- print("state = state ^ changes state of the debouncer")
- print("-----------")
- print("{:5} {:5} {:5} {:5} {:5} {:5}".format("samp", "delta", "db0", "db1", "chngs", "state"))
- for s in samp:
- delta = s ^ state
- db1 = (db1 ^ db0 ) & delta
- db0 = ~(db0) & delta
- changes = ~(~delta | db0 | db1)
- state ^= changes
- print("{:5} {:5} {:5} {:5} {:5} {:5}".format(s, delta, db0, db1, changes, state))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement