Commit f179bd6b authored by andz's avatar andz

-- Added Doxygen documentation

-- Added Error managemen
-- Changed IP, port and MAC to real values
parent 03bf61fb
/*
*
*/
///
/// @file rotor.cpp
/// @copyright Christian Obersteiner, Andreas Müller - CC-BY-SA 4.0
///
/// @brief Contains all kind of rotor functions
///
#include "rotor.h"
///
/// @brief Constructor
///
CRotor::CRotor()
{
initRotor();
}
///
/// @brief Initialize all ADC Values and set Arduino Pins to a defined value.
///
void CRotor::initRotor()
{
if(AZIM)
......@@ -39,6 +50,10 @@ void CRotor::initRotor()
}
}
///
/// @brief Does all the rotor movement stuff
///
void CRotor::doRotor()
{
//Do all the Rotor Stuff here
......@@ -54,6 +69,10 @@ void CRotor::doRotor()
}
///
/// @brief Serial Debug output Function
///
void CRotor::debugOut()
{
//debug Out
......@@ -67,32 +86,92 @@ void CRotor::debugOut()
Serial.println("");
}
///
/// @brief Returns the actual Azimuth value in degree
///
/// @return uint16 actual Azimuth value in degree
///
uint16 CRotor::getActualAzimuth() const
{
return m_uActualAzimuth;
}
///
/// @brief Returns the actual Elevation value in degree
///
/// @return actual Elevation value in degree
///
uint16 CRotor::getActualElevation() const
{
return m_uActualElevation;
}
void CRotor::setAzimuth(uint16 pAzimuth)
///
/// @brief Sets the actual Azimuth value in degree and checks valid range
///
/// @param pAzimuth Azimuth value to be set
///
/// @return Error Code
///
rotorError CRotor::setAzimuth(uint16 pAzimuth)
{
m_uSetAzimuth = pAzimuth;
if(pAzimuth >= AZIM_MIN && pAzimuth <= AZIM_MAX)
{
m_uSetAzimuth = pAzimuth;
return CRotor::ROT_OK;
}
else
{
return CRotor::ROT_VAL_OUT_OF_RANGE;
}
}
void CRotor::setElevation(uint16 pElevation)
///
/// @brief Sets the actual Elevation value in degree and checks valid range
///
/// @param pElevation Elevation value to be set
///
/// @return Error Code
///
rotorError CRotor::setElevation(uint16 pElevation)
{
m_uSetElevation = pElevation;
if(pElevation >= ELEV_MIN && pElevation <= ELEV_MAX)
{
m_uSetElevation = pElevation;
return CRotor::ROT_OK;
}
else
{
return CRotor::ROT_VAL_OUT_OF_RANGE;
}
}
///
/// @brief Reads out the Sensor values and stores them
///
/// @return Error Code
///
void CRotor::readRotSensors()
{
m_uActualAzimuth = (uint16)(readADC(AZIM_POT)/AZIM_DEG);
m_uActualElevation = (uint16)(readADC(ELEV_POT)/ELEV_DEG);
return CRotor::ROT_OK;
}
///
/// @brief Reads out an ADC Pin 4 times and returns the average
///
/// @param AdcPin ADC Pin to read
///
/// @return average ADC value
///
uint16 CRotor::readADC(int AdcPin)
{
//Read ADC 4 times and calculate average
......
/*
*
*/
///
/// @file rotor.h
/// @copyright Christian Obersteiner, Andreas Müller - CC-BY-SA 4.0
///
/// @brief Contains all kind of rotor functions
///
#ifndef ROTOR_H
#define ROTOR_H
......@@ -13,28 +14,29 @@
class CRotor
{
public:
CRotor();
void initRotor();
void doRotor();
void debugOut();
uint16 getActualAzimuth() const;
uint16 getActualElevation() const;
uint16 getSetAzimuth() const;
uint16 getSetElevation() const;
void setAzimuth(uint16);
void setElevation(uint16);
enum rotorError { ROT_OK,
ROT_NOK,
ROT_VAL_OUT_OF_RANGE };
CRotor();
void initRotor();
void doRotor();
void debugOut();
uint16 getActualAzimuth() const;
uint16 getActualElevation() const;
rotorError setAzimuth(uint16);
rotorError setElevation(uint16);
private:
void readRotSensors();
uint16 readADC(int);
rotorError readRotSensors();
uint16 readADC(int);
uint16 m_uActualAzimuth;
uint16 m_uActualElevation;
uint16 m_uSetAzimuth;
uint16 m_uSetElevation;
byte m_bAzimuthBreakReleased;
byte m_bElevationBreakReleased;
uint16 m_uActualAzimuth;
uint16 m_uActualElevation;
uint16 m_uSetAzimuth;
uint16 m_uSetElevation;
byte m_bAzimuthBreakReleased;
byte m_bElevationBreakReleased;
};
......
/*
*
*/
///
/// @file settings.h
/// @copyright Christian Obersteiner, Andreas Müller - CC-BY-SA 4.0
///
/// @brief Contains all settings used by the rotor control
///
#ifndef SETTINGS_H
#define SETTINGS_H
......@@ -15,19 +18,19 @@
#define AZIM_BREAK 1
#define ELEV_BREAK 1
// Degree Span
// Allowed span in degree
#define AZIM_SPAN 5
#define ELEV_SPAN 3
// Max Values
#define AZIM_MIN 0.0
#define AZIM_MAX 360.0
#define ELEV_MIN 0.0
#define ELEV_MAX 180.0
#define AZIM_MIN 0
#define AZIM_MAX 360
#define ELEV_MIN 0
#define ELEV_MAX 180
// ADC Values
#define AZIM_ADC_MIN 0.0
#define AZIM_ADC_MAX 1024.0
#define ELEV_ADC_MIN 0.0
#define ELEV_ADC_MAX 1024.0
#define AZIM_ADC_MIN 0
#define AZIM_ADC_MAX 1024
#define ELEV_ADC_MIN 0
#define ELEV_ADC_MAX 1024
#define AZIM_DEG ((AZIM_ADC_MAX-AZIM_ADC_MIN)/(AZIM_MAX-AZIM_MIN))
#define ELEV_DEG ((ELEV_ADC_MAX-ELEV_ADC_MIN)/(ELEV_MAX-ELEV_MIN))
......
/*
*
*
*
*/
///
/// @file shackremote.ino
/// @copyright Christian Obersteiner, Andreas Müller - CC-BY-SA 4.0
///
/// @brief Contains all arduino stuff for the rotor control
///
#include <Arduino.h>
#include "settings.h"
......@@ -13,32 +14,32 @@
#include "rotor.h"
// Network Settings
/// \todo move to settings.h
/// @todo move to settings.h
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
//EthernetServer server(80);
0xDE, 0xAD, 0xBE, 0xEF, 0x13, 0x37 };
IPAddress ip(83,133,178,126);
unsigned int localPort = 51337;
CRotor rotor;
EthernetUDP Udp;
int debugTime;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(19200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
Ethernet.begin(mac, ip);
//server.begin();
Serial.print("Local IP: ");
Serial.println(Ethernet.localIP());
//Debug
debugTime = 0;
// Open serial communications and wait for port to open:
Serial.begin(19200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
Ethernet.begin(mac, ip);
Udp.begin(localPort);
Serial.print("Local IP: ");
Serial.println(Ethernet.localIP());
//Debug
debugTime = 0;
}
......@@ -51,6 +52,4 @@ void loop()
debugTime = 0;
}
debugTime++;
//hambits->doCommands();
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment