Saturday, June 30, 2018

arduino radio TEA5767

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

Saturday, June 23, 2018

How to draw pixel, circle, rect, fillrect,roundrect with oled arduino?

if you new how to install oled and how install libraries adafruide please check this link.

Arduino oled adafruit display

below this syntax how to drawpixel, drawcicle, drawfillrec, drawroundrect

Syntax:
Adafruit_SSD1306 oled(RS_pin)
Parameters:
RS_pin:reset pin
RS_pin= LED_BUILTIN (It's using without reset out site)

Syntax:
oled.begin(address)
Parameters:
address: address of oled in bus l2C

Syntax:
oled.display() (Show logo adafruit)

Syntax:
oled.clear.Display() (Clearn screen on oled)

Syntax.
oled.drawPixel(x,y,color)
Parameter:
x: position horizontal on screen oled
y: position vertical on screen oled
color : white/black

Syntax
oled.drawCircle(x,y,r,color);(it's using for draw circle position x,y have radius)
parameter:
x: position horizontal on screen oled
y: position vertical on screen oled
r: radius
color: white/black

Syntax:
oled.drawRect(x,y,w,h,color)
parameter:
x:position horizontal on screen oled
y:position vertical on screen oled
w:width of your rectal on screen
h:high of your rectal on screen

Syntax
oled.fillrect(x,y,w,h,color);
description: it's rectal have fill in side.
parameter:
x:position horizontal on screen oled
y:position vertical on screen oled
w:width of your rectal on screen
h:high of your rectal on screen

Synaxt
oled. drawRoundRect(x,y,w,h,r,color);
Description: it's using for draw round rectal on screen oled
parameter:
x:position horizontal on screen oled
y:position vertical on screen oled
w:width of your rectal on screen
r:radius filled
h:high of your rectal on screen

syntax:
oled.fillRoundRect(x,y,w,h,r,color)
description: draw fill rectal round
x:position horizontal on screen oled
y:position vertical on screen oled
w:width of your rectal on screen
r:radius filled
h:high of your rectal on screen

syntax:
oled.drawTriangle(x1,y1,x2,y2,x3,y3,color)
description draw triangle

syntax
oled.filltriangle(x1,y1,x2,y2,x3,y3,color)
description draw traingle have fill

syntax
oled.drawLine(x1,y1,x2,y2,color)
description it's using fro drawing line

it you not yet install about syntax and my description how to using code please don't worry below this color I summary all syntax i was talking about. :)



#include <Adafruit_SSD1306.h>           // call libralies
Adafruit_SSD1306 oled(LED_BUILTIN);     //define oled fuction
void setup() {
  // put your setup code here, to run once:
oled.begin(0x3c);                       //oled begin on address i2c
oled.display();                         // display adafruid
delay(1000);                            // waiting 1sec



}

void loop() {
  // put your main code here, to run repeatedly:
oled.clearDisplay();                      // oled clear screen
oled.drawPixel(64,31,WHITE);              //drawing pixel x64 y31 color white
oled.display();                           //display drawpixel
delay(1000);                              //waiting 3sec

oled.clearDisplay();                      // oled clear screen
oled.drawCircle(64,31,30,WHITE);          // draw circle x:64 y:31 r:30 color:white
oled.display();
delay(1000);

oled.clearDisplay();                      // oled clear screen
oled.drawRect(64,31,30,30,WHITE);         // draw rectal on oled  x:64 y:31 w:30 h:30 color:white
oled.display();                           // display rectal on oled
delay(1000);                              // waiting 3sec

oled.clearDisplay();                      // oled clear screen
oled.fillRect(64,31,30,30,WHITE);         // fill rectal on oled  x:64 y:31 w:30 h:30 color:white
oled.display();                           // display rectal on oled
delay(1000);                              // waiting 3sec

oled.clearDisplay();                      // oled clear screen
oled.drawRoundRect(64,31,30,30,5,WHITE);  // draw round rectal  x:64 y:31 w:30 h:30 r:5 color:white
oled.display();                           // display rectal on oled
delay(1000);                              // waiting 3sec

oled.clearDisplay();                      // oled clear screen
oled.fillRoundRect(64,31,30,30,5,WHITE);  // fill round rect on oled  x:64 y:31 w:30 h:30 r:5 color:white
oled.display();                           // display rectal on oled
delay(1000);                              // waiting 3sec

oled.clearDisplay();                      // oled clear screen
oled.drawTriangle(50,120,50,5,5,31,WHITE);  // fill round rect on oled  x:64 y:31 w:30 h:30 r:5 color:white
oled.display();                           // display rectal on oled
delay(1000);                              // waiting 3sec

oled.clearDisplay();                      // oled clear screen
oled.fillTriangle(50,120,50,5,5,31,WHITE);  // fill round rect on oled  x:64 y:31 w:30 h:30 r:5 color:white
oled.display();                           // display rectal on oled
delay(1000);                              // waiting 3sec

oled.clearDisplay();                      // oled clear screen
oled.drawLine(50,120,50,5,WHITE);  // fill round rect on oled  x:64 y:31 w:30 h:30 r:5 color:white
oled.display();                           // display rectal on oled
delay(1000);                              // waiting 3sec

}

Arduino oled adafruit display

in order to using with download library of Adaftruit please download below link
https://github.com/adafruit/adafruit_ssd1306

after that please open your arduino and then upload your zib library.
Sketch> Include Library > Add .zip library