From 5fcedb0fcaeeca64661a6f4e5b8d640acbcb26ef Mon Sep 17 00:00:00 2001 From: Russell Gilbert Date: Sat, 7 Feb 2026 04:36:27 +0000 Subject: [PATCH] Initializes project structure for Dixon Robot, config build & link Sets up the initial project structure for the Dixon robot, including core components and build configurations. This commit lays the foundation for future development by: - Adding necessary `.idea` files for IDE configuration, including `.gitignore`, `aws.xml`, `modules.xml`, `vcs.xml`, `editor.xml`, and `encodings.xml` - Creating `Heart` component for managing heart beat with GPIO. - Setting up CMakeLists.txt to define project dependencies and configurations, including specifying C++20 standard and linking necessary libraries. --- .idea/.gitignore | 10 ++ .idea/Dixon.iml | 8 + .idea/aws.xml | 11 ++ .idea/editor.xml | 249 +++++++++++++++++++++++++++ .idea/encodings.xml | 4 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + src/RobotNode/CMakeLists.txt | 12 +- src/RobotNode/CardioCenter/Heart.cpp | 22 +++ src/RobotNode/CardioCenter/Heart.h | 16 ++ 10 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/Dixon.iml create mode 100644 .idea/aws.xml create mode 100644 .idea/editor.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 src/RobotNode/CardioCenter/Heart.cpp create mode 100644 src/RobotNode/CardioCenter/Heart.h diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..69ab804 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/Dixon.iml b/.idea/Dixon.iml new file mode 100644 index 0000000..bc2cd87 --- /dev/null +++ b/.idea/Dixon.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..fef3201 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,249 @@ + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..55d757f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/RobotNode/CMakeLists.txt b/src/RobotNode/CMakeLists.txt index 5f742d2..65145f2 100644 --- a/src/RobotNode/CMakeLists.txt +++ b/src/RobotNode/CMakeLists.txt @@ -1,10 +1,20 @@ +# Sets the minimum CMake version required to handle modern C++ features cmake_minimum_required(VERSION 4.1) + +# Defines the project name (used for internal variable naming and IDE display project(Dixon) +# Forces the compiler to use C++20 features (required for modern libgpiod) set(CMAKE_CXX_STANDARD 20) +# Define the executable and its source files add_executable(Dixon main.cpp DixonNodeState.cpp DixonNodeState.h DixonBrain.cpp - DixonBrain.h) + DixonBrain.h + CardioCenter/Heart.cpp + CardioCenter/Heart.h) + +# 2. Tell the linker what libraries to "glue" to that executable +target_link_libraries(Dixon PRIVATE gpiodcxx gpiod) \ No newline at end of file diff --git a/src/RobotNode/CardioCenter/Heart.cpp b/src/RobotNode/CardioCenter/Heart.cpp new file mode 100644 index 0000000..fb3e3a9 --- /dev/null +++ b/src/RobotNode/CardioCenter/Heart.cpp @@ -0,0 +1,22 @@ +#include "Heart.h" + +Heart::Heart(const char* chipName, unsigned int lineOffset) + : _chip(chipName), + _line(_chip.get_line(lineOffset)), + _isOn(false) +{ + // Request the GPIO line as an output, initial value LOW + _line.request( + { "heart", gpiod::line_request::DIRECTION_OUTPUT, 0 }, + 0 + ); +} + +void Heart::beat() +{ + // Toggle the state + _isOn = !_isOn; + + // Write the new value to the GPIO line + _line.set_value(_isOn ? 1 : 0); +} \ No newline at end of file diff --git a/src/RobotNode/CardioCenter/Heart.h b/src/RobotNode/CardioCenter/Heart.h new file mode 100644 index 0000000..a76a30e --- /dev/null +++ b/src/RobotNode/CardioCenter/Heart.h @@ -0,0 +1,16 @@ +#pragma once +#include + +class Heart +{ +public: + Heart(const char* chipName = "gpiochip0", unsigned int lineOffset = 17); + + // DixonBrain calls this when a beat occurs + void beat(); + +private: + gpiod::chip _chip; + gpiod::line _line; + bool _isOn; +}; \ No newline at end of file