Skip to content
Open
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
5 changes: 5 additions & 0 deletions .github/workflows/run-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ jobs:

- name: Install platform
run: |
New-Item -ItemType "directory" -Path "$env:USERPROFILE\Arduino"
New-Item -ItemType "directory" -Path "$env:LOCALAPPDATA\Arduino15\libraries"

arduino-cli config init
arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
arduino-cli config add board_manager.additional_urls https://drazzy.com/package_drazzy.com_index.json
arduino-cli config add board_manager.additional_urls https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
arduino-cli config set directories.builtin.libraries "$env:LOCALAPPDATA\Arduino15\libraries"
arduino-cli config set directories.user "$env:USERPROFILE\Arduino"
arduino-cli config dump

arduino-cli core update-index
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/CMakeLists.txt.user*
/playground

CMakeLists.txt.user*

2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ add_custom_target(
toolchain/Arduino/RulesOverride.cmake
toolchain/Arduino/ScriptMode.cmake
toolchain/Platform/Arduino.cmake
toolchain/Scripts/CollectLibraries.cmake
toolchain/Scripts/Preprocess.cmake
toolchain/Templates/ArduinoLibraryCMakeLists.txt.in
toolchain/Templates/CollectLibrariesConfig.cmake.in
toolchain/Templates/PreprocessConfig.cmake.in
toolchain/arduino-cli-toolchain.cmake)

Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ This project would not have been possible without all the previous hard work
I took good inspiration from it, especially when it comes to making CMake's initial
compiler detection accept Arduinos very special binary layout.

## Third-Party Code

This project's test suites uses example code from third parties:

* [DigitalPotControl](tests/DigitalPotControl/DigitalPotControl.ino)
by _Heather Dewey-Hagborg_ and _Tom Igoe_.
* [EchoString](tests/EchoString/EchoString.ino)
by unknown author: This example code is in the public domain.
* [LinkStatus](tests/LinkStatus/LinkStatus.ino)
by _Cristian Maglie_: This example code is in the public domain.
* [TFTBitmapLogo](tests/TFTBitmapLogo/TFTBitmapLogo.ino)
by _Enrico Gueli_: This example code is in the public domain.
* [TwoPortReceive](tests/TwoPortReceive/TwoPortReceive.ino)
by _Mikal Hart_ and _Tom Igoe_: this example code is in the public domain.

<!-- The following are the link reference definitions used in this document -->

[arduino-avr]: https://github.com/arduino/ArduinoCore-avr
Expand Down
18 changes: 18 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include(platforms.cmake)

