Fix ESP32 servos, platformio.ini, etc. (#14247)

This commit is contained in:
felixstorm 2019-06-11 06:22:19 +02:00 committed by Scott Lahteine
parent a373d3f557
commit 9439fab7fd
6 changed files with 24 additions and 18 deletions

View file

@ -193,6 +193,9 @@ void HAL_adc_start_conversion(uint8_t adc_pin) {
} }
void analogWrite(int pin, int value) { void analogWrite(int pin, int value) {
if (!PWM_PIN(pin)) return;
static int cnt_channel = 1, static int cnt_channel = 1,
pin_to_channel[40] = {}; pin_to_channel[40] = {};
if (pin_to_channel[pin] == 0) { if (pin_to_channel[pin] == 0) {

View file

@ -27,7 +27,9 @@
#include "HAL_Servo_ESP32.h" #include "HAL_Servo_ESP32.h"
int Servo::channel_next_free = 0; // Adjacent channels (0/1, 2/3 etc.) share the same timer and therefore the same frequency and resolution settings on ESP32,
// so we only allocate servo channels up high to avoid side effects with regards to analogWrite (fans, leds, laser pwm etc.)
int Servo::channel_next_free = 12;
Servo::Servo() { Servo::Servo() {
this->channel = channel_next_free++; this->channel = channel_next_free++;
@ -42,7 +44,7 @@ int8_t Servo::attach(const int pin) {
return true; return true;
} }
void Servo::detach() { ledcDetachPin(this->pin) } void Servo::detach() { ledcDetachPin(this->pin); }
int Servo::read() { return this->degrees; } int Servo::read() { return this->degrees; }

View file

@ -21,10 +21,11 @@
*/ */
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
#include "../../inc/MarlinConfigPre.h"
#include "i2s.h" #include "i2s.h"
#include "../shared/Marduino.h" #include "../shared/Marduino.h"
#include "../../core/macros.h"
#include "driver/periph_ctrl.h" #include "driver/periph_ctrl.h"
#include "rom/lldesc.h" #include "rom/lldesc.h"
#include "soc/i2s_struct.h" #include "soc/i2s_struct.h"

View file

@ -33,9 +33,3 @@ uint8_t i2s_state(uint8_t pin);
void i2s_write(uint8_t pin, uint8_t val); void i2s_write(uint8_t pin, uint8_t val);
void i2s_push_sample(); void i2s_push_sample();
// pin definitions
#define I2S_WS 25
#define I2S_BCK 26
#define I2S_DATA 27

View file

@ -30,18 +30,24 @@
#define BOARD_NAME "Espressif ESP32" #define BOARD_NAME "Espressif ESP32"
//
// I2S (steppers & other output-only pins)
//
#define I2S_STEPPER_STREAM
#define I2S_WS 25
#define I2S_BCK 26
#define I2S_DATA 27
// //
// Limit Switches // Limit Switches
// //
#define X_MIN_PIN 34 #define X_MIN_PIN 34
#define Y_MIN_PIN 35 #define Y_MIN_PIN 35
#define Z_MIN_PIN 15 #define Z_MIN_PIN 15
// //
// Steppers // Steppers
// //
#define I2S_STEPPER_STREAM
#define X_STEP_PIN 128 #define X_STEP_PIN 128
#define X_DIR_PIN 129 #define X_DIR_PIN 129
#define X_ENABLE_PIN 130 #define X_ENABLE_PIN 130

View file

@ -403,10 +403,10 @@ lib_ignore =
# Espressif ESP32 # Espressif ESP32
# #
[env:esp32] [env:esp32]
platform = https://github.com/platformio/platform-espressif32.git ; #feature/stage platform = espressif32
board = esp32dev board = esp32dev
framework = arduino framework = arduino
upload_speed = 115200 upload_speed = 115200
monitor_speed = 115200 monitor_speed = 115200
upload_port = /dev/ttyUSB0 upload_port = /dev/ttyUSB0
lib_deps = lib_deps =