Skip to content

Commit 734d451

Browse files
committed
new folder to allow sharing modules between flight, controller, and other targets
1 parent 67ba821 commit 734d451

File tree

262 files changed

+3951
-2997
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+3951
-2997
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

CMakeModules/add_submodule.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if(NOT DEFINED MACRO_SUBMODULE_LOADED)
2+
set( ADDED_MODULES "" CACHE INTERNAL "" )
3+
set( MACRO_SUBMODULE_LOADED TRUE )
4+
endif()
5+
6+
7+
macro(add_submodule module_name)
8+
get_property( added_modules CACHE ADDED_MODULES PROPERTY VALUE )
9+
list( FIND added_modules "${module_name}" module_index )
10+
if ( module_index EQUAL -1 )
11+
message(STATUS "Adding module : ${module_name}")
12+
add_subdirectory( ${CMAKE_SOURCE_DIR}/../lib/${module_name} ${CMAKE_BINARY_DIR}/${module_name} )
13+
get_property( added_modules CACHE ADDED_MODULES PROPERTY VALUE )
14+
list( APPEND added_modules "${module_name}" )
15+
set( ADDED_MODULES "${added_modules}" CACHE INTERNAL "" )
16+
get_property( added_modules_new CACHE ADDED_MODULES PROPERTY VALUE )
17+
endif()
18+
endmacro()

controller_pc/CMakeLists.txt

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cmake_minimum_required( VERSION 2.8.11 )
2-
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )
2+
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../CMakeModules" )
3+
include( add_submodule )
4+
5+
enable_language( C CXX ASM )
36
project( controller_pc )
47

58
SET( board "pc" CACHE BOOL "board" )
@@ -35,16 +38,17 @@ else()
3538
endif()
3639

3740

38-
include_directories( ${CMAKE_SOURCE_DIR}/../libcontroller )
39-
include_directories( ${CMAKE_SOURCE_DIR}/../libcontroller/links )
40-
include_directories( ${CMAKE_SOURCE_DIR}/../librawwifi )
41+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/controller )
42+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/links )
43+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/rawwifi )
44+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/debug )
4145
include_directories( ${CMAKE_SOURCE_DIR}/../external/LuaJIT-2.0.4/src )
4246
include_directories( ${CMAKE_SOURCE_DIR}/../external/openh264-master/codec/api/svc )
4347
include_directories( ${Qt5PrintSupport_INCLUDE_DIRS} ${QSCINTILLA_INCLUDE_DIR} ${QSCINTILLA_INCLUDE_DIR}/Qsci )
4448
include_directories( ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/ui ${CMAKE_BINARY_DIR} )
4549

46-
add_subdirectory( ${CMAKE_SOURCE_DIR}/../libcontroller libcontroller )
47-
add_subdirectory( ${CMAKE_SOURCE_DIR}/../libdebug libdebug )
50+
add_submodule( controller )
51+
add_submodule( debug )
4852
if ( ${RAWWIFI_ON} MATCHES 1 )
4953
set( OTHER_LIBS ${OTHER_LIBS} rawwifi )
5054
if ( WIN32 OR MINGW )
@@ -56,14 +60,8 @@ if ( RAWWIFI_ON MATCHES 0 )
5660
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_RAWWIFI" )
5761
endif()
5862

59-
set( OTHER_LIBS ${OTHER_LIBS} -lfftw3f )
63+
set( OTHER_LIBS ${OTHER_LIBS} -lfftw3f )
6064

61-
set( LUA_32 "" )
62-
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
63-
set( LUA_32 "-m32" )
64-
endif()
65-
# add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip ${LUA_32} )
66-
add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip ${LUA_HOST_CC_OPTIONS} )
6765
add_custom_target( libopenh264_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_openh264.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} )
6866

