Permalink
Browse files

Finished up digital sensors

  • Loading branch information...
1 parent fa90080 commit ad39f3b5deb26283848de07f0f6b6bcec2b2127e @bmcdorman bmcdorman committed Aug 2, 2012
Showing with 315 additions and 2 deletions.
  1. +187 −0 doxygen/DoxygenLayout.xml
  2. +69 −0 include/digital.h
  3. +1 −1 include/digital.hpp
  4. +57 −0 src/digital_c.cpp
  5. +1 −1 src/digital_p.cpp
View
@@ -0,0 +1,187 @@
+<doxygenlayout version="1.0">
+ <!-- Navigation index tabs for HTML output -->
+ <navindex>
+ <tab type="mainpage" visible="yes" title=""/>
+ <tab type="pages" visible="yes" title="" intro=""/>
+ <tab type="modules" visible="yes" title="" intro=""/>
+ <!-- ><tab type="namespaces" visible="yes" title="">
+ <tab type="namespacelist" visible="yes" title="" intro=""/>
+ <tab type="namespacemembers" visible="yes" title="" intro=""/>
+ </tab> -->
+ <tab type="classes" visible="yes" title="">
+ <tab type="classlist" visible="yes" title="" intro=""/>
+ <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
+ <tab type="hierarchy" visible="yes" title="" intro=""/>
+ <tab type="classmembers" visible="yes" title="" intro=""/>
+ </tab>
+ <tab type="files" visible="yes" title="">
+ <tab type="filelist" visible="yes" title="" intro=""/>
+ <tab type="globals" visible="yes" title="" intro=""/>
+ </tab>
+ <tab type="examples" visible="yes" title="" intro=""/>
+ </navindex>
+
+ <!-- Layout definition for a class page -->
+ <class>
+ <briefdescription visible="yes"/>
+ <includes visible="$SHOW_INCLUDE_FILES"/>
+ <inheritancegraph visible="$CLASS_GRAPH"/>
+ <collaborationgraph visible="$COLLABORATION_GRAPH"/>
+ <allmemberslink visible="yes"/>
+ <memberdecl>
+ <nestedclasses visible="yes" title=""/>
+ <publictypes title=""/>
+ <publicslots title=""/>
+ <signals title=""/>
+ <publicmethods title=""/>
+ <publicstaticmethods title=""/>
+ <publicattributes title=""/>
+ <publicstaticattributes title=""/>
+ <protectedtypes title=""/>
+ <protectedslots title=""/>
+ <protectedmethods title=""/>
+ <protectedstaticmethods title=""/>
+ <protectedattributes title=""/>
+ <protectedstaticattributes title=""/>
+ <packagetypes title=""/>
+ <packagemethods title=""/>
+ <packagestaticmethods title=""/>
+ <packageattributes title=""/>
+ <packagestaticattributes title=""/>
+ <properties title=""/>
+ <events title=""/>
+ <privatetypes title=""/>
+ <privateslots title=""/>
+ <privatemethods title=""/>
+ <privatestaticmethods title=""/>
+ <privateattributes title=""/>
+ <privatestaticattributes title=""/>
+ <friends title=""/>
+ <related title="" subtitle=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ <memberdef>
+ <inlineclasses title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <constructors title=""/>
+ <functions title=""/>
+ <related title=""/>
+ <variables title=""/>
+ <properties title=""/>
+ <events title=""/>
+ </memberdef>
+ <usedfiles visible="$SHOW_USED_FILES"/>
+ <authorsection visible="yes"/>
+ </class>
+
+ <!-- Layout definition for a namespace page -->
+ <namespace>
+ <briefdescription visible="yes"/>
+ <memberdecl>
+ <nestednamespaces visible="yes" title=""/>
+ <classes visible="yes" title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ <memberdef>
+ <inlineclasses title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ </memberdef>
+ <authorsection visible="yes"/>
+ </namespace>
+
+ <!-- Layout definition for a file page -->
+ <file>
+ <briefdescription visible="yes"/>
+ <includes visible="$SHOW_INCLUDE_FILES"/>
+ <includegraph visible="$INCLUDE_GRAPH"/>
+ <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
+ <sourcelink visible="yes"/>
+ <memberdecl>
+ <classes visible="yes" title=""/>
+ <namespaces visible="yes" title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ <memberdef>
+ <inlineclasses title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ </memberdef>
+ <authorsection/>
+ </file>
+
+ <!-- Layout definition for a group page -->
+ <group>
+ <briefdescription visible="yes"/>
+ <groupgraph visible="$GROUP_GRAPHS"/>
+ <memberdecl>
+ <nestedgroups visible="yes" title=""/>
+ <dirs visible="yes" title=""/>
+ <files visible="yes" title=""/>
+ <namespaces visible="yes" title=""/>
+ <classes visible="yes" title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <enumvalues title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <signals title=""/>
+ <publicslots title=""/>
+ <protectedslots title=""/>
+ <privateslots title=""/>
+ <events title=""/>
+ <properties title=""/>
+ <friends title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ <memberdef>
+ <pagedocs/>
+ <inlineclasses title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <enumvalues title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <signals title=""/>
+ <publicslots title=""/>
+ <protectedslots title=""/>
+ <privateslots title=""/>
+ <events title=""/>
+ <properties title=""/>
+ <friends title=""/>
+ </memberdef>
+ <authorsection visible="yes"/>
+ </group>
+
+ <!-- Layout definition for a directory page -->
+ <directory>
+ <briefdescription visible="yes"/>
+ <directorygraph visible="yes"/>
+ <memberdecl>
+ <dirs visible="yes"/>
+ <files visible="yes"/>
+ </memberdecl>
+ <detaileddescription title=""/>
+ </directory>
+</doxygenlayout>
View
@@ -0,0 +1,69 @@
+/**************************************************************************
+ * Copyright 2012 KISS Institute for Practical Robotics *
+ * *
+ * This file is part of libkovan. *
+ * *
+ * libkovan is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * libkovan is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with libkovan. Check the LICENSE file in the project root. *
+ * If not, see <http://www.gnu.org/licenses/>. *
+ **************************************************************************/
+
+/*!
+ * \file digital.h
+ * \brief Functions for working with digital sensors
+ * \author Braden McDorman
+ * \copyright KISS Insitute for Practical Robotics
+ * \ingroup sensor
+ */
+
+#ifndef _DIGITAL_H_
+#define _DIGITAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+ * \see get_digital_value
+ */
+int digital(int port);
+
+/*!
+ * Sets the value of the digital port in output mode.
+ * \see get_digital_value
+ */
+void set_digital_value(int port, int value);
+
+/*!
+ * Gets the current value of the digital port.
+ * \return 1 if the switch is closed, 0 if the switch is open
+ * \see set_digital_value
+ */
+int get_digital_value(int port);
+
+/*!
+ * Sets the digital mode.
+ * \param port The port to modify.
+ * \param out 1 for output mode, 0 for input mode.
+ */
+void set_digital_output(int port, int out);
+int get_digital_output(int port);
+
+int get_digital_pullup(int port);
+void set_digital_pullup(int port, int pullup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
View
@@ -49,7 +49,7 @@ class Digital : public Sensor<bool>
*/
virtual bool value() const;
- virtual bool setOutput(const bool& output);
+ virtual void setOutput(const bool& output);
virtual bool isOutput() const;
virtual void setPullup(const bool& pullup);
View
@@ -0,0 +1,57 @@
+/**************************************************************************
+ * Copyright 2012 KISS Institute for Practical Robotics *
+ * *
+ * This file is part of libkovan. *
+ * *
+ * libkovan is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * libkovan is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with libkovan. Check the LICENSE file in the project root. *
+ * If not, see <http://www.gnu.org/licenses/>. *
+ **************************************************************************/
+
+#include "digital.h"
+#include "digital_p.hpp"
+
+int digital(int port)
+{
+ return get_digital_value();
+}
+
+void set_digital_value(int port, int value)
+{
+ Private::Digital::instance()->setValue(m_port, value);
+}
+
+int get_digital_value(int port)
+{
+ return Private::Digital::instance()->value(m_port);
+}
+
+void set_digital_output(int port, int out)
+{
+ Private::Digital::instance()->setDirection(m_port, output ? Private::Digital::Out : Private::Digital::In);
+}
+
+int get_digital_output(int port)
+{
+ return Private::Digital::instance()->direction(m_port) == Private::Digital::Out;
+}
+
+int get_digital_pullup(int port)
+{
+ return Private::Digital::instance()->pullup(m_port);
+}
+
+void set_digital_pullup(int port, int pullup)
+{
+ Private::Digital::instance()->setPullup(m_port, pullup);
+}
View
@@ -78,7 +78,7 @@ bool Digital::setPullup(const unsigned char& port, const bool& pullup)
return true;
}
-static Digital *Digital::instance()
+Digital *Digital::instance()
{
static Digital s_digital;
return &s_digital;

0 comments on commit ad39f3b

Please sign in to comment.