paragliding detection system
About  Build  Blog  Drones  Register/Log In  Downloads  Videos  Images  Contact  Links
paragliding detection system



paragliding system


Kobo Sounds


As we all know the kobo is an amazing bit of kit to fly with but unfortunately we have no sounds, sounds are extremely useful for warnings, flying into airspace is extremely easy to do if your concentrating on thermalling and forget to keep checking where you are!

A simple solution is to add a small development board and a piezo buzzer, the following page shows how to do this, its not very difficult to do, give it a go, cost is under £3.

You will need one of these :- Wemos D1 Mini, Piezo Buzzer (theres 3 here but always good for spares!) and some small gauge wire.

Navigate to the downloads page and download the Flasher and the binary for the sounds. Notice there are two, one for 9600 baud and one for 57600, an auto detect would be useful but havent got the time to write at the moment, so choose the correct one, if in doubt choose the 9600 one, check in your Device page in XCSoar or LK8000, it will tell you there.

Plug your Wemos D1 board into a micro usb lead into the PC and then run the flasher and upload the sounds binary, more info is on the Airware build pages if your having problems. (Build)

Wire up the D1 mini as the following diagram.



LK8000

Download the SOUND_TABLE.TXT file from the downloads page and copy it to _Configuration directory in LK8000 on the kobo, everything is case sensitive, take care. Load LK8000 and then config config, LK8000 setup, Device Setup. This page should now have a new field "Ext. Sound", change to On.

Hopefully now you will have sounds!

The current format for the sounds is as follows:-

GFPALARM

The number after the Alarm text is then added to 200+number times 13, this gives the frequency, the default duration is 200ms.

BSD

This is a chain of sounds, first one is frequency, next is duration, repeat

For example

BSD 392 200 784 200 392 200 900 200

is frequency 392 for 200 ms and then 784 for 200ms etc etc.

XCSoar

The guys at blueflyvario have put something together for this, please follow this page

Code

If you wish to change anything the code is as follows :- (it isnt perfectly written, but works fine)



#include "ESP8266WiFi.h"
extern "C" {
#include <user_interface.h>
#include "Esp.h"
}


/* ==== Defines ==== */
#define SERIAL_BAUD 9600
#define GFPALARM_LENGTH 200
#define GFPALARM_BASE_FREQUENCY 200
#define GFPALARM_SCALE 13
/* ==== END Defines ==== */


int speakerPin = 13;

bool validSoundLine=false;
int incomingByte = 0;
char incomingChar;
String out;
int tuneIs[20][2]={0};
int noTones=0;
int currentTone=0;

bool isItNumeric ( String testString )
{

    for ( int i=0;i<testString.length();i++)
    {
      if (testString.charAt(i)=='0' || 
          testString.charAt(i)=='1' ||
          testString.charAt(i)=='2' ||
          testString.charAt(i)=='3' ||
          testString.charAt(i)=='4' ||
          testString.charAt(i)=='5' ||
          testString.charAt(i)=='6' ||
          testString.charAt(i)=='7' ||
          testString.charAt(i)=='8' ||
          testString.charAt(i)=='9')
      {
      }
      else
      {
        return false;
      }
    }
  return true;  
}

void setup()
{
  Serial.begin(SERIAL_BAUD);
  WiFi.mode(WIFI_OFF);
  WiFi.forceSleepBegin();
  wifi_set_sleep_type(MODEM_SLEEP_T);
}


void loop()
{

 if (currentTone>=noTones)
 {

   validSoundLine=false;
  
   if (  millis() > tuneIs[currentTone][1])
   {
    // Serial.println("tone off");
     tuneIs[currentTone][1]=0;
     noTones=0;
     currentTone=0;
     noTone(speakerPin);
     validSoundLine=false;
   }
 }

 if ( noTones>0 && validSoundLine)
 {
  if ( millis()>tuneIs[currentTone][1])
  {
    currentTone++;
    tone(speakerPin, tuneIs[currentTone][0]);
   }
 }
 
 if (Serial.available() > 0 )
 {
   incomingChar = Serial.read();
     
   if ( incomingChar == '\n' )
   {

     String line=out.substring(0,out.indexOf("*"));

     if ( line.substring(0,9)=="$GFPALARM" )
     {

       if (isItNumeric(line.substring(10)))
       {
         int toneNumber=line.substring(10).toInt();
         validSoundLine=true;
         toneNumber=(toneNumber*GFPALARM_SCALE)+GFPALARM_BASE_FREQUENCY;

         tuneIs[0][0]=toneNumber;
         tuneIs[0][1]=GFPALARM_LENGTH+millis(); 
      // start playing the first.
         tone(speakerPin, tuneIs[0][0]);
         currentTone=0;
         noTones=0; 
       }
       else
       {
        validSoundLine=false;
       }
       
     }
     if (line.substring(0,4)=="$BSD")
     {

       String bsdLine=line.substring(5);

       Serial.println(bsdLine);
       int currentChar=0;

       int tuneLength=0;
       int maxTones=10;

       int toneReading=0;
       int spaceIndex=0;

       validSoundLine=true;
       
       while( spaceIndex>=0 && currentTone<maxTones && validSoundLine)
       {
        
         spaceIndex=bsdLine.indexOf(" ",currentChar);

         String currS=bsdLine.substring(currentChar,spaceIndex);

         if (isItNumeric(currS))
         {
           // time to play tone
           if ( toneReading == 1 )
           {
             tuneIs[currentTone][toneReading]=tuneLength+currS.toInt()+millis(); 
             tuneLength=tuneLength+currS.toInt();
           }
           else
           {
            tuneIs[currentTone][toneReading]=currS.toInt();
           }
         
           currentChar=spaceIndex+1;
         
           if (toneReading==0)
           {
             toneReading=1;
             noTones++;
          }
           else
           {
             toneReading=0;
             currentTone++;
           }
         }
         else
         {
           validSoundLine=false;
         }
       }

      if (validSoundLine)
      {
      // start playing first tone and then check at top of loop for the next tone to change to.
        tone(speakerPin, tuneIs[0][0]);
     
        currentTone=0;
      // playing the first.
        noTones--;
      }
    }
     
     out="";
   }
   else
   {
     out=out+String(incomingChar);
   }
 }

 yield();
 // delay in to stop the board looping too fast and crashing.
 delay(5);
}








paragliding  system

paragliding detection system