6967
qt5_wrap_ui( controller_pc_UI
@@ -91,10 +89,9 @@ add_executable( controller_pc
9189
)
9290

9391
add_dependencies( controller_pc libopenh264_static )
94-
add_dependencies( controller_pc libluajit_static )
9592
add_dependencies( controller_pc controller )
96-
add_dependencies( controller_pc libdebug )
93+
add_dependencies( controller_pc debuglib )
9794

98-
target_link_libraries( controller_pc -L./ controller libdebug -lluajit_static -ldecoder_static -lopenh264_static ${SHINE_LIBRARIES} ${MP4V2_LIBRARIES} ${QSCINTILLA_LIBRARY} Qt5::Widgets Qt5::OpenGL Qt5::PrintSupport Qt5::Multimedia ${OPENGL_LIBRARIES} -lpthread ${OTHER_LIBS} )
95+
target_link_libraries( controller_pc -L./ controller debuglib -ldecoder_static -lopenh264_static ${SHINE_LIBRARIES} ${MP4V2_LIBRARIES} ${QSCINTILLA_LIBRARY} Qt5::Widgets Qt5::OpenGL Qt5::PrintSupport Qt5::Multimedia ${OPENGL_LIBRARIES} -lpthread ${OTHER_LIBS} )
9996

10097
install( TARGETS controller_pc RUNTIME DESTINATION bin )

controller_pc/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <stdio.h>
2626
#include <RawWifi.h>
2727
#include <Socket.h>
28-
#include <../libdebug/Debug.h>
28+
#include <Debug.h>
2929
#include "ControllerPC.h"
3030

3131
#include "MainWindow.h"

controller_pc/ui/mainWindow.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ color: rgb(255, 255, 255);</string>
15661566
<customwidget>
15671567
<class>QsciScintilla</class>
15681568
<extends>QWidget</extends>
1569-
<header>qsciscintilla.h</header>
1569+
<header>Qsci/qsciscintilla.h</header>
15701570
<container>1</container>
15711571
</customwidget>
15721572
</customwidgets>

controller_rc/ADCs/MCP320x.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
MCP320x::MCP320x( const std::string& devfile )
2727
: mSPI( new SPI( devfile, 500000 ) )
2828
{
29+
mSPI->Connect();
2930
}
3031

3132

@@ -42,23 +43,24 @@ void MCP320x::setSmoothFactor( uint8_t channel, float f )
4243

4344
uint16_t MCP320x::Read( uint8_t channel, float dt )
4445
{
45-
static const int nbx = 4;
46+
static const int nbx = 1;
47+
// static const int nbx = 4;
4648
uint32_t b[3] = { 0, 0, 0 };
4749
uint8_t bx[nbx][3] = { { 0 } };
4850
uint8_t buf[12];
4951

5052
buf[0] = 0b00000110 | ( ( channel & 0b100 ) >> 2 );
5153
buf[1] = ( ( channel & 0b11 ) << 6 );
5254
buf[2] = 0x00;
53-
buf[3] = 0b00000110 | ( ( channel & 0b100 ) >> 2 );
54-
buf[4] = ( ( channel & 0b11 ) << 6 );
55-
buf[5] = 0x00;
56-
buf[6] = 0b00000110 | ( ( channel & 0b100 ) >> 2 );
57-
buf[7] = ( ( channel & 0b11 ) << 6 );
58-
buf[8] = 0x00;
59-
buf[9] = 0b00000110 | ( ( channel & 0b100 ) >> 2 );
60-
buf[10] = ( ( channel & 0b11 ) << 6 );
61-
buf[11] = 0x00;
55+
// buf[3] = 0b00000110 | ( ( channel & 0b100 ) >> 2 );
56+
// buf[4] = ( ( channel & 0b11 ) << 6 );
57+
// buf[5] = 0x00;
58+
// buf[6] = 0b00000110 | ( ( channel & 0b100 ) >> 2 );
59+
// buf[7] = ( ( channel & 0b11 ) << 6 );
60+
// buf[8] = 0x00;
61+
// buf[9] = 0b00000110 | ( ( channel & 0b100 ) >> 2 );
62+
// buf[10] = ( ( channel & 0b11 ) << 6 );
63+
// buf[11] = 0x00;
6264

6365
for ( int i = 0; i < nbx; i++ ) {
6466
if ( mSPI->Transfer( buf, bx[i], 3 ) < 0 ) {
@@ -71,6 +73,8 @@ uint16_t MCP320x::Read( uint8_t channel, float dt )
7173
for ( int i = 0; i < nbx; i++ ) {
7274
ret[i] = ( ( bx[i][1] & 0b1111 ) << 8 ) | bx[i][2];
7375
}
76+
final_ret = ret[0];
77+
/*
7478
for ( int j = 0; j < nbx; j++ ) {
7579
for ( int i = 0; i < nbx; i++ ) {
7680
if ( i != j and std::abs( (int32_t)(ret[i] - ret[j]) ) > 250 ) {
@@ -84,7 +88,7 @@ uint16_t MCP320x::Read( uint8_t channel, float dt )
8488
}
8589
final_ret /= nbx;
8690
final_ret &= 0xFFFFFFF7;
87-
91+
*/
8892
// Raw value
8993
if ( dt == 0.0f ) {
9094
return final_ret;

controller_rc/CMakeLists.txt

Lines changed: 78 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
cmake_minimum_required( VERSION 2.6 )
1+
cmake_minimum_required( VERSION 3.5 )
2+
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../CMakeModules" )
3+
include( add_submodule )
4+
5+
set( CMAKE_CXX_STANDARD 17 )
26

37
# Command line options
48
SET( board "rpi" CACHE BOOL "board" )
@@ -10,6 +14,7 @@ if ( NOT ${board} MATCHES OFF AND NOT ${board} MATCHES "generic" )
1014
set( CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/../Toolchain-${board}.cmake )
1115
endif()
1216

17+
enable_language( C CXX ASM )
1318
project( controller_rc )
1419

1520
# Set compiler options
@@ -45,56 +50,93 @@ include_directories( boards/${board} )
4550
include_directories( ${CMAKE_SOURCE_DIR} )
4651
include_directories( ${CMAKE_BINARY_DIR} )
4752
add_definitions( -DBOARD="${board}" -DBOARD_${board} )
48-
if ( ${USE_MINISTD} MATCHES TRUE )
49-
add_definitions( -DSTD=ministd )
50-
else()
51-
add_definitions( -DSTD=std )
52-
endif()
5353

54-
include_directories( ${CMAKE_SOURCE_DIR}/../libdebug )
55-
include_directories( ${CMAKE_SOURCE_DIR}/../libcontroller )
56-
include_directories( ${CMAKE_SOURCE_DIR}/../libcontroller/links )
54+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/debug )
55+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/controller )
56+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/links )
5757
if ( ${rawwifi} MATCHES "1" OR ${rawwifi} MATCHES "yes" OR ${rawwifi} MATCHES "true" )
58-
include_directories( ${CMAKE_SOURCE_DIR}/../librawwifi )
59-
set( RAWWIFI_LIBS rawwifi -lpcap )
58+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/rawwifi )
59+
# set( RAWWIFI_LIBS rawwifi -lpcap )
6060
add_definitions( -DBUILD_rawwifi )
6161
endif()
62+
63+
include_directories( ${CMAKE_SOURCE_DIR}/../lib/luacore/src )
6264
include_directories( ${CMAKE_SOURCE_DIR}/../external/LuaJIT-2.0.4/src )
63-
add_subdirectory( ${CMAKE_SOURCE_DIR}/../libcontroller libcontroller )
64-
add_subdirectory( ${CMAKE_SOURCE_DIR}/../libdebug libdebug )
65-
66-
add_custom_target( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR}/../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS}strip "-m32" )
67-
add_custom_target( ui_headers COMMAND
68-
${UIC} ${CMAKE_SOURCE_DIR}/ui/main.ui > ${CMAKE_BINARY_DIR}/ui_main.h
69-
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/window.ui > ${CMAKE_BINARY_DIR}/ui_window.h
70-
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/calibrate.ui > ${CMAKE_BINARY_DIR}/ui_calibrate.h
71-
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/camera.ui > ${CMAKE_BINARY_DIR}/ui_camera.h
72-
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/network.ui > ${CMAKE_BINARY_DIR}/ui_network.h
73-
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/settings.ui > ${CMAKE_BINARY_DIR}/ui_settings.h
74-
)
65+
add_submodule( controller )
66+
add_submodule( debug )
7567

