Hallo Allemaal,
Alvast een voor proefje
Met yaesu ft817 en cat62 kabel is een max232 nodig denk ik
Aangesloten op pin 0 en 1
Dus moet er af als je wilt programmeren via de USB<>PC
Nu nog op zoek naar een geschilkt Display
Dat moet een pixel display zijn denk ik dus geen Alfa nummeriek display
Setupje voor de FT817 Arduino Code.
Alleen nog aan de slag in de GFXDisplay() routine
Alle verzamelde Smeter values staan in arrS[]
Alle hulp en commentaar welkom !!!!
Code:
/* PA3BNX FT817 S-meter
* 12-10-2016
* 13-10-2016
* I understand that the Arduino Uno and Nano have just one UART
* so we must connect a max232 on pin 0 and 1
* Todo communication to the FT817 with Cat62 Yaesu Cable
* One INPUT pin with button for Reset The S meter display
*/
//Integer
const int cDelayTime=1000;
const byte cUarray=100;
const byte cEmpty=255;
const byte cResetPin=2;
//String
String inputString;
//Bool
bool bStringComplete;
//Array
byte arrS[cUarray];
//Functions
void AddNewSmeter(byte s)
{
static int c;
//With 255 just reset pointer
if (s==cEmpty) {c=0;return;}
c+=1;
if (c>cUarray)
{
for (byte i=1;i<cUarray;i++)
{
arrS[i-1]=arrS[i];
}
c=cUarray;
}
arrS[c]=s;
}//Last StoreSmeter
void AskFreqFT817()
{
//Read RX Status
//x,x,x.x,e7 (231)
byte buf[]={0,0,0,0,231};
Serial.write(buf,5);
}//Last Ask
void ClearSmeter()
{
for (int i=0;i<cUarray;i++)
{
arrS[i]=cEmpty;
}
}//Last ClearSmeter
byte ExtractFT817Smeter(String MyString)
{
//Not ready yet
//Read RX Status
//x,x,x.x,f7 (247)
//76543210
//3210=S meter data
//7=Squels
byte x;
byte buf[5];
MyString.getBytes(buf,5);
if (buf[4]==247)
{
if (buf[0] && 1) {x+=1;}
if (buf[0] && 2){x+=2;}
if (buf[0] && 4){x+=4;}
if (buf[0] && 8){x+=8;}
//x ranges between 0 and 15
return x;
}
return cEmpty;
}//Last ExtractFT817Smeter
void SerialEvent()
{
while (Serial.available()) {
//get the new byte:
byte inByte=(byte)Serial.read();
if (inputString.length() > 4 )
{
bStringComplete=true;
}
else
{
//add it to the inputString:
inputString+=inByte;
}
}
}//Last SerialEvent
void GFXDisplay()
{
//Show here the Values in arrS[]
//On a Display
for (byte i=0;i<cUarray;i++)
{
if (arrS[i]=cEmpty){return;}
//Draw here values from arrS[]
}
}//Last GFXDisplay
void setup() {
// put your setup code here, to run once:
Serial.begin(4800);
pinMode(13,OUTPUT);//Led 13 as Received Cat-ft817 cmd
pinMode(cResetPin,INPUT_PULLUP);
ClearSmeter();
AddNewSmeter(cEmpty);
}
void loop() {
// put your main code here, to run repeatedly:
byte count;
AskFreqFT817();
SerialEvent();
delay(cDelayTime);
tryagain:
if (bStringComplete==true)
{
digitalWrite(13,HIGH);//Something RXed
if (digitalRead(cResetPin)==LOW)
{
ClearSmeter();
AddNewSmeter(cEmpty);
GFXDisplay();
}
if (inputString != "")
{
byte s = ExtractFT817Smeter(inputString);
AddNewSmeter(s);
GFXDisplay();
}
digitalWrite(13,LOW);//Processed Something RXed
}
else
{
//Try max 10 times before ask for new Smeter
count+=1;
if (count<10)
{
//Wait for RXed data
SerialEvent();
goto tryagain;
}
}//Last bStringComplete
inputString="";
bStringComplete=false;
count=0; //Not needed I think because loop starts again
}//Last Loop