GY-63_MS5611/libraries/Radar/radar.h

86 lines
2.0 KiB
C
Raw Normal View History

2020-11-27 05:33:55 -05:00
#pragma once
2013-09-30 12:46:09 -04:00
//
// FILE: radar.h
// AUTHOR: Rob Tillaart
2023-11-16 14:08:09 -05:00
// VERSION: 0.1.8
2020-11-27 05:33:55 -05:00
// PURPOSE: Arduino library for a pan tilt radar.
// URL: https://github.com/RobTillaart/RADAR
2013-09-30 12:46:09 -04:00
2021-01-29 06:31:58 -05:00
2020-11-27 05:33:55 -05:00
#include "Arduino.h"
2013-09-30 12:46:09 -04:00
2023-11-16 14:08:09 -05:00
#define RADAR_LIB_VERSION (F("0.1.8"))
2021-05-28 07:42:27 -04:00
2021-01-29 06:31:58 -05:00
2022-11-23 07:53:23 -05:00
// TODO # positions in a begin() or constructor?
2020-11-27 05:33:55 -05:00
#ifndef RADAR_POSITIONS
2021-01-29 06:31:58 -05:00
#define RADAR_POSITIONS 10
2020-11-27 05:33:55 -05:00
#endif
2013-09-30 12:46:09 -04:00
2021-05-28 07:42:27 -04:00
2013-09-30 12:46:09 -04:00
class RADAR
{
2020-11-27 05:33:55 -05:00
public:
2022-11-23 07:53:23 -05:00
RADAR(const uint8_t pinPan, const uint8_t pinTilt);
// no valid range checking or negative value check.
void setPanPerSecond(float pps) { _panPerSecond = pps; };
float getPanPerSecond() { return _panPerSecond; };
void setTiltPerSecond(float tps) { _tiltPerSecond = tps; };
float getTiltPerSecond() { return _tiltPerSecond; };
// basic moves
void gotoPan(const int16_t pan);
int16_t getPan();
void gotoTilt(const int16_t tilt);
int16_t getTilt();
void gotoPanTilt(const int16_t pan, const int16_t tilt);
// memory positions - store / recall?
uint8_t getMaxPositions() { return RADAR_POSITIONS; };
bool setPosition(const uint8_t index, const int16_t pan, const int16_t tilt);
bool getPosition(const uint8_t index, int16_t & pan, int16_t & tilt);
bool gotoPosition(const uint8_t index);
void setHomePosition(const int16_t pan, const int16_t tilt);
void gotoHomePosition();
// feedback on positions.
bool isMoving() { return isPanMoving() || isTiltMoving(); };
bool isPanMoving() { return getPan() != _pan; };
bool isTiltMoving() { return getTilt() != _tilt; };
// TODO NIY
uint32_t ping();
uint32_t ping(const int16_t pan, const int16_t tilt);
2021-12-27 14:23:58 -05:00
2020-11-27 05:33:55 -05:00
private:
2022-11-23 07:53:23 -05:00
int16_t _pinPan;
int16_t _pinTilt;
2021-12-27 14:23:58 -05:00
2022-11-23 07:53:23 -05:00
int16_t _prevPan;
int16_t _pan;
int16_t _homePan;
uint32_t _lastPanTime;
2021-12-27 14:23:58 -05:00
2022-11-23 07:53:23 -05:00
int16_t _prevTilt;
int16_t _tilt;
int16_t _homeTilt;
uint32_t _lastTiltTime;
2021-12-27 14:23:58 -05:00
2022-11-23 07:53:23 -05:00
int16_t _panArray[RADAR_POSITIONS];
int16_t _tiltArray[RADAR_POSITIONS];
2020-11-27 05:33:55 -05:00
2022-11-23 07:53:23 -05:00
float _panPerSecond = 15;
float _tiltPerSecond = 15;
2013-09-30 12:46:09 -04:00
};
2021-05-28 07:42:27 -04:00
2023-11-16 14:08:09 -05:00
// -- END OF FILE --