Hello Every Body
I am stil working on the so called foxcopter.
Not ready yet
But also playing with a LCD5110
witch could be used as Pelorus display
or even a Smeter History for mij FT817
So this is a help for beginner arduino graphics also..
/*
* Klooi Pelorus File voor testen enzo PA3BNX met Nokia LCD5110 en Arduino Nano
* 06-07-2018
*/
/*********************************************************************
This is an example sketch for our Monochrome Nokia 5110 LCD Displays
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/338
These displays use SPI to communicate, 4 or 5 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
// Software SPI (slower updates, more flexible pin options):
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
// Hardware SPI (faster, but must use certain hardware pins):
// SCK is LCD serial clock (SCLK) - this is pin 13 on Arduino Uno
// MOSI is LCD DIN - this is pin 11 on an Arduino Uno
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
// Adafruit_PCD8544 display = Adafruit_PCD8544(5, 4, 3);
// Note with hardware SPI MISO and SS pins aren't used but will still be read
// and written to during SPI transfer. Be careful sharing these pins!
int t = 200;
void Pelorus(int d){
//Float
const float rad =PI/180 ; //0.017453292
float q;
//Int
static int OldDegrees = 999;
//Integer
int xc = display.width()/2 -1;
int yc = display.height()/2-1;
int r = yc-2;
byte y;
int s,ss;
//Nothing ToDo
if (OldDegrees==d)
{
return;
}
display.clearDisplay();
display.drawCircle(xc,yc,yc,BLACK);
if (d==999)
{
display.fillCircle(xc,yc,2,BLACK); //Just a Center dot now
}
else
{
q = (d-90) * rad;
s = xc + int(cos(q)*r);
ss = yc + int(sin(q)*r);
display.drawLine(xc,yc,s,ss,BLACK);
//Text print
if (d > 270 || d < 90)
{
y=yc+3;
}
else
{
y=yc-10;
}
display.setTextSize(1);
display.setCursor(xc-9,y);
display.println(Format3Degrees(d));
}
display.display();
OldDegrees=d;//Backup now
Serial.println(d);
}
String Format3Degrees(int d){
String str;
int digits[3];
int reminder;
digits[0]=d/100;
reminder=d%100;
digits[1]=reminder/10;
reminder=reminder%10;
digits[2]=reminder;
//str+='%';
str+=digits[0];
str+=digits[1];
str+=digits[2];
return str;
}
void setup(){
Serial.begin(9600);
display.begin();
// init done
// you can change the contrast around to adapt the display
// for the best viewing!
display.setContrast(50);
}
void loop(){
Pelorus(999);
delay(500);
for (int i=0;i<800;i++)
{
Pelorus(random(0,360));
delay(100);
}
delay(250);
}
/*
* ===============================
*((C))PA3BNX FT817 Smeter History
* with Nokia LCD5110 Display
* 06-07-2018
*/
#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <Adafruit_PCD8544.h>
// Software SPI (slower updates, more flexible pin options):
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
//Int
int t = 2000;
void Demo()
{
SmeterHistoryFT817(16); //Reset
for (int i = 0;i<368;i++)
{
if (i >= 100 && i< 150)
{
SmeterHistoryFT817(11);
}
else
{
SmeterHistoryFT817(random(0,15));
}
delay(70);
}
}//Last Demo
void SmeterHistoryFT817(byte rssi)
//ToDo try to draw
{
const int UboundArr=168;
static byte Smeter[UboundArr];
static int count=0;
int i;
if (rssi==16){
count = 0 ;
for (i=0 ; i < UboundArr-i ; i++)
{
Smeter[i]=0;
}
display.clearDisplay();
display.display();
return;
}
if (count<UboundArr)
{
Smeter[count]=rssi;
count ++;
}
else
{
for (int i=1;i<UboundArr;i++)
{
Smeter[i-1]=Smeter[i];
}
Smeter[UboundArr-1]=rssi;
}
display.clearDisplay();//Clear Buffer
for ( i=0;i<count ;i++)
{
if (i > UboundArr/2)
{
//Lower
display.drawLine(i-UboundArr/2 ,display.height()-1,i-UboundArr/2,display.height()-1 - Smeter[i], BLACK);
}
else
{
//Upper
display.drawLine(i,display.height()/2,i,display.height()/2 -Smeter[i],BLACK);
}
}
display.display();//Show Now
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
display.begin();
// init done
// you can change the contrast around to adapt the display
// for the best viewing!
display.setContrast(50);
display.clearDisplay();
display.setCursor(0,12);
display.setTextSize(1);
display.println(F("((C))PA3BNX"));
display.setTextSize(2);
display.println(F("FT817"));
display.println(F("S-Meter"));
display.display();
delay(2000);
}
void loop() {
// put your main code here, to run repeatedly:
Demo();
delay(t);
}