Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getBits its 78 bytes too big #32

Open
ruenahcmohr opened this issue Feb 12, 2019 · 0 comments
Open

getBits its 78 bytes too big #32

ruenahcmohr opened this issue Feb 12, 2019 · 0 comments

Comments

@ruenahcmohr
Copy link

resolved with the following function...
and obviously the creation of WordData in the struct.

uint8_t Talkie::getBits(uint8_t bits) {
uint8_t value = 0;
for (; bits; WordDataBit--, WordData >>= 1, bits--) {
value <<= 1; // NULL on first pass
if (!WordDataBit) { // regular byte rollover junk...
WordData = pgm_read_byte(WordDataPointer);
WordDataPointer++;
WordDataBit = 8;
}
value |= (WordData & 0x01); // OR a 1 into value if the MSB of WordData is set
}
return value;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant