FireFly 2012: behaviour rewrite now uses the hexapod library
From Electronics\Hexapod\Arduino sketches 2011-2012\FireFly. Data.h, Def.h and SerD.h moved into the library.
This commit is contained in:
1 parent
304367a769
commit
6e50819e01
9 files changed
+84
-465
No files matched your search
@@ -0,0 +1,60 @@
|
||||
//Ultrasone.cpp
|
||||
// V3.0
|
||||
|
||||
#include "Ultrasone.h"
|
||||
|
||||
void Ultrasone::GetRadar(Data *DataLine)
|
||||
{
|
||||
DataLine->HeadTime = 0;
|
||||
|
||||
#ifdef DEBUGUS
|
||||
Serial.print("### Ultrasone Direction/Position: ");
|
||||
Serial.print(CurrentDirection);
|
||||
Serial.print(", ");
|
||||
Serial.println(CurrentPosition);
|
||||
#endif
|
||||
|
||||
if (CurrentDirection == 0) // Left
|
||||
{
|
||||
if (CurrentPosition > MaxLeft)
|
||||
{
|
||||
CurrentPosition--;
|
||||
DataLine->HeadAngle = CurrentPosition;
|
||||
|
||||
Con.ConvertHead(DataLine);
|
||||
SSC32.MoveHead(DataLine);
|
||||
|
||||
Serial.print("### Ultrasone Distance: ");
|
||||
Serial.println(DataLine->FireFly.GetUltraSoneDistance());
|
||||
}
|
||||
else
|
||||
CurrentDirection = 1;
|
||||
}
|
||||
else if(CurrentDirection == 1) // Right
|
||||
{
|
||||
if (CurrentPosition < MaxRight)
|
||||
{
|
||||
CurrentPosition++;
|
||||
DataLine->HeadAngle = CurrentPosition;
|
||||
|
||||
Con.ConvertHead(DataLine);
|
||||
SSC32.MoveHead(DataLine);
|
||||
|
||||
Serial.print("### Ultrasone Distance: ");
|
||||
Serial.println(DataLine->FireFly.GetUltraSoneDistance());
|
||||
}
|
||||
else
|
||||
CurrentDirection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
[Vector]
|
||||
X = Distance / Cos( CurrentPosition * pi2rad );
|
||||
Y = Distance / sin( CurrentPosition / pi2rad );
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//Ultrasone.h
|
||||
// V3.0
|
||||
|
||||
#ifndef ULTRASONE_H
|
||||
#define ULTRASONE_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Data.h"
|
||||
#include "Servos.h"
|
||||
#include "Converter.h"
|
||||
|
||||
#define MaxLeft -45
|
||||
#define MaxRight 45
|
||||
|
||||
class Ultrasone
|
||||
{
|
||||
private:
|
||||
Servos SSC32;
|
||||
Converter Con;
|
||||
|
||||
public:
|
||||
void GetRadar(Data *DataLine);
|
||||
|
||||
int CurrentPosition;
|
||||
byte CurrentDirection;
|
||||
|
||||
Ultrasone()
|
||||
{
|
||||
CurrentPosition = 0;
|
||||
CurrentDirection = 0; // Left
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user