diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f8bd697..1a65c03 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -25,6 +25,7 @@ jobs: | # Install arduino AVR arduino-cli core install arduino:avr + arduino-cli core install arduino:esp32 # Install dependencies libs=$(cat library.properties | grep depends | sed 's/depends=//g') IFS=',' read -ra lib <<< "$libs" @@ -37,3 +38,4 @@ jobs: | # Perform test compile arduino-cli compile tests --fqbn arduino:avr:uno --log --library . --clean + arduino-cli compile tests --fqbn arduino:esp32:nano_nora --log --library . --clean diff --git a/library.properties b/library.properties index f2b884a..423c238 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Leaphy Extensions -version=1.0.1 +version=1.0.2 author=Leaphy Robotics maintainer=Leaphy Robotics sentence=Provides functionality to program all Leaphy robots @@ -9,5 +9,5 @@ url=https://github.com/leaphy-robotics/leaphy-extensions architectures=avr # Only include actually used library code in the resulting executable dot_a_linkage=true -depends=Adafruit SSD1306,Adafruit GFX Library,Adafruit LSM303 Accel,Adafruit LIS2MDL,Adafruit BusIO,Adafruit_VL53L0X,Adafruit NeoPixel +depends=Adafruit SSD1306,Adafruit GFX Library,Adafruit LSM303 Accel,Adafruit LIS2MDL,Adafruit BusIO,Adafruit_VL53L0X,Adafruit NeoPixel,EspSoftwareSerial diff --git a/src/LSM303AGR.cpp b/src/LSM303AGR.cpp deleted file mode 100644 index f495b17..0000000 --- a/src/LSM303AGR.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "LSM303AGR.h" - -#define _ADDRESS_MAG 0x1E //!< Default address -#include -#include -#include -#include -#include - -CompassSensor::CompassSensor() { - CompassSensor::mag = Adafruit_LIS2MDL(); - // initiate the event - CompassSensor::mag.getEvent(data); -} - -bool CompassSensor::begin(uint8_t i2c_addr = _ADDRESS_MAG, TwoWire *wire = &Wire) { - CompassSensor::mag.begin(i2c_addr = _ADDRESS_MAG, wire = &Wire); - - return true; -} - -bool CompassSensor::begin_SPI(uint8_t cs_pin, SPIClass *theSPI = &SPI) { - CompassSensor::mag.begin_SPI(cs_pin, theSPI); - - return true; -} - -bool CompassSensor::begin_SPI(int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, int8_t mosi_pin) { - CompassSensor::mag.begin_SPI(cs_pin, sck_pin, miso_pin, mosi_pin); - - return true; -} - -lis2mdl_rate_t CompassSensor::getDataRate() { - return CompassSensor::mag.getDataRate(); -} - -void CompassSensor::setDataRate(lis2mdl_rate_t rate) { - CompassSensor::mag.setDataRate(rate); -} - -void CompassSensor::reset() { - CompassSensor::mag.reset(); -} - -void CompassSensor::update() { - CompassSensor::mag.getEvent(data); -} diff --git a/src/LSM303AGR.h b/src/LSM303AGR.h deleted file mode 100644 index e158e76..0000000 --- a/src/LSM303AGR.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LSM303AGR_H -#define LSM303AGR_H -#include -#include -#include - -class CompassSensor { - private: - Adafruit_LIS2MDL mag; - - - public: - sensors_event_t * data; - CompassSensor(); - bool begin(uint8_t i2c_addr = _ADDRESS_MAG, TwoWire *wire = &Wire); - bool begin_SPI(uint8_t cs_pin, SPIClass *theSPI = &SPI); - bool begin_SPI(int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, - int8_t mosi_pin); - - lis2mdl_rate_t getDataRate(); - void setDataRate(lis2mdl_rate_t rate); - void reset(); - void update(); -}; - -#endif diff --git a/src/Leaphyoriginal1.cpp b/src/Leaphyoriginal1.cpp index d2f1756..c73622d 100644 --- a/src/Leaphyoriginal1.cpp +++ b/src/Leaphyoriginal1.cpp @@ -2,7 +2,6 @@ // suitable for Fundumoto Shield // Copyright Science4Kids& Stichting Leaphy 2018 // version 1.0.0 25 JULI 2018 - #include "Leaphyoriginal1.h" @@ -100,3 +99,4 @@ void setLed(int fpRed, int fpGreen, int fpBlue) analogWrite(LED1_GREEN, fpGreen); analogWrite(LED1_BLUE, fpBlue); } + diff --git a/src/Leaphyoriginal1.h b/src/Leaphyoriginal1.h index 682563a..95c1528 100644 --- a/src/Leaphyoriginal1.h +++ b/src/Leaphyoriginal1.h @@ -10,7 +10,6 @@ #ifndef F_CPU #define F_CPU 16000000UL #endif -#include #include #include diff --git a/src/RedMP3.cpp b/src/RedMP3.cpp index 1d24d0e..f413b75 100644 --- a/src/RedMP3.cpp +++ b/src/RedMP3.cpp @@ -24,10 +24,18 @@ #include #include "RedMP3.h" +#ifdef AVR MP3::MP3(uint8_t rxd, uint8_t txd):myMP3(txd, rxd) { myMP3.begin(9600);//baud rate is 9600bps } +#else +MP3::MP3(uint8_t rxd, uint8_t txd) +{ + myMP3.begin(9600, SWSERIAL_8N1, txd, rxd, false);//baud rate is 9600bps +} +#endif + void MP3::begin() { sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card diff --git a/src/RedMP3.h b/src/RedMP3.h index bbcbe3a..a7f7787 100644 --- a/src/RedMP3.h +++ b/src/RedMP3.h @@ -74,7 +74,11 @@ class MP3 void playCombine(int16_t folderAndIndex[], int8_t number); private: + #ifdef AVR SoftwareSerial myMP3; + #else + EspSoftwareSerial::UART myMP3; + #endif void sendCommand(int8_t command, int16_t dat = 0); void mp3Basic(int8_t command); void mp3_5bytes(int8_t command, uint8_t dat);