going-digital / Talkie

Speech library for Arduino
305 stars 113 forks source link

getBits its 78 bytes too big #32

Open ruenahcmohr opened 5 years ago

ruenahcmohr commented 5 years ago

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;
}