├── firmware.nm ├── embedded ├── footer.txt ├── tool.html.gz ├── build.bat ├── package.json ├── header.txt └── build.py ├── requirements.txt ├── install_scripts ├── common │ ├── SecurityFusesOK.bin │ ├── SecurityFusesOK0.bin │ └── README-ESPTOOL-SOURCE.txt ├── win64 │ ├── fluidterm.bat │ ├── README-ESPTOOL.txt │ ├── tools.bat │ ├── erase.bat │ ├── install-fs.bat │ ├── install-bt.bat │ ├── install-wifi.bat │ └── checksecurity.bat └── posix │ ├── checksecurity.sh │ ├── fluidterm.sh │ ├── erase.sh │ ├── install-bt.sh │ ├── install-wifi.sh │ └── install-fs.sh ├── X86TestSupport └── TestSupport │ ├── soc │ ├── rtc.h │ ├── uart_reg.h │ ├── dport_reg.h │ ├── gpio_sig_map.h │ ├── io_mux_reg.h │ └── ledc_struct.cpp │ ├── esp_system.h │ ├── SPI.cpp │ ├── esp_attr.h │ ├── esp32-hal-cpu.h │ ├── esp32-hal-dac.h │ ├── esp32-hal.h │ ├── esp32-hal-ledc.h │ ├── esp32-hal-matrix.h │ ├── nvs.h │ ├── driver │ ├── dac.h │ ├── dac.cpp │ ├── ledc.h │ ├── rmt.cpp │ └── ledc.cpp │ ├── xtensa │ └── core-macros.h │ ├── SPI.h │ ├── library.properties │ ├── freertos │ ├── FreeRTOSTypes.h │ └── FreeRTOS.h │ ├── I2SO.cpp │ ├── SDFS.cpp │ ├── library.json │ ├── SPIFFS.cpp │ ├── Arduino.h │ ├── TMC │ └── TMCStepper_UTILITY.h │ ├── esp32-hal-timer.cpp │ ├── esp32-hal-timer.h │ ├── SPIFFS.h │ ├── Esp.h │ ├── Printable.h │ └── SD.h ├── .editorconfig ├── .gitattributes ├── FluidNC ├── data │ ├── favicon.ico │ └── index.html.gz ├── esp32 │ ├── wdt.h │ ├── tmc_spi_support.h │ ├── esp_error.hpp │ ├── spiffs.cpp │ ├── esp_error.cpp │ ├── coredump.c │ ├── spi.cpp │ ├── littlefs.cpp │ ├── wdt.cpp │ ├── StartupLog.cpp │ └── delay_usecs.cpp ├── data3 │ └── index.html.gz ├── src │ ├── CPUMap.h │ ├── xmodem.h │ ├── Main.h │ ├── tests │ │ ├── parsetest.nc │ │ ├── spindle_testing.nc │ │ ├── spindle │ │ │ └── spindle_modal.nc │ │ └── user_io.nc │ ├── Machine │ │ ├── ProbeEventPin.cpp │ │ ├── EventPin.cpp │ │ ├── ProbeEventPin.h │ │ ├── EventPin.h │ │ ├── WifiSTAConfig.h │ │ ├── I2SOBus.h │ │ ├── SPIBus.h │ │ ├── WifiAPConfig.h │ │ ├── I2CBus.h │ │ ├── I2SOBus.cpp │ │ ├── UserOutputs.h │ │ ├── WifiConfig.h │ │ ├── LimitPin.h │ │ └── Axis.h │ ├── Regex.h │ ├── Platform.h │ ├── Configuration │ │ ├── HandlerType.h │ │ ├── TokenState.h │ │ ├── ParseException.h │ │ ├── parser_logging.h │ │ ├── AfterParse.cpp │ │ ├── Configurable.h │ │ ├── LegacySettingHandler.h │ │ ├── LegacySettingRegistry.h │ │ ├── Validator.cpp │ │ ├── Generator.cpp │ │ ├── Parser.h │ │ ├── Tokenizer.h │ │ ├── Validator.h │ │ └── AfterParse.h │ ├── CustomCode.cpp │ ├── ControlPin.cpp │ ├── SettingsDefinitions.h │ ├── SpindleDatatypes.h │ ├── WebUI │ │ ├── Authentication.h │ │ ├── InputBuffer.cpp │ │ ├── WifiServices.h │ │ ├── InputBuffer.h │ │ ├── WebSettings.h │ │ ├── Commands.h │ │ ├── TelnetServer.h │ │ ├── Commands.cpp │ │ ├── TelnetClient.h │ │ ├── WebClient.h │ │ ├── Authentication.cpp │ │ └── NotificationsService.h │ ├── Motors │ │ ├── NullMotor.cpp │ │ ├── TMC2160ProDriver.cpp │ │ ├── RcServoSettings.h │ │ ├── NullMotor.h │ │ ├── TMC2160ProDriver.h │ │ ├── StepStick.h │ │ ├── Servo.h │ │ ├── TMC2130Driver.h │ │ ├── TMC5160Driver.h │ │ ├── TrinamicUartDriver.h │ │ ├── TMC2208Driver.h │ │ ├── TMC2209Driver.h │ │ ├── TrinamicUartDriver.cpp │ │ ├── StepStick.cpp │ │ └── StandardStepper.h │ ├── StringStream.h │ ├── Kinematics │ │ ├── Midtbot.cpp │ │ └── Midtbot.h │ ├── Pins │ │ ├── PinDetail.cpp │ │ ├── VoidPinDetail.h │ │ ├── ErrorPinDetail.h │ │ ├── VoidPinDetail.cpp │ │ ├── ChannelPinDetail.h │ │ ├── I2SOPinDetail.h │ │ ├── GPIOPinDetail.h │ │ ├── DebugPinDetail.h │ │ ├── PinDetail.h │ │ └── ErrorPinDetail.cpp │ ├── FluidError.hpp │ ├── StartupLog.h │ ├── string_util.h │ ├── Spindles │ │ ├── RelaySpindle.cpp │ │ ├── RelaySpindle.h │ │ ├── H100Spindle.md │ │ ├── NowForeverSpindle.h │ │ ├── H2ASpindle.h │ │ ├── NullSpindle.cpp │ │ ├── H100Spindle.h │ │ ├── NullSpindle.h │ │ ├── YL620Spindle.h │ │ ├── HuanyangSpindle.h │ │ ├── DacSpindle.h │ │ ├── Laser.cpp │ │ ├── Laser.h │ │ ├── SiemensV20Spindle.h │ │ └── 10vSpindle.h │ ├── UartTypes.h │ ├── EnumItem.h │ ├── ControlPin.h │ ├── Jog.h │ ├── HashFS.h │ ├── UTF8.h │ ├── Control.h │ ├── FluidError.cpp │ ├── Event.h │ ├── StackTrace │ │ └── AssertionFailed.h │ ├── Assert.h │ ├── Limits.h │ ├── Types.h │ ├── CoolantControl.h │ ├── FluidPath.h │ ├── Jog.cpp │ ├── Logging.cpp │ ├── Stepper.h │ ├── PinMapper.h │ ├── string_util.cpp │ ├── Parking.h │ ├── Status_outputs.h │ ├── Stepper.md │ ├── Probe.h │ └── SDCard.h ├── include │ └── Driver │ │ ├── spiffs.h │ │ ├── littlefs.h │ │ ├── sdspi.h │ │ ├── delay_usecs.h │ │ ├── StepTimer.h │ │ ├── fluidnc_i2c.h │ │ ├── spi.h │ │ ├── PwmPin.h │ │ ├── localfs.h │ │ └── fluidnc_gpio.h ├── ld │ └── esp32 │ │ ├── vtable_in_dram.py │ │ ├── app3M_spiffs1M_8MB.csv │ │ ├── app3M_spiffs9M_16MB.csv │ │ └── vtable_in_dram.ld ├── stdfs │ ├── fluidnc_vfs_ops.h │ └── fluidnc_vfs_ops.cpp ├── tests │ └── test_main.cpp └── test │ ├── TestFrameworkTest.cpp │ ├── Pins │ ├── ErrorPinTest.cpp │ ├── BasicGPIO.cpp │ └── Undefined.cpp │ ├── test_main.cpp │ └── TestFactory.h ├── fluidterm ├── fluidterm.exe ├── HOWTO-COMPILE.md ├── fluidterm.spec └── README-FluidTerm.md ├── example_configs ├── README.md └── uartio.yaml ├── packages.config ├── libraries └── ESP32SSDP │ ├── library.properties │ ├── README.rst │ ├── keywords.txt │ └── examples │ └── SSDP │ └── SSDP.ino ├── min_littlefs.csv ├── .github ├── ISSUE_TEMPLATE │ └── config.yml └── FUNDING.yml ├── clear-flags.ps1 ├── .gitignore ├── .travis.yml ├── AUTHORS ├── debug.ini └── VisualStudio.md /firmware.nm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /embedded/footer.txt: -------------------------------------------------------------------------------- 1 | #endif //__nofile_h 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | platformio == 6.1.* 2 | -------------------------------------------------------------------------------- /install_scripts/common/SecurityFusesOK.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /install_scripts/common/SecurityFusesOK0.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/soc/rtc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp_system.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/soc/uart_reg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/soc/dport_reg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/soc/gpio_sig_map.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/soc/io_mux_reg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | insert_final_newline = true -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/SPI.cpp: -------------------------------------------------------------------------------- 1 | #include "SPI.h" 2 | 3 | SPIClass SPI; 4 | -------------------------------------------------------------------------------- /install_scripts/win64/fluidterm.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | win64\fluidterm.exe %* 3 | 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp_attr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp32-hal-cpu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "driver/ledc.h" 4 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp32-hal-dac.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "driver/dac.h" 4 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp32-hal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "esp32-hal-timer.h" 4 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp32-hal-ledc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "driver/ledc.h" 4 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp32-hal-matrix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "driver/ledc.h" 4 | -------------------------------------------------------------------------------- /embedded/tool.html.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigtreetech/FluidNC/HEAD/embedded/tool.html.gz -------------------------------------------------------------------------------- /install_scripts/posix/checksecurity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./tools.sh 4 | 5 | check_security 6 | -------------------------------------------------------------------------------- /FluidNC/data/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigtreetech/FluidNC/HEAD/FluidNC/data/favicon.ico -------------------------------------------------------------------------------- /FluidNC/esp32/wdt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void enable_core0_WDT(); 4 | void disable_core0_WDT(); 5 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/soc/ledc_struct.cpp: -------------------------------------------------------------------------------- 1 | #include "ledc_struct.h" 2 | 3 | ledc_dev_t LEDC; 4 | -------------------------------------------------------------------------------- /fluidterm/fluidterm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigtreetech/FluidNC/HEAD/fluidterm/fluidterm.exe -------------------------------------------------------------------------------- /FluidNC/data/index.html.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigtreetech/FluidNC/HEAD/FluidNC/data/index.html.gz -------------------------------------------------------------------------------- /FluidNC/data3/index.html.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigtreetech/FluidNC/HEAD/FluidNC/data3/index.html.gz -------------------------------------------------------------------------------- /FluidNC/src/CPUMap.h: -------------------------------------------------------------------------------- 1 | // Machine configuration is now done in machine.h 2 | // Read that file for instructions. 3 | -------------------------------------------------------------------------------- /install_scripts/posix/fluidterm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! . ./tools.sh; then exit 1; fi 4 | 5 | run_fluidterm $* 6 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/nvs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigtreetech/FluidNC/HEAD/X86TestSupport/TestSupport/nvs.h -------------------------------------------------------------------------------- /install_scripts/posix/erase.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! . ./tools.sh; then exit 1; fi 4 | 5 | esptool_erase 6 | 7 | deactivate 8 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/driver/dac.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | void dacWrite(uint8_t pin, uint8_t value); 6 | -------------------------------------------------------------------------------- /install_scripts/posix/install-bt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BuildType=bt 4 | 5 | if ! . ./tools.sh; then exit 1; fi 6 | 7 | install 8 | 9 | deactivate 10 | -------------------------------------------------------------------------------- /install_scripts/posix/install-wifi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BuildType=wifi 4 | 5 | if ! . ./tools.sh; then exit 1; fi 6 | 7 | install 8 | 9 | deactivate 10 | -------------------------------------------------------------------------------- /install_scripts/win64/README-ESPTOOL.txt: -------------------------------------------------------------------------------- 1 | The esptool binaries were extracted from official Espressif release files at 2 | https://github.com/espressif/esptool . 3 | -------------------------------------------------------------------------------- /example_configs/README.md: -------------------------------------------------------------------------------- 1 | ### The config files have moved to their own GitHub repo 2 | 3 | [See this GitHub repo](https://github.com/bdring/fluidnc-config-files). 4 | 5 | -------------------------------------------------------------------------------- /install_scripts/common/README-ESPTOOL-SOURCE.txt: -------------------------------------------------------------------------------- 1 | The esptool source package was downloaded from the Espressif release files at 2 | https://github.com/espressif/esptool . 3 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/spiffs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | bool spiffs_format(const char* partition_label); 3 | bool spiffs_mount(const char* label = "spiffs", bool format = false); 4 | void spiffs_unmount(); 5 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/xtensa/core-macros.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../esp32-hal-timer.h" 4 | 5 | inline int32_t IRAM_ATTR XTHAL_GET_CCOUNT() { 6 | return int32_t(millis()); 7 | } 8 | -------------------------------------------------------------------------------- /FluidNC/ld/esp32/vtable_in_dram.py: -------------------------------------------------------------------------------- 1 | Import("env") 2 | 3 | import os.path 4 | 5 | env.Prepend( 6 | LIBPATH=[ 7 | os.path.join("$PROJECT_DIR","FluidNC","ld","esp32") 8 | ] 9 | ) 10 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/SPI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class SPIClass { 4 | public: 5 | void begin(int sck, int miso, int mosi) { /* TODO */ 6 | } 7 | }; 8 | 9 | extern SPIClass SPI; 10 | -------------------------------------------------------------------------------- /packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /FluidNC/src/xmodem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Channel.h" 4 | #include "FileStream.h" 5 | 6 | int xmodemReceive(Channel* serial, FileStream* outfile); 7 | int xmodemTransmit(Channel* serial, FileStream* infile); 8 | -------------------------------------------------------------------------------- /FluidNC/src/Main.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | void main_init(); 7 | void run_once(); 8 | -------------------------------------------------------------------------------- /FluidNC/src/tests/parsetest.nc: -------------------------------------------------------------------------------- 1 | G21 2 | G90 (A standard comment) 3 | G1 Z3.810 F228.6 ; a LinuxCNC style comment 4 | G0x0x0 (some lowercase) 5 | G0 X10 (internal comment) Y0 6 | G0X0 (internal comment; with semi colon) Y0Z3 7 | -------------------------------------------------------------------------------- /install_scripts/posix/install-fs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! . ./tools.sh; then exit 1; fi 4 | 5 | if ! check_security; then exit 1; fi 6 | 7 | LocalFS="0x3d0000 wifi/littlefs.bin" 8 | esptool_write $LocalFS 9 | 10 | deactivate 11 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/littlefs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | extern const char* littlefs_label; 3 | 4 | bool littlefs_format(const char* partition_label); 5 | bool littlefs_mount(const char* label = "littlefs", bool format = false); 6 | void littlefs_unmount(); 7 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/sdspi.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | bool sd_init_slot(uint32_t freq_hz, int cs_pin, int cd_pin = -1, int wp_pin = -1); 4 | void sd_unmount(); 5 | void sd_deinit_slot(); 6 | 7 | std::error_code sd_mount(int max_files = 1); 8 | -------------------------------------------------------------------------------- /libraries/ESP32SSDP/library.properties: -------------------------------------------------------------------------------- 1 | name=ESP32SSPD 2 | version=1.0 3 | author=Me-No-Dev 4 | maintainer=Me-No-Dev 5 | sentence=Simple SSDP library for ESP32 6 | paragraph=Only for ESP32 7 | category=Communication 8 | url= 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/ProbeEventPin.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | #include "src/Machine/ProbeEventPin.h" 3 | #include "src/Machine/MachineConfig.h" // config 4 | 5 | #include "src/Protocol.h" // protocol_send_event_from_ISR() 6 | 7 | namespace Machine { 8 | 9 | } 10 | #endif -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/library.properties: -------------------------------------------------------------------------------- 1 | name=X86TestSupport 2 | version=1.0 3 | author=Stefan de Bruijn 4 | maintainer=Stefan de Bruijn 5 | sentence=X86 test support 6 | paragraph=Only for X86 7 | category=Communication 8 | url= 9 | architectures=x86 10 | -------------------------------------------------------------------------------- /FluidNC/src/Regex.h: -------------------------------------------------------------------------------- 1 | // Simple regular expression matcher. 2 | // See Regex.cpp for attribution, description and discussion 3 | 4 | // Returns true if text contains the regular expression regexp 5 | bool regexMatch(const char* regexp, const char* text, bool case_sensitive = true); 6 | -------------------------------------------------------------------------------- /FluidNC/stdfs/fluidnc_vfs_ops.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | bool isSPIFFS(const char* mountpoint); 6 | bool isSD(const char* mountpoint); 7 | bool isLittleFS(const char* mountpoint); 8 | bool fluidnc_vfs_stats(const char* mountpoint, uint64_t& total, uint64_t& used); 9 | -------------------------------------------------------------------------------- /min_littlefs.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | app0, app, ota_0, 0x10000, 0x1E0000, 5 | app1, app, ota_1, 0x1F0000,0x1E0000, 6 | spiffs, data, spiffs, 0x3D0000,0x30000, 7 | -------------------------------------------------------------------------------- /FluidNC/src/Platform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // This contains definitions of "very platform specific defines", that cannot be dealth with some other way. 4 | 5 | #ifdef ESP32 6 | 7 | # define WEAK_LINK __attribute__((weak)) 8 | 9 | #else 10 | 11 | # define WEAK_LINK 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/delay_usecs.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern uint32_t ticks_per_us; 4 | 5 | void timing_init(); 6 | void spinUntil(int32_t endTicks); 7 | void delay_us(int32_t us); 8 | 9 | int32_t usToCpuTicks(int32_t us); 10 | int32_t usToEndTicks(int32_t us); 11 | int32_t getCpuTicks(); 12 | -------------------------------------------------------------------------------- /FluidNC/src/tests/spindle_testing.nc: -------------------------------------------------------------------------------- 1 | ; [ESP220]/spindle_testing.nc 2 | G21 3 | G90 4 | G0X50 5 | G0X100 6 | M3 S10000 ; spindle on, spin up delay 7 | G0X140 8 | X60 9 | X100 10 | S15000 ; faster spindle up, no delay 11 | G0X140 12 | X60 13 | X100 14 | M5 ; spindle off, spin down delay 15 | G0X0 ; return to 0 16 | -------------------------------------------------------------------------------- /FluidNC/ld/esp32/app3M_spiffs1M_8MB.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | app0, app, ota_0, 0x10000, 0x300000, 5 | app1, app, ota_1, 0x310000,0x300000, 6 | spiffs, data, spiffs, 0x610000,0x1F0000, 7 | -------------------------------------------------------------------------------- /FluidNC/ld/esp32/app3M_spiffs9M_16MB.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | app0, app, ota_0, 0x10000, 0x300000, 5 | app1, app, ota_1, 0x310000,0x300000, 6 | spiffs, data, spiffs, 0x610000,0x9F0000, 7 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/driver/dac.cpp: -------------------------------------------------------------------------------- 1 | #include "dac.h" 2 | #include "../Capture.h" 3 | 4 | #include 5 | #include 6 | 7 | void dacWrite(uint8_t pin, uint8_t value) { 8 | std::ostringstream oss; 9 | oss << "DAC." << pin; 10 | 11 | Capture::instance().write(oss.str(), value); 12 | } 13 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/HandlerType.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | namespace Configuration { 7 | enum struct HandlerType { Parser, AfterParse, Runtime, Generator, Validator, Completer }; 8 | } 9 | -------------------------------------------------------------------------------- /FluidNC/src/CustomCode.cpp: -------------------------------------------------------------------------------- 1 | // This file loads custom code from the Custom/ subdirectory if 2 | // CUSTOM_CODE_FILENAME is defined. 3 | 4 | #include "Config.h" 5 | 6 | #ifdef CUSTOM_CODE_FILENAME 7 | # include CUSTOM_CODE_FILENAME 8 | #endif 9 | 10 | #ifdef DISPLAY_CODE_FILENAME 11 | # include DISPLAY_CODE_FILENAME 12 | #endif 13 | -------------------------------------------------------------------------------- /FluidNC/src/ControlPin.cpp: -------------------------------------------------------------------------------- 1 | #include "ControlPin.h" 2 | 3 | namespace Machine { 4 | void ControlPin::init() { 5 | if (_pin.undefined()) { 6 | return; 7 | } 8 | _pin.report(_legend); 9 | _pin.setAttr(Pin::Attr::Input); 10 | _pin.registerEvent(static_cast(this)); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /FluidNC/src/SettingsDefinitions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Settings.h" 4 | 5 | extern StringSetting* config_filename; 6 | 7 | extern StringSetting* build_info; 8 | 9 | extern StringSetting* start_message; 10 | 11 | extern IntSetting* status_mask; 12 | 13 | extern IntSetting* sd_fallback_cs; 14 | 15 | extern EnumSetting* message_level; 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: General Questions 4 | url: http://wiki.fluidnc.com/ 5 | about: Please read our wiki which answers many questions 6 | - name: Discord server 7 | url: https://discord.com/invite/vGhne3QmFZ 8 | about: Please ask and answer questions on our Discord server. 9 | -------------------------------------------------------------------------------- /FluidNC/src/SpindleDatatypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef uint32_t SpindleSpeed; 6 | 7 | // Modal Group M7: Spindle control 8 | enum class SpindleState : uint8_t { 9 | Disable = 0, // M5 (Default: Must be zero) 10 | Cw = 1, // M3 11 | Ccw = 2, // M4 12 | Unknown, // Used for initialization 13 | }; 14 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/StepTimer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | #include 9 | 10 | void stepTimerInit(uint32_t frequency, bool (*fn)(void)); 11 | void stepTimerStop(); 12 | void stepTimerSetTicks(uint32_t ticks); 13 | void stepTimerStart(); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /clear-flags.ps1: -------------------------------------------------------------------------------- 1 | # Remove the override of PLATFORMIO_BUILD_FLAGS 2 | # This is useful if you were running build-all.ps1 and 3 | # had to kill it with Ctrl-C, thus leaving 4 | # PLATFORMIO_BUILD_FLAGS set to override the machine type. 5 | # A clear-flags.sh equivalent is unnecessary, as build-all.sh 6 | # does not set PLATFORMIO_BUILD_FLAGS globally 7 | Remove-Item Env:PLATFORMIO_BUILD_FLAGS -------------------------------------------------------------------------------- /FluidNC/src/Configuration/TokenState.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | namespace Configuration { 7 | enum class TokenState { 8 | Bof, 9 | Matching, 10 | Matched, 11 | Held, 12 | Eof, 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/freertos/FreeRTOSTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define portMAX_DELAY (TickType_t)0xffffffffUL 6 | 7 | using portBASE_TYPE = int; 8 | using UBaseType_t = unsigned int; 9 | using BaseType_t = portBASE_TYPE; 10 | using TickType_t = uint32_t; 11 | 12 | typedef void (*TaskFunction_t)(void*); 13 | typedef void* TaskHandle_t; 14 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/EventPin.cpp: -------------------------------------------------------------------------------- 1 | #include "EventPin.h" 2 | #include "src/Report.h" 3 | 4 | #include "src/Protocol.h" // protocol_send_event 5 | 6 | void EventPin::trigger(bool active) { 7 | update(active); 8 | log_debug(_legend << " " << active); 9 | if (active) { 10 | protocol_send_event(_event, this); 11 | } 12 | report_recompute_pin_string(); 13 | } 14 | -------------------------------------------------------------------------------- /FluidNC/src/tests/spindle/spindle_modal.nc: -------------------------------------------------------------------------------- 1 | G17 2 | G0Z12.700 3 | S500M3 4 | G0X0.000Y0.000 5 | G0X13.599Y24.932Z5.080 6 | G1Z-2.000F152400.0 7 | G1Y58.857 8 | X62.091 9 | Y24.932 10 | X13.599 11 | G0Z5.080 12 | S1000M03 13 | G4P3 14 | G0X15.472Y27.568Z5.080 15 | G1Z-2.000F152400.0 16 | G1Y57.424 17 | X59.341 18 | Y27.568 19 | X15.472 20 | G0Z5.080 21 | G53G0Z-2 22 | G0X0.000Y0.000 23 | M5 24 | -------------------------------------------------------------------------------- /FluidNC/tests/test_main.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | int main(int argc, char** argv) { 4 | ::testing::InitGoogleTest(&argc, argv); 5 | // if you plan to use GMock, replace the line above with 6 | // ::testing::InitGoogleMock(&argc, argv); 7 | 8 | if (RUN_ALL_TESTS()) {} 9 | 10 | // Always return zero-code and allow PlatformIO to parse results 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /install_scripts/win64/tools.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem This file is intentionally (almost) empty 3 | rem It is present for symmetry with the Linux and MacOS versions, 4 | rem so the release scripts can process a similar set of files. 5 | rem It might be possible to use this file to eliminate some 6 | rem redundancy in the install-* scripts, but batch file scripting 7 | rem is so tricky that we have not yet attempted that. 8 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/Authentication.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WebUI { 6 | //Authentication level 7 | enum class AuthenticationLevel : uint8_t { LEVEL_GUEST = 0, LEVEL_USER = 1, LEVEL_ADMIN = 2 }; 8 | 9 | static const int MIN_LOCAL_PASSWORD_LENGTH = 1; 10 | static const int MAX_LOCAL_PASSWORD_LENGTH = 16; 11 | 12 | void remove_password(char* str, AuthenticationLevel& auth_level); 13 | } 14 | -------------------------------------------------------------------------------- /FluidNC/test/TestFrameworkTest.cpp: -------------------------------------------------------------------------------- 1 | #include "TestFramework.h" 2 | 3 | /* Normally you don't want these: 4 | 5 | Test(PassingTest, TestFrameworkTest) { 6 | Assert(1 == 1); 7 | } 8 | 9 | Test(FailingTest1, TestFrameworkTest) { 10 | Assert(1 != 1); 11 | } 12 | 13 | Test(FailingTest2, TestFrameworkTest) { 14 | Assert(1 != 1, "Oops"); 15 | } 16 | 17 | Test(FailingTest3, TestFrameworkTest) { 18 | throw "oops"; 19 | } 20 | 21 | */ 22 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/ProbeEventPin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "EventPin.h" 4 | #include "../Pin.h" 5 | namespace Machine { 6 | class ProbeEventPin : public EventPin { 7 | private: 8 | bool _value = 0; 9 | Pin* _pin = nullptr; 10 | 11 | public: 12 | ProbeEventPin(const char* legend, Pin& pin); 13 | 14 | void init(); 15 | void update(bool state) override; 16 | bool get(); 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/NullMotor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | /* 5 | This is a fake motor that does nothing. 6 | */ 7 | 8 | #include "NullMotor.h" 9 | 10 | namespace MotorDrivers { 11 | // Configuration registration 12 | namespace { 13 | MotorFactory::InstanceBuilder registration("null_motor"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /FluidNC/src/StringStream.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "Print.h" 7 | 8 | #include 9 | 10 | class StringStream : public Print { 11 | std::vector data_; 12 | 13 | public: 14 | size_t write(uint8_t c) override { 15 | data_.push_back(c); 16 | return 1; 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /install_scripts/win64/erase.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call checksecurity.bat 4 | if not %ErrorLevel% equ 0 ( 5 | exit /b 1 6 | ) 7 | 8 | set EsptoolPath=win64\esptool.exe 9 | 10 | set BaseArgs=--chip esp32 --baud 921600 11 | set SetupArgs=--before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 12 | 13 | echo %EsptoolPath% %BaseArgs% erase_flash 14 | %EsptoolPath% %BaseArgs% erase_flash 15 | 16 | pause 17 | -------------------------------------------------------------------------------- /FluidNC/src/Kinematics/Midtbot.cpp: -------------------------------------------------------------------------------- 1 | #include "Midtbot.h" 2 | /* 3 | 4 | 5 | */ 6 | 7 | namespace Kinematics { 8 | void Midtbot::group(Configuration::HandlerBase& handler) {} 9 | 10 | void Midtbot::init() { 11 | _x_scaler = 2.0; 12 | log_info("Kinematic system: " << name()); 13 | } 14 | 15 | // Configuration registration 16 | namespace { 17 | KinematicsFactory::InstanceBuilder registration("midtbot"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/TMC2160ProDriver.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "TMC2160ProDriver.h" 5 | #include "../Machine/MachineConfig.h" 6 | #include 7 | 8 | namespace MotorDrivers { 9 | 10 | // Configuration registration 11 | namespace { 12 | MotorFactory::InstanceBuilder registration("tmc_2160Pro"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FluidNC/esp32/tmc_spi_support.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void tmc_spi_bus_setup(); 11 | void tmc_spi_transfer_data(uint8_t* out, int out_bitlen, uint8_t* in, int in_bitlen); 12 | void tmc_spi_rw_reg(uint8_t cmd, uint32_t data, int index); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/InputBuffer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Luc Lebosse. All rights reserved. 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "../Config.h" 5 | #include "InputBuffer.h" 6 | 7 | namespace WebUI { 8 | InputBuffer inputBuffer; 9 | 10 | InputBuffer::InputBuffer() : Channel("macros") {} 11 | 12 | InputBuffer::operator bool() const { return true; } 13 | 14 | InputBuffer::~InputBuffer() {} 15 | } 16 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/RcServoSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | const int SERVO_PWM_FREQ_DEFAULT = 50; // 50Hz ...This is a standard analog servo value. Digital ones can repeat faster 4 | const uint32_t SERVO_PWM_FREQ_MIN = 50; 5 | const uint32_t SERVO_PWM_FREQ_MAX = 200; 6 | 7 | const int SERVO_PULSE_US_MIN_DEFAULT = 1000; 8 | const int SERVO_PULSE_US_MAX_DEFAULT = 2000; 9 | const uint32_t SERVO_PULSE_US_MIN = 500; 10 | const uint32_t SERVO_PULSE_US_MAX = 2500; 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pioenvs/ 2 | .pio/ 3 | Thumbs.db 4 | .DS_Store 5 | *.orig 6 | embedded/node_modules 7 | embedded/dist 8 | *~ 9 | .pio/ 10 | .vscode/ 11 | .history/ 12 | *.pyc 13 | .vs/ 14 | Debug/ 15 | Release/ 16 | *.vsarduino.h 17 | __vm/ 18 | *.user 19 | FluidNC.vcxproj 20 | FluidNC.vcxproj.filters 21 | *.suo 22 | packages/ 23 | pio_machine.h 24 | project.checksum 25 | version.cpp 26 | esptool*.zip 27 | v*.zip 28 | /FluidNC/data/config.yaml 29 | build/ 30 | dist/ 31 | *.cppx 32 | *.hx 33 | /compile_commands.json 34 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/PinDetail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "PinDetail.h" 5 | 6 | #include "../Assert.h" 7 | #include // IRAM_ATTR 8 | 9 | namespace Pins { 10 | void PinDetail::registerEvent(EventPin* obj) { Assert(false, "registerEvent is not supported by pin %d", _index); } 11 | 12 | void IRAM_ATTR PinDetail::synchronousWrite(int high) { write(high); } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /FluidNC/esp32/esp_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | // Wrapper to make std:error_code from ESP_IDF esp_err_t values 5 | 6 | #include // ESP_IDF error definitions 7 | #include 8 | 9 | namespace esp_error { 10 | const std::error_category& category(); 11 | inline std::error_code make_error_code(esp_err_t err) { return std::error_code(err, esp_error::category()); } 12 | } 13 | -------------------------------------------------------------------------------- /embedded/build.bat: -------------------------------------------------------------------------------- 1 | cd %~dp0 2 | cmd.exe /c npm install 3 | cmd.exe /c npm audit fix 4 | cmd.exe /c npm audit 5 | cmd.exe /c gulp package 6 | cmd.exe /c bin2c -o embedded.h -m tool.html.gz 7 | cat header.txt > out.h 8 | cat embedded.h >> out.h 9 | cat footer.txt >> out.h 10 | sed -i "s/tool_html_gz_size/PAGE_NOFILES_SIZE/g" ./out.h 11 | sed -i "s/const unsigned char tool_html_gz/const char PAGE_NOFILES/g" ./out.h 12 | sed -i "s/] = {/] PROGMEM = {/g" ./out.h 13 | cat out.h > ../FluidNC/nofile.h 14 | rm -f out.h 15 | pause 16 | 17 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/fluidnc_i2c.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "src/Pins/PinDetail.h" // pinnum_t 7 | 8 | // I2C interface 9 | 10 | bool i2c_master_init(int bus_number, pinnum_t sda_pin, pinnum_t scl_pin, uint32_t frequency); 11 | int i2c_write(int bus_number, uint8_t address, const uint8_t* data, size_t count); 12 | int i2c_read(int bus_number, uint8_t address, uint8_t* data, size_t count); 13 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/NullMotor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MotorDriver.h" 4 | 5 | namespace MotorDrivers { 6 | class Nullmotor : public MotorDriver { 7 | public: 8 | Nullmotor() = default; 9 | 10 | bool set_homing_mode(bool isHoming) { return false; } 11 | 12 | bool isReal() override { return false; } 13 | 14 | // Configuration handlers: 15 | void group(Configuration::HandlerBase& handler) override {} 16 | 17 | const char* name() const override { return "null_motor"; } 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/driver/ledc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // PWM: 6 | uint32_t getApbFrequency(); // In Hz 7 | double ledcSetup(uint8_t channel, double freq, uint8_t resolution_bits); 8 | void ledcWrite(uint8_t channel, uint32_t duty); 9 | void ledcAttachPin(uint8_t pin, uint8_t channel); 10 | void ledcDetachPin(uint8_t pin); 11 | 12 | void pinMatrixOutAttach(uint8_t pin, uint8_t function, bool invertOut, bool invertEnable); 13 | void pinMatrixOutDetach(uint8_t pin, bool invertOut, bool invertEnable); 14 | -------------------------------------------------------------------------------- /FluidNC/src/FluidError.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // The associated message strings are in FluidError.cpp 4 | enum class FluidError { None, SDNotConfigured }; 5 | 6 | std::error_code make_error_code(FluidError); 7 | 8 | // Declare that FluidError is a standard error code 9 | // This makes it possible to assign a FluidError 10 | // directly to std::error_code variable, e.g. 11 | // std::error_code ec = FluidError::SDNotConfigured 12 | 13 | namespace std { 14 | template <> 15 | struct is_error_code_enum : true_type {}; 16 | } 17 | -------------------------------------------------------------------------------- /FluidNC/src/StartupLog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "Config.h" 7 | 8 | #include "Channel.h" 9 | 10 | class StartupLog : public Channel { 11 | public: 12 | StartupLog() : Channel("Startup Log") {} 13 | virtual ~StartupLog(); 14 | 15 | size_t write(uint8_t data) override; 16 | 17 | static void init(); 18 | static void dump(Channel& channel); 19 | }; 20 | 21 | extern StartupLog startupLog; 22 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/WifiServices.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Luc Lebosse. All rights reserved. 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Config.h" // ENABLE_* 7 | 8 | namespace WebUI { 9 | class WiFiServices { 10 | public: 11 | WiFiServices(); 12 | 13 | static bool begin(); 14 | static void end(); 15 | static void handle(); 16 | 17 | ~WiFiServices(); 18 | }; 19 | 20 | extern WiFiServices wifi_services; 21 | } 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: python 3 | 4 | os: 5 | - linux 6 | 7 | cache: 8 | directories: 9 | - "~/.platformio" 10 | 11 | install: 12 | - pip install -U platformio 13 | 14 | script: 15 | - ./configure-features.py -e WIFI -d BLUETOOTH -v 16 | - ./build-machine.py test_drive.h 17 | - ./configure-features.py -e BLUETOOTH -d WIFI -v 18 | - ./build-machine.py test_drive.h 19 | - ./configure-features.py -e BLUETOOTH WIFI -v 20 | - ./build-all.py 21 | 22 | notifications: 23 | email: 24 | on_success: change 25 | on_failure: change 26 | -------------------------------------------------------------------------------- /FluidNC/src/string_util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace string_util { 6 | char tolower(char c); 7 | bool equal_ignore_case(std::string_view a, std::string_view b); 8 | bool starts_with_ignore_case(std::string_view a, std::string_view b); 9 | const std::string_view trim(std::string_view s); 10 | 11 | bool is_int(std::string_view s, int32_t& value); 12 | bool is_uint(std::string_view s, uint32_t& value); 13 | bool is_float(std::string_view s, float& value); 14 | } 15 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/driver/rmt.cpp: -------------------------------------------------------------------------------- 1 | #include "rmt.h" 2 | 3 | rmt_dev_t RMT; 4 | 5 | esp_err_t rmt_set_source_clk(rmt_channel_t channel, rmt_source_clk_t base_clk) { 6 | return ESP_OK; 7 | } 8 | 9 | esp_err_t rmt_config(const rmt_config_t* rmt_param) { 10 | // TODO: figure out the stuff that matter, and push them. 11 | return ESP_OK; 12 | } 13 | esp_err_t rmt_fill_tx_items(rmt_channel_t channel, const rmt_item32_t* item, uint16_t item_num, uint16_t mem_offset) { 14 | // TODO: figure out the stuff that matter, and push them. 15 | return ESP_OK; 16 | } 17 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/RelaySpindle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | /* 5 | This is used for a basic on/off spindle All S Values above 0 6 | will turn the spindle on. 7 | */ 8 | 9 | #include "RelaySpindle.h" 10 | 11 | // ========================= Relay ================================== 12 | 13 | namespace Spindles { 14 | // Configuration registration 15 | namespace { 16 | SpindleFactory::InstanceBuilder registration("Relay"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /install_scripts/win64/install-fs.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call checksecurity.bat 4 | if not %ErrorLevel% equ 0 ( 5 | exit /b 1 6 | ) 7 | 8 | set EsptoolPath=win64\esptool.exe 9 | 10 | set BaseArgs=--chip esp32 --baud 921600 11 | set SetupArgs=--before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 12 | 13 | set LocalFS=0x3d0000 wifi\littlefs.bin 14 | 15 | echo %EsptoolPath% %BaseArgs% %SetupArgs% %LocalFS% 16 | %EsptoolPath% %BaseArgs% %SetupArgs% %LocalFS% 17 | 18 | echo Starting fluidterm 19 | win64\fluidterm.exe 20 | 21 | pause 22 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/EventPin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "src/Event.h" 4 | #include 5 | 6 | class EventPin { 7 | protected: 8 | const Event* _event; 9 | std::string _legend; // The name that appears in init() messages and the name of the configuration item 10 | 11 | public: 12 | 13 | EventPin(const Event* event, const char* legend) : _event(event), _legend(legend) {}; 14 | 15 | virtual void update(bool state) {}; 16 | 17 | virtual void trigger(bool active); 18 | 19 | const std::string& legend() { return _legend; } 20 | 21 | ~EventPin() {} 22 | }; 23 | -------------------------------------------------------------------------------- /FluidNC/src/UartTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | const int MAX_N_UARTS = UART_NUM_MAX; 6 | 7 | enum class UartData : int { 8 | Bits5 = UART_DATA_5_BITS, 9 | Bits6 = UART_DATA_6_BITS, 10 | Bits7 = UART_DATA_7_BITS, 11 | Bits8 = UART_DATA_8_BITS, 12 | }; 13 | 14 | enum class UartStop : int { 15 | Bits1 = UART_STOP_BITS_1, 16 | Bits1_5 = UART_STOP_BITS_1_5, 17 | Bits2 = UART_STOP_BITS_2, 18 | }; 19 | 20 | enum class UartParity : int { 21 | None = UART_PARITY_DISABLE, 22 | Even = UART_PARITY_EVEN, 23 | Odd = UART_PARITY_ODD, 24 | }; 25 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/spi.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "src/Pins/PinDetail.h" // pinnum_t 5 | #include "driver/spi_master.h" 6 | 7 | bool spi_init_bus(pinnum_t sck_pin, pinnum_t miso_pin, pinnum_t mosi_pin, bool dma); 8 | void spi_deinit_bus(); 9 | 10 | // Returns devid or -1 11 | spi_device_t spi_register_device(pinnum_t cs_pin); 12 | 13 | void spi_unregister_device(spi_device_t devid); 14 | 15 | bool spi_transfer(spi_device_t busid, uint8_t* outbuf, uint8_t* inbuf, size_t len); 16 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/InputBuffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Luc Lebosse. All rights reserved. 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Channel.h" 7 | 8 | namespace WebUI { 9 | class InputBuffer : public Channel { 10 | public: 11 | InputBuffer(); 12 | 13 | size_t write(uint8_t c) override { return 0; } 14 | int availableforwrite() { return 0; }; 15 | 16 | operator bool() const; 17 | 18 | ~InputBuffer(); 19 | }; 20 | 21 | extern InputBuffer inputBuffer; 22 | } 23 | -------------------------------------------------------------------------------- /FluidNC/test/Pins/ErrorPinTest.cpp: -------------------------------------------------------------------------------- 1 | #include "../TestFramework.h" 2 | 3 | #include 4 | 5 | namespace Pins { 6 | Test(Error, Pins) { 7 | // Error pins should throw whenever they are used. 8 | 9 | Pin errorPin = Pin::Error(); 10 | 11 | AssertThrow(errorPin.write(true)); 12 | AssertThrow(errorPin.read()); 13 | 14 | errorPin.setAttr(Pin::Attr::None); 15 | 16 | AssertThrow(errorPin.write(true)); 17 | AssertThrow(errorPin.read()); 18 | 19 | Assert(errorPin.capabilities() == Pin::Capabilities::Error, "Incorrect caps"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/TMC2160ProDriver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "TMC5160ProDriver.h" 7 | #include "../Pin.h" 8 | #include "../PinMapper.h" 9 | 10 | #include 11 | 12 | const float TMC2160_RSENSE_DEFAULT = 0.050f; // Ref only, not used 13 | 14 | namespace MotorDrivers { 15 | 16 | class TMC2160Driver : public TMC5160ProDriver { 17 | public: 18 | const char* name() const override { return "tmc_2160Pro"; } 19 | 20 | private: 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/WebSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Mitch Bradley 2 | // Copyright (c) 2014 Luc Lebosse. All rights reserved. 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "../Config.h" // ENABLE_* 8 | #include "../Settings.h" 9 | #include 10 | 11 | namespace WebUI { 12 | bool get_param(const char* parameter, const char* key, std::string& s); 13 | 14 | #ifdef ENABLE_AUTHENTICATION 15 | extern AuthPasswordSetting* user_password; 16 | extern AuthPasswordSetting* admin_password; 17 | #endif 18 | 19 | } 20 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/PwmPin.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | // PWM driver interface 7 | 8 | #include "src/Pin.h" 9 | 10 | class PwmPin { 11 | public: 12 | PwmPin(Pin& pin, uint32_t frequency); 13 | ~PwmPin(); 14 | uint32_t frequency() { return _frequency; } 15 | uint32_t period() { return _period; } 16 | 17 | void setDuty(uint32_t duty); 18 | 19 | private: 20 | uint32_t _frequency; 21 | int _channel; 22 | int _period; 23 | int _gpio; 24 | }; 25 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/Commands.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Luc Lebosse. All rights reserved. 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | #include "../Config.h" 6 | 7 | namespace WebUI { 8 | class COMMANDS { 9 | public: 10 | static void handle(); 11 | static void restart_MCU(); 12 | static void send_json_command_response(Channel& out, uint cmdID, bool isok = true, std::string message = ""); 13 | static bool isJSON(const char* cmd_params); 14 | 15 | private: 16 | static bool _restart_MCU; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: bdring 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Palpal, etc. 13 | -------------------------------------------------------------------------------- /FluidNC/test/test_main.cpp: -------------------------------------------------------------------------------- 1 | #ifdef ESP32 2 | 3 | # include "TestFactory.h" 4 | # include 5 | # include 6 | # include "unity.h" 7 | 8 | void test_blank() { 9 | int i = 5; 10 | TEST_ASSERT_EQUAL(i, 5); 11 | } 12 | 13 | void setup() { 14 | delay(500); // Let's give it some time first, in case it triggers a reboot. 15 | 16 | UNITY_BEGIN(); 17 | 18 | // calls to tests will go here 19 | // RUN_TEST(test_blank); 20 | 21 | // Run all tests: 22 | TestFactory::instance().runAll(); 23 | 24 | UNITY_END(); // stop unit testing 25 | } 26 | 27 | void loop() {} 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The following people have contributed to the development of FluidNC 2 | 3 | Simen Svale Skogsrud [Grbl] 4 | Sungeun K. Jeon for Gnea Research LLC [Grbl] 5 | Jens Geisler [Grbl motion control enhancements] 6 | Bart Dring [Grbl_ESP32, hardware designs, project management, ongoing design and support] 7 | Luc Lebosse [WebUI] 8 | Simon Jouet [IS2 output expansion] 9 | Michiyasu Odaki [port of I2S output expansion to Grbl_Esp32] 10 | Mitch Bradley (wmb@firmorks.com) [setting architecture, YAML configuration] 11 | Stefan de Bruijn [YAML configuration, VFD spindles] 12 | The Ant Team [Trinamic UART driver] 13 | Marco Wagner [YL620 spindle driver] 14 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/localfs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | bool localfs_format(const char* fsname); 5 | bool localfs_mount(); 6 | void localfs_unmount(); 7 | 8 | const char* canonicalPath(const char* filename, const char* defaultFs); 9 | 10 | std::uintmax_t localfs_size(); 11 | 12 | extern const char* localfsName; 13 | 14 | constexpr const char* sdName = "sd"; 15 | constexpr const char* spiffsName = "spiffs"; 16 | constexpr const char* littlefsName = "littlefs"; 17 | 18 | #ifdef USE_LITTLEFS 19 | constexpr const char* defaultLocalfsName = littlefsName; 20 | #else 21 | constexpr const char* defaultLocalfsName = spiffsName; 22 | #endif 23 | -------------------------------------------------------------------------------- /fluidterm/HOWTO-COMPILE.md: -------------------------------------------------------------------------------- 1 | ## Compiling Fluidterm to an Executable 2 | 3 | You have to do this on the host system on which you wish to run 4 | the executable. 5 | 6 | python3 -m pip install pyinstaller 7 | python3 -m PyInstaller --onefile fluidterm.py 8 | 9 | The output is in dist\fluidterm.exe (Windows) or dist\fluidterm 10 | (Linux and MacOS). On Linux and Mac, the executable may depend 11 | on versions of libraries that might not present on your system. 12 | On those platforms, it can sometimes be easier to run from the 13 | source code, with: 14 | 15 | python3 -m pip install -q pyserial xmodem # Only need to do this once 16 | python3 fluidterm.py 17 | 18 | 19 | -------------------------------------------------------------------------------- /FluidNC/src/EnumItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Usage: 4 | // 5 | // EnumItem stepTypes[] = { 6 | // { ST_TIMED, "Timed" }, { ST_RMT, "RMT" }, { ST_I2S_STATIC, "I2S_static" }, { ST_I2S_STREAM, "I2S_stream" }, EnumItem(ST_RMT) 7 | // }; 8 | 9 | struct EnumItem { 10 | // Used for brace initialization 11 | EnumItem() {} 12 | 13 | // Set enumItem with a default value as last item in the EnumItem array. This is the terminator. 14 | EnumItem(int defaultValue) : value(defaultValue), name(nullptr) {} 15 | 16 | // Other items are here. 17 | EnumItem(int val, const char* n) : value(val), name(n) {} 18 | 19 | int value; 20 | const char* name; 21 | }; 22 | -------------------------------------------------------------------------------- /FluidNC/src/tests/user_io.nc: -------------------------------------------------------------------------------- 1 | (MSG, Starting User I/O tests) 2 | M62 P0 3 | G4 P0.5 4 | M62 P1 5 | G4 P0.5 6 | M62 P2 7 | G4 P0.5 8 | M62 P3 9 | (MSG Digital 1 and 2 on) 10 | G4 P2 11 | M63 P0 12 | M63 P1 13 | M63 P2 14 | M63 P3 15 | G4P1 16 | M67 E0 Q10 17 | M67 E1 Q100 18 | G4 P0.25 19 | M67 E0 Q20 20 | M67 E1 Q90 21 | G4 P0.25 22 | M67 E0 Q30 23 | M67 E1 Q80 24 | G4 P0.25 25 | M67 E0 Q40 26 | M67 E1 Q70 27 | G4 P0.25 28 | M67 E0 Q50 29 | M67 E1 Q60 30 | G4 P0.25 31 | M67 E0 Q60 32 | M67 E1 Q50 33 | G4 P0.25 34 | M67 E0 Q70 35 | M67 E1 Q40 36 | G4 P0.25 37 | M67 E0 Q80 38 | M67 E1 Q30 39 | G4 P0.25 40 | M67 E0 Q90 41 | M67 E1 Q20 42 | G4 P0.25 43 | M67 E0 Q0 44 | M67 E1 Q0 45 | G4 P0.25 -------------------------------------------------------------------------------- /FluidNC/src/ControlPin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Pin.h" 4 | #include "Machine/EventPin.h" 5 | namespace Machine { 6 | class ControlPin : public EventPin { 7 | private: 8 | char _letter; // The name that appears in init() messages and the name of the configuration item 9 | Pin _pin; 10 | 11 | public: 12 | ControlPin(const Event* event, const char* legend, char letter) : EventPin(event, legend), _letter(letter) {} 13 | 14 | void init(); 15 | 16 | bool get() { return _pin.read(); } 17 | 18 | Pin& pin() { return _pin; } 19 | 20 | char letter() { return _letter; }; 21 | 22 | ~ControlPin(); 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/WifiSTAConfig.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2021 - Mitch Bradley 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "../Configuration/Configurable.h" 8 | #include "WifiConfig.h" 9 | 10 | namespace Machine { 11 | class WifiSTAConfig : public WifiConfig { 12 | public: 13 | WifiSTAConfig() = default; 14 | 15 | void validate() override { WifiConfig::validate(); } 16 | 17 | void group(Configuration::HandlerBase& handler) override { WifiConfig::group(handler); } 18 | 19 | ~WifiSTAConfig() = default; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/I2SO.cpp: -------------------------------------------------------------------------------- 1 | #include "../../FluidNC/src/I2SOut.h" 2 | 3 | // STUB implementation. Won't do you any good. 4 | 5 | int i2s_out_init() { 6 | return 0; 7 | } 8 | 9 | void i2s_out_push() {} 10 | 11 | void i2s_out_push_sample(unsigned int x) {} 12 | 13 | int i2s_out_set_passthrough() { 14 | return 0; 15 | } 16 | 17 | int i2s_out_set_stepping() { 18 | return 0; 19 | } 20 | 21 | void i2s_out_delay() {} 22 | 23 | int i2s_out_set_pulse_period(unsigned int x) { 24 | return 0; 25 | } 26 | 27 | int i2s_out_reset() { 28 | return 0; 29 | } 30 | 31 | i2s_out_pulser_status_t i2s_out_get_pulser_status() { 32 | return i2s_out_pulser_status_t::PASSTHROUGH; 33 | } 34 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/I2SOBus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2021 - Mitch Bradley 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "../Configuration/Configurable.h" 8 | 9 | namespace Machine { 10 | class I2SOBus : public Configuration::Configurable { 11 | public: 12 | I2SOBus() = default; 13 | 14 | Pin _bck; 15 | Pin _data; 16 | Pin _ws; 17 | 18 | void validate() override; 19 | void group(Configuration::HandlerBase& handler) override; 20 | 21 | void init(); 22 | 23 | ~I2SOBus() = default; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /FluidNC/src/Jog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC 2 | // Copyright (c) 2018 - Bart Dring 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "Error.h" 8 | #include "Planner.h" 9 | #include "GCode.h" 10 | 11 | // System motion line numbers must be zero. 12 | const int JOG_LINE_NUMBER = 0; 13 | 14 | // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog. 15 | // cancelledInflight will be set to true if was not added to parser due to a cancelJog. 16 | Error jog_execute(plan_line_data_t* pl_data, parser_block_t* gc_block, bool* cancelledInflight); 17 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/SDFS.cpp: -------------------------------------------------------------------------------- 1 | #include "SD.h" 2 | 3 | namespace fs { 4 | 5 | SDFS::SDFS(FSImplPtr impl) : fs::FS(impl) {} 6 | bool SDFS::begin(uint8_t ssPin, SPIClass& spi, uint32_t frequency, const char* mountpoint, uint8_t max_files, bool format_if_empty) { 7 | return true; 8 | } 9 | void SDFS::end() {} 10 | uint64_t SDFS::cardSize() { return 0; } 11 | uint64_t SDFS::totalBytes() { return 0; } 12 | uint64_t SDFS::usedBytes() { return 0; } 13 | bool SDFS::readRAW(uint8_t* buffer, uint32_t sector) { return false; } 14 | bool SDFS::writeRAW(uint8_t* buffer, uint32_t sector) { return false; } 15 | 16 | FSImplPtr inst; 17 | } 18 | 19 | fs::SDFS SD(fs::inst); 20 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "X86TestSupport", 3 | "keywords": "X86TestSupport", 4 | "description": "X86TestSupport is a testing framework developed for FluidNC.", 5 | "license": "GPL", 6 | "homepage": "https://github.com/bdring/FluidNC", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/bdring/FluidNC" 10 | }, 11 | "version": "1.0.0", 12 | "export": { 13 | "include": [ 14 | "*", 15 | "driver/*", 16 | "freertos/*", 17 | "soc/*", 18 | "xtensa/*" 19 | ], 20 | "exclude": [ 21 | ] 22 | }, 23 | "build": { 24 | "flags": [ 25 | ], 26 | "srcFilter": [ 27 | "+<*>", 28 | "+<*/*>" 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FluidNC/src/HashFS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | class HashFS { 7 | public: 8 | static std::map localFsHashes; 9 | 10 | static bool file_is_hashed(const std::filesystem::path& path); 11 | static void delete_file(const std::filesystem::path& path, bool report = true); 12 | static void rehash_file(const std::filesystem::path& path, bool report = true); 13 | static void rename_file(const std::filesystem::path& ipath, const std::filesystem::path& opath, bool report = true); 14 | static void hash_all(); 15 | static void report_change(); 16 | 17 | static std::string hash(const std::filesystem::path& path); 18 | 19 | private: 20 | }; 21 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/SPIFFS.cpp: -------------------------------------------------------------------------------- 1 | #include "SPIFFS.h" 2 | 3 | namespace fs { 4 | 5 | SPIFFSFS::SPIFFSFS() : fs::FS(nullptr), partitionLabel_("spiffs") {} 6 | SPIFFSFS::~SPIFFSFS() {} 7 | bool SPIFFSFS::begin(bool formatOnFail /* = false*/, 8 | const char* basePath /*= "/spiffs"*/, 9 | uint8_t maxOpenFiles /*= 10*/, 10 | const char* partitionLabel /*= NULL*/) { 11 | return true; 12 | } 13 | bool SPIFFSFS::format() { return true; } 14 | size_t SPIFFSFS::totalBytes() { return 1024 * 1024; /* 1 MB */ } 15 | size_t SPIFFSFS::usedBytes() { return 0; } 16 | void SPIFFSFS::end() {} 17 | } 18 | 19 | fs::SPIFFSFS SPIFFS; 20 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/freertos/FreeRTOS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Task.h" 4 | #include "Queue.h" 5 | #include "FreeRTOSTypes.h" 6 | #include 7 | #include 8 | 9 | /* "mux" data structure (spinlock) */ 10 | 11 | struct portMUX_TYPE { 12 | std::atomic lock_ = { false }; 13 | 14 | void lock() { 15 | while (lock_.exchange(true, std::memory_order_acquire)) 16 | ; 17 | } 18 | 19 | void unlock() { lock_.store(false, std::memory_order_release); } 20 | }; 21 | 22 | inline void vTaskExitCritical(portMUX_TYPE* mux) { 23 | mux->lock(); 24 | } 25 | inline void vTaskEnterCritical(portMUX_TYPE* mux) { 26 | mux->unlock(); 27 | } 28 | 29 | inline int32_t xPortGetFreeHeapSize() { 30 | return 1024 * 1024 * 4; 31 | } 32 | -------------------------------------------------------------------------------- /FluidNC/src/UTF8.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | class UTF8 { 10 | private: 11 | uint32_t _num; 12 | int _state = 0; 13 | 14 | public: 15 | // Byte-at-a-time decoder. Returns -1 for error, 1 for okay, 0 for keep trying 16 | int decode(uint8_t ch, uint32_t& value); 17 | 18 | // Vector-of-bytes decoder. Returns true if the vector contains 19 | // a well-formed UTF8 sequence. 20 | bool decode(const std::vector& in, uint32_t& value); 21 | 22 | // Encode to vector 23 | std::vector encode(const uint32_t value); 24 | }; 25 | 26 | void test_UTF8(); 27 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/ParseException.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | namespace Configuration { 7 | class ParseException { 8 | int _linenum; 9 | const std::string _description; 10 | 11 | public: 12 | ParseException() = default; 13 | ParseException(const ParseException&) = default; 14 | 15 | ParseException(int linenum, const char* description) : _linenum(linenum), _description(description) {} 16 | 17 | inline int LineNumber() const { return _linenum; } 18 | inline const std::string& What() const { return _description; } 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /FluidNC/src/Control.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "Configuration/Configurable.h" 7 | #include "ControlPin.h" 8 | #include 9 | 10 | using namespace Machine; 11 | class Control : public Configuration::Configurable { 12 | public: 13 | Control(); 14 | 15 | std::vector _pins; 16 | 17 | // Initializes control pins. 18 | void init(); 19 | 20 | // Configuration handlers. 21 | void group(Configuration::HandlerBase& handler) override; 22 | 23 | bool stuck(); 24 | bool safety_door_ajar(); 25 | 26 | std::string report_status(); 27 | 28 | bool startup_check(); 29 | 30 | ~Control() = default; 31 | }; 32 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/Arduino.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "esp_err.h" 6 | 7 | class SystemRestartException {}; 8 | 9 | #define IRAM_ATTR 10 | 11 | // From Arduino.h: 12 | 13 | void delay(int ms); 14 | 15 | // Get time in microseconds since boot. 16 | int64_t esp_timer_get_time(); 17 | 18 | // this_thread::yield? 19 | #define NOP() \ 20 | do { \ 21 | } while (0); 22 | 23 | #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) 24 | 25 | // ESP... 26 | 27 | #include "Esp.h" 28 | -------------------------------------------------------------------------------- /FluidNC/src/FluidError.cpp: -------------------------------------------------------------------------------- 1 | #include "FluidError.hpp" 2 | 3 | namespace FluidErrorCategory { 4 | const char* error_names[] = { "None", "SDCard not configured" }; 5 | namespace detail { 6 | class category : public std::error_category { 7 | public: 8 | virtual const char* name() const noexcept override { return "FluidError"; } 9 | virtual std::string message(int value) const override { return error_names[(int)value]; } 10 | }; 11 | } 12 | const std::error_category& category() { 13 | // The category singleton 14 | static detail::category instance; 15 | return instance; 16 | } 17 | } 18 | 19 | std::error_code make_error_code(FluidError err) { 20 | return std::error_code(static_cast(err), FluidErrorCategory::category()); 21 | } 22 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/TMC/TMCStepper_UTILITY.h: -------------------------------------------------------------------------------- 1 | #ifndef TMCStepper_UTILITY_h 2 | #define TMCStepper_UTILITY_h 3 | 4 | void print_HEX(uint32_t data) { 5 | for(uint8_t B=24; B>=4; B-=8){ 6 | Serial.print((data>>(B+4))&0xF, HEX); 7 | Serial.print((data>>B)&0xF, HEX); 8 | Serial.print(":"); 9 | } 10 | Serial.print((data>>4)&0xF, HEX); 11 | Serial.print(data&0xF, HEX); 12 | } 13 | 14 | void print_BIN(uint32_t data) { 15 | int b = 31; 16 | for(; b>=24; b--){ 17 | Serial.print((data>>b)&0b1); 18 | } 19 | Serial.print("."); 20 | for(; b>=16; b--){ 21 | Serial.print((data>>b)&0b1); 22 | } 23 | Serial.print("."); 24 | for(; b>=8; b--){ 25 | Serial.print((data>>b)&0b1); 26 | } 27 | Serial.print("."); 28 | for(; b>=0; b--){ 29 | Serial.print((data>>b)&0b1); 30 | } 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /install_scripts/win64/install-bt.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call checksecurity.bat 4 | if not %ErrorLevel% equ 0 ( 5 | exit /b 1 6 | ) 7 | 8 | set BuildType=bt 9 | set EsptoolPath=win64\esptool.exe 10 | 11 | set BaseArgs=--chip esp32 --baud 921600 12 | set SetupArgs=--before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 13 | 14 | set Bootloader=0x1000 %BuildType%\bootloader.bin 15 | set Bootapp=0xe000 common\boot_app0.bin 16 | set Firmware=0x10000 %BuildType%\firmware.bin 17 | set Partitions=0x8000 %BuildType%\partitions.bin 18 | 19 | echo %EsptoolPath% %BaseArgs% %SetupArgs% %Bootloader% %Bootapp% %Firmware% %Partitions% 20 | %EsptoolPath% %BaseArgs% %SetupArgs% %Bootloader% %Bootapp% %Firmware% %Partitions% 21 | 22 | echo Starting fluidterm 23 | win64\fluidterm.exe 24 | 25 | pause 26 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/parser_logging.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | static constexpr bool verbose_debugging = false; 4 | #define log_parser_verbose(x) \ 5 | do { \ 6 | if (verbose_debugging) { \ 7 | log_debug(x); \ 8 | } \ 9 | } while (0) 10 | -------------------------------------------------------------------------------- /install_scripts/win64/install-wifi.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call checksecurity.bat 4 | if not %ErrorLevel% equ 0 ( 5 | exit /b 1 6 | ) 7 | 8 | set BuildType=wifi 9 | set EsptoolPath=win64\esptool.exe 10 | 11 | set BaseArgs=--chip esp32 --baud 921600 12 | set SetupArgs=--before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 13 | 14 | set Bootloader=0x1000 %BuildType%\bootloader.bin 15 | set Bootapp=0xe000 common\boot_app0.bin 16 | set Firmware=0x10000 %BuildType%\firmware.bin 17 | set Partitions=0x8000 %BuildType%\partitions.bin 18 | 19 | echo %EsptoolPath% %BaseArgs% %SetupArgs% %Bootloader% %Bootapp% %Firmware% %Partitions% 20 | %EsptoolPath% %BaseArgs% %SetupArgs% %Bootloader% %Bootapp% %Firmware% %Partitions% 21 | 22 | echo Starting fluidterm 23 | win64\fluidterm.exe 24 | 25 | pause 26 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/SPIBus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2021 - Mitch Bradley 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "../Configuration/Configurable.h" 8 | 9 | namespace Machine { 10 | class SPIBus : public Configuration::Configurable { 11 | public: 12 | SPIBus() = default; 13 | 14 | Pin _miso; 15 | Pin _mosi; 16 | Pin _sck; 17 | 18 | void validate() override; 19 | void group(Configuration::HandlerBase& handler) override; 20 | void afterParse() override; 21 | 22 | void init(); 23 | void deinit(); 24 | 25 | bool defined(); 26 | 27 | ~SPIBus() = default; 28 | 29 | private: 30 | bool _defined = false; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/VoidPinDetail.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "PinDetail.h" 7 | #include "PinOptionsParser.h" 8 | 9 | namespace Pins { 10 | class VoidPinDetail : public PinDetail { 11 | public: 12 | VoidPinDetail(int number = 0); 13 | VoidPinDetail(const PinOptionsParser& options); 14 | 15 | PinCapabilities capabilities() const override; 16 | 17 | // I/O: 18 | void write(int high) override; 19 | int read() override; 20 | void setAttr(PinAttributes value) override; 21 | PinAttributes getAttr() const override; 22 | 23 | std::string toString() override; 24 | 25 | ~VoidPinDetail() override {} 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/AfterParse.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "AfterParse.h" 5 | 6 | #include "Configurable.h" 7 | #include "../System.h" 8 | 9 | #include 10 | 11 | namespace Configuration { 12 | void AfterParse::enterSection(const char* name, Configurable* value) { 13 | _path.push_back(name); // For error handling 14 | 15 | try { 16 | value->afterParse(); 17 | } catch (const AssertionFailed& ex) { 18 | // Log something meaningful to the user: 19 | log_config_error("Initialization error at "; for (auto it : _path) { ss << '/' << it; } ss << ": " << ex.msg); 20 | } 21 | 22 | value->group(*this); 23 | 24 | _path.erase(_path.begin() + (_path.size() - 1)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /embedded/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "embedded4ESP3D", 3 | "description": "Embedded files for ESP3D", 4 | "devDependencies": { 5 | "del": "latest", 6 | "deprecated": "latest", 7 | "fs": "latest", 8 | "gulp": "^4.0.0", 9 | "gulp-bytediff": "latest", 10 | "gulp-cdnizer": "latest", 11 | "gulp-clean-css": "latest", 12 | "gulp-concat": "latest", 13 | "gulp-gzip": "latest", 14 | "gulp-htmlmin": "latest", 15 | "gulp-if": "latest", 16 | "gulp-jshint": "latest", 17 | "gulp-ng-annotate": "latest", 18 | "gulp-remove-code": "latest", 19 | "gulp-replace": "latest", 20 | "gulp-smoosher": "latest", 21 | "gulp-uglify": "latest", 22 | "gulp-zip": "latest", 23 | "jshint": "latest", 24 | "merge-stream": "latest" 25 | }, 26 | "repository": "https://github.com/luc-github/ESP3D", 27 | "author": "Luc LEBOSSE", 28 | "license": "(ISC OR GPL-3.0)" 29 | } 30 | -------------------------------------------------------------------------------- /FluidNC/esp32/spiffs.cpp: -------------------------------------------------------------------------------- 1 | #include "esp_spiffs.h" 2 | #include "esp_log.h" 3 | #include "wdt.h" 4 | #include "src/Config.h" 5 | 6 | bool spiffs_format(const char* partition_label) { 7 | disable_core0_WDT(); 8 | esp_err_t err = esp_spiffs_format(partition_label); 9 | enable_core0_WDT(); 10 | if (err) { 11 | log_info("SPIFFS format failed: " << esp_err_to_name(err)); 12 | return true; 13 | } 14 | return false; 15 | } 16 | bool spiffs_mount(const char* label, bool format) { 17 | esp_log_level_set("SPIFFS", ESP_LOG_NONE); 18 | esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", .partition_label = label, .max_files = 2, .format_if_mount_failed = format }; 19 | 20 | esp_err_t err = esp_vfs_spiffs_register(&conf); 21 | if (err) { 22 | return true; 23 | } 24 | return false; 25 | } 26 | void spiffs_unmount() { 27 | esp_vfs_spiffs_unregister("spiffs"); 28 | } 29 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/Configurable.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "Generator.h" 7 | #include "Parser.h" 8 | 9 | namespace Configuration { 10 | class HandlerBase; 11 | 12 | class Configurable { 13 | Configurable(const Configurable&) = delete; 14 | Configurable(Configurable&&) = default; 15 | 16 | Configurable& operator=(const Configurable&) = delete; 17 | Configurable& operator=(Configurable&&) = default; 18 | 19 | public: 20 | Configurable() = default; 21 | 22 | virtual void validate() {}; 23 | virtual void group(HandlerBase& handler) = 0; 24 | virtual void afterParse() {} 25 | // virtual const char* name() const = 0; 26 | 27 | virtual ~Configurable() {} 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/ErrorPinDetail.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "PinDetail.h" 7 | #include "PinOptionsParser.h" 8 | #include 9 | 10 | namespace Pins { 11 | class ErrorPinDetail : public PinDetail { 12 | std::string _description; 13 | 14 | public: 15 | ErrorPinDetail(std::string_view descr); 16 | 17 | PinCapabilities capabilities() const override; 18 | 19 | // I/O will all give an error: 20 | void write(int high) override; 21 | int read() override; 22 | void setAttr(PinAttributes value) override; 23 | PinAttributes getAttr() const override; 24 | 25 | std::string toString() override; 26 | 27 | ~ErrorPinDetail() override {} 28 | }; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/WifiAPConfig.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2021 - Mitch Bradley 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "../Configuration/Configurable.h" 8 | #include "WifiConfig.h" 9 | 10 | namespace Machine { 11 | class WifiAPConfig : public WifiConfig { 12 | public: 13 | WifiAPConfig() = default; 14 | 15 | int _channel = 1; 16 | 17 | void validate() override { 18 | WifiConfig::validate(); 19 | Assert(_channel >= 1 && _channel <= 16, "WIFI channel %d is out of bounds", _channel); // TODO: I guess? 20 | } 21 | 22 | void group(Configuration::HandlerBase& handler) override { 23 | WifiConfig::group(handler); 24 | handler.item("channel", _channel); 25 | } 26 | 27 | ~WifiAPConfig() = default; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /FluidNC/esp32/esp_error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 202f Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | // Wrapper to make std:error_code from ESP_IDF esp_err_t values 5 | 6 | #include "esp_error.hpp" // Adapter 7 | 8 | namespace esp_error { 9 | namespace detail { 10 | class category : public std::error_category { 11 | public: 12 | virtual const char* name() const noexcept override { return "esp_error"; } 13 | virtual std::string message(int value) const override { 14 | // Let the native function do the actual work 15 | return ::esp_err_to_name((esp_err_t)value); 16 | } 17 | }; 18 | } // namespace detail 19 | 20 | const std::error_category& category() { 21 | // The category singleton 22 | static detail::category instance; 23 | return instance; 24 | } 25 | } // namespace esp_error 26 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/I2CBus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Configuration/Configurable.h" 7 | 8 | #include 9 | 10 | class TwoWire; 11 | 12 | namespace Machine { 13 | class I2CBus : public Configuration::Configurable { 14 | private: 15 | bool _error = false; 16 | 17 | public: 18 | I2CBus(int busNumber); 19 | 20 | int _busNumber = 0; 21 | Pin _sda; 22 | Pin _scl; 23 | uint32_t _frequency = 100000; 24 | 25 | void init(); 26 | void validate() override; 27 | void group(Configuration::HandlerBase& handler) override; 28 | 29 | int write(uint8_t address, const uint8_t* data, size_t count); 30 | int read(uint8_t address, uint8_t* data, size_t count); 31 | 32 | ~I2CBus() = default; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/StepStick.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | /* 7 | Stepstick.cpp -- stepstick type stepper drivers 8 | */ 9 | 10 | #include "StandardStepper.h" 11 | 12 | namespace MotorDrivers { 13 | class StepStick : public StandardStepper { 14 | Pin _MS1; 15 | Pin _MS2; 16 | Pin _MS3; 17 | Pin _Reset; 18 | 19 | public: 20 | StepStick() = default; 21 | 22 | void init() override; 23 | 24 | // Configuration handlers: 25 | void validate() override; 26 | void group(Configuration::HandlerBase& handler) override; 27 | 28 | void afterParse() override; 29 | 30 | // Name of the configurable. Must match the name registered in the cpp file. 31 | const char* name() const override; 32 | 33 | ~StepStick() = default; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /FluidNC/include/Driver/fluidnc_gpio.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "src/Pins/PinDetail.h" // pinnum_t 7 | 8 | // GPIO interface 9 | 10 | void gpio_write(pinnum_t pin, bool value); 11 | bool gpio_read(pinnum_t pin); 12 | void gpio_mode(pinnum_t pin, bool input, bool output, bool pullup, bool pulldown, bool opendrain = false); 13 | void gpio_set_interrupt_type(pinnum_t pin, int mode); 14 | void gpio_add_interrupt(pinnum_t pin, int mode, void (*callback)(void*), void* arg); 15 | void gpio_remove_interrupt(pinnum_t pin); 16 | void gpio_route(pinnum_t pin, uint32_t signal); 17 | 18 | class Print; 19 | void gpio_dump(Print& out); 20 | 21 | typedef void (*gpio_dispatch_t)(int, void*, bool); 22 | 23 | void gpio_set_action(int gpio_num, gpio_dispatch_t action, void* arg, bool invert); 24 | void gpio_clear_action(int gpio_num); 25 | void poll_gpios(); 26 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/RelaySpindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | /* 7 | This is used for a basic on/off spindle All S Values above 0 8 | will turn the spindle on. 9 | */ 10 | #include "OnOffSpindle.h" 11 | 12 | namespace Spindles { 13 | // This is for an on/off spindle all RPMs above 0 are on 14 | class Relay : public OnOff { 15 | public: 16 | Relay() = default; 17 | 18 | Relay(const Relay&) = delete; 19 | Relay(Relay&&) = delete; 20 | Relay& operator=(const Relay&) = delete; 21 | Relay& operator=(Relay&&) = delete; 22 | 23 | ~Relay() {} 24 | 25 | // Configuration handlers: 26 | 27 | // Name of the configurable. Must match the name registered in the cpp file. 28 | const char* name() const override { return "Relay"; } 29 | 30 | protected: 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /debug.ini: -------------------------------------------------------------------------------- 1 | ; Edit this to optimize for your debug environment and 2 | ; uncomment the extra_configs line in platformio.ini 3 | 4 | [env] 5 | ; Windows 6 | upload_port = COM3 7 | monitor_port = COM3 8 | ; macOS 9 | ;upload_port = /dev/cu.SLAB_USBtoUART 10 | ;monitor_port = /dev/cu.SLAB_USBtoUART 11 | ; macOS ESP-Prog 12 | ;upload_port = /dev/cu.usbserial-14200 13 | ;monitor_port = /dev/cu.usbserial-14201 14 | ;upload_protocol = esp-prog 15 | ; Linux 16 | ;upload_port = /dev/ttyUSB* 17 | ;monitor_port = /dev/ttyUSB* 18 | build_flags = 19 | ${common.build_flags} 20 | -DMACHINE_FILENAME=test_drive.h 21 | 22 | [env:debug] 23 | ; You can switch between debugging tools using debug_tool option 24 | ; https://docs.platformio.org/en/latest/plus/debugging.html#tools-debug-probes 25 | ; 26 | ; Minimodule 27 | ;;debug_tool = minimodule 28 | ;;upload_protocol = minimodule 29 | ; ESP-Prog 30 | debug_tool = esp-prog 31 | upload_protocol = esp-prog 32 | 33 | ;debug_init_break = thb app_main 34 | debug_init_break = thb setup 35 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/LegacySettingHandler.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "LegacySettingRegistry.h" 7 | 8 | namespace Configuration { 9 | class LegacySettingHandler { 10 | public: 11 | inline LegacySettingHandler() { LegacySettingRegistry::registerHandler(this); } 12 | 13 | LegacySettingHandler(const LegacySettingHandler&) = delete; 14 | LegacySettingHandler(LegacySettingHandler&&) = delete; 15 | LegacySettingHandler& operator=(const LegacySettingHandler&) = delete; 16 | LegacySettingHandler& operator=(LegacySettingHandler&&) = delete; 17 | 18 | virtual int index() = 0; 19 | virtual void setValue(const char* value) = 0; 20 | 21 | virtual ~LegacySettingHandler() { 22 | // Remove from factory? We shouldn't remove handlers... 23 | } 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp32-hal-timer.cpp: -------------------------------------------------------------------------------- 1 | #include "esp32-hal-timer.h" 2 | 3 | uint32_t g_ticks_per_us_pro = 240 * 1000 * 1000; // For CPU 0 - typically 240 MHz 4 | uint32_t g_ticks_per_us_app = 240 * 1000 * 1000; // For CPU 1 - typically 240 MHz 5 | 6 | struct hw_timer_s {}; 7 | 8 | // TODO: These are just stubs. 9 | 10 | void timerAlarmEnable(hw_timer_t* timer) {} 11 | void timerAlarmDisable(hw_timer_t* timer) {} 12 | void timerWrite(hw_timer_t* timer, uint64_t val) {} 13 | void timerAlarmWrite(hw_timer_t* timer, uint64_t interruptAt, bool autoreload) {} 14 | 15 | hw_timer_t* timerBegin(uint8_t timer, uint16_t divider, bool countUp) { 16 | return new hw_timer_t(); 17 | } 18 | 19 | void timerEnd(hw_timer_t* timer) { 20 | delete timer; 21 | } 22 | 23 | void timerAttachInterrupt(hw_timer_t* timer, void (*fn)(void), bool edge) {} 24 | void timerDetachInterrupt(hw_timer_t* timer) {} 25 | 26 | // Figure this out: 27 | extern "C" { 28 | esp_err_t esp_task_wdt_reset(void) { 29 | return ESP_OK; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FluidNC/src/Event.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | // Objects derived from the Event base class are placed in the event queue. 7 | // Protocol dequeues them and calls their run methods. 8 | class Event { 9 | public: 10 | Event() {} 11 | virtual void run(void* arg) const = 0; 12 | }; 13 | 14 | class NoArgEvent : public Event { 15 | void (*_function)() = nullptr; 16 | 17 | public: 18 | NoArgEvent(void (*function)()) : _function(function) {} 19 | void run(void* arg) const override { 20 | if (_function) { 21 | _function(); 22 | } 23 | } 24 | }; 25 | 26 | class ArgEvent : public Event { 27 | void (*_function)(void*) = nullptr; 28 | 29 | public: 30 | ArgEvent(void (*function)(void*)) : _function(function) {} 31 | void run(void* arg) const override { 32 | if (_function) { 33 | _function(arg); 34 | } 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /FluidNC/test/TestFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct TestBase { 6 | TestBase() : next(nullptr) {} 7 | TestBase* next; 8 | 9 | virtual const char* unitTestCase() const = 0; 10 | virtual const char* unitTestName() const = 0; 11 | 12 | #ifdef ESP32 13 | typedef void (*TestFunction)(); 14 | virtual TestFunction getFunction() = 0; 15 | #else 16 | #endif 17 | virtual void run() = 0; 18 | }; 19 | 20 | class TestFactory { 21 | TestBase* first; 22 | TestBase* last; 23 | 24 | TestFactory() : first(nullptr), last(nullptr) {} 25 | TestFactory(const TestFactory& o) = default; 26 | 27 | public: 28 | static TestFactory& instance() { 29 | static TestFactory instance_; 30 | return instance_; 31 | } 32 | 33 | void registerTest(TestBase* test) { 34 | if (last == nullptr) { 35 | first = last = test; 36 | } else { 37 | last->next = test; 38 | last = test; 39 | } 40 | } 41 | 42 | void runAll(); 43 | }; 44 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/I2SOBus.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2021 - Mitch Bradley 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #include "I2SOBus.h" 6 | #include "../I2SOut.h" 7 | 8 | namespace Machine { 9 | void I2SOBus::validate() { 10 | if (_bck.defined() || _data.defined() || _ws.defined()) { 11 | Assert(_bck.defined(), "I2SO BCK pin should be configured once"); 12 | Assert(_data.defined(), "I2SO Data pin should be configured once"); 13 | Assert(_ws.defined(), "I2SO WS pin should be configured once"); 14 | } 15 | } 16 | 17 | void I2SOBus::group(Configuration::HandlerBase& handler) { 18 | handler.item("bck_pin", _bck); 19 | handler.item("data_pin", _data); 20 | handler.item("ws_pin", _ws); 21 | } 22 | 23 | void I2SOBus::init() { 24 | log_info("I2SO BCK:" << _bck.name() << " WS:" << _ws.name() << " DATA:" << _data.name()); 25 | i2s_out_init(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /embedded/header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | nofile.h - ESP3D data file 3 | 4 | Copyright (c) 2014 Luc Lebosse. All rights reserved. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | //data generated by https://github.com/AraHaan/bin2c 22 | //bin2c Conversion Tool v0.14.0 - Windows - [FINAL]. 23 | #ifndef __nofile_h 24 | #define __nofile_h 25 | -------------------------------------------------------------------------------- /FluidNC/src/Kinematics/Midtbot.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | /* 7 | Midtbot.h 8 | 9 | Midtbot is simply a CoreXY with compensation for the moving motors 10 | 11 | */ 12 | 13 | #include "Kinematics.h" 14 | #include "CoreXY.h" 15 | 16 | namespace Kinematics { 17 | class Midtbot : public CoreXY { 18 | public: 19 | Midtbot() = default; 20 | 21 | Midtbot(const Midtbot&) = delete; 22 | Midtbot(Midtbot&&) = delete; 23 | Midtbot& operator=(const Midtbot&) = delete; 24 | Midtbot& operator=(Midtbot&&) = delete; 25 | 26 | // Kinematic Interface 27 | 28 | void init() override; 29 | void group(Configuration::HandlerBase& handler) override; 30 | 31 | // Name of the configurable. Must match the name registered in the cpp file. 32 | const char* name() const override { return "midtbot"; } 33 | 34 | ~Midtbot() {} 35 | }; 36 | } // namespace Kinematics 37 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/VoidPinDetail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include // IRAM_ATTR 5 | #include "VoidPinDetail.h" 6 | 7 | namespace Pins { 8 | VoidPinDetail::VoidPinDetail(int number) : PinDetail(number) {} 9 | VoidPinDetail::VoidPinDetail(const PinOptionsParser& options) : VoidPinDetail() {} 10 | 11 | PinCapabilities VoidPinDetail::capabilities() const { 12 | // Void pins support basic functionality. It just won't do you any good. 13 | return PinCapabilities::Output | PinCapabilities::Input | PinCapabilities::ISR | PinCapabilities::Void; 14 | } 15 | 16 | void IRAM_ATTR VoidPinDetail::write(int high) {} 17 | int VoidPinDetail::read() { return 0; } 18 | void VoidPinDetail::setAttr(PinAttributes value) {} 19 | PinAttributes VoidPinDetail::getAttr() const { return PinAttributes::None; } 20 | 21 | std::string VoidPinDetail::toString() { return std::string("NO_PIN"); } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/esp32-hal-timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "esp_err.h" 5 | 6 | extern uint32_t g_ticks_per_us_pro; // For CPU 0 - typically 240 MHz 7 | extern uint32_t g_ticks_per_us_app; // For CPU 1 - typically 240 MHz 8 | 9 | // Timer: 10 | 11 | struct hw_timer_s; 12 | typedef struct hw_timer_s hw_timer_t; 13 | 14 | void timerAlarmEnable(hw_timer_t* timer); 15 | void timerAlarmDisable(hw_timer_t* timer); 16 | void timerWrite(hw_timer_t* timer, uint64_t val); 17 | void timerAlarmWrite(hw_timer_t* timer, uint64_t interruptAt, bool autoreload); 18 | 19 | hw_timer_t* timerBegin(uint8_t timer, uint16_t divider, bool countUp); 20 | void timerEnd(hw_timer_t* timer); 21 | 22 | void timerAttachInterrupt(hw_timer_t* timer, void (*fn)(void), bool edge); 23 | void timerDetachInterrupt(hw_timer_t* timer); 24 | 25 | // Figure this out: 26 | extern "C" { 27 | esp_err_t esp_task_wdt_reset(void); 28 | } 29 | 30 | unsigned long micros(); 31 | unsigned long millis(); 32 | void delay(uint32_t); 33 | void delayMicroseconds(uint32_t us); 34 | -------------------------------------------------------------------------------- /install_scripts/win64/checksecurity.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set EsptoolPath=win64\esptool.exe 3 | 4 | set BaseArgs=--chip esp32 --baud 921600 5 | 6 | rem Read the security fuses 7 | echo %EsptoolPath% %BaseArgs% dump_mem 0x3ff5a018 4 SecurityFuses.bin 8 | %EsptoolPath% %BaseArgs% dump_mem 0x3ff5a018 4 SecurityFuses.bin 9 | 10 | if not %ErrorLevel% equ 0 ( 11 | echo esptool failed 12 | pause 13 | exit /b 1 14 | ) 15 | 16 | fc /b SecurityFuses.bin common\SecurityFusesOK.bin > nul 2>&1 17 | if not %Errorlevel% equ 0 ( 18 | fc /b SecurityFuses.bin common\SecurityFusesOK0.bin > nul 2>&1 19 | if not %Errorlevel% equ 0 ( 20 | echo ******************************************* 21 | echo * Secure boot is enabled on this ESP32 * 22 | echo * Loading FluidNC would probably brick it * 23 | echo * !ABORTED! Read Wiki for more Info * 24 | echo ******************************************* 25 | fc /b SecurityFuses.bin common\SecurityFusesOK0.bin 26 | del SecurityFuses.bin 27 | pause 28 | exit /b 1 29 | ) 30 | ) 31 | del SecurityFuses.bin 32 | exit /b 0 33 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/Servo.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | #include 6 | #include // TimerHandle_t 7 | 8 | /* 9 | This is a base class for servo-type motors - ones that autonomously 10 | move to a specified position, instead of being moved incrementally 11 | by stepping. Specific kinds of servo motors inherit from it. 12 | */ 13 | 14 | #include "MotorDriver.h" 15 | 16 | namespace MotorDrivers { 17 | class Servo : public MotorDriver { 18 | public: 19 | Servo(); 20 | 21 | virtual void update() = 0; // This must be implemented by derived classes 22 | void group(Configuration::HandlerBase& handler) override {} 23 | 24 | virtual const char* name() = 0; // This must be implemented by derived classes 25 | 26 | protected: 27 | static void update_servo(TimerHandle_t timer); 28 | static void schedule_update(Servo* object, int interval); 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/TMC2130Driver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "TrinamicSpiDriver.h" 7 | #include "../Pin.h" 8 | #include "../PinMapper.h" 9 | 10 | #include 11 | 12 | const float TMC2130_RSENSE_DEFAULT = 0.11f; 13 | 14 | namespace MotorDrivers { 15 | 16 | class TMC2130Driver : public TrinamicSpiDriver { 17 | public: 18 | // Overrides for inherited methods 19 | void init() override; 20 | void set_disable(bool disable); 21 | void config_motor() override; 22 | void debug_message() override; 23 | void validate() override { StandardStepper::validate(); } 24 | 25 | // Name of the configurable. Must match the name registered in the cpp file. 26 | const char* name() const override { return "tmc_2130"; } 27 | 28 | private: 29 | TMC2130Stepper* tmc2130 = nullptr; 30 | 31 | bool test(); 32 | void set_registers(bool isHoming) override; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /example_configs/uartio.yaml: -------------------------------------------------------------------------------- 1 | name: "UART I/O test config" 2 | board: "6 Pack Controller" 3 | 4 | stepping: 5 | engine: RMT 6 | idle_ms: 250 7 | dir_delay_us: 1 8 | pulse_us: 2 9 | disable_delay_us: 0 10 | 11 | 12 | uart1: 13 | txd_pin: gpio.4 14 | rxd_pin: gpio.26 15 | baud: 921600 16 | mode: 8N1 17 | 18 | uart_channel1: 19 | report_interval_ms: 75 20 | uart_num: 1 21 | all_messages: false 22 | 23 | 24 | i2so: 25 | bck_pin: gpio.22 26 | data_pin: gpio.21 27 | ws_pin: gpio.17 28 | 29 | spi: 30 | miso_pin: gpio.19 31 | mosi_pin: gpio.23 32 | sck_pin: gpio.18 33 | 34 | sdcard: 35 | cs_pin: gpio.5 36 | card_detect_pin: NO_PIN 37 | 38 | probe: 39 | pin: NO_PIN 40 | 41 | user_outputs: 42 | digital0_pin: uart_channel1.0 43 | digital1_pin: uart_channel1.1 44 | digital2_pin: uart_channel1.2 45 | digital3_pin: uart_channel1.3 46 | digital4_pin: uart_channel1.4 47 | digital5_pin: uart_channel1.5 48 | digital6_pin: uart_channel1.6 49 | digital7_pin: uart_channel1.7 50 | 51 | coolant: 52 | mist_pin: uart_channel1.8 53 | flood_pin: uart_channel1.9 54 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/UserOutputs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2021 - Mitch Bradley 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "../Configuration/Configurable.h" 8 | #include "../GCode.h" // MaxUserDigitalPin MaxUserAnalogPin 9 | #include "Driver/PwmPin.h" // pwm_chan_t 10 | 11 | namespace Machine { 12 | class UserOutputs : public Configuration::Configurable { 13 | PwmPin* _pwm[MaxUserAnalogPin]; 14 | uint32_t _current_value[MaxUserAnalogPin]; 15 | 16 | public: 17 | UserOutputs(); 18 | 19 | Pin _analogOutput[MaxUserAnalogPin]; 20 | int _analogFrequency[MaxUserAnalogPin]; 21 | Pin _digitalOutput[MaxUserDigitalPin]; 22 | 23 | void init(); 24 | void all_off(); 25 | 26 | void group(Configuration::HandlerBase& handler) override; 27 | bool setDigital(size_t io_num, bool isOn); 28 | bool setAnalogPercent(size_t io_num, float percent); 29 | 30 | ~UserOutputs(); 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/LegacySettingRegistry.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "../Config.h" 8 | 9 | namespace Configuration { 10 | class LegacySettingHandler; 11 | 12 | class LegacySettingRegistry { 13 | static LegacySettingRegistry& instance() { 14 | static LegacySettingRegistry instance_; 15 | return instance_; 16 | } 17 | 18 | LegacySettingRegistry() = default; 19 | 20 | LegacySettingRegistry(const LegacySettingRegistry&) = delete; 21 | LegacySettingRegistry& operator=(const LegacySettingRegistry&) = delete; 22 | 23 | std::vector handlers_; 24 | 25 | static bool isLegacySetting(const char* str); 26 | static void tryLegacy(int index, const char* value); 27 | 28 | public: 29 | static void registerHandler(LegacySettingHandler* handler); 30 | static bool tryHandleLegacy(const char* str); 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/ChannelPinDetail.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "PinDetail.h" 7 | #include "PinOptionsParser.h" 8 | #include "src/Channel.h" 9 | #include "../Logging.h" 10 | 11 | namespace Pins { 12 | class ChannelPinDetail : public PinDetail { 13 | private: 14 | Channel* _channel; 15 | PinAttributes _attributes; 16 | bool _value = false; 17 | 18 | public: 19 | ChannelPinDetail(Channel* channel, int number, const PinOptionsParser& options); 20 | 21 | PinCapabilities capabilities() const override; 22 | 23 | // I/O: 24 | void write(int high) override; 25 | int read() override; 26 | void setAttr(PinAttributes value) override; 27 | PinAttributes getAttr() const override; 28 | 29 | void registerEvent(EventPin* obj); 30 | 31 | std::string toString() override; 32 | 33 | ~ChannelPinDetail() override {} 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /VisualStudio.md: -------------------------------------------------------------------------------- 1 | # Getting started with GRBL_ESP32 in Visual Studio 2 | 3 | **!! Important !! There's a huge difference between Visual Studio and 4 | Visual Studio Code. This document is about Visual Studio, not Visual 5 | Studio Code!** 6 | 7 | First, get PlatformIO to work with Visual studio. The steps that 8 | need to be taken for this are the following: 9 | 10 | 1. Install python. This is needed for both PlatformIO and for generating 11 | the vcxproj file. 12 | 2. From https://docs.platformio.org/en/latest/core/index.html#piocore 13 | you should install the PlatformIO Core (CLI). Make sure you update 14 | the command line search path. 15 | 3. Use python to generate a vcxproj file: `python generate_vcxproj.py`. 16 | 4. Start FluidNC.sln 17 | 18 | ## Building 19 | 20 | Building is as easy as building your solution. 21 | 22 | ## Uploading 23 | 24 | Uploading can be done from the command line using platformio. For 25 | example, run `platformio run --target upload --upload-port COM7`. 26 | For more details, see [the documentation of pio](https://dokk.org/documentation/platformio/v3.6.1/platforms/espressif32/). 27 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/WifiConfig.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2021 - Mitch Bradley 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "../Configuration/Configurable.h" 8 | #include 9 | 10 | namespace Machine { 11 | class WifiConfig : public Configuration::Configurable { 12 | public: 13 | IPAddress _ipAddress; 14 | IPAddress _gateway; 15 | IPAddress _netmask; 16 | 17 | WifiConfig() : _ipAddress(10, 0, 0, 1), _gateway(10, 0, 0, 1), _netmask(255, 255, 0, 0) {} 18 | 19 | std::string _ssid = "FluidNC"; 20 | 21 | bool _dhcp = true; 22 | 23 | void group(Configuration::HandlerBase& handler) override { 24 | handler.item("ssid", _ssid); 25 | // No passwords in the config file! 26 | handler.item("ip_address", _ipAddress); 27 | handler.item("gateway", _gateway); 28 | handler.item("netmask", _netmask); 29 | 30 | handler.item("dhcp", _dhcp); 31 | } 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /FluidNC/esp32/coredump.c: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | // 4 | // Noop replacements for ESP-IDF coredump routines. 5 | // This suppresses complaints about not being able to find a coredump partition. 6 | // We don't want to waste space for such a partition, and the Arduino Framework 7 | // enables coredumps. We override that by stubbing out these routines. 8 | 9 | #include 10 | #include "esp_err.h" 11 | #include "esp_private/panic_internal.h" 12 | #include "esp_core_dump_summary_port.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | void esp_core_dump_init(void) {} 19 | 20 | void esp_core_dump_flash_init(void) {} 21 | void esp_core_dump_to_flash(void* info) {} 22 | 23 | esp_err_t esp_core_dump_image_check(void) { 24 | return ESP_ERR_NOT_FOUND; 25 | } 26 | esp_err_t esp_core_dump_image_get(size_t* out_addr, size_t* out_size) { 27 | return ESP_ERR_NOT_FOUND; 28 | } 29 | esp_err_t esp_core_dump_image_erase(void) { 30 | return ESP_OK; 31 | } 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/Validator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "Validator.h" 5 | 6 | #include "Configurable.h" 7 | #include "../System.h" 8 | 9 | #include 10 | #include 11 | 12 | namespace Configuration { 13 | Validator::Validator() { 14 | // Read fence for config. Shouldn't be necessary, but better safe than sorry. 15 | std::atomic_thread_fence(std::memory_order::memory_order_seq_cst); 16 | } 17 | 18 | void Validator::enterSection(const char* name, Configurable* value) { 19 | _path.push_back(name); // For error handling 20 | 21 | try { 22 | value->validate(); 23 | } catch (const AssertionFailed& ex) { 24 | // Log something meaningful to the user: 25 | log_config_error("Validation error at "; for (auto it : _path) { ss << '/' << it; } ss << ": " << ex.msg); 26 | } 27 | 28 | value->group(*this); 29 | 30 | _path.erase(_path.begin() + (_path.size() - 1)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/H100Spindle.md: -------------------------------------------------------------------------------- 1 | # Basic protocol of H100 spindle 2 | 3 | All these things are tested 4 | 5 | ## H100 General protocol 6 | 7 | [id] [fcn code] [start addr] [payload] [checksum] 8 | 9 | Read F011 (min frequency) and F005 (max frequency): 10 | 11 | [03] [000B] [0001] gives [03] [02] [xxxx] (with 02 the result byte count). 12 | [03] [0005] [0001] gives [03] [02] [xxxx] (with 02 the result byte count). 13 | 14 | First commands. These give the identity response if things go correctly. So: 15 | 16 | [01] [05] [00 49] [ff 00] [0c 2c] -- forward run 17 | [01] [05] [00 4A] [ff 00] [0c 2c] -- reverse run 18 | [01] [05] [00 4B] [ff 00] [0c 2c] -- stop 19 | 20 | Tracking: 21 | 22 | [01] [04] [0000] [0002] -- output frequency 23 | gives [01] [04] [04] [00] [00] [0F] [crc16]. 24 | 25 | 01 04 |xx xx| |xx xx| |crc1 crc2|. So that's addr, cmd=04, 26 | 2x 2xdata. First data seems running freq, second data set 27 | freq. Running freq is *data[2,3]*. 28 | 29 | Set frequency: 30 | [01] [06] [0201] [07D0] Set frequency to [07D0] = 200.0 Hz. (2000 is written!) 31 | 32 | Irrelevant but could be useful: 33 | [01] [04] [0001] [0002] -- set frequency 34 | -------------------------------------------------------------------------------- /FluidNC/test/Pins/BasicGPIO.cpp: -------------------------------------------------------------------------------- 1 | #include "../TestFramework.h" 2 | 3 | #include 4 | 5 | #ifdef ESP32 6 | 7 | extern "C" int __digitalRead(uint8_t pin); 8 | extern "C" void __pinMode(uint8_t pin, uint8_t mode); 9 | extern "C" void __digitalWrite(uint8_t pin, uint8_t val); 10 | 11 | namespace Pins { 12 | Test(BasicGPIO, ReadGPIORaw) { 13 | auto pin = 26; 14 | 15 | // Enable driver, write high/low. 16 | __pinMode(pin, OUTPUT); 17 | 18 | __digitalWrite(pin, HIGH); 19 | auto value = __digitalRead(pin); 20 | Assert(value != 0); 21 | 22 | __digitalWrite(pin, LOW); 23 | value = __digitalRead(pin); 24 | Assert(value == 0); 25 | 26 | __digitalWrite(pin, HIGH); 27 | value = __digitalRead(pin); 28 | Assert(value != 0); 29 | 30 | __digitalWrite(pin, LOW); 31 | value = __digitalRead(pin); 32 | Assert(value == 0); 33 | 34 | // Disable driver, should read the last value (low). 35 | __pinMode(pin, INPUT); 36 | value = __digitalRead(pin); 37 | Assert(value == 0); 38 | } 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /FluidNC/src/StackTrace/AssertionFailed.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #ifdef ESP32 9 | class AssertionFailed { 10 | public: 11 | std::string stackTrace; 12 | std::string msg; 13 | 14 | AssertionFailed(std::string st, std::string message) : stackTrace(st), msg(message) {} 15 | 16 | static AssertionFailed create(const char* condition) { return create(condition, "Assertion failed"); } 17 | static AssertionFailed create(const char* condition, const char* msg, ...); 18 | 19 | const char* what() const { return msg.c_str(); } 20 | }; 21 | 22 | #else 23 | # include 24 | 25 | class AssertionFailed { 26 | public: 27 | std::string stackTrace; 28 | std::string msg; 29 | 30 | static std::exception create(const char* condition) { return create(condition, "Assertion failed"); } 31 | static std::exception create(const char* condition, const char* msg, ...); 32 | 33 | const char* what() const { return msg.c_str(); } 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/NowForeverSpindle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VFDSpindle.h" 4 | 5 | namespace Spindles { 6 | class NowForever : public VFD { 7 | protected: 8 | uint16_t _minFrequency = 0; 9 | uint16_t _maxFrequency = 0; 10 | 11 | void updateRPM(); 12 | 13 | void direction_command(SpindleState mode, ModbusCommand& data) override; 14 | void set_speed_command(uint32_t hz, ModbusCommand& data) override; 15 | 16 | response_parser initialization_sequence(int index, ModbusCommand& data) override; 17 | response_parser get_current_speed(ModbusCommand& data) override; 18 | response_parser get_current_direction(ModbusCommand& data) override; 19 | response_parser get_status_ok(ModbusCommand& data) override; 20 | bool safety_polling() const { return true; } 21 | 22 | bool use_delay_settings() const override { return false; } 23 | 24 | // Name of the configurable. Must match the name registered in the cpp file. 25 | const char* name() const override { return "NowForever"; } 26 | 27 | public: 28 | NowForever(); 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/H2ASpindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "VFDSpindle.h" 7 | 8 | namespace Spindles { 9 | class H2A : public VFD { 10 | protected: 11 | void direction_command(SpindleState mode, ModbusCommand& data) override; 12 | void set_speed_command(uint32_t dev_speed, ModbusCommand& data) override; 13 | 14 | response_parser initialization_sequence(int index, ModbusCommand& data) override; 15 | response_parser get_current_speed(ModbusCommand& data) override; 16 | response_parser get_current_direction(ModbusCommand& data) override; 17 | response_parser get_status_ok(ModbusCommand& data) override { return nullptr; } 18 | 19 | bool use_delay_settings() const override { return false; } 20 | bool safety_polling() const override { return false; } 21 | 22 | // Name of the configurable. Must match the name registered in the cpp file. 23 | const char* name() const override { return "H2A"; } 24 | 25 | uint32_t _maxRPM; 26 | 27 | public: 28 | H2A(); 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /FluidNC/src/Assert.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "StackTrace/AssertionFailed.h" 7 | 8 | class AssertionFailed; 9 | 10 | #undef Assert 11 | 12 | #define Stringify(x) #x 13 | #define Stringify2(x) Stringify(x) 14 | #define Assert(condition, ...) \ 15 | { \ 16 | if (!(condition)) { \ 17 | const char* ch = #condition " (@line " Stringify2(__LINE__) ")"; \ 18 | throw AssertionFailed::create(ch, ##__VA_ARGS__); \ 19 | } \ 20 | } 21 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/I2SOPinDetail.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | #ifdef ESP32 6 | 7 | # include "PinDetail.h" 8 | 9 | namespace Pins { 10 | class I2SOPinDetail : public PinDetail { 11 | PinCapabilities _capabilities; 12 | PinAttributes _attributes; 13 | int _readWriteMask; 14 | 15 | static const int nI2SOPins = 32; 16 | static std::vector _claimed; 17 | 18 | bool _lastWrittenValue = false; 19 | 20 | public: 21 | I2SOPinDetail(pinnum_t index, const PinOptionsParser& options); 22 | 23 | PinCapabilities capabilities() const override; 24 | 25 | // I/O: 26 | void write(int high) override; 27 | void synchronousWrite(int high) override; 28 | int read() override; 29 | void setAttr(PinAttributes value) override; 30 | PinAttributes getAttr() const override; 31 | 32 | std::string toString() override; 33 | 34 | ~I2SOPinDetail() override { _claimed[_index] = false; } 35 | }; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/Generator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "Generator.h" 5 | 6 | #include "Configurable.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace Configuration { 13 | Generator::Generator(Channel& dst, int indent) : indent_(indent), dst_(dst) { 14 | std::atomic_thread_fence(std::memory_order::memory_order_seq_cst); 15 | } 16 | 17 | void Generator::enter(const char* name) { 18 | send_item(name, ""); 19 | indent_++; 20 | } 21 | 22 | void Generator::add(Configuration::Configurable* configurable) { 23 | if (configurable != nullptr) { 24 | configurable->group(*this); 25 | } 26 | } 27 | 28 | void Generator::leave() { 29 | if (!lastIsNewline_) { 30 | log_string(dst_, ""); 31 | lastIsNewline_ = true; 32 | } 33 | 34 | indent_--; 35 | } 36 | 37 | void Generator::enterSection(const char* name, Configurable* value) { 38 | enter(name); 39 | value->group(*this); 40 | leave(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /FluidNC/src/Limits.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC 2 | // Copyright (c) 2009-2011 Simen Svale Skogsrud 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "System.h" 8 | 9 | #include 10 | 11 | extern bool soft_limit; 12 | 13 | // Initialize the limits module 14 | void limits_init(); 15 | 16 | // Returns limit state 17 | MotorMask limits_get_state(); 18 | bool limits_startup_check(); 19 | 20 | void limit_error(); 21 | void limit_error(size_t axis, float cordinate); 22 | 23 | float limitsMaxPosition(size_t axis); 24 | float limitsMinPosition(size_t axis); 25 | 26 | // Private 27 | 28 | // Returns limit state under mask 29 | AxisMask limits_check(AxisMask check_mask); 30 | 31 | // A task that runs after a limit switch interrupt. 32 | void limitCheckTask(void* pvParameters); 33 | 34 | bool limitsCheckTravel(float* target); 35 | 36 | // True if an axis is reporting engaged limits on both ends. This 37 | // typically happens when the same pin is used for a pair of switches, 38 | // so you cannot tell which one is triggered. In that case, automatic 39 | // pull-off is impossible. 40 | bool ambiguousLimit(); 41 | -------------------------------------------------------------------------------- /FluidNC/src/Types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef uint32_t MotorMask; // Bits indexed by motor_num*16 + axis 6 | typedef uint16_t AxisMask; // Bits indexed by axis number 7 | typedef uint8_t Percent; // Integer percent 8 | 9 | // System states. The state variable primarily tracks the individual functions 10 | // to manage each without overlapping. It is also used as a messaging flag for 11 | // critical events. 12 | enum class State : uint8_t { 13 | Idle = 0, // Must be zero. 14 | Alarm, // In alarm state. Locks out all g-code processes. Allows settings access. 15 | CheckMode, // G-code check mode. Locks out planner and motion only. 16 | Homing, // Performing homing cycle 17 | Cycle, // Cycle is running or motions are being executed. 18 | Hold, // Active feed hold 19 | Jog, // Jogging mode. 20 | SafetyDoor, // Safety door is ajar. Feed holds and de-energizes system. 21 | Sleep, // Sleep state. 22 | ConfigAlarm, // You can't do anything but fix your config file. 23 | Critical, // You can't do anything but reset with CTRL-x or the reset button 24 | }; 25 | 26 | void set_state(State s); 27 | bool state_is(State s); 28 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/NullSpindle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | /* 5 | This is used when you don't want to use a spindle No I/O will be used 6 | and most methods don't do anything 7 | */ 8 | #include "NullSpindle.h" 9 | 10 | #include "../System.h" // sys.spindle_speed 11 | 12 | #include // IRAM_ATTR 13 | 14 | namespace Spindles { 15 | // ======================= Null ============================== 16 | // Null is just a bunch of do nothing (ignore) methods to be used when you don't want a spindle 17 | 18 | void Null::init() { 19 | is_reversable = false; 20 | config_message(); 21 | _speeds.clear(); 22 | } 23 | void IRAM_ATTR Null::setSpeedfromISR(uint32_t dev_speed) {}; 24 | void Null::setState(SpindleState state, SpindleSpeed speed) { 25 | _current_state = state; 26 | sys.spindle_speed = speed; 27 | } 28 | void Null::config_message() { /*log_info("No spindle");*/ 29 | } 30 | 31 | // Configuration registration 32 | namespace { 33 | SpindleFactory::InstanceBuilder registration("NoSpindle"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /FluidNC/esp32/spi.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "Driver/spi.h" 5 | 6 | #include "driver/spi_common.h" 7 | #include "src/Config.h" 8 | 9 | #include 10 | 11 | #ifdef CONFIG_IDF_TARGET_ESP32S3 12 | # define HSPI_HOST SPI2_HOST 13 | #endif 14 | 15 | bool spi_init_bus(pinnum_t sck_pin, pinnum_t miso_pin, pinnum_t mosi_pin, bool dma) { 16 | // Start the SPI bus with the pins defined here. Once it has been started, 17 | // those pins "stick" and subsequent attempts to restart it with defaults 18 | // for the miso, mosi, and sck pins are ignored 19 | 20 | spi_bus_config_t bus_cfg = { 21 | .mosi_io_num = mosi_pin, 22 | .miso_io_num = miso_pin, 23 | .sclk_io_num = sck_pin, 24 | .quadwp_io_num = -1, 25 | .quadhd_io_num = -1, 26 | .max_transfer_sz = 4000, 27 | }; 28 | 29 | // Depends on the chip variant 30 | return !spi_bus_initialize(HSPI_HOST, &bus_cfg, dma ? SPI_DMA_CH_AUTO : SPI_DMA_DISABLED); 31 | } 32 | 33 | void spi_deinit_bus() { 34 | esp_err_t err = spi_bus_free(HSPI_HOST); 35 | log_debug("deinit spi " << int(err)); 36 | } 37 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/H100Spindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "VFDSpindle.h" 7 | 8 | namespace Spindles { 9 | class H100Spindle : public VFD { 10 | private: 11 | int reg; 12 | 13 | protected: 14 | uint16_t _minFrequency = 0; 15 | uint16_t _maxFrequency = 4000; // H100 works with frequencies scaled by 10. 16 | 17 | void updateRPM(); 18 | 19 | void direction_command(SpindleState mode, ModbusCommand& data) override; 20 | void set_speed_command(uint32_t rpm, ModbusCommand& data) override; 21 | 22 | response_parser initialization_sequence(int index, ModbusCommand& data) override; 23 | response_parser get_status_ok(ModbusCommand& data) override { return nullptr; } 24 | response_parser get_current_speed(ModbusCommand& data) override; 25 | 26 | bool use_delay_settings() const override { return false; } 27 | 28 | // Name of the configurable. Must match the name registered in the cpp file. 29 | const char* name() const override { return "H100"; } 30 | 31 | public: 32 | H100Spindle(); 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/SPIFFS.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "FS.h" 18 | 19 | namespace fs { 20 | 21 | class SPIFFSFS : public FS { 22 | public: 23 | SPIFFSFS(); 24 | ~SPIFFSFS(); 25 | bool begin(bool formatOnFail = false, const char* basePath = "/spiffs", uint8_t maxOpenFiles = 10, const char* partitionLabel = NULL); 26 | bool format(); 27 | size_t totalBytes(); 28 | size_t usedBytes(); 29 | void end(); 30 | 31 | private: 32 | char* partitionLabel_; 33 | }; 34 | 35 | } 36 | 37 | extern fs::SPIFFSFS SPIFFS; 38 | -------------------------------------------------------------------------------- /FluidNC/src/CoolantControl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "Configuration/Configurable.h" 7 | 8 | #include "GCode.h" // CoolantState 9 | 10 | class CoolantControl : public Configuration::Configurable { 11 | Pin _mist; 12 | Pin _flood; 13 | 14 | uint32_t _delay_ms = 0; 15 | 16 | CoolantState _previous_state = {}; 17 | 18 | void write(CoolantState state); 19 | 20 | public: 21 | CoolantControl() = default; 22 | 23 | bool hasMist() const { return _mist.defined(); } 24 | bool hasFlood() const { return _flood.defined(); } 25 | 26 | // Initializes coolant control pins. 27 | void init(); 28 | 29 | // Returns current coolant output state. Overrides may alter it from programmed state. 30 | CoolantState get_state(); 31 | 32 | // Immediately disables coolant pins. 33 | void stop(); 34 | 35 | // Sets the coolant pins according to state specified. 36 | void off(); 37 | void set_state(CoolantState state); 38 | 39 | // Configuration handlers. 40 | void group(Configuration::HandlerBase& handler) override; 41 | 42 | ~CoolantControl() = default; 43 | }; 44 | -------------------------------------------------------------------------------- /libraries/ESP32SSDP/README.rst: -------------------------------------------------------------------------------- 1 | ESP32 Simple Service Discovery Copyright (c) 2015 Hristo Gochkov 2 | Original (Arduino) version by Filippo Sallemi, July 23, 2014. Can be 3 | found at: https://github.com/nomadnt/uSSDP 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /FluidNC/esp32/littlefs.cpp: -------------------------------------------------------------------------------- 1 | #include "esp_partition.h" 2 | #include "esp_littlefs.h" 3 | #include "esp_log.h" 4 | #include "wdt.h" 5 | #include "Driver/localfs.h" 6 | #include "src/Config.h" 7 | 8 | // Remember the partition label of the littlefs filesystem - 9 | // typically littlefs or spiffs - so we can pass it to esp_littlefs_info 10 | const char* littlefs_label; 11 | 12 | bool littlefs_format(const char* partition_label) { 13 | esp_log_level_set("esp_littlefs", ESP_LOG_NONE); 14 | esp_err_t err; 15 | disable_core0_WDT(); 16 | err = esp_littlefs_format(partition_label); 17 | enable_core0_WDT(); 18 | if (err) { 19 | log_debug("LittleFS format in " << partition_label << " partition failed: " << esp_err_to_name(err)); 20 | return true; 21 | } 22 | return false; 23 | } 24 | 25 | bool littlefs_mount(const char* label, bool format) { 26 | esp_log_level_set("esp_littlefs", ESP_LOG_NONE); 27 | esp_vfs_littlefs_conf_t conf = { .base_path = "/littlefs", .partition_label = label, .format_if_mount_failed = format }; 28 | 29 | esp_err_t err = esp_vfs_littlefs_register(&conf); 30 | 31 | if (!err) { 32 | littlefs_label = label; 33 | } 34 | return err; 35 | } 36 | void littlefs_unmount() { 37 | esp_vfs_littlefs_unregister(littlefs_label); 38 | } 39 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/GPIOPinDetail.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "PinDetail.h" 7 | 8 | namespace Pins { 9 | class GPIOPinDetail : public PinDetail { 10 | PinCapabilities _capabilities; 11 | PinAttributes _attributes; 12 | int _readWriteMask; 13 | 14 | static PinCapabilities GetDefaultCapabilities(pinnum_t index); 15 | 16 | static std::vector _claimed; 17 | 18 | bool _lastWrittenValue = false; 19 | 20 | static void gpioAction(int, void*, bool); 21 | 22 | public: 23 | static const int nGPIOPins = 40; 24 | 25 | GPIOPinDetail(pinnum_t index, PinOptionsParser options); 26 | 27 | PinCapabilities capabilities() const override; 28 | 29 | // I/O: 30 | void write(int high) override; 31 | int IRAM_ATTR read() override; 32 | void setAttr(PinAttributes value) override; 33 | PinAttributes getAttr() const override; 34 | 35 | void registerEvent(EventPin* obj) override; 36 | 37 | std::string toString() override; 38 | 39 | ~GPIOPinDetail() override { _claimed[_index] = false; } 40 | }; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /FluidNC/src/FluidPath.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Driver/localfs.h" 7 | 8 | namespace stdfs = std::filesystem; 9 | 10 | class FluidPath : public stdfs::path { 11 | public: 12 | FluidPath(const char* name, const char* fs, std::error_code& ec) noexcept : FluidPath(name, fs, &ec) {} 13 | FluidPath(const std::string& name, const char* fs, std::error_code& ec) noexcept : FluidPath(name.c_str(), fs, &ec) {} 14 | FluidPath(const char* name, const char* fs) : FluidPath(name, fs, nullptr) {} 15 | FluidPath(const std::string& name, const char* fs) : FluidPath(name.c_str(), fs) {} 16 | 17 | ~FluidPath(); 18 | 19 | FluidPath() = default; 20 | 21 | FluidPath(const FluidPath& o); // copy 22 | FluidPath(FluidPath&& o); // move 23 | FluidPath& operator=(const FluidPath& o); // copy assignment 24 | FluidPath& operator=(FluidPath&& o); // move assignment 25 | 26 | // true if there is something after the mount name. 27 | // /localfs/foo -> true, /localfs -> false 28 | bool hasTail() { return ++(++begin()) != end(); } 29 | 30 | private: 31 | FluidPath(const char* name, const char* fs, std::error_code*); 32 | 33 | static int _refcnt; 34 | bool _isSD = false; 35 | }; 36 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/NullSpindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | /* 7 | This is used when you don't want to use a spindle No I/O will be used 8 | and most methods don't do anything 9 | */ 10 | 11 | #include "Spindle.h" 12 | 13 | namespace Spindles { 14 | // This is a dummy spindle that has no I/O. 15 | // It is used to ignore spindle commands when no spindle is desired 16 | class Null : public Spindle { 17 | public: 18 | Null() = default; 19 | 20 | Null(const Null&) = delete; 21 | Null(Null&&) = delete; 22 | Null& operator=(const Null&) = delete; 23 | Null& operator=(Null&&) = delete; 24 | 25 | void init() override; 26 | void setSpeedfromISR(uint32_t dev_speed) override; 27 | void setState(SpindleState state, SpindleSpeed speed) override; 28 | void config_message() override; 29 | 30 | // Configuration handlers: 31 | void group(Configuration::HandlerBase& handler) override {} 32 | 33 | // Name of the configurable. Must match the name registered in the cpp file. 34 | const char* name() const override { return "NoSpindle"; } 35 | 36 | ~Null() {} 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/YL620Spindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Marco Wagner 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "VFDSpindle.h" 7 | 8 | namespace Spindles { 9 | class YL620 : public VFD { 10 | protected: 11 | uint16_t _minFrequency = 0; // frequency lower limit. Factor 10 of actual frequency 12 | uint16_t _maxFrequency = 4000; // max frequency the VFD will allow. Normally 400.0. Factor 10 of actual frequency 13 | 14 | void direction_command(SpindleState mode, ModbusCommand& data) override; 15 | void set_speed_command(uint32_t rpm, ModbusCommand& data) override; 16 | 17 | response_parser initialization_sequence(int index, ModbusCommand& data) override; 18 | response_parser get_current_speed(ModbusCommand& data) override; 19 | response_parser get_current_direction(ModbusCommand& data) override; 20 | response_parser get_status_ok(ModbusCommand& data) override { return nullptr; } 21 | 22 | bool safety_polling() const override { return false; } 23 | 24 | // Name of the configurable. Must match the name registered in the cpp file. 25 | const char* name() const override { return "YL620"; } 26 | 27 | public: 28 | YL620(); 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /fluidterm/fluidterm.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | 3 | 4 | block_cipher = None 5 | 6 | 7 | a = Analysis(['fluidterm.py'], 8 | pathex=[], 9 | binaries=[], 10 | datas=[], 11 | hiddenimports=['pyserial'], 12 | hookspath=[], 13 | hooksconfig={}, 14 | runtime_hooks=[], 15 | excludes=[], 16 | win_no_prefer_redirects=False, 17 | win_private_assemblies=False, 18 | cipher=block_cipher, 19 | noarchive=False) 20 | pyz = PYZ(a.pure, a.zipped_data, 21 | cipher=block_cipher) 22 | 23 | exe = EXE(pyz, 24 | a.scripts, 25 | [], 26 | exclude_binaries=True, 27 | name='fluidterm', 28 | debug=False, 29 | bootloader_ignore_signals=False, 30 | strip=False, 31 | upx=True, 32 | console=True, 33 | disable_windowed_traceback=False, 34 | target_arch=None, 35 | codesign_identity=None, 36 | entitlements_file=None ) 37 | coll = COLLECT(exe, 38 | a.binaries, 39 | a.zipfiles, 40 | a.datas, 41 | strip=False, 42 | upx=True, 43 | upx_exclude=[], 44 | name='fluidterm') 45 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/TelnetServer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Luc Lebosse. All rights reserved. 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Config.h" // ENABLE_* 7 | #include "../Channel.h" 8 | #include 9 | 10 | #ifdef ENABLE_WIFI 11 | 12 | # include "../Settings.h" 13 | 14 | # include 15 | 16 | class TelnetClient; 17 | 18 | namespace WebUI { 19 | class TelnetServer { 20 | static const int DEFAULT_TELNET_STATE = 1; 21 | static const int DEFAULT_TELNETSERVER_PORT = 23; 22 | 23 | static const int MAX_TELNET_PORT = 65001; 24 | static const int MIN_TELNET_PORT = 1; 25 | 26 | static const int MAX_TLNT_CLIENTS = 2; 27 | 28 | static const int FLUSHTIMEOUT = 500; 29 | 30 | public: 31 | TelnetServer(); 32 | 33 | bool begin(); 34 | void end(); 35 | void handle(); 36 | 37 | uint16_t port() { return _port; } 38 | 39 | std::queue _disconnected; 40 | 41 | ~TelnetServer(); 42 | 43 | private: 44 | bool _setupdone = false; 45 | WiFiServer* _wifiServer = nullptr; 46 | uint16_t _port = 0; 47 | }; 48 | 49 | extern TelnetServer telnetServer; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/Parser.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2023 - Dylan Knutson 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "Tokenizer.h" 8 | #include "../Pin.h" 9 | #include "../EnumItem.h" 10 | #include "../UartTypes.h" 11 | #include "HandlerBase.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace Configuration { 18 | class Parser : public Tokenizer { 19 | void parseError(const char* description) const; 20 | 21 | public: 22 | Parser(std::string_view yaml_string); 23 | 24 | bool is(const char* expected); 25 | 26 | std::string_view stringValue() const; 27 | bool boolValue() const; 28 | int intValue() const; 29 | uint32_t uintValue() const; 30 | std::vector speedEntryValue() const; 31 | float floatValue() const; 32 | Pin pinValue() const; 33 | int enumValue(const EnumItem* e) const; 34 | IPAddress ipValue() const; 35 | void uartMode(UartData& wordLength, UartParity& parity, UartStop& stopBits) const; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/Commands.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Luc Lebosse. All rights reserved. 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "Commands.h" 5 | #include // millis() 6 | #include // ESP.restart() 7 | 8 | #include "Authentication.h" // MAX_LOCAL_PASSWORD_LENGTH 9 | #include "../Configuration/JsonGenerator.h" 10 | 11 | #include 12 | #include 13 | 14 | namespace WebUI { 15 | bool COMMANDS::_restart_MCU = false; 16 | 17 | void COMMANDS::send_json_command_response(Channel& out, uint cmdID, bool isok, std::string message) { 18 | JSONencoder j(true, &out); 19 | j.begin(); 20 | j.member("cmd", String(cmdID).c_str()); 21 | j.member("status", isok ? "ok" : "error"); 22 | j.member("data", message); 23 | j.end(); 24 | } 25 | 26 | bool COMMANDS::isJSON(const char* cmd_params) { return strstr(cmd_params, "json=yes") != NULL; } 27 | 28 | /** 29 | * Restart ESP 30 | */ 31 | void COMMANDS::restart_MCU() { _restart_MCU = true; } 32 | 33 | /** 34 | * Handle not critical actions that must be done in sync environement 35 | */ 36 | void COMMANDS::handle() { 37 | if (_restart_MCU) { 38 | ESP.restart(); 39 | while (1) {} 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/Esp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef enum { 6 | ESP_RST_UNKNOWN, //!< Reset reason can not be determined 7 | ESP_RST_POWERON, //!< Reset due to power-on event 8 | ESP_RST_EXT, //!< Reset by external pin (not applicable for ESP32) 9 | ESP_RST_SW, //!< Software reset via esp_restart 10 | ESP_RST_PANIC, //!< Software reset due to exception/panic 11 | ESP_RST_INT_WDT, //!< Reset (software or hardware) due to interrupt watchdog 12 | ESP_RST_TASK_WDT, //!< Reset due to task watchdog 13 | ESP_RST_WDT, //!< Reset due to other watchdogs 14 | ESP_RST_DEEPSLEEP, //!< Reset after exiting deep sleep mode 15 | ESP_RST_BROWNOUT, //!< Brownout reset (software or hardware) 16 | ESP_RST_SDIO, //!< Reset over SDIO 17 | } esp_reset_reason_t; 18 | 19 | esp_reset_reason_t esp_reset_reason(void); 20 | 21 | struct EspClass { 22 | uint64_t getEfuseMac(); 23 | uint32_t getCpuFreqMHz(); 24 | const char* getSdkVersion(); 25 | uint32_t getFreeHeap(); 26 | uint32_t getFlashChipSize(); 27 | 28 | void restart(); 29 | }; 30 | extern EspClass ESP; 31 | 32 | inline long map(long x, long in_min, long in_max, long out_min, long out_max) { 33 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 34 | } 35 | 36 | int temperatureRead(void); 37 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/TMC5160Driver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "TrinamicSpiDriver.h" 7 | #include "../Pin.h" 8 | #include "../PinMapper.h" 9 | 10 | #include 11 | 12 | const float TMC5160_RSENSE_DEFAULT = 0.075f; 13 | 14 | namespace MotorDrivers { 15 | 16 | class TMC5160Driver : public TrinamicSpiDriver { 17 | public: 18 | // Overrides for inherited methods 19 | void init() override; 20 | void set_disable(bool disable); 21 | void config_motor() override; 22 | void debug_message() override; 23 | void validate() override { StandardStepper::validate(); } 24 | 25 | void group(Configuration::HandlerBase& handler) override { 26 | TrinamicSpiDriver::group(handler); 27 | handler.item("tpfd", _tpfd, 0, 15); 28 | } 29 | 30 | // Name of the configurable. Must match the name registered in the cpp file. 31 | const char* name() const override { return "tmc_5160"; } 32 | 33 | private: 34 | TMC5160Stepper* tmc5160 = nullptr; 35 | 36 | uint8_t _tpfd = 4; 37 | 38 | bool test(); 39 | void set_registers(bool isHoming); 40 | void trinamic_test_response(); 41 | void trinamic_stepper_enable(bool enable); 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /FluidNC/esp32/wdt.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "wdt.h" 5 | #include "esp_task_wdt.h" 6 | #include 7 | #include "src/Config.h" 8 | 9 | static TaskHandle_t wdt_task_handle = nullptr; 10 | 11 | static void get_wdt_task_handle() { 12 | TaskHandle_t idle_0 = xTaskGetIdleTaskHandleForCPU(0); 13 | esp_err_t err; 14 | err = esp_task_wdt_status(idle_0); 15 | switch (err) { 16 | case ESP_OK: 17 | wdt_task_handle = idle_0; 18 | break; 19 | case ESP_ERR_NOT_FOUND: 20 | wdt_task_handle = nullptr; 21 | return; 22 | case ESP_ERR_INVALID_STATE: 23 | wdt_task_handle = nullptr; 24 | return; 25 | } 26 | } 27 | 28 | void enable_core0_WDT() { 29 | if (!wdt_task_handle) { 30 | return; 31 | } 32 | esp_err_t err; 33 | if ((err = esp_task_wdt_add(wdt_task_handle)) != ESP_OK) { 34 | log_error("Failed to add Core 0 IDLE task to WDT " << err); 35 | } 36 | } 37 | 38 | void disable_core0_WDT() { 39 | get_wdt_task_handle(); 40 | if (!wdt_task_handle) { 41 | return; 42 | } 43 | esp_err_t err; 44 | if ((err = esp_task_wdt_delete(wdt_task_handle)) != ESP_OK) { 45 | log_error("Failed to remove Core 0 IDLE task from WDT " << err); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /FluidNC/src/Jog.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC 2 | // Copyright (c) 2018 - Bart Dring 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #include "Jog.h" 6 | 7 | #include "Machine/MachineConfig.h" 8 | #include "MotionControl.h" // mc_linear 9 | #include "Stepper.h" // st_prep_buffer, st_wake_up 10 | #include "Limits.h" // constrainToSoftLimits() 11 | 12 | // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog. 13 | // cancelledInflight will be set to true if was not added to parser due to a cancelJog. 14 | Error jog_execute(plan_line_data_t* pl_data, parser_block_t* gc_block, bool* cancelledInflight) { 15 | config->_kinematics->constrain_jog(gc_block->values.xyz, pl_data, gc_state.position); 16 | 17 | // Initialize planner data struct for jogging motions. 18 | // NOTE: Spindle and coolant are allowed to fully function with overrides during a jog. 19 | pl_data->feed_rate = gc_block->values.f; 20 | pl_data->motion.noFeedOverride = 1; 21 | pl_data->is_jog = true; 22 | pl_data->line_number = gc_block->values.n; 23 | 24 | if (!mc_linear(gc_block->values.xyz, pl_data, gc_state.position)) { 25 | return Error::JogCancelled; 26 | } 27 | 28 | // The motion will be initiated by the cycle start mechanism 29 | return Error::Ok; 30 | } 31 | -------------------------------------------------------------------------------- /FluidNC/ld/esp32/vtable_in_dram.ld: -------------------------------------------------------------------------------- 1 | /* List of files and sections to place in RAM instead of FLASH */ 2 | /* See README.md in this directory for a complete explanation */ 3 | 4 | *Laser.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 5 | 6 | /* All files whose name ends with Spindle.cpp */ 7 | **Spindle.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 8 | 9 | /* Motors */ 10 | *Motor.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 11 | *Dynamixel2.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 12 | *MotorDriver.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 13 | *NullMotor.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 14 | *RcServo.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 15 | *Servo.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 16 | *Solenoid.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 17 | *StandardStepper.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 18 | *StepStick.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 19 | *TMC*Driver.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 20 | *TrinamicBase.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 21 | *TrinamicSpiDriver.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 22 | *TrinamicUartDriver.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 23 | *UnipolarMotor.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 24 | 25 | /* Pin Details */ 26 | **Detail.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 27 | *PwmPin.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 28 | *Pin.cpp.o(.rodata .rodata.* .xt.prop .xt.prop.*) 29 | -------------------------------------------------------------------------------- /FluidNC/src/Logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "Config.h" 5 | #include "Protocol.h" 6 | #include "Serial.h" 7 | #include "SettingsDefinitions.h" 8 | #include "Channel.h" 9 | 10 | const EnumItem messageLevels2[] = { { MsgLevelNone, "None" }, { MsgLevelError, "Error" }, { MsgLevelWarning, "Warn" }, 11 | { MsgLevelInfo, "Info" }, { MsgLevelDebug, "Debug" }, { MsgLevelVerbose, "Verbose" }, 12 | EnumItem(MsgLevelNone) }; 13 | 14 | bool atMsgLevel(MsgLevel level) { 15 | return message_level == nullptr || message_level->get() >= level; 16 | } 17 | 18 | LogStream::LogStream(Channel& channel, MsgLevel level) : _channel(channel), _level(level) { 19 | _line = new std::string(); 20 | } 21 | 22 | LogStream::LogStream(Channel& channel, MsgLevel level, const char* name) : LogStream(channel, level) { 23 | print(name); 24 | } 25 | 26 | LogStream::LogStream(Channel& channel, const char* name) : LogStream(channel, MsgLevelNone, name) {} 27 | LogStream::LogStream(MsgLevel level, const char* name) : LogStream(allChannels, level, name) {} 28 | 29 | size_t LogStream::write(uint8_t c) { 30 | *_line += (char)c; 31 | return 1; 32 | } 33 | 34 | LogStream::~LogStream() { 35 | if ((*_line).length() && (*_line)[0] == '[') { 36 | *_line += ']'; 37 | } 38 | _channel.sendLine(_level, _line); 39 | } 40 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with this library; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | 17 | #ifndef Printable_h 18 | #define Printable_h 19 | 20 | #include 21 | 22 | class Print; 23 | 24 | /** The Printable class provides a way for new classes to allow themselves to be printed. 25 | By deriving from Printable and implementing the printTo method, it will then be possible 26 | for users to print out instances of this class by passing them into the usual 27 | Print::print and Print::println methods. 28 | */ 29 | 30 | class Printable { 31 | public: 32 | virtual ~Printable() {} 33 | virtual size_t printTo(Print& p) const = 0; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/TrinamicUartDriver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Copyright (c) 2020 - The Ant Team 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "TrinamicBase.h" 8 | #include "../Pin.h" 9 | #include "../Uart.h" 10 | 11 | #include 12 | 13 | namespace MotorDrivers { 14 | 15 | class TrinamicUartDriver : public TrinamicBase { 16 | public: 17 | TrinamicUartDriver() = default; 18 | 19 | void init() override; 20 | 21 | uint8_t _addr; 22 | 23 | // Configuration handlers: 24 | void validate() override { StandardStepper::validate(); } 25 | 26 | void afterParse() override { 27 | StandardStepper::validate(); 28 | Assert(_uart_num != -1, "TrinamicUartDriver must set uart_num: "); 29 | } 30 | 31 | void group(Configuration::HandlerBase& handler) override { 32 | handler.item("addr", _addr); 33 | handler.item("cs_pin", _cs_pin); 34 | handler.item("uart_num", _uart_num); 35 | 36 | TrinamicBase::group(handler); 37 | } 38 | 39 | protected: 40 | Uart* _uart = nullptr; 41 | 42 | Pin _cs_pin; 43 | 44 | int _uart_num = -1; 45 | 46 | static bool _uart_started; 47 | void config_message() override; 48 | 49 | uint8_t toffValue(); // TO DO move to Base? 50 | 51 | private: 52 | 53 | }; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/HuanyangSpindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Copyright (c) 2020 - Stefan de Bruijn 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "VFDSpindle.h" 8 | 9 | namespace Spindles { 10 | class Huanyang : public VFD { 11 | private: 12 | int reg; 13 | 14 | protected: 15 | uint16_t _minFrequency = 0; // PD011: frequency lower limit. Normally 0. 16 | uint16_t _maxFrequency = 400; // PD005: max frequency the VFD will allow. Normally 400. 17 | uint16_t _maxRpmAt50Hz = 100; // PD144: rated motor revolution at 50Hz => 24000@400Hz = 3000@50HZ 18 | uint16_t _numberPoles = 2; // PD143: 4 or 2 poles in motor. Default is 4. A spindle being 24000RPM@400Hz implies 2 poles 19 | 20 | void updateRPM(); 21 | 22 | void direction_command(SpindleState mode, ModbusCommand& data) override; 23 | void set_speed_command(uint32_t rpm, ModbusCommand& data) override; 24 | 25 | response_parser initialization_sequence(int index, ModbusCommand& data) override; 26 | response_parser get_status_ok(ModbusCommand& data) override; 27 | response_parser get_current_speed(ModbusCommand& data) override; 28 | 29 | // Name of the configurable. Must match the name registered in the cpp file. 30 | const char* name() const override { return "Huanyang"; } 31 | 32 | public: 33 | Huanyang(); 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/DacSpindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | /* 7 | DacSpindle.h 8 | 9 | This uses the Analog DAC in the ESP32 to generate a voltage 10 | proportional to the GCode S value desired. Some spindle uses 11 | a 0-5V or 0-10V value to control the spindle. You would use 12 | an Op Amp type circuit to get from the 0.3.3V of the ESP32 to that voltage. 13 | */ 14 | 15 | #include "OnOffSpindle.h" 16 | 17 | #include 18 | 19 | namespace Spindles { 20 | // This uses one of the (2) DAC pins on ESP32 to output a voltage 21 | class Dac : public OnOff { 22 | public: 23 | Dac() = default; 24 | 25 | Dac(const Dac&) = delete; 26 | Dac(Dac&&) = delete; 27 | Dac& operator=(const Dac&) = delete; 28 | Dac& operator=(Dac&&) = delete; 29 | 30 | void init() override; 31 | void config_message() override; 32 | void setSpeedfromISR(uint32_t dev_speed) override; 33 | 34 | // Configuration handlers: 35 | // Inherited from PWM 36 | 37 | // Name of the configurable. Must match the name registered in the cpp file. 38 | const char* name() const override { return "DAC"; } 39 | 40 | ~Dac() {} 41 | 42 | private: 43 | bool _gpio_ok; // DAC is on a valid pin 44 | 45 | protected: 46 | void set_output(uint32_t duty); // sets DAC instead of PWM 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /libraries/ESP32SSDP/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Ultrasound 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ESP8266SSDP KEYWORD1 10 | SSDP KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | 16 | begin KEYWORD2 17 | schema KEYWORD2 18 | setName KEYWORD2 19 | setURL KEYWORD2 20 | setHTTPPort KEYWORD2 21 | setSchemaURL KEYWORD2 22 | setSerialNumber KEYWORD2 23 | setModelName KEYWORD2 24 | setModelNumber KEYWORD2 25 | setModelURL KEYWORD2 26 | setManufacturer KEYWORD2 27 | setManufacturerURL KEYWORD2 28 | 29 | ####################################### 30 | # Constants (LITERAL1) 31 | ####################################### 32 | SSDP_INTERVAL LITERAL1 33 | SSDP_PORT LITERAL1 34 | SSDP_METHOD_SIZE LITERAL1 35 | SSDP_URI_SIZE LITERAL1 36 | SSDP_BUFFER_SIZE LITERAL1 37 | SSDP_BASE_SIZE LITERAL1 38 | SSDP_FRIENDLY_NAME_SIZE LITERAL1 39 | SSDP_SERIAL_NUMBER_SIZE LITERAL1 40 | SSDP_PRESENTATION_URL_SIZE LITERAL1 41 | SSDP_MODEL_NAME_SIZE LITERAL1 42 | SSDP_MODEL_URL_SIZE LITERAL1 43 | SSDP_MODEL_VERSION_SIZE LITERAL1 44 | SSDP_MANUFACTURER_SIZE LITERAL1 45 | SSDP_MANUFACTURER_URL_SIZE LITERAL1 46 | SEARCH LITERAL1 47 | NOTIFY LITERAL1 48 | BASIC LITERAL1 49 | MANAGEABLE LITERAL1 50 | SOLARPROTECTIONBLIND LITERAL1 51 | DIGITALSECURITYCAMERA LITERAL1 52 | HVAC LITERAL1 53 | LIGHTINGCONTROL LITERAL1 54 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/DebugPinDetail.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "PinDetail.h" 7 | 8 | namespace Pins { 9 | class DebugPinDetail : public PinDetail { 10 | PinDetail* _implementation; 11 | 12 | uint32_t _lastEvent; 13 | int _eventCount; 14 | bool _isHigh; 15 | 16 | struct CallbackHandler { 17 | void (*callback)(void* arg); 18 | void* argument; 19 | DebugPinDetail* _myPin; 20 | 21 | static void handle(void* arg); 22 | } _isrHandler; 23 | 24 | friend void CallbackHandler::handle(void* arg); 25 | 26 | bool shouldEvent(); 27 | 28 | public: 29 | DebugPinDetail(PinDetail* implementation) : 30 | PinDetail(implementation->number()), _implementation(implementation), _lastEvent(0), _eventCount(0), _isHigh(false), 31 | _isrHandler({ 0 }) {} 32 | 33 | PinCapabilities capabilities() const override { return _implementation->capabilities(); } 34 | 35 | // I/O: 36 | void write(int high) override; 37 | int read() override; 38 | void setAttr(PinAttributes value) override; 39 | PinAttributes getAttr() const override; 40 | 41 | std::string toString() override { return _implementation->toString(); } 42 | 43 | ~DebugPinDetail() override {} 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/PinDetail.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "PinCapabilities.h" 7 | #include "PinAttributes.h" 8 | #include "PinOptionsParser.h" 9 | #include "src/Machine/EventPin.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | typedef uint8_t pinnum_t; 17 | 18 | namespace Pins { 19 | 20 | // Implementation details of pins. 21 | class PinDetail { 22 | protected: 23 | public: 24 | int _index; 25 | 26 | PinDetail(int number) : _index(number) {} 27 | PinDetail(const PinDetail& o) = delete; 28 | PinDetail(PinDetail&& o) = delete; 29 | PinDetail& operator=(const PinDetail& o) = delete; 30 | PinDetail& operator=(PinDetail&& o) = delete; 31 | 32 | virtual PinCapabilities capabilities() const = 0; 33 | 34 | // I/O: 35 | virtual void write(int high) = 0; 36 | virtual void synchronousWrite(int high); 37 | virtual int read() = 0; 38 | virtual void setAttr(PinAttributes value) = 0; 39 | virtual PinAttributes getAttr() const = 0; 40 | 41 | virtual void registerEvent(EventPin* obj); 42 | 43 | virtual std::string toString() = 0; 44 | 45 | inline int number() const { return _index; } 46 | 47 | virtual ~PinDetail() {} 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /FluidNC/stdfs/fluidnc_vfs_ops.cpp: -------------------------------------------------------------------------------- 1 | #include "fluidnc_vfs_ops.h" 2 | #include 3 | #include "src/Config.h" 4 | 5 | #include "esp_spiffs.h" 6 | #include "ff.h" 7 | #include "esp_littlefs.h" 8 | #include "Driver/littlefs.h" 9 | 10 | bool isSPIFFS(const char* mountpoint) { 11 | return !strcmp(mountpoint, "spiffs"); 12 | } 13 | bool isSD(const char* mountpoint) { 14 | return !strcmp(mountpoint, "sd"); 15 | } 16 | bool isLittleFS(const char* mountpoint) { 17 | return !strcmp(mountpoint, "littlefs"); 18 | } 19 | bool fluidnc_vfs_stats(const char* mountpoint, uint64_t& total, uint64_t& used) { 20 | if (isSD(mountpoint)) { 21 | FATFS* fsinfo; 22 | DWORD fre_clust; 23 | if (f_getfree("0:", &fre_clust, &fsinfo) != 0) { 24 | return false; 25 | } 26 | uint64_t clsize = fsinfo->csize * fsinfo->ssize; 27 | uint32_t total_cl = fsinfo->n_fatent - 2; 28 | 29 | total = clsize * total_cl; 30 | used = clsize * (total_cl - fsinfo->free_clst); 31 | return true; 32 | } 33 | size_t stotal, sused; 34 | 35 | if (isSPIFFS(mountpoint)) { 36 | esp_err_t err; 37 | if ((err = esp_spiffs_info("spiffs", &stotal, &sused)) != ESP_OK) { 38 | return false; 39 | } 40 | } else if (isLittleFS(mountpoint)) { 41 | if (esp_littlefs_info(littlefs_label, &stotal, &sused)) { 42 | return false; 43 | } 44 | } else { 45 | return false; 46 | } 47 | total = stotal; 48 | used = sused; 49 | return true; 50 | } 51 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/LimitPin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "EventPin.h" 4 | 5 | namespace Machine { 6 | class LimitPin : public EventPin { 7 | private: 8 | bool _value = 0; 9 | uint32_t _bitmask = 0; 10 | 11 | // _pHardLimits is a reference so the shared variable at the 12 | // Endstops level can be changed at runtime to control the 13 | // limit behavior dynamically. 14 | bool& _pHardLimits; 15 | 16 | // _pLimited is a reference to the _limited member of 17 | // the Motor class. Setting it when the Limit ISR fires 18 | // lets the motor driver respond rapidly to a limit switch 19 | // touch, increasing the accuracy of homing 20 | // _pExtraLimited lets the limit control two motors, as with 21 | // CoreXY 22 | volatile bool& _pLimited; 23 | volatile bool* _pExtraLimited = nullptr; 24 | 25 | volatile uint32_t* _posLimits = nullptr; 26 | volatile uint32_t* _negLimits = nullptr; 27 | 28 | Pin* _pin; 29 | 30 | public: 31 | LimitPin(Pin& pin, int axis, int motorNum, int direction, bool& phardLimits, bool& pLimited); 32 | 33 | void update(bool value) override; 34 | 35 | void init(); 36 | void makeDualMask(); // makes this a mask for motor0 and motor1 37 | void setExtraMotorLimit(int axis, int motorNum); 38 | 39 | bool isHard() { return _pHardLimits; } 40 | 41 | bool get() { return _pin->read(); } 42 | 43 | int _axis; 44 | int _motorNum; 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/TMC2208Driver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "TrinamicUartDriver.h" 7 | #include "../Pin.h" 8 | #include "../PinMapper.h" 9 | 10 | #include 11 | 12 | const float TMC2208_RSENSE_DEFAULT = 0.11f; 13 | 14 | namespace MotorDrivers { 15 | 16 | class TMC2208Driver : public TrinamicUartDriver { 17 | public: 18 | // Overrides for inherited methods 19 | void init() override; 20 | void set_disable(bool disable); 21 | void config_motor() override; 22 | void debug_message() override; 23 | void validate() override { StandardStepper::validate(); } 24 | 25 | void group(Configuration::HandlerBase& handler) override { 26 | TrinamicUartDriver::group(handler); 27 | handler.item("run_mode", _run_mode, trinamicModes); 28 | handler.item("homing_mode", _homing_mode, trinamicModes); 29 | handler.item("stallguard", _stallguard, -64, 63); 30 | handler.item("stallguard_debug", _stallguardDebugMode); 31 | handler.item("toff_coolstep", _toff_coolstep, 2, 15); 32 | } 33 | 34 | // Name of the configurable. Must match the name registered in the cpp file. 35 | const char* name() const override { return "tmc_2208"; } 36 | 37 | private: 38 | TMC2208Stepper* tmc2208 = nullptr; 39 | 40 | bool test(); 41 | void set_registers(bool isHoming); 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/Tokenizer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2023 - Dylan Knutson 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "TokenState.h" 8 | #include "../Config.h" 9 | #include 10 | 11 | namespace Configuration { 12 | 13 | class Tokenizer { 14 | std::string_view _remainder; 15 | 16 | bool isWhiteSpace(char c); 17 | bool isIdentifierChar(char c); 18 | bool nextLine(); 19 | void parseKey(); 20 | void parseValue(); 21 | 22 | public: 23 | int _linenum; 24 | std::string_view _line; 25 | 26 | // Results: 27 | struct TokenData { 28 | // The initial value for indent is -1, so when ParserHandler::enterSection() 29 | // is called to handle the top level of the YAML config file, tokens at 30 | // indent 0 will be processed. 31 | TokenData() : _key({}), _value({}), _indent(-1), _state(TokenState::Bof) {} 32 | std::string_view _key; 33 | std::string_view _value; 34 | int _indent; 35 | 36 | TokenState _state = TokenState::Bof; 37 | } _token; 38 | 39 | void ParseError(const char* description) const; 40 | 41 | public: 42 | Tokenizer(std::string_view yaml_string); 43 | void Tokenize(); 44 | inline std::string_view key() const { return _token._key; } 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /libraries/ESP32SSDP/examples/SSDP/SSDP.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | const char* ssid = "********"; 6 | const char* password = "********"; 7 | 8 | WebServer HTTP(80); 9 | 10 | void setup() { 11 | Serial.begin(115200); 12 | Serial.println(); 13 | Serial.println("Starting WiFi..."); 14 | 15 | WiFi.mode(WIFI_STA); 16 | WiFi.begin(ssid, password); 17 | if(WiFi.waitForConnectResult() == WL_CONNECTED){ 18 | 19 | Serial.printf("Starting HTTP...\n"); 20 | HTTP.on("/index.html", HTTP_GET, [](){ 21 | HTTP.send(200, "text/plain", "Hello World!"); 22 | }); 23 | HTTP.on("/description.xml", HTTP_GET, [](){ 24 | SSDP.schema(HTTP.client()); 25 | }); 26 | HTTP.begin(); 27 | 28 | Serial.printf("Starting SSDP...\n"); 29 | SSDP.setSchemaURL("description.xml"); 30 | SSDP.setHTTPPort(80); 31 | SSDP.setName("Philips hue clone"); 32 | SSDP.setSerialNumber("001788102201"); 33 | SSDP.setURL("index.html"); 34 | SSDP.setModelName("Philips hue bridge 2012"); 35 | SSDP.setModelNumber("929000226503"); 36 | SSDP.setModelURL("http://www.meethue.com"); 37 | SSDP.setManufacturer("Royal Philips Electronics"); 38 | SSDP.setManufacturerURL("http://www.philips.com"); 39 | SSDP.setDeviceType("upnp:rootdevice"); //to appear as root device 40 | SSDP.begin(); 41 | 42 | Serial.printf("Ready!\n"); 43 | } else { 44 | Serial.printf("WiFi Failed\n"); 45 | while(1) delay(100); 46 | } 47 | } 48 | 49 | void loop() { 50 | HTTP.handleClient(); 51 | delay(1); 52 | } 53 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/Laser.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | /* 5 | This is similar to the PWM Spindle except that it enables the 6 | M4 speed vs. power compensation. 7 | */ 8 | 9 | #include "Laser.h" 10 | #include "Driver/PwmPin.h" // pwmInit(), etc. 11 | 12 | #include "../Machine/MachineConfig.h" 13 | 14 | // ===================================== Laser ============================================== 15 | 16 | namespace Spindles { 17 | bool Laser::isRateAdjusted() { 18 | return true; // can use M4 (CCW) laser mode. 19 | } 20 | 21 | void Laser::config_message() { 22 | log_info(name() << " Ena:" << _enable_pin.name() << " Out:" << _output_pin.name() << " Freq:" << _pwm->frequency() 23 | << "Hz Period:" << _pwm->period()); 24 | } 25 | 26 | void Laser::init() { 27 | if (_speeds.size() == 0) { 28 | // The default speed map for a Laser is linear from 0=0% to 255=100% 29 | linearSpeeds(255, 100.0f); 30 | } 31 | // A speed map is now present and PWM::init() will not set its own default 32 | 33 | PWM::init(); 34 | 35 | // Turn off is_reversable regardless of what PWM::init() thinks. 36 | // Laser mode uses M4 for speed-dependent power instead of CCW rotation. 37 | is_reversable = false; 38 | } 39 | 40 | // Configuration registration 41 | namespace { 42 | SpindleFactory::InstanceBuilder registration("Laser"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FluidNC/src/Pins/ErrorPinDetail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "ErrorPinDetail.h" 5 | #include "../Config.h" 6 | #include "../Assert.h" 7 | 8 | namespace Pins { 9 | ErrorPinDetail::ErrorPinDetail(std::string_view descr) : PinDetail(0), _description(descr) {} 10 | 11 | PinCapabilities ErrorPinDetail::capabilities() const { return PinCapabilities::Error; } 12 | 13 | #ifdef ESP32 14 | void ErrorPinDetail::write(int high) { log_error("Cannot write to pin " << _description.c_str() << ". The config is incorrect."); } 15 | int ErrorPinDetail::read() { 16 | log_error("Cannot read from pin " << _description.c_str() << ". The config is incorrect."); 17 | return false; 18 | } 19 | void ErrorPinDetail::setAttr(PinAttributes value) { 20 | log_error("Cannot set mode on pin " << _description.c_str() << ". The config is incorrect."); 21 | } 22 | 23 | #else 24 | void ErrorPinDetail::write(int high) { Assert(false, "Cannot write to an error pin."); } 25 | int ErrorPinDetail::read() { 26 | Assert(false, "Cannot read from an error pin."); 27 | return false; 28 | } 29 | void ErrorPinDetail::setAttr(PinAttributes value) { /* Fine, this won't get you anywhere. */ 30 | } 31 | 32 | #endif 33 | 34 | PinAttributes ErrorPinDetail::getAttr() const { return PinAttributes::None; } 35 | 36 | std::string ErrorPinDetail::toString() { 37 | std::string s("ERROR_PIN (for "); 38 | return s + _description + ")"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/Laser.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | /* 7 | This is similar to the PWM Spindle except that it enables the 8 | M4 speed vs. power copensation. 9 | */ 10 | 11 | #include "PWMSpindle.h" 12 | 13 | #include 14 | 15 | namespace Spindles { 16 | // this is the same as a PWM spindle but the M4 compensation is supported. 17 | class Laser : public PWM { 18 | public: 19 | Laser() = default; 20 | 21 | Laser(const Laser&) = delete; 22 | Laser(Laser&&) = delete; 23 | Laser& operator=(const Laser&) = delete; 24 | Laser& operator=(Laser&&) = delete; 25 | 26 | bool isRateAdjusted() override; 27 | void config_message() override; 28 | void init() override; 29 | void set_direction(bool Clockwise) override {}; 30 | bool use_delay_settings() const override { return false; } 31 | // Name of the configurable. Must match the name registered in the cpp file. 32 | const char* name() const override { return "Laser"; } 33 | 34 | void group(Configuration::HandlerBase& handler) override { 35 | // pwm_freq is the only item that the PWM class adds to OnOff 36 | // We cannot call PWM::group() because that would pick up 37 | // direction_pin, which we do not want in Laser 38 | handler.item("pwm_hz", _pwm_freq, 1000, 100000); 39 | OnOff::groupCommon(handler); 40 | } 41 | 42 | ~Laser() {} 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /embedded/build.py: -------------------------------------------------------------------------------- 1 | # Creates a NoFile.h include file that contains the embedded 2 | # web page that is used when index.html.gz is missing 3 | # NoFile.h is created from the code in /embedded 4 | 5 | import subprocess, sys 6 | 7 | header = """// Embedded web page to load the index,html.gz for ESP3D-WEBUI. 8 | // Generated from the code in /embedded/ . Do not edit manually. 9 | 10 | // Copyright (c) 2014 Luc Lebosse. All rights reserved. 11 | // License: GPL version 2.1 or (at your option) any later version. 12 | 13 | #pragma once 14 | // clang-format off 15 | 16 | """ 17 | 18 | footer = "" 19 | 20 | def bin2header(data, var_name='var'): 21 | out = [] 22 | out.append('const char {var_name}[] = {{'.format(var_name=var_name)) 23 | l = [ data[i:i+16] for i in range(0, len(data), 16) ] 24 | for i, x in enumerate(l): 25 | line = ', '.join([ '0x{val:02X}'.format(val=c) for c in x ]) 26 | out.append(' {line}{end_comma}'.format(line=line, end_comma=',' if i 11 | 12 | const float TMC2209_RSENSE_DEFAULT = 0.11f; 13 | 14 | namespace MotorDrivers { 15 | 16 | class TMC2209Driver : public TrinamicUartDriver { 17 | public: 18 | // Overrides for inherited methods 19 | void init() override; 20 | void set_disable(bool disable); 21 | void config_motor() override; 22 | void debug_message() override; 23 | void validate() override { StandardStepper::validate(); } 24 | 25 | void group(Configuration::HandlerBase& handler) override { 26 | TrinamicUartDriver::group(handler); 27 | 28 | handler.item("run_mode", _run_mode, trinamicModes); 29 | handler.item("homing_mode", _homing_mode, trinamicModes); 30 | handler.item("homing_amps", _homing_current, 0.5, 10.0); 31 | handler.item("stallguard", _stallguard, 0, 255); 32 | handler.item("stallguard_debug", _stallguardDebugMode); 33 | handler.item("toff_coolstep", _toff_coolstep, 2, 15); 34 | } 35 | 36 | // Name of the configurable. Must match the name registered in the cpp file. 37 | const char* name() const override { return "tmc_2209"; } 38 | 39 | private: 40 | TMC2209Stepper* tmc2209 = nullptr; 41 | 42 | bool test(); 43 | void set_registers(bool isHoming); 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/TelnetClient.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Config.h" // ENABLE_* 7 | #include "../Channel.h" 8 | 9 | #ifdef ENABLE_WIFI 10 | # include 11 | 12 | namespace WebUI { 13 | class TelnetClient : public Channel { 14 | WiFiClient* _wifiClient; 15 | 16 | // The default value of the rx buffer in WiFiClient.cpp is 1436 which is 17 | // related to the network frame size minus TCP/IP header sizes. 18 | // The WiFiClient API has no way to override or query it. 19 | // We use a smaller value for safety. There is little advantage 20 | // to sending too many GCode lines at once, especially since the 21 | // common serial communication case is typically limited to 128 bytes. 22 | static const int WIFI_CLIENT_READ_BUFFER_SIZE = 1200; 23 | 24 | static const int DISCONNECT_CHECK_COUNTS = 1000; 25 | 26 | int _state = 0; 27 | 28 | public: 29 | TelnetClient(WiFiClient* wifiClient); 30 | 31 | int rx_buffer_available() override; 32 | size_t write(uint8_t data) override; 33 | size_t write(const uint8_t* buffer, size_t size) override; 34 | int read(void) override; 35 | int peek(void) override; 36 | int available() override; 37 | void flush() override {} 38 | void flushRx() override; 39 | 40 | void closeOnDisconnect(); 41 | 42 | void handle() override; 43 | 44 | ~TelnetClient(); 45 | }; 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /FluidNC/src/Stepper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 2 | // Copyright (c) 2009-2011 Simen Svale Skogsrud 3 | // Copyright (c) 2018 - Bart Dring 4 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 5 | 6 | #pragma once 7 | 8 | /* 9 | Stepper.h - stepper motor driver: executes motion plans of planner.c using the stepper motors 10 | */ 11 | 12 | #include "EnumItem.h" 13 | 14 | #include 15 | 16 | namespace Stepper { 17 | void init(); 18 | 19 | bool pulse_func(); 20 | 21 | // Enable steppers, but cycle does not start unless called by motion control or realtime command. 22 | void wake_up(); 23 | 24 | // Stops stepping and disables stepper (not ISR-safe) 25 | void go_idle(); 26 | 27 | // Stops stepping (ISR-safe) 28 | void stop_stepping(); 29 | 30 | // Reset the stepper subsystem variables 31 | void reset(); 32 | 33 | // Changes the run state of the step segment buffer to execute the special parking motion. 34 | void parking_setup_buffer(); 35 | 36 | // Restores the step segment buffer to the normal run state after a parking motion. 37 | void parking_restore_buffer(); 38 | 39 | // Reloads step segment buffer. Called continuously by realtime execution system. 40 | void prep_buffer(); 41 | 42 | // Called by planner_recalculate() when the executing block is updated by the new plan. 43 | bool update_plan_block_parameters(); 44 | 45 | // Called by realtime status reporting if realtime rate reporting is enabled in config.h. 46 | float get_realtime_rate(); 47 | 48 | extern uint32_t isr_count; 49 | } 50 | -------------------------------------------------------------------------------- /FluidNC/src/Machine/Axis.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Copyright (c) 2021 - Mitch Bradley 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "../Configuration/Configurable.h" 8 | // #include "Axes.h" 9 | #include "Motor.h" 10 | #include "Homing.h" 11 | 12 | namespace MotorDrivers { 13 | class MotorDriver; 14 | } 15 | 16 | namespace Machine { 17 | class Axis : public Configuration::Configurable { 18 | int _axis; 19 | int motorsWithSwitches(); 20 | 21 | public: 22 | Axis(int currentAxis) : _axis(currentAxis) { 23 | for (int i = 0; i < MAX_MOTORS_PER_AXIS; ++i) { 24 | _motors[i] = nullptr; 25 | } 26 | } 27 | 28 | static const int MAX_MOTORS_PER_AXIS = 2; 29 | 30 | Motor* _motors[MAX_MOTORS_PER_AXIS]; 31 | Homing* _homing = nullptr; 32 | 33 | float _stepsPerMm = 80.0f; 34 | float _maxRate = 1000.0f; 35 | float _acceleration = 25.0f; 36 | float _maxTravel = 1000.0f; 37 | bool _softLimits = false; 38 | 39 | // Configuration system helpers: 40 | void group(Configuration::HandlerBase& handler) override; 41 | void afterParse() override; 42 | 43 | // Checks if a motor matches this axis: 44 | bool hasMotor(const MotorDrivers::MotorDriver* const driver) const; 45 | bool hasDualMotor(); 46 | 47 | float commonPulloff(); 48 | float extraPulloff(); 49 | 50 | void init(); 51 | void config_motors(); 52 | 53 | ~Axis(); 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/WebClient.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Config.h" // ENABLE_* 7 | #include "../Channel.h" 8 | 9 | #ifdef ENABLE_WIFI 10 | class WebServer; 11 | 12 | namespace WebUI { 13 | class WebClient : public Channel { 14 | public: 15 | WebClient(); 16 | ~WebClient(); 17 | 18 | void attachWS(WebServer* webserver, bool silent); 19 | void detachWS(); 20 | 21 | size_t write(uint8_t data) override; 22 | size_t write(const uint8_t* buffer, size_t length) override; 23 | void flush(); 24 | 25 | void sendLine(MsgLevel level, const char* line) override; 26 | void sendLine(MsgLevel level, const std::string* line) override; 27 | void sendLine(MsgLevel level, const std::string& line) override; 28 | 29 | void sendError(int code, const std::string& line); 30 | 31 | bool anyOutput() { return _header_sent; } 32 | 33 | void out(const char* s, const char* tag) override; 34 | void out(const std::string& s, const char* tag) override; 35 | void out_acked(const std::string& s, const char* tag) override; 36 | 37 | private: 38 | bool _header_sent = false; 39 | bool _silent = false; 40 | WebServer* _webserver = nullptr; 41 | static const size_t BUFLEN = 1200; 42 | char _buffer[BUFLEN]; 43 | size_t _buflen = 0; 44 | }; 45 | 46 | extern WebClient webClient; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/TrinamicUartDriver.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Copyright (c) 2020 - The Ant Team 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | /* 6 | This is used for Trinamic UART controlled stepper motor drivers. 7 | 8 | TMC2209 Datasheet 9 | https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2209_Datasheet_V103.pdf 10 | */ 11 | 12 | #include "TrinamicUartDriver.h" 13 | 14 | #include "../Machine/MachineConfig.h" 15 | #include "../Uart.h" 16 | 17 | #include // https://github.com/teemuatlut/TMCStepper 18 | #include 19 | 20 | namespace MotorDrivers { 21 | 22 | void TrinamicUartDriver::init() { 23 | _uart = config->_uarts[_uart_num]; 24 | Assert(_uart, "TMC Driver missing uart%d section", _uart_num); 25 | 26 | _cs_pin.setAttr(Pin::Attr::Output); 27 | } 28 | 29 | /* 30 | This is the startup message showing the basic definition. 31 | 32 | log_info(" UART CS:" << ); 33 | */ 34 | void TrinamicUartDriver::config_message() { //TODO: The RX/TX pin could be added to the msg. 35 | log_info(" " << name() << " UART" << _uart_num << " Addr:" << _addr << " CS:" << _cs_pin.name() << " Step:" << _step_pin.name() 36 | << " Dir:" << _dir_pin.name() << " Disable:" << _disable_pin.name() << " R:" << _r_sense); 37 | } 38 | 39 | uint8_t TrinamicUartDriver::toffValue() { 40 | if (_disabled) { 41 | return _toff_disable; 42 | } 43 | return _mode == TrinamicMode::StealthChop ? _toff_stealthchop : _toff_coolstep; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/Authentication.cpp: -------------------------------------------------------------------------------- 1 | #include "Authentication.h" 2 | 3 | #include "../Config.h" // ENABLE_* 4 | 5 | #include 6 | 7 | namespace WebUI { 8 | #ifdef ENABLE_AUTHENTICATION 9 | // TODO Settings - need ADMIN_ONLY and if it is called without a parameter it sets the default 10 | AuthPasswordSetting* user_password; 11 | AuthPassowrdSetting* admin_password; 12 | 13 | void remove_password(char* str, AuthenticationLevel& auth_level) { 14 | std::string paramStr(str); 15 | size_t pos = paramStr.find("pwd="); 16 | if (pos == std::string::npos) { 17 | return; 18 | } 19 | 20 | // Truncate the str string at the pwd= . 21 | // If the pwd= is preceded by a space, take off that space too. 22 | int endpos = pos; 23 | if (endpos && str[endpos - 1] == ' ') { 24 | --endpos; 25 | } 26 | str[endpos] = '\0'; 27 | 28 | // Upgrade the authentication level if a password 29 | // for a higher level is present. 30 | const char* password = str + pos + strlen("pwd="); 31 | if (auth_level < AuthenticationLevel::LEVEL_USER) { 32 | if (!strcmp(password, user_password->get())) { 33 | auth_level = AuthenticationLevel::LEVEL_USER; 34 | } 35 | } 36 | if (auth_level < AuthenticationLevel::LEVEL_ADMIN) { 37 | if (!strcmp(password, admin_password->get())) { 38 | auth_level = AuthenticationLevel::LEVEL_ADMIN; 39 | } 40 | } 41 | } 42 | #else 43 | void remove_password(char* str, AuthenticationLevel& auth_level) { auth_level = AuthenticationLevel::LEVEL_ADMIN; } 44 | #endif 45 | } 46 | -------------------------------------------------------------------------------- /FluidNC/esp32/StartupLog.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #include "src/StartupLog.h" 5 | #include "src/Protocol.h" // send_line() 6 | #include 7 | 8 | // The startup log is stored in RTC RAM that is preserved across 9 | // resets. That lets us show the previous startup log if the 10 | // system panics and resets. 11 | 12 | // The size is limited by the size of RTC RAM minus system usage thereof 13 | static const size_t _maxlen = 7000; 14 | static RTC_NOINIT_ATTR char _messages[_maxlen]; 15 | static RTC_NOINIT_ATTR size_t _len; 16 | static bool _paniced; 17 | 18 | void StartupLog::init() { 19 | if (esp_reset_reason() == ESP_RST_PANIC) { 20 | _paniced = true; 21 | } else { 22 | _paniced = false; 23 | _len = 0; 24 | } 25 | } 26 | size_t StartupLog::write(uint8_t data) { 27 | if (_paniced || _len >= _maxlen) { 28 | return 0; 29 | } 30 | _messages[_len++] = (char)data; 31 | return 1; 32 | } 33 | void StartupLog::dump(Channel& out) { 34 | if (_paniced) { 35 | log_error_to(out, "Showing startup log from previous panic"); 36 | } 37 | for (size_t i = 0; i < _len;) { 38 | std::string line; 39 | while (i < _len) { 40 | char c = _messages[i++]; 41 | if (c == '\r') { 42 | continue; 43 | } 44 | if (c == '\n') { 45 | break; 46 | } 47 | line += c; 48 | } 49 | log_stream(out, line); 50 | } 51 | } 52 | 53 | StartupLog::~StartupLog() {} 54 | 55 | StartupLog startupLog; 56 | -------------------------------------------------------------------------------- /FluidNC/src/PinMapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Pin mapper is a class that maps 'Pin' objects to Arduino digitalWrite / digitalRead / setMode. This 4 | // can be useful for support of external libraries, while keeping all the things that Pin has to offer. 5 | // 6 | // It's designed to be easy to use. Basically just: `PinMapper myMap(pinToMap);`. It doesn't *own* the 7 | // pin, it merely uses a pointer. Then, the external library can use `myMap.pinId()` as its pin number. 8 | // Once the mapper goes out of scope (or is destructed if it's a field), the mapping is implicitly removed. 9 | // Note that this is merely for external libraries that don't allow us to pass user data such as a void*... 10 | 11 | #include "Pin.h" 12 | 13 | class PinMapper { 14 | uint8_t _mappedId; 15 | 16 | public: 17 | // Default constructor. Doesn't map anything 18 | PinMapper(); 19 | 20 | // Constructor that maps a pin to some Arduino pin ID 21 | PinMapper(Pin& pin); 22 | 23 | // We do not want object copies 24 | PinMapper(const Pin& o) = delete; 25 | PinMapper& operator=(const Pin& o) = delete; 26 | 27 | // For return values, we have to add some move semantics. This is just to 28 | // support trivial assignment cases and return values. Normally: don't use it. 29 | // All these constructors just pass along the id by swapping it. If a pinmapper 30 | // goes out of scope, it is destructed. 31 | PinMapper(PinMapper&& o); 32 | PinMapper& operator=(PinMapper&& o); 33 | 34 | // The ID of the pin, as used by digitalWrite, digitalRead and setMode. 35 | inline uint8_t pinId() const { return _mappedId; } 36 | 37 | // Destructor. Implicitly removes the mapping. 38 | ~PinMapper(); 39 | }; 40 | -------------------------------------------------------------------------------- /FluidNC/src/string_util.cpp: -------------------------------------------------------------------------------- 1 | #include "string_util.h" 2 | #include 3 | 4 | namespace string_util { 5 | char tolower(char c) { 6 | if (c >= 'A' && c <= 'Z') { 7 | return c + ('a' - 'A'); 8 | } 9 | return c; 10 | } 11 | 12 | bool equal_ignore_case(std::string_view a, std::string_view b) { 13 | return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](auto a, auto b) { return tolower(a) == tolower(b); }); 14 | } 15 | 16 | bool starts_with_ignore_case(std::string_view a, std::string_view b) { 17 | return std::equal(a.begin(), a.begin() + b.size(), b.begin(), b.end(), [](auto a, auto b) { return tolower(a) == tolower(b); }); 18 | } 19 | 20 | const std::string_view trim(std::string_view s) { 21 | auto start = s.find_first_not_of(" \t\n\r\f\v"); 22 | if (start == std::string_view::npos) { 23 | return ""; 24 | } 25 | auto end = s.find_last_not_of(" \t\n\r\f\v"); 26 | if (end == std::string_view::npos) { 27 | return s.substr(start); 28 | } 29 | return s.substr(start, end - start + 1); 30 | } 31 | 32 | bool is_int(std::string_view s, int32_t& value) { 33 | char* end; 34 | value = std::strtol(s.cbegin(), &end, 10); 35 | return end == s.cend(); 36 | } 37 | 38 | bool is_uint(std::string_view s, uint32_t& value) { 39 | char* end; 40 | value = std::strtoul(s.cbegin(), &end, 10); 41 | return end == s.cend(); 42 | } 43 | 44 | bool is_float(std::string_view s, float& value) { 45 | char* end; 46 | value = std::strtof(s.cbegin(), &end); 47 | return end == s.cend(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /fluidterm/README-FluidTerm.md: -------------------------------------------------------------------------------- 1 | # fluidterm a Serial Terminal for FluidNC 2 | 3 | ### Overview 4 | 5 | This is a clone of the python [miniterm](https://github.com/pyserial/pyserial/blob/master/serial/tools/miniterm.py) with changes made for [FluidNC](https://github.com/bdring/FluidNC). FluidNC is a next generation CNC controller that runs on ESP32 hardware. 6 | 7 | In most cases no parameters need to be supplied, but all miniterm parameters and hotkeys are still supported. 8 | 9 | Changes 10 | 11 | - The default serial port parameters match FluidNC 12 | 13 | - **Baudrate**: 115200 14 | - **EOL**: CRLF 15 | - **Echo**: On 16 | 17 | - If there is one serial port, it will attempt to use it. If there is more than one, you will be presented a list to choose from. 18 | 19 | - There is a new Transformation to colorize FluidNC responses. It uses that by default. 20 | 21 | - You can run it as a python script or as a [Windows exe](https://github.com/bdring/fluidterm/tree/main/dist). 22 | 23 | ### Usage 24 | 25 | - With Python: **python fluidterm.py** 26 | - Windows: double click on **fluidterm.exe** or open a Powershell window in the folder and send **./fluidterm.exe** 27 | 28 | ### Restarting the eSP32 29 | 30 | You can restart the ESP32 to see the boot messages with the FluidNC **$bye** command or you can toggle the DTR function to restart most ESP32 modules by doing Ctrl+T Ctrl+D twice. 31 | 32 | 33 | 34 | ### Source Code 35 | 36 | The source code for fluidterm.py (the Python version) is in this directory. The source code for 37 | fluidterm.exe (the Windows native version) is at https://github.com/MitchBradley/FluidTerm2 . 38 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/StepStick.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | /* 5 | Stepstick.cpp -- stepstick type stepper drivers 6 | */ 7 | 8 | #include "StepStick.h" 9 | 10 | namespace MotorDrivers { 11 | void StepStick::init() { 12 | // If they are not 'undefined', set them as 'on'. 13 | _MS1.setAttr(Pin::Attr::Output | Pin::Attr::InitialOn); 14 | _MS2.setAttr(Pin::Attr::Output | Pin::Attr::InitialOn); 15 | _MS3.setAttr(Pin::Attr::Output | Pin::Attr::InitialOn); 16 | 17 | StandardStepper::init(); 18 | } 19 | 20 | // Configuration handlers: 21 | void StepStick::validate() { StandardStepper::validate(); } 22 | 23 | void StepStick::group(Configuration::HandlerBase& handler) { 24 | StandardStepper::group(handler); 25 | 26 | handler.item("ms1_pin", _MS1); 27 | handler.item("ms2_pin", _MS2); 28 | handler.item("ms3_pin", _MS3); 29 | handler.item("reset_pin", _Reset); 30 | } 31 | 32 | void StepStick::afterParse() { 33 | if (!_Reset.undefined()) { 34 | log_info("Using StepStick Mode"); 35 | 36 | // !RESET pin on steppers (MISO On Schematic) 37 | _Reset.setAttr(Pin::Attr::Output | Pin::Attr::InitialOn); 38 | _Reset.on(); 39 | } 40 | } 41 | 42 | // Name of the configurable. Must match the name registered in the cpp file. 43 | const char* StepStick::name() const { return "stepstick"; } 44 | 45 | // Configuration registration 46 | namespace { 47 | MotorFactory::InstanceBuilder registration("stepstick"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /FluidNC/src/WebUI/NotificationsService.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Luc Lebosse. All rights reserved. 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Config.h" // ENABLE_* 7 | 8 | #ifndef ENABLE_WIFI 9 | namespace WebUI { 10 | class NotificationsService { 11 | public: 12 | NotificationsService() = default; 13 | bool sendMSG(const char* title, const char* message) { return false; }; 14 | }; 15 | extern NotificationsService notificationsService; 16 | } 17 | #else 18 | # include 19 | 20 | namespace WebUI { 21 | class NotificationsService { 22 | public: 23 | NotificationsService(); 24 | 25 | bool begin(); 26 | void end(); 27 | void handle(); 28 | bool sendMSG(const char* title, const char* message); 29 | const char* getTypeString(); 30 | bool started(); 31 | 32 | ~NotificationsService(); 33 | 34 | private: 35 | bool _started; 36 | uint8_t _notificationType; 37 | std::string _token1; 38 | std::string _token2; 39 | std::string _settings; 40 | std::string _serveraddress; 41 | uint16_t _port; 42 | 43 | bool sendPushoverMSG(const char* title, const char* message); 44 | bool sendEmailMSG(const char* title, const char* message); 45 | bool sendLineMSG(const char* title, const char* message); 46 | bool getPortFromSettings(); 47 | bool getServerAddressFromSettings(); 48 | bool getEmailFromSettings(); 49 | }; 50 | 51 | extern NotificationsService notificationsService; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/driver/ledc.cpp: -------------------------------------------------------------------------------- 1 | #include "ledc.h" 2 | #include "../soc/ledc_struct.h" 3 | #include "../Arduino.h" 4 | #include "../Capture.h" 5 | 6 | #include 7 | 8 | class LEDCInfo { 9 | public: 10 | LEDCInfo() : chan_(0), freq_(0), pin_(0) {} 11 | LEDCInfo(int chan, double freq, int pin) : chan_(chan), freq_(freq), pin_(pin) { 12 | std::ostringstream oss; 13 | oss << "ledc." << chan << ";freq=" << freq << ";pin=" << pin; 14 | key_ = oss.str(); 15 | } 16 | 17 | int chan_; 18 | double freq_; 19 | int pin_; 20 | std::string key_; 21 | 22 | void write(uint32_t duty) { Capture::instance().write(key_, duty); } 23 | }; 24 | 25 | LEDCInfo infos[16]; 26 | 27 | uint32_t getApbFrequency() { // in Hz 28 | return 80'000'000; // 80 MHz 29 | } 30 | double ledcSetup(uint8_t chan, double freq, uint8_t resolution_bits) { 31 | infos[chan] = LEDCInfo(chan, freq, 0); 32 | return freq; 33 | } 34 | void ledcWrite(uint8_t channel, uint32_t duty) { 35 | infos[channel].write(duty); 36 | } 37 | void ledcAttachPin(uint8_t pin, uint8_t channel) { 38 | auto old = infos[channel]; 39 | infos[channel] = LEDCInfo(channel, old.freq_, pin); 40 | } 41 | void ledcDetachPin(uint8_t pin) { 42 | for (int i = 0; i < 16; ++i) { 43 | if (infos[i].pin_ == pin) { 44 | infos[i] = LEDCInfo(0, 0, 0); 45 | } 46 | } 47 | } 48 | 49 | // TODO FIXME: Find some way to cope with these: 50 | void pinMatrixOutAttach(uint8_t pin, uint8_t function, bool invertOut, bool invertEnable) {} // Cannot capture this... 51 | void pinMatrixOutDetach(uint8_t pin, bool invertOut, bool invertEnable) {} // Cannot capture this... 52 | -------------------------------------------------------------------------------- /FluidNC/src/Motors/StandardStepper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MotorDriver.h" 4 | 5 | #include 6 | 7 | namespace MotorDrivers { 8 | class StandardStepper : public MotorDriver { 9 | public: 10 | //StandardStepper(size_t axis_index, Pin step_pin, Pin dir_pin, Pin disable_pin); 11 | 12 | StandardStepper() = default; 13 | 14 | // Overrides for inherited methods 15 | void init() override; 16 | 17 | // No special action, but return true to say homing is possible 18 | bool set_homing_mode(bool isHoming) override { return true; } 19 | void set_disable(bool) override; 20 | void set_direction(bool) override; 21 | void step() override; 22 | void unstep() override; 23 | void read_settings() override; 24 | 25 | void init_step_dir_pins(); 26 | 27 | protected: 28 | void config_message() override; 29 | 30 | Pin _step_pin; 31 | Pin _dir_pin; 32 | Pin _disable_pin; 33 | 34 | // Configuration handlers: 35 | void validate() override; 36 | 37 | void group(Configuration::HandlerBase& handler) override { 38 | handler.item("step_pin", _step_pin); 39 | handler.item("direction_pin", _dir_pin); 40 | handler.item("disable_pin", _disable_pin); 41 | } 42 | 43 | // Name of the configurable. Must match the name registered in the cpp file. 44 | const char* name() const override { return "standard_stepper"; } 45 | 46 | private: 47 | // Initialized after configuration for RMT steps: 48 | bool _invert_step; 49 | bool _invert_disable; 50 | 51 | rmt_channel_t _rmt_chan_num = RMT_CHANNEL_MAX; 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /FluidNC/src/Parking.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 - Mitch Bradley 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "Configuration/HandlerBase.h" 7 | #include "Configuration/Configurable.h" 8 | 9 | #include "GCode.h" // CoolantState etc 10 | #include "Planner.h" // plan_line_data_t 11 | #include "Machine/Axes.h" // axisType 12 | 13 | #include 14 | 15 | class Parking : public Configuration::Configurable { 16 | private: 17 | // Configuration 18 | bool _enable = false; 19 | float _target_mpos = -5.0; 20 | float _pullout = 5.0; 21 | float _rate = 800.0; 22 | float _pullout_rate = 250.0; 23 | int _axis = 2; // Default to Z 24 | 25 | // local variables 26 | float parking_target[MAX_N_AXIS]; 27 | float restore_target[MAX_N_AXIS]; 28 | float retract_waypoint; 29 | 30 | CoolantState saved_coolant; 31 | SpindleState saved_spindle; 32 | SpindleSpeed saved_spindle_speed; 33 | 34 | plan_line_data_t plan_data; 35 | 36 | plan_block_t* block; 37 | 38 | void moveto(float* target); 39 | 40 | bool can_park(); 41 | 42 | public: 43 | Parking() {} 44 | 45 | void setup(); // Called when suspend start 46 | void set_target(); // Called when motion has stopped after suspend 47 | 48 | void restore_spindle(); // Restores spindle state upon resume 49 | void restore_coolant(); // Restores coolant state upon resume 50 | 51 | void park(bool restart); 52 | void unpark(bool restart); 53 | 54 | // Configuration handlers. 55 | void group(Configuration::HandlerBase& handler) override; 56 | 57 | ~Parking() = default; 58 | }; 59 | -------------------------------------------------------------------------------- /FluidNC/src/Status_outputs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Config.h" 4 | #include "Configuration/Configurable.h" 5 | #include "Channel.h" 6 | 7 | typedef const uint8_t* font_t; 8 | 9 | class Status_Outputs : public Channel, public Configuration::Configurable { 10 | Pin _Idle_pin; 11 | Pin _Run_pin; 12 | Pin _Hold_pin; 13 | Pin _Alarm_pin; 14 | 15 | public: 16 | private: 17 | std::string _report; 18 | std::string _state; 19 | 20 | int _report_interval_ms = 500; 21 | 22 | void parse_report(); 23 | void parse_status_report(); 24 | 25 | public: 26 | Status_Outputs() : Channel("status_outputs") {} 27 | 28 | Status_Outputs(const Status_Outputs&) = delete; 29 | Status_Outputs(Status_Outputs&&) = delete; 30 | Status_Outputs& operator=(const Status_Outputs&) = delete; 31 | Status_Outputs& operator=(Status_Outputs&&) = delete; 32 | 33 | virtual ~Status_Outputs() = default; 34 | 35 | void init(); 36 | 37 | size_t write(uint8_t data) override; 38 | 39 | Channel* pollLine(char* line) override; 40 | void flushRx() override {} 41 | 42 | bool lineComplete(char*, char) override { return false; } 43 | size_t timedReadBytes(char* buffer, size_t length, TickType_t timeout) override { return 0; } 44 | 45 | // Configuration handlers: 46 | void validate() override {} 47 | void afterParse() override {}; 48 | 49 | void group(Configuration::HandlerBase& handler) override { 50 | handler.item("report_interval_ms", _report_interval_ms, 100, 5000); 51 | handler.item("idle_pin", _Idle_pin); 52 | handler.item("run_pin", _Run_pin); 53 | handler.item("hold_pin", _Hold_pin); 54 | handler.item("alarm_pin", _Alarm_pin); 55 | } 56 | }; 57 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/SiemensV20Spindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Copyright (c) 2020 - Stefan de Bruijn 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "VFDSpindle.h" 8 | 9 | namespace Spindles { 10 | class SiemensV20 : public VFD { 11 | 12 | protected: 13 | uint16_t _minFrequency = 0; // PD011: frequency lower limit. Normally 0. 14 | uint16_t _maxFrequency = 400; // PD005: max frequency the VFD will allow. Normally 400. 15 | uint16_t _numberPoles = 2; // 4 or 2 poles in motor. Default is 4. A spindle being 24000RPM@400Hz implies 2 poles 16 | uint16_t _NumberPhases = 3; // Typically 3 Phases for standard VFDs 17 | float _FreqScaler = float(-16384.0) / _maxFrequency; // SPEED_SCALING Internally it is standardized to 16384. (16384 / 400) With this scaling HSW and HIW are transferred via the Modbus register. 18 | 19 | 20 | void direction_command(SpindleState mode, ModbusCommand& data) override; 21 | void set_speed_command(uint32_t rpm, ModbusCommand& data) override; 22 | response_parser initialization_sequence(int index, ModbusCommand& data) override; 23 | response_parser get_current_speed(ModbusCommand& data) override; 24 | response_parser get_status_ok(ModbusCommand& data) override { return nullptr; } 25 | 26 | bool use_delay_settings() const override { return false; } 27 | bool safety_polling() const override { return false; } 28 | 29 | // Name of the configurable. Must match the name registered in the cpp file. 30 | const char* name() const override { return "SiemensV20"; } 31 | 32 | public: 33 | SiemensV20(); 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /FluidNC/test/Pins/Undefined.cpp: -------------------------------------------------------------------------------- 1 | #include "../TestFramework.h" 2 | 3 | #include 4 | 5 | namespace Pins { 6 | Test(Undefined, Pins) { 7 | // Unassigned pins are not doing much... 8 | 9 | Pin unassigned; 10 | Assert(Pin() == unassigned, "Undefined has wrong pin id"); 11 | 12 | { 13 | unassigned.write(true); 14 | auto result = unassigned.read(); 15 | Assert(0 == result, "Result value incorrect"); 16 | } 17 | 18 | { 19 | unassigned.write(false); 20 | auto result = unassigned.read(); 21 | Assert(0 == result, "Result value incorrect"); 22 | } 23 | 24 | Assert(unassigned.capabilities().has(Pin::Capabilities::Void)); 25 | auto name = unassigned.name(); 26 | Assert(unassigned.name().equals("NO_PIN")); 27 | } 28 | 29 | Test(Undefined, MultipleInstances) { 30 | { 31 | Pin unassigned; 32 | Pin unassigned2; 33 | 34 | Assert(unassigned == unassigned2, "Should evaluate to true."); 35 | } 36 | 37 | { 38 | Pin unassigned = Pin(); 39 | Pin unassigned2; 40 | 41 | Assert(unassigned == unassigned2, "Should evaluate to true."); 42 | } 43 | 44 | { 45 | Pin unassigned = Pin::create("void.2"); 46 | Pin unassigned2; 47 | 48 | Assert(unassigned != unassigned2, "Second void pin should match first."); 49 | } 50 | 51 | { 52 | Pin unassigned = Pin::create("void.2"); 53 | Pin unassigned2 = Pin::create("void.2"); 54 | 55 | Assert(unassigned != unassigned2, "Second void pin should not match first."); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /X86TestSupport/TestSupport/SD.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _SD_H_ 15 | #define _SD_H_ 16 | 17 | #include "FS.h" 18 | #include "SPI.h" 19 | 20 | namespace fs { 21 | 22 | class SDFS : public FS { 23 | protected: 24 | uint8_t _pdrv; 25 | 26 | public: 27 | SDFS(FSImplPtr impl); 28 | bool begin(uint8_t ssPin, 29 | SPIClass& spi = SPI, 30 | uint32_t frequency = 4000000, 31 | const char* mountpoint = "/sd", 32 | uint8_t max_files = 5, 33 | bool format_if_empty = false); 34 | void end(); 35 | uint64_t cardSize(); 36 | uint64_t totalBytes(); 37 | uint64_t usedBytes(); 38 | bool readRAW(uint8_t* buffer, uint32_t sector); 39 | bool writeRAW(uint8_t* buffer, uint32_t sector); 40 | }; 41 | 42 | } 43 | 44 | extern fs::SDFS SD; 45 | 46 | using namespace fs; 47 | typedef fs::File SDFile; 48 | typedef fs::SDFS SDFileSystemClass; 49 | #define SDFileSystem SD 50 | 51 | #endif /* _SD_H_ */ 52 | -------------------------------------------------------------------------------- /FluidNC/src/Stepper.md: -------------------------------------------------------------------------------- 1 | # How stepper works 2 | 3 | The logic for the different stepping engines is better encapsulated but still distributed across several modules. Timing - things like stepper disable delays, direction-to-step delay, step pulse length, and isr tick timing - used to be in Stepper.cpp with little fragments scattered throughout motion code. Now the timing stuff has been collected in Stepping.cpp - mostly. Step pulse generation still works like this: Stepper::pulse_func() determines the next step and calls Axes::step(step_mask, dir_mask). If dir_mask has changed, Axes::step() loops over axes and motors and calls Motor::set_direction(bool) for each extant motor. Axes::step() then loops over axes again and calls Motor::step() for each motor that is currently being driven. ... 4 | 5 | Motor::step() usually boils down to StandardStepper::step() via inheritance. 6 | 7 | StandardStepper::step() looks at the stepping engine value. If it is RMT, it starts a pulse on the RMT channel associated with that pin. If not, it calls _step_pin.on(), vectoring to the PinDetail instance for the pin - either I2SOPinDetail or GPIOPinDetail. 8 | 9 | GPIOPinDetail::on() calls __digitalWrite() after some error checking. 10 | 11 | I2SOPinDetail::on() calls i2s_out_write() which is interesting. In the streaming case, i2s_out_write sets or clears a bit in a bitmask variable, where it just sits until a later step. In the passthrough (static) case, the bitmask variable is immediately sent to the output stream. 12 | 13 | In I2SO streaming, the bitmask is not sent to the hardware until after all of the axes have been handled. It happens in Stepping::waitPulse(), which call i2s_out_push_sample() to transfer the bitmask - which reflects the state of all of the step bits - to the DMA buffer. 14 | -------------------------------------------------------------------------------- /FluidNC/src/Probe.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC 2 | // Copyright (c) 2018 - Bart Dring 3 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include "Configuration/HandlerBase.h" 8 | #include "Configuration/Configurable.h" 9 | 10 | #include 11 | class ProbeEventPin; 12 | 13 | class Probe : public Configuration::Configurable { 14 | // Inverts the probe pin state depending on user settings and probing cycle mode. 15 | bool _away = false; 16 | ProbeEventPin* _probeEventPin; 17 | ProbeEventPin* _toolsetterEventPin; 18 | 19 | public: 20 | bool _hard_stop = false; 21 | // Configurable 22 | bool _check_mode_start = true; 23 | // _check_mode_start configures the position after a probing cycle 24 | // during check mode. false sets the position to the probe target, 25 | // true sets the position to the start position. 26 | 27 | Probe() = default; 28 | 29 | // Configurable 30 | Pin _probePin; 31 | Pin _toolsetterPin; 32 | 33 | bool exists() const { return _probePin.defined() || _toolsetterPin.defined(); } 34 | // Probe pin initialization routine. 35 | void init(); 36 | 37 | // setup probing direction G38.2 vs. G38.4 38 | void set_direction(bool away); 39 | 40 | // Returns probe pin state. Triggered = true. Called by gcode parser and probe state monitor. 41 | bool get_state(); 42 | 43 | // Returns true if the probe pin is tripped, depending on the direction (away or not) 44 | bool IRAM_ATTR tripped(); 45 | 46 | // Configuration handlers. 47 | void validate() override; 48 | void group(Configuration::HandlerBase& handler) override; 49 | 50 | ~Probe() = default; 51 | }; 52 | -------------------------------------------------------------------------------- /FluidNC/esp32/delay_usecs.cpp: -------------------------------------------------------------------------------- 1 | #include "Driver/delay_usecs.h" 2 | 3 | #include // IRAM_ATTR 4 | #include 5 | 6 | #include 7 | 8 | #if CONFIG_IDF_TARGET_ESP32 9 | # include "esp32/clk.h" 10 | #elif CONFIG_IDF_TARGET_ESP32S2 11 | # include "esp32s2/clk.h" 12 | #elif CONFIG_IDF_TARGET_ESP32S3 13 | # include "esp32s3/clk.h" 14 | #elif CONFIG_IDF_TARGET_ESP32C3 15 | # include "esp32c3/clk.h" 16 | #elif CONFIG_IDF_TARGET_ESP32H2 17 | # include "esp32h2/clk.h" 18 | #endif 19 | 20 | uint32_t ticks_per_us; 21 | int esp_clk_cpu_freq(void); 22 | 23 | void timing_init() { 24 | ticks_per_us = esp_clk_cpu_freq() / 1000000; 25 | } 26 | 27 | void IRAM_ATTR delay_us(int32_t us) { 28 | spinUntil(usToEndTicks(us)); 29 | } 30 | 31 | int32_t IRAM_ATTR usToCpuTicks(int32_t us) { 32 | return us * ticks_per_us; 33 | } 34 | 35 | int32_t IRAM_ATTR usToEndTicks(int32_t us) { 36 | return getCpuTicks() + usToCpuTicks(us); 37 | } 38 | 39 | // At the usual ESP32 clock rate of 240MHz, the range of this is 40 | // just under 18 seconds, but it really should be used only for 41 | // short delays up to a few tens of microseconds. 42 | 43 | void IRAM_ATTR spinUntil(int32_t endTicks) { 44 | while ((getCpuTicks() - endTicks) < 0) { 45 | #ifdef ESP32 46 | asm volatile("nop"); 47 | #endif 48 | } 49 | } 50 | 51 | // Short delays measured using the CPU cycle counter. There is a ROM 52 | // routine "esp_delay_us(us)" that almost does what what we need, 53 | // except that it is in ROM and thus dodgy for use from ISRs. We 54 | // duplicate the esp_delay_us() here, but placed in IRAM, inlined, 55 | // and factored so it can be used in different ways. 56 | 57 | int32_t IRAM_ATTR getCpuTicks() { 58 | return XTHAL_GET_CCOUNT(); 59 | } 60 | -------------------------------------------------------------------------------- /FluidNC/src/SDCard.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | /* 7 | * Connect the SD card to the following pins: 8 | * 9 | * SD Card | ESP32 10 | * D2 - 11 | * D3 SS 12 | * CMD MOSI 13 | * VSS GND 14 | * VDD 3.3V 15 | * CLK SCK 16 | * VSS GND 17 | * D0 MISO 18 | * D1 - 19 | */ 20 | 21 | #include "Configuration/Configurable.h" 22 | #include "WebUI/Authentication.h" 23 | #include "Pin.h" 24 | #include "Error.h" 25 | 26 | #include 27 | 28 | class SDCard : public Configuration::Configurable { 29 | public: 30 | enum class State : uint8_t { 31 | Idle = 0, 32 | NotPresent = 1, 33 | Busy = 2, 34 | BusyUploading = 3, 35 | BusyParsing = 4, 36 | BusyWriting = 5, 37 | BusyReading = 6, 38 | }; 39 | 40 | private: 41 | State _state; 42 | Pin _cardDetect; 43 | Pin _cs; 44 | 45 | uint32_t _frequency_hz = 8000000; // Set to nonzero to override the default 46 | 47 | public: 48 | SDCard(); 49 | SDCard(const SDCard&) = delete; 50 | SDCard& operator=(const SDCard&) = delete; 51 | 52 | void afterParse() override; 53 | 54 | const char* filename(); 55 | bool config_ok = false; 56 | 57 | // Initializes pins. 58 | void init(); 59 | 60 | // Configuration handlers. 61 | void group(Configuration::HandlerBase& handler) override { 62 | handler.item("cs_pin", _cs); 63 | handler.item("card_detect_pin", _cardDetect); 64 | handler.item("frequency_hz", _frequency_hz, 400000, 20000000); 65 | } 66 | 67 | ~SDCard(); 68 | }; 69 | -------------------------------------------------------------------------------- /FluidNC/src/Spindles/10vSpindle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 - Bart Dring 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | /* 7 | 10vSpindle.h 8 | 9 | This is basically a PWM spindle with some changes, so a separate forward and 10 | reverse signal can be sent. 11 | 12 | The direction pins will act as enables for the 2 directions. There is usually 13 | a min RPM with VFDs, that speed will remain even if speed is 0. You 14 | must turn off both direction pins when enable is off. 15 | */ 16 | 17 | #include "PWMSpindle.h" 18 | 19 | namespace Spindles { 20 | class _10v : public PWM { 21 | public: 22 | _10v() = default; 23 | 24 | _10v(const _10v&) = delete; 25 | _10v(_10v&&) = delete; 26 | _10v& operator=(const _10v&) = delete; 27 | _10v& operator=(_10v&&) = delete; 28 | 29 | void init() override; 30 | void config_message() override; 31 | void setSpeedfromISR(uint32_t dev_speed) override; 32 | 33 | void deinit() override; 34 | 35 | // Configuration handlers: 36 | void validate() override { PWM::validate(); } 37 | 38 | void group(Configuration::HandlerBase& handler) override { 39 | handler.item("forward_pin", _forward_pin); 40 | handler.item("reverse_pin", _reverse_pin); 41 | PWM::group(handler); 42 | } 43 | 44 | // Name of the configurable. Must match the name registered in the cpp file. 45 | const char* name() const override { return "10V"; } 46 | 47 | ~_10v() {} 48 | 49 | protected: 50 | void set_enable(bool enable_pin) override; 51 | void set_direction(bool Clockwise); 52 | 53 | Pin _forward_pin; 54 | Pin _reverse_pin; 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/Validator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Pin.h" 7 | #include "HandlerBase.h" 8 | 9 | #include 10 | 11 | namespace Configuration { 12 | class Configurable; 13 | 14 | class Validator : public HandlerBase { 15 | Validator(const Validator&) = delete; 16 | Validator& operator=(const Validator&) = delete; 17 | 18 | std::vector _path; 19 | 20 | protected: 21 | void enterSection(const char* name, Configurable* value) override; 22 | bool matchesUninitialized(const char* name) override { return false; } 23 | HandlerType handlerType() override { return HandlerType::Validator; } 24 | 25 | public: 26 | Validator(); 27 | 28 | void item(const char* name, bool& value) override {} 29 | void item(const char* name, int32_t& value, const int32_t minValue, const int32_t maxValue) override {} 30 | void item(const char* name, uint32_t& value, const uint32_t minValue, const uint32_t maxValue) override {} 31 | void item(const char* name, float& value, const float minValue, const float maxValue) override {} 32 | void item(const char* name, std::vector& value) override {} 33 | void item(const char* name, UartData& wordLength, UartParity& parity, UartStop& stopBits) override {} 34 | void item(const char* name, std::string& value, const int minLength, const int maxLength) override {} 35 | void item(const char* name, Pin& value) override {} 36 | void item(const char* name, IPAddress& value) override {} 37 | void item(const char* name, int& value, const EnumItem* e) override {} 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /FluidNC/src/Configuration/AfterParse.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - Stefan de Bruijn 2 | // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. 3 | 4 | #pragma once 5 | 6 | #include "../Pin.h" 7 | #include "HandlerBase.h" 8 | 9 | #include 10 | 11 | namespace Configuration { 12 | class Configurable; 13 | 14 | class AfterParse : public HandlerBase { 15 | AfterParse(const AfterParse&) = delete; 16 | AfterParse& operator=(const AfterParse&) = delete; 17 | 18 | std::vector _path; 19 | 20 | protected: 21 | void enterSection(const char* name, Configurable* value) override; 22 | bool matchesUninitialized(const char* name) override { return false; } 23 | HandlerType handlerType() override { return HandlerType::AfterParse; } 24 | 25 | public: 26 | AfterParse() = default; 27 | 28 | void item(const char* name, bool& value) override {} 29 | void item(const char* name, int32_t& value, const int32_t minValue, const int32_t maxValue) override {} 30 | void item(const char* name, uint32_t& value, const uint32_t minValue, const uint32_t maxValue) override {} 31 | void item(const char* name, float& value, const float minValue, const float maxValue) override {} 32 | void item(const char* name, std::vector& value) override {} 33 | void item(const char* name, UartData& wordLength, UartParity& parity, UartStop& stopBits) override {} 34 | void item(const char* name, std::string& value, const int minLength, const int maxLength) override {} 35 | void item(const char* name, Pin& value) override {} 36 | void item(const char* name, IPAddress& value) override {} 37 | void item(const char* name, int& value, const EnumItem* e) override {} 38 | }; 39 | } 40 | --------------------------------------------------------------------------------