Support compilation for ESP32

This commit is contained in:
Eiren Rain
2021-06-23 14:29:37 +03:00
parent bd1986a4a8
commit 553446e897
15 changed files with 46 additions and 74 deletions

View File

@@ -1478,8 +1478,8 @@ boolean BNO080::getData(uint16_t bytesRemaining)
while (bytesRemaining > 0)
{
uint16_t numberOfBytesToRead = bytesRemaining;
if (numberOfBytesToRead > (I2C_BUFFER_LENGTH - 4))
numberOfBytesToRead = (I2C_BUFFER_LENGTH - 4);
if (numberOfBytesToRead > (BNO_I2C_BUFFER_LENGTH - 4))
numberOfBytesToRead = (BNO_I2C_BUFFER_LENGTH - 4);
_i2cPort->requestFrom((uint8_t)_deviceAddress, (size_t)(numberOfBytesToRead + 4));
if (waitForI2C() == false)
@@ -1544,7 +1544,7 @@ boolean BNO080::sendPacket(uint8_t channelNumber, uint8_t dataLength)
}
else //Do I2C
{
//if(packetLength > I2C_BUFFER_LENGTH) return(false); //You are trying to send too much. Break into smaller packets.
//if(packetLength > BNO_I2C_BUFFER_LENGTH) return(false); //You are trying to send too much. Break into smaller packets.
_i2cPort->beginTransmission(_deviceAddress);

View File

@@ -65,7 +65,7 @@
#else
//The catch-all default is 32
#define I2C_BUFFER_LENGTH 32
#define BNO_I2C_BUFFER_LENGTH 32
#endif
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

View File

@@ -75,6 +75,9 @@ THE SOFTWARE.
#endif
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include <Wire.h>
#ifndef BUFFER_LENGTH
#define BUFFER_LENGTH I2C_BUFFER_LENGTH
#endif
#endif
#else
#include "ArduinoWrapper.h"

View File

@@ -99,7 +99,6 @@ struct Vector3 {
inline Vector3 floor() const;
inline Vector3 sign() const;
inline Vector3 ceil() const;
inline Vector3 round() const;
inline double distance_to(const Vector3& p_b) const;
inline double distance_squared_to(const Vector3& p_b) const;
@@ -179,10 +178,6 @@ Vector3 Vector3::ceil() const {
return Vector3(std::ceil(x), std::ceil(y), std::ceil(z));
}
Vector3 Vector3::round() const {
return Vector3(std::round(x), std::round(y), std::round(z));
}
Vector3 Vector3::lerp(const Vector3& p_b, double p_t) const {
return Vector3(
x + (p_t * (p_b.x - x)),

View File

@@ -39,7 +39,7 @@ THE SOFTWARE.
#include "I2Cdev.h"
#include "helper_3dmath.h"
#include <avr/pgmspace.h>
#include <pgmspace.h>
// MotionApps 2.0 DMP implementation, built using the MPU-6050EVB evaluation board
#define MPU9250_INCLUDE_DMP_MOTIONAPPS20

View File

@@ -37,50 +37,7 @@ THE SOFTWARE.
#include "MPU9250.h"
// Tom Carpenter's conditional PROGMEM code
// http://forum.arduino.cc/index.php?topic=129407.0
#ifdef __AVR__
#include <avr/pgmspace.h>
#else
// Teensy 3.0 library conditional PROGMEM code from Paul Stoffregen
#ifndef _PGMSPACE_H_
#define _PGMSPACE_H_ 1
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
#define F(x) x
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcat_P(dest, src) strcat((dest), (src))
#define strcmp_P(a, b) strcmp((a), (b))
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#endif
#endif
#include <pgmspace.h>
/* Source is from the InvenSense MotionApps v2 demo code. Original source is
* unavailable, unless you happen to be amazing as decompiling binary by

View File

@@ -11,12 +11,8 @@
[env]
lib_deps=
https://github.com/pvizeli/CmdParser.git
[env:esp12e]
platform = espressif8266
board = esp12e
monitor_speed = 115200
framework = arduino
monitor_speed = 115200
; If you want to enable OTA Updates, uncomment and set OTA password here and in credentials.h
; You can set upload_port to device's ip after it's set up for the first time
@@ -24,4 +20,16 @@ monitor_speed = 115200
;upload_protocol = espota
;upload_port = 192.168.1.49
;upload_flags =
; --auth=SlimeVR-OTA
; --auth=SlimeVR-OTA
; Settings for different boards
[env:esp12e]
platform = espressif8266
board = esp12e
; Uncomment below if you want to build for esp32
; Check your board name at https://docs.platformio.org/en/latest/platforms/espressif32.html#boards
;[env:esp32]
;platform = espressif32
;board = esp-wrover-kit

View File

@@ -100,6 +100,8 @@ void BNO080Sensor::motionLoop()
sendResetReason(rr);
digitalWrite(LOADING_LED, LOW);
}
Serial.print("[ERR] Sensor was reset: ");
Serial.println(rr);
}
}

View File

@@ -24,6 +24,10 @@
#ifndef _OWO_CONFIG_H_
#define _OWO_CONFIG_H_
#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif
#define LOADING_LED LED_BUILTIN
#define CALIBRATING_LED LED_BUILTIN

View File

@@ -25,7 +25,7 @@
#include "ota.h"
#include "sensor.h"
#include "configuration.h"
#include "wifi.h"
#include "wifihandler.h"
#include "udpclient.h"
#include "defines.h"
#include "credentials.h"
@@ -100,7 +100,9 @@ void setup()
// join I2C bus
Wire.begin(PIN_IMU_SDA, PIN_IMU_SCL);
#ifdef ESP8266
Wire.setClockStretchLimit(150000L); // Default streatch limit 150mS
#endif
Wire.setClock(100000);
if (hasConfigStored())

View File

@@ -22,7 +22,7 @@
*/
#include "serialcommands.h"
#include "wifi.h"
#include "wifihandler.h"
#include <CmdCallback.hpp>
CmdCallback<5> cmdCallbacks;

View File

@@ -22,9 +22,6 @@
*/
#include "udpclient.h"
#include "configuration.h"
#include "defines.h"
#include "wifi.h"
#define TIMEOUT 3000UL
@@ -36,8 +33,6 @@ unsigned char buf[128];
configRecievedCallback fp_configCallback;
commandRecievedCallback fp_commandCallback;
IPAddress broadcast = IPAddress(255, 255, 255, 255);
int port = 6969;
IPAddress host = IPAddress(255, 255, 255, 255);
bool connected = false;
@@ -152,7 +147,7 @@ void sendFloat(float const value, int type)
}
}
void sendByte(char const value, int type)
void sendByte(unsigned char const value, int type)
{
if (Udp.beginPacket(host, port) > 0)
{
@@ -298,7 +293,7 @@ void sendSerial(uint8_t *const data, int length, int type) {
}
}
void sendSensorInfo(char const sensorId, char const sensorState, int type) {
void sendSensorInfo(unsigned char const sensorId, unsigned char const sensorState, int type) {
if (Udp.beginPacket(host, port) > 0)
{
sendType(type);
@@ -347,7 +342,7 @@ void sendHandshake() {
Udp.write(convert_to_chars((uint32_t) 0, buf), sizeof(uint32_t));
Udp.write(convert_to_chars((uint32_t) 0, buf), sizeof(uint32_t));
Udp.write(convert_to_chars((uint32_t) FIRMWARE_BUILD_NUMBER, buf), sizeof(uint32_t));
Udp.write(FIRMWARE_VERSION, sizeof(FIRMWARE_VERSION));
Udp.write((const unsigned char *) FIRMWARE_VERSION, sizeof(FIRMWARE_VERSION));
if (Udp.endPacket() == 0)
{
Serial.print("Write error: ");

View File

@@ -24,12 +24,18 @@
#ifndef _UDP_CLIENT_H_
#define _UDP_CLIENT_H_
#include <ESP8266WiFi.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <WiFiUdp.h>
#include <Arduino.h>
#include "quat.h"
#include "configuration.h"
#include "sensor.h"
#include "wifihandler.h"
#include "defines.h"
#define PACKET_HEARTBEAT 0
#define PACKET_ROTATION 1
@@ -68,8 +74,8 @@ void sendQuat(Quat * const quaternion, int type);
void sendVector(float * const result, int type);
void sendConfig(DeviceConfig * const config, int type);
void sendFloat(float const value, int type);
void sendByte(char const value, int type);
void sendSensorInfo(char const sensorId, char const sensorState, int type);
void sendByte(unsigned char const value, int type);
void sendSensorInfo(unsigned char const sensorId, unsigned char const sensorState, int type);
void sendRawCalibrationData(int * const data, int type);
void setConfigRecievedCallback(configRecievedCallback);
void setCommandRecievedCallback(commandRecievedCallback);

View File

@@ -21,7 +21,7 @@
THE SOFTWARE.
*/
#include "wifi.h"
#include "wifihandler.h"
#include "udpclient.h"
#include "defines.h"