Add examples for debug output
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
parent
d3d63a30a4
commit
c96c9f0f8c
7 changed files with 169 additions and 1 deletions
|
@ -8,6 +8,7 @@ set(FUSION_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/modules/Fusion)
|
|||
set(FUSION_LIBRARY Fusion)
|
||||
|
||||
add_subdirectory(interface_lib)
|
||||
add_subdirectory(examples)
|
||||
|
||||
add_executable(nrealAirLinuxDriver
|
||||
src/driver.c
|
||||
|
|
3
examples/CMakeLists.txt
Normal file
3
examples/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
add_subdirectory(debug_d3)
|
||||
add_subdirectory(debug_d4)
|
17
examples/debug_d3/CMakeLists.txt
Normal file
17
examples/debug_d3/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(nrealAirDebugD3)
|
||||
|
||||
set(CMAKE_C_STANDARD 17)
|
||||
|
||||
add_library(
|
||||
nrealAirDebugD3
|
||||
src/debug.c
|
||||
)
|
||||
|
||||
target_include_directories(nrealAirDebugD3
|
||||
BEFORE PUBLIC ${NRA_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(nrealAirDebugD3
|
||||
${NRA_LIBRARY}
|
||||
)
|
64
examples/debug_d3/src/debug.c
Normal file
64
examples/debug_d3/src/debug.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// Created by thejackimonster on 05.04.23.
|
||||
//
|
||||
// Copyright (c) 2023 thejackimonster. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#include "device3.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void test3(uint64_t timestamp,
|
||||
device3_event_type event,
|
||||
const device3_ahrs_type* ahrs) {
|
||||
device3_quat_type orientation;
|
||||
device3_vec3_type euler;
|
||||
|
||||
switch (event) {
|
||||
case DEVICE3_EVENT_INIT:
|
||||
printf("Initialized\n");
|
||||
break;
|
||||
case DEVICE3_EVENT_UPDATE:
|
||||
orientation = device3_get_orientation(ahrs);
|
||||
euler = device3_get_euler(orientation);
|
||||
printf("Pitch: %.2f; Roll: %.2f; Yaw: %.2f\n", euler.x, euler.y, euler.z);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
device3_type* dev3 = device3_open(test3);
|
||||
|
||||
if (!dev3) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (dev3) {
|
||||
if (device3_read(dev3, 0) < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
device3_close(dev3);
|
||||
return 0;
|
||||
}
|
17
examples/debug_d4/CMakeLists.txt
Normal file
17
examples/debug_d4/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(nrealAirDebugD4)
|
||||
|
||||
set(CMAKE_C_STANDARD 17)
|
||||
|
||||
add_library(
|
||||
nrealAirDebugD4
|
||||
src/debug.c
|
||||
)
|
||||
|
||||
target_include_directories(nrealAirDebugD4
|
||||
BEFORE PUBLIC ${NRA_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(nrealAirDebugD4
|
||||
${NRA_LIBRARY}
|
||||
)
|
66
examples/debug_d4/src/debug.c
Normal file
66
examples/debug_d4/src/debug.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
//
|
||||
// Created by thejackimonster on 05.04.23.
|
||||
//
|
||||
// Copyright (c) 2023 thejackimonster. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#include "device4.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void test4(uint32_t timestamp,
|
||||
device4_event_type event,
|
||||
uint8_t brightness,
|
||||
const char* msg) {
|
||||
switch (event) {
|
||||
case DEVICE4_EVENT_MESSAGE:
|
||||
printf("Message: `%s`\n", msg);
|
||||
break;
|
||||
case DEVICE4_EVENT_BRIGHTNESS_SET:
|
||||
printf("Set Brightness: %u\n", brightness);
|
||||
break;
|
||||
case DEVICE4_EVENT_BRIGHTNESS_UP:
|
||||
printf("Increase Brightness: %u\n", brightness);
|
||||
break;
|
||||
case DEVICE4_EVENT_BRIGHTNESS_DOWN:
|
||||
printf("Decrease Brightness: %u\n", brightness);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
device4_type* dev4 = device4_open(test4);
|
||||
|
||||
if (!dev4) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (dev4) {
|
||||
if (device4_read(dev4, 0) < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
device4_close(dev4);
|
||||
return 0;
|
||||
}
|
|
@ -24,5 +24,5 @@ target_link_libraries(nrealAirLibrary
|
|||
${LIBUSB1_LIBRARIES} ${FUSION_LIBRARY} m
|
||||
)
|
||||
|
||||
set(NRA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include PARENT_SCOPE)
|
||||
set(NRA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
|
||||
set(NRA_LIBRARY nrealAirLibrary PARENT_SCOPE)
|
||||
|
|
Reference in a new issue