cmake_host_system_information(RESULT _logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
message(STATUS "${_logical_cores} logical CPU cores available for testing")
set(CTEST_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/CTestResources.json")
configure_file(CTestResources.json.in "${CTEST_RESOURCE_SPEC_FILE}")

Expand Down Expand Up @@ -75,4 +76,21 @@ function(arduino_cli_toolchain_add_test NAME)
endforeach()
endfunction()

# ======================================================================================================================
# the actual tests
# ======================================================================================================================

# A very minimal sketch without any additional dependencies
arduino_cli_toolchain_add_test(CMakeBlink)

# Some sketches from Arduino examples that use one single core library
arduino_cli_toolchain_add_test(DigitalPotControl SKIP attiny43) # some pins are mising for attiny43
arduino_cli_toolchain_add_test(TwoPortReceive SKIP nano_33_iot nodemcu-32s) # no SoftwareSerial for samd and esp32

# Some sketches from Arduino examples that use core libraries which depend on other core libraries
arduino_cli_toolchain_add_test(EchoString)
arduino_cli_toolchain_add_test(LinkStatus)
arduino_cli_toolchain_add_test(TFTBitmapLogo)

# TBD: A sketch which uses multiple independent libraries
# TDB: A sketch with complex directory structure: multiple .ino files, multiple .cpp files, src folder
3 changes: 3 additions & 0 deletions tests/DigitalPotControl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.19)
project(DigitalPotControl LANGUAGES CXX)
add_executable(DigitalPotControl DigitalPotControl.ino)
73 changes: 73 additions & 0 deletions tests/DigitalPotControl/DigitalPotControl.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Digital Pot Control

This example controls an Analog Devices AD5206 digital potentiometer.
The AD5206 has 6 potentiometer channels. Each channel's pins are labeled
A - connect this to voltage
W - this is the pot's wiper, which changes when you set it
B - connect this to ground.

The AD5206 is SPI-compatible,and to command it, you send two bytes,
one with the channel number (0 - 5) and one with the resistance value for the
channel (0 - 255).

The circuit:
* All A pins of AD5206 connected to +5V
* All B pins of AD5206 connected to ground
* An LED and a 220-ohm resistor in series connected from each W pin to ground
* CS - to digital pin 10 (SS pin)
* SDI - to digital pin 11 (MOSI pin)
* CLK - to digital pin 13 (SCK pin)

created 10 Aug 2010
by Tom Igoe

Thanks to Heather Dewey-Hagborg for the original tutorial, 2005

*/


// include the SPI library:
#include <SPI.h>


// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;

void setup() {
// set the slaveSelectPin as an output:
pinMode(slaveSelectPin, OUTPUT);
// initialize SPI:
SPI.begin();
}

void loop() {
// go through the six channels of the digital pot:
for (int channel = 0; channel < 6; channel++) {
// change the resistance on this channel from min to max:
for (int level = 0; level < 255; level++) {
digitalPotWrite(channel, level);
delay(10);
}
// wait a second at the top:
delay(100);
// change the resistance on this channel from max to min:
for (int level = 0; level < 255; level++) {
digitalPotWrite(channel, 255 - level);
delay(10);
}
}

}

void digitalPotWrite(int address, int value) {
// take the SS pin low to select the chip:
digitalWrite(slaveSelectPin, LOW);
delay(100);
// send in the address and value via SPI:
SPI.transfer(address);
SPI.transfer(value);
delay(100);
// take the SS pin high to de-select the chip:
digitalWrite(slaveSelectPin, HIGH);
}
3 changes: 3 additions & 0 deletions tests/EchoString/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.19)
project(EchoString LANGUAGES CXX)
add_executable(EchoString EchoString.ino)
44 changes: 44 additions & 0 deletions tests/EchoString/EchoString.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Firmata is a generic protocol for communicating with microcontrollers
* from software on a host computer. It is intended to work with
* any host computer software package.
*
* To download a host software package, please click on the following link
* to open the list of Firmata client libraries in your default browser.
*
* https://github.com/firmata/arduino#firmata-client-libraries
*/

/* This sketch accepts strings and raw sysex messages and echos them back.
*
* This example code is in the public domain.
*/
#include <Firmata.h>

void stringCallback(char *myString)
{
Firmata.sendString(myString);
}


void sysexCallback(byte command, byte argc, byte *argv)
{
Firmata.sendSysex(command, argc, argv);
}

void setup()
{
Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);
Firmata.attach(STRING_DATA, stringCallback);
Firmata.attach(START_SYSEX, sysexCallback);
Firmata.begin(57600);
}

void loop()
{
while (Firmata.available()) {
Firmata.processInput();
}
}


3 changes: 3 additions & 0 deletions tests/LinkStatus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.19)
project(LinkStatus LANGUAGES CXX)
add_executable(LinkStatus LinkStatus.ino)
44 changes: 44 additions & 0 deletions tests/LinkStatus/LinkStatus.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Link Status

This sketch prints the Ethernet link status. When the
Ethernet cable is connected the link status should go to "ON".
NOTE: Only WIZnet W5200 and W5500 are capable of reporting
the link status. W5100 will report "Unknown".
Hardware:
- Ethernet shield or equivalent board/shield with WIZnet W5200/W5500
Written by Cristian Maglie
This example is public domain.
*/

#include <SPI.h>
#include <Ethernet.h>

void setup() {
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(10); // Most Arduino shields
//Ethernet.init(5); // MKR ETH Shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit FeatherWing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit FeatherWing Ethernet

Serial.begin(9600);
}

void loop() {
auto link = Ethernet.linkStatus();
Serial.print("Link status: ");
switch (link) {
case Unknown:
Serial.println("Unknown");
break;
case LinkON:
Serial.println("ON");
break;
case LinkOFF:
Serial.println("OFF");
break;
}
delay(1000);
}
3 changes: 3 additions & 0 deletions tests/TFTBitmapLogo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.19)
project(TFTBitmapLogo LANGUAGES CXX)
add_executable(TFTBitmapLogo TFTBitmapLogo.ino)
108 changes: 108 additions & 0 deletions tests/TFTBitmapLogo/TFTBitmapLogo.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*

Arduino TFT Bitmap Logo example

This example reads an image file from a micro-SD card
and draws it on the screen, at random locations.

In this sketch, the Arduino logo is read from a micro-SD card.
There is a .bmp file included with this sketch.
- open the sketch folder (Ctrl-K or Cmd-K)
- copy the "colors.bmp" file to a micro-SD
- put the SD into the SD slot of the Arduino TFT module.

This example code is in the public domain.

Created 19 April 2013 by Enrico Gueli

http://www.arduino.cc/en/Tutorial/TFTBitmapLogo

*/

// include the necessary libraries
#include <SPI.h>
#include <SD.h>
#include <TFT.h> // Arduino LCD library

// pin definition for the Uno
#define sd_cs 4
#define lcd_cs 10
#define dc 9
#define rst 8

// pin definition for the Leonardo
//#define sd_cs 8
//#define lcd_cs 7
//#define dc 0
//#define rst 1

TFT TFTscreen = TFT(lcd_cs, dc, rst);

// this variable represents the image to be drawn on screen
PImage logo;


void setup() {
// initialize the GLCD and show a message
// asking the user to open the serial line
TFTscreen.begin();
TFTscreen.background(255, 255, 255);

TFTscreen.stroke(0, 0, 255);
TFTscreen.println();
TFTscreen.println(F("Arduino TFT Bitmap Example"));
TFTscreen.stroke(0, 0, 0);
TFTscreen.println(F("Open serial monitor"));
TFTscreen.println(F("to run the sketch"));

// initialize the serial port: it will be used to
// print some diagnostic info
Serial.begin(9600);
while (!Serial) {
// wait for serial port to connect. Needed for native USB port only
}

// clear the GLCD screen before starting
TFTscreen.background(255, 255, 255);

// try to access the SD card. If that fails (e.g.
// no card present), the setup process will stop.
Serial.print(F("Initializing SD card..."));
if (!SD.begin(sd_cs)) {
Serial.println(F("failed!"));
return;
}
Serial.println(F("OK!"));

// initialize and clear the GLCD screen
TFTscreen.begin();
TFTscreen.background(255, 255, 255);

// now that the SD card can be access, try to load the
// image file.
logo = TFTscreen.loadImage("colors.bmp");
if (!logo.isValid()) {
Serial.println(F("error while loading colors.bmp"));
}
}

void loop() {
// don't do anything if the image wasn't loaded correctly.
if (logo.isValid() == false) {
return;
}

Serial.println(F("drawing image"));

// get a random location where to draw the image.
// To avoid the image to be draw outside the screen,
// take into account the image size.
int x = random(TFTscreen.width() - logo.width());
int y = random(TFTscreen.height() - logo.height());

// draw the image to the screen
TFTscreen.image(logo, x, y);

// wait a little bit before drawing again
delay(1500);
}
Binary file added tests/TFTBitmapLogo/colors.bmp
Binary file not shown.
3 changes: 3 additions & 0 deletions tests/TwoPortReceive/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.19)
project(TwoPortReceive LANGUAGES CXX)
add_executable(TwoPortReceive TwoPortReceive.ino)
Loading