Пример #1
0
Bool SmplMatrixDialog::InitValues(void)
{
	SetInt32(GADGET_SMPL_MATRIX_DOCUMENT_PREVIEW, document_preview);
	SetInt32(GADGET_SMPL_MATRIX_TEXTURE_MODE, settings->tile_flags == TILE_REPEAT_BORDER ? 0 : 1);

	SetPercent(GADGET_SMPL_MATRIX_SLIDER_MIX, settings->matrix_opacity, 0.0, 100.0, 0.1);
	SetFloat(GADGET_SMPL_MATRIX_SLIDER_ANGLE, Rad(settings->angle), Rad(MIN_ANGLE), Rad(MAX_ANGLE), Rad(STEP_ANGLE), FORMAT_DEGREE);
	SetInt32(GADGET_SMPL_MATRIX_TYPE_POPUP, settings->type);

	return true;
}
void VectorTest::updateFromSliders(){

	// Calculate
	Vector2D p(sliderX->value(), sliderY->value());
	//Trafo2D t = Trafo2D::trans(sliderX->value(), sliderY->value()) * Trafo2D::rot(Rad(sliderRotation->value())) ;
	t = Trafo2D::rot(Rad(sliderRotation->value())) * Trafo2D::trans(sliderX->value(), sliderY->value());
	//Trafo2D t = Trafo2D::trans(sliderX->value(), sliderY->value());
	//Trafo2D t = Trafo2D::rot(Rad(sliderRotation->value())) ;

//	for (int j = 0; j < 3; j++){
//		for (int k = 0; k < 3; k++){
//			std::cout << " " << t.Data[j][k];
//		}
//		std::cout << std::endl;
//	}
//	std::cout << std::endl;
//


	//p = Trafo2D::rot(30) * p;
	//r.rot(20);
	//p = r*p;


	draw();

}
Пример #3
0
int All_Date_Time(double jd, const tm* pTM)
{
    //cout<<"Current JD is "<<jd<<endl;
    //cout<<"GMT is: "<<pTM->tm_hour<<":"<<pTM->tm_min<<":"<<pTM->tm_sec<<endl;
    //cout<<"GMT Date-time is: "<<asctime (pTM)<<endl;
    double ThetaZero=ThetaG_JD(jd);                 // in radians

    double YLlong =Rad(242.210911);

    double LMST=fmod(ThetaZero+YLlong,TWO_PI);         // radians
/****************************************
radians to HMS
2pi 360 degrees
15 degrees per hour
86400 seconds per day(24*60*60)
*****************************************/
    double H,M,S;

    double LMST_HMS=LMST*((360/TWO_PI))/15;
    H=LMST_HMS;

    double param, fractpart, intpart;
    param = H;
    fractpart = modf (param , &intpart);
    M=fractpart*60;
    param=M;
    fractpart = modf (param , &intpart);
    S=fractpart*60;
    //cout<<"LMST= \t"<<(int)H<<":"<<(int)M<<":"<<S<<endl;

    return 0;
}
ExpectedMovementTracker::ExpectedMovementTracker(Core *core, long x, long y, double rotation) : MovementTracker("Expected", core) {
	transformation = Trafo2D::trans(x,y) * Trafo2D::rot(Rad(rotation)); // Core/COIL has a clockwise positive rotation while the math library has a anti-clockwise rotation...
	lastGetDistanceTimestamp = QTime();
	lastGetAngleTimestamp = QTime();
	wheelSpeed = Vector2D(0,0);
	weight = 1;
}
Пример #5
0
Trade::MeshData3D Capsule3D::solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords) {
    CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}));

    Implementation::Spheroid capsule(segments, textureCoords == TextureCoords::Generate ?
        Implementation::Spheroid::TextureCoords::Generate :
        Implementation::Spheroid::TextureCoords::DontGenerate);

    Float height = 2.0f+2.0f*halfLength;
    Float hemisphereTextureCoordsVIncrement = 1.0f/(hemisphereRings*height);
    Rad hemisphereRingAngleIncrement(Constants::pi()/(2*hemisphereRings));

    /* Bottom cap vertex */
    capsule.capVertex(-height/2, -1.0f, 0.0f);

    /* Rings of bottom hemisphere */
    capsule.hemisphereVertexRings(hemisphereRings-1, -halfLength, -Rad(Constants::pi())/2+hemisphereRingAngleIncrement, hemisphereRingAngleIncrement, hemisphereTextureCoordsVIncrement, hemisphereTextureCoordsVIncrement);

    /* Rings of cylinder */
    capsule.cylinderVertexRings(cylinderRings+1, -halfLength, 2.0f*halfLength/cylinderRings, 1.0f/height, 2.0f*halfLength/(cylinderRings*height));

    /* Rings of top hemisphere */
    capsule.hemisphereVertexRings(hemisphereRings-1, halfLength, hemisphereRingAngleIncrement, hemisphereRingAngleIncrement, (1.0f + 2.0f*halfLength)/height+hemisphereTextureCoordsVIncrement, hemisphereTextureCoordsVIncrement);

    /* Top cap vertex */
    capsule.capVertex(height/2, 1.0f, 1.0f);

    /* Faces */
    capsule.bottomFaceRing();
    capsule.faceRings(hemisphereRings*2-2+cylinderRings);
    capsule.topFaceRing();

    return capsule.finalize();
}
Пример #6
0
Trade::MeshData3D UVSphere::solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords) {
    CORRADE_ASSERT(rings >= 2 && segments >= 3, "UVSphere must have at least two rings and three segments", Trade::MeshData3D(Mesh::Primitive::Triangles, {}, {}, {}, {}));

    Implementation::Spheroid sphere(segments, textureCoords == TextureCoords::Generate ?
        Implementation::Spheroid::TextureCoords::Generate :
        Implementation::Spheroid::TextureCoords::DontGenerate);

    Float textureCoordsVIncrement = 1.0f/rings;
    Rad ringAngleIncrement(Constants::pi()/rings);

    /* Bottom cap vertex */
    sphere.capVertex(-1.0f, -1.0f, 0.0f);

    /* Vertex rings */
    sphere.hemisphereVertexRings(rings-1, 0.0f, -Rad(Constants::pi())/2+ringAngleIncrement, ringAngleIncrement, textureCoordsVIncrement, textureCoordsVIncrement);

    /* Top cap vertex */
    sphere.capVertex(1.0f, 1.0f, 1.0f);

    /* Faces */
    sphere.bottomFaceRing();
    sphere.faceRings(rings-2);
    sphere.topFaceRing();

    return sphere.finalize();
}
Пример #7
0
void RoboPult::RadS()
  {
   askStena->setChecked(false);	
   askFree->setChecked(false);
      switchButt();
  emit Rad();
  };
