Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix compilation on esp32 #4

Merged
merged 19 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 14 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
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Leaphy Extensions
version=1.0.1
version=1.0.2
author=Leaphy Robotics
maintainer=Leaphy Robotics <[email protected]>
sentence=Provides functionality to program all Leaphy robots
Expand All @@ -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

3 changes: 3 additions & 0 deletions src/LSM303AGR.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef AVR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deze file kan weg

#include "LSM303AGR.h"

#define _ADDRESS_MAG 0x1E //!< Default address
Expand Down Expand Up @@ -46,3 +47,5 @@ void CompassSensor::reset() {
void CompassSensor::update() {
CompassSensor::mag.getEvent(data);
}

#endif //#ifdef AVR
4 changes: 4 additions & 0 deletions src/LSM303AGR.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef AVR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deze ook


#ifndef LSM303AGR_H
#define LSM303AGR_H
#include <Wire.h>
Expand All @@ -24,3 +26,5 @@ class CompassSensor {
};

#endif

#endif //#ifdef AVR
3 changes: 3 additions & 0 deletions src/Leaphyoriginal1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// suitable for Fundumoto Shield
// Copyright Science4Kids& Stichting Leaphy 2018
// version 1.0.0 25 JULI 2018
#ifdef AVR

#include "Leaphyoriginal1.h"

Expand Down Expand Up @@ -100,3 +101,5 @@ void setLed(int fpRed, int fpGreen, int fpBlue)
analogWrite(LED1_GREEN, fpGreen);
analogWrite(LED1_BLUE, fpBlue);
}

#endif // #ifdef AVR
2 changes: 2 additions & 0 deletions src/Leaphyoriginal1.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// suitable for Fundumoto Shield
// Copyright Science4Kids 2017
// version 1.0.0 1 February 2017
#ifdef AVR
#ifndef LEAPHYORIGINAL1_H_
#define LEAPHYORIGINAL1_H_

Expand Down Expand Up @@ -53,3 +54,4 @@ void moveMotors(int fpDirection, int fpSpeed);
void setLed(int fpRed, int fpGreen, int fpBlue);

#endif
#endif // #ifdef AVR
8 changes: 8 additions & 0 deletions src/RedMP3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@
#include <SoftwareSerial.h>
#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
Expand Down
4 changes: 4 additions & 0 deletions src/RedMP3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down