Advertisement
Guest User

TEF6686.h

a guest
Dec 27th, 2019
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.12 KB | None | 0 0
  1.   #if defined(ARDUINO) && ARDUINO >= 100
  2.       #include "Arduino.h"
  3.     #else
  4.       #include "WProgram.h"
  5.     #endif
  6.  
  7.  
  8. #ifndef TEF6686_h
  9. #define TEF6686_h
  10.  
  11. #include <Wire.h>
  12.  
  13. #include "Tuner_Api.h"
  14. #include "Tuner_Drv_Lithio.h"
  15. #include "Tuner_Interface.h"
  16.  
  17. #define I2C_PORT 2
  18. #define I2C_ADDR 0x64
  19. #define I2C_FAST_MODE 0x2
  20.  
  21. typedef struct RdsInfo {
  22.   char programType[17];
  23.   char programService[9];
  24.   char programServiceUnsafe[9];
  25.   char programId[5];
  26.   char radioText[65];
  27.   bool newRadioText;
  28. };
  29.  
  30. class TEF6686 {
  31.   public:
  32.     TEF6686();
  33.     uint8_t init();
  34.     void powerOn();                 // call in setup
  35.     void powerOff();               
  36.     void setFrequency(uint16_t frequency);    // frequency as int, i.e. 100.00 as 10000
  37.     uint16_t getFrequency(); // returns the current frequency
  38.     uint16_t getLevel();
  39.     uint8_t getStereoStatus();
  40.     uint16_t seekUp();      // returns the tuned frequency or 0
  41.     uint16_t seekDown();    // returns the tuned frequency or 0
  42.     uint16_t tuneUp();      // returns the tuned frequency or 0
  43.     uint16_t tuneDown();    // returns the tuned frequency or 0
  44.     void setVolume(uint16_t volume);    //-60 -- +24 dB volume
  45.     void setMute();
  46.     void setUnMute();
  47.     bool readRDS();
  48.     void getRDS(RdsInfo* rdsInfo);
  49.     void clearRDS();
  50.      
  51.   private:
  52.     uint16_t seek(uint8_t up);
  53.     uint16_t tune(uint8_t up);
  54.     void rdsFormatString(char* str, uint16_t length);
  55.  
  56.     char rdsRadioText[65];
  57.     char rdsProgramService[9];
  58.     char rdsProgramServiceUnsafe[9];
  59.     char rdsProgramId[5];
  60.     uint8_t rdsAb;
  61.     char rdsProgramType[17];
  62.     uint8_t isRdsNewRadioText;
  63.  
  64.     // 0: working with PS A, 1: working with PS B
  65.     bool psAB;
  66.     // first dimension: ps A, ps B, second dimension: PS characters
  67.     char unsafePs[2][8];
  68.     // 4 bit groups, 1111: no data, 0000: no error, 0001: small error, 0010, 0011: large error
  69.     uint32_t psErrors = 0xFFFFFFFF;
  70.     // 4 bit groups: ps A, B blocks (0-3) is set
  71.     uint8_t psCharIsSet = 0;
  72.     // previous address (if prev address greater than current, change psAB status)
  73.     uint8_t prevAddress = 3;
  74. };
  75.  
  76. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement