diff --git a/.github/workflows/doxygen-gh-pages.yml b/.github/workflows/doxygen-gh-pages.yml new file mode 100644 index 0000000..b3a60a2 --- /dev/null +++ b/.github/workflows/doxygen-gh-pages.yml @@ -0,0 +1,16 @@ +name: Doxygen GitHub Pages Deploy Action + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: DenverCoder1/doxygen-github-pages-action@v1.2.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + folder: docs/html + branch: doxygen \ No newline at end of file diff --git a/ArduinoLibrary.cmake b/Arduino.cmake similarity index 85% rename from ArduinoLibrary.cmake rename to Arduino.cmake index a810f88..11b8206 100644 --- a/ArduinoLibrary.cmake +++ b/Arduino.cmake @@ -1,10 +1,10 @@ -# ArduinoLibrary.cmake +# Arduino.cmake # Defines a function to easily add Arduino-style libraries to your CMake project. # # Example usage for arduino-SAM library from GitHub -# Place this in your CMakeLists.txt after including ArduinoLibrary.cmake +# Place this in your CMakeLists.txt after including Arduino.cmake # -# include(${CMAKE_SOURCE_DIR}/ArduinoLibrary.cmake) +# include(${CMAKE_SOURCE_DIR}/Arduino.cmake) # arduino_library(arduino-SAM "https://github.com/pschatzmann/arduino-SAM") # target_link_libraries(your_target PRIVATE arduino-SAM) @@ -31,22 +31,32 @@ function(arduino_library LIB_NAME LIB_PATH) endif() set(LIB_PATH "${CLONE_DIR}") endif() - set(INC_DIR "${LIB_PATH}/src") - file(GLOB SRC_FILES - "${LIB_PATH}/src/*.c" - "${LIB_PATH}/src/*.cpp" - ) + if(EXISTS "${LIB_PATH}/src") + set(INC_DIR "${LIB_PATH}/src") + file(GLOB_RECURSE SRC_FILES + "${LIB_PATH}/src/*.c" + "${LIB_PATH}/src/*.cpp" + ) + else() + # Legacy libraries without src folder + set(INC_DIR "${LIB_PATH}") + file(GLOB_RECURSE SRC_FILES + "${LIB_PATH}/*.c" + "${LIB_PATH}/*.cpp" + ) + endif() # Only create library if there are source files if(SRC_FILES) add_library(${LIB_NAME} STATIC ${SRC_FILES}) target_compile_options(${LIB_NAME} PRIVATE -DPROGMEM=) # Ensure C files are compiled as C, not C++ set_target_properties(${LIB_NAME} PROPERTIES LINKER_LANGUAGE C) + target_include_directories(${LIB_NAME} PUBLIC ${INC_DIR}) else() # Create a header-only interface library if no source files add_library(${LIB_NAME} INTERFACE) + target_include_directories(${LIB_NAME} INTERFACE ${INC_DIR}) endif() - target_include_directories(${LIB_NAME} PUBLIC ${INC_DIR}) # Link arduino_emulator to propagate its include directories if(TARGET arduino_emulator) if(SRC_FILES) @@ -54,8 +64,10 @@ function(arduino_library LIB_NAME LIB_PATH) else() # For interface libraries, use INTERFACE linkage target_link_libraries(${LIB_NAME} INTERFACE arduino_emulator) - endif() + endif() + endif() + endfunction() # arduino_sketch( [LIBRARIES ...] [DEFINITIONS ...]) @@ -107,11 +119,7 @@ function(arduino_sketch name ino_file) target_compile_definitions(${name} PUBLIC ${ARG_DEFINITIONS}) endif() - # Add platform-specific libraries - if (USE_RPI) - target_link_libraries(${name} gpiod) - endif(USE_RPI) - + # Handle FTDI support if specified if (USE_FTDI) # Find and link libftdi1 find_package(PkgConfig REQUIRED) diff --git a/ArduinoCore-Linux/cores/arduino/HardwareSetupRemote.h b/ArduinoCore-Linux/cores/arduino/HardwareSetupRemote.h index 0d7e68e..a097252 100644 --- a/ArduinoCore-Linux/cores/arduino/HardwareSetupRemote.h +++ b/ArduinoCore-Linux/cores/arduino/HardwareSetupRemote.h @@ -76,6 +76,7 @@ class HardwareSetupRemote : public I2CSource, // setup global objects if (asDefault) { + Logger.warning("GPIO, I2C, SPI set up for Remote"); SPI.setSPI(&spi); Wire.setI2C(&i2c); GPIO.setGPIO(&gpio); diff --git a/ArduinoCore-Linux/cores/arduino/WProgram.h b/ArduinoCore-Linux/cores/arduino/WProgram.h new file mode 100644 index 0000000..4efcac3 --- /dev/null +++ b/ArduinoCore-Linux/cores/arduino/WProgram.h @@ -0,0 +1,22 @@ +/* + WProgram.h - Legacy Main include file for the Arduino SDK + Copyright (c) 2025 Phil Schatzmann. All right reserved. + + This 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. + + This 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 Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#pragma once +// This is for compatibility with older Arduino libraries that still include WProgram.h +// It is recommended to use Arduino.h instead of WProgram.h in new code +#include "Arduino.h" diff --git a/ArduinoCore-Linux/cores/rasperry_pi/HardwareGPIO_RPI.h b/ArduinoCore-Linux/cores/rasperry_pi/HardwareGPIO_RPI.h index e69f90b..e690d85 100644 --- a/ArduinoCore-Linux/cores/rasperry_pi/HardwareGPIO_RPI.h +++ b/ArduinoCore-Linux/cores/rasperry_pi/HardwareGPIO_RPI.h @@ -19,6 +19,7 @@ */ #ifdef USE_RPI #include "HardwareGPIO.h" +#include namespace arduino { diff --git a/ArduinoCore-Linux/cores/rasperry_pi/HardwareSetupRPI.h b/ArduinoCore-Linux/cores/rasperry_pi/HardwareSetupRPI.h index a1b4e6a..53fe60b 100644 --- a/ArduinoCore-Linux/cores/rasperry_pi/HardwareSetupRPI.h +++ b/ArduinoCore-Linux/cores/rasperry_pi/HardwareSetupRPI.h @@ -51,6 +51,7 @@ class HardwareSetupRPI : public I2CSource, public SPISource, public GPIOSource { // define the global hardware interfaces if (asDefault) { + Logger.warning("GPIO, I2C, SPI set up for Raspberry Pi"); GPIO.setGPIO(&gpio); SPI.setSPI(&spi); Wire.setI2C(&i2c); diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eba3f5..ca2a6ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,10 +66,11 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ArduinoCore-Linux/cores/arduino/" target_compile_features(arduino_emulator PUBLIC cxx_std_17) # Include Arduino library functions -include(${CMAKE_CURRENT_SOURCE_DIR}/ArduinoLibrary.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/Arduino.cmake) if (USE_RPI) target_compile_options(arduino_emulator PUBLIC -DUSE_RPI) + target_link_libraries(arduino_emulator gpiod) endif(USE_RPI) if (USE_REMOTE) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 95ce6d2..38d61f6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,6 +7,11 @@ add_subdirectory("serial2") add_subdirectory("using-arduino-library") add_subdirectory("pwm") +# BME280 Sensor Examples +arduino_library(SparkFunBME280 "https://github.com/sparkfun/SparkFun_BME280_Arduino_Library" ) +add_subdirectory("bme280-i2c") +add_subdirectory("bme280-spi") + if(USE_HTTPS) add_subdirectory("wifi-secure") endif(USE_HTTPS) diff --git a/examples/bme280-i2c/CMakeLists.txt b/examples/bme280-i2c/CMakeLists.txt new file mode 100644 index 0000000..0d3a8e8 --- /dev/null +++ b/examples/bme280-i2c/CMakeLists.txt @@ -0,0 +1 @@ +arduino_sketch(bme280-i2c bme280-i2c.ino LIBRARIES SparkFunBME280) diff --git a/examples/bme280-i2c/bme280-i2c.ino b/examples/bme280-i2c/bme280-i2c.ino new file mode 100644 index 0000000..e1d431f --- /dev/null +++ b/examples/bme280-i2c/bme280-i2c.ino @@ -0,0 +1,32 @@ +// Example sketch for the BME280 combined humidity and pressure sensor +// Using I2C communication with the SparkFun BME280 Arduino Library + +#include +#include +#include "SparkFunBME280.h" + +BME280 mySensor; + +void setup() { + Serial.begin(115200); + Serial.println("Reading basic values from BME280"); + // Begin communication over I2C + Wire.begin(); + if (!mySensor.beginI2C(Wire)) { + Serial.println("The sensor did not respond. Please check wiring."); + while (1); // Freeze + } +} + +void loop() { + Serial.print("Humidity: "); + Serial.print(mySensor.readFloatHumidity(), 0); + Serial.print(" Pressure: "); + Serial.print(mySensor.readFloatPressure(), 0); + Serial.print(" Alt: "); + Serial.print(mySensor.readFloatAltitudeMeters(), 1); + Serial.print(" Temp: "); + Serial.println(mySensor.readTempC(), 2); + + delay(1000); +} diff --git a/examples/bme280-spi/CMakeLists.txt b/examples/bme280-spi/CMakeLists.txt new file mode 100644 index 0000000..2082640 --- /dev/null +++ b/examples/bme280-spi/CMakeLists.txt @@ -0,0 +1 @@ +arduino_sketch(bme280-spi bme280-spi.ino LIBRARIES SparkFunBME280) diff --git a/examples/bme280-spi/bme280-spi.ino b/examples/bme280-spi/bme280-spi.ino new file mode 100644 index 0000000..4755f89 --- /dev/null +++ b/examples/bme280-spi/bme280-spi.ino @@ -0,0 +1,32 @@ +// Example sketch for the BME280 combined humidity and pressure sensor +// Using SPI communication with the SparkFun BME280 Arduino Library + +#include +#include +#include "SparkFunBME280.h" + +const int csPin = 13; // Chip select pin for SPI +BME280 mySensor; + +void setup() { + Serial.begin(9600); + Serial.println("Reading basic values from BME280"); + // Begin communication over SPI. Use pin 13 as CS. + if (!mySensor.beginSPI(csPin)) { + Serial.println("The sensor did not respond. Please check wiring."); + while (1); // Freeze + } +} + +void loop() { + Serial.print("Humidity: "); + Serial.print(mySensor.readFloatHumidity(), 0); + Serial.print(" Pressure: "); + Serial.print(mySensor.readFloatPressure(), 0); + Serial.print(" Alt: "); + Serial.print(mySensor.readFloatAltitudeMeters(), 1); + Serial.print(" Temp: "); + Serial.println(mySensor.readTempC(), 2); + + delay(1000); +} diff --git a/examples/serial2/serial2.ino b/examples/serial2/serial2.ino index b8865c0..30196f0 100644 --- a/examples/serial2/serial2.ino +++ b/examples/serial2/serial2.ino @@ -7,6 +7,7 @@ void setup() { } void loop() { + Serial.println("Hallo world from Serial"); Serial2.println("Hallo world from Serial2"); delay(1000); // Wait for 1 second } \ No newline at end of file diff --git a/examples/using-arduino-library/CMakeLists.txt b/examples/using-arduino-library/CMakeLists.txt index 5f6f11d..2122218 100644 --- a/examples/using-arduino-library/CMakeLists.txt +++ b/examples/using-arduino-library/CMakeLists.txt @@ -4,3 +4,4 @@ arduino_library(sam "https://github.com/pschatzmann/arduino-SAM") # Use the arduino_sketch function to build the example with additional libraries arduino_sketch(using-arduino-library using-arduino-library.ino LIBRARIES sam) +