download Libraries
https://github.com/big12boy/TEA5767
code
//#include <Wire.h>
#include <TEA5767.h>
TEA5767 radio=TEA5767();
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(LED_BUILTIN);
//User changable
short minlvl=14 ;//required signal level(0-5=unuseable,6-9=poor,10-12=good,13-14=really good, 15=execellent)
void setup() {
oled.begin(0x3c);
//oled.display();
oled.clearDisplay();
// put your setup code here, to run once:
Serial.begin(9600); //Initial Serical connection
Serial.setTimeout(100);
radio.init(minlvl); //initial needet features and search for station
//print the result
Serial.println("Radio Command Info ");
Serial.println("s :command scant frequency ");
Serial.println("n :command change next frequency ");
Serial.println("fn :command change frequency number ");
Serial.print ("Found(");
Serial.print(radio.getStations()); //get number of station from Library
Serial.println(")Station(s):");
oled_display(radio.getStations(),radio.getFrequency());
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()>0){
String cmd = Serial.readString();
if (cmd="s"){
listStation();
oled_display(radio.getStations(),radio.getFrequency());
}
if (cmd="n"){
radio.nextStation();
oled_display(radio.getStations(),radio.getFrequency());
}
if (cmd="f"){
float frequency=cmd.substring(1).toFloat();
Serial.println("Charge Freq:"+ String(frequency));
radio.setFrequency(frequency);
oled_display(radio.getStations(),frequency);
}
}
}
void listStation(){
short stations=radio.getStations();
for(short i=0;i<stations;i++){
delay(50);
printStation();
radio.nextStation();
}
}
void printStation(){
Serial.print("Frequency:");
Serial.println(radio.getFrequency()); //print frequency
Serial.print("Signallevel:");
Serial.println(radio.getSignalLevel());
Serial.println();
}
//oled_display(radio.getStations(),radio.getFrequency())
void oled_display(float allch,float freq){
oled.clearDisplay();
oled.setTextSize(2);
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.print("Radio");
oled.setTextSize(1);
oled.setCursor(0,20);
oled.print("All Freq:");
oled.setCursor(60,20);
oled.print(allch);
oled.setCursor(0,30);
oled.print("On Freq:");
oled.setCursor(60,30);
oled.print(freq);
oled.display();
}
https://github.com/big12boy/TEA5767
code
//#include <Wire.h>
#include <TEA5767.h>
TEA5767 radio=TEA5767();
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(LED_BUILTIN);
//User changable
short minlvl=14 ;//required signal level(0-5=unuseable,6-9=poor,10-12=good,13-14=really good, 15=execellent)
void setup() {
oled.begin(0x3c);
//oled.display();
oled.clearDisplay();
// put your setup code here, to run once:
Serial.begin(9600); //Initial Serical connection
Serial.setTimeout(100);
radio.init(minlvl); //initial needet features and search for station
//print the result
Serial.println("Radio Command Info ");
Serial.println("s :command scant frequency ");
Serial.println("n :command change next frequency ");
Serial.println("fn :command change frequency number ");
Serial.print ("Found(");
Serial.print(radio.getStations()); //get number of station from Library
Serial.println(")Station(s):");
oled_display(radio.getStations(),radio.getFrequency());
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()>0){
String cmd = Serial.readString();
if (cmd="s"){
listStation();
oled_display(radio.getStations(),radio.getFrequency());
}
if (cmd="n"){
radio.nextStation();
oled_display(radio.getStations(),radio.getFrequency());
}
if (cmd="f"){
float frequency=cmd.substring(1).toFloat();
Serial.println("Charge Freq:"+ String(frequency));
radio.setFrequency(frequency);
oled_display(radio.getStations(),frequency);
}
}
}
void listStation(){
short stations=radio.getStations();
for(short i=0;i<stations;i++){
delay(50);
printStation();
radio.nextStation();
}
}
void printStation(){
Serial.print("Frequency:");
Serial.println(radio.getFrequency()); //print frequency
Serial.print("Signallevel:");
Serial.println(radio.getSignalLevel());
Serial.println();
}
//oled_display(radio.getStations(),radio.getFrequency())
void oled_display(float allch,float freq){
oled.clearDisplay();
oled.setTextSize(2);
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.print("Radio");
oled.setTextSize(1);
oled.setCursor(0,20);
oled.print("All Freq:");
oled.setCursor(60,20);
oled.print(allch);
oled.setCursor(0,30);
oled.print("On Freq:");
oled.setCursor(60,30);
oled.print(freq);
oled.display();
}
No comments:
Post a Comment