Пример #8
0
void StructureMap::registerObjectDetected(double distance, double angle, double opacity, int size) {
	if (finish) return;
	Trafo2D objectLocation = create->tracker->getTransformation() * Trafo2D::rot(Rad(angle)) * Trafo2D::trans(0, distance);

	Vector2D p = Vector2D(objectLocation.trans().x(),objectLocation.trans().y());

	appendPoint(p);

}
Пример #9
0
/*====================================================================================================*/
void AHRS_GetQ( Quaternion *pNumQ )
{
  fp32 ErrX, ErrY, ErrZ;
  fp32 AccX, AccY, AccZ;
  fp32 GyrX, GyrY, GyrZ;
	fp32 Normalize;
  static fp32 exInt = 0.0f, eyInt = 0.0f, ezInt = 0.0f;
	Gravity V;
	
	// 加速度归一化
	Normalize = Q_rsqrt(squa(sensor.acc.averag.x)+ squa(sensor.acc.averag.y) +squa(sensor.acc.averag.z));
	AccX = sensor.acc.averag.x*Normalize;
  AccY = sensor.acc.averag.y*Normalize;
  AccZ = sensor.acc.averag.z*Normalize;

	// 提取重力分量
	V = Quaternion_vectorGravity(&NumQ);
	
	// 向量差乘
 	ErrX = (AccY*V.z - AccZ*V.y);
  ErrY = (AccZ*V.x - AccX*V.z);
  ErrZ = (AccX*V.y - AccY*V.x);
 	
 	exInt = exInt + ErrX * KiDef;
  eyInt = eyInt + ErrY * KiDef;
  ezInt = ezInt + ErrZ * KiDef;

  GyrX = Rad(sensor.gyro.averag.x) + KpDef * VariableParameter(ErrX) * ErrX  +  exInt;
  GyrY = Rad(sensor.gyro.averag.y) + KpDef * VariableParameter(ErrY) * ErrY  +  eyInt;
	GyrZ = Rad(sensor.gyro.averag.z) + KpDef * VariableParameter(ErrZ) * ErrZ  +  ezInt;
	
	
	// 一阶龙格库塔法, 更新四元数
	Quaternion_RungeKutta(&NumQ, GyrX, GyrY, GyrZ, SampleRateHalf);
	
	// 四元数归一化
	Quaternion_Normalize(&NumQ);
}
Пример #10
0
void Game::mouseMoveEvent(AbstractScreen::MouseMoveEvent& event) {
    /** @todo mouse sensitivity */
    player->normalizeRotation()->rotateY(-Rad((Constants::pi()*event.relativePosition().x()/500.0f)),
        SceneGraph::TransformationType::Local);

    Rad angle(-Constants::pi()*event.relativePosition().y()/500.0f);
    Matrix4 xRotation = Matrix4::rotationX(angle)*camera->transformation();

    /* Don't rotate under the floor */
    if(Math::abs(Vector3::dot(xRotation.rotation()*Vector3::yAxis(), Vector3(0.0f, 1.0f, -1.0f).normalized())) > 0.75f)
        camera->normalizeRotation()->rotateX(angle);

    event.setAccepted();
    redraw();
}
void WireframeSpheroid::ring(const Float y) {
    /* Ring vertices and indices */
    const Rad segmentAngleIncrement(Constants::piHalf()/_segments);
    for(UnsignedInt j = 0; j != _segments; ++j) {
        for(UnsignedInt i = 0; i != 4; ++i) {
            const Rad segmentAngle = Rad(Float(i)*Constants::piHalf()) + Float(j)*segmentAngleIncrement;
            if(j != 0) _indices.insert(_indices.end(), {UnsignedInt(_positions.size()-4), UnsignedInt(_positions.size())});
            _positions.emplace_back(Math::sin(segmentAngle), y, Math::cos(segmentAngle));
        }
    }

    /* Close the ring */
    for(UnsignedInt i = 0; i != 4; ++i)
        _indices.insert(_indices.end(), {UnsignedInt(_positions.size())-4+i, UnsignedInt(_positions.size())-4*_segments+(i+1)%4});
}
Пример #12
0
void RemainingTargets::animationStep(Float time, Float) {
    scale = 1.0f + Math::sin(Rad(Constants::pi()*time/duration()))*0.35f;
}
Пример #13
0
void INDIMountInterface::SkyChart_Paint( Control& sender, const Rect& updateRect )
{
   Graphics g( sender );

   RGBA darkRed = RGBAColor( 153, 0, 0 );
   RGBA darkYellow = RGBAColor( 153, 153, 0 );
   RGBA darkGreen = RGBAColor( 0, 153, 0 );

   Rect r( sender.BoundsRect() );

   int w = r.Width();
   int h = r.Height();
   int x0 = w >> 1;
   int y0 = h >> 1;

   g.FillRect( r, 0u );
   g.SetBrush( Brush::Null() );

   g.SetPen( darkRed );
   const int margin = 10;
   g.DrawLine( x0, 0+margin, x0, h-margin );
   g.DrawLine( 0+margin, y0, w-margin, y0 );

   g.EnableAntialiasing();

   if ( m_isAllSkyView )
   {
      double chartRadius = x0 - margin;
      g.DrawCircle( x0, y0, chartRadius );

      // draw telescope position
      StereoProjection::Spherical s;
      double hourAngle = (m_TargetRA.ToDouble() - m_lst)*360/24;
      double currentAlt = SkyMap::getObjectAltitude( m_TargetDEC.ToDouble(), hourAngle, m_geoLat );
      double currentAz = SkyMap::getObjectAzimut( m_TargetDEC.ToDouble(), hourAngle, m_geoLat );
      s.phi = Rad( currentAz );
      s.theta = Rad( 90 + currentAlt );
      StereoProjection::Polar p = s.Projected( chartRadius );
      StereoProjection::Rectangular r = p.ToRectangular();
#if 0
      Console().WriteLn( String().Format( "x=%f, y=%f, r=%f", r.x, r.y, chartRadius ) );
      Console().WriteLn( String().Format( "x0=%d, y0=%d", x0, y0 ) );
      Console().WriteLn( String().Format( "w=%d, h=%d", w, h ) );
      Console().WriteLn( String().Format( "phi=%f, theta=%f", s.phi, s.theta ) );
      Console().WriteLn( String().Format( "r=%f, pphi=%f", p.r, p.phi ) );
#endif
      g.DrawCircle( x0+r.x, y0+r.y, 5 );

      g.SetPen( darkGreen );
      hourAngle = (m_scopeRA - m_lst)*360/24;
      currentAlt = SkyMap::getObjectAltitude( m_scopeDEC, hourAngle, m_geoLat );
      currentAz = SkyMap::getObjectAzimut( m_scopeDEC, hourAngle, m_geoLat );
      s.phi = Rad( currentAz );
      s.theta = Rad( 90 + currentAlt );
      r = s.Projected( chartRadius ).ToRectangular();
      g.DrawCircle( x0+r.x, y0+r.y, 5 );

      g.SetPen( darkYellow );
      if ( m_skymap != nullptr )
         m_skymap->plotStars( m_lst, m_geoLat, x0, y0, chartRadius, g, m_limitStarMag );
   }
   else
   {
      if ( m_skymap != nullptr )
      {
         double CCD_chipHeight = 2200;
         double CCD_chipWidth = 2750;
         double CCD_pixelSize = 4.54/1000;
         double TEL_focalLength = 700;
         double FoV_width = CCD_chipWidth*CCD_pixelSize  / TEL_focalLength*3438/60;
         double FoV_height = CCD_chipHeight*CCD_pixelSize / TEL_focalLength*3438/60;
         double scale = 180.0/FoV_width;

         // draw scope position
         double currentAlt = SkyMap::getObjectAltitude( m_scopeDEC, m_scopeRA*360/24, m_geoLat );
         double currentAz = SkyMap::getObjectAzimut( m_scopeDEC, m_scopeRA*360/24, m_geoLat );

         StereoProjection::Spherical spherical( Rad( currentAz ), Rad( 90 + currentAlt ) );
         StereoProjection::Polar p = spherical.Projected( scale*x0 );
         StereoProjection::Rectangular r = p.ToRectangular();

         //Console().WriteLn( String().Format( "xx=%f, yy=%f, r=%f", r.x, r.y, scale * x0 ) );
         g.DrawCircle( x0, y0, 5 );

         // draw alignment deviation
         double alignAlt = SkyMap::getObjectAltitude( m_alignedDEC, m_alignedRA*360/24, m_geoLat );
         double alignAz = SkyMap::getObjectAzimut( m_alignedDEC, m_alignedRA*360/24, m_geoLat );
         StereoProjection::Rectangular rAlign =
            StereoProjection::Spherical( Rad( alignAz ), Rad( 90 + alignAlt ) ).Projected( scale*x0 ).ToRectangular();
         g.SetPen( darkGreen );
         g.DrawLine( x0 - r.x + r.x,
                     y0 - r.y + r.y,
                     x0 - r.x + rAlign.x,
                     y0 - r.y + rAlign.y );

         m_skymap->plotFoVStars( m_lst, m_geoLat, x0-r.x, y0-r.y, scale*x0, g, 13 );
      }
   }
}
// Returns a transformation matrix which represents the
// translation and rotation for the given node at t based
// on the left and right wheelSpline...
Trafo2D SplineNavigation::getWheelTransformation(int node, double t) {
	Vector2D center = Vector2D(wheelLeftSplineX->getValue(node,t) + wheelRightSplineX->getValue(node,t), wheelLeftSplineY->getValue(node,t) + wheelRightSplineY->getValue(node,t)) / 2; // Center point between left and right spline
	double angle = -std::atan2(wheelRightSplineX->getValue(node,t) - wheelLeftSplineX->getValue(node,t), wheelRightSplineY->getValue(node,t) - wheelLeftSplineY->getValue(node,t)) + Rad(90); // Angle between left and right (-90) in rad
	return Trafo2D::trans(center.x(), center.y()) * Trafo2D::rot(angle);
}
void VectorTest::btnRot2() {
	// Rot Subtract
	t = t*t.rot(Rad(-20));
	draw();
}
void VectorTest::btnRot1() {
	// Rot Add
	t = t*t.rot(Rad(20));
	draw();
}
Пример #17
0
template <class P1, class P2> static
void Convolve_2( const GenericImage<P1>& image, GenericImage<P2>& sharp,
                 pcl_enum interpolation, float dR, float angleD, DPoint center, int c )
{
   PixelInterpolation* P = 0;
   PixelInterpolation::Interpolator<P1>* interpolator = 0;

   try
   {
      switch ( interpolation )
      {
      case LSInterpolation::Bilinear:
         P = new BilinearPixelInterpolation();
         break;
      default:
      case LSInterpolation::Bicubic:
         P = new BicubicPixelInterpolation();
         break;
      case LSInterpolation::BicubicSpline:
         P = new BicubicSplinePixelInterpolation();
         break;
      case LSInterpolation::BicubicBSpline:
         P = new BicubicBSplinePixelInterpolation();
         break;
      }

      interpolator = P->NewInterpolator<P1>( image[c], image.Width(), image.Height() );

      int w = image.Width() - 1;
      int h = image.Height() - 1;

      double fimg, fsharp;
      StatusMonitor monitor;
      monitor.Initialize( "<end><cbr>High-pass Larson-Sekanina filter", image.NumberOfPixels() );

      sharp.Zero();

      float dAlpha = Rad( angleD );
      for ( int x = 0; x < image.Width(); ++x )
         for ( int y = 0; y < image.Height(); ++y, ++monitor )
         {
            // Get the central value
            P1::FromSample( fimg, image.Pixel( x, y, c ) );
            fsharp = fimg+fimg;

            double r, theta;
            ToPolar( x, y, center, r, theta);

            DPoint delta;

            // Positive differential
            ToCartesian( r-dR, theta+dAlpha, center, delta );
            if ( delta.x < 0 )
               delta.x = Abs( delta.x );
            else if ( delta.x > w )
               delta.x = 2*w - delta.x;
            if ( delta.y < 0 )
               delta.y = Abs( delta.y );
            else if ( delta.y > h )
               delta.y = 2*h - delta.y;
            P1::FromSample( fimg, (*interpolator)( delta ) );
            fsharp -= fimg;

            //Negative differential
            ToCartesian( r-dR, theta-dAlpha, center, delta );
            if ( delta.x < 0 )
               delta.x = Abs( delta.x );
            else if ( delta.x > w )
               delta.x = 2*w - delta.x;
            if ( delta.y < 0 )
               delta.y = Abs( delta.y );
            else if ( delta.y > h )
               delta.y = 2*h - delta.y;
            P1::FromSample( fimg, (*interpolator)( delta ) );
            fsharp -= fimg;

            sharp.Pixel( x, y ) = P2::ToSample( fsharp );
         }

      delete interpolator;
      delete P;
   }

   catch ( ... )
   {
      if ( interpolator != 0 )
         delete interpolator;
      if ( P != 0 )
         delete P;
      throw;
   }
}
Пример #18
0
int main(int argc, char* argv[])
{

 	#ifdef __linux__
 	struct sigaction sig_struct;
	sig_struct.sa_handler = sig_handler;
	sig_struct.sa_flags = 0;
	sigemptyset(&sig_struct.sa_mask);

	if (sigaction(SIGINT, &sig_struct, NULL) == -1)
    {
		cout << "Problem with sigaction" << endl;
		exit(1);
	}
	#endif // __linux__


/// ===    File read needed if moving something from PC to here
//    myFP = fopen(netname, "a+");
//    if(myFP == NULL)
//        {
//        cout<<"ERROR opening"<<endl;
//        exit(1);
//        }
//    fread(read_buf, 1, 100, myFP);
//    int buffersize = strlen(read_buf);
//    fclose(myFP);
//    cout<<"read the file: "<<read_buf<<endl;
// =============================================================

    int lcdp=lcd_open();
    int adcp=ADS1015_Init("/dev/i2c-1");

    PCA9685 myPCA={0x40, 0, 69, 0, 0, 0x11, 0x4, 50, 0x79,}; // control structure
    myPCA.file=PCA_Init("/dev/i2c-1");
    PCA9685_start(myPCA.file);

    //adcresult=read_convert_register(adcp);
    //sprintf(dis_buf, "ADC: %6.3f V", adcresult);
    //lcd_write(dis_buf);


	lcd_write("Hello from Steve's\nLCD stuff");
	lcd_clear();
	get_NIST();

	mcp23s17_enable_interrupts(GPIO_INTERRUPT_PIN);
	//mcp23s17_enable_interrupts(SW_GPIO_INTERRUPT_PIN);

	cout.setf(ios::fixed);
	//=== SET CURRENT TIME ==========================
	struct tm *newtime;								//--- for time now
	time_t long_time;								//--- Get time as long integer.
	double DeltaT=0.0;								//--- time since is in minutes

	Observer PLACENTIA={"Yorba Linda",Rad(33.909),Rad(-117.782),30.0,0};
	//Observer PHILLY={"Philly",Rad(40.0),Rad(-75.0),0.0,0};
	double sdctime;
	SATELSET Eset;
	SATPOS satpos;
	//ELLIPSE myEllipse;
	//double SP,JDG,E2JD,JDN;
	double JDG,E2JD,JDN;
	VectorIJK test,test1;           //ptest;
	//VectLook testlook;
	SATSUB SB;

	clock_t goal;
	clock_t wait=(clock_t)2 * CLOCKS_PER_SEC;       // change the 2 for update rate, 2= about 2 seconds

	Read_TLE(argv[1], Eset);                        // read the 2 line data

	do
	{
		time( &long_time );
		newtime=gmtime( &long_time );                   // time, expressed as a UTC time, GMT timezone
		JDN=JD_Now(newtime);							//--- JD based on system clock as GMT
		JDG=ThetaG_JD(JDN);								//--- in radians
		E2JD=Epoch2JD(Eset.iEpochYear,Eset.dEpochDay);	//--- JD based on TLE epoch
		double local_time=0.0;
		double test_time=0.0;

        local_time=newtime->tm_yday+1+(newtime->tm_hour+(newtime->tm_min+newtime->tm_sec/60.0)/60.0)/24.0;
        test_time=local_time-Eset.dEpochDay;
        //cout<<"test_time delta days "<<test_time<<endl;
        test_time*=1440.0;
        //cout<<"test_time delta minutes "<<test_time<<endl;

/**************************************
 local_time minus Eset.dEpochDay matches JDN-E2JD.
 And is easier to check and calculate and no need for
 all the JD and JD0 code.
*************************************/
		sdctime=JDN-E2JD;								//--- delta days
		sdctime*=1440.0;                                // delta minutes
		//sdctime=fmod(sdctime,60);
        //cout<<"Current sdctime "<<sdctime<<endl;

		DeltaT=sdctime;

        //satpos=SatPos(DeltaT, &Eset);				    //--- get satellite position
		satpos=clean_SatPos(DeltaT, &Eset);

		cout<<"=====Satellite ECI position============================\n"<<satpos;

		test=Obs_Position(PLACENTIA,JDG);				//--- get observer position
		//test1=Obs_to_ECI(PHILLY,JDG);                 //-- test data from TS Kelso
		test1=Obs_to_ECI(PLACENTIA,JDG);
		testlook=LookAngles(satpos, PLACENTIA,JDG);		//--- get look angles
		SB= SatSubPoint(satpos,JDG);

		cout<<"=====Observer ECI====================\n"<<test1;
		cout<<"=====Observer Look angles============\n"<<testlook; // for antenna tracker
		cout<<"=====Sat Sub Point===================\n"<<SB;



/// used before
    //int s_count=read_convert_register_count(adcp);
    //set_count(myPCA.file, 0, 5, s_count); // file channel, start count, end count




/// LCD setup and stuff

    adcresult=read_convert_register_volts(adcp);
    sprintf(dis_buf, "ADC: %6.3f V", adcresult);
    lcd_write(dis_buf);

    /// aztovolts is the target reference position
    double aztovolts = (Deg(testlook.AZ)) * (3.2/360.0);

    /// wtf is the difference of the pot input, adcresults, and reference
    double wtf = aztovolts - adcresult; /// double - float

    printf("\nVOLTS ADC: %6.3f V\n",adcresult);
    printf("AZ Degrees: %6.3f \n",Deg(testlook.AZ));
    printf("AZ to volts: %6.3f V\n",aztovolts);
    printf("DELTA: %6.3f \n",wtf);

    /**
    volts   0       1.6     3.2
    count   200     320     450
            max left    no motion   max right
            1 ms    1.5 ms  2ms
            50 hz timing
    **/

    /// for applying delta Vin
    //float PCAcount = (wtf*80)+320;   ///this is for  0 - 3.2 Vin
    float PCAcount = (wtf*80)+300;   ///this is for  0 - 3.2 Vin, 340 from measurements

    if(wtf< -1.25)
        PCAcount = 240;
    else if(wtf> 1.25)
            PCAcount = 425;


    //set_count(myPCA.file, 0, 5, PCAcount); // file channel, start count, end count
    set_count(myPCA.file, 0, 1, PCAcount); // file channel, start count, end count
    //set_count(myPCA.file, 1, 1, PCAcount); // file channel, start count, end count

    printf("MOTOR count: %6.3f \n",PCAcount);



//#define TRACK 0
//#define LOCATION 1
//#define SATDATA 2
//#define NIST 3

    if(display_count < 5)
    {
        display_control(TRACK, PLACENTIA, SB, Eset, testlook);
        display_count++;
        LED_off(GPIO_INTERRUPT_PIN);
    }
    else
    {
        display_control(LOCATION, PLACENTIA, SB, Eset, testlook);
        display_count++;
        LED_on(GPIO_INTERRUPT_PIN);
    }

    if(display_count > 10)
    {
        display_count = 0;
	}

        /**
            ====================
            Look angles:visible
            AZ:123456 EL:123456
            Sat LAT/LONG
            LT:123456 LG:123456
            ====================
            Location Yorba Linda
            LT:123456 LG:123456
            Range: 123456

            ====================
            Tracking:ISS (ZARYA)
            Incl:12345
            MM: 123456
            MA: 123456

        **/
/// LCD done

		goal = wait + clock();
		while( goal > clock() );

        #ifdef __linux__
        if(ctrl_c_pressed)
            {
                cout << "Ctrl^C Pressed" << endl;
                cout << "unexporting pins" << endl;
                //gpio26->unexport_gpio();
                //gpio16->unexport_gpio();
                mcp23s17_disable_interrupts(GPIO_INTERRUPT_PIN);
                //mcp23s17_disable_interrupts(SW_GPIO_INTERRUPT_PIN);

                cout << "deallocating GPIO Objects" << endl;
                //delete gpio26;
                //gpio26 = 0;
                //delete gpio16;
                //gpio16 =0;
                break;

            }
        #endif // __linux__
	}

	#ifdef __linux__
    	while(1);
    #elif _WIN32
        while(!(_kbhit()));
    #else
    #endif

	//while(1);
    //while(!(_kbhit()));

		//pthread_exit(NULL);
		set_all(myPCA.file, 0, 0);      /// kill the servos
		lcd_close();                    /// kill the LCD

	return 0;
}