76-
# add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/rc_data.cpp COMMAND ${RCC} ${CMAKE_SOURCE_DIR}/ui/data.qrc > ${CMAKE_BINARY_DIR}/rc_data.cpp WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
77-
add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/MainWindow.moc.cpp COMMAND ${MOC} ${CMAKE_SOURCE_DIR}/ui/MainWindow.h > ${CMAKE_BINARY_DIR}/MainWindow.moc.cpp WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
7868

7969
file( GLOB_RECURSE BOARD_SOURCES boards/${board}/*.cpp boards/${board}/*.c )
8070
file( GLOB_RECURSE ADCS_SOURCES ADCs/*.cpp ADCs/*.c )
8171

72+
file( GLOB HEADERS
73+
${CMAKE_SOURCE_DIR}/*.h
74+
${CMAKE_SOURCE_DIR}/boards/rpi/*.h
75+
${CMAKE_SOURCE_DIR}/../lib/controller/*.h
76+
${CMAKE_SOURCE_DIR}/../lib/links/*.h
77+
)
78+
79+
set_source_files_properties( ${CMAKE_BINARY_DIR}/lua_init.cpp PROPERTIES GENERATED TRUE )
80+
set_source_files_properties( ${CMAKE_BINARY_DIR}/rc_data.cpp PROPERTIES GENERATED TRUE )
81+
82+
83+
add_custom_command(
84+
OUTPUT ${CMAKE_BINARY_DIR}/lua_init.cpp
85+
DEPENDS ${CMAKE_SOURCE_DIR}/../lib/luacore/classes.auto.lua ${HEADERS}
86+
COMMAND ${CMAKE_SOURCE_DIR}/../lib/luacore/classes.auto.lua --init=lua_init --output="${CMAKE_BINARY_DIR}/lua_init.cpp" ${HEADERS}
87+
)
88+
add_custom_command(
89+
OUTPUT
90+
${CMAKE_BINARY_DIR}/ui_main.h
91+
${CMAKE_BINARY_DIR}/ui_window.h
92+
${CMAKE_BINARY_DIR}/ui_calibrate.h
93+
${CMAKE_BINARY_DIR}/ui_camera.h
94+
${CMAKE_BINARY_DIR}/ui_network.h
95+
${CMAKE_BINARY_DIR}/ui_settings.h
96+
COMMAND
97+
${UIC} ${CMAKE_SOURCE_DIR}/ui/main.ui > ${CMAKE_BINARY_DIR}/ui_main.h
98+
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/window.ui > ${CMAKE_BINARY_DIR}/ui_window.h
99+
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/calibrate.ui > ${CMAKE_BINARY_DIR}/ui_calibrate.h
100+
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/camera.ui > ${CMAKE_BINARY_DIR}/ui_camera.h
101+
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/network.ui > ${CMAKE_BINARY_DIR}/ui_network.h
102+
&& ${UIC} ${CMAKE_SOURCE_DIR}/ui/settings.ui > ${CMAKE_BINARY_DIR}/ui_settings.h
103+
DEPENDS
104+
${CMAKE_SOURCE_DIR}/ui/main.ui
105+
${CMAKE_SOURCE_DIR}/ui/window.ui
106+
${CMAKE_SOURCE_DIR}/ui/calibrate.ui
107+
${CMAKE_SOURCE_DIR}/ui/camera.ui
108+
${CMAKE_SOURCE_DIR}/ui/network.ui
109+
${CMAKE_SOURCE_DIR}/ui/settings.ui
110+
)
111+
add_custom_target(ui_headers
112+
DEPENDS
113+
${CMAKE_BINARY_DIR}/ui_main.h
114+
${CMAKE_BINARY_DIR}/ui_window.h
115+
${CMAKE_BINARY_DIR}/ui_calibrate.h
116+
${CMAKE_BINARY_DIR}/ui_camera.h
117+
${CMAKE_BINARY_DIR}/ui_network.h
118+
${CMAKE_BINARY_DIR}/ui_settings.h
119+
)
120+
121+
add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/rc_data.cpp COMMAND ${RCC} ${CMAKE_SOURCE_DIR}/ui/data.qrc > ${CMAKE_BINARY_DIR}/rc_data.cpp WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
122+
add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/MainWindow.moc.cpp COMMAND ${MOC} ${CMAKE_SOURCE_DIR}/ui/MainWindow.h > ${CMAKE_BINARY_DIR}/MainWindow.moc.cpp WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
123+
82124
add_executable( controller_rc
83-
main.cpp
84-
Config.cpp
85-
ui/GlobalUI.cpp
86-
ui/MainWindow.cpp
87-
${CMAKE_BINARY_DIR}/rc_data.cpp
88-
${CMAKE_BINARY_DIR}/MainWindow.moc.cpp
89-
${ADCS_SOURCES}
90-
${BOARD_SOURCES}
91-
)
125+
main.cpp
126+
Config.cpp
127+
ui/GlobalUI.cpp
128+
ui/MainWindow.cpp
129+
${CMAKE_BINARY_DIR}/rc_data.cpp
130+
${CMAKE_BINARY_DIR}/MainWindow.moc.cpp
131+
${CMAKE_BINARY_DIR}/lua_init.cpp
132+
${ADCS_SOURCES}
133+
${BOARD_SOURCES}
134+
)
92135

93136
add_dependencies( controller_rc controller )
94-
add_dependencies( controller_rc libluajit_static )
95137
add_dependencies( controller_rc ui_headers )
96138

97139

98-
target_link_libraries( controller_rc -L./ controller libdebug libluajit_static.a -lrt -ldl ${RAWWIFI_LIBS} -lz pthread ${BOARD_LIBS} )
140+
target_link_libraries( controller_rc -L./ controller debuglib -lrt -ldl ${RAWWIFI_LIBS} -lz pthread ${BOARD_LIBS} )
99141

100142
install( TARGETS controller_rc RUNTIME DESTINATION bin )

0 commit comments

Comments
 (0)