Created
April 9, 2025 20:14
-
-
Save Wriar/51108d9e68d4cc6454ad403394111fc1 to your computer and use it in GitHub Desktop.
HID Wiegand Keypad Bit Decoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Translates the raw input bits from a HID keypad reader to decimal. | |
| int keypadBitToInteger(String inputBits) { | |
| int decimalValue = 0; | |
| int length = inputBits.length(); | |
| for (int i = 0; i < length; i++) { | |
| char bit = inputBits.charAt(i); | |
| if (bit == '1') { | |
| decimalValue = decimalValue * 2 + 1; | |
| } else if (bit == '0') { | |
| decimalValue = decimalValue * 2; | |
| } else { | |
| return -1; //Or whatever error code u want TBD | |
| } | |
| } | |
| return decimalValue; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment