summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libk8055/CMakeLists.txt16
-rw-r--r--libk8055/k8055++.h81
-rw-r--r--libk8055/libk8055.cpp172
3 files changed, 269 insertions, 0 deletions
diff --git a/libk8055/CMakeLists.txt b/libk8055/CMakeLists.txt
index 62398ff..75466ff 100644
--- a/libk8055/CMakeLists.txt
+++ b/libk8055/CMakeLists.txt
@@ -14,6 +14,22 @@ INSTALL(TARGETS k8055-${VERSION}
PUBLIC_HEADER DESTINATION include
)
+ADD_LIBRARY( k8055++-${VERSION} SHARED libk8055.cpp )
+ADD_DEPENDENCIES(k8055++-${VERSION} k8055-${VERSION})
+ADD_LIBRARY( k8055++-static-${VERSION} STATIC libk8055.cpp )
+ADD_DEPENDENCIES(k8055++-static-${VERSION} k8055-${VERSION})
+INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} )
+TARGET_LINK_LIBRARIES( k8055++-${VERSION}
+ k8055-${VERSION}
+)
+SET_TARGET_PROPERTIES(k8055++-${VERSION} PROPERTIES PUBLIC_HEADER k8055++.h )
+
+INSTALL(TARGETS k8055++-${VERSION}
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ PUBLIC_HEADER DESTINATION include
+)
+
ADD_EXECUTABLE(k8055 WIN32 MACOSX_BUNDLE main.c )
TARGET_LINK_LIBRARIES(k8055
k8055-${VERSION}
diff --git a/libk8055/k8055++.h b/libk8055/k8055++.h
new file mode 100644
index 0000000..074458a
--- /dev/null
+++ b/libk8055/k8055++.h
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the libk8055 Library.
+ *
+ * The libk8055 Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * The libk8055 Library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * http://opensource.org/licenses/
+ *
+ * Copyright (C) 2011 by Jérémy Zurcher
+ *
+ */
+
+#include "k8055.h"
+
+class K8055 {
+ public:
+ K8055();
+ ~K8055();
+
+ int read( void );
+ int write( void );
+
+ int digital_1( void );
+ int digital_2( void );
+ int digital_3( void );
+ int digital_4( void );
+ int digital_5( void );
+ int analog_1( void );
+ int analog_2( void );
+ int counter_1( void );
+ int counter_2( void );
+
+ static char* Version( void );
+ static int SearchDevices( void );
+
+ int OpenDevice( int board_address );
+ int CloseDevice();
+
+ int SetAnalogChannel( int channel );
+ int ClearAnalogChannel( int channel );
+ int ReadAnalogChannel( int channel_no );
+ int WriteAnalogChannel( int channel, int data );
+
+ int SetAllAnalog();
+ int ClearAllAnalog();
+ int ReadAllAnalog( int* data1, int* data2 );
+ int WriteAllAnalog( int data1,int data2 );
+
+ int SetDigitalChannel( int channel );
+ int ClearDigitalChannel( int channel );
+ int ReadDigitalChannel( int channel );
+
+ int SetAllDigital();
+ int ClearAllDigital();
+ int ReadAllDigital();
+ int WriteAllDigital( int data );
+
+ int SetAllValues( int digital_data, int ad_data1, int ad_data2 );
+ int ReadAllValues ( int* data1, int* data2, int* data3, int* data4, int* data5 );
+
+ int ResetCounter( int counter_n );
+ int ReadCounter( int counter_n );
+
+ int SetCounterDebounceTime( int counter_n, int debounce_time );
+
+ private:
+ struct k8055_dev dev;
+};
+
diff --git a/libk8055/libk8055.cpp b/libk8055/libk8055.cpp
new file mode 100644
index 0000000..2266a41
--- /dev/null
+++ b/libk8055/libk8055.cpp
@@ -0,0 +1,172 @@
+/*
+ * This file is part of the libk8055 Library.
+ *
+ * The libk8055 Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * The libk8055 Library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * http://opensource.org/licenses/
+ *
+ * Copyright (C) 2011 by Jérémy Zurcher
+ *
+ */
+
+#include "k8055++.h"
+
+K8055::K8055() {
+}
+
+K8055::~K8055() {
+ k8055_close_device( &dev );
+}
+
+int K8055::read( void ) {
+ return k8055_read( &dev );
+}
+
+int K8055::write( void ) {
+ return k8055_write( &dev );
+}
+
+int K8055::digital_1( void ) {
+ return k8055_digital_1( &dev );
+}
+
+int K8055::digital_2( void ) {
+ return k8055_digital_2( &dev );
+}
+
+int K8055::digital_3( void ) {
+ return k8055_digital_3( &dev );
+}
+
+int K8055::digital_4( void ) {
+ return k8055_digital_4( &dev );
+}
+
+int K8055::digital_5( void ) {
+ return k8055_digital_5( &dev );
+}
+
+int K8055::analog_1( void ) {
+ return k8055_analog_1( &dev );
+}
+
+int K8055::analog_2( void ) {
+ return k8055_analog_2( &dev );
+}
+
+int K8055::counter_1( void ) {
+ return k8055_counter_1( &dev );
+}
+
+int K8055::counter_2( void ) {
+ return k8055_counter_2( &dev );
+}
+
+char* K8055::Version( void ) {
+ return k8055_version();
+}
+
+int K8055::SearchDevices( void ) {
+ return k8055_search_devices();
+}
+
+int K8055::OpenDevice( int board_address ) {
+ return k8055_open_device( &dev, board_address );
+}
+
+int K8055::CloseDevice() {
+ return k8055_close_device( &dev );
+}
+
+int K8055::SetAnalogChannel( int channel ) {
+ return k8055_set_analog_channel( &dev, channel );
+}
+
+int K8055::ClearAnalogChannel( int channel ) {
+ return k8055_clear_analog_channel( &dev, channel );
+}
+
+int K8055::ReadAnalogChannel( int channel_no ) {
+ return k8055_read_analog_channel( &dev, channel_no );
+}
+
+int K8055::WriteAnalogChannel( int channel, int data ) {
+ return k8055_write_analog_channel( &dev, channel, data );
+}
+
+int K8055::SetAllAnalog() {
+ return k8055_set_all_analog( &dev );
+}
+int K8055::ClearAllAnalog() {
+ return k8055_clear_all_analog( &dev );
+}
+
+int K8055::ReadAllAnalog( int* data1, int* data2 ) {
+ return k8055_read_all_analog( &dev, data1, data2 );
+}
+
+int K8055::WriteAllAnalog( int data1,int data2 ) {
+ return k8055_write_all_analog( &dev, data1, data2 );
+}
+
+int K8055::SetDigitalChannel( int channel ) {
+ return k8055_set_digital_channel( &dev, channel );
+}
+
+int K8055::ReadDigitalChannel( int channel ) {
+ return k8055_read_digital_channel( &dev, channel );
+}
+
+int K8055::ClearDigitalChannel( int channel ) {
+ return k8055_clear_digital_channel( &dev, channel );
+}
+
+int K8055::SetAllDigital() {
+ return k8055_set_all_digital( &dev );
+}
+
+int K8055::ClearAllDigital() {
+ return k8055_clear_all_digital( &dev );
+}
+
+int K8055::ReadAllDigital() {
+ return k8055_read_all_digital( &dev );
+}
+
+int K8055::WriteAllDigital( int data ) {
+ return k8055_write_all_digital( &dev, data );
+}
+
+int K8055::SetAllValues( int digital_data, int ad_data1, int ad_data2 ) {
+ return k8055_set_all_values( &dev, digital_data, ad_data1, ad_data2 );
+}
+
+int K8055::ReadAllValues ( int* data1, int* data2, int* data3, int* data4, int* data5 ) {
+ return k8055_read_all_values( &dev, data1, data2, data3, data4, data5 );
+}
+
+int K8055::ResetCounter( int counter_n ) {
+ return k8055_reset_counter( &dev, counter_n );
+}
+
+int K8055::ReadCounter( int counter_n ) {
+ return k8055_read_counter( &dev, counter_n );
+}
+
+int K8055::SetCounterDebounceTime( int counter_n, int debounce_time ) {
+ return k8055_set_counter_debounce_time( &dev, counter_n, debounce_time );
+}
+