SmartKnob Firmware

Wuzi

December 2021, 24

13 min read

SmartKnob Firmware

Getting Started

Open the smartknob/firmware directory with VS Code. (Just open the firmware directory, not the whole smartknob directory)

Install VS Code Extensions

  • Better C++ Syntax
  • C/C++
  • C/C++ Extension Pack
  • C/C++ Themes
  • CMake
  • CMake Tools
  • Code Runner
  • Doxygen Documentation Generator
  • PlatformIO IDE
  • XML Tools

Flush Firmware

If everything is OK. You can see the following three icons in the toolbar under VS Code.

From left to right: Compile, Write, Serial Monitor.

Compile

Click Position 1 to start compile with following output:

* 正在执行任务: C:\Users\piercebrands\.platformio\penv\Scripts\platformio.exe run
Processing view (board: esp32doit-devkit-v1; platform: espressif32@3.4; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/toolchain-xtensa32 @ ~2.50200.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-xtensa32@2.50200.97 has been installed!
Tool Manager: Installing platformio/framework-arduinoespressif32 @ ~3.10006.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: framework-arduinoespressif32@3.10006.210326 has been installed!
Tool Manager: Installing platformio/tool-esptoolpy @ ~1.30100.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-esptoolpy@1.30100.210531 has been installed!
Library Manager: Installing askuric/Simple FOC @ 2.2.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Library Manager: Simple FOC@2.2.0 has been installed!
Library Manager: Installing infineon/TLV493D-Magnetic-Sensor @ 1.0.3
Downloading [####################################] 100%
Unpacking [####################################] 100%
Library Manager: TLV493D-Magnetic-Sensor@1.0.3 has been installed!
Library Manager: Installing bxparks/AceButton @ 1.9.1
Downloading [####################################] 100%
Unpacking [####################################] 100%
Library Manager: AceButton@1.9.1 has been installed!
Library Manager: Installing bodmer/TFT_eSPI @ 2.4.25
Downloading [####################################] 100%
Unpacking [####################################] 100%
Library Manager: TFT_eSPI@2.4.25 has been installed!
Library Manager: Installing fastled/FastLED @ 3.5.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Library Manager: FastLED@3.5.0 has been installed!
Library Manager: Installing bogde/HX711 @ 0.7.5
Downloading [####################################] 100%
Unpacking [####################################] 100%
Library Manager: HX711@0.7.5 has been installed!
Library Manager: Installing adafruit/Adafruit VEML7700 Library @ 1.1.1
Downloading [####################################] 100%
Unpacking [####################################] 100%
Library Manager: Adafruit VEML7700 Library@1.1.1 has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing Adafruit BusIO
Downloading [####################################] 100%
Unpacking [####################################] 100%
Library Manager: Adafruit BusIO@1.13.2 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40400.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-scons@4.40400.0 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (3.4.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
- tool-esptoolpy @ 1.30100.210531 (3.1.0)
- toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Simple FOC @ 2.2.0
| |-- Wire @ 1.0.1
| |-- SPI @ 1.0
|-- TLV493D-Magnetic-Sensor @ 1.0.3
| |-- Wire @ 1.0.1
|-- AceButton @ 1.9.1
|-- TFT_eSPI @ 2.4.25
| |-- SPI @ 1.0
| |-- SPIFFS @ 1.0
| | |-- FS @ 1.0
| |-- FS @ 1.0
|-- FastLED @ 3.5.0
| |-- SPI @ 1.0
|-- HX711 @ 0.7.5
|-- Adafruit VEML7700 Library @ 1.1.1
| |-- Adafruit BusIO @ 1.13.2
| | |-- Wire @ 1.0.1
| | |-- SPI @ 1.0
| |-- Wire @ 1.0.1
| |-- SPI @ 1.0
Building in release mode
Compiling .pio\build\view\libcd9\FastLED\FastLED.cpp.o
Compiling .pio\build\view\libcd9\FastLED\bitswap.cpp.o
Compiling .pio\build\view\libcd9\FastLED\colorpalettes.cpp.o
Compiling .pio\build\view\libcd9\FastLED\colorutils.cpp.o
Compiling .pio\build\view\libcd9\FastLED\hsv2rgb.cpp.o
Compiling .pio\build\view\libcd9\FastLED\lib8tion.cpp.o
Compiling .pio\build\view\libcd9\FastLED\noise.cpp.o
Compiling .pio\build\view\libcd9\FastLED\platforms.cpp.o
Compiling .pio\build\view\libcd9\FastLED\platforms\esp\32\clockless_rmt_esp32.cpp.o
Compiling .pio\build\view\libcd9\FastLED\power_mgt.cpp.o
Compiling .pio\build\view\libcd9\FastLED\wiring.cpp.o
Compiling .pio\build\view\src\display_task.cpp.o
Compiling .pio\build\view\src\interface_task.cpp.o
Compiling .pio\build\view\src\main.cpp.o
Compiling .pio\build\view\src\motor_task.cpp.o
Compiling .pio\build\view\src\mt6701_sensor.cpp.o
Compiling .pio\build\view\src\tlv_sensor.cpp.o
Generating partitions .pio\build\view\partitions.bin
Compiling .pio\build\view\libb39\Wire\Wire.cpp.o
Compiling .pio\build\view\lib8f9\SPI\SPI.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\BLDCMotor.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\StepperMotor.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\common\base_classes\CurrentSense.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\common\base_classes\FOCMotor.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\common\base_classes\Sensor.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\common\foc_utils.cpp.o
Archiving .pio\build\view\lib8f9\libSPI.a
Indexing .pio\build\view\lib8f9\libSPI.a
Compiling .pio\build\view\lib44f\Simple FOC\common\lowpass_filter.cpp.o
.pio/libdeps/view/Simple FOC/src/common/foc_utils.cpp: In function 'float _sqrtApprox(float)':
.pio/libdeps/view/Simple FOC/src/common/foc_utils.cpp:68:21: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
i = * ( long * ) &y;
^
.pio/libdeps/view/Simple FOC/src/common/foc_utils.cpp:70:22: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
y = * ( float * ) &i;
^
src/motor_task.cpp: In member function 'void MotorTask::run()':
src/motor_task.cpp:280:37: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
command.add('M', &doMotor, "foo");
^
src/motor_task.cpp:296:14: warning: unused variable 'last_debug' [-Wunused-variable]
uint32_t last_debug = 0;
^
src/mt6701_sensor.cpp: In member function 'virtual float MT6701Sensor::getSensorAngle()':
src/mt6701_sensor.cpp:94:15: warning: unused variable 'field_status' [-Wunused-variable]
uint8_t field_status = (spi_32 >> 6) & 0x3;
^
src/mt6701_sensor.cpp:95:15: warning: unused variable 'push_status' [-Wunused-variable]
uint8_t push_status = (spi_32 >> 8) & 0x1;
^
src/mt6701_sensor.cpp:96:15: warning: unused variable 'loss_status' [-Wunused-variable]
uint8_t loss_status = (spi_32 >> 9) & 0x1;
^
.pio/libdeps/view/FastLED/src/platforms/esp/32/clockless_rmt_esp32.cpp: In static member function 'static void ESP32RMTController::init(gpio_num_t)':
.pio/libdeps/view/FastLED/src/platforms/esp/32/clockless_rmt_esp32.cpp:111:15: warning: variable 'espErr' set but not used [-Wunused-but-set-variable]
esp_err_t espErr = ESP_OK;
^
.pio/libdeps/view/FastLED/src/platforms/esp/32/clockless_rmt_esp32.cpp: In member function 'void ESP32RMTController::startOnChannel(int)':
.pio/libdeps/view/FastLED/src/platforms/esp/32/clockless_rmt_esp32.cpp:239:15: warning: variable 'espErr' set but not used [-Wunused-but-set-variable]
esp_err_t espErr = ESP_OK;
^
Compiling .pio\build\view\lib44f\Simple FOC\common\pid.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\common\time_utils.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\communication\Commander.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\communication\StepDirListener.cpp.o
Archiving .pio\build\view\libb39\libWire.a
In file included from .pio/libdeps/view/FastLED/src/FastLED.h:67:0,
from src/interface_task.cpp:4:
.pio/libdeps/view/FastLED/src/fastspi.h:145:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
# pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\InlineCurrentSense.cpp.o
^
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\LowsideCurrentSense.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\atmega_mcu.cpp.o
Indexing .pio\build\view\libb39\libWire.a
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\due_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\esp32_adc_driver.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\esp32_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\generic_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\samd21_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\samd_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\stm32_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\stm32g4_hal.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\stm32g4_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\current_sense\hardware_specific\teensy_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\BLDCDriver3PWM.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\BLDCDriver6PWM.cpp.o
src/display_task.cpp: In member function 'void DisplayTask::run()':
src/display_task.cpp:106:13: warning: unused variable 'pointer_center_x' [-Wunused-variable]
int32_t pointer_center_x = TFT_WIDTH / 2;
^
src/display_task.cpp:107:13: warning: unused variable 'pointer_center_y' [-Wunused-variable]
int32_t pointer_center_y = TFT_HEIGHT / 2;
^
src/display_task.cpp:108:13: warning: unused variable 'pointer_length_short' [-Wunused-variable]
int32_t pointer_length_short = 10;
^
src/display_task.cpp:109:13: warning: unused variable 'pointer_length_long' [-Wunused-variable]
int32_t pointer_length_long = TFT_WIDTH / 2 - 5;
^
Compiling .pio\build\view\lib44f\Simple FOC\drivers\StepperDriver2PWM.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\StepperDriver4PWM.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\atmega2560_mcu.cpp.o
src/display_task.cpp: At global scope:
src/display_task.cpp:22:13: warning: 'void HSV_to_RGB(float, float, float, uint8_t*, uint8_t*, uint8_t*)' defined but not used [-Wunused-function]
static void HSV_to_RGB(float h, float s, float v, uint8_t *r, uint8_t *g, uint8_t *b)
^
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\atmega328_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\atmega32u4_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\due_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\esp32_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\esp8266_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\generic_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\portenta_h7_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\rp2040_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\samd21_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\samd51_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\samd_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\stm32_mcu.cpp.o
.pio/libdeps/view/Simple FOC/src/current_sense/hardware_specific/esp32_mcu.cpp: In function 'float _readADCVoltageLowSide(int)':
.pio/libdeps/view/Simple FOC/src/current_sense/hardware_specific/esp32_mcu.cpp:60:18: warning: 'raw_adc' may be used uninitialized in this
function [-Wmaybe-uninitialized]
return raw_adc * _ADC_CONV;
^
Compiling .pio\build\view\lib44f\Simple FOC\drivers\hardware_specific\teensy_mcu.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\sensors\Encoder.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\sensors\HallSensor.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\sensors\MagneticSensorAnalog.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\sensors\MagneticSensorI2C.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\sensors\MagneticSensorPWM.cpp.o
Compiling .pio\build\view\lib44f\Simple FOC\sensors\MagneticSensorSPI.cpp.o
Compiling .pio\build\view\lib1b5\tlv\Tlv493d.cpp.o
Compiling .pio\build\view\lib1b5\tlv\util\BusInterface.cpp.o
Compiling .pio\build\view\lib1b5\tlv\util\RegMask.cpp.o
Compiling .pio\build\view\lib02a\AceButton\ace_button\AceButton.cpp.o
Compiling .pio\build\view\lib02a\AceButton\ace_button\ButtonConfig.cpp.o
Compiling .pio\build\view\lib02a\AceButton\ace_button\EncodedButtonConfig.cpp.o
Compiling .pio\build\view\lib02a\AceButton\ace_button\LadderButtonConfig.cpp.o
Compiling .pio\build\view\lib02a\AceButton\ace_button\testing\EventTracker.cpp.o
Compiling .pio\build\view\lib65c\FS\FS.cpp.o
Compiling .pio\build\view\lib65c\FS\vfs_api.cpp.o
Compiling .pio\build\view\lib725\SPIFFS\SPIFFS.cpp.o
Compiling .pio\build\view\lib067\TFT_eSPI\TFT_eSPI.cpp.o
Compiling .pio\build\view\libbf2\HX711\HX711.cpp.o
Compiling .pio\build\view\liba5e\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\view\liba5e\Adafruit BusIO\Adafruit_I2CDevice.cpp.o
Compiling .pio\build\view\liba5e\Adafruit BusIO\Adafruit_SPIDevice.cpp.o
Compiling .pio\build\view\lib905\Adafruit VEML7700 Library\Adafruit_VEML7700.cpp.o
Archiving .pio\build\view\libFrameworkArduinoVariant.a
Indexing .pio\build\view\libFrameworkArduinoVariant.a
Compiling .pio\build\view\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\view\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\view\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\view\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\view\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\view\FrameworkArduino\MD5Builder.cpp.o
Archiving .pio\build\view\lib44f\libSimple FOC.a
Compiling .pio\build\view\FrameworkArduino\Print.cpp.o
Archiving .pio\build\view\lib1b5\libtlv.a
Compiling .pio\build\view\FrameworkArduino\Stream.cpp.o
Indexing .pio\build\view\lib1b5\libtlv.a
Compiling .pio\build\view\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\view\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\view\FrameworkArduino\WString.cpp.o
Compiling .pio\build\view\FrameworkArduino\base64.cpp.o
Indexing .pio\build\view\lib44f\libSimple FOC.a
Compiling .pio\build\view\FrameworkArduino\cbuf.cpp.o
Archiving .pio\build\view\lib02a\libAceButton.a
Indexing .pio\build\view\lib02a\libAceButton.a
Compiling .pio\build\view\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-gpio.c.o
Archiving .pio\build\view\libbf2\libHX711.a
Compiling .pio\build\view\FrameworkArduino\esp32-hal-i2c.c.o
Indexing .pio\build\view\libbf2\libHX711.a
Archiving .pio\build\view\lib725\libSPIFFS.a
Indexing .pio\build\view\lib725\libSPIFFS.a
Compiling .pio\build\view\FrameworkArduino\esp32-hal-ledc.c.o
Archiving .pio\build\view\liba5e\libAdafruit BusIO.a
Archiving .pio\build\view\lib65c\libFS.a
Compiling .pio\build\view\FrameworkArduino\esp32-hal-log.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-matrix.c.o
Indexing .pio\build\view\lib65c\libFS.a
Indexing .pio\build\view\liba5e\libAdafruit BusIO.a
Compiling .pio\build\view\FrameworkArduino\esp32-hal-misc.c.o
Archiving .pio\build\view\lib905\libAdafruit VEML7700 Library.a
Compiling .pio\build\view\FrameworkArduino\esp32-hal-psram.c.o
Indexing .pio\build\view\lib905\libAdafruit VEML7700 Library.a
Compiling .pio\build\view\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-sigmadelta.c.o
.pio/libdeps/view/TFT_eSPI/TFT_eSPI.cpp: In member function 'virtual int16_t TFT_eSPI::drawChar(uint16_t, int32_t, int32_t, uint8_t)':
.pio/libdeps/view/TFT_eSPI/TFT_eSPI.cpp:4220:12: warning: unused variable 'flash_address' [-Wunused-variable]
uint32_t flash_address = 0;
^
.pio/libdeps/view/TFT_eSPI/TFT_eSPI.cpp:4249:11: warning: unused variable 'w' [-Wunused-variable]
int32_t w = width;
^
.pio/libdeps/view/TFT_eSPI/TFT_eSPI.cpp:4250:11: warning: unused variable 'pX' [-Wunused-variable]
int32_t pX = 0;
^
.pio/libdeps/view/TFT_eSPI/TFT_eSPI.cpp:4251:11: warning: unused variable 'pY' [-Wunused-variable]
int32_t pY = y;
^
.pio/libdeps/view/TFT_eSPI/TFT_eSPI.cpp:4252:11: warning: unused variable 'line' [-Wunused-variable]
uint8_t line = 0;
^
.pio/libdeps/view/TFT_eSPI/TFT_eSPI.cpp:4253:8: warning: unused variable 'clip' [-Wunused-variable]
bool clip = xd < _vpX || xd + width * textsize >= _vpW || yd < _vpY || yd + height * textsize >= _vpH;
^
In file included from .pio/libdeps/view/TFT_eSPI/TFT_eSPI.cpp:5078:0:
.pio/libdeps/view/TFT_eSPI/Extensions/Sprite.cpp: In member function 'virtual int16_t TFT_eSprite::drawChar(uint16_t, int32_t, int32_t, uint8_t)':
.pio/libdeps/view/TFT_eSPI/Extensions/Sprite.cpp:2181:12: warning: unused variable 'flash_address' [-Wunused-variable]
uint32_t flash_address = 0;
^
.pio/libdeps/view/TFT_eSPI/Extensions/Sprite.cpp:2210:11: warning: unused variable 'w' [-Wunused-variable]
int32_t w = width;
^
.pio/libdeps/view/TFT_eSPI/Extensions/Sprite.cpp:2211:11: warning: unused variable 'pX' [-Wunused-variable]
int32_t pX = 0;
^
.pio/libdeps/view/TFT_eSPI/Extensions/Sprite.cpp:2212:11: warning: unused variable 'pY' [-Wunused-variable]
int32_t pY = y;
^
.pio/libdeps/view/TFT_eSPI/Extensions/Sprite.cpp:2213:11: warning: unused variable 'line' [-Wunused-variable]
uint8_t line = 0;
^
.pio/libdeps/view/TFT_eSPI/Extensions/Sprite.cpp:2214:8: warning: unused variable 'clip' [-Wunused-variable]
bool clip = xd < _vpX || xd + width * textsize >= _vpW || yd < _vpY || yd + height * textsize >= _vpH;
^
Compiling .pio\build\view\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-time.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-timer.c.o
C:/Users/piercebrands/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c: In function 'spiTransferBytesNL':
C:/Users/piercebrands/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c:922:39: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
uint8_t * last_out8 = &result[c_longs-1];
^
C:/Users/piercebrands/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c:923:40: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
uint8_t * last_data8 = &last_data;
^
Compiling .pio\build\view\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\view\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\view\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\view\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\view\FrameworkArduino\main.cpp.o
Compiling .pio\build\view\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\view\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\view\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\view\libFrameworkArduino.a
Indexing .pio\build\view\libFrameworkArduino.a
Archiving .pio\build\view\lib067\libTFT_eSPI.a
Indexing .pio\build\view\lib067\libTFT_eSPI.a
Linking .pio\build\view\firmware.elf
Retrieving maximum program size .pio\build\view\firmware.elf
Checking size .pio\build\view\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 5.4% (used 17648 bytes from 327680 bytes)
Flash: [=== ] 27.3% (used 357566 bytes from 1310720 bytes)
Building .pio\build\view\firmware.bin
esptool.py v3.1
Merged 1 ELF section
====================================================== [SUCCESS] Took 412.84 seconds ======================================================
Environment Status Duration
------------- -------- ------------
view SUCCESS 00:06:52.838
======================================================= 1 succeeded in 00:06:52.838 ======================================================= * 终端将被任务重用,按任意键关闭。

If you see output similar to the above, the compilation is complete.

Write

After the compilation is complete, click the Write button on Position 2 and the write log will look like this:

* 正在执行任务: C:\Users\piercebrands\.platformio\penv\Scripts\platformio.exe run --target upload
Processing view (board: esp32doit-devkit-v1; platform: espressif32@3.4; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/tool-mkspiffs @ ~2.230.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-mkspiffs@2.230.0 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (3.4.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
- tool-esptoolpy @ 1.30100.210531 (3.1.0)
- tool-mkspiffs @ 2.230.0 (2.30)
- toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Simple FOC @ 2.2.0
| |-- Wire @ 1.0.1
| |-- SPI @ 1.0
|-- TLV493D-Magnetic-Sensor @ 1.0.3
| |-- Wire @ 1.0.1
|-- AceButton @ 1.9.1
|-- TFT_eSPI @ 2.4.25
| |-- SPI @ 1.0
| |-- SPIFFS @ 1.0
| | |-- FS @ 1.0
| |-- FS @ 1.0
|-- FastLED @ 3.5.0
| |-- SPI @ 1.0
|-- HX711 @ 0.7.5
|-- Adafruit VEML7700 Library @ 1.1.1
| |-- Adafruit BusIO @ 1.13.2
| | |-- Wire @ 1.0.1
| | |-- SPI @ 1.0
| |-- Wire @ 1.0.1
| |-- SPI @ 1.0
Building in release mode
Retrieving maximum program size .pio\build\view\firmware.elf
Checking size .pio\build\view\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 5.4% (used 17648 bytes from 327680 bytes)
Flash: [=== ] 27.3% (used 357566 bytes from 1310720 bytes)
Configuring upload protocol...
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: COM3
Uploading .pio\build\view\firmware.bin
esptool.py v3.1
Serial port COM3
Connecting......
Chip is ESP32-PICO-V3-02 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, Embedded PSRAM, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 98:cd:ac:e8:af:ec
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 8MB
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00067fff...
Flash params set to 0x0230
Compressed 17104 bytes to 11191...
Writing at 0x00001000... (100 %)
Wrote 17104 bytes (11191 compressed) at 0x00001000 in 0.6 seconds (effective 229.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.1 seconds (effective 364.0 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 541.4 kbit/s)...
Hash of data verified.
Compressed 357680 bytes to 190508...
Writing at 0x00010000... (8 %)
Writing at 0x00018fcf... (16 %)
Writing at 0x0002ae74... (25 %)
Writing at 0x0003201b... (33 %)
Writing at 0x00037658... (41 %)
Writing at 0x0003ce83... (50 %)
Writing at 0x0004347a... (58 %)
Writing at 0x0004c06f... (66 %)
Writing at 0x000519bf... (75 %)
Writing at 0x00057a46... (83 %)
Writing at 0x0005d864... (91 %)
Writing at 0x00063652... (100 %)
Wrote 357680 bytes (190508 compressed) at 0x00010000 in 4.4 seconds (effective 651.0 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
====================================================== [SUCCESS] Took 19.27 seconds ======================================================
Environment Status Duration
------------- -------- ------------
view SUCCESS 00:00:19.271
======================================================= 1 succeeded in 00:00:19.271 =======================================================
* 终端将被任务重用,按任意键关闭。

Serial Monitor

Waiting the write task is complete, press the serial button on the Position 3 and the output is as follows:

* 正在执行任务: C:\Users\piercebrands\.platformio\penv\Scripts\platformio.exe device monitor
--- Terminal on COM3 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct,
esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
Sprite created!
millilux: 0.00
HX711 reading: 669031
millilux: 0.00
HX711 reading: 668815
Press Y to run calibration <========= // Look this
millilux: 0.00
HX711 reading: 668869
millilux: 0.00
HX711 reading: 668639
millilux: 0.00
HX711 reading: 668634
4.43
Got new config
millilux: 0.00

There is a word Press Y to run calibration, which can be used to automatically debug a set value suitable for the current device. After pressing the capital Y in the serial window, the knob will be rotated automatically, and after a while, the following result will be output in the serial port:

RESULTS:
zero electric angle: 4.43 // The values on this side may be different for each device.
direction: CW
pole pairs: 7

Open motor_task.cpp file:

float zero_electric_offset = 4.43; // Replace the value with the value of zero electric angle output above.

After saving, write the firmware again. It should run successfully.

Share to X