mirror of
https://github.com/BotChain-Robots/control.git
synced 2026-03-09 16:22:26 +01:00
Oled implementation (#1)
This commit is contained in:
19
examples/display/CMakeLists.txt
Normal file
19
examples/display/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
project(DisplayExample)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(libcontrol REQUIRED)
|
||||
find_package(spdlog REQUIRED)
|
||||
find_package(librpc REQUIRED)
|
||||
|
||||
add_executable(DisplayExample main.cpp)
|
||||
|
||||
target_link_libraries(DisplayExample
|
||||
PRIVATE
|
||||
libcontrol::libcontrol
|
||||
spdlog::spdlog
|
||||
librpc::librpc
|
||||
)
|
||||
9
examples/display/CMakeUserPresets.json
Normal file
9
examples/display/CMakeUserPresets.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": 4,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/CMakePresets.json"
|
||||
]
|
||||
}
|
||||
10
examples/display/README.md
Normal file
10
examples/display/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Display Example
|
||||
|
||||
## Compiling
|
||||
```
|
||||
conan install . --build=missing --output-folder=build -s build_type=Release
|
||||
cmake -S . -B "build" -DCMAKE_TOOLCHAIN_FILE="build/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE="Release"
|
||||
cmake --build "./build" --config "Release"
|
||||
|
||||
./build/DisplayExample
|
||||
```
|
||||
9
examples/display/conanfile.txt
Normal file
9
examples/display/conanfile.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
[requires]
|
||||
libcontrol/1.0.0
|
||||
flatbuffers/24.12.23
|
||||
spdlog/1.16.0
|
||||
librpc/1.1.6
|
||||
|
||||
[generators]
|
||||
CMakeDeps
|
||||
CMakeToolchain
|
||||
31
examples/display/main.cpp
Normal file
31
examples/display/main.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <format>
|
||||
#include <thread>
|
||||
|
||||
#include "libcontrol.h"
|
||||
|
||||
int main() {
|
||||
|
||||
const auto controller = std::make_unique<RobotController>();
|
||||
|
||||
controller->fetchDirectlyConnectedModules(true);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
||||
|
||||
std::cout << "Found " << controller->getModules().size() << " modules" << std::endl;
|
||||
|
||||
for (const auto& maybe_module : controller->getModules()) {
|
||||
if (const auto& module = maybe_module.lock()) {
|
||||
std::cout << "Found module " << (int)module->get_device_id();
|
||||
|
||||
if (module->get_type() == ModuleType_DISPLAY) {
|
||||
module->actuate(std::format("BotChain \n\n\nModule ID: {}", module->get_device_id()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user