Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/doxygen-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Doxygen GitHub Pages Deploy Action

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: DenverCoder1/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
folder: docs/html
branch: doxygen
38 changes: 23 additions & 15 deletions ArduinoLibrary.cmake → Arduino.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -31,31 +31,43 @@ 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)
target_link_libraries(${LIB_NAME} PUBLIC arduino_emulator)
else()
# For interface libraries, use INTERFACE linkage
target_link_libraries(${LIB_NAME} INTERFACE arduino_emulator)
endif()
endif()

endif()

endfunction()

# arduino_sketch(<name> <ino_file> [LIBRARIES <lib1> <lib2> ...] [DEFINITIONS <def1> <def2> ...])
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ArduinoCore-Linux/cores/arduino/HardwareSetupRemote.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 22 additions & 0 deletions ArduinoCore-Linux/cores/arduino/WProgram.h
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions ArduinoCore-Linux/cores/rasperry_pi/HardwareGPIO_RPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
#ifdef USE_RPI
#include "HardwareGPIO.h"
#include <map>


namespace arduino {
Expand Down
1 change: 1 addition & 0 deletions ArduinoCore-Linux/cores/rasperry_pi/HardwareSetupRPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions examples/bme280-i2c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
arduino_sketch(bme280-i2c bme280-i2c.ino LIBRARIES SparkFunBME280)
32 changes: 32 additions & 0 deletions examples/bme280-i2c/bme280-i2c.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Example sketch for the BME280 combined humidity and pressure sensor
// Using I2C communication with the SparkFun BME280 Arduino Library

#include <Arduino.h>
#include <Wire.h>
#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);
}
1 change: 1 addition & 0 deletions examples/bme280-spi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
arduino_sketch(bme280-spi bme280-spi.ino LIBRARIES SparkFunBME280)
32 changes: 32 additions & 0 deletions examples/bme280-spi/bme280-spi.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Example sketch for the BME280 combined humidity and pressure sensor
// Using SPI communication with the SparkFun BME280 Arduino Library

#include <Arduino.h>
#include <SPI.h>
#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);
}
1 change: 1 addition & 0 deletions examples/serial2/serial2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions examples/using-arduino-library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)