X-Git-Url: https://vault307.fbx.one/gitweb/micorpython_ir.git/blobdiff_plain/3bc46448ddca0bfdf3a98d96c3e9315159bf642b..3b6cfaf15ad930c34b0d7f87c6a841ea651ccccb:/ir_rx/print_error.py diff --git a/ir_rx/print_error.py b/ir_rx/print_error.py new file mode 100644 index 0000000..31ce51e --- /dev/null +++ b/ir_rx/print_error.py @@ -0,0 +1,19 @@ +# print_error.py Error print for IR receiver + +# Author: Peter Hinch +# Copyright Peter Hinch 2020 Released under the MIT license + +from ir_rx import IR_RX + +_errors = {IR_RX.BADSTART : 'Invalid start pulse', + IR_RX.BADBLOCK : 'Error: bad block', + IR_RX.BADREP : 'Error: repeat', + IR_RX.OVERRUN : 'Error: overrun', + IR_RX.BADDATA : 'Error: invalid data', + IR_RX.BADADDR : 'Error: invalid address'} + +def print_error(data): + if data in _errors: + print(_errors[data]) + else: + print('Unknown error code:', data)