└── RadioEmbed └── RadioEmbed.ino /RadioEmbed/RadioEmbed.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "TFT_eSPI.h" 5 | #include 6 | 7 | 8 | TFT_eSPI tft = TFT_eSPI(); 9 | TFT_eSprite spr = TFT_eSprite(&tft); 10 | 11 | #define PIN_IN1 2 12 | #define PIN_IN2 1 13 | 14 | #define NUM_LEDS 7 15 | #define DATA_PIN 42 16 | #define CLOCK_PIN 45 17 | CRGB leds[NUM_LEDS]; 18 | 19 | RotaryEncoder encoder(PIN_IN1, PIN_IN2, RotaryEncoder::LatchMode::TWO03); 20 | 21 | 22 | #define color1 0xC638 23 | #define color2 0xC638 24 | 25 | int value=980; 26 | int minimal=880; 27 | int maximal=1080; 28 | int strength=0; 29 | String sta[6]={"96.6","101.0","89.4","106,5","98.2","92.4"}; 30 | 31 | float freq=0.00; 32 | TEA5767 radio = TEA5767(); 33 | 34 | bool muted=0; 35 | int deb=0; 36 | 37 | void setup() { 38 | 39 | pinMode(46, OUTPUT); 40 | digitalWrite(46, HIGH); 41 | 42 | tft.begin(); 43 | tft.writecommand(0x11); 44 | tft.setRotation(3); 45 | tft.fillScreen(TFT_BLACK); 46 | 47 | pinMode(15, OUTPUT); 48 | digitalWrite(15, HIGH); 49 | 50 | pinMode(0, INPUT_PULLUP); 51 | FastLED.addLeds(leds, NUM_LEDS); 52 | 53 | Wire.begin(43,44); 54 | 55 | 56 | spr.createSprite(320,170); 57 | spr.setTextDatum(4); 58 | spr.setSwapBytes(true); 59 | spr.setFreeFont(&Orbitron_Light_24); 60 | spr.setTextColor(color1,TFT_BLACK); 61 | 62 | leds[0] = CRGB::Red; 63 | leds[1] = CRGB::White; 64 | leds[2] = CRGB::Red; 65 | leds[3] = CRGB::Green; 66 | leds[4] = CRGB::Red; 67 | leds[5] = CRGB::Blue; 68 | leds[6] = CRGB::Red; 69 | FastLED.show(); 70 | drawSprite(); 71 | 72 | } 73 | 74 | void readEncoder() { 75 | 76 | static int pos = 0; 77 | encoder.tick(); 78 | 79 | if(digitalRead(0)==0){ 80 | if(deb==0){ 81 | deb=1; 82 | muted=!muted; 83 | radio.setMuted(muted); 84 | drawSprite(); 85 | delay(200); 86 | } 87 | }else deb=0; 88 | 89 | int newPos = encoder.getPosition(); 90 | if (pos != newPos) { 91 | 92 | if(newPos>pos) 93 | value=value-1; 94 | if(newPos