Skip to content

Commit

Permalink
fix parity (esphome#4476)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuel Sieb <[email protected]>
2 people authored and jesserockz committed Feb 23, 2023
1 parent 3a36d0b commit 069b5f8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions esphome/components/wiegand/wiegand.cpp
Original file line number Diff line number Diff line change
@@ -38,8 +38,8 @@ void Wiegand::setup() {
bool check_eparity(uint64_t value, int start, int length) {
int parity = 0;
uint64_t mask = 1LL << start;
for (int i = 0; i <= length; i++, mask <<= 1) {
if (value & i)
for (int i = 0; i < length; i++, mask <<= 1) {
if (value & mask)
parity++;
}
return !(parity & 1);
@@ -48,8 +48,8 @@ bool check_eparity(uint64_t value, int start, int length) {
bool check_oparity(uint64_t value, int start, int length) {
int parity = 0;
uint64_t mask = 1LL << start;
for (int i = 0; i <= length; i++, mask <<= 1) {
if (value & i)
for (int i = 0; i < length; i++, mask <<= 1) {
if (value & mask)
parity++;
}
return parity & 1;

0 comments on commit 069b5f8

Please sign in to comment.