├── FirmwareBin ├── firmware.bin.md5sum ├── firmware.bin ├── firmware-disablemsd.bin └── Readme.md ├── .gitmodules ├── bootloader ├── DFU-Bootloader.hex.md5sum ├── DFU-Bootloader.bin ├── DFU-Bootloader.elf └── Readme.md ├── src ├── libs │ ├── platform_memory.cpp │ ├── Hook.cpp │ ├── Network │ │ ├── uip │ │ │ ├── webserver │ │ │ │ ├── httpd-fs │ │ │ │ │ └── 404.html │ │ │ │ ├── httpd-fs-src │ │ │ │ │ └── 404.html │ │ │ │ ├── makestrings │ │ │ │ ├── http-strings.h │ │ │ │ ├── http-strings │ │ │ │ ├── webserver.h │ │ │ │ ├── makefsdata.pl │ │ │ │ └── httpd-fs.h │ │ │ ├── NetworkPublicAccess.h │ │ │ ├── c-fifo.h │ │ │ ├── CommandQueue.h │ │ │ ├── sftp │ │ │ │ └── sftpd.h │ │ │ ├── CallbackStream.h │ │ │ ├── fifo.cpp │ │ │ ├── Network.h │ │ │ ├── CallbackStream.cpp │ │ │ ├── CommandQueue.cpp │ │ │ ├── plan9 │ │ │ │ └── plan9.h │ │ │ ├── clock-arch.h │ │ │ └── clock-arch.c │ │ └── Drivers │ │ │ └── LPC17XX_Ethernet.h │ ├── SerialMessage.h │ ├── platform_memory.h │ ├── Hook.h │ ├── AppendFileStream.cpp │ ├── MRI_Hooks.h │ ├── spi_hal.h │ ├── Watchdog.h │ ├── AppendFileStream.h │ ├── StringStream.h │ ├── FileStream.h │ ├── Pwm.h │ ├── StreamOutput.cpp │ ├── Watchdog.cpp │ ├── PublicData.cpp │ ├── utils.h │ ├── Vector3.h │ ├── nuts_bolts.h │ ├── Median.h │ ├── ConfigSources │ │ ├── FirmConfigSource.h │ │ └── FileConfigSource.h │ ├── StreamOutputPool.h │ ├── ConfigSource.h │ ├── ConfigCache.h │ ├── MemoryPool.h │ ├── StreamOutput.h │ ├── Vector3.cpp │ ├── ConfigValue.h │ ├── Adc.h │ ├── Module.cpp │ ├── Config.h │ ├── PublicData.h │ ├── HeapRing.h │ ├── ConfigCache.cpp │ ├── PublicDataRequest.h │ ├── MRI_Hooks.cpp │ └── SlowTicker.h ├── generate-version.sh ├── version.h ├── config.S ├── version.cpp ├── generate-version.bat ├── modules │ ├── tools │ │ ├── extruder │ │ │ ├── ExtruderPublicAccess.h │ │ │ └── ExtruderMaker.h │ │ ├── endstops │ │ │ └── EndstopsPublicAccess.h │ │ ├── toolmanager │ │ │ ├── ToolManagerPublicAccess.h │ │ │ ├── Tool.h │ │ │ └── ToolManager.h │ │ ├── switch │ │ │ ├── SwitchPublicAccess.h │ │ │ ├── SwitchPool.h │ │ │ └── SwitchPool.cpp │ │ ├── zprobe │ │ │ ├── Plane3D.h │ │ │ ├── LevelingStrategy.h │ │ │ ├── DeltaCalibrationStrategy.h │ │ │ ├── ThreePointStrategy.h │ │ │ ├── Plane3D.cpp │ │ │ ├── ZGridStrategy.h │ │ │ └── ZProbe.h │ │ ├── temperaturecontrol │ │ │ ├── TemperatureControlPublicAccess.h │ │ │ ├── TemperatureControlPool.h │ │ │ ├── PID_Autotuner.h │ │ │ ├── max31855.h │ │ │ ├── TempSensor.h │ │ │ ├── TemperatureControlPool.cpp │ │ │ └── predefined_thermistors.h │ │ ├── filamentdetector │ │ │ └── FilamentDetector.h │ │ ├── scaracal │ │ │ └── SCARAcal.h │ │ ├── drillingcycles │ │ │ └── Drillingcycles.h │ │ ├── laser │ │ │ └── Laser.h │ │ └── spindle │ │ │ └── Spindle.h │ ├── robot │ │ ├── Pauser.h │ │ ├── arm_solutions │ │ │ ├── HBotSolution.h │ │ │ ├── CartesianSolution.h │ │ │ ├── CartesianSolution.cpp │ │ │ ├── HBotSolution.cpp │ │ │ ├── BaseSolution.h │ │ │ ├── RotatableCartesianSolution.h │ │ │ ├── ExperimentalDeltaSolution.h │ │ │ ├── MorganSCARASolution.h │ │ │ ├── LinearDeltaSolution.h │ │ │ ├── RotatableCartesianSolution.cpp │ │ │ └── RotatableDeltaSolution.h │ │ ├── Planner.h │ │ ├── Pauser.cpp │ │ ├── Conveyor.h │ │ └── Stepper.h │ ├── utils │ │ ├── panel │ │ │ ├── panels │ │ │ │ ├── LcdBase.cpp │ │ │ │ ├── UniversalAdapter.h │ │ │ │ ├── ReprapDiscountGLCD.h │ │ │ │ ├── rrdglcd │ │ │ │ │ └── RrdGlcd.h │ │ │ │ └── ST7565.h │ │ │ ├── Button.h │ │ │ ├── screens │ │ │ │ ├── JogScreen.h │ │ │ │ ├── ExtruderScreen.h │ │ │ │ ├── CustomScreen.h │ │ │ │ ├── PrepareScreen.h │ │ │ │ ├── MainMenuScreen.h │ │ │ │ ├── ProbeScreen.h │ │ │ │ ├── FileScreen.h │ │ │ │ ├── ControlScreen.h │ │ │ │ ├── WatchScreen.h │ │ │ │ └── ModifyValuesScreen.h │ │ │ ├── PanelScreen.h │ │ │ └── Button.cpp │ │ ├── currentcontrol │ │ │ ├── CurrentControl.h │ │ │ ├── DigipotBase.h │ │ │ ├── ad5206.h │ │ │ └── mcp4451.h │ │ ├── PlayLed │ │ │ ├── PlayLed.h │ │ │ └── PlayLed.cpp │ │ ├── player │ │ │ └── PlayerPublicAccess.h │ │ ├── pausebutton │ │ │ └── PauseButton.h │ │ └── configurator │ │ │ └── Configurator.h │ └── communication │ │ ├── GcodeDispatch.h │ │ ├── SerialConsole.h │ │ └── utils │ │ └── Gcode.h ├── testframework │ ├── Test_kernel.h │ ├── Test_main.cpp │ ├── unittests │ │ └── libs │ │ │ └── TEST_utils.cpp │ ├── easyunit │ │ ├── testrunner.cpp │ │ ├── testharness.h │ │ ├── testrunner.h │ │ ├── testprinter.h │ │ ├── testpartresult.cpp │ │ └── simplestring.h │ └── Readme.md └── config.default ├── checksum.pl ├── ConfigSamples ├── Snippets │ ├── drill_cycles.config │ ├── filament-change-menu.config │ ├── filament_out_switch.config │ ├── ZprobeGrid.config │ └── psu_off_when_cooled_down.config └── README.TXT ├── .gitignore ├── rakefile.defaults.example ├── makefile ├── smoothie-stream.py └── README.creole /FirmwareBin/firmware.bin.md5sum: -------------------------------------------------------------------------------- 1 | 1197697c2c8ef70479bea3c46b4f5d33 FirmwareBin/firmware.bin 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "mbed"] 2 | path = mbed 3 | url = https://github.com/clementleger/gcc4mbed.git 4 | -------------------------------------------------------------------------------- /bootloader/DFU-Bootloader.hex.md5sum: -------------------------------------------------------------------------------- 1 | 86b565ff21a21958b3a1c49d1d5c3846 bootloader/DFU-Bootloader.hex 2 | -------------------------------------------------------------------------------- /src/libs/platform_memory.cpp: -------------------------------------------------------------------------------- 1 | #include "platform_memory.h" 2 | 3 | MemoryPool* _AHB0; 4 | MemoryPool* _AHB1; 5 | -------------------------------------------------------------------------------- /FirmwareBin/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clementleger/Smoothieware-STM32/HEAD/FirmwareBin/firmware.bin -------------------------------------------------------------------------------- /bootloader/DFU-Bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clementleger/Smoothieware-STM32/HEAD/bootloader/DFU-Bootloader.bin -------------------------------------------------------------------------------- /bootloader/DFU-Bootloader.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clementleger/Smoothieware-STM32/HEAD/bootloader/DFU-Bootloader.elf -------------------------------------------------------------------------------- /src/generate-version.sh: -------------------------------------------------------------------------------- 1 | echo `git symbolic-ref HEAD 2> /dev/null | cut -b 12-`-`git log --pretty=format:%h -1` 2 | touch version.cpp -------------------------------------------------------------------------------- /FirmwareBin/firmware-disablemsd.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clementleger/Smoothieware-STM32/HEAD/FirmwareBin/firmware-disablemsd.bin -------------------------------------------------------------------------------- /src/libs/Hook.cpp: -------------------------------------------------------------------------------- 1 | extern "C"{ 2 | #include 3 | } 4 | #include "Hook.h" 5 | 6 | // Hook is just a glorified FPointer 7 | 8 | Hook::Hook(){} 9 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | #ifndef _VERSION__H 2 | #define _VERSION__H 3 | class Version { 4 | public: 5 | const char *get_build(void) const; 6 | const char *get_build_date(void) const; 7 | }; 8 | #endif 9 | -------------------------------------------------------------------------------- /src/config.S: -------------------------------------------------------------------------------- 1 | .section .data.configdefault,"a" 2 | .global _binary_config_default_start 3 | _binary_config_default_start: 4 | .incbin "config.default" 5 | _binary_config_default_end: 6 | .global _binary_config_default_end 7 | -------------------------------------------------------------------------------- /src/version.cpp: -------------------------------------------------------------------------------- 1 | #include "version.h" 2 | const char *Version::get_build(void) const { 3 | return __GITVERSIONSTRING__; 4 | } 5 | const char *Version::get_build_date(void) const { 6 | return __DATE__ " " __TIME__; 7 | } 8 | -------------------------------------------------------------------------------- /src/libs/Network/uip/webserver/httpd-fs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

404 - file not found

5 |

Go here instead.

6 |
7 | 8 | 9 | -------------------------------------------------------------------------------- /src/libs/Network/uip/webserver/httpd-fs-src/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

404 - file not found

5 |

Go here instead.

