Commit 03bf61fb authored by andz's avatar andz

enhanced rpo control software

first implementation of rotor control
parent 1804db1b
......@@ -6,27 +6,98 @@
CRotor::CRotor()
{
// intentionally blank
initRotor();
}
uint16 CRotor::getAzimuth() const
void CRotor::initRotor()
{
return m_uAzimuth;
if(AZIM)
{
//Pin Settings
pinMode(AZIM_RE_CW, OUTPUT);
pinMode(AZIM_RE_CCW, OUTPUT);
pinMode(AZIM_RE_BREAK, OUTPUT);
//All Relais Off
digitalWrite(AZIM_RE_CW, HIGH);
digitalWrite(AZIM_RE_CCW, HIGH);
digitalWrite(AZIM_RE_BREAK, HIGH);
//Initial Values
m_bAzimuthBreakReleased = 0;
}
if(ELEV)
{
//Pin Settings
pinMode(ELEV_RE_UP, OUTPUT);
pinMode(ELEV_RE_DWN, OUTPUT);
pinMode(ELEV_RE_BREAK, OUTPUT);
//All Relais Off
digitalWrite(ELEV_RE_UP, HIGH);
digitalWrite(ELEV_RE_DWN, HIGH);
digitalWrite(ELEV_RE_BREAK, HIGH);
//Initial Values
m_bElevationBreakReleased = 0;
}
}
uint16 CRotor::getElevation() const
void CRotor::doRotor()
{
return m_uElevation;
//Do all the Rotor Stuff here
readRotSensors();
if(AZIM)
{
//Do all the Azimuth Stuff here
}
if(ELEV)
{
//Do all the Elevation Stuff here
}
}
void CRotor::debugOut()
{
//debug Out
readRotSensors();
Serial.println("-----------------");
Serial.write("Azim Value: ");
Serial.write(m_uActualAzimuth);
Serial.println("");
Serial.write("Elev Value: ");
Serial.write(m_uActualElevation);
Serial.println("");
}
uint16 CRotor::getActualAzimuth() const
{
return m_uActualAzimuth;
}
uint16 CRotor::getActualElevation() const
{
return m_uActualElevation;
}
void CRotor::setAzimuth(uint16 pAzimuth)
{
// try to set desired Azimuth
/// \todo check for max values
m_uSetAzimuth = pAzimuth;
}
void CRotor::setElevation(uint16 pElevation)
{
// try to set desired Elevation
/// \todo check for max values
m_uSetElevation = pElevation;
}
void CRotor::readRotSensors()
{
m_uActualAzimuth = (uint16)(readADC(AZIM_POT)/AZIM_DEG);
m_uActualElevation = (uint16)(readADC(ELEV_POT)/ELEV_DEG);
}
uint16 CRotor::readADC(int AdcPin)
{
//Read ADC 4 times and calculate average
uint16 adcValue = 0;
for(int i = 0; i < 4; i++)
adcValue += analogRead(AdcPin);
adcValue = adcValue/4;
}
\ No newline at end of file
......@@ -8,21 +8,34 @@
#define ROTOR_H
#include "settings.h"
#include "Arduino.h"
class CRotor
{
public:
CRotor();
uint16 getAzimuth() const;
uint16 getElevation() const;
void initRotor();
void doRotor();
void debugOut();
uint16 getActualAzimuth() const;
uint16 getActualElevation() const;
uint16 getSetAzimuth() const;
uint16 getSetElevation() const;
void setAzimuth(uint16);
void setElevation(uint16);
private:
uint16 m_uAzimuth;
uint16 m_uElevation;
void readRotSensors();
uint16 readADC(int);
uint16 m_uActualAzimuth;
uint16 m_uActualElevation;
uint16 m_uSetAzimuth;
uint16 m_uSetElevation;
byte m_bAzimuthBreakReleased;
byte m_bElevationBreakReleased;
};
#endif //ROTOR_H
\ No newline at end of file
......@@ -4,13 +4,51 @@
#ifndef SETTINGS_H
#define SETTINGS_H
// MISC Settings
//// Rotor Settings
// Rotor present
#define AZIM 1
#define ELEV 1
// Has Break?
#define AZIM_BREAK 1
#define ELEV_BREAK 1
// Degree Span
#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
// 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_DEG ((AZIM_ADC_MAX-AZIM_ADC_MIN)/(AZIM_MAX-AZIM_MIN))
#define ELEV_DEG ((ELEV_ADC_MAX-ELEV_ADC_MIN)/(ELEV_MAX-ELEV_MIN))
// Pin Settings
// Rotor Sensor Pins
#define AZIM_POT A8
#define ELEV_POT A9
// Rotor Relais
// Aximut
#define AZIM_RE_CW 0
#define AZIM_RE_CCW 0
#define AZIM_RE_BREAK 0
// Elevation
#define ELEV_RE_UP 0
#define ELEV_RE_DWN 0
#define ELEV_RE_BREAK 0
// Pin Settings
// Network Settings
// Network Settings
////////////////////////////
......
......@@ -17,9 +17,10 @@
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
EthernetServer server(80);
//EthernetServer server(80);
CRotor rotor;
int debugTime;
void setup()
{
......@@ -30,64 +31,26 @@ void setup()
}
// start the Ethernet connection and the server:
// start the Ethernet connection:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
//server.begin();
Serial.print("Local IP: ");
Serial.println(Ethernet.localIP());
//Debug
debugTime = 0;
}
void loop()
{
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("<br />");
}
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
rotor.doRotor();
if(debugTime > 100)
{
rotor.debugOut();
debugTime = 0;
}
debugTime++;
//hambits->doCommands();
}
\ No newline at end of file
......@@ -12,3 +12,19 @@ QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
CONFIG += console
CONFIG -= app_bundle
target.path = /home/pi
INSTALLS += target
OTHER_FILES += \
qml/BlackButtonBackground.qml \
qml/BlackButtonStyle.qml \
qml/main.qml
DISTFILES += \
images/icon-go.png \
fonts/OpenSans-Regular.ttf
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
Item {
width: 640
height: 480
property alias button1: button1
property alias button2: button2
RowLayout {
anchors.centerIn: parent
Button {
id: button1
text: qsTr("Press Me 1")
}
Button {
id: button2
text: qsTr("Press Me 2")
}
}
}
......@@ -6,7 +6,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
return app.exec();
}
......
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
MainForm {
anchors.fill: parent
button1.onClicked: messageDialog.show(qsTr("Button 1 pressed"))
button2.onClicked: messageDialog.show(qsTr("Button 2 pressed"))
}
MessageDialog {
id: messageDialog
title: qsTr("May I have your attention, please?")
function show(caption) {
messageDialog.text = caption;
messageDialog.open();
}
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>MainForm.ui.qml</file>
<file>qml/BlackButtonStyle.qml</file>
<file>qml/BlackButtonBackground.qml</file>
<file>qml/main.qml</file>
<file>fonts/OpenSans-Regular.ttf</file>
<file>images/icon-go.png</file>
</qresource>
</RCC>
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
Rectangle {
property bool pressed: false
gradient: Gradient {
GradientStop {
color: pressed ? "#222" : "#333"
position: 0
}
GradientStop {
color: "#222"
position: 1
}
}
Rectangle {
height: 1
width: parent.width
anchors.top: parent.top
color: "#444"
visible: !pressed
}
Rectangle {
height: 1
width: parent.width
anchors.bottom: parent.bottom
color: "#000"
}
}
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
ButtonStyle {
property color fontColor
property url rightAlignedIconSource
background: BlackButtonBackground {
pressed: control.pressed
}
label: Item {
implicitWidth: row.implicitWidth
implicitHeight: row.implicitHeight
baselineOffset: row.y + text.y + text.baselineOffset
Row {
id: row
anchors.left: control.text.length === 0 ? undefined : parent.left
anchors.leftMargin: control.text.length === 0 ? 0 : textSingleton.implicitHeight
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: control.text.length === 0 ? parent.horizontalCenter : undefined
Image {
source: control.iconSource
width: Math.min(sourceSize.width, height)
height: text.implicitHeight
fillMode: Image.PreserveAspectFit
}
Text {
id: text
text: control.text
color: fontColor
font.pixelSize: control.height * 0.25
font.family: openSans.name
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
anchors.verticalCenter: parent.verticalCenter
}
}
Loader {
active: rightAlignedIconSource.toString().length !== 0
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: textSingleton.implicitHeight
sourceComponent: Image {
width: Math.min(sourceSize.width, height)
height: text.implicitHeight
fillMode: Image.PreserveAspectFit
source: rightAlignedIconSource
}
}
}
}
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import QtQuick.Controls.Styles 1.4
import QtQuick.Extras 1.4
import QtQuick.Layouts 1.0
import QtQuick.Window 2.1
Window {
id: root
objectName: "window"
visible: true
width: 800
height: 480
color: "#161616"
title: "HamBits Control 0.1"
function toPixels(percentage) {
return percentage * Math.min(root.width, root.height);