Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit c9ea0ea170d9d22f8598d3650229e0ff74ad6ae9 @bmcdorman bmcdorman committed Jul 16, 2012
@@ -0,0 +1,18 @@
+# Compiled Object files
+*.slo
+*.lo
+*.o
+
+# Compiled Dynamic libraries
+*.so
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+
+build
+lib
+deploy
+
+.DS_Store
@@ -0,0 +1,41 @@
+#################################
+# libkovan CMake Build File #
+#################################
+
+PROJECT(libkovan)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
+
+FIND_PACKAGE(Qt4 REQUIRED)
+
+SET(INCLUDE ${libkovan_SOURCE_DIR}/include)
+SET(SRC ${libkovan_SOURCE_DIR}/src)
+
+INCLUDE_DIRECTORIES(${INCLUDE})
+
+INCLUDE(${QT_USE_FILE})
+
+FILE(GLOB INCLUDES ${INCLUDE}/*.h ${INCLUDE}/*.hpp)
+FILE(GLOB SOURCES ${SRC}/*.cpp)
+
+SET(MOC_SRCS ${SRC}/draw_p.hpp)
+QT4_WRAP_CPP(SOURCES ${MOC_SRCS})
+
+SET(CMAKE_CXX_FLAGS "-Wall")
+
+IF(APPLE)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -g")
+ELSEIF(WIN32)
+ SET(CMAKE_CXX_FLAGS "-Wl,--enable-auto-import")
+ELSEIF(UNIX)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
+ENDIF()
+
+SET(LIBRARY_OUTPUT_PATH ${libkovan_SOURCE_DIR}/lib )
+
+ADD_LIBRARY(kovan SHARED ${SOURCES})
+TARGET_LINK_LIBRARIES(kovan ${QT_LIBRARIES})
+
+install(FILES ${INCLUDES} DESTINATION include/kovan)
+
+add_subdirectory(test)
674 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,27 @@
+libkovan
+========
+
+libkovan is a user library that can read sensor values, move motors, and draw graphics to the Kovan. libkovan is written in C++, but also exposes both C bindings for simplified use cases.
+
+Requirements
+============
+
+* CMake 2.6.0 or higher
+* Qt 4.8.0 or higher (drawing library)
+* i2c_wrapper
+
+Runtime Requirements
+====================
+
+* running instance of kovand
+* X11 server or Qt embedded server
+
+Authors
+=======
+
+* Braden McDorman
+
+License
+=======
+
+This project is released under the terms of the GPLv3. For more information, read the LICENSE file included in the project.
@@ -0,0 +1,14 @@
+#ifndef _BATTERY_H_
+#define _BATTERY_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+float power_level();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
@@ -0,0 +1,10 @@
+#ifndef _BATTERY_HPP_
+#define _BATTERY_HPP_
+
+class Battery
+{
+public:
+ static float powerLevel();
+};
+
+#endif
@@ -0,0 +1,15 @@
+#ifndef _CAMERA_H_
+#define _CAMERA_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
No changes.
@@ -0,0 +1,4 @@
+#ifndef _COMMON_HPP_
+#define _COMMON_HPP_
+
+#endif
@@ -0,0 +1,19 @@
+#ifndef _DRAW_H_
+#define _DRAW_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int draw_open();
+void draw_point(int x, int y);
+void draw_line(int sx, int sy, int ex, int ey);
+void draw_clear();
+void draw_close();
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
@@ -0,0 +1,27 @@
+#ifndef _DRAW_HPP_
+#define _DRAW_HPP_
+
+namespace Private
+{
+ class Draw;
+}
+
+class Draw
+{
+public:
+ Draw();
+ ~Draw();
+
+ bool open();
+ void point(int x, int y);
+ void line(int sx, int sy, int ex, int ey);
+ void clear();
+ void raise();
+ void setSize(const unsigned int& width, const unsigned int& height);
+ void close();
+
+private:
+ Private::Draw *p_draw;
+};
+
+#endif
@@ -0,0 +1,15 @@
+#ifndef _IR_H_
+#define _IR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void ir_read();
+void ir_write();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
@@ -0,0 +1,11 @@
+#ifndef _IR_HPP_
+#define _IR_HPP_
+
+class Ir
+{
+public:
+ static void read();
+ static void write();
+};
+
+#endif
@@ -0,0 +1,13 @@
+#ifndef _KOVAN_H_
+#define _KOVAN_H_
+
+#include "motors.h"
+#include "servos.h"
+#include "camera.h"
+#include "ir.h"
+#include "wifi.h"
+#include "draw.h"
+#include "battery.h"
+#include "util.h"
+
+#endif
@@ -0,0 +1,13 @@
+#ifndef _KOVAN_H_
+#define _KOVAN_H_
+
+#include "motors.hpp"
+#include "servos.hpp"
+#include "camera.hpp"
+#include "ir.hpp"
+#include "wifi.hpp"
+#include "draw.hpp"
+#include "battery.hpp"
+#include "util.hpp"
+
+#endif
@@ -0,0 +1,35 @@
+#ifndef _MOTORS_H_
+#define _MOTORS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int get_motor_position_counter(int motor);
+int clear_motor_position_counter(int motor);
+int move_at_velocity(int motor, int velocity);
+int mav(int motor, int velocity);
+int move_to_position(int motor, int speed, int goal_pos);
+int mtp(int motor, int speed, int goal_pos);
+int move_relative_position(int motor, int speed, int delta_pos);
+int mrp(int motor, int speed, int delta_pos);
+void set_pid_gains(int motor, int p, int i, int d, int pd, int id, int dd);
+void get_pid_gains(int motor, int *p, int *i, int *d, int *pd, int *id, int *dd);
+int freeze(int motor);
+int get_motor_done(int motor);
+void block_motor_done(int motor);
+void bmd(int motor);
+int setpwm(int motor, int pwm);
+int getpwm(int motor);
+void fd(int motor);
+void bk(int motor);
+void motor (int motor, int percent);
+void off(int motor);
+void ao();
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
@@ -0,0 +1,39 @@
+#ifndef _MOTORS_HPP_
+#define _MOTORS_HPP_
+
+#include "port.hpp"
+
+namespace Private
+{
+ class Motor;
+}
+
+class Motor
+{
+public:
+ Motor(const port_t& port) throw();
+
+ void moveAtVelocity(const int& velocity);
+ void moveToPosition(const int& speed, const int& goalPos);
+ void moveRelativePosition(const int& speed, const int& deltaPos);
+
+ void setPidGains(const short& p, const short& i, const short& d, const short& pd, const short& id, const short& dd);
+ void pidGains(short& p, short& i, short& d, short& pd, short& id, short& dd);
+
+ void freeze();
+
+ bool getMotorDone() const;
+ void blockMotorDone() const;
+
+ void forward();
+ void backward();
+ void motor(int percent);
+ void off();
+
+ const port_t& port() const;
+private:
+ port_t m_port;
+ Private::Motor *p_motor;
+};
+
+#endif
@@ -0,0 +1,14 @@
+#ifndef _PORT_HPP_
+#define _PORT_HPP_
+
+#include <stdexcept>
+
+class InvalidPort : std::logic_error
+{
+public:
+ InvalidPort(const std::string& what);
+};
+
+typedef int port_t;
+
+#endif
@@ -0,0 +1,22 @@
+#ifndef _PRIVATE_HPP_
+#define _PRIVATE_HPP_
+
+#include <pthread.h>
+
+#define SHARED_MEMORY_KEY 8374
+
+namespace Private
+{
+ struct SharedMemory
+ {
+ pthread_mutex_t mutex;
+
+ bool motorDirty : 1;
+ bool servoDirty : 1;
+
+
+ unsigned short rawBatteryVoltage;
+ };
+}
+
+#endif
@@ -0,0 +1,15 @@
+#ifndef _SERVOS_H_
+#define _SERVOS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
No changes.
@@ -0,0 +1,14 @@
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void msleep(long msecs);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
@@ -0,0 +1,6 @@
+#ifndef _TIME_HPP_
+#define _TIME_HPP_
+
+#include "time.h"
+
+#endif
Oops, something went wrong.

0 comments on commit c9ea0ea

Please sign in to comment.