6 |
7 | 8 | 9 | -------------------------------------------------------------------------------- /FirmwareBin/Readme.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Make sure you download the binary file and not the HTML page. 4 | 5 | Click the file you want, then click the View Raw button to get the raw binary file. 6 | 7 | Flashing the HTML will mean the leds will not flash :) 8 | -------------------------------------------------------------------------------- /src/libs/SerialMessage.h: -------------------------------------------------------------------------------- 1 | #ifndef SERIALMESSAGE_H 2 | #define SERIALMESSAGE_H 3 | 4 | #include 5 | 6 | class StreamOutput; 7 | 8 | struct SerialMessage { 9 | StreamOutput* stream; 10 | std::string message; 11 | }; 12 | #endif 13 | -------------------------------------------------------------------------------- /src/libs/platform_memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLATFORM_MEMORY_H 2 | #define _PLATFORM_MEMORY_H 3 | 4 | #include "MemoryPool.h" 5 | 6 | #define AHB0 (*_AHB0) 7 | #define AHB1 (*_AHB1) 8 | 9 | extern MemoryPool* _AHB0; 10 | extern MemoryPool* _AHB1; 11 | 12 | #endif /* _PLATFORM_MEMORY_H */ 13 | -------------------------------------------------------------------------------- /bootloader/Readme.md: -------------------------------------------------------------------------------- 1 | This is only needed if you have an old Beta board, or need to reflash the bootloader. 2 | All Smoothie baords come pre flashed with the current bootloader. 3 | 4 | see http://smoothieware.org/flashing-the-bootloader for details on how to flash the bootloader if you need to. 5 | -------------------------------------------------------------------------------- /src/libs/Network/uip/NetworkPublicAccess.h: -------------------------------------------------------------------------------- 1 | #ifndef NETWORKPUBLICACCESS_H 2 | #define NETWORKPUBLICACCESS_H 3 | 4 | #define network_checksum CHECKSUM("network") 5 | #define get_ip_checksum CHECKSUM("getip") 6 | #define get_ipconfig_checksum CHECKSUM("getipconfig") 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/libs/Hook.h: -------------------------------------------------------------------------------- 1 | #ifndef HOOK_H 2 | #define HOOK_H 3 | #include "libs/FPointer.h" 4 | 5 | // Hook is just a glorified FPointer 6 | 7 | class Hook : public FPointer { 8 | public: 9 | Hook(); 10 | int interval; 11 | int countdown; 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /checksum.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | 5 | while (defined $ARGV[0]) { 6 | my $s1 = 0; 7 | my $s2 = 0; 8 | my $str = shift @ARGV; 9 | 10 | for (split //, $str) { 11 | $s1 = ($s1 + (ord $_)) % 255; 12 | $s2 = ($s2 + $s1) % 255; 13 | }; 14 | printf "%s:\t%d\n", $str, ($s2<<8) + $s1; 15 | } 16 | -------------------------------------------------------------------------------- /src/libs/AppendFileStream.cpp: -------------------------------------------------------------------------------- 1 | #include "AppendFileStream.h" 2 | #include 3 | 4 | int AppendFileStream::puts(const char *str) 5 | { 6 | FILE *fd= fopen(this->fn, "a"); 7 | if(fd == NULL) return 0; 8 | 9 | int n= fwrite(str, 1, strlen(str), fd); 10 | fclose(fd); 11 | return n; 12 | } 13 | -------------------------------------------------------------------------------- /src/generate-version.bat: -------------------------------------------------------------------------------- 1 | @for /f "delims=" %%a in ('git symbolic-ref HEAD') do @set myvar=%%a 2 | @for /f "delims=" %%b in ('git log "--pretty=format:%%h" -1') do @set myvar2=%%b 3 | @REM the 11 is derived from generate-version.sh "cut -b 12" by subtracting 1 4 | @echo %myvar:~11%-%myvar2% 5 | @copy /b version.cpp+,, >NUL: 6 | 7 | -------------------------------------------------------------------------------- /src/libs/MRI_Hooks.h: -------------------------------------------------------------------------------- 1 | #ifndef _MRI_HOOKS_H 2 | #define _MRI_HOOKS_H 3 | 4 | extern "C" { 5 | void __mriPlatform_EnteringDebuggerHook(); 6 | void __mriPlatform_LeavingDebuggerHook(); 7 | 8 | void set_high_on_debug(int port, int pin); 9 | void set_low_on_debug(int port, int pin); 10 | } 11 | 12 | #endif /* _MRI_HOOKS_H */ 13 | -------------------------------------------------------------------------------- /src/libs/Network/uip/c-fifo.h: -------------------------------------------------------------------------------- 1 | #ifndef _CFIFO_H_ 2 | #define _CFIFO_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void *new_fifo(); 9 | void delete_fifo(void *); 10 | char *fifo_pop(void *); 11 | void fifo_push(void *, char *); 12 | int fifo_size(void *); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/modules/tools/extruder/ExtruderPublicAccess.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define extruder_checksum CHECKSUM("extruder") 4 | #define save_state_checksum CHECKSUM("save_state") 5 | #define restore_state_checksum CHECKSUM("restore_state") 6 | #define target_checksum CHECKSUM("target") 7 | -------------------------------------------------------------------------------- /src/modules/tools/endstops/EndstopsPublicAccess.h: -------------------------------------------------------------------------------- 1 | #ifndef __ENDSTOPSPUBLICACCESS_H_ 2 | #define __ENDSTOPSPUBLICACCESS_H_ 3 | 4 | // addresses used for public data access 5 | #define endstops_checksum CHECKSUM("endstop") 6 | #define trim_checksum CHECKSUM("trim") 7 | #define home_offset_checksum CHECKSUM("home_offset") 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/testframework/Test_kernel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Module.h" 4 | #include 5 | 6 | void test_kernel_setup_config(const char* start, const char* end); 7 | void test_kernel_teardown(); 8 | void test_kernel_trap_event(_EVENT_ENUM id_event, std::function fnc); 9 | void test_kernel_untrap_event(_EVENT_ENUM id_event); 10 | -------------------------------------------------------------------------------- /ConfigSamples/Snippets/drill_cycles.config: -------------------------------------------------------------------------------- 1 | # Drills module 2 | # Implement the Canned Drilling Cycles 3 | # G80-83, G98, G99 in absolute mode only 4 | # Incremental mode not implemented (L) 5 | drillingcycles.enable false # enable module, default false 6 | drillingcycles.dwell_units S # dwell units [S = seconds, P = millis], default: S 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *~ 3 | *.bin 4 | *.disasm 5 | *.elf 6 | *.hex 7 | *.map 8 | mri.log 9 | gdb.txt 10 | deploy 11 | debug 12 | /mbed/src/Debug/ 13 | /mbed/src/Release/ 14 | /LPC1768/ 15 | /mbed/drop/ 16 | /gcc-arm-none-eabi/ 17 | /BuildShell 18 | /BuildShellDebug 19 | /BuildShell.cmd 20 | /BuildShellDebug.cmd 21 | /mac_install.log 22 | /win_install.log 23 | /linux_install.log 24 | 25 | -------------------------------------------------------------------------------- /src/libs/spi_hal.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPI_HAL_H 2 | #define _SPI_HAL_H 3 | 4 | #include "lpc17xx_ssp.h" 5 | 6 | #ifdef __LPC17XX__ 7 | #include 8 | typedef struct { 9 | uint8_t port; 10 | uint8_t pin; 11 | } Pin_t; 12 | 13 | typedef LPC_SSP_TypeDef SPI_REG; 14 | typedef LPC_GPDMACH_TypeDef DMA_REG; 15 | 16 | #define N_SPI_INTERRUPT_ROUTINES 2 17 | #endif 18 | 19 | #endif /* _SPI_HAL_H */ 20 | -------------------------------------------------------------------------------- /src/modules/tools/toolmanager/ToolManagerPublicAccess.h: -------------------------------------------------------------------------------- 1 | #ifndef __TOOLMANAGERPUBLICACCESS_H 2 | #define __TOOLMANAGERPUBLICACCESS_H 3 | 4 | // addresses used for public data access 5 | #define tool_manager_checksum CHECKSUM("tool_manager") 6 | #define current_tool_name_checksum CHECKSUM("current_tool_name") 7 | #define is_active_tool_checksum CHECKSUM("is_active_tool") 8 | 9 | #endif // __TOOLMANAGERPUBLICACCESS_H 10 | 11 | -------------------------------------------------------------------------------- /src/libs/Watchdog.h: -------------------------------------------------------------------------------- 1 | #ifndef _WATCHDOG_H 2 | #define _WATCHDOG_H 3 | 4 | #include 5 | 6 | #include "Module.h" 7 | 8 | typedef enum 9 | { 10 | WDT_MRI, 11 | WDT_RESET, 12 | } WDT_ACTION; 13 | 14 | class Watchdog : public Module 15 | { 16 | public: 17 | Watchdog(uint32_t timeout, WDT_ACTION action); 18 | void feed(); 19 | 20 | void on_module_loaded(); 21 | void on_idle(void*); 22 | }; 23 | 24 | #endif /* _WATCHDOG_H */ 25 | -------------------------------------------------------------------------------- /src/config.default: -------------------------------------------------------------------------------- 1 | # This is a place for the user to specify their own 'firm' defaults at compile time 2 | # One can also use this as the primary config system if an sdcard is unavailable 3 | # The format of this file is identical to that of a normal config file 4 | # 5 | # to have git ignore this file so you can keep your own defaults in here that are 6 | # preserved through updates run this command: 7 | # git update-index --assume-unchanged src/config.default 8 | # 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/libs/AppendFileStream.h: -------------------------------------------------------------------------------- 1 | #ifndef _APPENDFILESTREAM_H_ 2 | #define _APPENDFILESTREAM_H_ 3 | 4 | #include "StreamOutput.h" 5 | #include "string.h" 6 | #include "stdlib.h" 7 | 8 | class AppendFileStream : public StreamOutput { 9 | public: 10 | AppendFileStream(const char *filename) { fn= strdup(filename); } 11 | virtual ~AppendFileStream(){ free(fn); } 12 | int puts(const char*); 13 | 14 | private: 15 | char *fn; 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/modules/robot/Pauser.h: -------------------------------------------------------------------------------- 1 | #ifndef PAUSER_H 2 | #define PAUSER_H 3 | 4 | #include "Module.h" 5 | 6 | class Block; 7 | 8 | class Pauser : public Module { 9 | public: 10 | Pauser(); 11 | void on_module_loaded(); 12 | void on_block_begin(void*); 13 | 14 | void take(); 15 | void release(); 16 | 17 | bool paused(); 18 | 19 | private: 20 | Block* paused_block; 21 | unsigned short counter; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/modules/utils/panel/panels/LcdBase.cpp: -------------------------------------------------------------------------------- 1 | #include "LcdBase.h" 2 | 3 | #include "stdarg.h" 4 | #include "stdio.h" 5 | 6 | LcdBase::LcdBase() {} 7 | LcdBase::~LcdBase() {} 8 | 9 | int LcdBase::printf(const char* format, ...){ 10 | va_list args; 11 | va_start(args, format); 12 | char buffer[80]; // max length for display anyway 13 | int n= vsnprintf(buffer, sizeof(buffer), format, args); 14 | va_end(args); 15 | this->write(buffer, n); 16 | return n; 17 | } 18 | -------------------------------------------------------------------------------- /src/modules/utils/currentcontrol/CurrentControl.h: -------------------------------------------------------------------------------- 1 | #ifndef CURRENTCONTROL_H 2 | #define CURRENTCONTROL_H 3 | 4 | #include "Module.h" 5 | 6 | class DigipotBase; 7 | 8 | class CurrentControl : public Module { 9 | public: 10 | CurrentControl(); 11 | virtual ~CurrentControl() {}; 12 | 13 | void on_module_loaded(); 14 | void on_gcode_received(void *); 15 | 16 | private: 17 | DigipotBase* digipot; 18 | 19 | }; 20 | 21 | 22 | 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/libs/StringStream.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRINGSTREAM_H_ 2 | #define _STRINGSTREAM_H_ 3 | 4 | #include "StreamOutput.h" 5 | 6 | #include 7 | 8 | class StringStream : public StreamOutput { 9 | public: 10 | StringStream() {} 11 | int puts(const char *str){ output.append(str); return strlen(str); } 12 | void clear() { output.clear(); } 13 | std::string getOutput() const { return output; } 14 | 15 | private: 16 | std::string output; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /rakefile.defaults.example: -------------------------------------------------------------------------------- 1 | # if regular build the modules to exclude from the build 2 | NONETWORK = true 3 | EXCLUDE_MODULES = %w(tools/touchprobe tools/laser tools/temperaturecontrol tools/extruder) 4 | 5 | # if test framework build the modules to include in the test... 6 | # here we enable unit tests for tools/temperatureswitch module and any unit tests in /src/testframework/unittests/tools/temperatureswitch/ 7 | # and any unittests in the src/testframework/unittests/libs folder 8 | TESTMODULES= %w(tools/temperatureswitch libs) 9 | -------------------------------------------------------------------------------- /src/modules/tools/switch/SwitchPublicAccess.h: -------------------------------------------------------------------------------- 1 | #ifndef __SWITCHPUBLICACCESS_H 2 | #define __SWITCHPUBLICACCESS_H 3 | 4 | // addresses used for public data access 5 | #define switch_checksum CHECKSUM("switch") 6 | #define fan_checksum CHECKSUM("fan") 7 | #define state_checksum CHECKSUM("state") 8 | #define value_checksum CHECKSUM("value") 9 | 10 | struct pad_switch { 11 | int name; 12 | bool state; 13 | float value; 14 | }; 15 | 16 | #endif // __SWITCHPUBLICACCESS_H 17 | -------------------------------------------------------------------------------- /src/modules/utils/PlayLed/PlayLed.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLAYLED_H 2 | #define _PLAYLED_H 3 | 4 | #include "libs/Kernel.h" 5 | #include "libs/Pin.h" 6 | 7 | 8 | class PlayLed : public Module 9 | { 10 | public: 11 | PlayLed(); 12 | 13 | void on_module_loaded(void); 14 | void on_config_reload(void *); 15 | void on_halt(void *arg); 16 | 17 | private: 18 | uint32_t led_tick(uint32_t); 19 | Pin led; 20 | struct { 21 | uint8_t cnt:4; 22 | bool halted:1; 23 | }; 24 | }; 25 | 26 | #endif /* _PLAYLED_H */ 27 | -------------------------------------------------------------------------------- /src/modules/utils/currentcontrol/DigipotBase.h: -------------------------------------------------------------------------------- 1 | #ifndef DIGIPOTBASE_H 2 | #define DIGIPOTBASE_H 3 | 4 | class DigipotBase { 5 | public: 6 | DigipotBase(){} 7 | virtual ~DigipotBase(){} 8 | 9 | virtual void set_current( int channel, float current )= 0; 10 | virtual float get_current(int channel)= 0; 11 | void set_max_current(float c) { max_current= c; } 12 | void set_factor(float f) { factor= f; } 13 | 14 | protected: 15 | float factor; 16 | float max_current; 17 | }; 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/modules/utils/player/PlayerPublicAccess.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAYERPUBLICACCESS_H 2 | #define PLAYERPUBLICACCESS_H 3 | 4 | #define player_checksum CHECKSUM("player") 5 | #define is_playing_checksum CHECKSUM("is_playing") 6 | #define is_suspended_checksum CHECKSUM("is_suspended") 7 | #define abort_play_checksum CHECKSUM("abort_play") 8 | #define get_progress_checksum CHECKSUM("progress") 9 | 10 | struct pad_progress { 11 | unsigned int percent_complete; 12 | unsigned long elapsed_secs; 13 | string filename; 14 | }; 15 | #endif 16 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/HBotSolution.h: -------------------------------------------------------------------------------- 1 | #ifndef HBOTSOLUTION_H 2 | #define HBOTSOLUTION_H 3 | #include "libs/Module.h" 4 | #include "libs/Kernel.h" 5 | #include "BaseSolution.h" 6 | #include "libs/nuts_bolts.h" 7 | 8 | #include "libs/Config.h" 9 | 10 | class HBotSolution : public BaseSolution { 11 | public: 12 | HBotSolution(); 13 | HBotSolution(Config*){}; 14 | void cartesian_to_actuator(const float[], float[] ); 15 | void actuator_to_cartesian(const float[], float[] ); 16 | }; 17 | 18 | 19 | 20 | 21 | 22 | 23 | #endif // HBOTSOLUTION_H 24 | 25 | -------------------------------------------------------------------------------- /src/modules/tools/zprobe/Plane3D.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLANE3D_H 2 | #define __PLANE3D_H 3 | 4 | #include "Vector3.h" 5 | 6 | #include 7 | 8 | // define a plane given three points 9 | class Plane3D 10 | { 11 | private: 12 | Vector3 normal; 13 | float d; 14 | 15 | public: 16 | Plane3D(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3); 17 | Plane3D(uint32_t a, uint32_t b, uint32_t c, uint32_t d); 18 | float getz(float x, float y); 19 | Vector3 getNormal() const; 20 | void encode(uint32_t& a, uint32_t& b, uint32_t& c, uint32_t& d); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/libs/FileStream.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILESTREAM_H_ 2 | #define _FILESTREAM_H_ 3 | 4 | #include "StreamOutput.h" 5 | #include 6 | #include 7 | 8 | class FileStream : public StreamOutput { 9 | public: 10 | FileStream(const char *filename) { fd= fopen(filename, "w"); } 11 | virtual ~FileStream(){ close(); } 12 | int puts(const char *str){ return (fd == NULL) ? 0 : fwrite(str, 1, strlen(str), fd); } 13 | void close() { if(fd != NULL) fclose(fd); fd= NULL; } 14 | bool is_open() { return fd != NULL; } 15 | 16 | private: 17 | FILE *fd; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/libs/Pwm.h: -------------------------------------------------------------------------------- 1 | #ifndef _PWM_H 2 | #define _PWM_H 3 | 4 | #include 5 | 6 | #include "Pin.h" 7 | #include "Module.h" 8 | 9 | class Pwm : public Module, public Pin { 10 | public: 11 | Pwm(); 12 | 13 | void on_module_load(void); 14 | uint32_t on_tick(uint32_t); 15 | 16 | Pwm* max_pwm(int); 17 | int max_pwm(void); 18 | 19 | void pwm(int); 20 | int get_pwm() const { return _pwm; } 21 | void set(bool); 22 | 23 | private: 24 | int _max; 25 | int _pwm; 26 | int _sd_accumulator; 27 | bool _sd_direction; 28 | }; 29 | 30 | #endif /* _PWM_H */ 31 | -------------------------------------------------------------------------------- /src/modules/tools/zprobe/LevelingStrategy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A strategy called from ZProbe to handle a strategy for leveling 3 | * examples are delta calibration, three point bed leveling, z height map 4 | */ 5 | 6 | #ifndef _LEVELINGSTRATEGY 7 | #define _LEVELINGSTRATEGY 8 | 9 | class ZProbe; 10 | class Gcode; 11 | 12 | class LevelingStrategy 13 | { 14 | public: 15 | LevelingStrategy(ZProbe* zprobe) : zprobe(zprobe){}; 16 | virtual ~LevelingStrategy(){}; 17 | virtual bool handleGcode(Gcode* gcode)= 0; 18 | virtual bool handleConfig()= 0; 19 | 20 | protected: 21 | ZProbe *zprobe; 22 | 23 | }; 24 | #endif 25 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/CartesianSolution.h: -------------------------------------------------------------------------------- 1 | #ifndef CARTESIANSOLUTION_H 2 | #define CARTESIANSOLUTION_H 3 | #include "libs/Module.h" 4 | #include "libs/Kernel.h" 5 | #include "BaseSolution.h" 6 | #include "libs/nuts_bolts.h" 7 | 8 | #include "libs/Config.h" 9 | 10 | class CartesianSolution : public BaseSolution { 11 | public: 12 | CartesianSolution(){}; 13 | CartesianSolution(Config*){}; 14 | void cartesian_to_actuator( const float millimeters[], float steps[] ); 15 | void actuator_to_cartesian( const float steps[], float millimeters[] ); 16 | }; 17 | 18 | 19 | 20 | 21 | 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make 2 | 3 | DIRS = mbed src 4 | DIRSCLEAN = $(addsuffix .clean,$(DIRS)) 5 | 6 | all: 7 | @echo Building Smoothie 8 | @ $(MAKE) -C src 9 | 10 | clean: $(DIRSCLEAN) 11 | 12 | $(DIRSCLEAN): %.clean: 13 | @echo Cleaning $* 14 | @ $(MAKE) -C $* clean 15 | 16 | debug-store: 17 | @ $(MAKE) -C src debug-store 18 | 19 | flash: 20 | @ $(MAKE) -C src flash 21 | 22 | dfu: 23 | @ $(MAKE) -C src dfu 24 | 25 | upload: 26 | @ $(MAKE) -C src upload 27 | 28 | debug: 29 | @ $(MAKE) -C src debug 30 | 31 | console: 32 | @ $(MAKE) -C src console 33 | 34 | .PHONY: all $(DIRS) $(DIRSCLEAN) debug-store flash upload debug console dfu 35 | -------------------------------------------------------------------------------- /ConfigSamples/Snippets/filament-change-menu.config: -------------------------------------------------------------------------------- 1 | custom_menu.filament_change.enable true # 2 | custom_menu.filament_change.name filament_change # 3 | custom_menu.filament_change.command M600 # 4 | 5 | custom_menu.resume.enable true # 6 | custom_menu.resume.name resume # 7 | custom_menu.resume.command M601 # 8 | 9 | after_suspend_gcode G91_G0Z10_G90 # optionally raise nozzle 10mm after suspend 10 | leave_heaters_on_suspend true # set to false if you want the heaters turned off on suspend 11 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/CartesianSolution.cpp: -------------------------------------------------------------------------------- 1 | #include "CartesianSolution.h" 2 | #include 3 | 4 | void CartesianSolution::cartesian_to_actuator( const float cartesian_mm[], float actuator_mm[] ){ 5 | actuator_mm[ALPHA_STEPPER] = cartesian_mm[X_AXIS]; 6 | actuator_mm[BETA_STEPPER ] = cartesian_mm[Y_AXIS]; 7 | actuator_mm[GAMMA_STEPPER] = cartesian_mm[Z_AXIS]; 8 | } 9 | 10 | void CartesianSolution::actuator_to_cartesian( const float actuator_mm[], float cartesian_mm[] ){ 11 | cartesian_mm[ALPHA_STEPPER] = actuator_mm[X_AXIS]; 12 | cartesian_mm[BETA_STEPPER ] = actuator_mm[Y_AXIS]; 13 | cartesian_mm[GAMMA_STEPPER] = actuator_mm[Z_AXIS]; 14 | } 15 | -------------------------------------------------------------------------------- /src/libs/StreamOutput.cpp: -------------------------------------------------------------------------------- 1 | #include "StreamOutput.h" 2 | 3 | NullStreamOutput StreamOutput::NullStream; 4 | 5 | int StreamOutput::printf(const char *format, ...) 6 | { 7 | char b[64]; 8 | char *buffer; 9 | // Make the message 10 | va_list args; 11 | va_start(args, format); 12 | 13 | int size = vsnprintf(b, 64, format, args) + 1; // we add one to take into account space for the terminating \0 14 | 15 | if (size < 64) { 16 | buffer = b; 17 | } else { 18 | buffer = new char[size]; 19 | vsnprintf(buffer, size, format, args); 20 | } 21 | va_end(args); 22 | 23 | puts(buffer); 24 | 25 | if (buffer != b) 26 | delete[] buffer; 27 | 28 | return size - 1; 29 | } 30 | -------------------------------------------------------------------------------- /src/modules/utils/pausebutton/PauseButton.h: -------------------------------------------------------------------------------- 1 | #ifndef PAUSEBUTTON_H 2 | #define PAUSEBUTTON_H 3 | 4 | #include "libs/Pin.h" 5 | 6 | class PauseButton : public Module { 7 | public: 8 | PauseButton(); 9 | 10 | void on_module_loaded(); 11 | void on_console_line_received( void *argument ); 12 | void on_idle(void *argument); 13 | uint32_t button_tick(uint32_t dummy); 14 | 15 | private: 16 | Pin pause_button; 17 | Pin kill_button; 18 | struct { 19 | bool pause_enable:1; 20 | bool kill_enable:1; 21 | bool button_state:1; 22 | bool killed:1; 23 | volatile bool do_kill:1; 24 | }; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libs/Network/uip/CommandQueue.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMANDQUEUE_H_ 2 | #define _COMMANDQUEUE_H_ 3 | 4 | #ifdef __cplusplus 5 | 6 | #include "fifo.h" 7 | #include 8 | 9 | class StreamOutput; 10 | 11 | class CommandQueue 12 | { 13 | public: 14 | CommandQueue(); 15 | ~CommandQueue(); 16 | bool pop(); 17 | int add(const char* cmd, StreamOutput *pstream); 18 | int size() {return q.size();} 19 | static CommandQueue* getInstance(); 20 | 21 | private: 22 | typedef struct {char* str; StreamOutput *pstream; } cmd_t; 23 | Fifo q; 24 | static CommandQueue *instance; 25 | StreamOutput *null_stream; 26 | }; 27 | 28 | #else 29 | 30 | extern int network_add_command(const char * cmd, void *pstream); 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/testframework/Test_main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "utils.h" 6 | #include "SerialConsole.h" 7 | #include "gpio.h" 8 | 9 | GPIO leds[5] = { 10 | GPIO(P1_18), 11 | GPIO(P1_19), 12 | GPIO(P1_20), 13 | GPIO(P1_21), 14 | GPIO(P4_28) 15 | }; 16 | 17 | #include "easyunit/testharness.h" 18 | #include "easyunit/test.h" 19 | 20 | int main( ) 21 | { 22 | Kernel* kernel = new Kernel(); 23 | 24 | printf("Starting tests...\n"); 25 | 26 | TestRegistry::runAndPrint(); 27 | 28 | kernel->serial->printf("Done\n"); 29 | 30 | // drop back into DFU upload 31 | kernel->serial->printf("Entering DFU flash mode...\n"); 32 | system_reset(true); 33 | 34 | for(;;) {} 35 | } 36 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/HBotSolution.cpp: -------------------------------------------------------------------------------- 1 | #include "HBotSolution.h" 2 | #include 3 | 4 | void HBotSolution::cartesian_to_actuator(const float cartesian_mm[], float actuator_mm[] ){ 5 | actuator_mm[ALPHA_STEPPER] = cartesian_mm[X_AXIS] + cartesian_mm[Y_AXIS]; 6 | actuator_mm[BETA_STEPPER ] = cartesian_mm[X_AXIS] - cartesian_mm[Y_AXIS]; 7 | actuator_mm[GAMMA_STEPPER] = cartesian_mm[Z_AXIS]; 8 | } 9 | 10 | void HBotSolution::actuator_to_cartesian(const float actuator_mm[], float cartesian_mm[] ){ 11 | cartesian_mm[X_AXIS] = 0.5F * (actuator_mm[ALPHA_STEPPER] + actuator_mm[BETA_STEPPER]); 12 | cartesian_mm[Y_AXIS] = 0.5F * (actuator_mm[ALPHA_STEPPER] - actuator_mm[BETA_STEPPER]); 13 | cartesian_mm[Z_AXIS] = actuator_mm[GAMMA_STEPPER]; 14 | } 15 | -------------------------------------------------------------------------------- /src/libs/Network/uip/sftp/sftpd.h: -------------------------------------------------------------------------------- 1 | #ifndef __SFTPD_H__ 2 | #define __SFTPD_H__ 3 | 4 | /* 5 | * Implement RFC913 Simple File Transfer 6 | */ 7 | 8 | 9 | #include 10 | extern "C" { 11 | #include "psock.h" 12 | } 13 | 14 | class Sftpd 15 | { 16 | public: 17 | Sftpd(); 18 | virtual ~Sftpd(); 19 | 20 | void appcall(void); 21 | void init(void); 22 | 23 | private: 24 | FILE *fd; 25 | enum STATES { STATE_NORMAL, STATE_CONNECTED, STATE_GET_LENGTH, STATE_DOWNLOAD, STATE_CLOSE }; 26 | STATES state; 27 | int acked(); 28 | int handle_command(); 29 | int handle_download(); 30 | int senddata(); 31 | 32 | struct psock sin; 33 | char buf[80]; 34 | const char *outbuf; 35 | unsigned int filesize; 36 | char *filename; 37 | }; 38 | 39 | #endif /* __sftpd_H__ */ 40 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/BaseSolution.h: -------------------------------------------------------------------------------- 1 | // Base class for an arm solution, only usefull for inheritence. http://en.wikipedia.org/wiki/Arm_solution 2 | #ifndef BASESOLUTION_H 3 | #define BASESOLUTION_H 4 | 5 | #include 6 | class Config; 7 | 8 | class BaseSolution { 9 | public: 10 | BaseSolution(){}; 11 | BaseSolution(Config*){}; 12 | virtual ~BaseSolution() {}; 13 | virtual void cartesian_to_actuator(const float[], float[] ) = 0; 14 | virtual void actuator_to_cartesian(const float[], float[] ) = 0; 15 | typedef std::map arm_options_t; 16 | virtual bool set_optional(const arm_options_t& options) { return false; }; 17 | virtual bool get_optional(arm_options_t& options, bool force_all= false) { return false; }; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/RotatableCartesianSolution.h: -------------------------------------------------------------------------------- 1 | #ifndef ROTATABLECARTESIANSOLUTION_H 2 | #define ROTATABLECARTESIANSOLUTION_H 3 | #include "libs/Module.h" 4 | #include "libs/Kernel.h" 5 | #include "BaseSolution.h" 6 | #include "libs/nuts_bolts.h" 7 | 8 | #include "libs/Config.h" 9 | 10 | #define alpha_angle_checksum CHECKSUM("alpha_angle") 11 | 12 | class RotatableCartesianSolution : public BaseSolution { 13 | public: 14 | RotatableCartesianSolution(Config*); 15 | void cartesian_to_actuator(const float[], float[] ); 16 | void actuator_to_cartesian(const float[], float[] ); 17 | 18 | void rotate(const float in[], float out[], float sin, float cos ); 19 | 20 | float sin_alpha; 21 | float cos_alpha; 22 | }; 23 | 24 | 25 | #endif // ROTATABLECARTESIANSOLUTION_H 26 | 27 | -------------------------------------------------------------------------------- /src/libs/Network/uip/CallbackStream.h: -------------------------------------------------------------------------------- 1 | #ifndef CALLBACKSTREAM_H 2 | #define CALLBACKSTREAM_H 3 | 4 | typedef int (*cb_t)(const char *, void *); 5 | 6 | #ifdef __cplusplus 7 | #include "libs/StreamOutput.h" 8 | 9 | 10 | class CallbackStream : public StreamOutput { 11 | public: 12 | CallbackStream(cb_t cb, void *u); 13 | virtual ~CallbackStream(); 14 | int puts(const char*); 15 | void inc() { use_count++; } 16 | void dec(); 17 | int get_count() { return use_count; } 18 | void mark_closed(); 19 | 20 | private: 21 | cb_t callback; 22 | void *user; 23 | bool closed; 24 | int use_count; 25 | }; 26 | 27 | #else 28 | 29 | extern void *new_callback_stream(cb_t cb, void *); 30 | extern void delete_callback_stream(void *); 31 | 32 | #endif // __cplusplus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ConfigSamples/Snippets/filament_out_switch.config: -------------------------------------------------------------------------------- 1 | switch.filamentout.enable true # 2 | switch.filamentout.input_pin 1.30^ # pin where filemant out button is connected 3 | switch.filamentout.output_on_command suspend # command 4 | 5 | switch.resume.enable true # 6 | switch.resume.input_pin 1.31^ # pin where resum ebutton is connected 7 | switch.resume.output_on_command resume # command 8 | 9 | after_suspend_gcode G91_G0E-5_G0Z10_G90_G0X-50Y-50 # gcode to run after suspend, retract then get head out of way 10 | before_resume_gcode G91_G1E1_G90 # gcode to run after temp is reached but before resume - do a prime 11 | 12 | -------------------------------------------------------------------------------- /src/modules/tools/zprobe/DeltaCalibrationStrategy.h: -------------------------------------------------------------------------------- 1 | #ifndef _DELTALEVELINGSTRATEGY 2 | #define _DELTALEVELINGSTRATEGY 3 | 4 | #include "LevelingStrategy.h" 5 | 6 | #define delta_calibration_strategy_checksum CHECKSUM("delta-calibration") 7 | 8 | class StreamOutput; 9 | 10 | class DeltaCalibrationStrategy : public LevelingStrategy 11 | { 12 | public: 13 | DeltaCalibrationStrategy(ZProbe *zprobe) : LevelingStrategy(zprobe){}; 14 | ~DeltaCalibrationStrategy(){}; 15 | bool handleGcode(Gcode* gcode); 16 | bool handleConfig(); 17 | 18 | private: 19 | bool set_trim(float x, float y, float z, StreamOutput *stream); 20 | bool get_trim(float& x, float& y, float& z); 21 | bool calibrate_delta_endstops(Gcode *gcode); 22 | bool calibrate_delta_radius(Gcode *gcode); 23 | bool probe_delta_points(Gcode *gcode); 24 | 25 | float probe_radius; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/libs/Network/uip/fifo.cpp: -------------------------------------------------------------------------------- 1 | // c accessibllity to the c++ fifo class 2 | #include "fifo.h" 3 | #include "c-fifo.h" 4 | 5 | void *new_fifo() 6 | { 7 | return new Fifo; 8 | } 9 | 10 | void delete_fifo(void *fifo) 11 | { 12 | if(fifo == NULL) return; 13 | Fifo *f= static_cast *>(fifo); 14 | while(f->size() > 0) { 15 | char *s= f->pop(); 16 | if (s != NULL) { 17 | free(s); 18 | } 19 | } 20 | delete f; 21 | } 22 | 23 | char *fifo_pop(void *fifo) 24 | { 25 | Fifo *f= static_cast *>(fifo); 26 | return f->pop(); 27 | } 28 | 29 | void fifo_push(void *fifo, char *str) 30 | { 31 | Fifo *f= static_cast *>(fifo); 32 | f->push(str); 33 | } 34 | 35 | int fifo_size(void *fifo) 36 | { 37 | Fifo *f= static_cast *>(fifo); 38 | return f->size(); 39 | } 40 | -------------------------------------------------------------------------------- /src/libs/Watchdog.cpp: -------------------------------------------------------------------------------- 1 | #include "Watchdog.h" 2 | 3 | #include 4 | 5 | // TODO : comment this 6 | // Basically, when stuff stop answering, reset, or enter MRI mode, or something 7 | 8 | Watchdog::Watchdog(uint32_t timeout, WDT_ACTION action) 9 | { 10 | /* FIXME STM32 11 | WDT_Init(WDT_CLKSRC_IRC, (action == WDT_MRI)?WDT_MODE_INT_ONLY:WDT_MODE_RESET); 12 | WDT_Start(timeout); 13 | WDT_Feed(); 14 | * */ 15 | } 16 | 17 | void Watchdog::feed() 18 | { 19 | /* FIXME STM32 20 | WDT_Feed(); 21 | * */ 22 | } 23 | 24 | void Watchdog::on_module_loaded() 25 | { 26 | register_for_event(ON_IDLE); 27 | feed(); 28 | } 29 | 30 | void Watchdog::on_idle(void*) 31 | { 32 | feed(); 33 | } 34 | 35 | 36 | extern "C" void WDT_IRQHandler(void) 37 | { 38 | /* FIXME STM32 39 | WDT_ClrTimeOutFlag(); 40 | WDT_Feed(); 41 | */ 42 | __debugbreak(); 43 | } 44 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/ExperimentalDeltaSolution.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPERIMENTALDELTASOLUTION_H 2 | #define EXPERIMENTALDELTASOLUTION_H 3 | 4 | #include "BaseSolution.h" 5 | 6 | class Config; 7 | 8 | class ExperimentalDeltaSolution : public BaseSolution { 9 | public: 10 | ExperimentalDeltaSolution(Config*); 11 | void cartesian_to_actuator(const float[], float[] ); 12 | void actuator_to_cartesian(const float[], float[] ); 13 | 14 | float solve_arm( float millimeters[] ); 15 | void rotate(const float in[], float out[], float sin, float cos ); 16 | 17 | private: 18 | float arm_length; 19 | float arm_radius; 20 | float arm_length_squared; 21 | 22 | float sin_alpha; 23 | float cos_alpha; 24 | float sin_beta; 25 | float cos_beta; 26 | float sin_gamma; 27 | float cos_gamma; 28 | }; 29 | 30 | 31 | 32 | 33 | 34 | 35 | #endif // EXPERIMENTALDELTASOLUTION_H 36 | -------------------------------------------------------------------------------- /src/modules/tools/switch/SwitchPool.h: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl). 3 | smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version. 4 | smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details. 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see . 6 | */ 7 | 8 | #ifndef SWITCHPOOL_H 9 | #define SWITCHPOOL_H 10 | 11 | class SwitchPool{ 12 | public: 13 | void load_tools(); 14 | }; 15 | 16 | #endif // SWITCHPOOL_H 17 | -------------------------------------------------------------------------------- /src/modules/tools/extruder/ExtruderMaker.h: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl). 3 | smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version. 4 | smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details. 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see . 6 | */ 7 | 8 | #ifndef EXTRUDERMAKER_H 9 | #define EXTRUDERMAKER_H 10 | 11 | class ExtruderMaker { 12 | public: 13 | void load_tools(); 14 | }; 15 | 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/modules/tools/temperaturecontrol/TemperatureControlPublicAccess.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEMPERATURECONTROLPUBLICACCESS_H 2 | #define __TEMPERATURECONTROLPUBLICACCESS_H 3 | 4 | #include "checksumm.h" 5 | 6 | #include 7 | 8 | // addresses used for public data access 9 | #define temperature_control_checksum CHECKSUM("temperature_control") 10 | #define hotend_checksum CHECKSUM("hotend") 11 | #define bed_checksum CHECKSUM("bed") 12 | #define current_temperature_checksum CHECKSUM("current_temperature") 13 | #define target_temperature_checksum CHECKSUM("target_temperature") 14 | #define temperature_pwm_checksum CHECKSUM("temperature_pwm") 15 | #define pool_index_checksum CHECKSUM("pool_index") 16 | #define poll_controls_checksum CHECKSUM("poll_controllers") 17 | 18 | struct pad_temperature { 19 | float current_temperature; 20 | float target_temperature; 21 | int pwm; 22 | uint16_t id; 23 | std::string designator; 24 | }; 25 | #endif 26 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/MorganSCARASolution.h: -------------------------------------------------------------------------------- 1 | #ifndef MORGANSCARASOLUTION_H 2 | #define MORGANSCARASOLUTION_H 3 | //#include "libs/Module.h" 4 | #include "BaseSolution.h" 5 | 6 | class Config; 7 | 8 | class MorganSCARASolution : public BaseSolution { 9 | public: 10 | MorganSCARASolution(Config*); 11 | void cartesian_to_actuator(const float[], float[] ); 12 | void actuator_to_cartesian(const float[], float[] ); 13 | 14 | bool set_optional(const arm_options_t& options); 15 | bool get_optional(arm_options_t& options, bool force_all); 16 | 17 | private: 18 | void init(); 19 | float to_degrees(float radians); 20 | 21 | float arm1_length; 22 | float arm2_length; 23 | float morgan_offset_x; 24 | float morgan_offset_y; 25 | float morgan_scaling_x; 26 | float morgan_scaling_y; 27 | float morgan_undefined_min; 28 | float morgan_undefined_max; 29 | float slow_rate; 30 | }; 31 | 32 | #endif // MORGANSCARASOLUTION_H 33 | -------------------------------------------------------------------------------- /src/libs/Network/uip/webserver/makestrings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | sub stringify { 5 | my $name = shift(@_); 6 | open(OUTPUTC, "> $name.c"); 7 | open(OUTPUTH, "> $name.h"); 8 | 9 | open(FILE, "$name"); 10 | 11 | while() { 12 | if(/(.+) "(.+)"/) { 13 | $var = $1; 14 | $data = $2; 15 | 16 | $datan = $data; 17 | $datan =~ s/\\r/\r/g; 18 | $datan =~ s/\\n/\n/g; 19 | $datan =~ s/\\01/\01/g; 20 | $datan =~ s/\\0/\0/g; 21 | 22 | printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1); 23 | printf(OUTPUTC "/* \"$data\" */\n"); 24 | printf(OUTPUTC "{"); 25 | for($j = 0; $j < length($datan); $j++) { 26 | printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); 27 | } 28 | printf(OUTPUTC "};\n"); 29 | 30 | printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); 31 | 32 | } 33 | } 34 | close(OUTPUTC); 35 | close(OUTPUTH); 36 | } 37 | stringify("http-strings"); 38 | 39 | exit 0; 40 | 41 | -------------------------------------------------------------------------------- /src/libs/PublicData.cpp: -------------------------------------------------------------------------------- 1 | #include "libs/Kernel.h" 2 | #include "PublicData.h" 3 | #include "PublicDataRequest.h" 4 | 5 | bool PublicData::get_value(uint16_t csa, uint16_t csb, uint16_t csc, void *data) { 6 | PublicDataRequest pdr(csa, csb, csc); 7 | // the caller may have created the storage for the returned data so we clear the flag, 8 | // if it gets set by the callee setting the data ptr that means the data is a pointer to a pointer and is set to a pointer to the returned data 9 | pdr.set_data_ptr(data, false); 10 | THEKERNEL->call_event(ON_GET_PUBLIC_DATA, &pdr ); 11 | if(pdr.is_taken() && pdr.has_returned_data()) { 12 | // the callee set the returned data pointer 13 | *(void**)data= pdr.get_data_ptr(); 14 | } 15 | return pdr.is_taken(); 16 | } 17 | 18 | bool PublicData::set_value(uint16_t csa, uint16_t csb, uint16_t csc, void *data) { 19 | PublicDataRequest pdr(csa, csb, csc); 20 | pdr.set_data_ptr(data); 21 | THEKERNEL->call_event(ON_SET_PUBLIC_DATA, &pdr ); 22 | return pdr.is_taken(); 23 | } 24 | -------------------------------------------------------------------------------- /src/modules/tools/temperaturecontrol/TemperatureControlPool.h: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl). 3 | smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version. 4 | smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details. 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see . 6 | */ 7 | 8 | #ifndef TEMPERATURECONTROLPOOL_H 9 | #define TEMPERATURECONTROLPOOL_H 10 | 11 | #include 12 | 13 | class TemperatureControlPool { 14 | public: 15 | void load_tools(); 16 | }; 17 | 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/libs/Network/uip/Network.h: -------------------------------------------------------------------------------- 1 | #ifndef _NETWORK_H 2 | #define _NETWORK_H 3 | 4 | #include "timer.h" 5 | #include "LPC17XX_Ethernet.h" 6 | #include "Module.h" 7 | 8 | 9 | class Network : public Module 10 | { 11 | public: 12 | Network(); 13 | virtual ~Network(); 14 | 15 | void on_module_loaded(); 16 | void on_idle(void* argument); 17 | void on_main_loop(void* argument); 18 | void on_get_public_data(void* argument); 19 | void dhcpc_configured(uint32_t ipaddr, uint32_t ipmask, uint32_t ipgw); 20 | static Network *getInstance() { return instance;} 21 | void tapdev_send(void *pPacket, unsigned int size); 22 | 23 | private: 24 | void init(); 25 | uint32_t tick(uint32_t dummy); 26 | void handlePacket(); 27 | 28 | static Network *instance; 29 | 30 | LPC17XX_Ethernet *ethernet; 31 | 32 | struct timer periodic_timer, arp_timer; 33 | uint8_t mac_address[6]; 34 | uint8_t ipaddr[4]; 35 | uint8_t ipmask[4]; 36 | uint8_t ipgw[4]; 37 | char *hostname; 38 | volatile uint32_t tickcnt; 39 | 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/libs/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H 2 | #define UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using std::string; 9 | using std::vector; 10 | 11 | string lc(const string& str); 12 | 13 | bool is_alpha( int ); 14 | bool is_digit( int ); 15 | bool is_numeric( int ); 16 | bool is_alphanum( int ); 17 | bool is_whitespace( int ); 18 | 19 | vector split(const char *str, char c = ','); 20 | vector parse_number_list(const char *str); 21 | 22 | string remove_non_number( string str ); 23 | 24 | uint16_t get_checksum(const string& to_check); 25 | uint16_t get_checksum(const char* to_check); 26 | 27 | void get_checksums(uint16_t check_sums[], const string& key); 28 | 29 | string shift_parameter( string ¶meters ); 30 | 31 | string get_arguments( string possible_command ); 32 | 33 | bool file_exists( const string file_name ); 34 | 35 | void system_reset( bool dfu= false ); 36 | 37 | string absolute_from_relative( string path ); 38 | 39 | int append_parameters(char *buf, std::vector> params, size_t bufsize); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/modules/tools/zprobe/ThreePointStrategy.h: -------------------------------------------------------------------------------- 1 | #ifndef _THREEPOINTSTRATEGY 2 | #define _THREEPOINTSTRATEGY 3 | 4 | #include "LevelingStrategy.h" 5 | 6 | #include 7 | #include 8 | 9 | #define three_point_leveling_strategy_checksum CHECKSUM("three-point-leveling") 10 | 11 | class StreamOutput; 12 | class Plane3D; 13 | 14 | class ThreePointStrategy : public LevelingStrategy 15 | { 16 | public: 17 | ThreePointStrategy(ZProbe *zprobe); 18 | ~ThreePointStrategy(); 19 | bool handleGcode(Gcode* gcode); 20 | bool handleConfig(); 21 | float getZOffset(float x, float y); 22 | 23 | private: 24 | void homeXY(); 25 | bool doProbing(StreamOutput *stream); 26 | std::tuple parseXY(const char *str); 27 | std::tuple parseXYZ(const char *str); 28 | void setAdjustFunction(bool); 29 | 30 | std::tuple probe_offsets; 31 | std::tuple probe_points[3]; 32 | Plane3D *plane; 33 | struct { 34 | bool home:1; 35 | bool save:1; 36 | }; 37 | float tolerance; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/libs/Vector3.h: -------------------------------------------------------------------------------- 1 | #ifndef _VECTOR3_H 2 | #define _VECTOR3_H 3 | 4 | class Vector3 5 | { 6 | public: 7 | Vector3() = default; 8 | Vector3(float a, float b, float c) : elem{a,b,c} {} 9 | Vector3(const Vector3& to_copy) = default; 10 | 11 | float operator[](int) const; 12 | Vector3 cross(const Vector3&) const; 13 | 14 | float dot(const Vector3&) const; 15 | 16 | float magsq() const; 17 | float mag() const; 18 | 19 | Vector3 add(const Vector3&) const; 20 | Vector3 sub(const Vector3&) const; 21 | 22 | Vector3 mul(float) const; 23 | 24 | Vector3 unit(void) const; 25 | 26 | float * data() { return elem; } 27 | float const* data() const { return elem; } 28 | private: 29 | float elem[3]{}; 30 | }; 31 | 32 | // typedef float Vector3[3]; 33 | 34 | // float* cross_product(Vector3 vec1, Vector3 vec2, Vector3 out); 35 | // float dot_product(Vector3 vec1, Vector3 vec2); 36 | // float magsq(Vector3 vec); 37 | // float* vecsub(Vector3 vec1, Vector3 vec2, Vector3 out) 38 | // float* scalar_mul(Vector3 vec, float scalar, Vector3 out) 39 | 40 | #endif /* _VECTOR3_H */ 41 | -------------------------------------------------------------------------------- /src/modules/utils/panel/Button.h: -------------------------------------------------------------------------------- 1 | #ifndef BUTTON_H 2 | #define BUTTON_H 3 | 4 | #include "libs/Hook.h" 5 | 6 | class Pin; 7 | 8 | class Button 9 | { 10 | public: 11 | Button(); 12 | 13 | Button *pin(Pin *passed_pin); 14 | 15 | void check_signal(); 16 | void check_signal(int val); 17 | void set_longpress_delay(int delay); 18 | bool get(); 19 | 20 | 21 | template Button *up_attach( T *optr, uint32_t ( T::*fptr )( uint32_t ) ) 22 | { 23 | this->up_hook = new Hook(); 24 | this->up_hook->attach(optr, fptr); 25 | return this; 26 | } 27 | 28 | template Button *down_attach( T *optr, uint32_t ( T::*fptr )( uint32_t ) ) 29 | { 30 | this->down_hook = new Hook(); 31 | this->down_hook->attach(optr, fptr); 32 | return this; 33 | } 34 | 35 | private: 36 | Hook *up_hook; 37 | Hook *down_hook; 38 | bool value; 39 | char counter; 40 | Pin *button_pin; 41 | 42 | int longpress_delay; 43 | int first_timer; //delay before starting to repeat 44 | int second_timer; //time beetwen repeats 45 | bool repeat; 46 | }; 47 | 48 | 49 | 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/LinearDeltaSolution.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEARDELTASOLUTION_H 2 | #define LINEARDELTASOLUTION_H 3 | #include "libs/Module.h" 4 | #include "BaseSolution.h" 5 | 6 | class Config; 7 | 8 | class LinearDeltaSolution : public BaseSolution { 9 | public: 10 | LinearDeltaSolution(Config*); 11 | void cartesian_to_actuator(const float[], float[] ); 12 | void actuator_to_cartesian(const float[], float[] ); 13 | 14 | bool set_optional(const arm_options_t& options); 15 | bool get_optional(arm_options_t& options, bool force_all); 16 | 17 | private: 18 | void init(); 19 | 20 | float arm_length; 21 | float arm_radius; 22 | float arm_length_squared; 23 | 24 | float delta_tower1_x; 25 | float delta_tower1_y; 26 | float delta_tower2_x; 27 | float delta_tower2_y; 28 | float delta_tower3_x; 29 | float delta_tower3_y; 30 | float tower1_offset; 31 | float tower2_offset; 32 | float tower3_offset; 33 | float tower1_angle; 34 | float tower2_angle; 35 | float tower3_angle; 36 | }; 37 | #endif // LINEARDELTASOLUTION_H 38 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/RotatableCartesianSolution.cpp: -------------------------------------------------------------------------------- 1 | #include "RotatableCartesianSolution.h" 2 | #include 3 | #include "checksumm.h" 4 | #include "ConfigValue.h" 5 | 6 | // degrees * (pi / 180) = radians 7 | #define DEG2RAD 0.01745329251994329576923690768489 8 | 9 | RotatableCartesianSolution::RotatableCartesianSolution(Config* config) { 10 | float alpha_angle = config->value(alpha_angle_checksum)->by_default(0.0f)->as_number() * DEG2RAD; 11 | sin_alpha = sinf(alpha_angle); 12 | cos_alpha = cosf(alpha_angle); 13 | } 14 | 15 | void RotatableCartesianSolution::cartesian_to_actuator(const float cartesian_mm[], float actuator_mm[] ){ 16 | rotate( cartesian_mm, actuator_mm, sin_alpha, cos_alpha ); 17 | } 18 | 19 | void RotatableCartesianSolution::actuator_to_cartesian(const float actuator_mm[], float cartesian_mm[] ){ 20 | rotate( actuator_mm, cartesian_mm, - sin_alpha, cos_alpha ); 21 | } 22 | 23 | void RotatableCartesianSolution::rotate(const float in[], float out[], float sin, float cos ){ 24 | out[ALPHA_STEPPER] = cos * in[X_AXIS] - sin * in[Y_AXIS]; 25 | out[BETA_STEPPER ] = sin * in[X_AXIS] + cos * in[Y_AXIS]; 26 | out[GAMMA_STEPPER] = in[Z_AXIS]; 27 | } 28 | -------------------------------------------------------------------------------- /src/modules/tools/filamentdetector/FilamentDetector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Module.h" 4 | #include "Pin.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace mbed { 11 | class InterruptIn; 12 | } 13 | 14 | class StreamOutput; 15 | 16 | class FilamentDetector: public Module 17 | { 18 | public: 19 | FilamentDetector(); 20 | ~FilamentDetector(); 21 | void on_module_loaded(); 22 | void on_main_loop(void* argument); 23 | void on_second_tick(void* argument); 24 | void on_console_line_received( void *argument ); 25 | void on_gcode_received(void *argument); 26 | 27 | private: 28 | void on_pin_rise(); 29 | void check_encoder(); 30 | void send_command(std::string msg, StreamOutput *stream); 31 | uint32_t button_tick(uint32_t dummy); 32 | float get_emove(); 33 | 34 | mbed::InterruptIn *encoder_pin{0}; 35 | Pin bulge_pin; 36 | float e_last_moved{0}; 37 | std::atomic_uint pulses{0}; 38 | float pulses_per_mm{0}; 39 | uint8_t seconds_per_check{1}; 40 | uint8_t seconds_passed{0}; 41 | 42 | struct { 43 | bool filament_out_alarm:1; 44 | bool bulge_detected:1; 45 | bool suspended:1; 46 | bool active:1; 47 | }; 48 | }; 49 | -------------------------------------------------------------------------------- /src/modules/tools/zprobe/Plane3D.cpp: -------------------------------------------------------------------------------- 1 | #include "Plane3D.h" 2 | 3 | Plane3D::Plane3D(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) 4 | { 5 | // get the normal of the plane 6 | Vector3 ab = v1.sub(v2); 7 | Vector3 ac = v1.sub(v3); 8 | 9 | Vector3 cp = ab.cross(ac); 10 | normal = cp.unit(); 11 | 12 | // ax+by+cz+d=0 13 | // solve for d 14 | d = -normal.dot(v1); 15 | } 16 | 17 | typedef union { float f; uint32_t u; } conv_t; 18 | // ctor used to restore a saved plane 19 | Plane3D::Plane3D(uint32_t a, uint32_t b, uint32_t c, uint32_t d) 20 | { 21 | conv_t ca, cb, cc, cd; 22 | ca.u= a; cb.u= b; cc.u= c; cd.u= d; 23 | this->normal = Vector3(ca.f, cb.f, cc.f); 24 | this->d= cd.f; 25 | } 26 | 27 | void Plane3D::encode(uint32_t& a, uint32_t& b, uint32_t& c, uint32_t& d) 28 | { 29 | conv_t ca, cb, cc, cd; 30 | ca.f= this->normal[0]; 31 | cb.f= this->normal[1]; 32 | cc.f= this->normal[2]; 33 | cd.f= this->d; 34 | a= ca.u; b= cb.u; c= cc.u; d= cd.u; 35 | } 36 | 37 | // solve for z given x and y 38 | // z= (-ax - by - d)/c 39 | float Plane3D::getz(float x, float y) 40 | { 41 | return ((-normal[0] * x) - (normal[1] * y) - d) / normal[2]; 42 | } 43 | 44 | Vector3 Plane3D::getNormal() const 45 | { 46 | return normal; 47 | } 48 | -------------------------------------------------------------------------------- /src/testframework/unittests/libs/TEST_utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "easyunit/test.h" 8 | 9 | TEST(UtilsTest,split) 10 | { 11 | const char *s= "one two three"; 12 | std::vector v= split(s, ' '); 13 | ASSERT_TRUE(v.size() == 3); 14 | ASSERT_TRUE(v[0] == "one"); 15 | ASSERT_TRUE(v[1] == "two"); 16 | ASSERT_TRUE(v[2] == "three"); 17 | } 18 | 19 | TEST(UtilsTest,split_empty_string) 20 | { 21 | const char *s= ""; 22 | std::vector v= split(s, ' '); 23 | 24 | ASSERT_TRUE(v.size() == 1); 25 | ASSERT_TRUE(v[0].empty()); 26 | ASSERT_TRUE(v[0] == ""); 27 | } 28 | 29 | TEST(UtilsTest,parse_number_list) 30 | { 31 | const char *s= "1.1,2.2,3.3"; 32 | std::vector v= parse_number_list(s); 33 | ASSERT_TRUE(v.size() == 3); 34 | ASSERT_TRUE(v[0] == 1.1F); 35 | ASSERT_TRUE(v[1] == 2.2F); 36 | ASSERT_TRUE(v[2] == 3.3F); 37 | } 38 | 39 | TEST(UtilsTest,append_parameters) 40 | { 41 | char buf[132]; 42 | 43 | int n= append_parameters(buf, {{'X', 1}, {'Y', 2}, {'Z', 3}}, sizeof(buf)); 44 | //printf("%d - %s\n", n, buf); 45 | ASSERT_TRUE(n == 24); 46 | ASSERT_TRUE(strcmp(buf, "X1.0000 Y2.0000 Z3.0000 ") == 0); 47 | } 48 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/JogScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef JOGSCREEN_H 9 | #define JOGSCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | class ControlScreen; 14 | 15 | class JogScreen : public PanelScreen { 16 | public: 17 | JogScreen(); 18 | void on_refresh(); 19 | void on_enter(); 20 | void display_menu_line(uint16_t line); 21 | void clicked_menu_entry(uint16_t line); 22 | 23 | private: 24 | ControlScreen *control_screen; 25 | }; 26 | 27 | 28 | 29 | 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/ExtruderScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef EXTRUDERSCREEN_H 9 | #define EXTRUDERSCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | class ExtruderScreen : public PanelScreen { 14 | public: 15 | ExtruderScreen(); 16 | void on_refresh(); 17 | void on_enter(); 18 | void display_menu_line(uint16_t line); 19 | void clicked_menu_entry(uint16_t line); 20 | int idle_timeout_secs() { return 60; } 21 | 22 | private: 23 | void setupConfigSettings(); 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/modules/tools/temperaturecontrol/PID_Autotuner.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Based on https://github.com/br3ttb/Arduino-PID-AutoTune-Library 3 | */ 4 | 5 | #ifndef _PID_AUTOTUNE_H 6 | #define _PID_AUTOTUNE_H 7 | 8 | #include 9 | 10 | #include "Module.h" 11 | 12 | class TemperatureControl; 13 | class StreamOutput; 14 | 15 | class PID_Autotuner : public Module 16 | { 17 | public: 18 | PID_Autotuner(); 19 | 20 | void on_module_loaded(void); 21 | uint32_t on_tick(uint32_t); 22 | void on_idle(void *); 23 | void on_gcode_received(void *); 24 | 25 | private: 26 | void begin(float, StreamOutput *, int ); 27 | void abort(); 28 | void finishUp(); 29 | 30 | TemperatureControl *temp_control; 31 | float target_temperature; 32 | StreamOutput *s; 33 | 34 | float *peaks; 35 | int requested_cycles; 36 | float noiseBand; 37 | unsigned long peak1, peak2; 38 | int sampleTime; 39 | int nLookBack; 40 | int lookBackCnt; 41 | int peakType; 42 | float *lastInputs; 43 | int peakCount; 44 | float absMax, absMin; 45 | float oStep; 46 | int output; 47 | volatile unsigned long tickCnt; 48 | struct { 49 | bool justchanged:1; 50 | volatile bool tick:1; 51 | bool firstPeak:1; 52 | }; 53 | }; 54 | 55 | #endif /* _PID_AUTOTUNE_H */ 56 | -------------------------------------------------------------------------------- /src/testframework/easyunit/testrunner.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | EasyUnit : Simple C++ Unit testing framework 3 | Copyright (C) 2004 Barthelemy Dagenais 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Barthelemy Dagenais 20 | barthelemy@prologique.com 21 | */ 22 | 23 | #include "testrunner.h" 24 | 25 | 26 | TestRunner::TestRunner() 27 | { 28 | } 29 | 30 | 31 | TestRunner::~TestRunner() 32 | { 33 | } 34 | 35 | void TestRunner::run(TestCase *testCase, int size) 36 | { 37 | for (int i=0; irun(); 39 | testCase = testCase->getNext(); 40 | } 41 | } 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/testframework/easyunit/testharness.h: -------------------------------------------------------------------------------- 1 | /* 2 | EasyUnit : Simple C++ Unit testing framework 3 | Copyright (C) 2004 Barthelemy Dagenais 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Barthelemy Dagenais 20 | barthelemy@prologique.com 21 | */ 22 | 23 | #ifndef TESTHARNESS_H 24 | #define TESTHARNESS_H 25 | 26 | #include "test.h" 27 | #include "testcase.h" 28 | #include "testpartresult.h" 29 | #include "testregistry.h" 30 | #include "simplestring.h" 31 | #include "testprinter.h" 32 | #include "testresult.h" 33 | #include "testrunner.h" 34 | #include "defaulttestprinter.h" 35 | 36 | #endif 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/libs/nuts_bolts.h: -------------------------------------------------------------------------------- 1 | /* 2 | nuts_bolts.h - cartesian robot controller. 3 | Part of Grbl 4 | 5 | Copyright (c) 2009-2011 Simen Svale Skogsrud 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #ifndef nuts_bolts_h 22 | #define nuts_bolts_h 23 | 24 | #define X_AXIS 0 25 | #define Y_AXIS 1 26 | #define Z_AXIS 2 27 | 28 | #define ALPHA_STEPPER 0 29 | #define BETA_STEPPER 1 30 | #define GAMMA_STEPPER 2 31 | 32 | #define clear_vector(a) memset(a, 0, sizeof(a)) 33 | #define clear_vector_float(a) memset(a, 0, sizeof(a)) 34 | 35 | #define confine(value, min, max) (((value) < (min))?(min):(((value) > (max))?(max):(value))) 36 | 37 | #define dd(...) LPC_GPIO2->FIODIR = 0xffff; LPC_GPIO2->FIOCLR = 0xffff; LPC_GPIO2->FIOSET = __VA_ARGS__ 38 | 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /ConfigSamples/README.TXT: -------------------------------------------------------------------------------- 1 | These subdirectories contain samples of config files that can be used with the 2 | Smoothie software to configure it for your particular setup. To use one of 3 | these configuration files with your Smoothie software, just copy the "config" 4 | file found in the appropriate directory to the root of the uSD card on your 5 | Smoothie enabled hardware. 6 | 7 | The full configs found in the ConfigSamples director include: 8 | * Smoothieboard - This directory contains a sample configuration for the 9 | most recent Smoothieboard. http://smoothieware.org/smoothieboard 10 | 11 | * Smoothieboard.delta - This directory contains a sample config for a 12 | Rostock or Kossel style linear delta bot using the most recent Smoothieboard. 13 | 14 | * FirePick.delta - This directory contains a sample config for a 15 | FirePick Rotatable delta bot using a custom Smoothie compatible board, see http://delta.firepick.org 16 | 17 | * AzteegX5Mini - This directory contains a sample config file for using 18 | the Azteeg X5 Mini. 19 | 20 | * Snippets - these are snippets of config that can be included in the main config or copy pasted. 21 | 22 | There are also example config fragments to be be found in the rest of the docs. 23 | 24 | You can find even more information about Smoothie configuration at this URL: 25 | http://smoothieware.org/configuring-smoothie 26 | -------------------------------------------------------------------------------- /ConfigSamples/Snippets/ZprobeGrid.config: -------------------------------------------------------------------------------- 1 | leveling-strategy.ZGrid-leveling.enable true # 2 | leveling-strategy.ZGrid-leveling.bed_x 200 # Bed size 3 | leveling-strategy.ZGrid-leveling.bed_y 200 # Bed Size 4 | 5 | # Machine height, used to determine probe attachment point (bed_z / 2) 6 | leveling-strategy.ZGrid-leveling.bed_z 20 7 | 8 | leveling-strategy.ZGrid-leveling.rows 7 # X divisions (Default 5) 9 | leveling-strategy.ZGrid-leveling.cols 9 # Y divisions (Default 5) 10 | 11 | leveling-strategy.ZGrid-leveling.probe_offsets 5,5,16.3 # 12 | 13 | #leveling-strategy.ZGrid-leveling.slow_feedrate 100 # optional 14 | 15 | #Configure for Machines with bed 0,0 at center of platform 16 | leveling-strategy.ZGrid-leveling.center_zero false 17 | 18 | # configure for Machines with circular beds 19 | leveling-strategy.ZGrid-leveling.circular_bed false 20 | 21 | # The machine can be told to wait for probe attachment and confirmation 22 | leveling-strategy.ZGrid-leveling.wait_for_probe true 23 | 24 | # The machine can be told to home in one of the following modes: 25 | leveling-strategy.ZGrid-leveling.home_before_probe homexyz; # nohome homexy homexyz (default) 26 | 27 | #gamma_max 200 # make sure this is set correctly 28 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/CustomScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef CUSTOMSCREEN_H 9 | #define CUSTOMSCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | #include 14 | #include 15 | 16 | class CustomScreen : public PanelScreen 17 | { 18 | public: 19 | CustomScreen(); 20 | 21 | void on_refresh(); 22 | void on_enter(); 23 | void display_menu_line(uint16_t line); 24 | void clicked_menu_entry(uint16_t line); 25 | int idle_timeout_secs() { return 60; } 26 | 27 | private: 28 | std::vector > menu_items; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/modules/tools/temperaturecontrol/max31855.h: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl). 3 | smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version. 4 | smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details. 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see . 6 | */ 7 | 8 | #ifndef max31855_h 9 | #define max31855_h 10 | 11 | #include "TempSensor.h" 12 | #include 13 | #include 14 | #include 15 | #include "RingBuffer.h" 16 | 17 | class Max31855 : public TempSensor 18 | { 19 | public: 20 | Max31855(); 21 | ~Max31855(); 22 | void UpdateConfig(uint16_t module_checksum, uint16_t name_checksum); 23 | float get_temperature(); 24 | 25 | private: 26 | float read_temp(); 27 | Pin spi_cs_pin; 28 | mbed::SPI *spi; 29 | RingBuffer readings; 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/modules/tools/toolmanager/Tool.h: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl). 3 | smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version. 4 | smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details. 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see . 6 | */ 7 | 8 | #ifndef TOOL_H 9 | #define TOOL_H 10 | 11 | #include "Module.h" 12 | 13 | #include 14 | 15 | class Tool : public Module 16 | { 17 | public: 18 | Tool(){}; 19 | virtual ~Tool() {}; 20 | 21 | virtual void enable(){ enabled= true; } 22 | virtual void disable(){ enabled= false; } 23 | virtual const float *get_offset() const { return offset; } 24 | virtual uint16_t get_name() const { return identifier; } 25 | 26 | protected: 27 | bool enabled; 28 | float offset[3]; 29 | uint16_t identifier; 30 | }; 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/PrepareScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef PREPARESCREEN_H 9 | #define PREPARESCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | class PrepareScreen : public PanelScreen 14 | { 15 | public: 16 | PrepareScreen(); 17 | 18 | void on_refresh(); 19 | void on_enter(); 20 | void display_menu_line(uint16_t line); 21 | void clicked_menu_entry(uint16_t line); 22 | int idle_timeout_secs() { return 60; } 23 | 24 | private: 25 | void preheat(); 26 | void cooldown(); 27 | void setup_temperature_screen(); 28 | 29 | PanelScreen *extruder_screen; 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/modules/communication/GcodeDispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef GCODE_DISPATCH_H 9 | #define GCODE_DISPATCH_H 10 | 11 | #include "libs/Module.h" 12 | 13 | #include 14 | #include 15 | using std::string; 16 | 17 | class GcodeDispatch : public Module 18 | { 19 | public: 20 | GcodeDispatch(); 21 | 22 | virtual void on_module_loaded(); 23 | virtual void on_console_line_received(void *line); 24 | void on_halt(void *arg); 25 | 26 | private: 27 | int currentline; 28 | string upload_filename; 29 | FILE *upload_fd; 30 | uint8_t last_g; 31 | struct { 32 | bool uploading: 1; 33 | bool halted: 1; 34 | }; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/modules/robot/arm_solutions/RotatableDeltaSolution.h: -------------------------------------------------------------------------------- 1 | #ifndef RotatableDeltaSolution_H 2 | #define RotatableDeltaSolution_H 3 | #include "libs/Module.h" 4 | #include "BaseSolution.h" 5 | 6 | class Config; 7 | 8 | class RotatableDeltaSolution : public BaseSolution { 9 | public: 10 | RotatableDeltaSolution(Config*); 11 | void cartesian_to_actuator(const float[], float[] ); 12 | void actuator_to_cartesian(const float[], float[] ); 13 | 14 | bool set_optional(const arm_options_t& options); 15 | bool get_optional(arm_options_t& options, bool force_all); 16 | 17 | private: 18 | void init(); 19 | int delta_calcAngleYZ(float x0, float y0, float z0, float &theta); 20 | int delta_calcForward(float theta1, float theta2, float theta3, float &x0, float &y0, float &z0); 21 | 22 | float delta_e; // End effector length 23 | float delta_f; // Base length 24 | float delta_re; // Carbon rod length 25 | float delta_rf; // Servo horn length 26 | float delta_z_offset ; // Distance from delta 8mm rod/pulley to table/bed 27 | // NOTE: For OpenPnP, set the zero to be about 25mm above the bed 28 | 29 | float delta_ee_offs; // Ball joint plane to bottom of end effector surface 30 | float tool_offset; // Distance between end effector ball joint plane and tip of tool 31 | float z_calc_offset; 32 | }; 33 | #endif // RotatableDeltaSolution_H 34 | -------------------------------------------------------------------------------- /src/modules/tools/toolmanager/ToolManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl). 3 | smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version. 4 | smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details. 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see . 6 | */ 7 | 8 | #ifndef TOOLMANAGER_H 9 | #define TOOLMANAGER_H 10 | 11 | using namespace std; 12 | #include 13 | 14 | class Tool; 15 | 16 | class ToolManager : public Module 17 | { 18 | public: 19 | ToolManager(); 20 | 21 | void on_module_loaded(); 22 | void on_gcode_received(void *); 23 | void on_config_reload(void *); 24 | void on_get_public_data(void *argument); 25 | void on_set_public_data(void *argument); 26 | void add_tool(Tool *tool_to_add); 27 | 28 | private: 29 | vector tools; 30 | 31 | int active_tool; 32 | uint16_t current_tool_name; 33 | bool return_error_on_unhandled_gcode; 34 | }; 35 | 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/modules/utils/configurator/Configurator.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | 9 | #ifndef configurator_h 10 | #define configurator_h 11 | 12 | #include "Module.h" 13 | 14 | #include 15 | using std::string; 16 | 17 | class StreamOutput; 18 | 19 | class Configurator : public Module 20 | { 21 | public: 22 | Configurator() {} 23 | 24 | void on_module_loaded(); 25 | void on_console_line_received( void *argument ); 26 | void on_main_loop( void *argument ); 27 | 28 | void config_get_command( string parameters, StreamOutput *stream ); 29 | void config_set_command( string parameters, StreamOutput *stream ); 30 | void config_load_command(string parameters, StreamOutput *stream ); 31 | }; 32 | 33 | 34 | #endif // configurator_h 35 | -------------------------------------------------------------------------------- /src/libs/Median.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | template 9 | void split(T data[], unsigned int n, T x, unsigned int& i, unsigned int& j) 10 | { 11 | do { 12 | while (data[i] < x) i++; 13 | while (x < data[j]) j--; 14 | 15 | if (i <= j) { 16 | T ii = data[i]; 17 | data[i] = data[j]; 18 | data[j] = ii; 19 | i++; j--; 20 | } 21 | } while (i <= j); 22 | } 23 | 24 | // C.A.R. Hoare's Quick Median 25 | template 26 | unsigned int quick_median(T data[], unsigned int n) 27 | { 28 | unsigned int l = 0, r = n-1, k = n/2; 29 | while (l < r) { 30 | T x = data[k]; 31 | unsigned int i = l, j = r; 32 | split(data, n, x, i, j); 33 | if (j < k) l = i; 34 | if (k < i) r = j; 35 | } 36 | return k; 37 | } 38 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/MainMenuScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef MAINMENUSCREEN_H 9 | #define MAINMENUSCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | class MainMenuScreen : public PanelScreen { 14 | public: 15 | MainMenuScreen(); 16 | void on_refresh(); 17 | void on_enter(); 18 | void display_menu_line(uint16_t line); 19 | void clicked_menu_entry(uint16_t line); 20 | 21 | friend class Panel; 22 | private: 23 | PanelScreen* watch_screen; 24 | PanelScreen* file_screen; 25 | PanelScreen* jog_screen; 26 | PanelScreen* prepare_screen; 27 | 28 | void abort_playing(); 29 | void setupConfigureScreen(); 30 | }; 31 | 32 | 33 | 34 | 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /smoothie-stream.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """\ 3 | Stream g-code to Smoothie telnet connection 4 | 5 | Based on GRBL stream.py 6 | """ 7 | 8 | from __future__ import print_function 9 | import sys 10 | import telnetlib 11 | import argparse 12 | 13 | # Define command line argument interface 14 | parser = argparse.ArgumentParser(description='Stream g-code file to Smoothie over telnet.') 15 | parser.add_argument('gcode_file', type=argparse.FileType('r'), 16 | help='g-code filename to be streamed') 17 | parser.add_argument('ipaddr', 18 | help='Smoothie IP address') 19 | parser.add_argument('-q','--quiet',action='store_true', default=False, 20 | help='suppress output text') 21 | args = parser.parse_args() 22 | 23 | f = args.gcode_file 24 | verbose = not args.quiet 25 | 26 | # Stream g-code to Smoothie 27 | print("Streaming " + args.gcode_file.name + " to " + args.ipaddr) 28 | 29 | tn = telnetlib.Telnet(args.ipaddr) 30 | # read startup prompt 31 | tn.read_until("> ") 32 | 33 | okcnt= 0 34 | linecnt= 0 35 | for line in f: 36 | tn.write(line) 37 | linecnt+=1 38 | rep= tn.read_eager() 39 | okcnt += rep.count("ok") 40 | if verbose: print("SND " + str(linecnt) + ": " + line.strip() + " - " + str(okcnt)) 41 | 42 | print("Waiting for complete...") 43 | 44 | while okcnt < linecnt: 45 | rep= tn.read_some() 46 | okcnt += rep.count("ok") 47 | if verbose: print(str(linecnt) + " - " + str(okcnt) ) 48 | 49 | tn.write("exit\n") 50 | tn.read_all() 51 | 52 | print("Done") 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/ProbeScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef PROBESCREEN_H 9 | #define PROBESCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | #include 14 | 15 | class ProbeScreen : public PanelScreen { 16 | public: 17 | ProbeScreen(); 18 | void on_refresh(); 19 | void on_enter(); 20 | void on_exit(); 21 | void on_main_loop(); 22 | void display_menu_line(uint16_t line); 23 | void clicked_menu_entry(uint16_t line); 24 | int idle_timeout_secs() { return 120; } 25 | 26 | private: 27 | int tcnt; 28 | std::string result; 29 | struct { 30 | bool do_probe:1; 31 | bool do_status:1; 32 | bool new_result:1; 33 | }; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/libs/ConfigSources/FirmConfigSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef FIRMCONFIGSOURCE_H 9 | #define FIRMCONFIGSOURCE_H 10 | 11 | #include "ConfigSource.h" 12 | #include "checksumm.h" 13 | 14 | class ConfigCache; 15 | 16 | using namespace std; 17 | #include 18 | 19 | class FirmConfigSource : public ConfigSource 20 | { 21 | public: 22 | FirmConfigSource(const char *name); 23 | FirmConfigSource(const char* name, const char *start, const char *end); 24 | 25 | void transfer_values_to_cache( ConfigCache *cache ); 26 | bool is_named( uint16_t check_sum ); 27 | bool write( string setting, string value ); 28 | string read( uint16_t check_sums[3] ); 29 | 30 | private: 31 | const char *start, *end; 32 | }; 33 | 34 | 35 | 36 | #endif // FIRMCONFIGSOURCE_H 37 | -------------------------------------------------------------------------------- /src/modules/tools/temperaturecontrol/TempSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl). 3 | smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version. 4 | smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details. 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see . 6 | */ 7 | 8 | #ifndef TEMPSENSOR_H 9 | #define TEMPSENSOR_H 10 | 11 | #include 12 | #include 13 | 14 | class TempSensor 15 | { 16 | public: 17 | virtual ~TempSensor() {} 18 | 19 | // Load config parameters using provided "base" names. 20 | virtual void UpdateConfig(uint16_t module_checksum, uint16_t name_checksum) {} 21 | 22 | // Return temperature in degrees Celsius. 23 | virtual float get_temperature() { return -1.0F; } 24 | 25 | typedef std::map sensor_options_t; 26 | virtual bool set_optional(const sensor_options_t& options) { return false; } 27 | virtual bool get_optional(sensor_options_t& options) { return false; } 28 | virtual void get_raw() {} 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /ConfigSamples/Snippets/psu_off_when_cooled_down.config: -------------------------------------------------------------------------------- 1 | switch.psu.enable true # turn atx on/off 2 | switch.psu.input_on_command M80 # 3 | switch.psu.input_off_command M81 # 4 | switch.psu.output_pin 2.4 # small mosfet 5 | switch.psu.output_type digital # on/off only 6 | 7 | # turn the PSU off when the hotend temp cools below 50, only do this after M1100 S1 has been executed 8 | 9 | temperatureswitch.psu_off.enable true # 10 | temperatureswitch.psu_off.designator T # first character of the temperature control designator to use as the temperature sensor to monitor 11 | temperatureswitch.psu_off.switch psu # select which switch to use, matches the name of the defined switch 12 | temperatureswitch.psu_off.threshold_temp 50.0 # temperature to trigger at when falling 13 | temperatureswitch.psu_off.heatup_poll 30 # poll heatup every 30 seconds 14 | temperatureswitch.psu_off.cooldown_poll 30 # poll cooldown every 30 seconds 15 | temperatureswitch.psu_off.arm_mcode 1100 # M1100 S1 will arm it 16 | temperatureswitch.psu_off.trigger falling # only trigger when the temp falls below after being above 17 | temperatureswitch.psu_off.inverted false # turn the switch off when we trigger (by default switches on when rising and off when falling) 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/FileScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef FILESCREEN_H 9 | #define FILESCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | #include 14 | 15 | class FileScreen : public PanelScreen { 16 | public: 17 | FileScreen(); 18 | void on_enter(); 19 | void on_exit(); 20 | void on_refresh(); 21 | void on_main_loop(); 22 | void clicked_line(uint16_t line); 23 | void display_menu_line(uint16_t line); 24 | 25 | private: 26 | void enter_folder(const char *folder); 27 | uint16_t count_folder_content(); 28 | std::string file_at(uint16_t line, bool& isdir); 29 | bool filter_file(const char *f); 30 | void play(const char *path); 31 | 32 | std::string play_path; 33 | bool start_play; 34 | }; 35 | 36 | 37 | 38 | 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/libs/Network/uip/webserver/http-strings.h: -------------------------------------------------------------------------------- 1 | extern const char http_http[8]; 2 | extern const char http_200[5]; 3 | extern const char http_301[5]; 4 | extern const char http_302[5]; 5 | extern const char http_get[5]; 6 | extern const char http_post[6]; 7 | extern const char http_10[9]; 8 | extern const char http_11[9]; 9 | extern const char http_content_type[15]; 10 | extern const char http_content_length[17]; 11 | extern const char http_cache_control[16]; 12 | extern const char http_no_cache[9]; 13 | extern const char http_texthtml[10]; 14 | extern const char http_location[11]; 15 | extern const char http_host[7]; 16 | extern const char http_crnl[3]; 17 | extern const char http_index_html[12]; 18 | extern const char http_404_html[10]; 19 | extern const char http_referer[9]; 20 | extern const char http_header_200[86]; 21 | extern const char http_header_304[152]; 22 | extern const char http_header_404[61]; 23 | extern const char http_header_503[58]; 24 | extern const char http_content_type_plain[29]; 25 | extern const char http_content_type_html[28]; 26 | extern const char http_content_type_css [27]; 27 | extern const char http_content_type_text[28]; 28 | extern const char http_content_type_png [28]; 29 | extern const char http_content_type_gif [28]; 30 | extern const char http_content_type_jpg [29]; 31 | extern const char http_content_type_binary[43]; 32 | extern const char http_html[6]; 33 | extern const char http_shtml[7]; 34 | extern const char http_htm[5]; 35 | extern const char http_css[5]; 36 | extern const char http_png[5]; 37 | extern const char http_gif[5]; 38 | extern const char http_jpg[5]; 39 | extern const char http_text[5]; 40 | extern const char http_txt[5]; 41 | -------------------------------------------------------------------------------- /src/modules/tools/zprobe/ZGridStrategy.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZGridSTRATEGY 2 | #define _ZGridSTRATEGY 3 | 4 | #include "LevelingStrategy.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define ZGrid_leveling_checksum CHECKSUM("ZGrid-leveling") 11 | 12 | class StreamOutput; 13 | 14 | class ZGridStrategy : public LevelingStrategy 15 | { 16 | public: 17 | ZGridStrategy(ZProbe *zprobe); 18 | ~ZGridStrategy(); 19 | bool handleGcode(Gcode* gcode); 20 | bool handleConfig(); 21 | float getZOffset(float x, float y); 22 | 23 | private: 24 | void homexyz(); 25 | 26 | void move(float *position, float feed); 27 | void next_cal(void); 28 | float getZhomeoffset(); 29 | void setZoffset(float zval); 30 | 31 | void setAdjustFunction(bool); 32 | bool doProbing(StreamOutput *stream); 33 | void normalize_grid(); 34 | 35 | bool loadGrid(std::string args); 36 | bool saveGrid(std::string args); 37 | void calcConfig(); 38 | 39 | std::tuple probe_offsets; 40 | std::tuple parseXYZ(const char *str); 41 | 42 | uint16_t numRows; 43 | uint16_t numCols; 44 | float *pData; 45 | float slow_rate; 46 | float bed_x; 47 | float bed_y; 48 | float bed_z; 49 | float cal_offset_x; 50 | float cal_offset_y; 51 | float bed_div_x; 52 | float bed_div_y; 53 | float cal[3]; // calibration positions for manual leveling 54 | struct { 55 | char home_before_probe:4; 56 | bool in_cal:1; 57 | bool center_zero:1; 58 | bool circular_bed:1; 59 | bool wait_for_probe:1; 60 | }; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/ControlScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef CONTROLSCREEN_H 9 | #define CONTROLSCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | class ControlScreen : public PanelScreen 14 | { 15 | public: 16 | ControlScreen(); 17 | void on_main_loop(); 18 | void on_refresh(); 19 | void on_enter(); 20 | void display_menu_line(uint16_t line); 21 | void set_jog_increment(float i) { jog_increment = i;} 22 | int idle_timeout_secs() { return 120; } 23 | 24 | private: 25 | void clicked_menu_entry(uint16_t line); 26 | void display_axis_line(char axis); 27 | void enter_axis_control(char axis); 28 | void enter_menu_control(); 29 | void get_current_pos(float *p); 30 | void set_current_pos(char axis, float p); 31 | char control_mode; 32 | char controlled_axis; 33 | bool pos_changed; 34 | float pos[3]; 35 | float jog_increment; 36 | }; 37 | 38 | 39 | 40 | 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/modules/tools/switch/SwitchPool.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #include "libs/Module.h" 9 | #include "libs/Kernel.h" 10 | #include 11 | using namespace std; 12 | #include 13 | #include "SwitchPool.h" 14 | #include "Switch.h" 15 | #include "Config.h" 16 | #include "checksumm.h" 17 | #include "ConfigValue.h" 18 | 19 | #define switch_checksum CHECKSUM("switch") 20 | #define enable_checksum CHECKSUM("enable") 21 | 22 | void SwitchPool::load_tools() 23 | { 24 | vector modules; 25 | THEKERNEL->config->get_module_list( &modules, switch_checksum ); 26 | 27 | for( unsigned int i = 0; i < modules.size(); i++ ) { 28 | // If module is enabled 29 | if( THEKERNEL->config->value(switch_checksum, modules[i], enable_checksum )->as_bool() == true ) { 30 | Switch *controller = new Switch(modules[i]); 31 | THEKERNEL->add_module(controller); 32 | } 33 | } 34 | 35 | } 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/libs/Network/uip/webserver/http-strings: -------------------------------------------------------------------------------- 1 | http_http "http://" 2 | http_200 "200 " 3 | http_301 "301 " 4 | http_302 "302 " 5 | http_get "GET " 6 | http_post "POST " 7 | http_10 "HTTP/1.0" 8 | http_11 "HTTP/1.1" 9 | http_content_type "content-type: " 10 | http_content_length "Content-Length: " 11 | http_cache_control "Cache-Control: " 12 | http_no_cache "no-cache" 13 | http_texthtml "text/html" 14 | http_location "location: " 15 | http_host "host: " 16 | http_crnl "\r\n" 17 | http_index_html "/index.html" 18 | http_404_html "/404.html" 19 | http_referer "Referer:" 20 | http_header_200 "HTTP/1.0 200 OK\r\nServer: uIP/1.0\r\nAccess-Control-Allow-Origin: *\r\nConnection: close\r\n" 21 | http_header_304 "HTTP/1.0 304 Not Modified\r\nServer: uIP/1.0\r\nConnection: close\r\nExpires: Thu, 31 Dec 2037 23:55:55 GMT\r\nCache-Control: max-age=315360000\r\nX-Cache: HIT\r\n" 22 | http_header_404 "HTTP/1.0 404 Not found\r\nServer: uIP/1.0\r\nConnection: close\r\n" 23 | http_header_503 "HTTP/1.0 503 Failed\r\nServer: uIP/1.0\r\nConnection: close\r\n" 24 | http_content_type_plain "Content-type: text/plain\r\n\r\n" 25 | http_content_type_html "Content-type: text/html\r\n\r\n" 26 | http_content_type_css "Content-type: text/css\r\n\r\n" 27 | http_content_type_text "Content-type: text/text\r\n\r\n" 28 | http_content_type_png "Content-type: image/png\r\n\r\n" 29 | http_content_type_gif "Content-type: image/gif\r\n\r\n" 30 | http_content_type_jpg "Content-type: image/jpeg\r\n\r\n" 31 | http_content_type_binary "Content-type: application/octet-stream\r\n\r\n" 32 | http_html ".html" 33 | http_shtml ".shtml" 34 | http_htm ".htm" 35 | http_css ".css" 36 | http_png ".png" 37 | http_gif ".gif" 38 | http_jpg ".jpg" 39 | http_text ".txt" 40 | http_txt ".txt" 41 | 42 | -------------------------------------------------------------------------------- /src/libs/Network/uip/CallbackStream.cpp: -------------------------------------------------------------------------------- 1 | #include "CallbackStream.h" 2 | #include "Kernel.h" 3 | #include 4 | 5 | #include "SerialConsole.h" 6 | #define DEBUG_PRINTF THEKERNEL->serial->printf 7 | 8 | CallbackStream::CallbackStream(cb_t cb, void *u) 9 | { 10 | DEBUG_PRINTF("Callbackstream ctor: %p\n", this); 11 | callback= cb; 12 | user= u; 13 | closed= false; 14 | use_count= 0; 15 | } 16 | 17 | CallbackStream::~CallbackStream() 18 | { 19 | DEBUG_PRINTF("Callbackstream dtor: %p\n", this); 20 | } 21 | 22 | int CallbackStream::puts(const char *s) 23 | { 24 | if(closed) return 0; 25 | 26 | if(s == NULL) return (*callback)(NULL, user); 27 | 28 | int len = strlen(s); 29 | int n; 30 | do { 31 | // call this streams result callback 32 | n= (*callback)(s, user); 33 | 34 | // if closed just pretend we sent it 35 | if(n == -1) { 36 | closed= true; 37 | return len; 38 | 39 | }else if(n == 0) { 40 | // if output queue is full 41 | // call idle until we can output more 42 | THEKERNEL->call_event(ON_IDLE); 43 | } 44 | } while(n == 0); 45 | 46 | return len; 47 | } 48 | 49 | void CallbackStream::mark_closed() 50 | { 51 | closed= true; 52 | if(use_count <= 0) delete this; 53 | } 54 | void CallbackStream::dec() 55 | { 56 | use_count--; 57 | if(closed && use_count <= 0) delete this; 58 | } 59 | 60 | extern "C" void *new_callback_stream(cb_t cb, void *u) 61 | { 62 | return new CallbackStream(cb, u); 63 | } 64 | 65 | extern "C" void delete_callback_stream(void *p) 66 | { 67 | // we don't delete it in case it is still on the command queue 68 | ((CallbackStream*)p)->mark_closed(); 69 | } 70 | -------------------------------------------------------------------------------- /src/modules/utils/currentcontrol/ad5206.h: -------------------------------------------------------------------------------- 1 | #ifndef AD5206_H 2 | #define AD5206_H 3 | 4 | #include "libs/Kernel.h" 5 | #include "libs/utils.h" 6 | #include 7 | #include "mbed.h" 8 | #include 9 | #include 10 | 11 | class AD5206 : public DigipotBase { 12 | public: 13 | AD5206(){ 14 | this->spi= new mbed::SPI(PB_5,PB_4,PB_3); //should be able to set those pins in config 15 | cs.from_string("C.15")->as_output(); //this also should be configurable 16 | cs.set(1); 17 | for (int i = 0; i < 6; i++) currents[i] = -1; 18 | } 19 | 20 | void set_current( int channel, float current ) 21 | { 22 | if(channel<6){ 23 | if(current < 0) { 24 | currents[channel]= -1; 25 | return; 26 | } 27 | current = min( max( current, 0.0F ), 2.0F ); 28 | char adresses[6] = { 0x05, 0x03, 0x01, 0x00, 0x02, 0x04 }; 29 | currents[channel] = current; 30 | cs.set(0); 31 | spi->write((int)adresses[channel]); 32 | spi->write((int)current_to_wiper(current)); 33 | cs.set(1); 34 | } 35 | } 36 | 37 | 38 | //taken from 4pi firmware 39 | unsigned char current_to_wiper( float current ){ 40 | unsigned int count = int((current*1000)*100/743); //6.8k resistor and 10k pot 41 | 42 | return (unsigned char)count; 43 | } 44 | 45 | float get_current(int channel) 46 | { 47 | if(channel < 6) 48 | return currents[channel]; 49 | return -1; 50 | } 51 | 52 | private: 53 | 54 | Pin cs; 55 | mbed::SPI* spi; 56 | float currents[6]; 57 | }; 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/testframework/easyunit/testrunner.h: -------------------------------------------------------------------------------- 1 | /* 2 | EasyUnit : Simple C++ Unit testing framework 3 | Copyright (C) 2004 Barthelemy Dagenais 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Barthelemy Dagenais 20 | barthelemy@prologique.com 21 | */ 22 | 23 | #ifndef TestRunner_H 24 | #define TestRunner_H 25 | 26 | #include "testcase.h" 27 | 28 | 29 | 30 | /** 31 | * Test runner used to determine which test to run. 32 | * 33 | * User may extends this class to provide a custom test runner 34 | * to TestRegistry. 35 | */ 36 | class TestRunner 37 | { 38 | public: 39 | TestRunner(); 40 | virtual ~TestRunner(); 41 | 42 | /** 43 | * Method used to run testcases by TestRegistry. 44 | * 45 | * User should override this method in order to provide custom 46 | * behavior. 47 | * 48 | * @param testCase Linked list of testcases 49 | * @param size Size of the linked list 50 | */ 51 | virtual void run(TestCase *testCase, int size); 52 | 53 | }; 54 | 55 | 56 | #endif // TestRunner_H 57 | 58 | -------------------------------------------------------------------------------- /src/libs/StreamOutputPool.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef STREAMOUTPUTPOOL_H 9 | #define STREAMOUTPUTPOOL_H 10 | 11 | using namespace std; 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "libs/StreamOutput.h" 18 | 19 | class StreamOutputPool : public StreamOutput { 20 | 21 | public: 22 | StreamOutputPool(){ 23 | } 24 | 25 | int puts(const char* s) 26 | { 27 | int r = 0; 28 | for(set::iterator i = this->streams.begin(); i != this->streams.end(); i++) 29 | { 30 | int k = (*i)->puts(s); 31 | if (k > r) 32 | r = k; 33 | } 34 | return r; 35 | } 36 | 37 | void append_stream(StreamOutput* stream) 38 | { 39 | this->streams.insert(stream); 40 | } 41 | 42 | void remove_stream(StreamOutput* stream) 43 | { 44 | this->streams.erase(stream); 45 | } 46 | 47 | private: 48 | set streams; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/modules/tools/scaracal/SCARAcal.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef SCARACAL_H_ 9 | #define SCARACAL_H_ 10 | 11 | #include "Module.h" 12 | #include "Pin.h" 13 | 14 | class StepperMotor; 15 | class Gcode; 16 | class StreamOutput; 17 | 18 | class SCARAcal: public Module 19 | { 20 | 21 | public: 22 | void on_module_loaded(); 23 | void on_config_reload(void *argument); 24 | 25 | void on_gcode_received(void *argument); 26 | 27 | 28 | private: 29 | void home(); 30 | bool set_trim(float x, float y, float z, StreamOutput *stream); 31 | bool get_trim(float& x, float& y, float& z); 32 | 33 | bool set_home_offset(float x, float y, float z, StreamOutput *stream); 34 | bool get_home_offset(float& x, float& y, float& z); 35 | 36 | bool translate_trim(StreamOutput *stream); 37 | 38 | void SCARA_ang_move(float theta, float psi, float z, float feedrate); 39 | 40 | float slow_rate; 41 | 42 | struct { 43 | bool is_scara:1; 44 | }; 45 | }; 46 | 47 | #endif /* SCARACAL_H_ */ 48 | -------------------------------------------------------------------------------- /src/testframework/easyunit/testprinter.h: -------------------------------------------------------------------------------- 1 | /* 2 | EasyUnit : Simple C++ Unit testing framework 3 | Copyright (C) 2004 Barthelemy Dagenais 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Barthelemy Dagenais 20 | barthelemy@prologique.com 21 | */ 22 | 23 | #ifndef TESTPRINTER_H 24 | #define TESTPRINTER_H 25 | 26 | #include "testresult.h" 27 | 28 | 29 | /** 30 | * A TestPrinter is a class used by the TestRegistry to print results 31 | * of executed TestCases. This is an abstract class, so no default behavior 32 | * for the print method is provided. 33 | * 34 | * @see DefaultTestPrinter 35 | */ 36 | class TestPrinter 37 | { 38 | public: 39 | virtual ~TestPrinter(){}; 40 | /** 41 | * Print the details of a given TestResult instance. This 42 | * method must be overridden by subclasses since it is 43 | * abstract. 44 | * 45 | * @param testResult TestResult instance that the user wish to print 46 | */ 47 | virtual void print(const TestResult *testResult) = 0; 48 | }; 49 | 50 | #endif // TESTPRINTER_H 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/libs/ConfigSources/FileConfigSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef FILECONFIGSOURCE_H 9 | #define FILECONFIGSOURCE_H 10 | 11 | #include "ConfigSource.h" 12 | 13 | class ConfigCache; 14 | 15 | using namespace std; 16 | #include 17 | #include 18 | 19 | class FileConfigSource : public ConfigSource 20 | { 21 | public: 22 | FileConfigSource(string config_file, const char *name); 23 | void transfer_values_to_cache( ConfigCache *cache ); 24 | void transfer_values_to_cache( ConfigCache *cache, const char * file_name ); 25 | bool is_named( uint16_t check_sum ); 26 | bool write( string setting, string value ); 27 | string read( uint16_t check_sums[3] ); 28 | bool has_config_file(); 29 | void try_config_file(string candidate); 30 | string get_config_file(); 31 | 32 | private: 33 | bool readLine(string& line, int lineno, FILE *fp); 34 | string config_file; // Path to the config file 35 | bool config_file_found; // Wether or not the config file's location is known 36 | }; 37 | 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/WatchScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef WATCHSCREEN_H 9 | #define WATCHSCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | #include 14 | 15 | class WatchScreen : public PanelScreen 16 | { 17 | public: 18 | WatchScreen(); 19 | ~WatchScreen(); 20 | void on_refresh(); 21 | void on_enter(); 22 | void on_main_loop(); 23 | void display_menu_line(uint16_t line); 24 | 25 | private: 26 | void get_current_status(); 27 | float get_current_speed(); 28 | void set_speed(); 29 | void get_current_pos(float *cp); 30 | void get_sd_play_info(); 31 | const char *get_status(); 32 | const char *get_network(); 33 | 34 | std::vector temp_controllers; 35 | 36 | uint32_t update_counts; 37 | int current_speed; 38 | float pos[3]; 39 | unsigned long elapsed_time; 40 | unsigned int sd_pcnt_played; 41 | char *ipstr; 42 | 43 | struct { 44 | bool speed_changed:1; 45 | bool issue_change_speed:1; 46 | bool fan_state:1; 47 | }; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/modules/robot/Planner.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef PLANNER_H 9 | #define PLANNER_H 10 | 11 | class Block; 12 | 13 | class Planner 14 | { 15 | public: 16 | Planner(); 17 | void append_block( float target[], float rate_mm_s, float distance, float unit_vec[] ); 18 | float max_allowable_speed( float acceleration, float target_velocity, float distance); 19 | void recalculate(); 20 | Block *get_current_block(); 21 | void cleanup_queue(); 22 | float get_acceleration() const { return acceleration; } 23 | float get_z_acceleration() const { return z_acceleration > 0.0F ? z_acceleration : acceleration; } 24 | 25 | friend class Robot; // for acceleration, junction deviation, minimum_planner_speed 26 | 27 | private: 28 | void config_load(); 29 | float previous_unit_vec[3]; 30 | float acceleration; // Setting 31 | float z_acceleration; // Setting 32 | float junction_deviation; // Setting 33 | float z_junction_deviation; // Setting 34 | float minimum_planner_speed; // Setting 35 | }; 36 | 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/libs/ConfigSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef CONFIGSOURCE_H 9 | #define CONFIGSOURCE_H 10 | 11 | using namespace std; 12 | #include 13 | #include 14 | 15 | class ConfigValue; 16 | class ConfigCache; 17 | 18 | class ConfigSource { 19 | public: 20 | ConfigSource(){} 21 | virtual ~ConfigSource(){} 22 | 23 | // Read each value, and append it as a ConfigValue to the config_cache we were passed 24 | virtual void transfer_values_to_cache( ConfigCache* ) = 0; 25 | virtual bool is_named( uint16_t check_sum ) = 0; 26 | virtual bool write( string setting, string value ) = 0; 27 | virtual string read( uint16_t check_sums[3] ) = 0; 28 | 29 | protected: 30 | virtual ConfigValue* process_line_from_ascii_config(const string& line, ConfigCache* cache); 31 | virtual string process_line_from_ascii_config(const string& line, uint16_t line_checksums[3]); 32 | uint16_t name_checksum; 33 | 34 | private: 35 | ConfigValue* process_line(const string &buffer); 36 | }; 37 | 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/libs/ConfigCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef CONFIGCACHE_H 9 | #define CONFIGCACHE_H 10 | 11 | using namespace std; 12 | #include 13 | #include 14 | #include 15 | 16 | class ConfigValue; 17 | class StreamOutput; 18 | 19 | class ConfigCache { 20 | public: 21 | ConfigCache(); 22 | ~ConfigCache(); 23 | void clear(); 24 | 25 | void add(ConfigValue* v); 26 | 27 | // lookup and return the entru that matches the check sums,return NULL if not found 28 | ConfigValue *lookup(const uint16_t *check_sums) const; 29 | 30 | // collect enabled checksums of the given family 31 | void collect(uint16_t family, uint16_t cs, vector *list); 32 | 33 | // If we find an existing value, replace it, otherwise, push it at the back of the list 34 | void replace_or_push_back(ConfigValue* new_value); 35 | 36 | // used for debugging, dumps the cache to a stream 37 | void dump(StreamOutput *stream); 38 | 39 | private: 40 | typedef vector storage_t; 41 | storage_t store; 42 | }; 43 | 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/libs/MemoryPool.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMORYPOOL_H 2 | #define _MEMORYPOOL_H 3 | 4 | #include 5 | // #include 6 | #include 7 | 8 | #ifdef MEMDEBUG 9 | #define MDEBUG(...) printf(__VA_ARGS__) 10 | #else 11 | #define MDEBUG(...) do {} while (0) 12 | #endif 13 | 14 | class StreamOutput; 15 | 16 | /* 17 | * with MUCH thanks to http://www.parashift.com/c++-faq-lite/memory-pools.html 18 | * 19 | * test framework at https://gist.github.com/triffid/5563987 20 | */ 21 | 22 | class MemoryPool 23 | { 24 | public: 25 | MemoryPool(void* base, uint16_t size); 26 | ~MemoryPool(); 27 | 28 | void* alloc(size_t); 29 | void dealloc(void* p); 30 | 31 | void debug(StreamOutput*); 32 | 33 | bool has(void*); 34 | 35 | uint32_t free(void); 36 | 37 | MemoryPool* next; 38 | 39 | static MemoryPool* first; 40 | 41 | private: 42 | void* base; 43 | uint16_t size; 44 | }; 45 | 46 | // this overloads "placement new" 47 | inline void* operator new(size_t nbytes, MemoryPool& pool) 48 | { 49 | return pool.alloc(nbytes); 50 | } 51 | 52 | // this allows placement new to free memory if the constructor fails 53 | inline void operator delete(void* p, MemoryPool& pool) 54 | { 55 | pool.dealloc(p); 56 | } 57 | 58 | // this catches all usages of delete blah. The object's destructor is called before we get here 59 | // it first checks if the deleted object is part of a pool, and uses free otherwise. 60 | inline void operator delete(void* p) 61 | { 62 | MemoryPool* m = MemoryPool::first; 63 | while (m) 64 | { 65 | if (m->has(p)) 66 | { 67 | MDEBUG("Pool %p has %p, using dealloc()\n", m, p); 68 | m->dealloc(p); 69 | return; 70 | } 71 | m = m->next; 72 | } 73 | 74 | MDEBUG("no pool has %p, using free()\n", p); 75 | free(p); 76 | } 77 | 78 | #endif /* _MEMORYPOOL_H */ 79 | -------------------------------------------------------------------------------- /src/libs/Network/uip/CommandQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "CommandQueue.h" 2 | 3 | #include "stdio.h" 4 | #include "string.h" 5 | #include "stdlib.h" 6 | 7 | #include "Kernel.h" 8 | #include "libs/SerialMessage.h" 9 | #include "CallbackStream.h" 10 | 11 | static CommandQueue *command_queue_instance; 12 | CommandQueue *CommandQueue::instance = NULL; 13 | 14 | 15 | CommandQueue::CommandQueue() 16 | { 17 | command_queue_instance = this; 18 | null_stream= &(StreamOutput::NullStream); 19 | } 20 | 21 | CommandQueue* CommandQueue::getInstance() 22 | { 23 | if(instance == 0) instance= new CommandQueue(); 24 | return instance; 25 | } 26 | 27 | extern "C" { 28 | int network_add_command(const char *cmd, void *pstream) 29 | { 30 | return command_queue_instance->add(cmd, (StreamOutput*)pstream); 31 | } 32 | } 33 | 34 | int CommandQueue::add(const char *cmd, StreamOutput *pstream) 35 | { 36 | cmd_t c= {strdup(cmd), pstream==NULL?null_stream:pstream}; 37 | q.push(c); 38 | if(pstream != NULL) { 39 | // count how many times this is on the queue 40 | CallbackStream *s= static_cast(pstream); 41 | s->inc(); 42 | } 43 | return q.size(); 44 | } 45 | 46 | // pops the next command off the queue and submits it. 47 | bool CommandQueue::pop() 48 | { 49 | if (q.size() == 0) return false; 50 | 51 | cmd_t c= q.pop(); 52 | char *cmd= c.str; 53 | 54 | struct SerialMessage message; 55 | message.message = cmd; 56 | message.stream = c.pstream; 57 | 58 | free(cmd); 59 | THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message ); 60 | 61 | if(message.stream != null_stream) { 62 | message.stream->puts(NULL); // indicates command is done 63 | // decrement usage count 64 | CallbackStream *s= static_cast(message.stream); 65 | s->dec(); 66 | } 67 | return true; 68 | } 69 | -------------------------------------------------------------------------------- /src/libs/StreamOutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef STREAMOUTPUT_H 9 | #define STREAMOUTPUT_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | // This is a base class for all StreamOutput objects. 16 | // StreamOutputs are basically "things you can sent strings to". They are passed along with gcodes for example so modules can answer to those gcodes. 17 | // They are usually associated with a command source, but can also be a NullStreamOutput if we just want to ignore whatever is sent 18 | 19 | class NullStreamOutput; 20 | 21 | class StreamOutput { 22 | public: 23 | StreamOutput(){} 24 | virtual ~StreamOutput(){} 25 | 26 | virtual int printf(const char *format, ...) __attribute__ ((format(printf, 2, 3))); 27 | virtual int _putc(int c) { return 1; } 28 | virtual int _getc(void) { return 0; } 29 | virtual int puts(const char* str) = 0; 30 | virtual bool ready() { return true; }; 31 | 32 | static NullStreamOutput NullStream; 33 | }; 34 | 35 | class NullStreamOutput : public StreamOutput { 36 | public: 37 | int puts(const char* str) { return strlen(str); } 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /README.creole: -------------------------------------------------------------------------------- 1 | == STM32 2 | This repository holds a hacked version of smoothieboard which works with a NUCLEO F411RE: https://developer.mbed.org/platforms/ST-Nucleo-F411RE/ 3 | Currently, the motion stuff is working. The ADC is still stubbed and needs to be configured in scan mode. 4 | 5 | 6 | ==Overview 7 | Smoothie is a free, opensource, high performance G-code interpreter and CNC controller written in Object-Oriented C++ for the LPC17xx micro-controller ( ARM Cortex M3 architecture ). It will run on a mBed, a LPCXpresso, a SmoothieBoard, R2C2 or any other LPC17xx-based board. The motion control part is a port of the awesome grbl. 8 | 9 | Documentation can be found here : [[http://smoothieware.org/]] 10 | 11 | NOTE it is not necessary to build Smoothie yourself unless you want to. prebuilt binaries are availble here http://builds.smoothieware.org/ 12 | 13 | ==Quick Start 14 | These are the quick steps to get Smoothie dependencies installed on your computer: 15 | * Pull down a clone of the Smoothie github project to your local machine. 16 | * In the root subdirectory of the cloned Smoothie project, there are install scripts for the supported platforms. Run the install script appropriate for your platform: 17 | ** Windows: win_install.cmd 18 | ** OS X: mac_install 19 | ** Linux: linux_install 20 | * You can then run the BuildShell script which will be created during the install to properly configure the PATH environment variable to point to the required version of GCC for ARM which was just installed on your machine. You may want to edit this script to further customize your development environment. 21 | 22 | ==Building Smoothie 23 | From a shell, switch into the root Smoothie project directory and run: 24 | {{{ 25 | make clean 26 | make all 27 | }}} 28 | 29 | To upload you can do 30 | 31 | {{{ 32 | make upload 33 | }}} 34 | 35 | if you have dfu-util installed. 36 | 37 | Alternatively copy the file LPC1768/main.bin to the sdcard calling it firmware.bin and reset. 38 | -------------------------------------------------------------------------------- /src/modules/utils/panel/PanelScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef PANELSCREEN_H 9 | #define PANELSCREEN_H 10 | 11 | #include 12 | #include 13 | 14 | class Panel; 15 | 16 | class PanelScreen 17 | { 18 | public: 19 | PanelScreen(); 20 | virtual ~PanelScreen(); 21 | 22 | virtual void on_refresh(); 23 | virtual void on_main_loop(); 24 | PanelScreen *set_parent(PanelScreen *passed_parent); 25 | virtual void on_enter(); 26 | virtual void on_exit(){}; 27 | // if you completely rewrite the screen do not clear it, this avoids flicker 28 | void refresh_screen(bool clear); 29 | void refresh_menu(bool clear); 30 | void refresh_menu(void) { refresh_menu(true); }; 31 | virtual void display_menu_line(uint16_t line) = 0; 32 | // default idle timeout for a screen, each screen can override this 33 | virtual int idle_timeout_secs(){ return 10; } 34 | 35 | friend class Panel; 36 | protected: 37 | void send_gcode(std::string g); 38 | void send_gcode(const char *gm_code, char parameter, float value); 39 | void send_command(const char *gcstr); 40 | static std::deque command_queue; 41 | PanelScreen *parent; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/modules/tools/drillingcycles/Drillingcycles.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef DRILLINGCYCLES_MODULE_H 9 | #define DRILLINGCYCLES_MODULE_H 10 | 11 | #include "libs/Module.h" 12 | 13 | class Gcode; 14 | 15 | class Drillingcycles : public Module 16 | { 17 | public: 18 | Drillingcycles(); 19 | virtual ~Drillingcycles() {}; 20 | void on_module_loaded(); 21 | 22 | private: 23 | void on_config_reload(void *argument); 24 | void on_gcode_received(void *argument); 25 | void reset_sticky(); 26 | void update_sticky(Gcode *gcode); 27 | int send_gcode(const char* format, ...); 28 | void make_hole(Gcode *gcode); 29 | void peck_hole(); 30 | 31 | bool cycle_started; // cycle status 32 | int retract_type; // rretract type 33 | 34 | float initial_z; // Initial-Z 35 | float r_plane; // R-Plane 36 | 37 | float sticky_z; // final depth 38 | float sticky_r; // R-Plane 39 | float sticky_f; // feedrate 40 | 41 | float sticky_q; // depth increment 42 | int sticky_p; // dwell pause 43 | 44 | int dwell_units; // units for dwell 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/modules/communication/SerialConsole.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef SERIALCONSOLE_H 9 | #define SERIALCONSOLE_H 10 | 11 | #include "libs/Module.h" 12 | #include "Serial.h" // mbed.h lib 13 | #include "libs/Kernel.h" 14 | #include 15 | #include 16 | using std::string; 17 | #include "libs/RingBuffer.h" 18 | #include "libs/StreamOutput.h" 19 | 20 | 21 | #define baud_rate_setting_checksum CHECKSUM("baud_rate") 22 | 23 | class SerialConsole : public Module, public StreamOutput { 24 | public: 25 | SerialConsole( PinName rx_pin, PinName tx_pin, int baud_rate ); 26 | 27 | void on_module_loaded(); 28 | void on_serial_char_received(); 29 | void on_main_loop(void * argument); 30 | bool has_char(char letter); 31 | 32 | int _putc(int c); 33 | int _getc(void); 34 | int puts(const char*); 35 | 36 | //string receive_buffer; // Received chars are stored here until a newline character is received 37 | //vector received_lines; // Received lines are stored here until they are requested 38 | RingBuffer buffer; // Receive buffer 39 | mbed::Serial* serial; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/libs/Network/uip/plan9/plan9.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLAN9_H__ 2 | #define __PLAN9_H__ 3 | 4 | /* 5 | * 9P network filesystem protocol 6 | * 7 | * by Daniel Mendler 8 | * 9 | * Resources: 10 | * 11 | * - Documentation: http://9p.cat-v.org/ 12 | * - List of implementations: http://9p.cat-v.org/implementations 13 | * - Specification: http://ericvh.github.io/9p-rfc/ 14 | * - Linux documentation: https://www.kernel.org/doc/Documentation/filesystems/9p.txt 15 | * 16 | * How to use it: 17 | * 18 | * 1. Add "network.plan9.enable true" to the config 19 | * 2. Mount under Linux with "mount -t 9p $ip /mnt/smoothie 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | extern "C" { 28 | #include "psock.h" 29 | } 30 | 31 | class Plan9 32 | { 33 | public: 34 | Plan9(); 35 | ~Plan9(); 36 | 37 | static void init(); 38 | static void appcall(); 39 | 40 | struct EntryData { 41 | uint8_t type; 42 | int refcount; 43 | 44 | EntryData() {} 45 | EntryData(uint8_t t) 46 | : type(t), refcount(0) {} 47 | }; 48 | 49 | typedef std::map EntryMap; 50 | typedef EntryMap::value_type* Entry; 51 | typedef std::map FidMap; 52 | union Message; 53 | 54 | private: 55 | int receive(); 56 | int send(); 57 | bool process(Message*, Message*); 58 | 59 | Entry add_entry(uint32_t, uint8_t, const std::string&); 60 | Entry get_entry(uint32_t); 61 | bool add_fid(uint32_t, Entry); 62 | void remove_fid(uint32_t); 63 | 64 | static const uint32_t INITIAL_MSIZE = 300; 65 | EntryMap entries; 66 | FidMap fids; 67 | psock sin, sout; 68 | char bufin[INITIAL_MSIZE], bufout[INITIAL_MSIZE]; 69 | std::queue queue; 70 | uint32_t msize, queue_bytes; 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/libs/Vector3.cpp: -------------------------------------------------------------------------------- 1 | #include "Vector3.h" 2 | 3 | #include 4 | #include 5 | 6 | float Vector3::operator[](int i) const 7 | { 8 | if (i >= 0 && i <= 2) 9 | return elem[i]; 10 | return NAN; 11 | } 12 | 13 | Vector3 Vector3::cross(const Vector3 &vec) const 14 | { 15 | Vector3 out; 16 | 17 | out.elem[0] = elem[1] * vec.elem[2] - elem[2] * vec.elem[1]; 18 | out.elem[1] = elem[2] * vec.elem[0] - elem[0] * vec.elem[2]; 19 | out.elem[2] = elem[0] * vec.elem[1] - elem[1] * vec.elem[0]; 20 | 21 | return out; 22 | } 23 | 24 | float Vector3::dot(const Vector3 &vec) const 25 | { 26 | return elem[0] * vec.elem[0] + 27 | elem[1] * vec.elem[1] + 28 | elem[2] * vec.elem[2]; 29 | } 30 | 31 | float Vector3::magsq() const 32 | { 33 | return powf(elem[0], 2) + 34 | powf(elem[1], 2) + 35 | powf(elem[2], 2); 36 | } 37 | 38 | float Vector3::mag() const 39 | { 40 | return sqrtf(magsq()); 41 | } 42 | 43 | Vector3 Vector3::add(const Vector3 &vec) const 44 | { 45 | Vector3 out; 46 | 47 | out.elem[0] = elem[0] + vec.elem[0]; 48 | out.elem[1] = elem[1] + vec.elem[1]; 49 | out.elem[2] = elem[2] + vec.elem[2]; 50 | 51 | return out; 52 | } 53 | 54 | Vector3 Vector3::sub(const Vector3 &vec) const 55 | { 56 | Vector3 out; 57 | 58 | out.elem[0] = elem[0] - vec.elem[0]; 59 | out.elem[1] = elem[1] - vec.elem[1]; 60 | out.elem[2] = elem[2] - vec.elem[2]; 61 | 62 | return out; 63 | } 64 | 65 | Vector3 Vector3::mul(float scalar) const 66 | { 67 | Vector3 out; 68 | 69 | out.elem[0] = elem[0] * scalar; 70 | out.elem[1] = elem[1] * scalar; 71 | out.elem[2] = elem[2] * scalar; 72 | 73 | return out; 74 | } 75 | 76 | Vector3 Vector3::unit() const 77 | { 78 | Vector3 out; 79 | 80 | float denom = mag(); 81 | 82 | out.elem[0] = elem[0] / denom; 83 | out.elem[1] = elem[1] / denom; 84 | out.elem[2] = elem[2] / denom; 85 | 86 | return out; 87 | } 88 | -------------------------------------------------------------------------------- /src/modules/tools/temperaturecontrol/TemperatureControlPool.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #include "libs/Module.h" 9 | #include "libs/Kernel.h" 10 | #include 11 | using namespace std; 12 | #include 13 | #include "TemperatureControlPool.h" 14 | #include "TemperatureControl.h" 15 | #include "PID_Autotuner.h" 16 | #include "Config.h" 17 | #include "checksumm.h" 18 | #include "ConfigValue.h" 19 | #include "TemperatureControlPublicAccess.h" 20 | 21 | #define enable_checksum CHECKSUM("enable") 22 | 23 | void TemperatureControlPool::load_tools() 24 | { 25 | vector modules; 26 | THEKERNEL->config->get_module_list( &modules, temperature_control_checksum ); 27 | int cnt = 0; 28 | for( auto cs : modules ) { 29 | // If module is enabled 30 | if( THEKERNEL->config->value(temperature_control_checksum, cs, enable_checksum )->as_bool() ) { 31 | TemperatureControl *controller = new TemperatureControl(cs, cnt++); 32 | THEKERNEL->add_module(controller); 33 | } 34 | } 35 | 36 | // no need to create one of these if no heaters defined 37 | if(cnt > 0) { 38 | PID_Autotuner *pidtuner = new PID_Autotuner(); 39 | THEKERNEL->add_module( pidtuner ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/libs/ConfigValue.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef CONFIGVALUE_H 9 | #define CONFIGVALUE_H 10 | 11 | #include 12 | using std::string; 13 | 14 | class ConfigValue{ 15 | public: 16 | ConfigValue(); 17 | ConfigValue(uint16_t *check_sums); 18 | ConfigValue(const ConfigValue& to_copy); 19 | ConfigValue& operator= (const ConfigValue& to_copy); 20 | void clear(); 21 | ConfigValue* required(); 22 | float as_number(); 23 | int as_int(); 24 | bool as_bool(); 25 | string as_string(); 26 | 27 | ConfigValue* by_default(float val); 28 | ConfigValue* by_default(string val); 29 | ConfigValue* by_default(int val); 30 | bool is_inverted(); 31 | 32 | 33 | friend class ConfigCache; 34 | friend class Config; 35 | friend class ConfigSource; 36 | friend class Configurator; 37 | friend class FileConfigSource; 38 | 39 | private: 40 | bool has_characters( const char* mask ); 41 | string value; 42 | int default_int; 43 | float default_double; 44 | uint16_t check_sums[3]; 45 | bool found; 46 | bool default_set; 47 | }; 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/modules/tools/laser/Laser.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef LASER_MODULE_H 9 | #define LASER_MODULE_H 10 | 11 | #include "libs/Module.h" 12 | 13 | namespace mbed { 14 | class PwmOut; 15 | } 16 | 17 | class Laser : public Module{ 18 | public: 19 | Laser(); 20 | virtual ~Laser() {}; 21 | void on_module_loaded(); 22 | void on_block_end(void* argument); 23 | void on_block_begin(void* argument); 24 | void on_play(void* argument); 25 | void on_pause(void* argument); 26 | void on_gcode_execute(void* argument); 27 | void on_speed_change(void* argument); 28 | 29 | private: 30 | void set_proportional_power(); 31 | mbed::PwmOut *laser_pin; // PWM output to regulate the laser power 32 | struct { 33 | bool laser_on:1; // Laser status 34 | bool laser_inverting:1; // stores whether the pwm period should be inverted 35 | }; 36 | float laser_maximum_power; // maximum allowed laser power to be output on the pwm pin 37 | float laser_minimum_power; // value used to tickle the laser on moves. Also minimum value for auto-scaling 38 | float laser_power; // current laser power 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/testframework/easyunit/testpartresult.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | EasyUnit : Simple C++ Unit testing framework 3 | Copyright (C) 2004 Barthelemy Dagenais 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Barthelemy Dagenais 20 | barthelemy@prologique.com 21 | */ 22 | 23 | #include "testpartresult.h" 24 | #include "test.h" 25 | 26 | 27 | TestPartResult::TestPartResult (Test *test, 28 | const SimpleString& fileName, 29 | long lineNumber, 30 | const SimpleString& message, 31 | testType type) 32 | : message_ (message), 33 | test_ (test), 34 | fileName_ (fileName), 35 | lineNumber_ (lineNumber), 36 | type_ (type) 37 | { 38 | } 39 | 40 | void TestPartResult::setNext(TestPartResult *next) { 41 | next_ = next; 42 | } 43 | 44 | TestPartResult* TestPartResult::getNext() const { 45 | return next_; 46 | } 47 | 48 | testType TestPartResult::getType() const { 49 | return type_; 50 | } 51 | 52 | const SimpleString& TestPartResult::getMessage() const { 53 | return message_; 54 | } 55 | 56 | Test* TestPartResult::getTest() const { 57 | return test_; 58 | } 59 | 60 | const SimpleString& TestPartResult::getFileName() const { 61 | return fileName_; 62 | } 63 | 64 | long TestPartResult::getLineNumber() const { 65 | return lineNumber_; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/libs/Adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | 9 | 10 | #ifndef ADC_H 11 | #define ADC_H 12 | 13 | #include "PinNames.h" // mbed.h lib 14 | 15 | #include 16 | 17 | class Pin; 18 | 19 | // define how many bits of extra resolution required 20 | // 2 bits means the 12bit ADC is 14 bits of resolution 21 | #define OVERSAMPLE 2 22 | 23 | class Adc 24 | { 25 | public: 26 | Adc(); 27 | void enable_pin(Pin *pin); 28 | unsigned int read(Pin *pin); 29 | 30 | static Adc *instance; 31 | void new_sample(int chan, uint32_t value); 32 | // return the maximum ADC value, base is 12bits 4095. 33 | #ifdef OVERSAMPLE 34 | int get_max_value() const { return 4095 << OVERSAMPLE;} 35 | #else 36 | int get_max_value() const { return 4095;} 37 | #endif 38 | 39 | private: 40 | PinName _pin_to_pinname(Pin *pin); 41 | /* FIXME STM32 42 | mbed::ADC *adc; 43 | */ 44 | static const int num_channels= 6; 45 | #ifdef OVERSAMPLE 46 | // we need 4^n sample to oversample and we get double that to filter out spikes 47 | static const int num_samples= powf(4, OVERSAMPLE)*2; 48 | #else 49 | static const int num_samples= 8; 50 | #endif 51 | // buffers storing the last num_samples readings for each channel 52 | uint16_t sample_buffers[num_channels][num_samples]; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/libs/Module.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #include "libs/Module.h" 9 | #include "libs/Kernel.h" 10 | 11 | Module::Module(){} 12 | Module::~Module(){} 13 | 14 | // this is used to callback the specific method in the Module instance, there must be one for each _EVENT_ENUM and in the same order 15 | // NOTE this is stored in Flash so takes up no RAM 16 | const ModuleCallback kernel_callback_functions[NUMBER_OF_DEFINED_EVENTS] = { 17 | &Module::on_main_loop, 18 | &Module::on_console_line_received, 19 | &Module::on_gcode_received, 20 | &Module::on_gcode_execute, 21 | &Module::on_speed_change, 22 | &Module::on_block_begin, 23 | &Module::on_block_end, 24 | &Module::on_play, 25 | &Module::on_pause, 26 | &Module::on_idle, 27 | &Module::on_second_tick, 28 | &Module::on_get_public_data, 29 | &Module::on_set_public_data, 30 | &Module::on_halt 31 | 32 | }; 33 | 34 | 35 | void Module::register_for_event(_EVENT_ENUM event_id){ 36 | // Events are the basic building blocks of Smoothie. They register for events, and then do stuff when those events are called. 37 | // You add things to Smoothie by making a new class that inherits the Module class. See http://smoothieware.org/moduleexample for a crude introduction 38 | THEKERNEL->register_for_event(event_id, this); 39 | } 40 | -------------------------------------------------------------------------------- /src/modules/utils/PlayLed/PlayLed.cpp: -------------------------------------------------------------------------------- 1 | #include "PlayLed.h" 2 | 3 | /* 4 | * LED indicator: 5 | * off = not paused, nothing to do 6 | * slow flash = paused 7 | * fast flash = halted 8 | * on = a block is being executed 9 | */ 10 | 11 | #include "PauseButton.h" 12 | #include "modules/robot/Conveyor.h" 13 | #include "SlowTicker.h" 14 | #include "Config.h" 15 | #include "Pauser.h" 16 | #include "checksumm.h" 17 | #include "ConfigValue.h" 18 | #include "Gcode.h" 19 | 20 | #define pause_led_pin_checksum CHECKSUM("pause_led_pin") 21 | #define play_led_pin_checksum CHECKSUM("play_led_pin") 22 | #define play_led_disable_checksum CHECKSUM("play_led_disable") 23 | 24 | PlayLed::PlayLed() { 25 | 26 | halted= false; 27 | cnt= 0; 28 | } 29 | 30 | void PlayLed::on_module_loaded() 31 | { 32 | if(THEKERNEL->config->value( play_led_disable_checksum )->by_default(false)->as_bool()) { 33 | delete this; 34 | return; 35 | } 36 | 37 | on_config_reload(this); 38 | this->register_for_event(ON_HALT); 39 | THEKERNEL->slow_ticker->attach(12, this, &PlayLed::led_tick); 40 | } 41 | 42 | void PlayLed::on_config_reload(void *argument) 43 | { 44 | string ledpin = "4.28!"; 45 | 46 | ledpin = THEKERNEL->config->value( pause_led_pin_checksum )->by_default(ledpin)->as_string(); // check for pause_led_pin first 47 | ledpin = THEKERNEL->config->value( play_led_pin_checksum )->by_default(ledpin)->as_string(); // override with play_led_pin if it's found 48 | 49 | led.from_string(ledpin)->as_output()->set(false); 50 | } 51 | 52 | uint32_t PlayLed::led_tick(uint32_t) 53 | { 54 | if(this->halted) { 55 | led.set(!led.get()); 56 | return 0; 57 | } 58 | 59 | if(++cnt >= 6) { // 6 ticks ~ 500ms 60 | cnt= 0; 61 | 62 | if (THEKERNEL->pauser->paused()) { 63 | led.set(!led.get()); 64 | } else { 65 | led.set(!THEKERNEL->conveyor->is_queue_empty()); 66 | } 67 | } 68 | 69 | return 0; 70 | } 71 | 72 | void PlayLed::on_halt(void *arg) 73 | { 74 | this->halted= (arg == nullptr); 75 | } 76 | -------------------------------------------------------------------------------- /src/libs/Config.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef CONFIG_H 9 | #define CONFIG_H 10 | 11 | 12 | using namespace std; 13 | #include 14 | #include 15 | 16 | class ConfigValue; 17 | class ConfigSource; 18 | class ConfigCache; 19 | 20 | class Config : public Module { 21 | public: 22 | Config(); 23 | Config(ConfigSource*); 24 | ~Config(); 25 | 26 | void on_module_loaded(); 27 | void on_console_line_received( void* argument ); 28 | void config_cache_load(bool parse= true); 29 | void config_cache_clear(); 30 | void set_string( string setting , string value); 31 | 32 | ConfigValue* value(uint16_t check_sum_a, uint16_t check_sum_b= 0, uint16_t check_sum_c= 0 ); 33 | ConfigValue* value(uint16_t check_sums[3] ); 34 | 35 | void get_module_list(vector* list, uint16_t family); 36 | bool is_config_cache_loaded() { return config_cache != NULL; }; // Whether or not the cache is currently popluated 37 | 38 | friend class Configurator; 39 | 40 | private: 41 | bool has_characters(uint16_t check_sum, string str ); 42 | 43 | ConfigCache* config_cache; // A cache in which ConfigValues are kept 44 | vector config_sources; // A list of all possible coniguration sources 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/modules/robot/Pauser.cpp: -------------------------------------------------------------------------------- 1 | #include "Pauser.h" 2 | 3 | #include "libs/Kernel.h" 4 | #include "Block.h" 5 | #include "libs/nuts_bolts.h" 6 | #include "libs/utils.h" 7 | 8 | #include 9 | using namespace std; 10 | 11 | // The Pauser module is the core of the pausing subsystem in smoothie. 12 | // Basically we want several modules to be able to pause smoothie at the same 13 | // time ( think both the user with a button, and the temperature control 14 | // because a temperature is not reached ). To do that, modules call the take() 15 | // methode, a pause event is called, and the pause does not end before all 16 | // modules have called the release() method. 17 | // Please note : Modules should keep track of their pause status themselves... 18 | // or Not for instance it may be better for the play/pause button to be able 19 | // to unpause when something else causes a pause 20 | Pauser::Pauser(){ 21 | paused_block = NULL; 22 | } 23 | 24 | void Pauser::on_module_loaded(){ 25 | this->counter = 0; 26 | register_for_event(ON_BLOCK_BEGIN); 27 | } 28 | 29 | void Pauser::on_block_begin(void* argument) 30 | { 31 | Block* block = static_cast(argument); 32 | 33 | if (counter) 34 | { 35 | block->take(); 36 | paused_block = block; 37 | } 38 | } 39 | 40 | // Pause smoothie if nobody else is currently doing so 41 | void Pauser::take(){ 42 | this->counter++; 43 | //THEKERNEL->streams->printf("take: %u \r\n", this->counter ); 44 | if( this->counter == 1 ){ 45 | THEKERNEL->call_event(ON_PAUSE, &this->counter); 46 | } 47 | } 48 | 49 | // Unpause smoothie unless something else is pausing it too 50 | void Pauser::release(){ 51 | if( --this->counter <= 0 ){ 52 | this->counter= 0; 53 | THEKERNEL->call_event(ON_PLAY, &this->counter); 54 | if (paused_block) 55 | { 56 | Block* tmp = paused_block; 57 | paused_block = NULL; 58 | tmp->release(); 59 | } 60 | } 61 | } 62 | 63 | // Return wether smoothie is paused 64 | bool Pauser::paused(){ 65 | return (counter != 0); 66 | } 67 | -------------------------------------------------------------------------------- /src/modules/utils/currentcontrol/mcp4451.h: -------------------------------------------------------------------------------- 1 | #ifndef MCP4451_H 2 | #define MCP4451_H 3 | 4 | #include "libs/Kernel.h" 5 | #include "I2C.h" // mbed.h lib 6 | #include "libs/utils.h" 7 | #include "DigipotBase.h" 8 | #include 9 | #include 10 | 11 | class MCP4451 : public DigipotBase { 12 | public: 13 | MCP4451(){ 14 | // I2C com 15 | this->i2c = new mbed::I2C(PB_9, PB_8); 16 | this->i2c->frequency(20000); 17 | for (int i = 0; i < 8; i++) currents[i] = -1; 18 | } 19 | 20 | ~MCP4451(){ 21 | delete this->i2c; 22 | } 23 | 24 | void set_current( int channel, float current ) 25 | { 26 | if(current < 0) { 27 | currents[channel]= -1; 28 | return; 29 | } 30 | current = min( (float) max( current, 0.0f ), this->max_current ); 31 | currents[channel] = current; 32 | char addr = 0x58; 33 | while(channel > 3){ 34 | addr += 0x02; 35 | channel -= 4; 36 | } 37 | 38 | // Initial setup 39 | this->i2c_send( addr, 0x40, 0xff ); 40 | this->i2c_send( addr, 0xA0, 0xff ); 41 | 42 | // Set actual wiper value 43 | char addresses[4] = { 0x00, 0x10, 0x60, 0x70 }; 44 | this->i2c_send( addr, addresses[channel], this->current_to_wiper(current) ); 45 | } 46 | 47 | float get_current(int channel) 48 | { 49 | return currents[channel]; 50 | } 51 | 52 | private: 53 | 54 | void i2c_send( char first, char second, char third ){ 55 | this->i2c->start(); 56 | this->i2c->write(first); 57 | this->i2c->write(second); 58 | this->i2c->write(third); 59 | this->i2c->stop(); 60 | } 61 | 62 | char current_to_wiper( float current ){ 63 | return char(ceilf(float((this->factor*current)))); 64 | } 65 | 66 | mbed::I2C* i2c; 67 | float currents[8]; 68 | }; 69 | 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/libs/Network/uip/clock-arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: clock-arch.h,v 1.2 2006/06/12 08:00:31 adam Exp $ 32 | */ 33 | 34 | #ifndef __CLOCK_ARCH_H__ 35 | #define __CLOCK_ARCH_H__ 36 | 37 | typedef unsigned clock_time_t; 38 | #define CLOCK_CONF_SECOND 100 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | void do_tick(); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* __CLOCK_ARCH_H__ */ 51 | -------------------------------------------------------------------------------- /src/modules/robot/Conveyor.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef CONVEYOR_H 9 | #define CONVEYOR_H 10 | 11 | #include "libs/Module.h" 12 | #include "HeapRing.h" 13 | 14 | using namespace std; 15 | #include 16 | #include 17 | 18 | class Gcode; 19 | class Block; 20 | 21 | class Conveyor : public Module 22 | { 23 | public: 24 | Conveyor(); 25 | 26 | void on_module_loaded(void); 27 | void on_idle(void *); 28 | void on_main_loop(void *); 29 | void on_block_end(void *); 30 | void on_halt(void *); 31 | void on_config_reload(void *); 32 | 33 | void notify_block_finished(Block *); 34 | 35 | void wait_for_empty_queue(); 36 | bool is_queue_empty() { return queue.is_empty(); }; 37 | bool is_queue_full() { return queue.is_full(); }; 38 | 39 | void ensure_running(void); 40 | 41 | void append_gcode(Gcode *); 42 | void queue_head_block(void); 43 | 44 | void dump_queue(void); 45 | void flush_queue(void); 46 | bool is_flushing() const { return flush; } 47 | 48 | friend class Planner; // for queue 49 | 50 | private: 51 | typedef HeapRing Queue_t; 52 | 53 | Queue_t queue; // Queue of Blocks 54 | volatile unsigned int gc_pending; 55 | 56 | struct { 57 | volatile bool running:1; 58 | volatile bool flush:1; 59 | volatile bool halted:1; 60 | }; 61 | 62 | }; 63 | 64 | #endif // CONVEYOR_H 65 | -------------------------------------------------------------------------------- /src/libs/PublicData.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef PUBLICDATA_H 9 | #define PUBLICDATA_H 10 | 11 | class PublicData { 12 | public: 13 | // there are two ways to get data from a module 14 | // 1. pass in a pointer to a data storage area that the caller creates, the callee module will put the returned data in that pointer 15 | // 2. pass in a pointer to a pointer, the callee will set that pointer to some storage the callee has control over, with the requested data 16 | // the version used is dependent on the target (callee) module 17 | static bool get_value(uint16_t csa, void *data) { return get_value(csa, 0, 0, data); } 18 | static bool get_value(uint16_t csa, uint16_t csb, void *data) { return get_value(csa, csb, 0, data); } 19 | static bool get_value(uint16_t cs[3], void *data) { return get_value(cs[0], cs[1], cs[2], data); }; 20 | static bool get_value(uint16_t csa, uint16_t csb, uint16_t csc, void *data); 21 | 22 | static bool set_value(uint16_t csa, void *data) { return set_value(csa, 0, 0, data); } 23 | static bool set_value(uint16_t csa, uint16_t csb, void *data) { return set_value(csa, csb, 0, data); } 24 | static bool set_value(uint16_t cs[3], void *data) { return set_value(cs[0], cs[1], cs[2], data); } 25 | static bool set_value(uint16_t csa, uint16_t csb, uint16_t csc, void *data); 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/modules/tools/temperaturecontrol/predefined_thermistors.h: -------------------------------------------------------------------------------- 1 | typedef struct { 2 | const char *name; 3 | int r1; 4 | int r2; 5 | float beta, r0, t0; 6 | } const thermistor_beta_table_t; 7 | 8 | // NOTE the order of these tables must NOT be changed as the index can be used in M305 to set the prefined thermistor to use 9 | 10 | static const thermistor_beta_table_t predefined_thermistors_beta[] { 11 | // name, r1, r2, beta, r0, t0 12 | {"EPCOS100K", 0, 4700, 4066.0F, 100000.0F, 25.0F}, // B57540G0104F000 13 | {"RRRF100K", 0, 4700, 3960.0F, 100000.0F, 25.0F}, 14 | {"RRRF10K", 680, 1600, 3964.0F, 10000.0F, 25.0F}, 15 | {"Honeywell100K", 0, 4700, 3974.0F, 100000.0F, 25.0F}, // 135-104LAG-J01 16 | {"Semitec", 0, 4700, 4267.0F, 100000.0F, 25.0F}, // 104GT-2 17 | {"HT100K", 0, 4700, 3990.0F, 100000.0F, 25.0F} 18 | }; 19 | 20 | typedef struct { 21 | const char *name; 22 | int r1; 23 | int r2; 24 | float c1, c2, c3; 25 | } const thermistor_table_t; 26 | 27 | // Use one of the following scripts to calcuate the coefficients: 28 | // - http://www.thinksrs.com/downloads/programs/Therm%20Calc/NTCCalibrator/NTCcalculator.htm 29 | // - https://github.com/MarlinFirmware/Marlin/blob/Development/Marlin/scripts/createTemperatureLookupMarlin.py 30 | static const thermistor_table_t predefined_thermistors[] { 31 | // name, r1, r2, c1, c2, c3 32 | {"EPCOS100K", 0, 4700, 0.000722378300319346F, 0.000216301852054578F, 9.2641025635702e-08F}, // B57540G0104F000 33 | {"Vishay100K", 0, 4700, 0.0007022607370F, 0.0002209155484F, 7.101626461e-08F }, // NTCS0603E3104FXT 34 | {"Honeywell100K", 0, 4700, 0.000596153185928425F, 0.000231333192738335F, 6.19534004306738e-08F}, // 135-104LAG-J01 35 | {"Semitec", 0, 4700, 0.000811290160145459F, 0.000211355789144265F, 7.17614730463848e-08F}, // 104GT-2 36 | {"Honeywell-QAD", 0, 4700, 0.000827339299500986F, 0.000208786427208899F, 8.05595282332277e-08F} // 135-104QAD-J01 37 | }; 38 | -------------------------------------------------------------------------------- /src/modules/communication/utils/Gcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | 9 | #ifndef GCODE_H 10 | #define GCODE_H 11 | #include 12 | #include 13 | 14 | using std::string; 15 | 16 | class StreamOutput; 17 | 18 | // Object to represent a Gcode command 19 | class Gcode { 20 | public: 21 | Gcode(const string&, StreamOutput*, bool strip=true); 22 | Gcode(const Gcode& to_copy); 23 | Gcode& operator= (const Gcode& to_copy); 24 | ~Gcode(); 25 | 26 | const char* get_command() const { return command; } 27 | bool has_letter ( char letter ) const; 28 | float get_value ( char letter, char **ptr= nullptr ) const; 29 | int get_int ( char letter, char **ptr= nullptr ) const; 30 | uint32_t get_uint ( char letter, char **ptr= nullptr ) const; 31 | int get_num_args() const; 32 | std::map get_args() const; 33 | void strip_parameters(); 34 | 35 | // FIXME these should be private 36 | unsigned int m; 37 | unsigned int g; 38 | float millimeters_of_travel; 39 | 40 | struct { 41 | bool add_nl:1; 42 | bool has_m:1; 43 | bool has_g:1; 44 | bool stripped:1; 45 | }; 46 | 47 | StreamOutput* stream; 48 | string txt_after_ok; 49 | 50 | private: 51 | void prepare_cached_values(bool strip=true); 52 | char *command; 53 | }; 54 | #endif 55 | -------------------------------------------------------------------------------- /src/modules/utils/panel/screens/ModifyValuesScreen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef MODIFYVALUESSCREEN_H 9 | #define MODIFYVALUESSCREEN_H 10 | 11 | #include "PanelScreen.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | class ModifyValuesScreen : public PanelScreen 20 | { 21 | public: 22 | ModifyValuesScreen(bool delete_on_exit= false); 23 | virtual ~ModifyValuesScreen(); 24 | 25 | void on_refresh(); 26 | void on_enter(); 27 | void on_exit(); 28 | void on_main_loop(); 29 | void display_menu_line(uint16_t line); 30 | void clicked_menu_entry(uint16_t line); 31 | int idle_timeout_secs(){ return 60; } 32 | 33 | typedef std::tuple, std::function, float, float, float, bool> MenuItemType; 34 | void addMenuItem(const char *name, std::function getter, std::function setter, float inc= 1.0F, float min= NAN, float max= NAN, bool instant= false); 35 | 36 | private: 37 | void addMenuItem(const MenuItemType& item); 38 | 39 | int execute_function; 40 | float new_value, min_value, max_value; 41 | int selected_item; 42 | // name, getter function, setter function, increment 43 | std::vector menu_items; 44 | 45 | char control_mode; 46 | struct { 47 | bool delete_on_exit:1; 48 | bool instant:1; 49 | }; 50 | 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/libs/Network/uip/webserver/webserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: webserver.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 33 | * 34 | */ 35 | #ifndef __WEBSERVER_H__ 36 | #define __WEBSERVER_H__ 37 | 38 | #include "httpd.h" 39 | 40 | //typedef struct httpd_state uip_tcp_appstate_t; 41 | /* UIP_APPCALL: the name of the application function. This function 42 | must return void and take no arguments (i.e., C type "void 43 | appfunc(void)"). */ 44 | #ifndef UIP_APPCALL 45 | #define UIP_APPCALL httpd_appcall 46 | #endif 47 | 48 | 49 | #endif /* __WEBSERVER_H__ */ 50 | -------------------------------------------------------------------------------- /src/libs/Network/Drivers/LPC17XX_Ethernet.h: -------------------------------------------------------------------------------- 1 | #ifndef _LPC17XX_ETHERNET_H 2 | #define _LPC17XX_ETHERNET_H 3 | 4 | #include "lpc17xx_emac.h" 5 | 6 | #include "Module.h" 7 | #include "net_util.h" 8 | 9 | #define EMAC_SMSC_8720A 0x0007C0F0 10 | 11 | // SMSC 8720A special control/status register 12 | #define EMAC_PHY_REG_SCSR 0x1F 13 | 14 | #define LPC17XX_MAX_PACKET 600 15 | #define LPC17XX_TXBUFS 4 16 | #define LPC17XX_RXBUFS 4 17 | 18 | typedef struct { 19 | void* packet; 20 | uint32_t control; 21 | } packet_desc; 22 | 23 | typedef struct { 24 | uint8_t buf[LPC17XX_RXBUFS][LPC17XX_MAX_PACKET]; 25 | RX_Stat rxstat[LPC17XX_RXBUFS]; 26 | packet_desc rxdesc[LPC17XX_RXBUFS]; 27 | } _rxbuf_t; 28 | 29 | typedef struct { 30 | uint8_t buf[LPC17XX_TXBUFS][LPC17XX_MAX_PACKET]; 31 | TX_Stat txstat[LPC17XX_TXBUFS]; 32 | packet_desc txdesc[LPC17XX_TXBUFS]; 33 | } _txbuf_t; 34 | 35 | class LPC17XX_Ethernet; 36 | 37 | class LPC17XX_Ethernet : public Module, public NetworkInterface 38 | { 39 | public: 40 | LPC17XX_Ethernet(); 41 | 42 | void on_module_loaded(); 43 | void on_idle(void*); 44 | void on_second_tick(void*); 45 | 46 | void emac_init(void) __attribute__ ((optimize("O0"))); 47 | 48 | void set_mac(uint8_t*); 49 | 50 | void irq(void); 51 | 52 | bool _receive_frame(void *packet, int* size); 53 | 54 | // NetworkInterface methods 55 | // void provide_net(netcore* n); 56 | bool can_read_packet(void); 57 | int read_packet(uint8_t**); 58 | void release_read_packet(uint8_t*); 59 | void periodical(int); 60 | 61 | bool can_write_packet(void); 62 | int write_packet(uint8_t *, int); 63 | 64 | void* request_packet_buffer(void); 65 | 66 | // Encapsulator methods 67 | int receive(NetworkInterface* ni, NET_PACKET, int); 68 | int construct(NetworkInterface* ni, NET_PACKET, int); 69 | NET_PACKET get_new_packet_buffer(NetworkInterface*); 70 | NET_PAYLOAD get_payload_buffer(NET_PACKET); 71 | void set_payload_length(NET_PACKET, int); 72 | 73 | static LPC17XX_Ethernet* instance; 74 | 75 | private: 76 | static _rxbuf_t rxbuf; 77 | static _txbuf_t txbuf; 78 | 79 | void check_interface(); 80 | }; 81 | 82 | #endif /* _LPC17XX_ETHERNET_H */ 83 | -------------------------------------------------------------------------------- /src/libs/Network/uip/webserver/makefsdata.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | open(OUTPUT, "> httpd-fsdata2.h"); 4 | 5 | chdir("httpd-fs"); 6 | 7 | opendir(DIR, "."); 8 | @files = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR); 9 | closedir(DIR); 10 | 11 | foreach $file (@files) { 12 | 13 | if(-d $file && $file !~ /^\./) { 14 | print "Processing directory $file\n"; 15 | opendir(DIR, $file); 16 | @newfiles = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR); 17 | closedir(DIR); 18 | printf "Adding files @newfiles\n"; 19 | @files = (@files, map { $_ = "$file/$_" } @newfiles); 20 | next; 21 | } 22 | } 23 | 24 | foreach $file (@files) { 25 | if(-f $file) { 26 | 27 | print "Adding file $file\n"; 28 | 29 | open(FILE, $file) || die "Could not open file $file\n"; 30 | 31 | $file =~ s-^-/-; 32 | $fvar = $file; 33 | $fvar =~ s-/-_-g; 34 | $fvar =~ s-\.-_-g; 35 | # for AVR, add PROGMEM here 36 | print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); 37 | print(OUTPUT "\t/* $file */\n\t"); 38 | for($j = 0; $j < length($file); $j++) { 39 | printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1))); 40 | } 41 | printf(OUTPUT "0,\n"); 42 | 43 | 44 | $i = 0; 45 | while(read(FILE, $data, 1)) { 46 | if($i == 0) { 47 | print(OUTPUT "\t"); 48 | } 49 | printf(OUTPUT "%#02x, ", unpack("C", $data)); 50 | $i++; 51 | if($i == 10) { 52 | print(OUTPUT "\n"); 53 | $i = 0; 54 | } 55 | } 56 | print(OUTPUT "0};\n\n"); 57 | close(FILE); 58 | push(@fvars, $fvar); 59 | push(@pfiles, $file); 60 | } 61 | } 62 | 63 | for($i = 0; $i < @fvars; $i++) { 64 | $file = $pfiles[$i]; 65 | $fvar = $fvars[$i]; 66 | 67 | if($i == 0) { 68 | $prevfile = "NULL"; 69 | } else { 70 | $prevfile = "file" . $fvars[$i - 1]; 71 | } 72 | print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, "); 73 | print(OUTPUT "data$fvar + ". (length($file) + 1) .", "); 74 | print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 2) ."}};\n\n"); # don't include the terminating nul 75 | } 76 | 77 | print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n"); 78 | print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n"); 79 | -------------------------------------------------------------------------------- /src/modules/robot/Stepper.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef STEPPER_H 9 | #define STEPPER_H 10 | 11 | #include "libs/Module.h" 12 | #include 13 | 14 | class Block; 15 | class StepperMotor; 16 | 17 | class Stepper : public Module 18 | { 19 | public: 20 | Stepper(); 21 | void on_module_loaded(); 22 | void on_config_reload(void *argument); 23 | void on_block_begin(void *argument); 24 | void on_block_end(void *argument); 25 | void on_gcode_received(void *argument); 26 | void on_gcode_execute(void *argument); 27 | void on_play(void *argument); 28 | void on_pause(void *argument); 29 | void on_halt(void *argument); 30 | uint32_t main_interrupt(uint32_t dummy); 31 | void trapezoid_generator_reset(); 32 | void set_step_events_per_second(float); 33 | void trapezoid_generator_tick(void); 34 | uint32_t stepper_motor_finished_move(uint32_t dummy); 35 | int config_step_timer( int cycles ); 36 | void turn_enable_pins_on(); 37 | void turn_enable_pins_off(); 38 | 39 | float get_trapezoid_adjusted_rate() const { return trapezoid_adjusted_rate; } 40 | const Block *get_current_block() const { return current_block; } 41 | 42 | private: 43 | Block *current_block; 44 | float trapezoid_adjusted_rate; 45 | StepperMotor *main_stepper; 46 | 47 | struct { 48 | bool enable_pins_status:1; 49 | bool force_speed_update:1; 50 | bool paused:1; 51 | bool halted:1; 52 | }; 53 | 54 | }; 55 | 56 | 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/libs/HeapRing.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEAPRING_H 2 | #define _HEAPRING_H 3 | 4 | template class HeapRing { 5 | 6 | // smoothie-specific friend classes 7 | friend class Planner; 8 | friend class Conveyor; 9 | friend class Block; 10 | 11 | public: 12 | HeapRing(); 13 | HeapRing(unsigned int length); 14 | 15 | ~HeapRing(); 16 | 17 | /* 18 | * direct accessors 19 | */ 20 | kind& head(); 21 | kind& tail(); 22 | 23 | void push_front(kind&) __attribute__ ((warning("Not thread-safe if pop_back() is used in ISR context!"))); // instead, prepare(head_ref()); produce_head(); 24 | kind& pop_back(void) __attribute__ ((warning("Not thread-safe if head_ref() is used to prepare new items, or push_front() is used in ISR context!"))); // instead, consume(tail_ref()); consume_tail(); 25 | 26 | /* 27 | * pointer accessors 28 | */ 29 | kind* head_ref(); 30 | kind* tail_ref(); 31 | 32 | void produce_head(void); 33 | void consume_tail(void); 34 | 35 | /* 36 | * queue status 37 | */ 38 | bool is_empty(void); 39 | bool is_full(void); 40 | 41 | /* 42 | * resize 43 | * 44 | * returns true on success, or false if queue is not empty or not enough memory available 45 | */ 46 | bool resize(unsigned int); 47 | 48 | /* 49 | * provide 50 | * kind* - new buffer pointer 51 | * int length - number of items in buffer (NOT size in bytes!) 52 | * 53 | * cause HeapRing to use a specific memory location instead of allocating its own 54 | * 55 | * returns true on success, or false if queue is not empty 56 | */ 57 | bool provide(kind*, unsigned int length); 58 | 59 | protected: 60 | /* 61 | * these functions are protected as they should only be used internally 62 | * or in extremely specific circumstances 63 | */ 64 | kind& item(unsigned int); 65 | kind* item_ref(unsigned int); 66 | 67 | unsigned int next(unsigned int); 68 | unsigned int prev(unsigned int); 69 | 70 | /* 71 | * buffer variables 72 | */ 73 | unsigned int length; 74 | 75 | volatile unsigned int head_i; 76 | volatile unsigned int tail_i; 77 | 78 | private: 79 | kind* ring; 80 | }; 81 | 82 | #endif /* _HEAPRING_H */ 83 | -------------------------------------------------------------------------------- /src/modules/utils/panel/panels/UniversalAdapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef UniversalAdapter_H 9 | #define UniversalAdapter_H 10 | 11 | #include "LcdBase.h" 12 | #include "mbed.h" 13 | 14 | class Pin; 15 | 16 | class UniversalAdapter : public LcdBase { 17 | public: 18 | UniversalAdapter(); 19 | virtual ~UniversalAdapter(); 20 | void home(); 21 | void clear(); 22 | void display(); 23 | void setCursor(uint8_t col, uint8_t row); 24 | void init(); 25 | void write(const char* line, int len); 26 | bool encoderReturnsDelta() { return true; } 27 | //void on_refresh(bool now); 28 | 29 | void setLed(int led, bool onoff); 30 | 31 | uint8_t readButtons(); 32 | int readEncoderDelta(); 33 | 34 | // this is the number of clicks per detent 35 | int getEncoderResolution() { return 2; } 36 | 37 | void buzz(long,uint16_t); 38 | 39 | private: 40 | // this is a C++ way to do something on entry of a class and something else on exit of scope 41 | class SPIFrame { 42 | public: 43 | SPIFrame(UniversalAdapter *pu); 44 | ~SPIFrame(); 45 | private: 46 | UniversalAdapter *u; 47 | }; 48 | 49 | uint8_t writeSPI(uint8_t b); 50 | void wait_until_ready(); 51 | uint8_t sendReadCmd(uint8_t cmd); 52 | uint16_t ledBits; 53 | mbed::SPI* spi; 54 | Pin *cs_pin; 55 | Pin *busy_pin; 56 | }; 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/libs/ConfigCache.cpp: -------------------------------------------------------------------------------- 1 | #include "ConfigCache.h" 2 | #include "ConfigValue.h" 3 | 4 | #include "libs/StreamOutput.h" 5 | 6 | ConfigCache::ConfigCache() 7 | { 8 | } 9 | 10 | ConfigCache::~ConfigCache() 11 | { 12 | clear(); 13 | } 14 | 15 | void ConfigCache::clear() 16 | { 17 | for (auto &kv : store) { 18 | delete kv; 19 | } 20 | store.clear(); 21 | storage_t().swap(store); // makes sure the vector releases its memory 22 | } 23 | 24 | void ConfigCache::add(ConfigValue *v) 25 | { 26 | store.push_back(v); 27 | } 28 | 29 | // If we find an existing value, replace it, otherwise, push it at the back of the list 30 | void ConfigCache::replace_or_push_back(ConfigValue *new_value) 31 | { 32 | // For each already existing element 33 | for(auto &cv : store) { 34 | // If this configvalue matches the checksum 35 | if(memcmp(new_value->check_sums, cv->check_sums, sizeof(cv->check_sums)) == 0) { 36 | // Replace with the provided value 37 | cv = new_value; 38 | printf("WARNING: duplicate config line replaced\n"); 39 | return; 40 | } 41 | } 42 | 43 | // Value does not already exists, add to the list 44 | store.push_back(new_value); 45 | } 46 | 47 | ConfigValue *ConfigCache::lookup(const uint16_t *check_sums) const 48 | { 49 | for( auto &cv : store) { 50 | if(memcmp(check_sums, cv->check_sums, sizeof(cv->check_sums)) == 0) 51 | return cv; 52 | } 53 | 54 | return NULL; 55 | } 56 | 57 | void ConfigCache::collect(uint16_t family, uint16_t cs, vector *list) 58 | { 59 | for( auto &kv : store ) { 60 | if( kv->check_sums[2] == cs && kv->check_sums[0] == family ) { 61 | // We found a module enable for this family, add it's number 62 | list->push_back(kv->check_sums[1]); 63 | } 64 | } 65 | } 66 | 67 | void ConfigCache::dump(StreamOutput *stream) 68 | { 69 | int l = 1; 70 | for( auto &kv : store ) { 71 | ConfigValue *v = kv; 72 | stream->printf("%3d - %04X %04X %04X : '%s' - found: %d, default: %d, default-double: %f, default-int: %d\n", 73 | l++, v->check_sums[0], v->check_sums[1], v->check_sums[2], v->value.c_str(), v->found, v->default_set, v->default_double, v->default_int ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/libs/PublicDataRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef PUBLICDATAREQUEST_H 9 | #define PUBLICDATAREQUEST_H 10 | 11 | class PublicDataRequest { 12 | public: 13 | PublicDataRequest(uint16_t addrcs1){ target[0]= addrcs1; target[1]= 0; target[2]= 0; data_taken= false; data= NULL; returned_data= true; } 14 | PublicDataRequest(uint16_t addrcs1, uint16_t addrcs2){ target[0]= addrcs1; target[1]= addrcs2; target[2]= 0; data_taken= false; data= NULL; returned_data= true; } 15 | PublicDataRequest(uint16_t addrcs1, uint16_t addrcs2, uint16_t addrcs3){ target[0]= addrcs1; target[1]= addrcs2; target[2]= addrcs3; data_taken= false; data= NULL; returned_data= true; } 16 | 17 | virtual ~PublicDataRequest() { data= nullptr; } 18 | 19 | bool starts_with(uint16_t addr) const { return addr == this->target[0]; } 20 | bool second_element_is(uint16_t addr) const { return addr == this->target[1]; } 21 | bool third_element_is(uint16_t addr) const { return addr == this->target[2]; } 22 | 23 | bool is_taken() const { return this->data_taken; } 24 | void set_taken() { this->data_taken= true; } 25 | bool has_returned_data() const { return this->returned_data; } 26 | void set_data_ptr(void *d, bool flag= true) { this->data= d; returned_data= flag; } 27 | void* get_data_ptr(void) const { return this->data; } 28 | 29 | private: 30 | uint16_t target[3]; 31 | void* data; 32 | struct { 33 | bool data_taken:1; 34 | bool returned_data:1; 35 | }; 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/modules/utils/panel/panels/ReprapDiscountGLCD.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | #ifndef RRDGLCD_H 8 | #define RRDGLCD_H 9 | 10 | #include "LcdBase.h" 11 | #include "Pin.h" 12 | 13 | class RrdGlcd; 14 | 15 | class ReprapDiscountGLCD : public LcdBase { 16 | public: 17 | ReprapDiscountGLCD(); 18 | virtual ~ReprapDiscountGLCD(); 19 | 20 | int getEncoderResolution() { return 2; } 21 | bool hasGraphics() { return true; } 22 | uint16_t get_screen_lines() { return 8; } 23 | 24 | uint8_t readButtons(); 25 | int readEncoderDelta(); 26 | void write(const char* line, int len); 27 | void home(); 28 | void clear(); 29 | void display(); 30 | void setCursor(uint8_t col, uint8_t row); 31 | void init(); 32 | void buzz(long,uint16_t); 33 | // blit a glyph of w pixels wide and h pixels high to x, y. offset pixel position in glyph by x_offset, y_offset. 34 | // span is the width in bytes of the src bitmap 35 | // The glyph bytes will be 8 bits of X pixels, msbit->lsbit from top left to bottom right 36 | void bltGlyph(int x, int y, int w, int h, const uint8_t *glyph, int span= 0, int x_offset=0, int y_offset=0); 37 | void on_refresh(bool now=false); 38 | 39 | private: 40 | RrdGlcd* glcd; 41 | uint8_t col; 42 | uint8_t row; 43 | 44 | Pin spi_cs_pin; 45 | Pin encoder_a_pin; 46 | Pin encoder_b_pin; 47 | Pin click_pin; 48 | Pin pause_pin; 49 | Pin back_pin; 50 | Pin buzz_pin; 51 | }; 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/libs/Network/uip/clock-arch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: clock-arch.c,v 1.2 2006/06/12 08:00:31 adam Exp $ 32 | */ 33 | 34 | /** 35 | * \file 36 | * Implementation of architecture-specific clock functionality 37 | * \author 38 | * Adam Dunkels 39 | */ 40 | 41 | #include "clock-arch.h" 42 | static clock_time_t Ticks; 43 | 44 | void do_tick() { 45 | Ticks++; 46 | } 47 | 48 | /*---------------------------------------------------------------------------*/ 49 | clock_time_t clock_time(void) 50 | { 51 | return Ticks; 52 | } 53 | /*---------------------------------------------------------------------------*/ 54 | -------------------------------------------------------------------------------- /src/modules/utils/panel/panels/rrdglcd/RrdGlcd.h: -------------------------------------------------------------------------------- 1 | #ifndef __RRDGLCD_H 2 | #define __RRDGLCD_H 3 | 4 | /* 5 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 6 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 7 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 8 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 9 | */ 10 | 11 | /** 12 | * Based loosely on st7920.h from http://mbed.org/users/Bas/code/ST7920 and parts of the Arduino U8glib library. 13 | * Written by Jim Morris 14 | */ 15 | 16 | #include 17 | #include "libs/Kernel.h" 18 | #include "libs/utils.h" 19 | #include 20 | 21 | 22 | class RrdGlcd { 23 | public: 24 | /** 25 | *@brief Constructor, initializes the lcd on the respective pins. 26 | *@param mosi mbed pinname for mosi 27 | *@param sclk mbed name for sclk 28 | *@param cd Smoothie Pin for cs 29 | *@return none 30 | */ 31 | RrdGlcd (int spi_channel, Pin cs); 32 | 33 | virtual ~RrdGlcd(); 34 | 35 | void setFrequency(int f); 36 | 37 | void initDisplay(void); 38 | void clearScreen(void); 39 | void displayString(int row, int column, const char *ptr, int length); 40 | void refresh(); 41 | 42 | /** 43 | *@brief Fills the screen with the graphics described in a 1024-byte array 44 | *@ 45 | *@param bitmap 128x64, bytes horizontal 46 | *@return none 47 | * 48 | */ 49 | void fillGDRAM(const uint8_t *bitmap); 50 | 51 | // copy the bits in g, of X line size pixels, to x, y in frame buffer 52 | void renderGlyph(int x, int y, const uint8_t *g, int pixelWidth, int pixelHeight); 53 | 54 | private: 55 | Pin cs; 56 | mbed::SPI* spi; 57 | void renderChar(uint8_t *fb, char c, int ox, int oy); 58 | void displayChar(int row, int column,char inpChr); 59 | 60 | uint8_t *fb; 61 | bool inited; 62 | bool dirty; 63 | }; 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /src/libs/MRI_Hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "MRI_Hooks.h" 2 | 3 | #include 4 | 5 | // This is used by MRI to turn pins on and off when entering and leaving MRI. Useful for not burning everything down 6 | // See http://smoothieware.org/mri-debugging 7 | 8 | extern "C" { 9 | static uint32_t _set_high_on_debug[5] = { 10 | // (1 << 4) | (1 << 10) | (1 << 19) | (1 << 21), // smoothieboard stepper EN pins 11 | 0, 12 | 0, 13 | 0, 14 | 0, 15 | 0 16 | }; 17 | static uint32_t _set_low_on_debug[5] = { 18 | 0, 19 | 0, 20 | // (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7), // smoothieboard heater outputs 21 | 0, 22 | 0, 23 | 0 24 | }; 25 | 26 | /* FIXME STM32 27 | static uint32_t _previous_state[5]; 28 | 29 | static LPC_GPIO_TypeDef* io; 30 | static int i; 31 | * */ 32 | 33 | void __mriPlatform_EnteringDebuggerHook() 34 | { 35 | /* FIXME STM32 36 | for (i = 0; i < 5; i++) 37 | { 38 | io = (LPC_GPIO_TypeDef*) (LPC_GPIO_BASE + (0x20 * i)); 39 | io->FIOMASK &= ~(_set_high_on_debug[i] | _set_low_on_debug[i]); 40 | 41 | _previous_state[i] = io->FIOPIN; 42 | 43 | io->FIOSET = _set_high_on_debug[i]; 44 | io->FIOCLR = _set_low_on_debug[i]; 45 | } 46 | */ 47 | } 48 | 49 | void __mriPlatform_LeavingDebuggerHook() 50 | { 51 | /* FIXME STM32 52 | for (i = 0; i < 5; i++) 53 | { 54 | io = (LPC_GPIO_TypeDef*) (LPC_GPIO_BASE + (0x20 * i)); 55 | io->FIOMASK &= ~(_set_high_on_debug[i] | _set_low_on_debug[i]); 56 | io->FIOSET = _previous_state[i] & (_set_high_on_debug[i] | _set_low_on_debug[i]); 57 | io->FIOCLR = (~_previous_state[i]) & (_set_high_on_debug[i] | _set_low_on_debug[i]); 58 | } 59 | */ 60 | } 61 | 62 | void set_high_on_debug(int port, int pin) 63 | { 64 | if ((port >= 5) || (port < 0)) 65 | return; 66 | if ((pin >= 32) || (pin < 0)) 67 | return; 68 | _set_high_on_debug[port] |= (1<= 5) || (port < 0)) 74 | return; 75 | if ((pin >= 32) || (pin < 0)) 76 | return; 77 | _set_low_on_debug[port] |= (1<. 6 | */ 7 | 8 | #ifndef SPINDLE_MODULE_H 9 | #define SPINDLE_MODULE_H 10 | 11 | #include "libs/Module.h" 12 | #include 13 | 14 | namespace mbed { 15 | class PwmOut; 16 | class InterruptIn; 17 | } 18 | 19 | // This module implements closed loop PID control for spindle RPM. 20 | class Spindle: public Module { 21 | public: 22 | Spindle(); 23 | virtual ~Spindle() {}; 24 | void on_module_loaded(); 25 | 26 | 27 | private: 28 | void on_pin_rise(); 29 | void on_gcode_received(void *argument); 30 | void on_gcode_execute(void *argument); 31 | uint32_t on_update_speed(uint32_t dummy); 32 | 33 | mbed::PwmOut *spindle_pin; // PWM output for spindle speed control 34 | mbed::InterruptIn *feedback_pin; // Interrupt pin for measuring speed 35 | bool output_inverted; 36 | 37 | // Current values, updated at runtime 38 | bool spindle_on; 39 | float current_rpm; 40 | float target_rpm; 41 | float current_I_value; 42 | float prev_error; 43 | float current_pwm_value; 44 | int time_since_update; 45 | uint32_t last_irq; 46 | 47 | // Values from config 48 | float pulses_per_rev; 49 | float control_P_term; 50 | float control_I_term; 51 | float control_D_term; 52 | float smoothing_decay; 53 | 54 | // These fields are updated by the interrupt 55 | uint32_t last_edge; // Timestamp of last edge 56 | volatile uint32_t last_time; // Time delay between last two edges 57 | volatile uint32_t irq_count; 58 | }; 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /src/modules/utils/panel/Button.cpp: -------------------------------------------------------------------------------- 1 | #include "Button.h" 2 | 3 | #include "libs/Kernel.h" 4 | #include "libs/utils.h" 5 | #include "libs/Pin.h" 6 | #include "libs/Hook.h" 7 | 8 | Button::Button() 9 | { 10 | this->counter = 0; 11 | this->value = false; 12 | this->up_hook = NULL; 13 | this->down_hook = NULL; 14 | this->button_pin = NULL; 15 | this->repeat = false; 16 | this->first_timer = 0; 17 | this->second_timer = 0; 18 | this->longpress_delay = 0; 19 | } 20 | 21 | Button *Button::pin(Pin *passed_pin) 22 | { 23 | this->button_pin = passed_pin; 24 | return this; 25 | } 26 | 27 | void Button::check_signal() 28 | { 29 | check_signal(this->button_pin->get() ? 1 : 0); 30 | } 31 | 32 | void Button::check_signal(int val) 33 | { 34 | bool start_value = this->value; 35 | if ( val ) { 36 | if ( this->counter < 5 ) { 37 | this->counter++; 38 | } 39 | if ( this->counter == 5 ) { 40 | this->value = true; 41 | } 42 | } else { 43 | if ( this->counter > 0 ) { 44 | this->counter--; 45 | } 46 | if ( this->counter == 0 ) { 47 | this->value = false; 48 | } 49 | } 50 | 51 | if ( start_value != this->value ) { 52 | if ( this->value ) { 53 | if ( this->up_hook != NULL ) { 54 | this->up_hook->call(); 55 | this->first_timer = 0; 56 | this->second_timer = 0; 57 | this->repeat = false; 58 | } 59 | } else { 60 | if ( this->down_hook != NULL ) { 61 | this->down_hook->call(); 62 | } 63 | } 64 | } 65 | //auto repeat button presses 66 | if(this->longpress_delay > 0) { 67 | if(this->value) { 68 | if(this->repeat) { 69 | this->second_timer++; 70 | if(this->second_timer == 10) { 71 | this->up_hook->call(); 72 | this->second_timer = 0; 73 | } 74 | } else { 75 | this->first_timer++; 76 | if(this->first_timer == longpress_delay) { 77 | this->repeat = true; 78 | this->first_timer = 0; 79 | } 80 | } 81 | } 82 | } 83 | } 84 | 85 | void Button::set_longpress_delay(int delay) 86 | { 87 | this->longpress_delay = delay; 88 | } 89 | 90 | bool Button::get() 91 | { 92 | return this->value; 93 | } 94 | -------------------------------------------------------------------------------- /src/libs/Network/uip/webserver/httpd-fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: httpd-fs.h,v 1.1 2006/06/07 09:13:08 adam Exp $ 34 | */ 35 | #ifndef __HTTPD_FS_H__ 36 | #define __HTTPD_FS_H__ 37 | 38 | #define HTTPD_FS_STATISTICS 1 39 | 40 | struct httpd_fs_file { 41 | char *data; 42 | int len; 43 | }; 44 | 45 | /* file must be allocated by caller and will be filled in 46 | by the function. */ 47 | int httpd_fs_open(const char *name, struct httpd_fs_file *file); 48 | 49 | #ifdef HTTPD_FS_STATISTICS 50 | #if HTTPD_FS_STATISTICS == 1 51 | u16_t httpd_fs_count(char *name); 52 | #endif /* HTTPD_FS_STATISTICS */ 53 | #endif /* HTTPD_FS_STATISTICS */ 54 | 55 | void httpd_fs_init(void); 56 | 57 | #endif /* __HTTPD_FS_H__ */ 58 | -------------------------------------------------------------------------------- /src/libs/SlowTicker.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | 9 | 10 | #ifndef SLOWTICKER_H 11 | #define SLOWTICKER_H 12 | 13 | #include "Module.h" 14 | 15 | using namespace std; 16 | #include 17 | 18 | #include "libs/Hook.h" 19 | #include "libs/Pin.h" 20 | 21 | #include 22 | 23 | class SlowTicker : public Module{ 24 | public: 25 | SlowTicker(); 26 | 27 | void on_module_loaded(void); 28 | void on_idle(void*); 29 | 30 | void set_frequency( int frequency ); 31 | void tick(); 32 | // For some reason this can't go in the .cpp, see : http://mbed.org/forum/mbed/topic/2774/?page=1#comment-14221 33 | // TODO replace this with std::function() 34 | template Hook* attach( uint32_t frequency, T *optr, uint32_t ( T::*fptr )( uint32_t ) ){ 35 | Hook* hook = new Hook(); 36 | hook->interval = floorf((SystemCoreClock/4)/frequency); 37 | hook->attach(optr, fptr); 38 | hook->countdown = hook->interval; 39 | 40 | // to avoid race conditions we must stop the interupts before updating this non thread safe vector 41 | __disable_irq(); 42 | if( frequency > this->max_frequency ){ 43 | this->max_frequency = frequency; 44 | this->set_frequency(frequency); 45 | } 46 | this->hooks.push_back(hook); 47 | __enable_irq(); 48 | return hook; 49 | } 50 | 51 | private: 52 | bool flag_1s(); 53 | 54 | vector hooks; 55 | uint32_t max_frequency; 56 | uint32_t interval; 57 | 58 | //~ Pin ispbtn; 59 | protected: 60 | int flag_1s_count; 61 | volatile int flag_1s_flag; 62 | }; 63 | 64 | 65 | 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/modules/utils/panel/panels/ST7565.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ST7565.h 3 | * 4 | * Created on: 21-06-2013 5 | * Author: Wulfnor 6 | */ 7 | 8 | #ifndef ST7565_H_ 9 | #define ST7565_H_ 10 | 11 | #include "LcdBase.h" 12 | #include "mbed.h" 13 | #include "libs/Pin.h" 14 | 15 | class ST7565: public LcdBase { 16 | public: 17 | ST7565(uint8_t v= 0); 18 | virtual ~ST7565(); 19 | void home(); 20 | void clear(); 21 | void display(); 22 | void setCursor(uint8_t col, uint8_t row); 23 | void init(); 24 | void write_char(char value); 25 | void write(const char* line, int len); 26 | 27 | void on_refresh(bool now=false); 28 | //encoder which dosent exist :/ 29 | uint8_t readButtons(); 30 | int readEncoderDelta(); 31 | int getEncoderResolution() { return is_viki2 ? 4 : 2; } 32 | uint16_t get_screen_lines() { return 8; } 33 | bool hasGraphics() { return true; } 34 | 35 | //added ST7565 commands 36 | void send_commands(const unsigned char* buf, size_t size); 37 | void send_data(const unsigned char* buf, size_t size); 38 | // set column and page number 39 | void set_xy(int x, int y); 40 | //send pic to whole screen 41 | void send_pic(const unsigned char* data); 42 | //drawing char 43 | int drawChar(int x, int y, unsigned char c, int color); 44 | // blit a glyph of w pixels wide and h pixels high to x, y. offset pixel position in glyph by x_offset, y_offset. 45 | // span is the width in bytes of the src bitmap 46 | // The glyph bytes will be 8 bits of X pixels, msbit->lsbit from top left to bottom right 47 | void bltGlyph(int x, int y, int w, int h, const uint8_t *glyph, int span= 0, int x_offset=0, int y_offset=0); 48 | void renderGlyph(int x, int y, const uint8_t *g, int pixelWidth, int pixelHeight); 49 | void pixel(int x, int y, int colour); 50 | 51 | uint8_t getContrast() { return contrast; } 52 | void setContrast(uint8_t c); 53 | 54 | void buzz(long duration, uint16_t freq); 55 | void setLed(int led, bool onoff); 56 | 57 | private: 58 | 59 | //buffer 60 | unsigned char *framebuffer; 61 | mbed::SPI* spi; 62 | Pin cs; 63 | Pin rst; 64 | Pin a0; 65 | Pin click_pin; 66 | Pin up_pin; 67 | Pin down_pin; 68 | Pin buzz_pin; 69 | Pin aux_pin; 70 | Pin encoder_a_pin; 71 | Pin encoder_b_pin; 72 | Pin red_led; 73 | Pin blue_led; 74 | 75 | // text cursor position 76 | uint8_t tx, ty; 77 | uint8_t contrast; 78 | struct { 79 | bool reversed:1; 80 | bool is_viki2:1; 81 | bool is_mini_viki2:1; 82 | bool use_pause:1; 83 | bool use_back:1; 84 | }; 85 | }; 86 | 87 | #endif /* ST7565_H_ */ 88 | -------------------------------------------------------------------------------- /src/testframework/Readme.md: -------------------------------------------------------------------------------- 1 | # Test framework 2 | 3 | ## Background 4 | 5 | 6 | This is a frame work for writing unit tests for modules or libs. 7 | It compiles only src/libs/... and a few select needed modules by default. 8 | It runs on the target and the output is written to the serial UART, it runs well with MRI so you can also debug with GDB. 9 | 10 | You can edit a file to specify which module you are going to test by default the example has tools/temperaturecontrol selected. 11 | 12 | The unit tests go in a directory named src/testframework/unittests/*XXXX*/*YYYY* where *XXXX* is the module subdirectory (tools,utils) and *YYYY* is the modulename 13 | 14 | The Kernel and main are replaced with special versions for testing. 15 | 16 | The main way to test is to stimulate the modules by sending it commands via 17 | on_gcode_received() (or other events it is registered for), and monitor its 18 | actions my mocking the ON_PUBLIC_SET/GET calls it makes. A properly written 19 | module does not access other modules any other way. 20 | 21 | Many HAL calls are made via THEKERNEL->xxx (eg THEKERNEL->adc) and these can be intercepted by mocks to provide the module with its external data. 22 | 23 | An example is provided here... 24 | 25 | `src/testframework/unittests/tools/temperatureswitch/TEST_TemperatureSwitch.cpp` 26 | 27 | ## Usage 28 | 29 | You compile a unit test and framework using [rake](http://rake.rubyforge.org/)... 30 | 31 | ```shell 32 | > rake testing=1 33 | > rake upload 34 | ``` 35 | 36 | The unit test will run, the results are printed to the serial uart port, and then it is left in DFU mode so `rake upload` can be run again for the next test. 37 | 38 | You select which tests and modules you want to compile by creating a file called rakefile.defaults in the same directory as the Rakefile is found. 39 | 40 | ```shell 41 | TESTMODULES= %w(tools/temperatureswitch libs) 42 | ``` 43 | 44 | Here we enable unit tests for the tools/temperatureswitch module and any unit tests in src/testframework/unittests/tools/temperatureswitch/. 45 | Also any unittests in the src/testframework/unittests/libs folder will be included 46 | 47 | In this case all files in src/libs/... are compiled anyway so we only need to enable unit tests in the src/testframework/unittests/libs folder. 48 | 49 | the tools/temperatureswitch both compiles all files in the src/modules/tools/temperatureswitch/... directory and enables the 50 | unit tests in src/testframework/unittests/tools/temperatureswitch/... 51 | 52 | by default no other files in the src/modules/... directory tree are compiled unless specified above. 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/modules/tools/zprobe/ZProbe.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see . 6 | */ 7 | 8 | #ifndef ZPROBE_H_ 9 | #define ZPROBE_H_ 10 | 11 | #include "Module.h" 12 | #include "Pin.h" 13 | 14 | #include 15 | 16 | // defined here as they are used in multiple files 17 | #define zprobe_checksum CHECKSUM("zprobe") 18 | #define leveling_strategy_checksum CHECKSUM("leveling-strategy") 19 | 20 | class StepperMotor; 21 | class Gcode; 22 | class StreamOutput; 23 | class LevelingStrategy; 24 | 25 | class ZProbe: public Module 26 | { 27 | 28 | public: 29 | void on_module_loaded(); 30 | void on_config_reload(void *argument); 31 | void on_gcode_received(void *argument); 32 | void acceleration_tick(void); 33 | 34 | bool wait_for_probe(int& steps); 35 | bool run_probe(int& steps, bool fast= false); 36 | bool run_probe_feed(int& steps, float feedrate); 37 | bool return_probe(int steps); 38 | bool doProbeAt(int &steps, float x, float y); 39 | float probeDistance(float x, float y); 40 | 41 | void coordinated_move(float x, float y, float z, float feedrate, bool relative=false); 42 | void home(); 43 | 44 | bool getProbeStatus() { return this->pin.get(); } 45 | float getSlowFeedrate() { return slow_feedrate; } 46 | float getFastFeedrate() { return fast_feedrate; } 47 | float getProbeHeight() { return probe_height; } 48 | float zsteps_to_mm(float steps); 49 | 50 | private: 51 | void accelerate(int c); 52 | 53 | volatile float current_feedrate; 54 | float slow_feedrate; 55 | float fast_feedrate; 56 | float return_feedrate; 57 | float probe_height; 58 | float max_z; 59 | volatile struct { 60 | volatile bool running:1; 61 | bool is_delta:1; 62 | }; 63 | 64 | Pin pin; 65 | uint8_t debounce_count; 66 | std::vector strategies; 67 | }; 68 | 69 | #endif /* ZPROBE_H_ */ 70 | --------------------------------------------------------------------------------