PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

50 lines
1.2KB

  1. // Talkie library
  2. // Copyright 2011 Peter Knight
  3. // This code is released under GPLv2 license.
  4. #ifndef _Talkie_h_
  5. #define _Talkie_h_
  6. #include <inttypes.h>
  7. #if defined(__AVR__) && !defined(TCCR2A)
  8. #error "Sorry, when using an AVR chip, Talkie requires Timer2. This board doesn't have it."
  9. #elif defined(__MK20DX128__)
  10. #error "Sorry, Talkie does not work with Teensy 3.0 (no DAC pin for audio output)."
  11. #endif
  12. #define SAY_BUFFER_SIZE 24 // 24 sets of 4 bytes plus added queue indexes is about 100 added bytes.
  13. class Talkie
  14. {
  15. public:
  16. void beginPWM(uint8_t pinPWM);
  17. void beginPropShield();
  18. void say(const uint8_t * address);
  19. int8_t sayQ(const uint8_t * address);
  20. const uint8_t * ptrAddr;
  21. uint8_t ptrBit;
  22. uint8_t active( void );
  23. uint8_t getBits(uint8_t bits);
  24. bool setPtr(const uint8_t * addr);
  25. bool say_add( const uint8_t *addr ); // sayisr() calls this
  26. const uint8_t * say_remove(); // sayisr() calls this
  27. private:
  28. // Say queue
  29. const uint8_t * say_buffer[SAY_BUFFER_SIZE];
  30. uint8_t head; // init on setup = 0
  31. uint8_t tail; // init on setup = 0
  32. uint8_t free; // init on setup = SAY_BUFFER_SIZE
  33. // Setup
  34. uint8_t setup;
  35. // Bitstream parser
  36. uint8_t rev(uint8_t a);
  37. };
  38. #endif