Преглед на файлове

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

felixstorm преди 6 години
родител
ревизия
9439fab7fd

+ 3
- 0
Marlin/src/HAL/HAL_ESP32/HAL.cpp Целия файл

193
 }
193
 }
194
 
194
 
195
 void analogWrite(int pin, int value) {
195
 void analogWrite(int pin, int value) {
196
+
197
+  if (!PWM_PIN(pin)) return;
198
+
196
   static int cnt_channel = 1,
199
   static int cnt_channel = 1,
197
              pin_to_channel[40] = {};
200
              pin_to_channel[40] = {};
198
   if (pin_to_channel[pin] == 0) {
201
   if (pin_to_channel[pin] == 0) {

+ 4
- 2
Marlin/src/HAL/HAL_ESP32/HAL_Servo_ESP32.cpp Целия файл

27
 
27
 
28
 #include "HAL_Servo_ESP32.h"
28
 #include "HAL_Servo_ESP32.h"
29
 
29
 
30
-int Servo::channel_next_free = 0;
30
+// Adjacent channels (0/1, 2/3 etc.) share the same timer and therefore the same frequency and resolution settings on ESP32,
31
+// so we only allocate servo channels up high to avoid side effects with regards to analogWrite (fans, leds, laser pwm etc.)
32
+int Servo::channel_next_free = 12;
31
 
33
 
32
 Servo::Servo() {
34
 Servo::Servo() {
33
   this->channel = channel_next_free++;
35
   this->channel = channel_next_free++;
42
   return true;
44
   return true;
43
 }
45
 }
44
 
46
 
45
-void Servo::detach() { ledcDetachPin(this->pin) }
47
+void Servo::detach() { ledcDetachPin(this->pin); }
46
 
48
 
47
 int Servo::read() { return this->degrees; }
49
 int Servo::read() { return this->degrees; }
48
 
50
 

+ 2
- 1
Marlin/src/HAL/HAL_ESP32/i2s.cpp Целия файл

21
  */
21
  */
22
 #ifdef ARDUINO_ARCH_ESP32
22
 #ifdef ARDUINO_ARCH_ESP32
23
 
23
 
24
+#include "../../inc/MarlinConfigPre.h"
25
+
24
 #include "i2s.h"
26
 #include "i2s.h"
25
 
27
 
26
 #include "../shared/Marduino.h"
28
 #include "../shared/Marduino.h"
27
-#include "../../core/macros.h"
28
 #include "driver/periph_ctrl.h"
29
 #include "driver/periph_ctrl.h"
29
 #include "rom/lldesc.h"
30
 #include "rom/lldesc.h"
30
 #include "soc/i2s_struct.h"
31
 #include "soc/i2s_struct.h"

+ 0
- 6
Marlin/src/HAL/HAL_ESP32/i2s.h Целия файл

33
 void i2s_write(uint8_t pin, uint8_t val);
33
 void i2s_write(uint8_t pin, uint8_t val);
34
 
34
 
35
 void i2s_push_sample();
35
 void i2s_push_sample();
36
-
37
-// pin definitions
38
-
39
-#define I2S_WS 25
40
-#define I2S_BCK 26
41
-#define I2S_DATA 27

+ 11
- 5
Marlin/src/pins/pins_ESP32.h Целия файл

31
 #define BOARD_NAME "Espressif ESP32"
31
 #define BOARD_NAME "Espressif ESP32"
32
 
32
 
33
 //
33
 //
34
+// I2S (steppers & other output-only pins)
35
+//
36
+#define I2S_STEPPER_STREAM
37
+#define I2S_WS              25
38
+#define I2S_BCK             26
39
+#define I2S_DATA            27
40
+
41
+//
34
 // Limit Switches
42
 // Limit Switches
35
 //
43
 //
36
-#define X_MIN_PIN          34
37
-#define Y_MIN_PIN          35
38
-#define Z_MIN_PIN          15
44
+#define X_MIN_PIN           34
45
+#define Y_MIN_PIN           35
46
+#define Z_MIN_PIN           15
39
 
47
 
40
 //
48
 //
41
 // Steppers
49
 // Steppers
42
 //
50
 //
43
-#define I2S_STEPPER_STREAM
44
-
45
 #define X_STEP_PIN         128
51
 #define X_STEP_PIN         128
46
 #define X_DIR_PIN          129
52
 #define X_DIR_PIN          129
47
 #define X_ENABLE_PIN       130
53
 #define X_ENABLE_PIN       130

+ 4
- 4
platformio.ini Целия файл

403
 # Espressif ESP32
403
 # Espressif ESP32
404
 #
404
 #
405
 [env:esp32]
405
 [env:esp32]
406
-platform    = https://github.com/platformio/platform-espressif32.git ; #feature/stage
407
-board       = esp32dev
408
-framework   = arduino
409
-upload_speed = 115200
406
+platform      = espressif32
407
+board         = esp32dev
408
+framework     = arduino
409
+upload_speed  = 115200
410
 monitor_speed = 115200
410
 monitor_speed = 115200
411
 upload_port = /dev/ttyUSB0
411
 upload_port = /dev/ttyUSB0
412
 lib_deps =
412
 lib_deps =

Loading…
Отказ
Запис