code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
EXTERN(__msp_init) EXTERN(__exc_reset) EXTERN(__exc_nmi) EXTERN(__exc_hardfault) EXTERN(__exc_memmanage) EXTERN(__exc_busfault) EXTERN(__exc_usagefault) EXTERN(__stm32reservedexception7) EXTERN(__stm32reservedexception8) EXTERN(__stm32reservedexception9) EXTERN(__stm32reservedexception10) EXTERN(__exc_svc) EXTERN(__exc_debug_monitor) EXTERN(__stm32reservedexception13) EXTERN(__exc_pendsv) EXTERN(__exc_systick) EXTERN(__irq_wwdg) EXTERN(__irq_pvd) EXTERN(__irq_tamper) EXTERN(__irq_rtc) EXTERN(__irq_flash) EXTERN(__irq_rcc) EXTERN(__irq_exti0) EXTERN(__irq_exti1) EXTERN(__irq_exti2) EXTERN(__irq_exti3) EXTERN(__irq_exti4) EXTERN(__irq_dma1_channel1) EXTERN(__irq_dma1_channel2) EXTERN(__irq_dma1_channel3) EXTERN(__irq_dma1_channel4) EXTERN(__irq_dma1_channel5) EXTERN(__irq_dma1_channel6) EXTERN(__irq_dma1_channel7) EXTERN(__irq_adc) EXTERN(__irq_usb_hp_can_tx) EXTERN(__irq_usb_lp_can_rx0) EXTERN(__irq_can_rx1) EXTERN(__irq_can_sce) EXTERN(__irq_exti9_5) EXTERN(__irq_tim1_brk) EXTERN(__irq_tim1_up) EXTERN(__irq_tim1_trg_com) EXTERN(__irq_tim1_cc) EXTERN(__irq_tim2) EXTERN(__irq_tim3) EXTERN(__irq_tim4) EXTERN(__irq_i2c1_ev) EXTERN(__irq_i2c1_er) EXTERN(__irq_i2c2_ev) EXTERN(__irq_i2c2_er) EXTERN(__irq_spi1) EXTERN(__irq_spi2) EXTERN(__irq_usart1) EXTERN(__irq_usart2) EXTERN(__irq_usart3) EXTERN(__irq_exti15_10) EXTERN(__irq_rtcalarm) EXTERN(__irq_usbwakeup) EXTERN(__irq_tim8_brk) EXTERN(__irq_tim8_up) EXTERN(__irq_tim8_trg_com) EXTERN(__irq_tim8_cc) EXTERN(__irq_adc3) EXTERN(__irq_fsmc) EXTERN(__irq_sdio) EXTERN(__irq_tim5) EXTERN(__irq_spi3) EXTERN(__irq_uart4) EXTERN(__irq_uart5) EXTERN(__irq_tim6) EXTERN(__irq_tim7) EXTERN(__irq_dma2_channel1) EXTERN(__irq_dma2_channel2) EXTERN(__irq_dma2_channel3) EXTERN(__irq_dma2_channel4_5)
2301_81045437/Marlin
buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/vector_symbols.inc
C++
agpl-3.0
1,759
// API compatibility #include "variant.h"
2301_81045437/Marlin
buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/pins_arduino.h
C
agpl-3.0
42
#pragma once #define digitalPinToPort(P) ( PIN_MAP[P].gpio_device ) #define digitalPinToBitMask(P) ( BIT(PIN_MAP[P].gpio_bit) ) #define portOutputRegister(port) ( &(port->regs->ODR) ) #define portInputRegister(port) ( &(port->regs->IDR) ) #define portSetRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->BSRR) ) #define portClearRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->BRR) ) #define portConfigRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->CRL) ) static const uint8_t SS = BOARD_SPI1_NSS_PIN; static const uint8_t SS1 = BOARD_SPI2_NSS_PIN; static const uint8_t MOSI = BOARD_SPI1_MOSI_PIN; static const uint8_t MISO = BOARD_SPI1_MISO_PIN; static const uint8_t SCK = BOARD_SPI1_SCK_PIN;
2301_81045437/Marlin
buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/variant.h
C
agpl-3.0
736
/****************************************************************************** * The MIT License * * Copyright (c) 2010 Perry Hung. * Copyright (c) 2011, 2012 LeafLabs, LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. *****************************************************************************/ /** * @file wirish/boards.cpp * @brief init() and board routines. * * This file is mostly interesting for the init() function, which * configures Flash, the core clocks, and a variety of other available * peripherals on the board so the rest of Wirish doesn't have to turn * things on before using them. * * Prior to returning, init() calls boardInit(), which allows boards * to perform any initialization they need to. This file includes a * weak no-op definition of boardInit(), so boards that don't need any * special initialization don't have to define their own. * * How init() works is chip-specific. See the boards_setup.cpp files * under e.g. wirish/stm32f1/, wirish/stmf32f2 for the details, but be * advised: their contents are unstable, and can/will change without * notice. */ #include <boards.h> #include <libmaple/libmaple_types.h> #include <libmaple/flash.h> #include <libmaple/nvic.h> #include <libmaple/systick.h> #include "boards_private.h" static void setup_flash(void); static void setup_clocks(void); static void setup_nvic(void); static void setup_adcs(void); static void setup_timers(void); /* * Exported functions */ void init(void) { setup_flash(); setup_clocks(); setup_nvic(); systick_init(SYSTICK_RELOAD_VAL); wirish::priv::board_setup_gpio(); setup_adcs(); setup_timers(); wirish::priv::board_setup_usb(); wirish::priv::series_init(); boardInit(); } /* Provide a default no-op boardInit(). */ __weak void boardInit(void) { } /* You could farm this out to the files in boards/ if e.g. it takes * too long to test on boards with lots of pins. */ bool boardUsesPin(uint8 pin) { for (int i = 0; i < BOARD_NR_USED_PINS; i++) { if (pin == boardUsedPins[i]) { return true; } } return false; } /* * Auxiliary routines */ static void setup_flash(void) { // Turn on as many Flash "go faster" features as // possible. flash_enable_features() just ignores any flags it // can't support. flash_enable_features(FLASH_PREFETCH | FLASH_ICACHE | FLASH_DCACHE); // Configure the wait states, assuming we're operating at "close // enough" to 3.3V. flash_set_latency(FLASH_SAFE_WAIT_STATES); } static void setup_clocks(void) { // Turn on HSI. We'll switch to and run off of this while we're // setting up the main PLL. rcc_turn_on_clk(RCC_CLK_HSI); // Turn off and reset the clock subsystems we'll be using, as well // as the clock security subsystem (CSS). Note that resetting CFGR // to its default value of 0 implies a switch to HSI for SYSCLK. RCC_BASE->CFGR = 0x00000000; rcc_disable_css(); rcc_turn_off_clk(RCC_CLK_PLL); rcc_turn_off_clk(RCC_CLK_HSE); wirish::priv::board_reset_pll(); // Clear clock readiness interrupt flags and turn off clock // readiness interrupts. RCC_BASE->CIR = 0x00000000; #if !USE_HSI_CLOCK // Enable HSE, and wait until it's ready. rcc_turn_on_clk(RCC_CLK_HSE); while (!rcc_is_clk_ready(RCC_CLK_HSE)) ; #endif // Configure AHBx, APBx, etc. prescalers and the main PLL. wirish::priv::board_setup_clock_prescalers(); rcc_configure_pll(&wirish::priv::w_board_pll_cfg); // Enable the PLL, and wait until it's ready. rcc_turn_on_clk(RCC_CLK_PLL); while(!rcc_is_clk_ready(RCC_CLK_PLL)) ; // Finally, switch to the now-ready PLL as the main clock source. rcc_switch_sysclk(RCC_CLKSRC_PLL); } /* * These addresses are where usercode starts when a bootloader is * present. If no bootloader is present, the user NVIC usually starts * at the Flash base address, 0x08000000. */ #ifdef BOOTLOADER_maple #define USER_ADDR_ROM 0x08002000 #else #define USER_ADDR_ROM 0x08000000 #endif #define USER_ADDR_RAM 0x20000C00 extern char __text_start__; static void setup_nvic(void) { nvic_init((uint32)VECT_TAB_ADDR, 0); /* Roger Clark. We now control nvic vector table in boards.txt using the build.vect parameter #ifdef VECT_TAB_FLASH nvic_init(USER_ADDR_ROM, 0); #elif defined VECT_TAB_RAM nvic_init(USER_ADDR_RAM, 0); #elif defined VECT_TAB_BASE nvic_init((uint32)0x08000000, 0); #elif defined VECT_TAB_ADDR // A numerically supplied value nvic_init((uint32)VECT_TAB_ADDR, 0); #else // Use the __text_start__ value from the linker script; this // should be the start of the vector table. nvic_init((uint32)&__text_start__, 0); #endif */ } static void adc_default_config(adc_dev *dev) { adc_enable_single_swstart(dev); adc_set_sample_rate(dev, wirish::priv::w_adc_smp); } static void setup_adcs(void) { adc_set_prescaler(wirish::priv::w_adc_pre); adc_foreach(adc_default_config); } static void timer_default_config(timer_dev *dev) { timer_adv_reg_map *regs = (dev->regs).adv; const uint16 full_overflow = 0xFFFF; const uint16 half_duty = 0x8FFF; timer_init(dev); timer_pause(dev); regs->CR1 = TIMER_CR1_ARPE; regs->PSC = 1; regs->SR = 0; regs->DIER = 0; regs->EGR = TIMER_EGR_UG; switch (dev->type) { case TIMER_ADVANCED: regs->BDTR = TIMER_BDTR_MOE | TIMER_BDTR_LOCK_OFF; // fall-through case TIMER_GENERAL: timer_set_reload(dev, full_overflow); for (uint8 channel = 1; channel <= 4; channel++) { if (timer_has_cc_channel(dev, channel)) { timer_set_compare(dev, channel, half_duty); timer_oc_set_mode(dev, channel, TIMER_OC_MODE_PWM_1, TIMER_OC_PE); } } // fall-through case TIMER_BASIC: break; } timer_generate_update(dev); timer_resume(dev); } static void setup_timers(void) { timer_foreach(timer_default_config); }
2301_81045437/Marlin
buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp
C++
agpl-3.0
7,127
/****************************************************************************** * The MIT License * * Copyright (c) 2012 LeafLabs, LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. *****************************************************************************/ /** * @file wirish/stm32f1/boards_setup.cpp * @author Marti Bolivar <mbolivar@leaflabs.com> * @brief STM32F1 chip setup. * * This file controls how init() behaves on the STM32F1. Be very * careful when changing anything here. Many of these values depend * upon each other. */ #include "boards_private.h" #include <libmaple/gpio.h> #include <libmaple/timer.h> #include <boards.h> #include <usb_serial.h> // Allow boards to provide a PLL multiplier. This is useful for // e.g. STM32F100 value line MCUs, which use slower multipliers. // (We're leaving the default to RCC_PLLMUL_9 for now, since that // works for F103 performance line MCUs, which is all that LeafLabs // currently officially supports). namespace wirish { namespace priv { static stm32f1_rcc_pll_data pll_data = {RCC_PLLMUL_6}; #if !USE_HSI_CLOCK __weak rcc_pll_cfg w_board_pll_cfg = {RCC_PLLSRC_HSE, &pll_data}; #else __weak rcc_pll_cfg w_board_pll_cfg = {RCC_PLLSRC_HSI_DIV_2, &pll_data}; #endif __weak adc_prescaler w_adc_pre = ADC_PRE_PCLK2_DIV_6; __weak adc_smp_rate w_adc_smp = ADC_SMPR_55_5; __weak void board_reset_pll(void) { // TODO } __weak void board_setup_clock_prescalers(void) { rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1); rcc_set_prescaler(RCC_PRESCALER_APB1, RCC_APB1_HCLK_DIV_2); rcc_set_prescaler(RCC_PRESCALER_APB2, RCC_APB2_HCLK_DIV_1); rcc_clk_disable(RCC_USB); #if F_CPU == 72000000 rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5); #elif F_CPU == 48000000 rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1); #endif } __weak void board_setup_gpio(void) { gpio_init_all(); } __weak void board_setup_usb(void) { #ifdef SERIAL_USB #ifdef GENERIC_BOOTLOADER //Reset the USB interface on generic boards - developed by Victor PV gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0); for(volatile unsigned int i=0;i<512;i++);// Only small delay seems to be needed, and USB pins will get configured in Serial.begin gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING); #endif Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility #endif } __weak void series_init(void) { // Initialize AFIO here, too, so peripheral remaps and external // interrupts work out of the box. afio_init(); } } }
2301_81045437/Marlin
buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards_setup.cpp
C++
agpl-3.0
4,063
/****************************************************************************** * The MIT License * * Copyright (c) 2011 LeafLabs, LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. *****************************************************************************/ /* * This file is a modified version of a file obtained from * CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the * following text appeared: * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ .text .code 16 .thumb_func .globl __start__ .type __start__, %function __start__: .fnstart ldr r1,=__msp_init mov sp,r1 ldr r1,=start_c bx r1 .pool .cantunwind .fnend
2301_81045437/Marlin
buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/start.S
Unix Assembly
agpl-3.0
2,348
/****************************************************************************** * The MIT License * * Copyright (c) 2011 LeafLabs, LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. *****************************************************************************/ /* * This file is a modified version of a file obtained from * CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the * following text appeared: * * Copyright (c) 2006, 2007 CodeSourcery Inc * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include <stddef.h> extern void __libc_init_array(void); extern int main(int, char**, char**); extern void exit(int) __attribute__((noreturn, weak)); /* The linker must ensure that these are at least 4-byte aligned. */ extern char __data_start__, __data_end__; extern char __bss_start__, __bss_end__; struct rom_img_cfg { int *img_start; }; extern char _lm_rom_img_cfgp; void __attribute__((noreturn)) start_c(void) { struct rom_img_cfg *img_cfg = (struct rom_img_cfg*)&_lm_rom_img_cfgp; int *src = img_cfg->img_start; int *dst = (int*)&__data_start__; int exit_code; /* Initialize .data, if necessary. */ if (src != dst) { int *end = (int*)&__data_end__; while (dst < end) { *dst++ = *src++; } } /* Zero .bss. */ dst = (int*)&__bss_start__; while (dst < (int*)&__bss_end__) { *dst++ = 0; } /* Run initializers. */ __libc_init_array(); /* Jump to main. */ exit_code = main(0, 0, 0); if (exit) { exit(exit_code); } /* If exit is NULL, make sure we don't return. */ for (;;) continue; }
2301_81045437/Marlin
buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/start_c.c
C
agpl-3.0
3,261
/****************************************************************************** * The MIT License * * Copyright (c) 2010 Perry Hung. * Copyright (c) 2011, 2012 LeafLabs, LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. *****************************************************************************/ /** * @file wirish/syscalls.c * @brief newlib stubs * * Low level system routines used by newlib for basic I/O and memory * allocation. You can override most of these. */ #include <libmaple/libmaple.h> #include <sys/stat.h> #include <errno.h> #include <stddef.h> /* If CONFIG_HEAP_START (or CONFIG_HEAP_END) isn't defined, then * assume _lm_heap_start (resp. _lm_heap_end) is appropriately set by * the linker */ #ifndef CONFIG_HEAP_START extern char _lm_heap_start; #define CONFIG_HEAP_START ((void *)&_lm_heap_start) #endif #ifndef CONFIG_HEAP_END extern char _lm_heap_end; #define CONFIG_HEAP_END ((void *)&_lm_heap_end) #endif /* * _sbrk -- Increment the program break. * * Get incr bytes more RAM (for use by the heap). malloc() and * friends call this function behind the scenes. */ void *_sbrk(int incr) { static void * pbreak = NULL; /* current program break */ void * ret; if (pbreak == NULL) { pbreak = CONFIG_HEAP_START; } if ((CONFIG_HEAP_END - pbreak < incr) || (pbreak - CONFIG_HEAP_START < -incr)) { errno = ENOMEM; return (void *)-1; } ret = pbreak; pbreak += incr; return ret; } __weak int _open(const char *path, int flags, ...) { return 1; } __weak int _close(int fd) { return 0; } __weak int _fstat(int fd, struct stat *st) { st->st_mode = S_IFCHR; return 0; } __weak int _isatty(int fd) { return 1; } __weak int isatty(int fd) { return 1; } __weak int _lseek(int fd, off_t pos, int whence) { return -1; } __weak unsigned char getch(void) { return 0; } __weak int _read(int fd, char *buf, size_t cnt) { *buf = getch(); return 1; } __weak void putch(unsigned char c) { } __weak void cgets(char *s, int bufsize) { char *p; int c; int i; for (i = 0; i < bufsize; i++) { *(s+i) = 0; } // memset(s, 0, bufsize); p = s; for (p = s; p < s + bufsize-1;) { c = getch(); switch (c) { case '\r' : case '\n' : putch('\r'); putch('\n'); *p = '\n'; return; case '\b' : if (p > s) { *p-- = 0; putch('\b'); putch(' '); putch('\b'); } break; default : putch(c); *p++ = c; break; } } return; } __weak int _write(int fd, const char *buf, size_t cnt) { int i; for (i = 0; i < cnt; i++) putch(buf[i]); return cnt; } /* Override fgets() in newlib with a version that does line editing */ __weak char *fgets(char *s, int bufsize, void *f) { cgets(s, bufsize); return s; } __weak void _exit(int exitcode) { while (1) ; }
2301_81045437/Marlin
buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/syscalls.c
C
agpl-3.0
4,166
cmake_minimum_required(VERSION 3.5) #====================================================================# # Usage under Linux: # # # # From Marlin/buildroot/share/cmake folder: # # mkdir -p build && cd build # # cmake .. # # make # # # # Usage under Windows: # # # # From Marlin/buildroot/share/cmake folder: # # mkdir build && cd build # # cmake -G"Unix Makefiles" .. # # make # #====================================================================# #====================================================================# # Download marlin-cmake scriptfiles if not already installed # # and add the path to the module path # #====================================================================# set(SCRIPT_BRANCH 1.0.2) #Set to wanted marlin-cmake release tag or branch if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake) file(DOWNLOAD https://github.com/tohara/marlin-cmake/archive/${SCRIPT_BRANCH}.tar.gz ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz SHOW_PROGRESS) execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xvf ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) file(RENAME ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-${SCRIPT_BRANCH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake) file(REMOVE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz) endif() if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules/Arduino_SDK.cmake) file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/master/modules/Arduino_SDK.cmake ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules/Arduino_SDK.cmake SHOW_PROGRESS) endif() if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules/marlin_cmake_functions.cmake) file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/master/modules/marlin_cmake_functions.cmake ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules/marlin_cmake_functions.cmake SHOW_PROGRESS) endif() if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake) file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/master/Platform/Arduino.cmake ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake SHOW_PROGRESS) endif() if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/settings/marlin_boards.txt) file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/master/settings/marlin_boards.txt ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/settings/marlin_boards.txt SHOW_PROGRESS) endif() if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake) file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/master/toolchain/ArduinoToolchain.cmake ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake SHOW_PROGRESS) endif() if(WIN32) if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/resources/make.exe) file(DOWNLOAD https://raw.githubusercontent.com/tohara/marlin-cmake/master/resources/make.exe ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/resources/make.exe SHOW_PROGRESS) endif() endif(WIN32) if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/arduino-1.8.19) file(DOWNLOAD https://downloads.arduino.cc/arduino-1.8.19-windows.zip ${CMAKE_CURRENT_LIST_DIR}/arduino-1.8.19-windows.zip SHOW_PROGRESS) execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xvzf ${CMAKE_CURRENT_LIST_DIR}/arduino-1.8.19-windows.zip WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) file(REMOVE ${CMAKE_CURRENT_LIST_DIR}/arduino-1.8.19-windows.zip) endif() # Print CMake version message("-- Running CMake version: " ${CMAKE_VERSION}) # Replace the CMake Ver. in the Arduino.cmake file(READ "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake" ORIGINAL_FILE_CONTENTS) string(REGEX REPLACE "cmake_minimum_required\\(VERSION[^\n]*\n" "cmake_minimum_required(VERSION 3.5)\n" NEW_FILE_CONTENTS "${ORIGINAL_FILE_CONTENTS}") file(WRITE "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake" "${NEW_FILE_CONTENTS}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules) #====================================================================# # Custom path to Arduino SDK can be set here. # # It can also be set from command line. eg.: # # cmake .. -DARDUINO_SDK_PATH="/path/to/arduino-1.x.x" # #====================================================================# set(ARDUINO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}/arduino-1.8.19) #set(ARDUINO_SDK_PATH /Applications/Arduino.app/Contents/Java) #set(ARDUINO_SDK_PATH $HOME/ArduinoAddons/Arduino_1.6.x) #====================================================================# # Set included cmake files # #====================================================================# include(Arduino_SDK) # Find the intallpath of Arduino SDK include(marlin_cmake_functions) #====================================================================# # Set toolchain file for arduino # #====================================================================# set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/ArduinoToolchain.cmake) # Arduino Toolchain #====================================================================# # Setup Project # # # # If you receive this error: # # 'Unknown CMake command "_cmake_record_install_prefix".' # # # # Go to the file in your CMake directory. # # # # For Windows: cmake\Modules\Platform\WindowsPaths.cmake # # For Linux: cmake/Modules/Platform/UnixPaths.cmake # # # # Comment out "_cmake_record_install_prefix()" # # - OR - # # Add "include(CMakeSystemSpecificInformation)" above the line. # # # #====================================================================# project(Marlin C CXX) #====================================================================# # Register non standard hardware # #====================================================================# #register_hardware_platform(/home/tom/test/Sanguino) #====================================================================# # Print any info # # print_board_list() # # print_programmer_list() # # print_board_settings(mega) # #====================================================================# print_board_list() print_programmer_list() #====================================================================# # Get motherboard settings from Configuration.h # # setup_motherboard(TARGET Marlin_src_folder) # # Returns ${TARGET}_BOARD and ${TARGET}_CPU # # # # To set it manually: # # set(${PROJECT_NAME}_BOARD mega) # # set(${PROJECT_NAME}_CPU atmega2560) # #====================================================================# setup_motherboard(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../../Marlin) #====================================================================# # Setup all source files # # Include Marlin.ino to compile libs not included in *.cpp files # #====================================================================# file(GLOB_RECURSE SOURCES "../../../Marlin/*.cpp") set(${PROJECT_NAME}_SRCS "${SOURCES};../../../Marlin/Marlin.ino") #====================================================================# # Define the port for uploading code to the Arduino # # Can be set from commandline with: # # cmake .. -DUPLOAD_PORT=/dev/ttyACM0 # #====================================================================# if(UPLOAD_PORT) set(${PROJECT_NAME}_PORT ${UPLOAD_PORT}) else() set(${PROJECT_NAME}_PORT /dev/ttyACM0) endif() #====================================================================# # Register arduino libraries not included in SDK # #====================================================================# #link_directories(/home/tom/test/ArduinoAddons) #U8glib #set(${PROJECT_NAME}_ARDLIBS U8glib) #set(U8glib_RECURSE True) #====================================================================# # Command to generate code arduino firmware (.hex file) # #====================================================================# generate_arduino_firmware(${PROJECT_NAME})
2301_81045437/Marlin
buildroot/share/cmake/CMakeLists.txt
CMake
agpl-3.0
10,073
#!/usr/bin/env bash mkdir -p icons-4 convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/hotend_off.svg ./icons-4/001-ICON_HotendOff.jpg convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/hotend_on.svg ./icons-4/002-ICON_HotendOn.jpg convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_off.svg ./icons-4/003-ICON_BedOff.jpg convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_on.svg ./icons-4/004-ICON_BedOn.jpg convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/fan.svg ./icons-4/005-ICON_Fan0.jpg convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 22.5 ./icons-svg/fan.svg ./icons-4/006-ICON_Fan1.jpg convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 45 ./icons-svg/fan.svg ./icons-4/007-ICON_Fan2.jpg convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 67.5 ./icons-svg/fan.svg ./icons-4/008-ICON_Fan3.jpg convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/halted.svg ./icons-4/009-ICON_Halted.jpg convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/question.svg ./icons-4/010-ICON_Question.jpg convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/alert.svg ./icons-4/011-ICON_Alert.jpg convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/rotate_cw.svg ./icons-4/012-ICON_RotateCW.jpg convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/rotate_ccw.svg ./icons-4/013-ICON_RotateCCW.jpg convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/up_arrow.svg ./icons-4/014-ICON_UpArrow.jpg convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/down_arrow.svg ./icons-4/015-ICON_DownArrow.jpg convert -size 48x8 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bedline.svg ./icons-4/016-ICON_Bedline.jpg convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_leveled_off.svg ./icons-4/017-ICON_BedLeveledOff.jpg convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_leveled_on.svg ./icons-4/018-ICON_BedLeveledOn.jpg rm -f 4.ICO ./bin/makeIco.py icons-4 4.ICO
2301_81045437/Marlin
buildroot/share/dwin/make_jpgs.sh
Shell
agpl-3.0
2,737
/** * Marlin 3D Printer Firmware * Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program 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. * * This program 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. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ /** * $(filename) */
2301_81045437/Marlin
buildroot/share/extras/file_header.h
C
agpl-3.0
887
/** * $(function) : Description pending * * $(javaparam) */
2301_81045437/Marlin
buildroot/share/extras/func_header.h
C
agpl-3.0
64
CFLAGS = -g -Wall #CFLAGS = -O4 -Wall SRC = bdf2u8g.c OBJ = $(SRC:.c=.o) bdf2u8g: $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o bdf2u8g.exe clean: -rm $(OBJ) bdf2u8g.exe test: ./bdf2u8g.exe -f 2 ../bdf/9x18.bdf u8g_aafont_9x18 u8g_aafont_9x18.c
2301_81045437/Marlin
buildroot/share/fonts/bdf2u8g/Makefile
Makefile
agpl-3.0
251
/* general font collections http://www.smashingmagazine.com/2007/11/08/40-excellent-freefonts-for-professional-design/ http://techmagazine.ws/most-popular-free-quality-fonts/ http://openfontlibrary.org/ bitmap font collections http://www.orgdot.com/aliasfonts/ (includes links) http://www.04.jp.org/ http://www.miniml.com http://www.fontspace.com/010bus http://en.wikipedia.org/wiki/Unicode_typeface da könnten auch ein paar fonts dabei sein, die die m2tklib sonderzeichen beinhalten: Caslon Roman http://en.wikipedia.org/wiki/Caslon_Roman Charis Sil http://en.wikipedia.org/wiki/Charis_SIL DejaVu Sans http://en.wikipedia.org/wiki/DejaVu_fonts Doulos http://en.wikipedia.org/wiki/Doulos_SIL Free Serif http://en.wikipedia.org/wiki/FreeSerif http://ftp.gnu.org/gnu/freefont/ --> keine box, aber es gibt pfeile/invertierte pfeile und kreise für m2tklib Gentium Plus ???? http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=Gentium_download#02b091ae --> keine graphic GNU Unifont http://en.wikipedia.org/wiki/GNU_Unifont, http://unifoundry.com/unifont.html Titus cyberbit Basic http://en.wikipedia.org/wiki/TITUS_Cyberbit_Basic fonts Gentium http://openfontlibrary.org/font/gentium license: OFL Old-Standard http://openfontlibrary.org/font/old-standard license: OFL Hanuman http://openfontlibrary.org/font/hanumanb license: OFL FreeUniversal http://openfontlibrary.org/font/freeuniversal license: OFL FriendShip-Code <--- nicht so sicher... http://openfontlibrary.org/font/friendship-code license: CC-BY-SA LinuxLibertine http://de.wikipedia.org/wiki/Linux_Libertine http://sourceforge.net/projects/linuxlibertine/files/linuxlibertine/5.1.3-2/ license: OFL DidactGothic source: http://openfontlibrary.org/ judson source: http://openfontlibrary.org/ unicons source: http://openfontlibrary.org/ license: OFL suggested pt: 26, 30 org_V01, fixed_V0 source: http://www.orgdot.com/aliasfonts/ license: open source, individual, cite required suggested pt: 8 04b_03b.zip 04b_03.zip 04b_09.zip 04b_11.zip 04b_19.zip 04b_21.zip 04b_25.zip 04b_30.zip source: http://www.04.jp.org/ license: "Freeware: You may use them as you like" 7px4bus source: http://www.fontspace.com/010bus license: Licensed as: Freeware, Commercial use allowed! suggested 7pt 8pxbus source: http://www.fontspace.com/010bus license: Licensed as: Freeware, Commercial use allowed! suggested 8pt */ /* only supports metric set "0" assume DWIDTH second arg to be 0 for all glyphs assumes that (0,0) of the BBX is placed on the base line assumes ISO10646 encoding of the BDF file font information offset 0 font format 1 FONTBOUNDINGBOX width unsigned 2 FONTBOUNDINGBOX height unsigned 3 FONTBOUNDINGBOX x-offset signed 4 FONTBOUNDINGBOX y-offset signed 5 capital A height unsigned 6 start 'A' 8 start 'a' 10 encoding start 11 encoding end 12 descent 'g' negative: below baseline 13 font max ascent 14 font min decent negative: below baseline 15 xascent (ascent of "(") 16 xdescent (descent of ")") format 0 glyph information offset 0 BBX width unsigned 1 BBX height unsigned 2 data size unsigned (BBX width + 7)/8 * BBX height 3 DWIDTH signed 4 BBX xoffset signed 5 BBX yoffset signed format 1 0 BBX xoffset signed --> upper 4 Bit 0 BBX yoffset signed --> lower 4 Bit 1 BBX width unsigned --> upper 4 Bit 1 BBX height unsigned --> lower 4 Bit 2 data size unsigned -(BBX width + 7)/8 * BBX height --> lower 4 Bit 2 DWIDTH signed --> upper 4 Bit byte 0 == 255 indicates empty glyph format 2 like format 0, but 4 gray levels for the glyph (4 pixel per byte in the glyph data) The glyph bitmap size is defined by BBX width and BBX height number of bytes in the bitmap data (BBX width + 7)/8 * BBX height (format 0 and 1) draw_text(x,y,str) get_text_frame(x,y,str, &x1, &y1, &width, &height) frame( x1, y1, width, height) underline( x1, y-1, width ) size of the surrounding bbox width = - xoffset(c1) + DWIDTH(c1) + DWIDTH(c2) + ... + DWIDTH(cn-1) + width(cn) + xoffset(cn) height = FONTBOUNDINGBOX height x1 = x + xoffset(c1) y1 = y + yoffset(c1) ISO-8859-1 was incorporated as the first 256 code points of ISO/IEC 10646 and Unicode. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #define BDF2U8G_COMPACT_OUTPUT #define BDF2U8G_VERSION "1.01" //#define VERBOSE /*=== forward declaration ===*/ void bdf_aa_ClearDoShow(void); void bdf_aa_Do(void); /*=== result data ===*/ #define DATA_BUF_SIZE (1024 * 64) unsigned char data_buf[DATA_BUF_SIZE]; int data_pos = 0; void data_Init(void) { data_pos = 0; } void data_Put(unsigned char c) { data_buf[data_pos] = c; data_pos++; } void data_Write(FILE *out_fp, const char *indent) { int i; int bytes_per_line = 16; for (i = 0; i < data_pos; i++) { fprintf(out_fp, "0x%02X", data_buf[i]); if (i + 1 != data_pos) fprintf(out_fp, ","); if ((i + 1) % bytes_per_line == 0) fprintf(out_fp, "\n%s", indent); } } /*=== low level parser ===*/ #define P_BUF_SIZE (1024 * 4) int p_current_char; const char *p_line; char p_buf[P_BUF_SIZE]; /* put next char into p_current_char */ static int p_next_char(void) { p_current_char = *p_line; if (p_current_char == '\0') return 0; p_line++; return 1; } int p_first_char(const char *line) { p_line = line; return p_next_char(); } void p_err(const char *msg) { } int p_skip_space(void) { for (;;) { if (p_current_char == 0 || p_current_char > 32) break; if (p_next_char() == 0) return 0; } return 1; } /* put identifier into p_buf */ int p_get_identifier(void) { int i = 0; if (p_current_char == '\0') return p_err("unexpected EOF (expected identifier)"), 0; for (;;) { if (p_current_char <= 32) break; p_buf[i++] = p_current_char; if (p_next_char() == 0) break; } p_buf[i++] = '\0'; p_skip_space(); return 1; } /* put identifier into p_buf */ int p_get_identifier_with_blank(void) { int i = 0; for (;;) { if (p_current_char < 32) break; p_buf[i++] = p_current_char; if (p_next_char() == 0) break; } p_buf[i++] = '\0'; p_skip_space(); return 1; } int p_get_string(void) { int i = 0; if (p_current_char == '\0') return 0; if (p_current_char != '\"') return p_err("\" expected"), 0; if (p_next_char() == 0) return p_err("unexpected EOF (\")"), 0; for (;;) { if (p_current_char == '\\') { if (p_next_char() == 0) return p_err("unexpected EOF (\\)"), 0; } else if (p_current_char == '\"') { p_next_char(); break; } p_buf[i++] = p_current_char; if (p_next_char() == 0) return p_err("unexpected EOF (\")"), 0; } p_buf[i] = '\0'; return 1; } int p_get_any(void) { if (p_current_char == '\"') return p_get_string(); return p_get_identifier(); } int p_get_val(void) { p_get_any(); return atoi(p_buf); } int p_get_hex(void) { int value = 0; if (p_current_char >= '0' && p_current_char <= '9') value = p_current_char - '0'; else if (p_current_char >= 'a' && p_current_char <= 'f') value = p_current_char - 'a' + 10; else if (p_current_char >= 'A' && p_current_char <= 'F') value = p_current_char - 'A' + 10; p_next_char(); return value; } int p_get_hex_byte(void) { int v; v = p_get_hex(); v *= 16; v += p_get_hex(); return v; } /*=== encoding mapping ===*/ /* the internal u8g index number (0..255) is mapped to the unicode number */ /* for the conversion we need the reverse search */ /* 0 is special and means not found */ int map_u8g_to_unicode[256]; int map_UnicodeToU8G(int unicode) { int i; for (i = 0; i < 256; i++) if (map_u8g_to_unicode[i] == unicode) return i; return 0; } void map_Init(void) { int i; map_u8g_to_unicode[0] = 0; for (i = 0; i < 256; i++) map_u8g_to_unicode[i] = i; } void map_UpperLowerPage(int lower_page, int upper_page, int shift, int upper_shift) { int i; int encoding; int tmp[256]; // map_u8g_to_unicode[0] = 0; for (i = 0; i < 128; i++) { encoding = i + lower_page * 128; map_u8g_to_unicode[i] = encoding; } for (i = 128; i < 256; i++) { encoding = i - 128 + upper_page * 128; if (i + upper_shift < 256) map_u8g_to_unicode[i + upper_shift] = encoding; } for (i = 0; i < 256; i++) tmp[i] = map_u8g_to_unicode[i]; for (i = 0; i < shift; i++) map_u8g_to_unicode[i] = -1; for (i = shift; i < 256; i++) map_u8g_to_unicode[i] = tmp[(i + 256 - shift) % 256]; /* printf("map_u8g_to_unicode[ 32 ] = %d\n", map_u8g_to_unicode[ 32 ]); printf("map_u8g_to_unicode[ 33 ] = %d\n", map_u8g_to_unicode[ 33 ]); */ } /*=== store bdf file positions ===*/ long bdf_last_line_start_pos; long bdf_encoding_pos[256]; void bdf_InitFilePos(void) { int i; for (i = 0; i < 256; i++) bdf_encoding_pos[i] = 0; } void bdf_SetFilePos(FILE *fp, int encoding) { if (encoding < 0) return; if (bdf_encoding_pos[encoding] == 0L) return; fseek(fp, bdf_encoding_pos[encoding], SEEK_SET); // fprintf(stderr, "setting file for encoding %d to pos %ld\n", encoding, bdf_encoding_pos[encoding]); } int bdf_IsEncodingAvailable(int encoding) { if (bdf_encoding_pos[encoding] == 0L) // printf("encoding %d not availabe\n", encoding); return 0; return 1; } void bdf_StoreFilePos(int encoding, long pos) { // if ( encoding == 33 ) // printf("encoding %d at pos %ld\n", encoding, pos); if (bdf_encoding_pos[encoding] != 0L) return; bdf_encoding_pos[encoding] = pos; } /*=== bdf file read ===*/ int bdf_font_format = 0; #define BDF_STATE_FONT_DATA 0 #define BDF_STATE_ENCODING 1 int bdf_state = BDF_STATE_FONT_DATA; int bdf_requested_encoding = 0; #define BDF_LINE_MAX (1024 * 4) #define BDF_LINE_STATE_KEYWORDS 0 #define BDF_LINE_STATE_BITMAP 1 #define BDF_MAX_HEIGHT 200 #define BDF_AA_OFFSET 1 char bdf_copyright[BDF_LINE_MAX]; char bdf_font[BDF_LINE_MAX]; unsigned char bdf_bitmap_line[BDF_MAX_HEIGHT][20]; unsigned char bdf_aa_bitmap_line[BDF_MAX_HEIGHT + 2 * BDF_AA_OFFSET][(20 + 2 * BDF_AA_OFFSET) * 8]; int bdf_line_state = BDF_LINE_STATE_KEYWORDS; int bdf_line_bm_line = 0; int bdf_font_size; /* point font size */ int bdf_font_width; /* FONTBOUNDINGBOX arg 1 */ int bdf_font_height; /* FONTBOUNDINGBOX arg 2 */ int bdf_font_x; /* FONTBOUNDINGBOX arg 3 */ int bdf_font_y; /* FONTBOUNDINGBOX arg 4 */ int bdf_capital_A_height; int bdf_capital_1_height; int bdf_lower_g_descent; int bdf_char_width; /* BBX arg 1 */ int bdf_char_max_width; int bdf_char_height; /* BBX arg 2 */ int bdf_char_ascent; /* defined as BBX arg 2 + BBX arg 4 */ int bdf_char_xascent; int bdf_char_xdescent; int bdf_char_max_ascent; int bdf_char_max_height; int bdf_char_x; /* BBX arg 3 */ int bdf_char_max_x; int bdf_char_min_x; int bdf_char_y; /* BBX arg 4 */ int bdf_char_max_y; int bdf_char_min_y; int bdf_delta_x_default = -1; int bdf_delta_x = -1; /* DWIDTH arg 1 */ int bdf_delta_max_x; int bdf_delta_min_x; int bdf_delta_y; /* DWIDTH arg 2 */ int bdf_delta_max_y; int bdf_delta_min_y; int bdf_glyph_data_len; int bdf_glyph_data_max_len; int bdf_encoding; int bdf_encoding_65_pos; int bdf_encoding_97_pos; int bdf_is_encoding_successfully_done; char bdf_info[32000 * 2]; int bdf_is_put_glyph_completed = 0; /* indicator, when the glyph has been processed */ void bdf_ResetMax(void) { bdf_char_max_width = 0; bdf_char_max_height = 0; bdf_char_max_x = 0; bdf_char_max_y = 0; bdf_delta_max_x = 0; bdf_delta_max_y = 0; bdf_char_min_x = 0; bdf_char_min_y = 0; bdf_delta_min_x = 0; bdf_delta_min_y = 0; bdf_glyph_data_max_len = 0; bdf_char_max_ascent = 0; bdf_char_xascent = 0; bdf_char_xdescent = 0; } void bdf_UpdateMax(void) { if (bdf_char_max_width < bdf_char_width) bdf_char_max_width = bdf_char_width; if (bdf_char_max_height < bdf_char_height) bdf_char_max_height = bdf_char_height; if (bdf_char_max_x < bdf_char_x) bdf_char_max_x = bdf_char_x; if (bdf_char_max_y < bdf_char_y) bdf_char_max_y = bdf_char_y; if (bdf_delta_max_x < bdf_delta_x) bdf_delta_max_x = bdf_delta_x; if (bdf_delta_max_y < bdf_delta_y) bdf_delta_max_y = bdf_delta_y; if (bdf_char_min_x > bdf_char_x) bdf_char_min_x = bdf_char_x; if (bdf_char_min_y > bdf_char_y) bdf_char_min_y = bdf_char_y; if (bdf_delta_min_x > bdf_delta_x) bdf_delta_min_x = bdf_delta_x; if (bdf_delta_min_y > bdf_delta_y) bdf_delta_min_y = bdf_delta_y; if (bdf_glyph_data_max_len < bdf_glyph_data_len) bdf_glyph_data_max_len = bdf_glyph_data_len; if (bdf_char_max_ascent < bdf_char_ascent) bdf_char_max_ascent = bdf_char_ascent; } void bdf_ShowGlyph(void) { #ifdef VERBOSE int x, y, byte, bit; int gx, gy; char *p; gy = bdf_char_height - 1 + bdf_char_y; printf("bbx %d %d %d %d encoding %d\n", bdf_char_width, bdf_char_height, bdf_char_x, bdf_char_y, bdf_encoding); for (y = 0; y < bdf_line_bm_line; y++) { printf("%02d ", gy); gx = bdf_char_x; for (x = 0; x < bdf_char_width; x++) { byte = x >> 3; bit = 7 - (x & 7); if ((bdf_bitmap_line[y][byte] & (1 << bit)) == 0) p = " ."; else p = " *"; if (gy == 0 && gx == 0) p = " o"; printf("%s", p); gx++; } printf(" "); for (x = 0; x < ((bdf_char_width + 7) / 8); x++) printf( "%02X", bdf_bitmap_line[y][x]); gy--; printf("\n"); } #else printf("bbx %d %d %d %d encoding %d\n", bdf_char_width, bdf_char_height, bdf_char_x, bdf_char_y, bdf_encoding); fflush(stdout); #endif } void bdf_ClearGlyphBuffer(void) { int x, y; for (y = 0; y < BDF_MAX_HEIGHT; y++) for (x = 0; x < 20; x++) bdf_bitmap_line[y][x] = 0; } void bdf_PutGlyph(void) { int len; int y, x; if (bdf_state == BDF_STATE_ENCODING) { //if (bdf_char_width == 0 && bdf_char_height == 0) bdf_char_y = 0; bdf_char_ascent = bdf_char_height + bdf_char_y; //printf("h:%d w:%d ascent: %d\n", bdf_char_height, bdf_char_width, bdf_char_ascent); if (bdf_encoding == 'A') bdf_capital_A_height = bdf_char_height; if (bdf_encoding == '1') bdf_capital_1_height = bdf_char_height; if (bdf_encoding == 'g') bdf_lower_g_descent = bdf_char_y; if (bdf_char_xascent < bdf_capital_A_height) bdf_char_xascent = bdf_capital_A_height; if (bdf_char_xascent < bdf_capital_1_height) bdf_char_xascent = bdf_capital_1_height; if (bdf_encoding == '(') if (bdf_char_xascent < bdf_char_ascent) bdf_char_xascent = bdf_char_ascent; if (bdf_encoding == '[') if (bdf_char_xascent < bdf_char_ascent) bdf_char_xascent = bdf_char_ascent; if (bdf_char_xdescent > bdf_lower_g_descent) bdf_char_xdescent = bdf_lower_g_descent; if (bdf_encoding == '(') if (bdf_char_xdescent > bdf_char_y) bdf_char_xdescent = bdf_char_y; if (bdf_encoding == '[') if (bdf_char_xdescent > bdf_char_y) bdf_char_xdescent = bdf_char_y; if (bdf_requested_encoding != bdf_encoding) return; assert( bdf_line_bm_line == bdf_char_height); bdf_ShowGlyph(); #ifdef VERBOSE bdf_aa_ClearDoShow(); #endif bdf_UpdateMax(); if (bdf_font_format <= 1) len = (bdf_char_width + 7) / 8 * bdf_char_height; else len = (bdf_char_width + 2 * BDF_AA_OFFSET + 3) / 4 * (bdf_char_height + 2 * BDF_AA_OFFSET); if (len > 255) { fprintf(stderr, "Glyph with encoding %d is too large (%d > 255)\n", bdf_encoding, len); exit(1); } bdf_glyph_data_len = len; /* format 0 and format 2 glyph information offset 0 BBX width unsigned 1 BBX height unsigned 2 data size unsigned (BBX width + 7)/8 * BBX height 3 DWIDTH signed 4 BBX xoffset signed 5 BBX yoffset signed */ if (bdf_font_format == 0) { data_Put(bdf_char_width); data_Put(bdf_char_height); data_Put(bdf_glyph_data_len); data_Put(bdf_delta_x); data_Put(bdf_char_x); data_Put(bdf_char_y); // data_Put(bdf_encoding); bdf_is_encoding_successfully_done = 1; } else if (bdf_font_format == 2) { data_Put(bdf_char_width + 2 * BDF_AA_OFFSET); data_Put(bdf_char_height + 2 * BDF_AA_OFFSET); data_Put(bdf_glyph_data_len); data_Put(bdf_delta_x); data_Put(bdf_char_x - BDF_AA_OFFSET); data_Put(bdf_char_y - BDF_AA_OFFSET); // data_Put(bdf_encoding); bdf_is_encoding_successfully_done = 1; } else { /** * format 1 * 0 BBX xoffset signed --> upper 4 Bit * 0 BBX yoffset signed --> lower 4 Bit * 1 BBX width unsigned --> upper 4 Bit * 1 BBX height unsigned --> lower 4 Bit * 2 data size unsigned -(BBX width + 7)/8 * BBX height --> lower 4 Bit * 2 DWIDTH signed --> upper 4 Bit * byte 0 == 255 indicates empty glyph */ if (bdf_glyph_data_len < 0 || bdf_glyph_data_len > 15) { fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (data len = %d)\n", bdf_encoding, bdf_glyph_data_len); exit(1); } if (bdf_delta_x < 0 || bdf_delta_x > 15) { fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (DWIDTH = %d)\n", bdf_encoding, bdf_delta_x); exit(1); } if (bdf_char_x < 0 || bdf_char_x > 15) { fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (x-off = %d)\n", bdf_encoding, bdf_char_x); exit(1); } if (bdf_char_y < -2 || bdf_char_y > 13) { fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (y-off = %d [%d..%d])\n", bdf_encoding, bdf_char_y, bdf_char_min_y, bdf_char_max_y); exit(1); } if (bdf_char_width < 0 || bdf_char_width > 15) { fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (width = %d)\n", bdf_encoding, bdf_char_width); exit(1); } if (bdf_char_height < 0 || bdf_char_height > 15) { fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (height = %d)\n", bdf_encoding, bdf_char_height); exit(1); } // data_Put(bdf_encoding); if (((bdf_char_x << 4) | (bdf_char_y + 2)) == 255) { fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (skip mark generated)\n", bdf_encoding); exit(1); } data_Put((bdf_char_x << 4) | (bdf_char_y + 2)); data_Put((bdf_char_width << 4) | bdf_char_height ); data_Put((bdf_delta_x << 4) | bdf_glyph_data_len ); bdf_is_encoding_successfully_done = 1; } sprintf(bdf_info + strlen(bdf_info), "/* encoding %d %c, bbx %d %d %d %d asc %d dx %d*/\n", bdf_encoding, bdf_encoding > 32 && bdf_encoding <= 'z' ? bdf_encoding : ' ', bdf_char_width, bdf_char_height, bdf_char_x, bdf_char_y, bdf_char_ascent, bdf_delta_x); if (bdf_font_format <= 1) { for (y = 0; y < bdf_char_height; y++) for (x = 0; x < ((bdf_char_width + 7) / 8); x++) { data_Put(bdf_bitmap_line[y][x]); len--; } assert( len == 0 ); bdf_is_put_glyph_completed = 1; } else { /* format == 2 */ int b, cnt; bdf_aa_Do(); for (y = 0; y < bdf_char_height + 2 * BDF_AA_OFFSET; y++) { b = 0; cnt = 0; for (x = 0; x < bdf_char_width + 2 * BDF_AA_OFFSET; x++) { b <<= 2; b |= bdf_aa_bitmap_line[y][x] & 3; cnt++; if (cnt == 4) { data_Put(b); b = 0; cnt = 0; len--; } } if (cnt != 0) { b <<= 2 * (4 - cnt); data_Put(b); b = 0; cnt = 0; len--; } } assert( len == 0 ); } } } /*=========================================================================*/ /* Glyph Clipping */ int bdf_IsColZero(int x) { int y, byte, bit; for (y = 0; y < bdf_char_height; y++) { byte = x >> 3; bit = 7 - (x & 7); if ((bdf_bitmap_line[y][byte] & (1 << bit)) != 0) return 0; } return 1; } int bdf_IsRowZero(int y) { int x, byte, bit; for (x = 0; x < bdf_char_width; x++) { byte = x >> 3; bit = 7 - (x & 7); if ((bdf_bitmap_line[y][byte] & (1 << bit)) != 0) return 0; } return 1; } void bdf_DeleteFirstCol(void) { int m = (bdf_char_width + 7) / 8; int x, y; for (y = 0; y < bdf_char_height; y++) for (x = 0; x < m; x++) { bdf_bitmap_line[y][x] <<= 1; bdf_bitmap_line[y][x] |= bdf_bitmap_line[y][x + 1] >> 7; } } void bdf_DeleteFirstRow(void) { int m = (bdf_char_width + 7) / 8; int x, y; for (y = 0; y + 1 < bdf_char_height; y++) for (x = 0; x < m; x++) bdf_bitmap_line[y][x] = bdf_bitmap_line[y + 1][x]; } void bdf_ReduceGlyph(void) { while (bdf_char_width > 0) { if (bdf_IsColZero(bdf_char_width - 1) == 0) break; bdf_char_width--; } while (bdf_char_height > 0) { if (bdf_IsRowZero(bdf_char_height - 1) == 0) break; bdf_line_bm_line--; bdf_char_height--; bdf_char_y++; } while (bdf_IsColZero(0) != 0 && bdf_char_width > 0) { bdf_DeleteFirstCol(); bdf_char_x++; bdf_char_width--; } while (bdf_char_height > 0) { if (bdf_IsRowZero(0) == 0) break; bdf_DeleteFirstRow(); bdf_line_bm_line--; bdf_char_height--; } } /*=========================================================================*/ /* Anti Aliasing / Graylevel Glyph */ int bdf_GetXYVal(int x, int y) { int byte, bit; if (x < 0) return 0; if (y < 0) return 0; if (x >= bdf_char_width) return 0; if (y >= bdf_char_height) return 0; byte = x >> 3; bit = 7 - (x & 7); if ((bdf_bitmap_line[y][byte] & (1 << bit)) != 0) return 1; return 0; } void bdf_aa_Clear(void) { int x, y; for (y = 0; y < BDF_MAX_HEIGHT + 2 * BDF_AA_OFFSET; y++) for (x = 0; x < (20 + 2 * BDF_AA_OFFSET) * 8; x++) bdf_aa_bitmap_line[y][x] = 0; } void bdf_aa_SetXYVal(int x, int y, int val) { bdf_aa_bitmap_line[y][x] = val; } int bdf_aa_matrix[9] = { 1, 3, 1, 3, 4, 3, 1, 3, 1 }; int bdf_aa_sum = 20; int bdf_aa_gray_levels = 4; void bdf_aa_Do(void) { int x, y, val, sx, sy, sum, gray; bdf_aa_Clear(); for (y = 0; y < bdf_char_height + 2 * BDF_AA_OFFSET; y++) for (x = 0; x < bdf_char_width + 2 * BDF_AA_OFFSET; x++) { if (bdf_GetXYVal(x - BDF_AA_OFFSET, y - BDF_AA_OFFSET) == 0) { sum = 0; for (sy = -BDF_AA_OFFSET; sy <= BDF_AA_OFFSET; sy++) for (sx = -BDF_AA_OFFSET; sx <= BDF_AA_OFFSET; sx++) { val = bdf_GetXYVal(x + sx - BDF_AA_OFFSET, y + sy - BDF_AA_OFFSET); val *= bdf_aa_matrix[(sy + BDF_AA_OFFSET) * (2 * BDF_AA_OFFSET + 1) + sx + BDF_AA_OFFSET]; sum += val; } if (sum <= 5) gray = 0; else gray = (sum * (bdf_aa_gray_levels - 1) + (bdf_aa_sum / 2)) / bdf_aa_sum; if (gray >= bdf_aa_gray_levels) gray = bdf_aa_gray_levels - 1; } else { gray = bdf_aa_gray_levels - 1; } bdf_aa_SetXYVal(x, y, gray); } } void bdf_aa_Show(void) { int x, y; if (bdf_font_format == 2) { for (y = 0; y < bdf_char_height + 2 * BDF_AA_OFFSET; y++) { for (x = 0; x < bdf_char_width + 2 * BDF_AA_OFFSET; x++) switch (bdf_aa_bitmap_line[y][x]) { case 0: printf("."); break; case 1: printf("-"); break; case 2: printf("+"); break; case 3: printf("#"); break; } printf("\n"); } } } void bdf_aa_ClearDoShow(void) { bdf_aa_Do(); bdf_aa_Show(); } /*=========================================================================*/ /* Parser */ void bdf_ReadLine(const char *s) { /* if ( bdf_line_state == BDF_LINE_STATE_BITMAP && bdf_requested_encoding != bdf_encoding && *s != 'E' ) return; */ if (p_first_char(s) == 0) return; if (p_skip_space() == 0) return; if (bdf_line_state == BDF_LINE_STATE_KEYWORDS) { p_get_identifier(); if (strcmp(p_buf, "COPYRIGHT") == 0) { p_get_any(); strcpy(bdf_copyright, p_buf); } else if (strcmp(p_buf, "FONT") == 0) { /* p_get_any(); */ p_get_identifier_with_blank(); strcpy(bdf_font, p_buf); } else if (strcmp(p_buf, "SIZE") == 0) { bdf_font_size = p_get_val(); } else if (strcmp(p_buf, "ENCODING") == 0) { bdf_encoding = map_UnicodeToU8G(p_get_val()); bdf_StoreFilePos(bdf_encoding, bdf_last_line_start_pos); } else if (strcmp(p_buf, "DWIDTH") == 0) { bdf_delta_x = p_get_val(); bdf_delta_y = p_get_val(); } else if (strcmp(p_buf, "FONTBOUNDINGBOX") == 0) { bdf_font_width = p_get_val(); bdf_font_height = p_get_val(); bdf_font_x = p_get_val(); bdf_font_y = p_get_val(); } else if (strcmp(p_buf, "BBX") == 0) { bdf_char_width = p_get_val(); bdf_char_height = p_get_val(); bdf_char_x = p_get_val(); bdf_char_y = p_get_val(); bdf_char_ascent = bdf_char_height + bdf_char_y; // printf("h:%d w:%d ascent: %d\n", bdf_char_height, bdf_char_width, bdf_char_ascent); } else if (strcmp(p_buf, "CHARS") == 0) { if (bdf_delta_x < 0) bdf_delta_x = 0; if (bdf_delta_x_default < 0) bdf_delta_x_default = bdf_delta_x; } else if (strcmp(p_buf, "STARTCHAR") == 0) { if (bdf_delta_x_default < 0) bdf_delta_x_default = 0; bdf_delta_x = bdf_delta_x_default; } else if (strcmp(p_buf, "BITMAP") == 0) { bdf_line_state = BDF_LINE_STATE_BITMAP; bdf_line_bm_line = 0; } } else if (bdf_line_state == BDF_LINE_STATE_BITMAP) { if (strncmp(s, "ENDCHAR", 7) == 0) { bdf_ReduceGlyph(); bdf_PutGlyph(); bdf_line_state = BDF_LINE_STATE_KEYWORDS; bdf_line_bm_line = 0; } else if (bdf_requested_encoding == bdf_encoding) { int i = 0; for (;;) { if (p_current_char < '0') break; bdf_bitmap_line[bdf_line_bm_line][i] = p_get_hex_byte(); i++; } bdf_line_bm_line++; assert(bdf_line_bm_line < BDF_MAX_HEIGHT); } } } int bdf_ReadFP(FILE *fp) { static char bdf_line[BDF_LINE_MAX]; bdf_is_put_glyph_completed = 0; for (;;) { bdf_last_line_start_pos = ftell(fp); if (fgets(bdf_line, BDF_LINE_MAX - 1, fp) == NULL) break; bdf_ReadLine(bdf_line); if (bdf_is_put_glyph_completed != 0) break; } return 1; } int bdf_ReadFile(const char *filename, int encoding) { int r; FILE *fp; fp = fopen(filename, "rb"); if (fp != NULL) { bdf_SetFilePos(fp, encoding); r = bdf_ReadFP(fp); fclose(fp); return r; } return 0; /* open error */ } void bdf_GenerateFontData(const char *filename, int begin, int end) { bdf_state = BDF_STATE_FONT_DATA; bdf_ReadFile(filename, -1); /** * font information * * offset * 0 font format * 1 FONTBOUNDINGBOX width unsigned * 2 FONTBOUNDINGBOX height unsigned * 3 FONTBOUNDINGBOX x-offset signed * 4 FONTBOUNDINGBOX y-offset signed * 5 Capital A Height unsigned * 6 position of encoding 65 'A' high byte first * 8 position of encoding 97 'a' high byte first */ data_Put(bdf_font_format); data_Put(bdf_font_width); data_Put(bdf_font_height); data_Put(bdf_font_x); data_Put(bdf_font_y); data_Put(bdf_capital_A_height > 0 ? bdf_capital_A_height : bdf_capital_1_height); data_Put(0); data_Put(0); data_Put(0); data_Put(0); data_Put(begin); data_Put(end); /* will be overwritten later */ data_Put(0); /* lower g descent */ data_Put(0); /* max ascent */ data_Put(0); /* min y = descent */ data_Put(0); /* x ascent */ data_Put(0); /* x descent */ } void bdf_GenerateGlyph(const char *filename, int encoding) { bdf_ClearGlyphBuffer(); bdf_requested_encoding = encoding; bdf_state = BDF_STATE_ENCODING; bdf_ReadFile(filename, encoding); } void bdf_Generate(const char *filename, int begin, int end) { int i; int last_valid_encoding; bdf_encoding_65_pos = 0; bdf_encoding_97_pos = 0; bdf_InitFilePos(); bdf_ResetMax(); bdf_info[0] = '\0'; bdf_font[0] = '\0'; bdf_copyright[0] = '\0'; bdf_GenerateFontData(filename, begin, end); for (i = begin; i <= end; i++) { if (i == 65) bdf_encoding_65_pos = data_pos; if (i == 97) bdf_encoding_97_pos = data_pos; bdf_is_encoding_successfully_done = 0; if (bdf_IsEncodingAvailable(i)) bdf_GenerateGlyph(filename, i); if (bdf_is_encoding_successfully_done == 0) data_Put(255); /* no char encoding */ if (bdf_is_encoding_successfully_done != 0) last_valid_encoding = i; } /* data_Put(255); obsolete, not required any more for format 0 */ /* encoding 255, end of font data (format 0) */ data_buf[5] = bdf_capital_A_height > 0 ? bdf_capital_A_height : bdf_capital_1_height; data_buf[6] = (bdf_encoding_65_pos >> 8); data_buf[7] = (bdf_encoding_65_pos & 255); data_buf[8] = (bdf_encoding_97_pos >> 8); data_buf[9] = (bdf_encoding_97_pos & 255); data_buf[12] = bdf_lower_g_descent; data_buf[13] = bdf_char_max_ascent; data_buf[14] = bdf_char_min_y; data_buf[15] = bdf_char_xascent; data_buf[16] = bdf_char_xdescent; if (0) data_buf[11] = last_valid_encoding; } void bdf_WriteC(const char *outname, const char *fontname) { int capital_ascent; FILE *out_fp; out_fp = fopen(outname, "wb"); assert( out_fp != NULL ); capital_ascent = bdf_capital_A_height > 0 ? bdf_capital_A_height : bdf_capital_1_height; fprintf(out_fp, "/*\n"); fprintf(out_fp, " Fontname: %s\n", bdf_font); fprintf(out_fp, " Copyright: %s\n", bdf_copyright); fprintf(out_fp, " Capital A Height: %d, '1' Height: %d\n", bdf_capital_A_height, bdf_capital_1_height); fprintf(out_fp, " Calculated Max Values w=%2d h=%2d x=%2d y=%2d dx=%2d dy=%2d ascent=%2d len=%2d\n", bdf_char_max_width, bdf_char_max_height, bdf_char_max_x, bdf_char_max_y, bdf_delta_max_x, bdf_delta_max_y, bdf_char_max_ascent, bdf_glyph_data_max_len); fprintf(out_fp, " Font Bounding box w=%2d h=%2d x=%2d y=%2d\n", bdf_font_width, bdf_font_height, bdf_font_x, bdf_font_y); fprintf(out_fp, " Calculated Min Values x=%2d y=%2d dx=%2d dy=%2d\n", bdf_char_min_x, bdf_char_min_y, bdf_delta_min_x, bdf_delta_min_y); fprintf(out_fp, " Pure Font ascent =%2d descent=%2d\n", capital_ascent, bdf_lower_g_descent); fprintf(out_fp, " X Font ascent =%2d descent=%2d\n", bdf_char_xascent, bdf_char_xdescent); fprintf(out_fp, " Max Font ascent =%2d descent=%2d\n", bdf_char_max_ascent, bdf_char_min_y); fprintf(out_fp, "*/\n"); fprintf(out_fp, "const u8g_fntpgm_uint8_t %s[%d] U8G_FONT_SECTION(\"%s\") = {\n", fontname, data_pos, fontname); fprintf(out_fp, " "); data_Write(out_fp, " "); fprintf(out_fp, "};\n"); #ifndef BDF2U8G_COMPACT_OUTPUT fprintf(out_fp, "%s\n", bdf_info); #endif fclose(out_fp); } int ga_argc; char **ga_argv; void ga_remove_arg(void) { if (ga_argc == 0) return; ga_argc--; ga_argv++; } int ga_is_arg(char opt) { if (ga_argc == 0) return 0; if (ga_argv[0] == NULL) return 0; if (ga_argv[0][0] != '-') return 0; if (ga_argv[0][1] != opt) return 0; ga_remove_arg(); return 1; } int main(int argc, char **argv) { int lower_page = 0; int upper_page = 1; int mapping_shift = 0; int upper_mapping_shift = 0; int begin = 32; int end = 255; if (argc < 4) { printf("bdf to u8glib font format converter v" BDF2U8G_VERSION "\n"); printf("%s [-l page] [-u page] [-s shift] [-S upper-shift] [-b begin] [-e end] [-f format] fontfile fontname outputfile\n", argv[0]); return 1; } ga_argc = argc; ga_argv = argv; ga_remove_arg(); /* remove program name */ for (;;) { if (ga_is_arg('l')) { lower_page = atoi(ga_argv[0]); ga_remove_arg(); } else if (ga_is_arg('u')) { upper_page = atoi(ga_argv[0]); ga_remove_arg(); } else if (ga_is_arg('s')) { mapping_shift = atoi(ga_argv[0]); ga_remove_arg(); } else if (ga_is_arg('S')) { upper_mapping_shift = atoi(ga_argv[0]); ga_remove_arg(); } else if (ga_is_arg('b')) { begin = atoi(ga_argv[0]); ga_remove_arg(); } else if (ga_is_arg('e')) { end = atoi(ga_argv[0]); ga_remove_arg(); } else if (ga_is_arg('f')) { bdf_font_format = atoi(ga_argv[0]); ga_remove_arg(); } else { break; } } printf("encoding range %d..%d\n", begin, end); data_Init(); map_Init(); map_UpperLowerPage(lower_page, upper_page, mapping_shift, upper_mapping_shift); /* puts(bdf_font); puts(bdf_copyright); if (ga_argc < 3) { printf("from page %d to page %d\n", lower_page, upper_page); return 1; } */ bdf_Generate(ga_argv[0], begin, end); bdf_WriteC(ga_argv[2], ga_argv[1]); printf("input file '%s'\n", ga_argv[0]); printf("u8g font name '%s'\n", ga_argv[1]); printf("output file '%s'\n", ga_argv[2]); return 0; }
2301_81045437/Marlin
buildroot/share/fonts/bdf2u8g/bdf2u8g.c
C
agpl-3.0
35,571
# Generate a 'HZK' font file for the T5UIC1 DWIN LCD # from multiple bdf font files. # Note: the 16x16 glyphs are not produced # Author: Taylor Talkington # License: GPL import bdflib.reader import math def glyph_bits(size_x, size_y, font, glyph_ord): asc = font[b'FONT_ASCENT'] desc = font[b'FONT_DESCENT'] bits = [0 for y in range(size_y)] glyph_bytes = math.ceil(size_x / 8) try: glyph = font[glyph_ord] for y, row in enumerate(glyph.data): v = row rpad = size_x - glyph.bbW if rpad < 0: rpad = 0 if glyph.bbW > size_x: v = v >> (glyph.bbW - size_x) # some glyphs are actually too wide to fit! v = v << (glyph_bytes * 8) - size_x + rpad v = v >> glyph.bbX bits[y + desc + glyph.bbY] |= v except KeyError: pass bits.reverse() return bits def marlin_font_hzk(): fonts = [ [6,12,'marlin-6x12-3.bdf'], [8,16,'marlin-8x16.bdf'], [10,20,'marlin-10x20.bdf'], [12,24,'marlin-12x24.bdf'], [14,28,'marlin-14x28.bdf'], [16,32,'marlin-16x32.bdf'], [20,40,'marlin-20x40.bdf'], [24,48,'marlin-24x48.bdf'], [28,56,'marlin-28x56.bdf'], [32,64,'marlin-32x64.bdf'] ] with open('marlin_fixed.hzk','wb') as output: for f in fonts: with open(f[2], 'rb') as file: print(f'{f[0]}x{f[1]}') font = bdflib.reader.read_bdf(file) for glyph in range(128): bits = glyph_bits(f[0], f[1], font, glyph) glyph_bytes = math.ceil(f[0]/8) for b in bits: try: z = b.to_bytes(glyph_bytes, 'big') output.write(z) except OverflowError: print('Overflow') print(f'{glyph}') print(font[glyph]) for b in bits: print(f'{b:0{f[0]}b}') return
2301_81045437/Marlin
buildroot/share/fonts/buildhzk.py
Python
agpl-3.0
2,109
#!/usr/bin/env bash ##################################################################### # genallfont.sh for Marlin # # This script generates font data for language headers # # Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com> # License: GPL/BSD ##################################################################### my_getpath() { local PARAM_DN="$1" shift #readlink -f local DN="${PARAM_DN}" local FN= if [ ! -d "${DN}" ]; then FN=$(basename "${DN}") DN=$(dirname "${DN}") fi cd "${DN}" > /dev/null 2>&1 DN=$(pwd) cd - > /dev/null 2>&1 echo -n "${DN}" [[ -z "$FN" ]] || echo -n "/${FN}" } DN_EXEC=$(dirname $(my_getpath "$0") ) # # Get language arguments # LANG_ARG="$@" # # Use 6x12 combined font data for Western languages # FN_FONT="${DN_EXEC}/marlin-6x12-3.bdf" # # Change to working directory 'Marlin' # OLDWD=`pwd` [[ $(basename "$OLDWD") != 'Marlin' && -d "Marlin" ]] && cd Marlin [[ -f "Configuration.h" ]] || { echo -n "cd to the 'Marlin' folder to run " ; basename $0 ; exit 1; } # # Compile the 'genpages.exe' and 'bdf2u8g.exe' commands in-place # if [[ ! -x "${DN_EXEC}/genpages/genpages.exe" ]]; then echo "Building genpages.exe..." ( cd ${DN_EXEC}/genpages ; cc -o genpages.exe genpages.c getline.c ) [[ -x "${DN_EXEC}/genpages/genpages.exe" ]] || { echo "Build of genpages.exe failed" ; exit 1 ; } fi if [[ ! -x "${DN_EXEC}/bdf2u8g/bdf2u8g.exe" ]]; then echo "Building bdf2u8g.exe..." ( cd ${DN_EXEC}/bdf2u8g ; make ) [[ -x "${DN_EXEC}/bdf2u8g/bdf2u8g.exe" ]] || { echo "Build of bdf2u8g.exe failed" ; exit 1 ; } fi # # By default loop through all languages # LANGS_DEFAULT="an bg ca cz da de el el_CY en es eu fi fr fr_na gl hr hu it jp_kana ko_KR nl pl pt pt_br ro ru sk sv tr uk vi zh_CN zh_TW test" # # Generate data for language list MARLIN_LANGS or all if not provided # for ALANG in ${LANG_ARG:=$LANGS_DEFAULT} ; do echo "Generating Marlin language data for '${ALANG}'" >&2 case "$ALANG" in zh_* ) FONTFILE="wenquanyi_12pt" ;; ko_* ) FONTFILE="${DN_EXEC}/NanumGothic.bdf" ;; * ) FONTFILE="${DN_EXEC}/marlin-6x12-3.bdf" ;; esac DN_WORK=$(mktemp -d) cp Configuration.h ${DN_WORK}/ cp src/lcd/language/language_${ALANG}.h ${DN_WORK}/ cd "${DN_WORK}" ${DN_EXEC}/uxggenpages.sh "${FONTFILE}" $ALANG sed -i fontutf8-data.h -e 's|fonts//|fonts/|g' -e 's|fonts//|fonts/|g' -e 's|[/0-9a-zA-Z_\-]*buildroot/share/fonts|buildroot/share/fonts|' 2>/dev/null cd - >/dev/null mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/fontdata/langdata_${ALANG}.h rm -rf ${DN_WORK} done # # Generate default ASCII font (char range 0-255): # Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h # EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g/bdf2u8g.exe" #if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then if [ 1 = 1 ]; then DN_WORK=$(mktemp -d) cd ${DN_WORK} ${EXEC_BDF2U8G} -b 1 -e 127 ${FN_FONT} ISO10646_1_5x7 tmp1.h >/dev/null ${EXEC_BDF2U8G} -b 1 -e 255 ${FN_FONT} ISO10646_1_5x7 tmp2.h >/dev/null TMP1=$(cat tmp1.h) TMP2=$(cat tmp2.h) cd - >/dev/null rm -rf ${DN_WORK} cat <<EOF >src/lcd/dogm/fontdata/fontdata_ISO10646_1.h /** * Marlin 3D Printer Firmware * Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program 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. * * This program 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. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ #include <U8glib-HAL.h> #if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7) // reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH $TMP1 #else // extended (original) font (symbols 1 - 255) $TMP2 #endif EOF fi cd "$OLDWD"
2301_81045437/Marlin
buildroot/share/fonts/genallfont.sh
Shell
agpl-3.0
4,250
/** * @file genpages.c * @brief generate required font page files * @author Yunhui Fu (yhfudev@gmail.com) * @version 1.0 * @date 2015-02-19 * @copyright Yunhui Fu (2015) */ #include <stdio.h> #include <stdint.h> /* uint8_t */ #include <stdlib.h> /* size_t */ #include <string.h> #include <assert.h> #include "getline.h" wchar_t get_val_utf82uni(uint8_t *pstart) { size_t cntleft; wchar_t retval = 0; if (0 == (0x80 & *pstart)) return *pstart; if (((*pstart & 0xE0) ^ 0xC0) == 0) { cntleft = 1; retval = *pstart & ~0xE0; } else if (((*pstart & 0xF0) ^ 0xE0) == 0) { cntleft = 2; retval = *pstart & ~0xF0; } else if (((*pstart & 0xF8) ^ 0xF0) == 0) { cntleft = 3; retval = *pstart & ~0xF8; } else if (((*pstart & 0xFC) ^ 0xF8) == 0) { cntleft = 4; retval = *pstart & ~0xFC; } else if (((*pstart & 0xFE) ^ 0xFC) == 0) { cntleft = 5; retval = *pstart & ~0xFE; } else { /* encoding error */ cntleft = 0; retval = 0; } pstart++; for (; cntleft > 0; cntleft --) { retval <<= 6; retval |= *pstart & 0x3F; pstart++; } return retval; } /** * @brief 转换 UTF-8 编码的一个字符为本地的 Unicode 字符(wchar_t) * * @param pstart : 存储 UTF-8 字符的指针 * @param pval : 需要返回的 Unicode 字符存放地址指针 * * @return 成功返回下个 UTF-8 字符的位置 * * 转换 UTF-8 编码的一个字符为本地的 Unicode 字符(wchar_t) */ uint8_t* get_utf8_value(uint8_t *pstart, wchar_t *pval) { uint32_t val = 0; uint8_t *p = pstart; /*size_t maxlen = strlen(pstart);*/ assert(NULL != pstart); #define NEXT_6_BITS() do{ val <<= 6; p++; val |= (*p & 0x3F); }while(0) if (0 == (0x80 & *p)) { val = (size_t)*p; p++; } else if (0xC0 == (0xE0 & *p)) { val = *p & 0x1F; NEXT_6_BITS(); p++; assert((wchar_t)val == get_val_utf82uni(pstart)); } else if (0xE0 == (0xF0 & *p)) { val = *p & 0x0F; NEXT_6_BITS(); NEXT_6_BITS(); p++; assert((wchar_t)val == get_val_utf82uni(pstart)); } else if (0xF0 == (0xF8 & *p)) { val = *p & 0x07; NEXT_6_BITS(); NEXT_6_BITS(); NEXT_6_BITS(); p++; assert((wchar_t)val == get_val_utf82uni(pstart)); } else if (0xF8 == (0xFC & *p)) { val = *p & 0x03; NEXT_6_BITS(); NEXT_6_BITS(); NEXT_6_BITS(); NEXT_6_BITS(); p++; assert((wchar_t)val == get_val_utf82uni(pstart)); } else if (0xFC == (0xFE & *p)) { val = *p & 0x01; NEXT_6_BITS(); NEXT_6_BITS(); NEXT_6_BITS(); NEXT_6_BITS(); NEXT_6_BITS(); p++; assert((wchar_t)val == get_val_utf82uni(pstart)); } else if (0x80 == (0xC0 & *p)) { /* error? */ for (; 0x80 == (0xC0 & *p); p++); } else { /* error */ for (; ((0xFE & *p) > 0xFC); p++); } /* if (val == 0) { p = NULL; */ /* } else if (pstart + maxlen < p) { p = pstart; if (pval) *pval = 0; } */ if (pval) *pval = val; return p; } void usage(char *progname) { fprintf(stderr, "usage: %s\n", progname); fprintf(stderr, " read data from stdin\n"); } void utf8_parse(const char *msg, unsigned int len) { uint8_t *pend = NULL; uint8_t *p; uint8_t *pre; wchar_t val; int page; pend = (uint8_t *)msg + len; for (pre = (uint8_t *)msg; pre < pend;) { val = 0; p = get_utf8_value(pre, &val); if (NULL == p) break; page = val / 128; if (val >= 256) { fprintf(stdout, "%d %d ", page, (val % 128)); for (; pre < p; pre++) fprintf(stdout, "%c", *pre); fprintf(stdout, "\n"); } pre = p; } } int load_file(FILE *fp) { char * buffer = NULL; size_t szbuf = 0; szbuf = 10000; buffer = (char*)malloc(szbuf); if (NULL == buffer) return -1; //pos = ftell (fp); while (getline( &buffer, &szbuf, fp ) > 0) utf8_parse((const char*)buffer, (unsigned int)strlen ((char *)buffer)); free(buffer); return 0; } int main(int argc, char * argv[]) { if (argc > 1) { usage(argv[0]); exit(1); } load_file(stdin); }
2301_81045437/Marlin
buildroot/share/fonts/genpages/genpages.c
C
agpl-3.0
4,088
/** * getline.c --- Based on... * * getdelim.c --- Implementation of replacement getdelim function. * Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005 Free * Software Foundation, Inc. * * This program 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 2, or (at * your option) any later version. * * This program 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ /* Ported from glibc by Simon Josefsson. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #if !HAVE_GETLINE //#include "getdelim.h" #include <stdio.h> #include <limits.h> #include <stdlib.h> #include <errno.h> #ifndef SIZE_MAX #define SIZE_MAX ((size_t) -1) #endif #ifndef SSIZE_MAX #define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) #endif #if !HAVE_FLOCKFILE #undef flockfile #define flockfile(x) ((void)0) #endif #if !HAVE_FUNLOCKFILE #undef funlockfile #define funlockfile(x) ((void)0) #endif /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and NUL-terminate it). *LINEPTR is a pointer returned from malloc (or NULL), pointing to *N characters of space. It is realloc'ed as necessary. Returns the number of characters read (not including the null terminator), or -1 on error or EOF. */ ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) { ssize_t result; size_t cur_len = 0; if (lineptr == NULL || n == NULL || fp == NULL) { errno = EINVAL; return -1; } flockfile (fp); if (*lineptr == NULL || *n == 0) { *n = 120; *lineptr = (char *) malloc(*n); if (*lineptr == NULL) { result = -1; goto unlock_return; } } for (;;) { int i; i = getc(fp); if (i == EOF) { result = -1; break; } /* Make enough space for len+1 (for final NUL) bytes. */ if (cur_len + 1 >= *n) { size_t needed_max = SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; size_t needed = 2 * *n + 1; /* Be generous. */ char *new_lineptr; if (needed_max < needed) needed = needed_max; if (cur_len + 1 >= needed) { result = -1; goto unlock_return; } new_lineptr = (char *) realloc (*lineptr, needed); if (new_lineptr == NULL) { result = -1; goto unlock_return; } *lineptr = new_lineptr; *n = needed; } (*lineptr)[cur_len] = i; cur_len++; if (i == delimiter) break; } (*lineptr)[cur_len] = '\0'; result = cur_len ? (int) cur_len : (int) result; unlock_return: funlockfile(fp); return result; } #endif
2301_81045437/Marlin
buildroot/share/fonts/genpages/getline.c
C
agpl-3.0
3,091
#ifndef MYGETLINE_H #define MYGETLINE_H //#include "config.h" #if !HAVE_GETLINE #include <stdio.h> ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp); #define getline(lineptr, n, stream) getdelim (lineptr, n, '\n', stream) #endif #endif // MYGETLINE_H
2301_81045437/Marlin
buildroot/share/fonts/genpages/getline.h
C
agpl-3.0
280
#!/usr/bin/env bash # # make_lang_na.sh # # Create non-accented language files given a list of accented language files. # which gsed >/dev/null || { echo "gsed is required for this script." ; exit 1 ; } which perl >/dev/null || { echo "perl is required for this script." ; exit 1 ; } # # Get language arguments # [ $# ] || { echo "One or more language codes (such as 'fr') must be supplied." ; exit 1 ; } LANG_ARG="$@" # # Change to working directory 'Marlin' # OLDWD=`pwd` [[ $(basename "$OLDWD") != 'Marlin' && -d "Marlin" ]] && cd Marlin [[ -f "Configuration.h" ]] || { echo -n "cd to the 'Marlin' folder to run " ; basename $0 ; exit 1; } # # Generate a non-accented language file # for ALANG in $LANG_ARG ; do echo "Generating a non-accented language for '${ALANG}'" >&2 OUTFILE=src/lcd/language/language_${ALANG}_na.h cp src/lcd/language/language_${ALANG}.h $OUTFILE perl -pi -e 's/\s*#define DISPLAY_CHARSET_.+\n*//g' $OUTFILE perl -pi -e 's/\s*constexpr .+ CHARSIZE.+\n*//g' $OUTFILE perl -pi -e "s/namespace Language_${ALANG}/#define DISPLAY_CHARSET_ISO10646_1\n#define NOT_EXTENDED_ISO10646_1_5X7\n\nnamespace Language_${ALANG}_na/" $OUTFILE gsed -i 'y/āáǎàâäēéěèêīíǐìïîōóǒòöôūúǔùǖǘǚǜüûĀÁǍÀĒÉĚÈÊĪÍǏÌÎŌÓǑÒÔŪÚǓÙǕǗǙǛÜÛÇçÑñ/aaaaaaeeeeeiiiiiioooooouuuuuuuuuuAAAAEEEEEIIIIIOOOOOUUUUUUUUUUCcNn/' $OUTFILE perl -pi -e 's/ß/ss/g' $OUTFILE done cd "$OLDWD"
2301_81045437/Marlin
buildroot/share/fonts/make_lang_na.sh
Shell
agpl-3.0
1,446
#!/usr/bin/env bash ##################################################################### # uxggenpages.sh for u8g # # This script will generate u8g c files for specified fonts # # Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com> # License: BSD ##################################################################### my_getpath() { local PARAM_DN="$1" shift #readlink -f local DN="${PARAM_DN}" local FN= if [ ! -d "${DN}" ]; then FN=$(basename "${DN}") DN=$(dirname "${DN}") fi cd "${DN}" > /dev/null 2>&1 DN=$(pwd) cd - > /dev/null 2>&1 echo -n "${DN}" [[ -z "$FN" ]] || echo -n "/${FN}" } #DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'` DN_EXEC=$(dirname $(my_getpath "$0") ) ##################################################################### EXEC_GENPAGES=${DN_EXEC}/genpages/genpages.exe [ -x "${EXEC_GENPAGES}" ] || { echo "Error: genpages not found!" ; exit 1; } EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g/bdf2u8g.exe [ -x "${EXEC_BDF2U8G}" ] || { echo "Error: bdf2u8g not found!" ; exit 1; } DN_CUR=$(pwd) DN_DATA=$(pwd)/datatmp mkdir -p "${DN_DATA}" ##################################################################### FONTHOME=/usr/share/fonts FN_FONT_BASE="marlin-6x12-3" #FN_FONT_BASE=unifont #FN_FONT_BASE=wenquanyi_12pt #FN_FONT_BASE=wenquanyi_9pt FN_FONT="${1:-}" LANG="$2" DN_FONT0=`dirname ${FN_FONT}` DN_FONT="$(my_getpath ${DN_FONT0})" FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}` [ -z "${FN_FONT}" ] && FN_FONT=${DN_DATA}/../${FN_FONT_BASE}.bdf [ -f "${FN_FONT}" ] || FN_FONT=${DN_EXEC}/${FN_FONT_BASE}.bdf [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/wenquanyi/${FN_FONT_BASE}.bdf" [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/X11/misc/${FN_FONT_BASE}.bdf" [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/misc/${FN_FONT_BASE}.bdf" #echo "uxggenpages.sh: FN_FONT=${FN_FONT}" if [ ! -f "${FN_FONT}" ]; then FN_FONT_PCF="$FONTHOME/X11/misc/${FN_FONT_BASE}.pcf" [ -f "${FN_FONT_PCF}" ] || FN_FONT_PCF="$FONTHOME/misc/${FN_FONT_BASE}.pcf" [ -f "${FN_FONT_PCF}" ] || FN_FONT_PCF="$FONTHOME/wenquanyi/${FN_FONT_BASE}.pcf" if [ -f "${FN_FONT_PCF}" ]; then EXEC_PCF2BDF=$(which pcf2bdf) if [ ! -x "${EXEC_PCF2BDF}" ]; then echo "Error: not found pcf2bdf!" echo " Please install pcf2bdf." exit 1 fi FN_FONT="./${FN_FONT_BASE}.bdf" echo ${EXEC_PCF2BDF} -o "${FN_FONT}" "${FN_FONT_PCF}" ${EXEC_PCF2BDF} -o "${FN_FONT}" "${FN_FONT_PCF}" fi fi [ -f "${FN_FONT}" ] || { echo "Error: can't find font ${FN_FONT}!" ; exit 1; } ##################################################################### #(cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c) rm -f tmpa tmpb touch tmpa tmpb #rm -f ${DN_EXEC}/fontpage_*.h rm -f fontpage_*.h cat << EOF >"proc.awk" BEGIN { cur_page=0; val_begin=0; val_pre=0; utf8_pre=""; utf8_begin=""; }{ page=\$1; val_real=\$2; utf8=\$3; # assert (val_real < 128); val=val_real + 128; if (cur_page != page) { if (cur_page != 0) { if (val_begin != 0) { print cur_page " " val_begin " " val_pre " " utf8_begin " " utf8_pre; } } cur_page=page; val_begin=val; val_pre=val; utf8_begin=utf8; utf8_pre=utf8; } else { if (val_pre + 1 != val) { if (cur_page != 0) { print cur_page " " val_begin " " val_pre " " utf8_begin " " utf8_pre; } val_begin=val; val_pre=val; utf8_begin=utf8; utf8_pre=utf8; } else { val_pre = val; utf8_pre=utf8; } } } END { if (cur_page != 0) { print cur_page " " val_begin " " val_pre " " utf8_begin " " utf8_pre; } } EOF AWK=$(which gawk || which awk) grep -Hrn _UxGT . | grep '"' \ | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \ | ${EXEC_GENPAGES} \ | sort -k 1n -k 2n | uniq \ | "$AWK" -v EXEC_PREFIX=${DN_EXEC} -f "proc.awk" \ | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \ if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \ ${EXEC_BDF2U8G} -u ${PAGE} -b ${BEGIN} -e ${END} ${FN_FONT} fontpage_${PAGE}_${BEGIN}_${END} ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h > /dev/null 2>&1 ; fi ; \ grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ; \ echo " FONTDATA_ITEM(${PAGE}, ${BEGIN}, ${END}, fontpage_${PAGE}_${BEGIN}_${END}), // '${UTF8BEGIN}' -- '${UTF8END}'" >> tmpb ;\ done TMPA=$(cat tmpa) TMPB=$(cat tmpb) EOL=$'\n' [[ ! "$TMPA" == "" ]] && TMPA="$TMPA$EOL$EOL" [[ ! "$TMPB" == "" ]] && TMPB="$EOL$TMPB$EOL" rm -f tmpa tmpb "proc.awk" cat <<EOF >fontutf8-data.h /** * Generated automatically by buildroot/share/fonts/uxggenpages.sh * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ #pragma once #include "langdata.h" ${TMPA}static const uxg_fontinfo_t g_fontinfo_${LANG}[] PROGMEM = {${TMPB}}; EOF
2301_81045437/Marlin
buildroot/share/fonts/uxggenpages.sh
Shell
agpl-3.0
4,954
#!/usr/bin/env bash # # firstpush # # Push a branch to 'origin' and open the # commit log to watch Travis CI progress. # [[ $# == 0 ]] || { echo "usage: `basename $0`" 1>&2 ; exit 1; } MFINFO=$(mfinfo) || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" FORK=${INFO[1]} REPO=${INFO[2]} BRANCH=${INFO[5]} git push --set-upstream origin HEAD:$BRANCH OPEN=$( which gnome-open xdg-open open | head -n1 ) URL="https://github.com/$FORK/$REPO/commits/$BRANCH" if [ -z "$OPEN" ]; then echo "Can't find a tool to open the URL:" echo $URL else echo "Viewing commits on $BRANCH..." "$OPEN" "$URL" fi
2301_81045437/Marlin
buildroot/share/git/firstpush
Shell
agpl-3.0
595
#!/usr/bin/env bash # # ghpc (GitHub Push Current) # # - Push current branch to its remote. Try the following until it works: # - Plain 'git push' # - 'git push -f' # - Try the 'git push' command from the 'git push' error message # - Try adding '-f' to that command # yay() { echo "SUCCESS" ; } boo() { echo "FAIL" ; } FORCE=$([[ "$1" == "--force" || "$1" == "-f" ]] && echo 1) if [[ ! $FORCE ]]; then echo -n "trying 'git push' ...... " git push >/dev/null 2>&1 && { yay ; exit ; } boo fi echo -n "trying 'git push -f' ... " # Get the error output from the failed push # and get the recommended 'git push' line git push -f 2>&1 | { CMD="" ltrim() { [[ "$1" =~ [^[:space:]].* ]] printf "%s" "$BASH_REMATCH" } while IFS= read -r line do #echo "$line" if [[ -z "$CMD" && $line =~ "git push" ]]; then CMD=$(ltrim "$line") fi done # if a command was found try it if [[ -n "$CMD" ]]; then boo if [[ ! $FORCE ]]; then echo -n "trying '$CMD' ...... " $CMD >/dev/null 2>&1 && { yay ; exit ; } boo fi fCMD=${CMD/ push / push -f } echo -n "trying '$fCMD' ... " $fCMD >/dev/null 2>&1 && { yay ; exit ; } boo exit 1 else yay fi } [[ ${PIPESTATUS[1]} == 1 ]] && echo "Sorry! Failed to push current branch."
2301_81045437/Marlin
buildroot/share/git/ghpc
Shell
agpl-3.0
1,324
#!/usr/bin/env bash # # ghtp (GitHub Transport Protocol) # # Set all remotes in the current repo to HTTPS or SSH connection. # Useful when switching environments, using public wifi, etc. # # Optionally, specify a particular remote to change. # GH_SSH="git@github\.com:" GH_HTTPS="https:\/\/github\.com\/" case "$1" in -[Hh]) TYPE=HTTPS ; MATCH="git@" ; REPLACE="$GH_SSH/$GH_HTTPS" ;; -[Ss]) TYPE=SSH ; MATCH="https:" ; REPLACE="$GH_HTTPS/$GH_SSH" ;; *) echo "Usage: `basename $0` -h | -s" 1>&2 echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2 echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2 exit 1 ;; esac AWK=$(which gawk || which awk) # Match all or specified remotes of the other type REGEX="\t$MATCH" ; [[ $# > 1 ]] && REGEX="^$2$REGEX" REMOTES=$(git remote -v | egrep "$REGEX" | "$AWK" '{print $1 " " $2}' | sort -u | sed "s/$REPLACE/") [[ -z $REMOTES ]] && { echo "Nothing to do." ; exit ; } # Update a remote for each results pair echo "$REMOTES" | xargs -n2 git remote set-url echo -n "Remotes set to $TYPE: " echo "$REMOTES" | "$AWK" '{printf "%s ", $1}' echo
2301_81045437/Marlin
buildroot/share/git/ghtp
Shell
agpl-3.0
1,107
#!/usr/bin/env bash # # mfadd user[:branch] [copyname] # # Add a remote and fetch it. Optionally copy a branch. # # Examples: # mfadd thefork # mfadd thefork:patch-1 # mfadd thefork:patch-1 the_patch_12345 # [[ $# > 0 && $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` user[:branch] [copyname]" 1>&2 ; exit 1; } # If a colon or slash is included, split the parts if [[ $1 =~ ":" || $1 =~ "/" ]]; then [[ $1 =~ ":" ]] && IFS=':' || IFS="/" read -a DATA <<< "$1" USER=${DATA[0]} BRANCH=${DATA[1]} NAME=${2:-$BRANCH} else USER=$1 fi MFINFO=$(mfinfo) || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" REPO=${INFO[2]} set -e echo "Adding and fetching $USER/$REPO..." git remote add "$USER" "git@github.com:$USER/$REPO.git" >/dev/null 2>&1 || echo "Remote exists." git fetch "$USER" [[ ! -z "$BRANCH" && ! -z "$NAME" ]] && git checkout -b "$NAME" --track "$USER/$BRANCH"
2301_81045437/Marlin
buildroot/share/git/mfadd
Shell
agpl-3.0
907
#!/usr/bin/env bash # # mfclean # # Prune all your merged branches and any branches whose remotes are gone # Great way to clean up your branches after messing around a lot # AWK=$(which gawk || which awk) KEEP="RC|RCBugFix|dev|master|bugfix-1|bugfix-2" echo "Fetching latest upstream and origin..." git fetch upstream git fetch origin echo echo "Pruning Merged Branches..." git branch --merged | egrep -v "^\*|$KEEP" | xargs -n 1 git branch -d echo echo "Pruning Remotely-deleted Branches..." git branch -vv | egrep -v "^\*|$KEEP" | grep ': gone]' | "$AWK" '{print $1}' | xargs -n 1 git branch -D echo # List fork branches that don't match local branches echo "You may want to remove (or checkout) these refs..." comm -23 \ <(git branch --all | sed 's/^[\* ] //' | grep origin/ | grep -v "\->" | awk '{ print $1; }' | sed 's/remotes\/origin\///') \ <(git branch --all | sed 's/^[\* ] //' | grep -v remotes/ | awk '{ print $1; }') \ | awk '{ print "git branch -d -r origin/" $1; print "git checkout origin/" $1 " -b " $1; print ""; }' echo
2301_81045437/Marlin
buildroot/share/git/mfclean
Shell
agpl-3.0
1,051
#!/usr/bin/env bash # # mfconfig init source dest # mfconfig manual source dest # # The MarlinFirmware/Configurations layout could be broken up into branches, # but this makes management more complicated and requires more commits to # perform the same operation, so this uses a single branch with subfolders. # # init - Initialize the repo with a base commit and changes: # - Source will be an 'import' branch containing all current configs. # - Create an empty 'BASE' branch from 'init-repo'. # - Add Marlin config files, but reset all to defaults. # - Commit this so changes will be clear in following commits. # - Add changed Marlin config files and commit. # # manual - Manually import changes from the Marlin repo # - Replace 'default' configs with those from the Marlin repo. # - Wait for manual propagation to the rest of the configs. # - Run init with the given 'source' and 'dest' # REPOHOME="`dirname ~/Projects/Maker/Firmware/.`" MARLINREPO="$REPOHOME/MarlinFirmware" CONFIGREPO="$REPOHOME/Configurations" CEXA=config/examples CDEF=config/default BC=Configuration.h AC=Configuration_adv.h COMMIT_STEPS=0 #cd "$CONFIGREPO" 2>/dev/null || { echo "Can't find Configurations repo!" ; exit 1; } ACTION=${1:-init} IMPORT=${2:-"import-2.1.x"} EXPORT=${3:-"bugfix-2.1.x"} echo -n "Doing grhh ... " ; grhh ; echo if [[ $ACTION == "manual" ]]; then # # Copy the latest default configs from MarlinFirmware/Marlin # or one of the import branches here, then use them to construct # a 'BASE' branch with only defaults as a starting point. # echo "- Updating '$IMPORT' from Marlin..." git checkout $IMPORT || exit # Reset from the latest complete state #git reset --hard bugfix-2.1.x cp "$MARLINREPO/Marlin/"Configuration*.h "$CDEF/" #git add . && git commit -m "Changes from Marlin ($(date '+%Y-%m-%d %H:%M'))." echo "- Fix up the import branch and come back." read -p "- Ready to init [y/N] ?" INIT_YES echo [[ $INIT_YES == 'Y' || $INIT_YES == 'y' ]] || { echo "Done." ; exit ; } ACTION='init' fi if [[ $ACTION == "init" ]]; then # # Copy all configs from a source such as MarlinFirmware/Marlin # or one of the import branches here, then use them to construct # a 'BASE' branch with only defaults as a starting point. # SED=$(which gsed sed | head -n1) echo "- Initializing BASE branch..." # Use the import branch as the source git checkout $IMPORT || exit # Copy to a temporary location TEMP=$( mktemp -d ) ; cp -R config $TEMP # Strip all #error lines IFS=$'\n'; set -f for fn in $( find $TEMP/config -type f -name "Configuration.h" ); do $SED -i~ -e "20,30{/#error/d}" "$fn" rm "$fn~" done unset IFS; set +f # Make sure we're not on the 'BASE' branch... git checkout init-repo >/dev/null 2>&1 || exit # Create 'BASE' as a copy of 'init-repo' (README, LICENSE, etc.) git branch -D BASE 2>/dev/null git checkout init-repo -b BASE || exit # Copy all config files into place echo "- Copying all configs from fresh $IMPORT..." cp -R "$TEMP/config" . # Delete anything that's not a Configuration file find config -type f \! -name "Configuration*" -exec rm "{}" \; # DEBUG: Commit the original config files for comparison ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Commit for comparison" >/dev/null # Init Cartesian/SCARA/TPARA configurations to default echo "- Initializing configs to default state..." find "$CEXA" -name $BC -print0 \ | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done find "$CEXA" -name $AC -print0 \ | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done # DEBUG: Commit the reset for review ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset configs..." >/dev/null # Update the %VERSION% in the README.md file VERS=$( echo $EXPORT | $SED 's/release-//' ) eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md" rm -f README.md~ # NOT DEBUGGING: Commit the 'BASE', ready for customizations ((COMMIT_STEPS)) || git add . >/dev/null && git commit --amend --no-edit >/dev/null # Create a new branch from 'BASE' for the final result echo "- Creating '$EXPORT' branch for the result..." git branch -D $EXPORT 2>/dev/null git checkout -b $EXPORT || exit # Delete temporary branch git branch -D BASE 2>/dev/null echo "- Applying example config customizations..." cp -R "$TEMP/config" . find config -type f \! -name "Configuration*" -exec rm "{}" \; addpathlabels() { find config -name "Conf*.h" -print0 | while read -d $'\0' fn ; do fldr=$(dirname "$fn") blank_line=$(awk '/^\s*$/ {print NR; exit}' "$fn") $SED -i~ "${blank_line}i\\\n#define CONFIG_EXAMPLES_DIR \"$fldr\"" "$fn" rm -f "$fn~" done } echo "- Adding path labels to all configs..." addpathlabels git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null echo "- Copying extras from Marlin..." cp -R "$TEMP/config" . # Apply labels again! addpathlabels git add . >/dev/null && git commit -m "Examples Extras" >/dev/null rm -rf $TEMP git push -f --set-upstream upstream "$EXPORT" else echo "Usage: mfconfig init|manual|rebase" fi
2301_81045437/Marlin
buildroot/share/git/mfconfig
Shell
agpl-3.0
5,218
#!/usr/bin/env bash # # mfdoc # # Start Jekyll in watch mode to work on Marlin Documentation and preview locally # [[ $# == 0 ]] || { echo "Usage: `basename $0`" 1>&2 ; exit 1; } MFINFO=$(mfinfo "$@") || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" ORG=${INFO[0]} REPO=${INFO[2]} BRANCH=${INFO[5]} [[ $ORG == "MarlinFirmware" && $REPO == "MarlinDocumentation" ]] || { echo "Wrong repository." 1>&2; exit 1; } opensite() { URL="http://127.0.0.1:4000/" OPEN=$( which gnome-open xdg-open open | head -n1 ) if [ -z "$OPEN" ]; then echo "Can't find a tool to open the URL:" echo $URL else echo "Opening preview site in the browser..." "$OPEN" "$URL" fi } echo "Previewing MarlinDocumentation..." bundle exec jekyll serve --watch --incremental | { while IFS= read -r line do [[ $line =~ "Server running" ]] && opensite echo "$line" done }
2301_81045437/Marlin
buildroot/share/git/mfdoc
Shell
agpl-3.0
876
#!/usr/bin/env bash # # mffp [1|2] [ref] # # Push the given commit (or HEAD) upstream immediately. # By default: `git push upstream HEAD:bugfix-2.1.x` # usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 ; } [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage ; exit 1; } if [[ $1 == '1' || $1 == '2' ]]; then MFINFO=$(mfinfo "$1") || exit 1 REF=${2:-HEAD} elif [[ $# == 1 ]]; then MFINFO=$(mfinfo) || exit 1 REF=${1:-HEAD} else usage ; exit 1 fi IFS=' ' read -a INFO <<< "$MFINFO" ORG=${INFO[0]} TARG=${INFO[3]} if [[ $ORG == "MarlinFirmware" ]]; then git push upstream $REF:$TARG else echo "Not a MarlinFirmware working copy."; exit 1 fi
2301_81045437/Marlin
buildroot/share/git/mffp
Shell
agpl-3.0
667
#!/usr/bin/env bash # # mfhelp # cat <<THIS Marlin Firmware Commands: firstpush ... Push and set-upstream the current branch to 'origin' ghpc ........ Push the current branch to its upstream branch ghtp ........ Set the transfer protocol for all your remotes mfadd ....... Fetch a remote branch from any Marlin fork mfclean ..... Attempt to clean up merged and deleted branches mfdoc ....... Build the website, serve locally, and browse mffp ........ Push new commits directly to MarlinFirmware mfinfo ...... Provide branch information (for the other scripts) mfinit ...... Create an 'upstream' remote for 'MarlinFirmare' mfnew ....... Create a new branch based on 'bugfix-...' mfpr ........ Push the current branch and open the PR form mfpub ....... Build and publish the marlinfw.org website mfqp ........ Commit changes, do an interactive rebase, and push mfrb ........ Interactively rebase the current branch on 'bugfix-...' mftest ...... Run a platform test locally with PlatformIO mfup ........ Fetch the latest 'upstream' and rebase on it Enter [command] --help for more information. Build / Test Commands: mftest ............... Run a platform test locally with PlatformIO build_all_examples ... Build all configurations of a branch, stop on error Modify Configuration.h / Configuration_adv.h: opt_add .............. Add a configuration option (to the top of Configuration.h) opt_disable .......... Disable a configuration option (modifies ) opt_enable ........... Enable a configuration option opt_set .............. Set the value of a configuration option use_example_configs .. Download configs from a remote branch on GitHub Modify pins files: pins_set ............. Set the value of a pin in a pins file pinsformat.py ........ Python script to format pins files THIS
2301_81045437/Marlin
buildroot/share/git/mfhelp
Shell
agpl-3.0
1,842
#!/usr/bin/env bash # # mfinfo # # Print the following info about the working copy: # # - Remote (upstream) Org name (MarlinFirmware) # - Remote (origin) Org name (your Github username) # - Repo Name (Marlin, MarlinDocumentation) # - PR Target branch (e.g., bugfix-2.1.x) # - Branch Arg (the branch argument or current branch) # - Current Branch # # Example output # > mfinfo -q ongoing # MarlinFirmware john.doe Marlin bugfix-2.1.x ongoing bugfix-2.1.x -q # CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g') [[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; } [[ $CURR == "(no"* ]] && { echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1; } REPO=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*\/(.*)\.git/\1/') [[ -z $REPO ]] && { echo "`basename $0`: No 'upstream' remote found. (Did you run mfinit?)" 1>&2 ; exit 1; } ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/') [[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; } FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/') # Defaults if no arguments given BRANCH=$CURR MORE="" INDEX=2 # Loop through arguments while [[ $# -gt 0 ]]; do # Get an arg and maybe a val to go with it opt="$1" ; shift ; val="$1" # Split up an arg containing = IFS='=' read -a PARTS <<<"$opt" [[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; } if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then val="" fi case "$opt" in -*|--*) MORE=" $MORE$opt" ; ((EQUALS)) && MORE="$MORE=$val" ;; 1|2) INDEX=$opt ;; *) BRANCH="$opt" ;; esac done case "$REPO" in Marlin ) TARG=bugfix-2.1.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;; Configurations ) TARG=import-2.1.x ;; MarlinDocumentation ) TARG=master ;; AutoBuildMarlin ) TARG=master ;; esac [[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1 ; } echo "$ORG $FORK $REPO $TARG $BRANCH $CURR$MORE"
2301_81045437/Marlin
buildroot/share/git/mfinfo
Shell
agpl-3.0
2,115
#!/usr/bin/env bash # # mfinit # # Create the upstream remote for a forked repository # [[ $# == 0 ]] || { echo "usage: `basename $0`" 1>&2 ; exit 1; } [[ -z $(git branch 2>/dev/null | grep ^* | sed 's/\* //g') ]] && { echo "No git repository here!" 1>&2 ; exit 1; } REPO=$(git remote get-url origin 2>/dev/null | sed -E 's/.*\/(.*)\.git/\1/') [[ -z $REPO ]] && { echo "`basename $0`: No 'origin' remote found." 1>&2 ; exit 1; } echo "Adding 'upstream' remote for convenience." git remote add upstream "git@github.com:MarlinFirmware/$REPO.git" git fetch upstream
2301_81045437/Marlin
buildroot/share/git/mfinit
Shell
agpl-3.0
567
#!/usr/bin/env bash # # mfnew # # Create a new branch from the default target with the given name # usage() { echo "usage: `basename $0` [1|2] [name]" 1>&2 ; } [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; } MFINFO=$(mfinfo "$@") || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" TARG=${INFO[3]} BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S") # BRANCH can be given as the last argument case "$#" in 1 ) case "$1" in 1|2) ;; *) BRANCH=$1 ;; esac ;; 2 ) case "$1" in 1|2) BRANCH=$2 ;; *) usage ; exit 1 ;; esac ;; esac git fetch upstream git checkout --no-track upstream/$TARG -b $BRANCH
2301_81045437/Marlin
buildroot/share/git/mfnew
Shell
agpl-3.0
667
#!/usr/bin/env bash # # mfpr [1|2] # # Make a PR targeted to MarlinFirmware/[repo] # [[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1; } MFINFO=$(mfinfo "$@") || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" ORG=${INFO[0]} FORK=${INFO[1]} REPO=${INFO[2]} TARG=${INFO[3]} BRANCH=${INFO[4]} OLDBRANCH=${INFO[5]} [[ $BRANCH == $TARG ]] && { echo "Can't create a PR from the PR Target ($BRANCH). Make a copy first." 1>&2 ; exit 1; } [[ $BRANCH != $OLDBRANCH ]] && { git checkout $BRANCH || exit 1; } # See if it's been pushed yet if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi OPEN=$( which gnome-open xdg-open open | head -n1 ) URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1" if [ -z "$OPEN" ]; then echo "Can't find a tool to open the URL:" echo $URL else echo "Opening a New PR Form..." "$OPEN" "$URL" fi [[ $BRANCH != $OLDBRANCH ]] && git checkout $OLDBRANCH
2301_81045437/Marlin
buildroot/share/git/mfpr
Shell
agpl-3.0
987
#!/usr/bin/env bash # # mfprep tag1 [tag2] # # Find commits in bugfix-2.1.x that are not yet in 2.1.x. # # Specify a version tag to start from, and optional version tag to end at. # For bugfix-2.1.x the tag will be prefixed by dev- to distinguish it from the version tag, # so at every release be sure to create a dev- tag and publish it to origin. # SED=$(which gsed sed | head -n1) SELF=`basename "$0"` DRYRUN=0 [[ $# < 1 || $# > 2 ]] && { echo "Usage $SELF tag1 [tag2]" ; exit 1 ; } TAG1=$1 TAG2=${2:-"HEAD"} DEST=2.1.x # Validate that the required tags exist MTAG=`git tag | grep -e "^dev-$TAG1\$"` [[ -n "$MTAG" ]] || { echo "Can't find tag dev-$TAG1" ; exit 1 ; } MTAG=`git tag | grep -e "^$TAG1\$"` [[ -n "$MTAG" ]] || { echo "Can't find tag $TAG1" ; exit 1 ; } # Generate log of recent commits for bugfix-2.1.x and DEST TMPDIR=`mktemp -d` LOGB="$TMPDIR/log-bf.txt" LOG2="$TMPDIR/log-2x.txt" TMPF="$TMPDIR/tmp.txt" SCRF="$TMPDIR/update-$DEST.sh" git checkout bugfix-2.1.x git log --pretty="[%h] %s" dev-$TAG1..$TAG2 | grep -v '\[cron\]' | $SED '1!G;h;$!d' >"$LOGB" git checkout $DEST git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "Can't find tag dev-$TAG1" ; exit 1 ; } # Go through commit text from DEST removing all matches from the bugfix log cat "$LOG2" | while read line; do if [[ $line =~ \(((#[0-9]{5}),* *)((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?\)$ ]]; then PATT="" for i in ${!BASH_REMATCH[@]}; do if ((i > 0 && (i % 2 == 0))); then if [[ -n "${BASH_REMATCH[i]}" ]]; then [[ -n "$PATT" ]] && PATT="$PATT|" PATT="$PATT${BASH_REMATCH[i]}" fi fi done #echo "... $PATT" [[ -n "$PATT" ]] && { grep -vE "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; } else PATT=$( $SED -E 's/^\[[0-9a-f]{10}\]( . )?(.+)$/\2/' <<<"$line" ) [[ -n "$PATT" ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; } fi done # Convert remaining commits into git commands echo -e "#!/usr/bin/env bash\nset -e\ngit checkout ${DEST}\n" >"$TMPF" cat "$LOGB" | while read line; do if [[ $line =~ ^\[([0-9a-f]{10})\]\ *(.*)$ ]]; then CID=${BASH_REMATCH[1]} REST=${BASH_REMATCH[2]} echo "git cherry-pick $CID ;# $REST" >>"$TMPF" else echo ";# $line" >>"$TMPF" fi done mv "$TMPF" "$SCRF" chmod +x "$SCRF" ((DRYRUN)) && rm -r "$TMPDIR" || open "$TMPDIR"
2301_81045437/Marlin
buildroot/share/git/mfprep
Shell
agpl-3.0
2,444
#!/usr/bin/env bash # # mfpub # # Use Jekyll to generate Marlin Documentation, which is then # git-pushed to Github to publish it to the live site. # This publishes the current branch, and doesn't force # changes to be pushed to the 'master' branch. Be sure to # push any permanent changes to 'master'. # [[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1; } MFINFO=$(mfinfo "$@") || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" ORG=${INFO[0]} FORK=${INFO[1]} REPO=${INFO[2]} TARG=${INFO[3]} BRANCH=${INFO[4]} CURR=${INFO[5]} if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then echo "Wrong repository." exit fi if [[ $BRANCH == "gh-pages" ]]; then echo "Can't build from 'gh-pages.' Only the Jekyll branches (based on 'master')." exit fi # Check out the named branch (or stay in current) if [[ $BRANCH != $CURR ]]; then echo "Stashing any changes to files..." [[ $(git stash) != "No local "* ]] && HAS_STASH=1 git checkout $BRANCH fi COMMIT=$( git log --format="%H" -n 1 ) # Clean out changes and other junk in the branch git clean -d -f opensite() { URL="$1" OPEN=$( which gnome-open xdg-open open | head -n1 ) if [ -z "$OPEN" ]; then echo "Can't find a tool to open the URL:" echo $URL else echo "Opening the site in the browser..." "$OPEN" "$URL" fi } # Push 'master' to the fork and make a proper PR... if [[ $BRANCH == $TARG ]]; then # Don't lose upstream changes! git fetch upstream # Rebase onto latest master if git rebase upstream/$TARG; then # Allow working directly with the main fork echo echo -n "Pushing to origin/$TARG... " git push origin HEAD:$TARG echo echo -n "Pushing to upstream/$TARG... " git push upstream HEAD:$TARG else echo "Merge conflicts? Stopping here." exit fi else if [ -z "$(git branch -vv | grep ^\* | grep \\\[origin)" ]; then firstpush else echo echo -n "Pushing to origin/$BRANCH... " git push -f origin fi opensite "https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1" fi # Uncomment to compress the final html files # mv ./_plugins/jekyll-press.rb-disabled ./_plugins/jekyll-press.rb # bundle install echo echo "Generating MarlinDocumentation..." rm -rf build # build the site statically and proof it bundle exec jekyll build --profile --trace --no-watch bundle exec htmlproofer ./build --only-4xx --allow-hash-href --check-favicon --check-html --url-swap ".*marlinfw.org/:/" # Sync the built site into a temporary folder TMPFOLDER=$( mktemp -d ) rsync -av build/ ${TMPFOLDER}/ # Clean out changes and other junk in the branch git reset --hard git clean -d -f # Copy built-site into the gh-pages branch git checkout gh-pages || { echo "Something went wrong!"; exit 1; } rsync -av ${TMPFOLDER}/ ./ # Commit and push the new live site directly git add --all git commit --message "Built from ${COMMIT}" git push -f origin git push -f upstream | { while IFS= read -r line do [[ $line =~ "gh-pages -> gh-pages" ]] && opensite "https://marlinfw.org/" echo "$line" done } # remove the temporary folder rm -rf ${TMPFOLDER} # Go back to the branch we started from git checkout $CURR && [[ $HAS_STASH == 1 ]] && git stash pop
2301_81045437/Marlin
buildroot/share/git/mfpub
Shell
agpl-3.0
3,298
#!/usr/bin/env bash # # mfqp [1|2] # # - git add . # - git commit --amend # - git push -f # MFINFO=$(mfinfo "$@") || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" REPO=${INFO[2]} TARG=${INFO[3]} CURR=${INFO[5]} IND=6 while [ $IND -lt ${#INFO[@]} ]; do ARG=${INFO[$IND]} case "$ARG" in -f|--force ) FORCE=1 ;; -h|--help ) USAGE=1 ;; * ) USAGE=1 ; echo "unknown option: $ARG" ;; esac let IND+=1 done [[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; } [[ $FORCE != 1 && $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; } git add . && git commit --amend && git push -f
2301_81045437/Marlin
buildroot/share/git/mfqp
Shell
agpl-3.0
682
#!/usr/bin/env bash # # mfrb # # Do "git rebase -i" against the repo's "target" branch # MFINFO=$(mfinfo "$@") || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" TARG=${INFO[3]} CURR=${INFO[5]} IND=6 while [ $IND -lt ${#INFO[@]} ]; do ARG=${INFO[$IND]} case "$ARG" in -q|--quick ) QUICK=1 ;; -h|--help ) USAGE=1 ;; * ) USAGE=1 ; echo "unknown option: $ARG" ;; esac let IND+=1 done [[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; } [[ $QUICK ]] || git fetch upstream git rebase upstream/$TARG && git rebase -i upstream/$TARG
2301_81045437/Marlin
buildroot/share/git/mfrb
Shell
agpl-3.0
577
#!/usr/bin/env bash # # mfup # # - Fetch latest upstream and replace the PR Target branch with # - Rebase the (current or specified) branch on the PR Target # - Force-push the branch to 'origin' # [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1; } MFINFO=$(mfinfo "$@") || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" ORG=${INFO[0]} FORK=${INFO[1]} REPO=${INFO[2]} TARG=${INFO[3]} BRANCH=${INFO[4]} CURR=${INFO[5]} set -e # Prevent accidental loss of current changes [[ $(git stash) != "No local "* ]] && HAS_STASH=1 echo "Fetching upstream ($ORG/$REPO)..." git fetch upstream if [[ $BRANCH != $TARG ]]; then echo ; echo "Rebasing $BRANCH on $TARG..." if [[ $BRANCH == $CURR ]] || git checkout $BRANCH; then if git rebase upstream/$TARG; then git push -f else echo "Looks like merge conflicts. Stopping here." exit fi else echo "No such branch!" fi else git reset --hard upstream/$TARG fi echo [[ $BRANCH != $CURR ]] && git checkout $CURR [[ $HAS_STASH == 1 ]] && git stash pop
2301_81045437/Marlin
buildroot/share/git/mfup
Shell
agpl-3.0
1,086
// Search pins usable for endstop-interrupts // Compile with the same build settings you'd use for Marlin. #if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) #undef digitalPinToPCICR #define digitalPinToPCICR(p) ( ((p) >= 10 && (p) <= 15) || \ ((p) >= 50 && (p) <= 53) || \ ((p) >= 62 && (p) <= 69) ? (&PCICR) : nullptr) #endif void setup() { Serial.begin(9600); Serial.println("PINs causing interrupts are:"); for (int i = 2; i < NUM_DIGITAL_PINS; i++) { if (digitalPinToPCICR(i) || (int)digitalPinToInterrupt(i) != -1) { for (int j = 0; j < NUM_ANALOG_INPUTS; j++) { if (analogInputToDigitalPin(j) == i) { Serial.print('A'); Serial.print(j); Serial.print(" = "); } } Serial.print('D'); Serial.println(i); } } Serial.println("Arduino pin numbering!"); } void loop() { // put your main code here, to run repeatedly: }
2301_81045437/Marlin
buildroot/share/pin_interrupt_test/pin_interrupt_test.ino
C++
agpl-3.0
1,011
# # MarlinBinaryProtocol.py # Supporting Firmware upload via USB/Serial, saving to the attached media. # import serial import math import time from collections import deque import threading import sys import datetime import random try: import heatshrink2 as heatshrink heatshrink_exists = True except ImportError: try: import heatshrink heatshrink_exists = True except ImportError: heatshrink_exists = False def millis(): return time.perf_counter() * 1000 class TimeOut(object): def __init__(self, milliseconds): self.duration = milliseconds self.reset() def reset(self): self.endtime = millis() + self.duration def timedout(self): return millis() > self.endtime class ReadTimeout(Exception): pass class FatalError(Exception): pass class SycronisationError(Exception): pass class PayloadOverflow(Exception): pass class ConnectionLost(Exception): pass class Protocol(object): device = None baud = None max_block_size = 0 port = None block_size = 0 packet_transit = None packet_status = None packet_ping = None errors = 0 packet_buffer = None simulate_errors = 0 sync = 0 connected = False syncronised = False worker_thread = None response_timeout = 1000 applications = [] responses = deque() def __init__(self, device, baud, bsize, simerr, timeout): print("pySerial Version:", serial.VERSION) self.port = serial.Serial(device, baudrate = baud, write_timeout = 0, timeout = 1) self.device = device self.baud = baud self.block_size = int(bsize) self.simulate_errors = max(min(simerr, 1.0), 0.0) self.connected = True self.response_timeout = timeout self.register(['ok', 'rs', 'ss', 'fe'], self.process_input) self.worker_thread = threading.Thread(target=Protocol.receive_worker, args=(self,)) self.worker_thread.start() def receive_worker(self): while self.port.in_waiting: self.port.reset_input_buffer() def dispatch(data): for tokens, callback in self.applications: for token in tokens: if token == data[:len(token)]: callback((token, data[len(token):])) return def reconnect(): print("Reconnecting..") self.port.close() for x in range(10): try: if self.connected: self.port = serial.Serial(self.device, baudrate = self.baud, write_timeout = 0, timeout = 1) return else: print("Connection closed") return except: time.sleep(1) raise ConnectionLost() while self.connected: try: data = self.port.readline().decode('utf8').rstrip() if len(data): #print(data) dispatch(data) except OSError: reconnect() except UnicodeDecodeError: # dodgy client output or datastream corruption self.port.reset_input_buffer() def shutdown(self): self.connected = False self.worker_thread.join() self.port.close() def process_input(self, data): #print(data) self.responses.append(data) def register(self, tokens, callback): self.applications.append((tokens, callback)) def send(self, protocol, packet_type, data = bytearray()): self.packet_transit = self.build_packet(protocol, packet_type, data) self.packet_status = 0 self.transmit_attempt = 0 timeout = TimeOut(self.response_timeout * 20) while self.packet_status == 0: try: if timeout.timedout(): raise ConnectionLost() self.transmit_packet(self.packet_transit) self.await_response() except ReadTimeout: self.errors += 1 #print("Packetloss detected..") self.packet_transit = None def await_response(self): timeout = TimeOut(self.response_timeout) while not len(self.responses): time.sleep(0.00001) if timeout.timedout(): raise ReadTimeout() while len(self.responses): token, data = self.responses.popleft() switch = {'ok' : self.response_ok, 'rs': self.response_resend, 'ss' : self.response_stream_sync, 'fe' : self.response_fatal_error} switch[token](data) def send_ascii(self, data, send_and_forget = False): self.packet_transit = bytearray(data, "utf8") + b'\n' self.packet_status = 0 self.transmit_attempt = 0 timeout = TimeOut(self.response_timeout * 20) while self.packet_status == 0: try: if timeout.timedout(): return self.port.write(self.packet_transit) if send_and_forget: self.packet_status = 1 else: self.await_response_ascii() except ReadTimeout: self.errors += 1 #print("Packetloss detected..") except serial.serialutil.SerialException: return self.packet_transit = None def await_response_ascii(self): timeout = TimeOut(self.response_timeout) while not len(self.responses): time.sleep(0.00001) if timeout.timedout(): raise ReadTimeout() token, data = self.responses.popleft() self.packet_status = 1 def corrupt_array(self, data): rid = random.randint(0, len(data) - 1) data[rid] ^= 0xAA return data def transmit_packet(self, packet): packet = bytearray(packet) if(self.simulate_errors > 0 and random.random() > (1.0 - self.simulate_errors)): if random.random() > 0.9: #random data drop start = random.randint(0, len(packet)) end = start + random.randint(1, 10) packet = packet[:start] + packet[end:] #print("Dropping {0} bytes".format(end - start)) else: #random corruption packet = self.corrupt_array(packet) #print("Single byte corruption") self.port.write(packet) self.transmit_attempt += 1 def build_packet(self, protocol, packet_type, data = bytearray()): PACKET_TOKEN = 0xB5AD if len(data) > self.max_block_size: raise PayloadOverflow() packet_buffer = bytearray() packet_buffer += self.pack_int8(self.sync) # 8bit sync id packet_buffer += self.pack_int4_2(protocol, packet_type) # 4 bit protocol id, 4 bit packet type packet_buffer += self.pack_int16(len(data)) # 16bit packet length packet_buffer += self.pack_int16(self.build_checksum(packet_buffer)) # 16bit header checksum if len(data): packet_buffer += data packet_buffer += self.pack_int16(self.build_checksum(packet_buffer)) packet_buffer = self.pack_int16(PACKET_TOKEN) + packet_buffer # 16bit start token, not included in checksum return packet_buffer # checksum 16 fletchers def checksum(self, cs, value): cs_low = (((cs & 0xFF) + value) % 255) return ((((cs >> 8) + cs_low) % 255) << 8) | cs_low def build_checksum(self, buffer): cs = 0 for b in buffer: cs = self.checksum(cs, b) return cs def pack_int32(self, value): return value.to_bytes(4, byteorder='little') def pack_int16(self, value): return value.to_bytes(2, byteorder='little') def pack_int8(self, value): return value.to_bytes(1, byteorder='little') def pack_int4_2(self, vh, vl): value = ((vh & 0xF) << 4) | (vl & 0xF) return value.to_bytes(1, byteorder='little') def connect(self): print("Connecting: Switching Marlin to Binary Protocol...") self.send_ascii("M28B1") self.send(0, 1) def disconnect(self): self.send(0, 2) self.syncronised = False def response_ok(self, data): try: packet_id = int(data) except ValueError: return if packet_id != self.sync: raise SycronisationError() self.sync = (self.sync + 1) % 256 self.packet_status = 1 def response_resend(self, data): packet_id = int(data) self.errors += 1 if not self.syncronised: print("Retrying syncronisation") elif packet_id != self.sync: raise SycronisationError() def response_stream_sync(self, data): sync, max_block_size, protocol_version = data.split(',') self.sync = int(sync) self.max_block_size = int(max_block_size) self.block_size = self.max_block_size if self.max_block_size < self.block_size else self.block_size self.protocol_version = protocol_version self.packet_status = 1 self.syncronised = True print("Connection synced [{0}], binary protocol version {1}, {2} byte payload buffer".format(self.sync, self.protocol_version, self.max_block_size)) def response_fatal_error(self, data): raise FatalError() class FileTransferProtocol(object): protocol_id = 1 class Packet(object): QUERY = 0 OPEN = 1 CLOSE = 2 WRITE = 3 ABORT = 4 responses = deque() def __init__(self, protocol, timeout = None): protocol.register(['PFT:success', 'PFT:version:', 'PFT:fail', 'PFT:busy', 'PFT:ioerror', 'PTF:invalid'], self.process_input) self.protocol = protocol self.response_timeout = timeout or protocol.response_timeout def process_input(self, data): #print(data) self.responses.append(data) def await_response(self, timeout = None): timeout = TimeOut(timeout or self.response_timeout) while not len(self.responses): time.sleep(0.0001) if timeout.timedout(): raise ReadTimeout() return self.responses.popleft() def connect(self): self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.QUERY) token, data = self.await_response() if token != 'PFT:version:': return False self.version, _, compression = data.split(':') if compression != 'none': algorithm, window, lookahead = compression.split(',') self.compression = {'algorithm': algorithm, 'window': int(window), 'lookahead': int(lookahead)} else: self.compression = {'algorithm': 'none'} print("File Transfer version: {0}, compression: {1}".format(self.version, self.compression['algorithm'])) def open(self, filename, compression, dummy): payload = b'\1' if dummy else b'\0' # dummy transfer payload += b'\1' if compression else b'\0' # payload compression payload += bytearray(filename, 'utf8') + b'\0'# target filename + null terminator timeout = TimeOut(5000) token = None self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload) while token != 'PFT:success' and not timeout.timedout(): try: token, data = self.await_response(1000) if token == 'PFT:success': print(filename,"opened") return elif token == 'PFT:busy': print("Broken transfer detected, purging") self.abort() time.sleep(0.1) self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload) timeout.reset() elif token == 'PFT:fail': raise Exception("Can not open file on client") except ReadTimeout: pass raise ReadTimeout() def write(self, data): self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.WRITE, data) def close(self): self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.CLOSE) token, data = self.await_response(1000) if token == 'PFT:success': print("File closed") return True elif token == 'PFT:ioerror': print("Client storage device IO error") return False elif token == 'PFT:invalid': print("No open file") return False def abort(self): self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.ABORT) token, data = self.await_response() if token == 'PFT:success': print("Transfer Aborted") def copy(self, filename, dest_filename, compression, dummy): self.connect() has_heatshrink = heatshrink_exists and self.compression['algorithm'] == 'heatshrink' if compression and not has_heatshrink: hs = '2' if sys.version_info[0] > 2 else '' print("Compression not supported by client. Use 'pip install heatshrink%s' to fix." % hs) compression = False data = open(filename, "rb").read() filesize = len(data) self.open(dest_filename, compression, dummy) block_size = self.protocol.block_size if compression: data = heatshrink.encode(data, window_sz2=self.compression['window'], lookahead_sz2=self.compression['lookahead']) cratio = filesize / len(data) blocks = math.floor((len(data) + block_size - 1) / block_size) kibs = 0 dump_pctg = 0 start_time = millis() for i in range(blocks): start = block_size * i end = start + block_size self.write(data[start:end]) kibs = (( (i+1) * block_size) / 1024) / (millis() + 1 - start_time) * 1000 if (i / blocks) >= dump_pctg: print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression else "", self.protocol.errors), end='') dump_pctg += 0.1 if self.protocol.errors > 0: # Dump last status (errors may not be visible) print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3} - Aborting...".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression else "", self.protocol.errors), end='') print("") # New line to break the transfer speed line self.close() print("Transfer aborted due to protocol errors") #raise Exception("Transfer aborted due to protocol errors") return False print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% if not self.close(): print("Transfer failed") return False print("Transfer complete") return True class EchoProtocol(object): def __init__(self, protocol): protocol.register(['echo:'], self.process_input) self.protocol = protocol def process_input(self, data): print(data)
2301_81045437/Marlin
buildroot/share/scripts/MarlinBinaryProtocol.py
Python
agpl-3.0
15,838
/**************************************\ * * * OpenSCAD Mesh Display * * by Thinkyhead - April 2017 * * * * Copy the grid output from Marlin, * * paste below as shown, and use * * OpenSCAD to see a visualization * * of your mesh. * * * \**************************************/ $t = 0.15; // comment out during animation! X = 0; Y = 1; L = 0; R = 1; F = 2; B = 3; // // Sample Mesh - Replace with your own // measured_z = [ [ -1.20, -1.13, -1.09, -1.03, -1.19 ], [ -1.16, -1.25, -1.27, -1.25, -1.08 ], [ -1.13, -1.26, -1.39, -1.31, -1.18 ], [ -1.09, -1.20, -1.26, -1.21, -1.18 ], [ -1.13, -0.99, -1.03, -1.06, -1.32 ] ]; // // An offset to add to all points in the mesh // zadjust = 0; // // Mesh characteristics // bed_size = [ 200, 200 ]; mesh_inset = [ 10, 10, 10, 10 ]; // L, F, R, B mesh_bounds = [ [ mesh_inset[L], mesh_inset[F] ], [ bed_size[X] - mesh_inset[R], bed_size[Y] - mesh_inset[B] ] ]; mesh_size = mesh_bounds[1] - mesh_bounds[0]; // NOTE: Marlin meshes already subtract the probe offset NAN = 0; // Z to use for un-measured points // // Geometry // max_z_scale = 100; // Scale at Time 0.5 min_z_scale = 10; // Scale at Time 0.0 and 1.0 thickness = 0.5; // thickness of the mesh triangles tesselation = 1; // levels of tesselation from 0-2 alternation = 2; // direction change modulus (try it) // // Appearance // show_plane = true; show_labels = true; show_coords = true; arrow_length = 5; label_font_lg = "Arial"; label_font_sm = "Arial"; mesh_color = [1,1,1,0.5]; plane_color = [0.4,0.6,0.9,0.6]; //================================================ Derive useful values big_z = max_2D(measured_z,0); lil_z = min_2D(measured_z,0); mean_value = (big_z + lil_z) / 2.0; mesh_points_y = len(measured_z); mesh_points_x = len(measured_z[0]); xspace = mesh_size[X] / (mesh_points_x - 1); yspace = mesh_size[Y] / (mesh_points_y - 1); // At $t=0 and $t=1 scale will be 100% z_scale_factor = min_z_scale + (($t > 0.5) ? 1.0 - $t : $t) * (max_z_scale - min_z_scale) * 2; // // Min and max recursive functions for 1D and 2D arrays // Return the smallest or largest value in the array // function some_1D(b,i) = (i<len(b)-1) ? (b[i] && some_1D(b,i+1)) : b[i] != 0; function some_2D(a,j) = (j<len(a)-1) ? some_2D(a,j+1) : some_1D(a[j], 0); function min_1D(b,i) = (i<len(b)-1) ? min(b[i], min_1D(b,i+1)) : b[i]; function min_2D(a,j) = (j<len(a)-1) ? min_2D(a,j+1) : min_1D(a[j], 0); function max_1D(b,i) = (i<len(b)-1) ? max(b[i], max_1D(b,i+1)) : b[i]; function max_2D(a,j) = (j<len(a)-1) ? max_2D(a,j+1) : max_1D(a[j], 0); // // Get the corner probe points of a grid square. // // Input : x,y grid indexes // Output : An array of the 4 corner points // function grid_square(x,y) = [ [x * xspace, y * yspace, z_scale_factor * (measured_z[y][x] - mean_value)], [x * xspace, (y+1) * yspace, z_scale_factor * (measured_z[y+1][x] - mean_value)], [(x+1) * xspace, (y+1) * yspace, z_scale_factor * (measured_z[y+1][x+1] - mean_value)], [(x+1) * xspace, y * yspace, z_scale_factor * (measured_z[y][x+1] - mean_value)] ]; // The corner point of a grid square with Z centered on the mean function pos(x,y,z) = [x * xspace, y * yspace, z_scale_factor * (z - mean_value)]; // // Draw the point markers and labels // module point_markers(show_home=true) { // Mark the home position 0,0 if (show_home) translate([1,1]) color([0,0,0,0.25]) cylinder(r=1, h=z_scale_factor, center=true); for (x=[0:mesh_points_x-1], y=[0:mesh_points_y-1]) { z = measured_z[y][x] - zadjust; down = z < mean_value; xyz = pos(x, y, z); translate([ xyz[0], xyz[1] ]) { // Show the XY as well as the Z! if (show_coords) { color("black") translate([0,0,0.5]) { $fn=8; rotate([0,0]) { posx = floor(mesh_bounds[0][X] + x * xspace); posy = floor(mesh_bounds[0][Y] + y * yspace); text(str(posx, ",", posy), 2, label_font_sm, halign="center", valign="center"); } } } translate([ 0, 0, xyz[2] ]) { // Label each point with the Z v = z - mean_value; if (show_labels) { color(abs(v) < 0.1 ? [0,0.5,0] : [0.25,0,0]) translate([0,0,down?-10:10]) { $fn=8; rotate([90,0]) text(str(z), 6, label_font_lg, halign="center", valign="center"); if (v) translate([0,0,down?-6:6]) rotate([90,0]) text(str(down || !v ? "" : "+", v), 3, label_font_sm, halign="center", valign="center"); } } // Show an arrow pointing up or down if (v) { rotate([0, down ? 180 : 0]) translate([0,0,-1]) cylinder( r1=0.5, r2=0.1, h=arrow_length, $fn=12, center=1 ); } else color([1,0,1,0.4]) sphere(r=1.0, $fn=20, center=1); } } } } // // Split a square on the diagonal into // two triangles and render them. // // s : a square // alt : a flag to split on the other diagonal // module tesselated_square(s, alt=false) { add = [0,0,thickness]; p1 = [ s[0], s[1], s[2], s[3], s[0]+add, s[1]+add, s[2]+add, s[3]+add ]; f1 = alt ? [ [0,1,3], [4,5,1,0], [4,7,5], [5,7,3,1], [7,4,0,3] ] : [ [0,1,2], [4,5,1,0], [4,6,5], [5,6,2,1], [6,4,0,2] ]; f2 = alt ? [ [1,2,3], [5,6,2,1], [5,6,7], [6,7,3,2], [7,5,1,3] ] : [ [0,2,3], [4,6,2,0], [4,7,6], [6,7,3,2], [7,4,0,3] ]; // Use the other diagonal polyhedron(points=p1, faces=f1); polyhedron(points=p1, faces=f2); } /** * The simplest mesh display */ module simple_mesh(show_plane=show_plane) { if (show_plane) color(plane_color) cube([mesh_size[X], mesh_size[Y], thickness]); color(mesh_color) for (x=[0:mesh_points_x-2], y=[0:mesh_points_y-2]) tesselated_square(grid_square(x, y)); } /** * Subdivide the mesh into smaller squares. */ module bilinear_mesh(show_plane=show_plane,tesselation=tesselation) { if (show_plane) color(plane_color) translate([-5,-5]) cube([mesh_size[X]+10, mesh_size[Y]+10, thickness]); if (some_2D(measured_z, 0)) { tesselation = tesselation % 4; color(mesh_color) for (x=[0:mesh_points_x-2], y=[0:mesh_points_y-2]) { square = grid_square(x, y); if (tesselation < 1) { tesselated_square(square,(x%alternation)-(y%alternation)); } else { subdiv_4 = subdivided_square(square); if (tesselation < 2) { for (i=[0:3]) tesselated_square(subdiv_4[i],i%alternation); } else { for (i=[0:3]) { subdiv_16 = subdivided_square(subdiv_4[i]); if (tesselation < 3) { for (j=[0:3]) tesselated_square(subdiv_16[j],j%alternation); } else { for (j=[0:3]) { subdiv_64 = subdivided_square(subdiv_16[j]); if (tesselation < 4) { for (k=[0:3]) tesselated_square(subdiv_64[k]); } } } } } } } } } // // Subdivision helpers // function ctrz(a) = (a[0][2]+a[1][2]+a[3][2]+a[2][2])/4; function avgx(a,i) = (a[i][0]+a[(i+1)%4][0])/2; function avgy(a,i) = (a[i][1]+a[(i+1)%4][1])/2; function avgz(a,i) = (a[i][2]+a[(i+1)%4][2])/2; // // Convert one square into 4, applying bilinear averaging // // Input : 1 square (4 points) // Output : An array of 4 squares // function subdivided_square(a) = [ [ // SW square a[0], // SW [a[0][0],avgy(a,0),avgz(a,0)], // CW [avgx(a,1),avgy(a,0),ctrz(a)], // CC [avgx(a,1),a[0][1],avgz(a,3)] // SC ], [ // NW square [a[0][0],avgy(a,0),avgz(a,0)], // CW a[1], // NW [avgx(a,1),a[1][1],avgz(a,1)], // NC [avgx(a,1),avgy(a,0),ctrz(a)] // CC ], [ // NE square [avgx(a,1),avgy(a,0),ctrz(a)], // CC [avgx(a,1),a[1][1],avgz(a,1)], // NC a[2], // NE [a[2][0],avgy(a,0),avgz(a,2)] // CE ], [ // SE square [avgx(a,1),a[0][1],avgz(a,3)], // SC [avgx(a,1),avgy(a,0),ctrz(a)], // CC [a[2][0],avgy(a,0),avgz(a,2)], // CE a[3] // SE ] ]; //================================================ Run the plan translate([-mesh_size[X] / 2, -mesh_size[Y] / 2]) { $fn = 12; point_markers(); bilinear_mesh(); }
2301_81045437/Marlin
buildroot/share/scripts/MarlinMesh.scad
OpenSCAD
agpl-3.0
8,682
#!/usr/bin/env python from __future__ import print_function from __future__ import division """ Generate the stepper delay lookup table for Marlin firmware. """ import argparse __author__ = "Ben Gamari <bgamari@gmail.com>" __copyright__ = "Copyright 2012, Ben Gamari" __license__ = "GPL" parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('-f', '--cpu-freq', type=int, default=16, help='CPU clockrate in MHz (default=16)') parser.add_argument('-d', '--divider', type=int, default=8, help='Timer/counter pre-scale divider (default=8)') args = parser.parse_args() cpu_freq = args.cpu_freq * 1000000 timer_freq = cpu_freq / args.divider print("#pragma once") print() print("#if F_CPU == %d" % cpu_freq) print() print(" const struct { uint16_t base; uint8_t gain; } speed_lookuptable_fast[256] PROGMEM = {") a = [0 for i in range(8)] + [ int(0.5 + float(timer_freq) / (i*256)) for i in range(8, 256) ] b = [0 for i in range(8)] + [ a[i] - a[i+1] for i in range(8, 255) ] b.append(b[-1]) for i in range(32): print(" ", end='') for j in range(8): print("{ %5d, %5d }," % (a[8*i+j], b[8*i+j]), end='') if j < 7: print(" ", end='') if i == 0: print(" // dummy first row") else: print() print(" };") print() print(" const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {") a = [ int(0.5 + float(timer_freq) / ((i*8)+(args.cpu_freq*2))) for i in range(256) ] b = [ a[i] - a[i+1] for i in range(255) ] b.append(b[-1]) for i in range(32): print(" ", end='') for j in range(8): print("{ %5d, %5d }," % (a[8*i+j], b[8*i+j]), end='') if j < 7: print(" ", end='') print() print(" };") print() print("#endif")
2301_81045437/Marlin
buildroot/share/scripts/createSpeedLookupTable.py
Python
agpl-3.0
1,700
#!/usr/bin/env python """Thermistor Value Lookup Table Generator Generates lookup to temperature values for use in a microcontroller in C format based on: https://en.wikipedia.org/wiki/Steinhart-Hart_equation The main use is for Arduino programs that read data from the circuit board described here: https://reprap.org/wiki/Temperature_Sensor_v2.0 Usage: python createTemperatureLookupMarlin.py [options] Options: -h, --help show this help --rp=... pull-up resistor --t1=ttt:rrr low temperature temperature:resistance point (around 25 degC) --t2=ttt:rrr middle temperature temperature:resistance point (around 150 degC) --t3=ttt:rrr high temperature temperature:resistance point (around 250 degC) --num-temps=... the number of temperature points to calculate (default: 36) """ from __future__ import print_function from __future__ import division from math import * import sys,getopt "Constants" ZERO = 273.15 # zero point of Kelvin scale VADC = 5 # ADC voltage VCC = 5 # supply voltage ARES = pow(2,10) # 10 Bit ADC resolution VSTEP = VADC / ARES # ADC voltage resolution TMIN = 0 # lowest temperature in table TMAX = 350 # highest temperature in table class Thermistor: "Class to do the thermistor maths" def __init__(self, rp, t1, r1, t2, r2, t3, r3): l1 = log(r1) l2 = log(r2) l3 = log(r3) y1 = 1.0 / (t1 + ZERO) # adjust scale y2 = 1.0 / (t2 + ZERO) y3 = 1.0 / (t3 + ZERO) x = (y2 - y1) / (l2 - l1) y = (y3 - y1) / (l3 - l1) c = (y - x) / ((l3 - l2) * (l1 + l2 + l3)) b = x - c * (l1**2 + l2**2 + l1*l2) a = y1 - (b + l1**2 *c)*l1 if c < 0: print("//////////////////////////////////////////////////////////////////////////////////////") print("// WARNING: Negative coefficient 'c'! Something may be wrong with the measurements! //") print("//////////////////////////////////////////////////////////////////////////////////////") c = -c self.c1 = a # Steinhart-Hart coefficients self.c2 = b self.c3 = c self.rp = rp # pull-up resistance def resol(self, adc): "Convert ADC reading into a resolution" res = self.temp(adc)-self.temp(adc+1) return res def voltage(self, adc): "Convert ADC reading into a Voltage" return adc * VSTEP # convert the 10 bit ADC value to a voltage def resist(self, adc): "Convert ADC reading into a resistance in Ohms" r = self.rp * self.voltage(adc) / (VCC - self.voltage(adc)) # resistance of thermistor return r def temp(self, adc): "Convert ADC reading into a temperature in Celsius" l = log(self.resist(adc)) Tinv = self.c1 + self.c2*l + self.c3* l**3 # inverse temperature return (1/Tinv) - ZERO # temperature def adc(self, temp): "Convert temperature into a ADC reading" x = (self.c1 - (1.0 / (temp+ZERO))) / (2*self.c3) y = sqrt((self.c2 / (3*self.c3))**3 + x**2) r = exp((y-x)**(1.0/3) - (y+x)**(1.0/3)) return (r / (self.rp + r)) * ARES def main(argv): "Default values" t1 = 25 # low temperature in Kelvin (25 degC) r1 = 100000 # resistance at low temperature (10 kOhm) t2 = 150 # middle temperature in Kelvin (150 degC) r2 = 1641.9 # resistance at middle temperature (1.6 KOhm) t3 = 250 # high temperature in Kelvin (250 degC) r3 = 226.15 # resistance at high temperature (226.15 Ohm) rp = 4700 # pull-up resistor (4.7 kOhm) num_temps = 36 # number of entries for look-up table try: opts, args = getopt.getopt(argv, "h", ["help", "rp=", "t1=", "t2=", "t3=", "num-temps="]) except getopt.GetoptError as err: print(str(err)) usage() sys.exit(2) for opt, arg in opts: if opt in ("-h", "--help"): usage() sys.exit() elif opt == "--rp": rp = int(arg) elif opt == "--t1": arg = arg.split(':') t1 = float(arg[0]) r1 = float(arg[1]) elif opt == "--t2": arg = arg.split(':') t2 = float(arg[0]) r2 = float(arg[1]) elif opt == "--t3": arg = arg.split(':') t3 = float(arg[0]) r3 = float(arg[1]) elif opt == "--num-temps": num_temps = int(arg) t = Thermistor(rp, t1, r1, t2, r2, t3, r3) increment = int((ARES - 1) / (num_temps - 1)) step = int((TMIN - TMAX) / (num_temps - 1)) low_bound = t.temp(ARES - 1) up_bound = t.temp(1) min_temp = int(TMIN if TMIN > low_bound else low_bound) max_temp = int(TMAX if TMAX < up_bound else up_bound) temps = list(range(max_temp, TMIN + step, step)) print("// Thermistor lookup table for Marlin") print("// ./createTemperatureLookupMarlin.py --rp=%s --t1=%s:%s --t2=%s:%s --t3=%s:%s --num-temps=%s" % (rp, t1, r1, t2, r2, t3, r3, num_temps)) print("// Steinhart-Hart Coefficients: a=%.15g, b=%.15g, c=%.15g " % (t.c1, t.c2, t.c3)) print("// Theoretical limits of thermistor: %.2f to %.2f degC" % (low_bound, up_bound)) print() print("const short temptable[][2] PROGMEM = {") for temp in temps: adc = t.adc(temp) print(" { OV(%7.2f), %4s }%s // v=%.3f\tr=%.3f\tres=%.3f degC/count" % (adc , temp, \ ',' if temp != temps[-1] else ' ', \ t.voltage(adc), \ t.resist( adc), \ t.resol( adc) \ )) print("};") def usage(): print(__doc__) if __name__ == "__main__": main(sys.argv[1:])
2301_81045437/Marlin
buildroot/share/scripts/createTemperatureLookupMarlin.py
Python
agpl-3.0
6,286
#!/usr/bin/env bash # # findMissingTranslations.sh # # Locate all language strings needing an update based on English # # Usage: findMissingTranslations.sh [language codes] # # If no language codes are specified then all languages will be checked # langname() { case "$1" in an ) echo "Aragonese" ;; bg ) echo "Bulgarian" ;; ca ) echo "Catalan" ;; cz ) echo "Czech" ;; da ) echo "Danish" ;; de ) echo "German" ;; el ) echo "Greek" ;; el_CY ) echo "Greek (Cyprus)" ;; el_gr) echo "Greek (Greece)" ;; en ) echo "English" ;; es ) echo "Spanish" ;; eu ) echo "Basque-Euskera" ;; fi ) echo "Finnish" ;; fr ) echo "French" ;; fr_na) echo "French (no accent)" ;; gl ) echo "Galician" ;; hr ) echo "Croatian (Hrvatski)" ;; hu ) echo "Hungarian / Magyar" ;; it ) echo "Italian" ;; jp_kana) echo "Japanese (Kana)" ;; ko_KR) echo "Korean" ;; nl ) echo "Dutch" ;; pl ) echo "Polish" ;; pt ) echo "Portuguese" ;; pt_br) echo "Portuguese (Brazil)" ;; ro ) echo "Romanian" ;; ru ) echo "Russian" ;; sk ) echo "Slovak" ;; sv ) echo "Swedish" ;; tr ) echo "Turkish" ;; uk ) echo "Ukrainian" ;; vi ) echo "Vietnamese" ;; zh_CN) echo "Simplified Chinese" ;; zh_TW ) echo "Traditional Chinese" ;; * ) echo "<unknown>" ;; esac } LANGHOME="Marlin/src/lcd/language" [ -d $LANGHOME ] && cd $LANGHOME FILES=$(ls language_*.h | grep -v -E "(_en|_test)\.h" | sed -E 's/language_([^\.]+)\.h/\1/' | tr '\n' ' ') # Get files matching the given arguments TEST_LANGS="" if [[ -n $@ ]]; then for K in "$@"; do for F in $FILES; do [[ $F == $K ]] && TEST_LANGS+="$F " done done [[ -z $TEST_LANGS ]] && { echo "No languages matching $@." ; exit 0 ; } else TEST_LANGS=$FILES fi echo "Finding all missing strings for $TEST_LANGS..." WORD_LINES=() # Complete lines for all words (or, grep out of en at the end instead) ALL_MISSING=() # All missing languages for each missing word #NEED_WORDS=() # All missing words across all specified languages WORD_COUNT=0 # Go through all strings in the English language file # For each word, query all specified languages for the word # If the word is missing, add its language to the list for WORD in $(awk '/LSTR/{print $2}' language_en.h); do # Skip MSG_MARLIN [[ $WORD == "MSG_MARLIN" ]] && break ((WORD_COUNT++)) # Find all selected languages that lack the string LANG_MISSING=" " for LANG in $TEST_LANGS; do if [[ $(grep -c -E "^ *LSTR +$WORD\b" language_${LANG}.h) -eq 0 ]]; then INHERIT=$(awk '/using namespace/{print $3}' language_${LANG}.h | sed -E 's/Language_([a-zA-Z_]+)\s*;/\1/') if [[ -z $INHERIT || $INHERIT == "en" ]]; then LANG_MISSING+="$LANG " elif [[ $(grep -c -E "^ *LSTR +$WORD\b" language_${INHERIT}.h) -eq 0 ]]; then LANG_MISSING+="$LANG " fi fi done # For each word store all the missing languages if [[ $LANG_MISSING != " " ]]; then WORD_LINES+=("$(grep -m 1 -E "$WORD\b" language_en.h)") ALL_MISSING+=("$LANG_MISSING") #NEED_WORDS+=($WORD) fi done echo echo "${#WORD_LINES[@]} out of $WORD_COUNT LCD strings need translation" for LANG in $TEST_LANGS; do HED=0 ; IND=0 for WORDLANGS in "${ALL_MISSING[@]}"; do # If the current word is missing from the current language then print it if [[ $WORDLANGS =~ " $LANG " ]]; then [[ $HED == 0 ]] && { echo ; echo "Missing strings for language_$LANG.h ($(langname $LANG)):" ; HED=1 ; } echo "${WORD_LINES[$IND]}" fi ((IND++)) done done
2301_81045437/Marlin
buildroot/share/scripts/findMissingTranslations.sh
Shell
agpl-3.0
3,804
#!/usr/bin/env python # This file is for preprocessing G-code and the new G29 Auto bed leveling from Marlin # It will analyze the first 2 layers and return the maximum size for this part # Then it will be replaced with g29_keyword = ';MarlinG29Script' with the new G29 LRFB. # The new file will be created in the same folder. from __future__ import print_function # Your G-code file/folder folder = './' my_file = 'test.gcode' # this is the minimum of G1 instructions which should be between 2 different heights min_g1 = 3 # maximum number of lines to parse, I don't want to parse the complete file # only the first plane is we are interested in max_g1 = 100000000 # g29 keyword g29_keyword = 'g29' g29_keyword = g29_keyword.upper() # output filename output_file = folder + 'g29_' + my_file # input filename input_file = folder + my_file # minimum scan size min_size = 40 probing_points = 3 # points x points # other stuff min_x = 500 min_y = min_x max_x = -500 max_y = max_x last_z = 0.001 layer = 0 lines_of_g1 = 0 gcode = [] # return only g1-lines def has_g1(line): return line[:2].upper() == "G1" # find position in g1 (x,y,z) def find_axis(line, axis): found = False number = "" for char in line: if found: if char == ".": number += char elif char == "-": number += char else: try: int(char) number += char except ValueError: break else: found = char.upper() == axis.upper() try: return float(number) except ValueError: return None # save the min or max-values for each axis def set_mima(line): global min_x, max_x, min_y, max_y, last_z current_x = find_axis(line, 'x') current_y = find_axis(line, 'y') if current_x is not None: min_x = min(current_x, min_x) max_x = max(current_x, max_x) if current_y is not None: min_y = min(current_y, min_y) max_y = max(current_y, max_y) return min_x, max_x, min_y, max_y # find z in the code and return it def find_z(gcode, start_at_line=0): for i in range(start_at_line, len(gcode)): my_z = find_axis(gcode[i], 'Z') if my_z is not None: return my_z, i def z_parse(gcode, start_at_line=0, end_at_line=0): i = start_at_line all_z = [] line_between_z = [] z_at_line = [] # last_z = 0 last_i = -1 while len(gcode) > i: try: z, i = find_z(gcode, i + 1) except TypeError: break all_z.append(z) z_at_line.append(i) temp_line = i - last_i -1 line_between_z.append(i - last_i - 1) # last_z = z last_i = i if 0 < end_at_line <= i or temp_line >= min_g1: # print('break at line {} at height {}'.format(i, z)) break line_between_z = line_between_z[1:] return all_z, line_between_z, z_at_line # get the lines which should be the first layer def get_lines(gcode, minimum): i = 0 all_z, line_between_z, z_at_line = z_parse(gcode, end_at_line=max_g1) for count in line_between_z: i += 1 if count > minimum: # print('layer: {}:{}'.format(z_at_line[i-1], z_at_line[i])) return z_at_line[i - 1], z_at_line[i] with open(input_file, 'r') as file: lines = 0 for line in file: lines += 1 if lines > 1000: break if has_g1(line): gcode.append(line) file.close() start, end = get_lines(gcode, min_g1) for i in range(start, end): set_mima(gcode[i]) print('x_min:{} x_max:{}\ny_min:{} y_max:{}'.format(min_x, max_x, min_y, max_y)) # resize min/max - values for minimum scan if max_x - min_x < min_size: offset_x = int((min_size - (max_x - min_x)) / 2 + 0.5) # int round up # print('min_x! with {}'.format(int(max_x - min_x))) min_x = int(min_x) - offset_x max_x = int(max_x) + offset_x if max_y - min_y < min_size: offset_y = int((min_size - (max_y - min_y)) / 2 + 0.5) # int round up # print('min_y! with {}'.format(int(max_y - min_y))) min_y = int(min_y) - offset_y max_y = int(max_y) + offset_y new_command = 'G29 L{0} R{1} F{2} B{3} P{4}\n'.format(min_x, max_x, min_y, max_y, probing_points) out_file = open(output_file, 'w') in_file = open(input_file, 'r') for line in in_file: if line[:len(g29_keyword)].upper() == g29_keyword: out_file.write(new_command) print('write G29') else: out_file.write(line) file.close() out_file.close() print('auto G29 finished')
2301_81045437/Marlin
buildroot/share/scripts/g29_auto.py
Python
agpl-3.0
4,888
#!/usr/bin/env python3 # # Marlin 3D Printer Firmware # Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] # # Based on Sprinter and grbl. # Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm # # This program 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. # # This program 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. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # # Generate Marlin TFT Images from bitmaps/PNG/JPG import sys,struct from PIL import Image def image2bin(image, output_file): if output_file.endswith(('.c', '.cpp')): f = open(output_file, 'wt') is_cpp = True f.write("const uint16_t image[%d] = {\n" % (image.size[1] * image.size[0])) else: f = open(output_file, 'wb') is_cpp = False pixs = image.load() for y in range(image.size[1]): for x in range(image.size[0]): R = pixs[x, y][0] >> 3 G = pixs[x, y][1] >> 2 B = pixs[x, y][2] >> 3 rgb = (R << 11) | (G << 5) | B if is_cpp: strHex = '0x{0:04X}, '.format(rgb) f.write(strHex) else: f.write(struct.pack("B", (rgb & 0xFF))) f.write(struct.pack("B", (rgb >> 8) & 0xFF)) if is_cpp: f.write("\n") if is_cpp: f.write("};\n") f.close() if len(sys.argv) <= 2: print("Utility to export a image in Marlin TFT friendly format.") print("It will dump a raw bin RGB565 image or create a CPP file with an array of 16 bit image pixels.") print("Usage: gen-tft-image.py INPUT_IMAGE.(png|bmp|jpg) OUTPUT_FILE.(cpp|bin)") print("Author: rhapsodyv") exit(1) output_img = sys.argv[2] img = Image.open(sys.argv[1]) image2bin(img, output_img)
2301_81045437/Marlin
buildroot/share/scripts/gen-tft-image.py
Python
agpl-3.0
2,242
#!/usr/bin/env python """ Extract the builds used in Github CI, so that we can run them locally """ import yaml # Set the yaml file to parse yaml_file = '.github/workflows/ci-build-tests.yml' # Parse the yaml file, and load it into a dictionary (github_configuration) with open(yaml_file) as f: github_configuration = yaml.safe_load(f) # Print out the test platforms print(' '.join(github_configuration['jobs']['test_builds']['strategy']['matrix']['test-platform']))
2301_81045437/Marlin
buildroot/share/scripts/get_test_targets.py
Python
agpl-3.0
474
#!/usr/bin/env python3 ''' languageExport.py Export LCD language strings to CSV files for easier translation. Use importTranslations.py to import CSV into the language files. ''' import re from pathlib import Path from languageUtil import namebyid LANGHOME = "Marlin/src/lcd/language" # Write multiple sheets if true, otherwise write one giant sheet MULTISHEET = True OUTDIR = 'out-csv' # Check for the path to the language files if not Path(LANGHOME).is_dir(): print("Error: Couldn't find the '%s' directory." % LANGHOME) print("Edit LANGHOME or cd to the root of the repo before running.") exit(1) # A limit just for testing LIMIT = 0 # A dictionary to contain strings for each language. # Init with 'en' so English will always be first. language_strings = { 'en': 0 } # A dictionary to contain all distinct LCD string names names = {} # Get all "language_*.h" files langfiles = sorted(list(Path(LANGHOME).glob('language_*.h'))) # Read each language file for langfile in langfiles: # Get the language code from the filename langcode = langfile.name.replace('language_', '').replace('.h', '') # Skip 'test' and any others that we don't want if langcode in ['test']: continue # Open the file f = open(langfile, 'r', encoding='utf-8') if not f: continue # Flags to indicate a wide or tall section wideflag, tallflag = False, False # A counter for the number of strings in the file stringcount = 0 # A dictionary to hold all the strings strings = { 'narrow': {}, 'wide': {}, 'tall': {} } # Read each line in the file for line in f: # Clean up the line for easier parsing line = line.split("//")[0].strip() if line.endswith(';'): line = line[:-1].strip() # Check for wide or tall sections, assume no complicated nesting if line.startswith("#endif") or line.startswith("#else"): wideflag, tallflag = False, False elif re.match(r'#if.*WIDTH\s*>=?\s*2[01].*', line): wideflag = True elif re.match(r'#if.*LCD_HEIGHT\s*>=?\s*4.*', line): tallflag = True # For string-defining lines capture the string data match = re.match(r'LSTR\s+([A-Z0-9_]+)\s*=\s*(.+)\s*', line) if match: # Name and quote-sanitized value name, value = match.group(1), match.group(2).replace('\\"', '$$$') # Remove all _UxGT wrappers from the value in a non-greedy way value = re.sub(r'_UxGT\((".*?")\)', r'\1', value) # Multi-line strings get one or more bars | for identification multiline = 0 multimatch = re.match(r'.*MSG_(\d)_LINE\s*\(\s*(.+?)\s*\).*', value) if multimatch: multiline = int(multimatch.group(1)) value = '|' + re.sub(r'"\s*,\s*"', '|', multimatch.group(2)) # Wrap inline defines in parentheses value = re.sub(r' *([A-Z0-9]+_[A-Z0-9_]+) *', r'(\1)', value) # Remove quotes around strings value = re.sub(r'"(.*?)"', r'\1', value).replace('$$$', '""') # Store all unique names as dictionary keys names[name] = 1 # Store the string as narrow or wide strings['tall' if tallflag else 'wide' if wideflag else 'narrow'][name] = value # Increment the string counter stringcount += 1 # Break for testing if LIMIT and stringcount >= LIMIT: break # Close the file f.close() # Store the array in the dict language_strings[langcode] = strings # Get the language codes from the dictionary langcodes = list(language_strings.keys()) # Print the array #print(language_strings) # Report the total number of unique strings print("Found %s distinct LCD strings." % len(names)) # Write a single language entry to the CSV file with narrow, wide, and tall strings def write_csv_lang(f, strings, name): f.write(',') if name in strings['narrow']: f.write('"%s"' % strings['narrow'][name]) f.write(',') if name in strings['wide']: f.write('"%s"' % strings['wide'][name]) f.write(',') if name in strings['tall']: f.write('"%s"' % strings['tall'][name]) if MULTISHEET: # # Export a separate sheet for each language # Path.mkdir(Path(OUTDIR), exist_ok=True) for lang in langcodes: with open("%s/language_%s.csv" % (OUTDIR, lang), 'w', encoding='utf-8') as f: lname = lang + ' ' + namebyid(lang) header = ['name', lname, lname + ' (wide)', lname + ' (tall)'] f.write('"' + '","'.join(header) + '"\n') for name in names.keys(): f.write('"' + name + '"') write_csv_lang(f, language_strings[lang], name) f.write('\n') else: # # Export one large sheet containing all languages # with open("languages.csv", 'w', encoding='utf-8') as f: header = ['name'] for lang in langcodes: lname = lang + ' ' + namebyid(lang) header += [lname, lname + ' (wide)', lname + ' (tall)'] f.write('"' + '","'.join(header) + '"\n') for name in names.keys(): f.write('"' + name + '"') for lang in langcodes: write_csv_lang(f, language_strings[lang], name) f.write('\n')
2301_81045437/Marlin
buildroot/share/scripts/languageExport.py
Python
agpl-3.0
5,334
#!/usr/bin/env python3 """ languageImport.py Import LCD language strings from a CSV file or Google Sheets and write Marlin LCD language files based on the data. Use languageExport.py to export CSV from the language files. Google Sheets Link: https://docs.google.com/spreadsheets/d/12yiy-kS84ajKFm7oQIrC4CF8ZWeu9pAR4zrgxH4ruk4/edit#gid=84528699 TODO: Use the defines and comments above the namespace from existing language files. Get the 'constexpr uint8_t CHARSIZE' from existing language files. Get the correct 'using namespace' for languages that don't inherit from English. """ import sys, re, requests, csv, datetime from languageUtil import namebyid LANGHOME = "Marlin/src/lcd/language" OUTDIR = 'out-language' # Get the file path from the command line FILEPATH = sys.argv[1] if len(sys.argv) > 1 else None download = FILEPATH == 'download' if not FILEPATH or download: SHEETID = "12yiy-kS84ajKFm7oQIrC4CF8ZWeu9pAR4zrgxH4ruk4" FILEPATH = 'https://docs.google.com/spreadsheet/ccc?key=%s&output=csv' % SHEETID if FILEPATH.startswith('http'): response = requests.get(FILEPATH) assert response.status_code == 200, 'GET failed for %s' % FILEPATH csvdata = response.content.decode('utf-8') else: if not FILEPATH.endswith('.csv'): FILEPATH += '.csv' with open(FILEPATH, 'r', encoding='utf-8') as f: csvdata = f.read() if not csvdata: print("Error: couldn't read CSV data from %s" % FILEPATH) exit(1) if download: DLNAME = sys.argv[2] if len(sys.argv) > 2 else 'languages.csv' if not DLNAME.endswith('.csv'): DLNAME += '.csv' with open(DLNAME, 'w', encoding='utf-8') as f: f.write(csvdata) print("Downloaded %s from %s" % (DLNAME, FILEPATH)) exit(0) lines = csvdata.splitlines() print(lines) reader = csv.reader(lines, delimiter=',') gothead = False columns = [''] numcols = 0 strings_per_lang = {} for row in reader: if not gothead: gothead = True numcols = len(row) if row[0] != 'name': print('Error: first column should be "name"') exit(1) # The rest of the columns are language codes and names for i in range(1, numcols): elms = row[i].split(' ') lang = elms[0] style = ('Wide' if elms[-1] == '(wide)' else 'Tall' if elms[-1] == '(tall)' else 'Narrow') columns.append({ 'lang': lang, 'style': style }) if not lang in strings_per_lang: strings_per_lang[lang] = {} if not style in strings_per_lang[lang]: strings_per_lang[lang][style] = {} continue # Add the named string for all the included languages name = row[0] for i in range(1, numcols): str = row[i] if str: col = columns[i] strings_per_lang[col['lang']][col['style']][name] = str # Create a folder for the imported language outfiles from pathlib import Path Path.mkdir(Path(OUTDIR), exist_ok=True) FILEHEADER = ''' /** * Marlin 3D Printer Firmware * Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program 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. * * This program 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. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ #pragma once /** * %s * * LCD Menu Messages * See also https://marlinfw.org/docs/development/lcd_language.html * * Substitutions are applied for the following characters when used in menu items titles: * * $ displays an inserted string * { displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) * @ displays an axis name such as XYZUVW, or E for an extruder */ ''' # Iterate over the languages which correspond to the columns # The columns are assumed to be grouped by language in the order Narrow, Wide, Tall # TODO: Go through lang only, then impose the order Narrow, Wide, Tall. # So if something is missing or out of order everything still gets built correctly. f = None gotlang = {} for i in range(1, numcols): #if i > 6: break # Testing col = columns[i] lang, style = col['lang'], col['style'] # If we haven't already opened a file for this language, do so now if not lang in gotlang: gotlang[lang] = {} if f: f.close() fn = "%s/language_%s.h" % (OUTDIR, lang) f = open(fn, 'w', encoding='utf-8') if not f: print("Failed to open %s." % fn) exit(1) # Write the opening header for the new language file #f.write(FILEHEADER % namebyid(lang)) f.write('/**\n * Imported from %s on %s at %s\n */\n' % (FILEPATH, datetime.date.today(), datetime.datetime.now().strftime("%H:%M:%S"))) # Start a namespace for the language and style f.write('\nnamespace Language%s_%s {\n' % (style, lang)) # Wide and tall namespaces inherit from the others if style == 'Wide': f.write(' using namespace LanguageNarrow_%s;\n' % lang) f.write(' #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2\n') elif style == 'Tall': f.write(' using namespace LanguageWide_%s;\n' % lang) f.write(' #if LCD_HEIGHT >= 4\n') elif lang != 'en': f.write(' using namespace Language_en; // Inherit undefined strings from English\n') # Formatting for the lines indent = ' ' if style == 'Narrow' else ' ' width = 34 if style == 'Narrow' else 32 lstr_fmt = '%sLSTR %%-%ds = %%s;%%s\n' % (indent, width) # Emit all the strings for this language and style for name in strings_per_lang[lang][style].keys(): # Get the raw string value val = strings_per_lang[lang][style][name] # Count the number of bars if val.startswith('|'): bars = val.count('|') val = val[1:] else: bars = 0 # Escape backslashes, substitute quotes, and wrap in _UxGT("...") val = '_UxGT("%s")' % val.replace('\\', '\\\\').replace('"', '$$$') # Move named references outside of the macro val = re.sub(r'\(([A-Z0-9]+_[A-Z0-9_]+)\)', r'") \1 _UxGT("', val) # Remove all empty _UxGT("") that result from the above val = re.sub(r'\s*_UxGT\(""\)\s*', '', val) # No wrapper needed for just spaces val = re.sub(r'_UxGT\((" +")\)', r'\1', val) # Multi-line strings start with a bar... if bars: # Wrap the string in MSG_#_LINE(...) and split on bars val = re.sub(r'^_UxGT\((.+)\)', r'_UxGT(MSG_%s_LINE(\1))' % bars, val) val = val.replace('|', '", "') # Restore quotes inside the string val = val.replace('$$$', '\\"') # Add a comment with the English string for reference comm = '' if lang != 'en' and 'en' in strings_per_lang: en = strings_per_lang['en'] if name in en[style]: str = en[style][name] elif name in en['Narrow']: str = en['Narrow'][name] if str: cfmt = '%%%ss// %%s' % (50 - len(val) if len(val) < 50 else 1) comm = cfmt % (' ', str) # Write out the string definition f.write(lstr_fmt % (name, val, comm)) if style == 'Wide' or style == 'Tall': f.write(' #endif\n') f.write('}\n') # End namespace # Assume the 'Tall' namespace comes last if style == 'Tall': f.write('\nnamespace Language_%s {\n using namespace LanguageTall_%s;\n}\n' % (lang, lang)) # Close the last-opened output file if f: f.close()
2301_81045437/Marlin
buildroot/share/scripts/languageImport.py
Python
agpl-3.0
8,140
#!/usr/bin/env python3 # # marlang.py # # A dictionary to contain language names LANGNAME = { 'an': "Aragonese", 'bg': "Bulgarian", 'ca': "Catalan", 'cz': "Czech", 'da': "Danish", 'de': "German", 'el': "Greek", 'el_CY': "Greek (Cyprus)", 'el_gr': "Greek (Greece)", 'en': "English", 'es': "Spanish", 'eu': "Basque-Euskera", 'fi': "Finnish", 'fr': "French", 'fr_na': "French (no accent)", 'gl': "Galician", 'hr': "Croatian (Hrvatski)", 'hu': "Hungarian / Magyar", 'it': "Italian", 'jp_kana': "Japanese (Kana)", 'ko_KR': "Korean", 'nl': "Dutch", 'pl': "Polish", 'pt': "Portuguese", 'pt_br': "Portuguese (Brazil)", 'ro': "Romanian", 'ru': "Russian", 'sk': "Slovak", 'sv': "Swedish", 'tr': "Turkish", 'uk': "Ukrainian", 'vi': "Vietnamese", 'zh_CN': "Simplified Chinese", 'zh_TW': "Traditional Chinese" } def namebyid(id): if id in LANGNAME: return LANGNAME[id] return '<unknown>'
2301_81045437/Marlin
buildroot/share/scripts/languageUtil.py
Python
agpl-3.0
1,001
#!/usr/bin/env python3 # # Formatter script for pins_MYPINS.h files # # Usage: pinsformat.py [infile] [outfile] # # With no parameters convert STDIN to STDOUT # import sys, re do_log = False def logmsg(msg, line): if do_log: print(msg, line) col_comment = 50 # String lpad / rpad def lpad(astr, fill, c=' '): if not fill: return astr need = fill - len(astr) return astr if need <= 0 else (need * c) + astr def rpad(astr, fill, c=' '): if not fill: return astr need = fill - len(astr) return astr if need <= 0 else astr + (need * c) # Concatenate a string, adding a space if necessary # to avoid merging two words def concat_with_space(s1, s2): if not s1.endswith(' ') and not s2.startswith(' '): s1 += ' ' return s1 + s2 # Pin patterns mpatt = [ r'-?\d{1,3}', r'P[A-I]\d+', r'P\d_\d+', r'Pin[A-Z]\d\b' ] mstr = '|'.join(mpatt) mexpr = [ re.compile(f'^{m}$') for m in mpatt ] # Corrsponding padding for each pattern ppad = [ 3, 4, 5, 5 ] # Match a define line definePatt = re.compile(rf'^\s*(//)?#define\s+[A-Z_][A-Z0-9_]+\s+({mstr})\s*(//.*)?$') def format_pins(argv): src_file = 'stdin' dst_file = None scnt = 0 for arg in argv: if arg == '-v': global do_log do_log = True elif scnt == 0: # Get a source file if specified. Default destination is the same file src_file = dst_file = arg scnt += 1 elif scnt == 1: # Get destination file if specified dst_file = arg scnt += 1 # No text to process yet file_text = '' if src_file == 'stdin': # If no source file specified read from STDIN file_text = sys.stdin.read() else: # Open and read the file src_file with open(src_file, 'r') as rf: file_text = rf.read() if len(file_text) == 0: print('No text to process') return # Read from file or STDIN until it terminates filtered = process_text(file_text) if dst_file: with open(dst_file, 'w') as wf: wf.write(filtered) else: print(filtered) # Find the pin pattern so non-pin defines can be skipped def get_pin_pattern(txt): r = '' m = 0 match_count = [ 0, 0, 0, 0 ] # Find the most common matching pattern match_threshold = 5 for line in txt.split('\n'): r = definePatt.match(line) if r == None: continue ind = -1 for p in mexpr: ind += 1 if not p.match(r[2]): continue match_count[ind] += 1 if match_count[ind] >= match_threshold: return { 'match': mpatt[ind], 'pad':ppad[ind] } return None def process_text(txt): if len(txt) == 0: return '(no text)' patt = get_pin_pattern(txt) if patt == None: return txt pmatch = patt['match'] pindefPatt = re.compile(rf'^(\s*(//)?#define)\s+([A-Z_][A-Z0-9_]+)\s+({pmatch})\s*(//.*)?$') noPinPatt = re.compile(r'^(\s*(//)?#define)\s+([A-Z_][A-Z0-9_]+)\s+(-1)\s*(//.*)?$') skipPatt1 = re.compile(r'^(\s*(//)?#define)\s+(AT90USB|USBCON|(BOARD|DAC|FLASH|HAS|IS|USE)_.+|.+_(ADDRESS|AVAILABLE|BAUDRATE|CLOCK|CONNECTION|DEFAULT|ERROR|EXTRUDERS|FREQ|ITEM|MKS_BASE_VERSION|MODULE|NAME|ONLY|ORIENTATION|PERIOD|RANGE|RATE|READ_RETRIES|SERIAL|SIZE|SPI|STATE|STEP|TIMER|VERSION))\s+(.+)\s*(//.*)?$') skipPatt2 = re.compile(r'^(\s*(//)?#define)\s+([A-Z_][A-Z0-9_]+)\s+(0x[0-9A-Fa-f]+|\d+|.+[a-z].+)\s*(//.*)?$') skipPatt3 = re.compile(r'^\s*#e(lse|ndif)\b.*$') aliasPatt = re.compile(r'^(\s*(//)?#define)\s+([A-Z_][A-Z0-9_]+)\s+([A-Z_][A-Z0-9_()]+)\s*(//.*)?$') switchPatt = re.compile(r'^(\s*(//)?#define)\s+([A-Z_][A-Z0-9_]+)\s*(//.*)?$') undefPatt = re.compile(r'^(\s*(//)?#undef)\s+([A-Z_][A-Z0-9_]+)\s*(//.*)?$') defPatt = re.compile(r'^(\s*(//)?#define)\s+([A-Z_][A-Z0-9_]+)\s+([-_\w]+)\s*(//.*)?$') condPatt = re.compile(r'^(\s*(//)?#(if|ifn?def|elif)(\s+\S+)*)\s+(//.*)$') commPatt = re.compile(r'^\s{20,}(//.*)?$') col_value_lj = col_comment - patt['pad'] - 2 col_value_rj = col_comment - 3 # # #define SKIP_ME # def trySkip1(d): if skipPatt1.match(d['line']) == None: return False logmsg("skip:", d['line']) return True # # #define MY_PIN [pin] # def tryPindef(d): line = d['line'] r = pindefPatt.match(line) if r == None: return False logmsg("pin:", line) pinnum = r[4] if r[4][0] == 'P' else lpad(r[4], patt['pad']) line = f'{r[1]} {r[3]}' line = concat_with_space(rpad(line, col_value_lj), pinnum) if r[5]: line = rpad(line, col_comment) + r[5] d['line'] = line return True # # #define MY_PIN -1 # def tryNoPin(d): line = d['line'] r = noPinPatt.match(line) if r == None: return False logmsg("pin -1:", line) line = f'{r[1]} {r[3]}' line = concat_with_space(rpad(line, col_value_lj), '-1') if r[5]: line = rpad(line, col_comment) + r[5] d['line'] = line return True # # #define SKIP_ME_TOO # def trySkip2(d): if skipPatt2.match( d['line']) == None: return False logmsg("skip:", d['line']) return True # # #else|endif # def trySkip3(d): if skipPatt3.match( d['line']) == None: return False logmsg("skip:", d['line']) return True # # #define ALIAS OTHER # def tryAlias(d): line = d['line'] r = aliasPatt.match(line) if r == None: return False logmsg("alias:", line) line = f'{r[1]} {r[3]}' line = concat_with_space(line, lpad(r[4], col_value_rj + 1 - len(line))) if r[5]: line = concat_with_space(rpad(line, col_comment), r[5]) d['line'] = line return True # # #define SWITCH # def trySwitch(d): line = d['line'] r = switchPatt.match(line) if r == None: return False logmsg("switch:", line) line = f'{r[1]} {r[3]}' if r[4]: line = concat_with_space(rpad(line, col_comment), r[4]) d['line'] = line d['check_comment_next'] = True return True # # #define ... # def tryDef(d): line = d['line'] r = defPatt.match(line) if r == None: return False logmsg("def:", line) line = f'{r[1]} {r[3]} ' line = concat_with_space(line, lpad(r[4], col_value_rj + 1 - len(line))) if r[5]: line = rpad(line, col_comment - 1) + ' ' + r[5] d['line'] = line return True # # #undef ... # def tryUndef(d): line = d['line'] r = undefPatt.match(line) if r == None: return False logmsg("undef:", line) line = f'{r[1]} {r[3]}' if r[4]: line = concat_with_space(rpad(line, col_comment), r[4]) d['line'] = line return True # # #if|ifdef|ifndef|elif ... # def tryCond(d): line = d['line'] r = condPatt.match(line) if r == None: return False logmsg("cond:", line) line = concat_with_space(rpad(r[1], col_comment), r[5]) d['line'] = line d['check_comment_next'] = True return True out = '' wDict = { 'check_comment_next': False } # Transform each line and add it to the output for line in txt.split('\n'): wDict['line'] = line if wDict['check_comment_next']: r = commPatt.match(line) wDict['check_comment_next'] = (r != None) if wDict['check_comment_next']: # Comments in column 50 line = rpad('', col_comment) + r[1] elif trySkip1(wDict): pass #define SKIP_ME elif tryPindef(wDict): pass #define MY_PIN [pin] elif tryNoPin(wDict): pass #define MY_PIN -1 elif trySkip2(wDict): pass #define SKIP_ME_TOO elif trySkip3(wDict): pass #else|endif elif tryAlias(wDict): pass #define ALIAS OTHER elif trySwitch(wDict): pass #define SWITCH elif tryDef(wDict): pass #define ... elif tryUndef(wDict): pass #undef ... elif tryCond(wDict): pass #if|ifdef|ifndef|elif ... out += wDict['line'] + '\n' return re.sub('\n\n$', '\n', re.sub(r'\n\n+', '\n\n', out)) # Python standard startup for command line with arguments if __name__ == '__main__': format_pins(sys.argv[1:])
2301_81045437/Marlin
buildroot/share/scripts/pinsformat.py
Python
agpl-3.0
8,515
#!/usr/bin/env python3 # # Utility to compress Marlin RGB565 TFT data to RLE16 format. # Reads the existing Marlin RGB565 cpp file and generates a new file with the additional RLE16 data. # # Usage: rle16_compress_cpp_image_data.py INPUT_FILE.cpp OUTPUT_FILE.cpp # import sys,struct import re def addCompressedData(input_file, output_file): ofile = open(output_file, 'wt') c_data_section = False c_skip_data = False c_footer = False raw_data = [] rle_value = [] rle_count = [] arrname = '' line = input_file.readline() while line: if not c_footer: if not c_skip_data: ofile.write(line) if "};" in line: c_skip_data = False c_data_section = False c_footer = True if c_data_section: cleaned = re.sub(r"\s|,|\n", "", line) as_list = cleaned.split("0x") as_list.pop(0) raw_data += [int(x, 16) for x in as_list] if "const uint" in line: # e.g.: const uint16_t marlin_logo_480x320x16[153600] = { if "_rle16" in line: c_skip_data = True else: c_data_section = True arrname = line.split('[')[0].split(' ')[-1] print("Found data array", arrname) line = input_file.readline() input_file.close() # # RLE16 (run length 16) encoding # Convert data from from raw RGB565 to a simple run-length-encoded format for each word of data. # - Each sequence begins with a count byte N. # - If the high bit is set in N the run contains N & 0x7F + 1 unique words. # - Otherwise it repeats the following word N + 1 times. # - Each RGB565 word is stored in MSB / LSB order. # def rle_encode(data): warn = "This may take a while" if len(data) > 300000 else "" print("Compressing image data...", warn) rledata = [] distinct = [] i = 0 while i < len(data): v = data[i] i += 1 rsize = 1 for j in range(i, len(data)): if v != data[j]: break i += 1 rsize += 1 if rsize >= 128: break # If the run is one, add to the distinct values if rsize == 1: distinct.append(v) # If distinct length >= 127, or the repeat run is 2 or more, # store the distinct run. nr = len(distinct) if nr and (nr >= 128 or rsize > 1 or i >= len(data)): rledata += [(nr - 1) | 0x80] + distinct distinct = [] # If the repeat run is 2 or more, store the repeat run. if rsize > 1: rledata += [rsize - 1, v] return rledata def append_byte(data, byte, cols=240): if data == '': data = ' ' data += ('0x{0:02X}, '.format(byte)) # 6 characters if len(data) % (cols * 6 + 2) == 0: data = data.rstrip() + "\n " return data def rle_emit(ofile, arrname, rledata, rawsize): col = 0 i = 0 outstr = '' size = 0 while i < len(rledata): rval = rledata[i] i += 1 if rval & 0x80: count = (rval & 0x7F) + 1 outstr = append_byte(outstr, rval) size += 1 for j in range(count): outstr = append_byte(outstr, rledata[i + j] >> 8) outstr = append_byte(outstr, rledata[i + j] & 0xFF) size += 2 i += count else: outstr = append_byte(outstr, rval) outstr = append_byte(outstr, rledata[i] >> 8) outstr = append_byte(outstr, rledata[i] & 0xFF) i += 1 size += 3 outstr = outstr.rstrip()[:-1] ofile.write("\n// Saves %i bytes\nconst uint8_t %s_rle16[%d] = {\n%s\n};\n" % (rawsize - size, arrname, size, outstr)) (w, h, d) = arrname.split("_")[-1].split('x') ofile.write("\nconst tImage MarlinLogo{0}x{1}x16 = MARLIN_LOGO_CHOSEN({0}, {1});\n".format(w, h)) ofile.write("\n#endif // HAS_GRAPHICAL_TFT && SHOW_BOOTSCREEN\n".format(w, h)) # Encode the data, write it out, close the file rledata = rle_encode(raw_data) rle_emit(ofile, arrname, rledata, len(raw_data) * 2) ofile.close() if len(sys.argv) <= 2: print("Utility to compress Marlin RGB565 TFT data to RLE16 format.") print("Reads a Marlin RGB565 cpp file and generates a new file with the additional RLE16 data.") print("Usage: rle16_compress_cpp_image_data.py INPUT_FILE.cpp OUTPUT_FILE.cpp") exit(1) output_cpp = sys.argv[2] inname = sys.argv[1].replace('//', '/') input_cpp = open(inname) print("Processing", inname, "...") addCompressedData(input_cpp, output_cpp)
2301_81045437/Marlin
buildroot/share/scripts/rle16_compress_cpp_image_data.py
Python
agpl-3.0
4,887
#!/usr/bin/env python3 # # Bitwise RLE compress a Marlin mono DOGM bitmap. # Input: An existing Marlin Marlin mono DOGM bitmap .cpp or .h file. # Output: A new file with the original and compressed data. # # Usage: rle_compress_bitmap.py INPUT_FILE OUTPUT_FILE # import sys,struct import re def addCompressedData(input_file, output_file): input_lines = input_file.readlines() input_file.close() ofile = open(output_file, 'wt') datatype = "uint8_t" bytewidth = 16 raw_data = [] arrname = '' c_data_section = False ; c_skip_data = False ; c_footer = False for line in input_lines: if not line: break if not c_footer: if not c_skip_data: ofile.write(line) mat = re.match(r'.+CUSTOM_BOOTSCREEN_BMPWIDTH\s+(\d+)', line) if mat: bytewidth = (int(mat[1]) + 7) // 8 if "};" in line: c_skip_data = False c_data_section = False c_footer = True if c_data_section: cleaned = re.sub(r"\s|,|\n", "", line) mat = re.match(r'(0b|B)[01]{8}', cleaned) if mat: as_list = cleaned.split(mat[1]) as_list.pop(0) raw_data += [int(x, 2) for x in as_list] else: as_list = cleaned.split("0x") as_list.pop(0) raw_data += [int(x, 16) for x in as_list] mat = re.match(r'const (uint\d+_t|unsigned char)', line) if mat: # e.g.: const unsigned char custom_start_bmp[] PROGMEM = { datatype = mat[0] if "_rle" in line: c_skip_data = True else: c_data_section = True arrname = line.split('[')[0].split(' ')[-1] print("Found data array", arrname) #print("\nRaw Bitmap Data", raw_data) # # Bitwise RLE (run length) encoding # Convert data from raw mono bitmap to a bitwise run-length-encoded format. # - The first nybble is the starting bit state. Changing this nybble inverts the bitmap. # - The following bytes provide the runs for alternating on/off bits. # - A value of 0-14 encodes a run of 1-15. # - A value of 16 indicates a run of 16-270 calculated using the next two bytes. # def bitwise_rle_encode(data): def get_bit(data, n): return 1 if (data[n // 8] & (0x80 >> (n & 7))) else 0 def try_encode(data, isext): bitslen = len(data) * 8 bitstate = get_bit(data, 0) rledata = [ bitstate ] bigrun = 256 if isext else 272 medrun = False i = 0 runlen = -1 while i <= bitslen: if i < bitslen: b = get_bit(data, i) runlen += 1 if bitstate != b or i == bitslen: if runlen >= bigrun: isext = True if medrun: return [], isext rem = runlen & 0xFF rledata += [ 15, 15, rem // 16, rem % 16 ] elif runlen >= 16: rledata += [ 15, runlen // 16 - 1, runlen % 16 ] if runlen >= 256: medrun = True else: rledata += [ runlen - 1 ] bitstate ^= 1 runlen = 0 i += 1 #print("\nrledata", rledata) encoded = [] ri = 0 rlen = len(rledata) while ri < rlen: v = rledata[ri] << 4 if (ri < rlen - 1): v |= rledata[ri + 1] encoded += [ v ] ri += 2 #print("\nencoded", encoded) return encoded, isext # Try to encode with the original isext flag warn = "This may take a while" if len(data) > 300000 else "" print("Compressing image data...", warn) isext = False encoded, isext = try_encode(data, isext) if len(encoded) == 0: encoded, isext = try_encode(data, True) return encoded, isext def bitwise_rle_decode(isext, rledata, invert=0): expanded = [] for n in rledata: expanded += [ n >> 4, n & 0xF ] decoded = [] bitstate = 0 ; workbyte = 0 ; outindex = 0 i = 0 while i < len(expanded): c = expanded[i] i += 1 if i == 1: bitstate = c ; continue if c == 15: d = expanded[i] ; e = expanded[i + 1] if isext and d == 15: c = 256 + 16 * e + expanded[i + 2] - 1 i += 1 else: c = 16 * d + e + 15 i += 2 for _ in range(c, -1, -1): bitval = 0x80 >> (outindex & 7) if bitstate: workbyte |= bitval if bitval == 1: decoded += [ workbyte ] workbyte = 0 outindex += 1 bitstate ^= 1 print("\nDecoded RLE data:") pretty = [ '{0:08b}'.format(v) for v in decoded ] rows = [pretty[i:i+bytewidth] for i in range(0, len(pretty), bytewidth)] for row in rows: print(f"{''.join(row)}") return decoded def rle_emit(ofile, arrname, rledata, rawsize, isext): outstr = '' rows = [ rledata[i:i+16] for i in range(0, len(rledata), 16) ] for i in range(0, len(rows)): rows[i] = [ '0x{0:02X}'.format(v) for v in rows[i] ] outstr += f" {', '.join(rows[i])},\n" outstr = outstr[:-2] size = len(rledata) defname = 'COMPACT_CUSTOM_BOOTSCREEN_EXT' if isext else 'COMPACT_CUSTOM_BOOTSCREEN' ofile.write(f"\n// Saves {rawsize - size} bytes\n#define {defname}\n{datatype} {arrname}_rle[{size}] PROGMEM = {{\n{outstr}\n}};\n") # Encode the data, write it out, close the file rledata, isext = bitwise_rle_encode(raw_data) rle_emit(ofile, arrname, rledata, len(raw_data), isext) ofile.close() # Validate that code properly compressed (and decompressed) the data checkdata = bitwise_rle_decode(isext, rledata) for i in range(0, len(checkdata)): if raw_data[i] != checkdata[i]: print(f'Data mismatch at byte offset {i} (should be {raw_data[i]} but got {checkdata[i]})') break if len(sys.argv) <= 2: print('Usage: rle_compress_bitmap.py INPUT_FILE OUTPUT_FILE') exit(1) output_h = sys.argv[2] inname = sys.argv[1].replace('//', '/') try: input_h = open(inname) print("Processing", inname, "...") addCompressedData(input_h, output_h) except OSError: print("Can't find input file", inname)
2301_81045437/Marlin
buildroot/share/scripts/rle_compress_bitmap.py
Python
agpl-3.0
6,780
import argparse import sys import os import time import random import serial Import("env") import MarlinBinaryProtocol #-----------------# # Upload Callback # #-----------------# def Upload(source, target, env): #-------# # Debug # #-------# Debug = False # Set to True to enable script debug def debugPrint(data): if Debug: print(f"[Debug]: {data}") #------------------# # Marlin functions # #------------------# def _GetMarlinEnv(marlinEnv, feature): if not marlinEnv: return None return marlinEnv[feature] if feature in marlinEnv else None #----------------# # Port functions # #----------------# def _GetUploadPort(env): debugPrint('Autodetecting upload port...') env.AutodetectUploadPort(env) portName = env.subst('$UPLOAD_PORT') if not portName: raise Exception('Error detecting the upload port.') debugPrint('OK') return portName #-------------------------# # Simple serial functions # #-------------------------# def _OpenPort(): # Open serial port if port.is_open: return debugPrint('Opening upload port...') port.open() port.reset_input_buffer() debugPrint('OK') def _ClosePort(): # Open serial port if port is None: return if not port.is_open: return debugPrint('Closing upload port...') port.close() debugPrint('OK') def _Send(data): debugPrint(f'>> {data}') strdata = bytearray(data, 'utf8') + b'\n' port.write(strdata) time.sleep(0.010) def _Recv(): clean_responses = [] responses = port.readlines() for Resp in responses: # Suppress invalid chars (coming from debug info) try: clean_response = Resp.decode('utf8').rstrip().lstrip() clean_responses.append(clean_response) debugPrint(f'<< {clean_response}') except: pass return clean_responses #------------------# # SDCard functions # #------------------# def _CheckSDCard(): debugPrint('Checking SD card...') _Send('M21') Responses = _Recv() if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): raise Exception('Error accessing SD card') debugPrint('SD Card OK') return True #----------------# # File functions # #----------------# def _GetFirmwareFiles(UseLongFilenames): debugPrint('Get firmware files...') _Send(f"M20 F{'L' if UseLongFilenames else ''}") Responses = _Recv() if len(Responses) < 3 or not any('file list' in r for r in Responses): raise Exception('Error getting firmware files') debugPrint('OK') return Responses def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): Firmwares = [] for FWFile in FirmwareList: # For long filenames take the 3rd column of the firmwares list if UseLongFilenames: Space = 0 Space = FWFile.find(' ') if Space >= 0: Space = FWFile.find(' ', Space + 1) if Space >= 0: FWFile = FWFile[Space + 1:] if not '/' in FWFile and '.BIN' in FWFile.upper(): Firmwares.append(FWFile[:FWFile.upper().index('.BIN') + 4]) return Firmwares def _RemoveFirmwareFile(FirmwareFile): _Send(f'M30 /{FirmwareFile}') Responses = _Recv() Removed = len(Responses) >= 1 and any('File deleted' in r for r in Responses) if not Removed: raise Exception(f"Firmware file '{FirmwareFile}' not removed") return Removed def _RollbackUpload(FirmwareFile): if not rollback: return print(f"Rollback: trying to delete firmware '{FirmwareFile}'...") _OpenPort() # Wait for SD card release time.sleep(1) # Remount SD card _CheckSDCard() print(' OK' if _RemoveFirmwareFile(FirmwareFile) else ' Error!') _ClosePort() #---------------------# # Callback Entrypoint # #---------------------# port = None protocol = None filetransfer = None rollback = False # Get Marlin evironment vars MarlinEnv = env['MARLIN_FEATURES'] marlin_pioenv = _GetMarlinEnv(MarlinEnv, 'PIOENV') marlin_motherboard = _GetMarlinEnv(MarlinEnv, 'MOTHERBOARD') marlin_board_info_name = _GetMarlinEnv(MarlinEnv, 'BOARD_INFO_NAME') marlin_board_custom_build_flags = _GetMarlinEnv(MarlinEnv, 'BOARD_CUSTOM_BUILD_FLAGS') marlin_firmware_bin = _GetMarlinEnv(MarlinEnv, 'FIRMWARE_BIN') marlin_long_filename_host_support = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_HOST_SUPPORT') is not None marlin_longname_write = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_WRITE_SUPPORT') is not None marlin_custom_firmware_upload = _GetMarlinEnv(MarlinEnv, 'CUSTOM_FIRMWARE_UPLOAD') is not None marlin_short_build_version = _GetMarlinEnv(MarlinEnv, 'SHORT_BUILD_VERSION') marlin_string_config_h_author = _GetMarlinEnv(MarlinEnv, 'STRING_CONFIG_H_AUTHOR') # Get firmware upload params upload_firmware_source_path = os.path.join(env["PROJECT_BUILD_DIR"], env["PIOENV"], f"{env['PROGNAME']}.bin") if 'PROGNAME' in env else str(source[0]) # Source firmware filename upload_speed = env['UPLOAD_SPEED'] if 'UPLOAD_SPEED' in env else 115200 # baud rate of serial connection upload_port = _GetUploadPort(env) # Serial port to use # Set local upload params upload_firmware_target_name = os.path.basename(upload_firmware_source_path) # Target firmware filename upload_timeout = 1000 # Communication timout, lossy/slow connections need higher values upload_blocksize = 512 # Transfer block size. 512 = Autodetect upload_compression = True # Enable compression upload_error_ratio = 0 # Simulated corruption ratio upload_test = False # Benchmark the serial link without storing the file upload_reset = True # Trigger a soft reset for firmware update after the upload # Set local upload params based on board type to change script behavior # "upload_delete_old_bins": delete all *.bin files in the root of SD Card upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', 'BOARD_CREALITY_V24S1'] # "upload_random_name": generate a random 8.3 firmware filename to upload upload_random_filename = upload_delete_old_bins and not marlin_long_filename_host_support # Heatshrink module is needed (only) for compression if upload_compression: if sys.version_info[0] > 2: try: import heatshrink2 except ImportError: print("Installing 'heatshrink2' python module...") env.Execute(env.subst("$PYTHONEXE -m pip install heatshrink2")) else: try: import heatshrink except ImportError: print("Installing 'heatshrink' python module...") env.Execute(env.subst("$PYTHONEXE -m pip install heatshrink")) try: # Start upload job print(f"Uploading firmware '{os.path.basename(upload_firmware_target_name)}' to '{marlin_motherboard}' via '{upload_port}'") # Dump some debug info if Debug: print('Upload using:') print('---- Marlin -----------------------------------') print(f' PIOENV : {marlin_pioenv}') print(f' SHORT_BUILD_VERSION : {marlin_short_build_version}') print(f' STRING_CONFIG_H_AUTHOR : {marlin_string_config_h_author}') print(f' MOTHERBOARD : {marlin_motherboard}') print(f' BOARD_INFO_NAME : {marlin_board_info_name}') print(f' CUSTOM_BUILD_FLAGS : {marlin_board_custom_build_flags}') print(f' FIRMWARE_BIN : {marlin_firmware_bin}') print(f' LONG_FILENAME_HOST_SUPPORT : {marlin_long_filename_host_support}') print(f' LONG_FILENAME_WRITE_SUPPORT : {marlin_longname_write}') print(f' CUSTOM_FIRMWARE_UPLOAD : {marlin_custom_firmware_upload}') print('---- Upload parameters ------------------------') print(f' Source : {upload_firmware_source_path}') print(f' Target : {upload_firmware_target_name}') print(f' Port : {upload_port} @ {upload_speed} baudrate') print(f' Timeout : {upload_timeout}') print(f' Block size : {upload_blocksize}') print(f' Compression : {upload_compression}') print(f' Error ratio : {upload_error_ratio}') print(f' Test : {upload_test}') print(f' Reset : {upload_reset}') print('-----------------------------------------------') # Custom implementations based on board parameters # Generate a new 8.3 random filename if upload_random_filename: upload_firmware_target_name = f"fw-{''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=5))}.BIN" print(f"Board {marlin_motherboard}: Overriding firmware filename to '{upload_firmware_target_name}'") # Delete all *.bin files on the root of SD Card (if flagged) if upload_delete_old_bins: # CUSTOM_FIRMWARE_UPLOAD is needed for this feature if not marlin_custom_firmware_upload: raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") # Init & Open serial port port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) _OpenPort() # Check SD card status _CheckSDCard() # Get firmware files FirmwareFiles = _GetFirmwareFiles(marlin_long_filename_host_support) if Debug: for FirmwareFile in FirmwareFiles: print(f'Found: {FirmwareFile}') # Get all 1st level firmware files (to remove) OldFirmwareFiles = _FilterFirmwareFiles(FirmwareFiles[1:len(FirmwareFiles)-2], marlin_long_filename_host_support) # Skip header and footers of list if len(OldFirmwareFiles) == 0: print('No old firmware files to delete') else: print(f"Remove {len(OldFirmwareFiles)} old firmware file{'s' if len(OldFirmwareFiles) != 1 else ''}:") for OldFirmwareFile in OldFirmwareFiles: print(f" -Removing- '{OldFirmwareFile}'...") print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') # Close serial _ClosePort() # Cleanup completed debugPrint('Cleanup completed') # WARNING! The serial port must be closed here because the serial transfer that follow needs it! # Upload firmware file debugPrint(f"Copy '{upload_firmware_source_path}' --> '{upload_firmware_target_name}'") protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) protocol.connect() # Mark the rollback (delete broken transfer) from this point on rollback = True filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) transferOK = filetransfer.copy(upload_firmware_source_path, upload_firmware_target_name, upload_compression, upload_test) protocol.disconnect() # Notify upload completed protocol.send_ascii('M117 Firmware uploaded' if transferOK else 'M117 Firmware upload failed') # Remount SD card print('Wait for SD card release...') time.sleep(1) print('Remount SD card') protocol.send_ascii('M21') # Transfer failed? if not transferOK: protocol.shutdown() _RollbackUpload(upload_firmware_target_name) else: # Trigger firmware update if upload_reset: print('Trigger firmware update...') protocol.send_ascii('M997', True) protocol.shutdown() print('Firmware update completed' if transferOK else 'Firmware update failed') return 0 if transferOK else -1 except KeyboardInterrupt: print('Aborted by user') if filetransfer: filetransfer.abort() if protocol: protocol.disconnect() protocol.shutdown() _RollbackUpload(upload_firmware_target_name) _ClosePort() raise except serial.SerialException as se: # This exception is raised only for send_ascii data (not for binary transfer) print(f'Serial excepion: {se}, transfer aborted') if protocol: protocol.disconnect() protocol.shutdown() _RollbackUpload(upload_firmware_target_name) _ClosePort() raise Exception(se) except MarlinBinaryProtocol.FatalError: print('Too many retries, transfer aborted') if protocol: protocol.disconnect() protocol.shutdown() _RollbackUpload(upload_firmware_target_name) _ClosePort() raise except Exception as ex: print(f"\nException: {ex}, transfer aborted") if protocol: protocol.disconnect() protocol.shutdown() _RollbackUpload(upload_firmware_target_name) _ClosePort() print('Firmware not updated') raise # Attach custom upload callback env.Replace(UPLOADCMD=Upload)
2301_81045437/Marlin
buildroot/share/scripts/upload.py
Python
agpl-3.0
14,622
; SYNTAX TEST "G-code.sublime-syntax" ; This is a G-code comment ;^comment G1 X100 Y100 ; Move to 100,100 ;^entity.command.gcode ; ^keyword.param.gcode ; ^constant.numeric.param.gcode ; ^comment T0 (This is a comment) S12 ;^entity.command.gcode ; ^punctuation.paren.comment.open ; ^paren.comment.gcode ; ^punctuation.paren.comment.close ; ^keyword.param.gcode ; ^constant.numeric.param.gcode M20 P'/path/to/macro/macro.g' R12 ;<-entity.command.gcode ;^constant.numeric.command.gcode ; ^keyword.param.gcode ; ^punctuation.quote.single.open.gcode ; ^string.quoted.single.gcode ; ^punctuation.quote.single.close.gcode ; ^keyword.param.gcode ; ^constant.numeric.param.gcode M117 This is a message ; and comment ;<-entity.command.gcode ;^constant.numeric.command.gcode ; ^string.unquoted.gcode ; ^punctuation.comment.eol.start ; ^comment.gcode M118 This is a message ; and comment ;<-entity.command.gcode ;^constant.numeric.command.gcode ; ^string.unquoted.gcode ; ^punctuation.comment.eol.start ; ^comment.gcode M98 P'/path/to/macro/macro.g' R12 ;<-entity.command.gcode ;^constant.numeric.command.gcode ; ^keyword.param.gcode ; ^punctuation.quote.single.open.gcode ; ^string.quoted.single.gcode ; ^punctuation.quote.single.close.gcode M98 P"/path/to/macro/macro.g" R12 ;<-entity.command.gcode ;^constant.numeric.command.gcode ; ^keyword.param.gcode ; ^punctuation.quote.double.open.gcode ; ^string.quoted.double.gcode ; ^punctuation.quote.double.close.gcode M32 S100 P0 !/path/file.gco# ;<-entity.command.gcode ;^constant.numeric.command.gcode ; ^keyword.param.gcode ; ^constant.numeric.param.gcode ; ^punctuation.string.path.open.gcode ; ^string.unquoted.path.gcode ; ^punctuation.string.path.close.gcode G28 ; Home All ;<-entity.command.gcode ;^constant.numeric.command.gcode ; ^punctuation.comment.eol.start ; ^comment.gcode N123 G1 X5 Y0 *64 ; EOL Comment ;<-entity.nword.gcode ;^constant.numeric.line-number.gcode ; ^entity.command.gcode ; ^constant.numeric.command.gcode ; ^keyword.param.gcode ; ^constant.numeric.param.gcode ; ^punctuation.marker.checksum.gcode ; ^constant.numeric.checksum.gcode N234 G1 X-5 Y+2 *64 error ;<-entity.nword.gcode ;^constant.numeric.line-number.gcode ; ^entity.command.gcode ; ^constant.numeric.command.gcode ; ^keyword.param.gcode ; ^constant.numeric.param.gcode ; ^punctuation.marker.checksum.gcode ; ^constant.numeric.checksum.gcode ; ^invalid.error.syntax.gcode N234 M107 *64 ; ^-invalid.error.syntax.gcode M92 E304.5:304.5:420:420:420:420 ; EOL Comment ;<-entity.command.gcode ;^constant.numeric.command.gcode ; ^keyword.param.gcode ; ^constant.numeric.param.gcode ; ^constant.numeric.param.gcode ; ^punctuation.comment.eol.start ; ^comment.gcode
2301_81045437/Marlin
buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode
G-code
agpl-3.0
3,320
#!/usr/bin/env python ####################################### # # Marlin 3D Printer Firmware # Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] # # Based on Sprinter and grbl. # Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm # # This program 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. # # This program 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. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # ####################################### ####################################### # # Revision: 2.1.0 # # Description: script to automate PlatformIO builds # CLI: python auto_build.py build_option # build_option (required) # build executes -> platformio run -e target_env # clean executes -> platformio run --target clean -e target_env # upload executes -> platformio run --target upload -e target_env # traceback executes -> platformio run --target upload -e target_env # program executes -> platformio run --target program -e target_env # test executes -> platformio test upload -e target_env # remote executes -> platformio remote run --target upload -e target_env # debug executes -> platformio debug -e target_env # # 'traceback' just uses the debug variant of the target environment if one exists # ####################################### ####################################### # # General program flow # # 1. Scans Configuration.h for the motherboard name and Marlin version. # 2. Scans pins.h for the motherboard. # returns the CPU(s) and platformio environment(s) used by the motherboard # 3. If further info is needed then a popup gets it from the user. # 4. The OUTPUT_WINDOW class creates a window to display the output of the PlatformIO program. # 5. A thread is created by the OUTPUT_WINDOW class in order to execute the RUN_PIO function. # 6. The RUN_PIO function uses a subprocess to run the CLI version of PlatformIO. # 7. The "iter(pio_subprocess.stdout.readline, '')" function is used to stream the output of # PlatformIO back to the RUN_PIO function. # 8. Each line returned from PlatformIO is formatted to match the color coding seen in the # PlatformIO GUI. # 9. If there is a color change within a line then the line is broken at each color change # and sent separately. # 10. Each formatted segment (could be a full line or a split line) is put into the queue # IO_queue as it arrives from the platformio subprocess. # 11. The OUTPUT_WINDOW class periodically samples IO_queue. If data is available then it # is written to the window. # 12. The window stays open until the user closes it. # 13. The OUTPUT_WINDOW class continues to execute as long as the window is open. This allows # copying, saving, scrolling of the window. A right click popup is available. # ####################################### from __future__ import print_function from __future__ import division import sys,os,re pwd = os.getcwd() # make sure we're executing from the correct directory level pwd = pwd.replace('\\', '/') if 0 <= pwd.find('buildroot/share/vscode'): pwd = pwd[:pwd.find('buildroot/share/vscode')] os.chdir(pwd) print('pwd: ', pwd) num_args = len(sys.argv) if num_args > 1: build_type = str(sys.argv[1]) else: print('Please specify build type') exit() print('build_type: ', build_type) print('\nWorking\n') python_ver = sys.version_info[0] # major version - 2 or 3 print("python version " + str(sys.version_info[0]) + "." + str(sys.version_info[1]) + "." + str(sys.version_info[2])) import platform current_OS = platform.system() #globals target_env = '' board_name = '' from datetime import datetime, date, time ######### # Python 2 error messages: # Can't find a usable init.tcl in the following directories ... # error "invalid command name "tcl_findLibrary"" # # Fix for the above errors on my Win10 system: # search all init.tcl files for the line "package require -exact Tcl" that has the highest 8.5.x number # copy it into the first directory listed in the error messages # set the environmental variables TCLLIBPATH and TCL_LIBRARY to the directory where you found the init.tcl file # reboot ######### ########################################################################################## # # popup to get input from user # ########################################################################################## def get_answer(board_name, question_txt, options, default_value=1): if python_ver == 2: import Tkinter as tk else: import tkinter as tk def CPU_exit_3(): # forward declare functions CPU_exit_3_() def got_answer(): got_answer_() def kill_session(): kill_session_() root_get_answer = tk.Tk() root_get_answer.title('') #root_get_answer.withdraw() #root_get_answer.deiconify() root_get_answer.attributes("-topmost", True) def disable_event(): pass root_get_answer.protocol("WM_DELETE_WINDOW", disable_event) root_get_answer.resizable(False, False) root_get_answer.radio_state = default_value # declare variables used by TK and enable global get_answer_val get_answer_val = default_value # return get_answer_val, set default to match radio_state default radio_state = tk.IntVar() radio_state.set(get_answer_val) l1 = tk.Label(text=board_name, fg="light green", bg="dark green", font="default 14 bold").grid(row=0, columnspan=2, sticky='EW', ipadx=2, ipady=2) l2 = tk.Label(text=question_txt).grid(row=1, pady=4, columnspan=2, sticky='EW') buttons = [] for index, val in enumerate(options): buttons.append( tk.Radiobutton( text=val, fg="black", bg="lightgray", relief=tk.SUNKEN, selectcolor="green", variable=radio_state, value=index + 1, indicatoron=0, command=CPU_exit_3 ).grid(row=index + 2, pady=1, ipady=2, ipadx=10, columnspan=2)) b6 = tk.Button(text="Cancel", fg="red", command=kill_session).grid(row=(2 + len(options)), column=0, padx=4, pady=4, ipadx=2, ipady=2) b7 = tk.Button(text="Continue", fg="green", command=got_answer).grid(row=(2 + len(options)), column=1, padx=4, pady=4, ipadx=2, ipady=2) def got_answer_(): root_get_answer.destroy() def CPU_exit_3_(): global get_answer_val get_answer_val = radio_state.get() def kill_session_(): raise SystemExit(0) # kill everything root_get_answer.mainloop() # end - get answer # # move custom board definitions from project folder to PlatformIO # def resolve_path(path): import os # turn the selection into a partial path if 0 <= path.find('"'): path = path[path.find('"'):] if 0 <= path.find(', line '): path = path.replace(', line ', ':') path = path.replace('"', '') # get line and column numbers line_num = 1 column_num = 1 line_start = path.find(':', 2) # use 2 here so don't eat Windows full path column_start = path.find(':', line_start + 1) if column_start == -1: column_start = len(path) column_end = path.find(':', column_start + 1) if column_end == -1: column_end = len(path) if 0 <= line_start: line_num = path[line_start + 1:column_start] if line_num == '': line_num = 1 if column_start != column_end: column_num = path[column_start + 1:column_end] if column_num == '': column_num = 0 index_end = path.find(',') if 0 <= index_end: path = path[:index_end] # delete comma and anything after index_end = path.find(':', 2) if 0 <= index_end: path = path[:path.find(':', 2)] # delete the line number and anything after path = path.replace('\\', '/') if 1 == path.find(':') and current_OS == 'Windows': return path, line_num, column_num # found a full path - no need for further processing elif 0 == path.find('/') and (current_OS == 'Linux' or current_OS == 'Darwin'): return path, line_num, column_num # found a full path - no need for further processing else: # resolve as many '../' as we can while 0 <= path.find('../'): end = path.find('../') - 1 start = path.find('/') while 0 <= path.find('/', start) < end: start = path.find('/', start) + 1 path = path[0:start] + path[end + 4:] # this is an alternative to the above - it just deletes the '../' section # start_temp = path.find('../') # while 0 <= path.find('../',start_temp): # start = path.find('../',start_temp) # start_temp = start + 1 # if 0 <= start: # path = path[start + 2 : ] start = path.find('/') if start != 0: # make sure path starts with '/' while 0 == path.find(' '): # eat any spaces at the beginning path = path[1:] path = '/' + path if current_OS == 'Windows': search_path = path.replace('/', '\\') # os.walk uses '\' in Windows else: search_path = path start_path = os.path.abspath('') # search project directory for the selection found = False full_path = '' for root, directories, filenames in os.walk(start_path): for filename in filenames: if 0 <= root.find('.git'): # don't bother looking in this directory break full_path = os.path.join(root, filename) if 0 <= full_path.find(search_path): found = True break if found: break return full_path, line_num, column_num # end - resolve_path # # Open the file in the preferred editor at the line & column number # If the preferred editor isn't already running then it tries the next. # If none are open then the system default is used. # # Editor order: # 1. Notepad++ (Windows only) # 2. Sublime Text # 3. Atom # 4. System default (opens at line 1, column 1 only) # def open_file(path): import subprocess file_path, line_num, column_num = resolve_path(path) if file_path == '': return if current_OS == 'Windows': editor_note = subprocess.check_output('wmic process where "name=' + "'notepad++.exe'" + '" get ExecutablePath') editor_sublime = subprocess.check_output('wmic process where "name=' + "'sublime_text.exe'" + '" get ExecutablePath') editor_atom = subprocess.check_output('wmic process where "name=' + "'atom.exe'" + '" get ExecutablePath') if 0 <= editor_note.find('notepad++.exe'): start = editor_note.find('\n') + 1 end = editor_note.find('\n', start + 5) - 4 editor_note = editor_note[start:end] command = file_path, ' -n' + str(line_num), ' -c' + str(column_num) subprocess.Popen([editor_note, command]) elif 0 <= editor_sublime.find('sublime_text.exe'): start = editor_sublime.find('\n') + 1 end = editor_sublime.find('\n', start + 5) - 4 editor_sublime = editor_sublime[start:end] command = file_path + ':' + line_num + ':' + column_num subprocess.Popen([editor_sublime, command]) elif 0 <= editor_atom.find('atom.exe'): start = editor_atom.find('\n') + 1 end = editor_atom.find('\n', start + 5) - 4 editor_atom = editor_atom[start:end] command = file_path + ':' + str(line_num) + ':' + str(column_num) subprocess.Popen([editor_atom, command]) else: os.startfile(resolve_path(path)) # open file with default app elif current_OS == 'Linux': command = file_path + ':' + str(line_num) + ':' + str(column_num) index_end = command.find(',') if 0 <= index_end: command = command[:index_end] # sometimes a comma magically appears, don't want it running_apps = subprocess.Popen('ps ax -o cmd', stdout=subprocess.PIPE, shell=True) (output, err) = running_apps.communicate() temp = output.split('\n') def find_editor_linux(name, search_obj): for line in search_obj: if 0 <= line.find(name): path = line return True, path return False, '' (success_sublime, editor_path_sublime) = find_editor_linux('sublime_text', temp) (success_atom, editor_path_atom) = find_editor_linux('atom', temp) if success_sublime: subprocess.Popen([editor_path_sublime, command]) elif success_atom: subprocess.Popen([editor_path_atom, command]) else: os.system('xdg-open ' + file_path) elif current_OS == 'Darwin': # MAC command = file_path + ':' + str(line_num) + ':' + str(column_num) index_end = command.find(',') if 0 <= index_end: command = command[:index_end] # sometimes a comma magically appears, don't want it running_apps = subprocess.Popen('ps axwww -o command', stdout=subprocess.PIPE, shell=True) (output, err) = running_apps.communicate() temp = output.split('\n') def find_editor_mac(name, search_obj): for line in search_obj: if 0 <= line.find(name): path = line if 0 <= path.find('-psn'): path = path[:path.find('-psn') - 1] return True, path return False, '' (success_sublime, editor_path_sublime) = find_editor_mac('Sublime', temp) (success_atom, editor_path_atom) = find_editor_mac('Atom', temp) if success_sublime: subprocess.Popen([editor_path_sublime, command]) elif success_atom: subprocess.Popen([editor_path_atom, command]) else: os.system('open ' + file_path) # end - open_file # Get the last build environment def get_build_last(): env_last = '' DIR_PWD = os.listdir('.') if '.pio' in DIR_PWD: date_last = 0.0 DIR__pioenvs = os.listdir('.pio') for name in DIR__pioenvs: if 0 <= name.find('.') or 0 <= name.find('-'): # skip files in listing continue DIR_temp = os.listdir('.pio/build/' + name) for names_temp in DIR_temp: if 0 == names_temp.find('firmware.'): date_temp = os.path.getmtime('.pio/build/' + name + '/' + names_temp) if date_temp > date_last: date_last = date_temp env_last = name return env_last # Get the board being built from the Configuration.h file # return: board name, major version of Marlin being used (1 or 2) def get_board_name(): board_name = '' # get board name with open('Marlin/Configuration.h', 'r') as myfile: Configuration_h = myfile.read() Configuration_h = Configuration_h.split('\n') Marlin_ver = 0 # set version to invalid number for lines in Configuration_h: if 0 == lines.find('#define CONFIGURATION_H_VERSION 01'): Marlin_ver = 1 if 0 == lines.find('#define CONFIGURATION_H_VERSION 02'): Marlin_ver = 2 board = lines.find(' BOARD_') + 1 motherboard = lines.find(' MOTHERBOARD ') + 1 define = lines.find('#define ') comment = lines.find('//') if (comment == -1 or comment > board) and \ board > motherboard and \ motherboard > define and \ define >= 0 : spaces = lines.find(' ', board) # find the end of the board substring if spaces == -1: board_name = lines[board:] else: board_name = lines[board:spaces] break return board_name, Marlin_ver # extract first environment name found after the start position # return: environment name and position to start the next search from def get_env_from_line(line, start_position): env = '' next_position = -1 env_position = line.find('env:', start_position) if 0 < env_position: next_position = line.find(' ', env_position + 4) if 0 < next_position: env = line[env_position + 4:next_position] else: env = line[env_position + 4:] # at the end of the line return env, next_position def invalid_board(): print('ERROR - invalid board') print(board_name) raise SystemExit(0) # quit if unable to find board # scan pins.h for board name and return the environment(s) found def get_starting_env(board_name_full, version): # get environment starting point if version == 1: path = 'Marlin/pins.h' if version == 2: path = 'Marlin/src/pins/pins.h' with open(path, 'r') as myfile: pins_h = myfile.read() board_name = board_name_full[6:] # only use the part after "BOARD_" since we're searching the pins.h file pins_h = pins_h.split('\n') list_start_found = False possible_envs = None for i, line in enumerate(pins_h): if 0 < line.find("Unknown MOTHERBOARD value set in Configuration.h"): invalid_board() if list_start_found == False and 0 < line.find('1280'): list_start_found = True elif list_start_found == False: # skip lines until find start of CPU list continue # Use a regex to find the board. Make sure it is surrounded by separators so the full boardname # will be matched, even if multiple exist in a single MB macro. This avoids problems with boards # such as MALYAN_M200 and MALYAN_M200_V2 where one board is a substring of the other. if re.search(r'MB.*[\(, ]' + board_name + r'[, \)]', line): # need to look at the next line for environment info possible_envs = re.findall(r'env:([^ ]+)', pins_h[i + 1]) break return possible_envs # get environment to be used for the build # return: environment def get_env(board_name, ver_Marlin): def no_environment(): print('ERROR - no environment for this board') print(board_name) raise SystemExit(0) # no environment so quit possible_envs = get_starting_env(board_name, ver_Marlin) if not possible_envs: no_environment() # Proceed to ask questions based on the available environments to filter down to a smaller list. # If more then one remains after this filtering the user will be prompted to choose between # all remaining options. # Filter selection based on CPU choice CPU_questions = [ {'options':['1280', '2560'], 'text':'1280 or 2560 CPU?', 'default':2}, {'options':['644', '1284'], 'text':'644 or 1284 CPU?', 'default':2}, {'options':['STM32F103RC', 'STM32F103RE'], 'text':'MCU Type?', 'default':1}] for question in CPU_questions: if any(question['options'][0] in env for env in possible_envs) and any(question['options'][1] in env for env in possible_envs): get_answer(board_name, question['text'], [question['options'][0], question['options'][1]], question['default']) possible_envs = [env for env in possible_envs if question['options'][get_answer_val - 1] in env] # Choose which STM32 framework to use, if both are available if [env for env in possible_envs if '_maple' in env] and [env for env in possible_envs if '_maple' not in env]: get_answer(board_name, 'Which STM32 Framework should be used?', ['ST STM32 (Preferred)', 'Maple (Deprecated)']) if 1 == get_answer_val: possible_envs = [env for env in possible_envs if '_maple' not in env] else: possible_envs = [env for env in possible_envs if '_maple' in env] # Both USB and non-USB STM32 options exist, filter based on these if any('STM32F103R' in env for env in possible_envs) and any('_USB' in env for env in possible_envs) and any('_USB' not in env for env in possible_envs): get_answer(board_name, 'USB Support?', ['USB', 'No USB']) if 1 == get_answer_val: possible_envs = [env for env in possible_envs if '_USB' in env] else: possible_envs = [env for env in possible_envs if '_USB' not in env] if not possible_envs: no_environment() if len(possible_envs) == 1: return possible_envs[0] # only one environment so finished target_env = None # A few environments require special behavior if 'LPC1768' in possible_envs: if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'LPC1768_debug_and_upload'): target_env = 'LPC1768_debug_and_upload' else: target_env = 'LPC1768' elif 'DUE' in possible_envs: target_env = 'DUE' if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'DUE_debug'): target_env = 'DUE_debug' elif 'DUE_USB' in possible_envs: get_answer(board_name, 'DUE Download Port?', ['(Native) USB port', 'Programming port']) if 1 == get_answer_val: target_env = 'DUE_USB' else: target_env = 'DUE' else: options = possible_envs # Perform some substitutions for environment names which follow a consistent # naming pattern and are very commonly used. This is fragile code, and replacements # should only be made here for stable environments unlikely to change often. for i, option in enumerate(options): if 'melzi' in option: options[i] = 'Melzi' elif 'sanguino1284p' in option: options[i] = 'sanguino1284p' if 'optiboot' in option: options[i] = options[i] + ' (Optiboot Bootloader)' if 'optimized' in option: options[i] = options[i] + ' (Optimized for Size)' get_answer(board_name, 'Which environment?', options) target_env = possible_envs[get_answer_val - 1] if build_type == 'traceback' and target_env != 'LPC1768_debug_and_upload' and target_env != 'DUE_debug' and Marlin_ver == 2: print("ERROR - this board isn't setup for traceback") print('board_name: ', board_name) print('target_env: ', target_env) raise SystemExit(0) return target_env # end - get_env # puts screen text into queue so that the parent thread can fetch the data from this thread if python_ver == 2: import Queue as queue else: import queue as queue IO_queue = queue.Queue() #PIO_queue = queue.Queue() not used! def write_to_screen_queue(text, format_tag='normal'): double_in = [text, format_tag] IO_queue.put(double_in, block=False) # # send one line to the terminal screen with syntax highlighting # # input: unformatted text, flags from previous run # return: formatted text ready to go to the terminal, flags from this run # # This routine remembers the status from call to call because previous # lines can affect how the current line is highlighted # # 'static' variables - init here and then keep updating them from within print_line warning = False warning_FROM = False error = False standard = True prev_line_COM = False next_line_warning = False warning_continue = False line_counter = 0 def line_print(line_input): global warning global warning_FROM global error global standard global prev_line_COM global next_line_warning global warning_continue global line_counter # all '0' elements must precede all '1' elements or they'll be skipped platformio_highlights = [ ['Environment', 0, 'highlight_blue'], ['[SKIP]', 1, 'warning'], ['[IGNORED]', 1, 'warning'], ['[ERROR]', 1, 'error'], ['[FAILED]', 1, 'error'], ['[SUCCESS]', 1, 'highlight_green'] ] def write_to_screen_with_replace(text, highlights): # search for highlights & split line accordingly did_something = False for highlight in highlights: found = text.find(highlight[0]) if did_something == True: break if found >= 0: did_something = True if 0 == highlight[1]: found_1 = text.find(' ') found_tab = text.find('\t') if not (0 <= found_1 <= found_tab): found_1 = found_tab write_to_screen_queue(text[:found_1 + 1]) for highlight_2 in highlights: if highlight[0] == highlight_2[0]: continue found = text.find(highlight_2[0]) if found >= 0: found_space = text.find(' ', found_1 + 1) found_tab = text.find('\t', found_1 + 1) if not (0 <= found_space <= found_tab): found_space = found_tab found_right = text.find(']', found + 1) write_to_screen_queue(text[found_1 + 1:found_space + 1], highlight[2]) write_to_screen_queue(text[found_space + 1:found + 1]) write_to_screen_queue(text[found + 1:found_right], highlight_2[2]) write_to_screen_queue(text[found_right:] + '\n') break break if 1 == highlight[1]: found_right = text.find(']', found + 1) write_to_screen_queue(text[:found + 1]) write_to_screen_queue(text[found + 1:found_right], highlight[2]) write_to_screen_queue(text[found_right:] + '\n' + '\n') break if did_something == False: r_loc = text.find('\r') + 1 if 0 < r_loc < len(text): # need to split this line text = text.split('\r') for line in text: if line != '': write_to_screen_queue(line + '\n') else: write_to_screen_queue(text + '\n') # end - write_to_screen_with_replace # scan the line line_counter = line_counter + 1 max_search = len(line_input) if max_search > 3: max_search = 3 beginning = line_input[:max_search] # set flags if 0 < line_input.find(': warning: '): # start of warning block warning = True warning_FROM = False error = False standard = False prev_line_COM = False prev_line_COM = False warning_continue = True if 0 < line_input.find('Thank you') or 0 < line_input.find('SUMMARY'): warning = False #standard line found warning_FROM = False error = False standard = True prev_line_COM = False warning_continue = False elif beginning == 'War' or \ beginning == '#er' or \ beginning == 'In ' or \ (beginning != 'Com' and prev_line_COM == True and not(beginning == 'Arc' or beginning == 'Lin' or beginning == 'Ind') or \ next_line_warning == True): warning = True #warning found warning_FROM = False error = False standard = False prev_line_COM = False elif beginning == 'Com' or \ beginning == 'Ver' or \ beginning == ' [E' or \ beginning == 'Rem' or \ beginning == 'Bui' or \ beginning == 'Ind' or \ beginning == 'PLA': warning = False #standard line found warning_FROM = False error = False standard = True prev_line_COM = False warning_continue = False elif beginning == '***': warning = False # error found warning_FROM = False error = True standard = False prev_line_COM = False elif 0 < line_input.find(': error:') or \ 0 < line_input.find(': fatal error:'): # start of warning /error block warning = False # error found warning_FROM = False error = True standard = False prev_line_COM = False warning_continue = True elif beginning == 'fro' and warning == True or \ beginning == '.pi' : # start of warning /error block warning_FROM = True prev_line_COM = False warning_continue = True elif warning_continue == True: warning = True warning_FROM = False # keep the warning status going until find a standard line or an error error = False standard = False prev_line_COM = False warning_continue = True else: warning = False # unknown so assume standard line warning_FROM = False error = False standard = True prev_line_COM = False warning_continue = False if beginning == 'Com': prev_line_COM = True # print based on flags if standard == True: write_to_screen_with_replace(line_input, platformio_highlights) #print white on black with substitutions if warning == True: write_to_screen_queue(line_input + '\n', 'warning') if error == True: write_to_screen_queue(line_input + '\n', 'error') # end - line_print ########################################################################## # # # run Platformio # # # ########################################################################## # build platformio run -e target_env # clean platformio run --target clean -e target_env # upload platformio run --target upload -e target_env # traceback platformio run --target upload -e target_env # program platformio run --target program -e target_env # test platformio test upload -e target_env # remote platformio remote run --target upload -e target_env # debug platformio debug -e target_env def sys_PIO(): ########################################################################## # # # run Platformio inside the same shell as this Python script # # # ########################################################################## global build_type global target_env import os print('build_type: ', build_type) print('starting platformio') if build_type == 'build': # pio_result = os.system("echo -en '\033c'") pio_result = os.system('platformio run -e ' + target_env) elif build_type == 'clean': pio_result = os.system('platformio run --target clean -e ' + target_env) elif build_type == 'upload': pio_result = os.system('platformio run --target upload -e ' + target_env) elif build_type == 'traceback': pio_result = os.system('platformio run --target upload -e ' + target_env) elif build_type == 'program': pio_result = os.system('platformio run --target program -e ' + target_env) elif build_type == 'test': pio_result = os.system('platformio test upload -e ' + target_env) elif build_type == 'remote': pio_result = os.system('platformio remote run --target program -e ' + target_env) elif build_type == 'debug': pio_result = os.system('platformio debug -e ' + target_env) else: print('ERROR - unknown build type: ', build_type) raise SystemExit(0) # kill everything # stream output from subprocess and split it into lines #for line in iter(pio_subprocess.stdout.readline, ''): # line_print(line.replace('\n', '')) # append info used to run PlatformIO # write_to_screen_queue('\nBoard name: ' + board_name + '\n') # put build info at the bottom of the screen # write_to_screen_queue('Build type: ' + build_type + '\n') # write_to_screen_queue('Environment used: ' + target_env + '\n') # write_to_screen_queue(str(datetime.now()) + '\n') # end - sys_PIO def run_PIO(dummy): global build_type global target_env global board_name print('build_type: ', build_type) import subprocess import sys print('starting platformio') if build_type == 'build': # platformio run -e target_env # combine stdout & stderr so all compile messages are included pio_subprocess = subprocess.Popen( ['platformio', 'run', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) elif build_type == 'clean': # platformio run --target clean -e target_env # combine stdout & stderr so all compile messages are included pio_subprocess = subprocess.Popen( ['platformio', 'run', '--target', 'clean', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) elif build_type == 'upload': # platformio run --target upload -e target_env # combine stdout & stderr so all compile messages are included pio_subprocess = subprocess.Popen( ['platformio', 'run', '--target', 'upload', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) elif build_type == 'traceback': # platformio run --target upload -e target_env - select the debug environment if there is one # combine stdout & stderr so all compile messages are included pio_subprocess = subprocess.Popen( ['platformio', 'run', '--target', 'upload', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) elif build_type == 'program': # platformio run --target program -e target_env # combine stdout & stderr so all compile messages are included pio_subprocess = subprocess.Popen( ['platformio', 'run', '--target', 'program', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) elif build_type == 'test': #platformio test upload -e target_env # combine stdout & stderr so all compile messages are included pio_subprocess = subprocess.Popen( ['platformio', 'test', 'upload', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) elif build_type == 'remote': # platformio remote run --target upload -e target_env # combine stdout & stderr so all compile messages are included pio_subprocess = subprocess.Popen( ['platformio', 'remote', 'run', '--target', 'program', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) elif build_type == 'debug': # platformio debug -e target_env # combine stdout & stderr so all compile messages are included pio_subprocess = subprocess.Popen( ['platformio', 'debug', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) else: print('ERROR - unknown build type: ', build_type) raise SystemExit(0) # kill everything # stream output from subprocess and split it into lines if python_ver == 2: for line in iter(pio_subprocess.stdout.readline, ''): line_print(line.replace('\n', '')) else: for line in iter(pio_subprocess.stdout.readline, b''): line = line.decode('utf-8') line_print(line.replace('\n', '')) # append info used to run PlatformIO write_to_screen_queue('\nBoard name: ' + board_name + '\n') # put build info at the bottom of the screen write_to_screen_queue('Build type: ' + build_type + '\n') write_to_screen_queue('Environment used: ' + target_env + '\n') write_to_screen_queue(str(datetime.now()) + '\n') # end - run_PIO ######################################################################## import time import threading if python_ver == 2: import Tkinter as tk import Queue as queue import ttk from Tkinter import Tk, Frame, Text, Scrollbar, Menu #from tkMessageBox import askokcancel this is not used: removed import tkFileDialog as fileDialog else: import tkinter as tk import queue as queue from tkinter import ttk, Tk, Frame, Text, Menu import subprocess import sys que = queue.Queue() #IO_queue = queue.Queue() class output_window(Text): # based on Super Text global continue_updates continue_updates = True global search_position search_position = '' # start with invalid search position global error_found error_found = False # are there any errors? def __init__(self): self.root = tk.Tk() self.root.attributes("-topmost", True) self.frame = tk.Frame(self.root) self.frame.pack(fill='both', expand=True) # text widget #self.text = tk.Text(self.frame, borderwidth=3, relief="sunken") Text.__init__(self, self.frame, borderwidth=3, relief="sunken") self.config(tabs=(400, )) # configure Text widget tab stops self.config(background='black', foreground='white', font=("consolas", 12), wrap='word', undo='True') #self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'none', undo = 'True') self.config(height=24, width=100) self.config(insertbackground='pale green') # keyboard insertion point self.pack(side='left', fill='both', expand=True) self.tag_config('normal', foreground='white') self.tag_config('warning', foreground='yellow') self.tag_config('error', foreground='red') self.tag_config('highlight_green', foreground='green') self.tag_config('highlight_blue', foreground='cyan') self.tag_config('error_highlight_inactive', background='dim gray') self.tag_config('error_highlight_active', background='light grey') self.bind_class("Text", "<Control-a>", self.select_all) # required in windows, works in others self.bind_all("<Control-Shift-E>", self.scroll_errors) self.bind_class("<Control-Shift-R>", self.rebuild) # scrollbar scrb = tk.Scrollbar(self.frame, orient='vertical', command=self.yview) self.config(yscrollcommand=scrb.set) scrb.pack(side='right', fill='y') #self.scrb_Y = tk.Scrollbar(self.frame, orient='vertical', command=self.yview) #self.scrb_Y.config(yscrollcommand=self.scrb_Y.set) #self.scrb_Y.pack(side='right', fill='y') #self.scrb_X = tk.Scrollbar(self.frame, orient='horizontal', command=self.xview) #self.scrb_X.config(xscrollcommand=self.scrb_X.set) #self.scrb_X.pack(side='bottom', fill='x') #scrb_X = tk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.xview) # tk.HORIZONTAL now have a horizsontal scroll bar BUT... shrinks it to a postage stamp and hides far right behind the vertical scroll bar #self.config(xscrollcommand=scrb_X.set) #scrb_X.pack(side='bottom', fill='x') #scrb= tk.Scrollbar(self, orient='vertical', command=self.yview) #self.config(yscrollcommand=scrb.set) #scrb.pack(side='right', fill='y') #self.config(height = 240, width = 1000) # didn't get the size baCK TO NORMAL #self.pack(side='left', fill='both', expand=True) # didn't get the size baCK TO NORMAL # pop-up menu self.popup = tk.Menu(self, tearoff=0) self.popup.add_command(label='Copy', command=self._copy) self.popup.add_command(label='Paste', command=self._paste) self.popup.add_separator() self.popup.add_command(label='Cut', command=self._cut) self.popup.add_separator() self.popup.add_command(label='Select All', command=self._select_all) self.popup.add_command(label='Clear All', command=self._clear_all) self.popup.add_separator() self.popup.add_command(label='Save As', command=self._file_save_as) self.popup.add_separator() #self.popup.add_command(label='Repeat Build(CTL-shift-r)', command=self._rebuild) self.popup.add_command(label='Repeat Build', command=self._rebuild) self.popup.add_separator() self.popup.add_command(label='Scroll Errors (CTL-shift-e)', command=self._scroll_errors) self.popup.add_separator() self.popup.add_command(label='Open File at Cursor', command=self._open_selected_file) if current_OS == 'Darwin': # MAC self.bind('<Button-2>', self._show_popup) # macOS only else: self.bind('<Button-3>', self._show_popup) # Windows & Linux # threading & subprocess section def start_thread(self, ): global continue_updates # create then start a secondary thread to run an arbitrary function # must have at least one argument self.secondary_thread = threading.Thread(target=lambda q, arg1: q.put(run_PIO(arg1)), args=(que, '')) self.secondary_thread.start() continue_updates = True # check the Queue in 50ms self.root.after(50, self.check_thread) self.root.after(50, self.update) def check_thread(self): # wait for user to kill the window global continue_updates if continue_updates == True: self.root.after(10, self.check_thread) def update(self): global continue_updates if continue_updates == True: self.root.after(10, self.update) #method is called every 50ms temp_text = ['0', '0'] if IO_queue.empty(): if not (self.secondary_thread.is_alive()): continue_updates = False # queue is exhausted and thread is dead so no need for further updates else: try: temp_text = IO_queue.get(block=False) except queue.Empty: continue_updates = False # queue is exhausted so no need for further updates else: self.insert('end', temp_text[0], temp_text[1]) self.see("end") # make the last line visible (scroll text off the top) # text editing section def _scroll_errors(self): global search_position global error_found if search_position == '': # first time so highlight all errors countVar = tk.IntVar() search_position = '1.0' search_count = 0 while search_position != '' and search_count < 100: search_position = self.search("error", search_position, stopindex="end", count=countVar, nocase=1) search_count = search_count + 1 if search_position != '': error_found = True end_pos = '{}+{}c'.format(search_position, 5) self.tag_add("error_highlight_inactive", search_position, end_pos) search_position = '{}+{}c'.format(search_position, 1) # point to the next character for new search else: break if error_found: if search_position == '': search_position = self.search("error", '1.0', stopindex="end", nocase=1) # new search else: # remove active highlight end_pos = '{}+{}c'.format(search_position, 5) start_pos = '{}+{}c'.format(search_position, -1) self.tag_remove("error_highlight_active", start_pos, end_pos) search_position = self.search( "error", search_position, stopindex="end", nocase=1 ) # finds first occurrence AGAIN on the first time through if search_position == "": # wrap around search_position = self.search("error", '1.0', stopindex="end", nocase=1) end_pos = '{}+{}c'.format(search_position, 5) self.tag_add("error_highlight_active", search_position, end_pos) # add active highlight self.see(search_position) search_position = '{}+{}c'.format(search_position, 1) # point to the next character for new search def scroll_errors(self, event): self._scroll_errors() def _rebuild(self): #global board_name #global Marlin_ver #global target_env #board_name, Marlin_ver = get_board_name() #target_env = get_env(board_name, Marlin_ver) self.start_thread() def rebuild(self, event): print("event happened") self._rebuild() def _open_selected_file(self): current_line = self.index('insert') line_start = current_line[:current_line.find('.')] + '.0' line_end = current_line[:current_line.find('.')] + '.200' self.mark_set("path_start", line_start) self.mark_set("path_end", line_end) path = self.get("path_start", "path_end") from_loc = path.find('from ') colon_loc = path.find(': ') if 0 <= from_loc and ((colon_loc == -1) or (from_loc < colon_loc)): path = path[from_loc + 5:] if 0 <= colon_loc: path = path[:colon_loc] if 0 <= path.find('\\') or 0 <= path.find('/'): # make sure it really contains a path open_file(path) def _file_save_as(self): self.filename = fileDialog.asksaveasfilename(defaultextension='.txt') f = open(self.filename, 'w') f.write(self.get('1.0', 'end')) f.close() def copy(self, event): try: selection = self.get(*self.tag_ranges('sel')) self.clipboard_clear() self.clipboard_append(selection) except TypeError: pass def cut(self, event): try: selection = self.get(*self.tag_ranges('sel')) self.clipboard_clear() self.clipboard_append(selection) self.delete(*self.tag_ranges('sel')) except TypeError: pass def _show_popup(self, event): '''right-click popup menu''' if self.root.focus_get() != self: self.root.focus_set() try: self.popup.tk_popup(event.x_root, event.y_root, 0) finally: self.popup.grab_release() def _cut(self): try: selection = self.get(*self.tag_ranges('sel')) self.clipboard_clear() self.clipboard_append(selection) self.delete(*self.tag_ranges('sel')) except TypeError: pass def cut(self, event): self._cut() def _copy(self): try: selection = self.get(*self.tag_ranges('sel')) self.clipboard_clear() self.clipboard_append(selection) except TypeError: pass def copy(self, event): self._copy() def _paste(self): self.insert('insert', self.selection_get(selection='CLIPBOARD')) def _select_all(self): self.tag_add('sel', '1.0', 'end') def select_all(self, event): self.tag_add('sel', '1.0', 'end') def _clear_all(self): #'''erases all text''' # #isok = askokcancel('Clear All', 'Erase all text?', frame=self, # default='ok') #if isok: # self.delete('1.0', 'end') self.delete('1.0', 'end') # end - output_window def main(): ########################################################################## # # # main program # # # ########################################################################## global build_type global target_env global board_name global Marlin_ver board_name, Marlin_ver = get_board_name() target_env = get_env(board_name, Marlin_ver) # Re-use the VSCode terminal, if possible if os.environ.get('PLATFORMIO_CALLER', '') == 'vscode': sys_PIO() else: auto_build = output_window() auto_build.start_thread() # executes the "run_PIO" function auto_build.root.mainloop() if __name__ == '__main__': main()
2301_81045437/Marlin
buildroot/share/vscode/auto_build.py
Python
agpl-3.0
45,507
#!/usr/bin/env python # # Builds custom upload command # 1) Run platformio as a subprocess to find a COM port # 2) Build the upload command # 3) Exit and let upload tool do the work # # This script runs between completion of the library/dependencies installation and compilation. # # Will continue on if a COM port isn't found so that the compilation can be done. # from __future__ import print_function from __future__ import division import subprocess,os,platform from SCons.Script import DefaultEnvironment current_OS = platform.system() env = DefaultEnvironment() build_type = os.environ.get("BUILD_TYPE", 'Not Set') if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') : env.Replace(UPLOAD_PROTOCOL = 'teensy-gui') # run normal Teensy2 scripts else: com_first = '' com_last = '' com_CDC = '' description_first = '' description_last = '' description_CDC = '' # # grab the first com port that pops up unless we find one we know for sure # is a CDC device # def get_com_port(com_search_text, descr_search_text, start): global com_first global com_last global com_CDC global description_first global description_last global description_CDC print('\nLooking for Serial Port\n') # stream output from subprocess and split it into lines pio_subprocess = subprocess.Popen(['platformio', 'device', 'list'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) looking_for_description = False for line in iter(pio_subprocess.stdout.readline, ''): if 0 <= line.find(com_search_text): looking_for_description = True com_last = line.replace('\n', '') if com_first == '': com_first = com_last if 0 <= line.find(descr_search_text) and looking_for_description: looking_for_description = False description_last = line[ start : ] if description_first == '': description_first = description_last if 0 <= description_last.find('CDC'): com_CDC = com_last description_CDC = description_last if com_CDC == '' and com_first != '': com_CDC = com_first description_CDC = description_first elif com_CDC == '': com_CDC = 'COM_PORT_NOT_FOUND' while 0 <= com_CDC.find('\n'): com_CDC = com_CDC.replace('\n', '') while 0 <= com_CDC.find('\r'): com_CDC = com_CDC.replace('\r', '') if com_CDC == 'COM_PORT_NOT_FOUND': print(com_CDC, '\n') else: print('FOUND: ', com_CDC) print('DESCRIPTION: ', description_CDC, '\n') if current_OS == 'Windows': get_com_port('COM', 'Hardware ID:', 13) # avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf' avrdude_conf_path = 'buildroot\\share\\vscode\\avrdude.conf' avrdude_exe_path = 'buildroot\\share\\vscode\\avrdude_5.10.exe' # source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex' source_path = '.pio\\build\\' + env.get("PIOENV") + '\\firmware.hex' upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i' if current_OS == 'Darwin': # MAC get_com_port('usbmodem', 'Description:', 13) # avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf' avrdude_conf_path = 'buildroot/share/vscode/avrdude_macOS.conf' avrdude_exe_path = 'buildroot/share/vscode/avrdude_5.10_macOS' # source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex' source_path = '.pio/build/' + env.get("PIOENV") + '/firmware.hex' # upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i' upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i' print('upload_string: ', upload_string) if current_OS == 'Linux': get_com_port('/dev/tty', 'Description:', 13) # avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf' avrdude_conf_path = 'buildroot/share/vscode/avrdude_linux.conf' avrdude_exe_path = 'buildroot/share/vscode/avrdude_5.10_linux' # source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex' source_path = '.pio/build/' + env.get("PIOENV") + '/firmware.hex' # upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i' upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i' env.Replace( UPLOADCMD = upload_string, MAXIMUM_RAM_SIZE = 8192, MAXIMUM_SIZE = 130048 )
2301_81045437/Marlin
buildroot/share/vscode/create_custom_upload_command_CDC.py
Python
agpl-3.0
4,989
# # Builds custom upload command # 1) Run platformio as a subprocess to find a COM port # 2) Build the upload command # 3) Exit and let upload tool do the work # # This script runs between completion of the library/dependencies installation and compilation. # # Will continue on if a COM port isn't found so that the compilation can be done. # import os from SCons.Script import DefaultEnvironment import platform current_OS = platform.system() env = DefaultEnvironment() build_type = os.environ.get("BUILD_TYPE", 'Not Set') if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') : env.Replace(UPLOAD_PROTOCOL = 'teensy-gui') # run normal Teensy2 scripts else: if current_OS == 'Windows': avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf' source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex' upload_string = 'avrdude -p usb1286 -c flip1 -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i' else: source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex' upload_string = 'avrdude -p usb1286 -c flip1 -U flash:w:' + source_path + ':i' env.Replace( UPLOADCMD = upload_string, MAXIMUM_RAM_SIZE = 8192, MAXIMUM_SIZE = 130048 )
2301_81045437/Marlin
buildroot/share/vscode/create_custom_upload_command_DFU.py
Python
agpl-3.0
1,359
; ; M808 Repeat Marker Test ; M808 L3 ; Marker at 54 M118 Outer Loop M300 S220 P100 M808 L5 ; Marker at 111 M118 Inner Loop M300 S110 P100 M808 M808
2301_81045437/Marlin
buildroot/test-gcode/M808-loops.gcode
G-code
agpl-3.0
154
#!/usr/bin/env bash # # Build tests for STM32F1 ARMED # # exit on first failure set -e # # Build with the default configurations # restore_configs use_example_configs ArmEd opt_set X_DRIVER_TYPE TMC2130 Y_DRIVER_TYPE TMC2208 opt_enable LASER_SYNCHRONOUS_M106_M107 exec_test $1 $2 "ArmEd Example Configuration with mixed TMC Drivers" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/ARMED
Shell
agpl-3.0
368
#!/usr/bin/env bash # # Build tests for STM32F407VGT6 BigTreeTech BTT002 V1.0 # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_BTT_BTT002_V1_0 \ SERIAL_PORT 1 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 opt_enable SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY SPI_ENDSTOPS exec_test $1 $2 "BigTreeTech BTT002 Default Configuration plus TMC steppers" "$3" # # A test with Probe Temperature Compensation enabled # use_example_configs Prusa/MK3S-BigTreeTech-BTT002 exec_test $1 $2 "BigTreeTech BTT002 with Prusa MK3S and related options" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/BIGTREE_BTT002
Shell
agpl-3.0
671
#!/usr/bin/env bash # # Build tests for BigTreeTech GTR 1.0 # # exit on first failure set -e restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ EXTRUDERS 8 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 TEMP_SENSOR_5 1 TEMP_SENSOR_6 1 TEMP_SENSOR_7 1 # Not necessary to enable auto-fan for all extruders to hit problematic code paths opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ NUM_RUNOUT_SENSORS 8 FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 \ FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 FIL_RUNOUT4_STATE HIGH FIL_RUNOUT8_STATE HIGH \ FILAMENT_RUNOUT_SCRIPT '"M600 T%c"' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH NEOPIXEL_LED Z_SAFE_HOMING NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE \ FILAMENT_RUNOUT_SENSOR FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP FILAMENT_CHANGE_RESUME_ON_INSERT PAUSE_REHEAT_FAST_RESUME \ LCD_BED_TRAMMING BED_TRAMMING_USE_PROBE opt_disable CONFIGURE_FILAMENT_CHANGE exec_test $1 $2 "BigTreeTech GTR | 8 Extruders | Auto-Fan | Mixed TMC Drivers | Runout Sensors w/ distinct states" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \ Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z3_DRIVER_TYPE A4988 Z4_DRIVER_TYPE A4988 \ DEFAULT_Kp_LIST '{ 22.2, 20.0, 21.0, 19.0, 18.0 }' DEFAULT_Ki_LIST '{ 1.08 }' DEFAULT_Kd_LIST '{ 114.0, 112.0, 110.0, 108.0 }' opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_SLOW_FIRST_PRIME TOOLCHANGE_FS_PRIME_FIRST_USED \ REPRAP_DISCOUNT_SMART_CONTROLLER PID_PARAMS_PER_HOTEND Z_MULTI_ENDSTOPS TC_GCODE_USE_GLOBAL_X TC_GCODE_USE_GLOBAL_Y exec_test $1 $2 "BigTreeTech GTR | 6 Extruders | Quad Z + Endstops" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ EXTRUDERS 3 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 \ SERVO1_PIN PE9 SERVO2_PIN PE11 \ SERVO_DELAY '{ 300, 300, 300 }' \ SWITCHING_TOOLHEAD_X_POS '{ 215, 0 ,0 }' \ MPC_HEATER_POWER '{ 40.0f, 40.0f, 40.0f }' \ MPC_BLOCK_HEAT_CAPACITY '{ 16.7f, 16.7f, 16.7f }' \ MPC_SENSOR_RESPONSIVENESS '{ 0.22f, 0.22f, 0.22f }' \ MPC_AMBIENT_XFER_COEFF '{ 0.068f, 0.068f, 0.068f }' \ MPC_AMBIENT_XFER_COEFF_FAN255 '{ 0.097f, 0.097f, 0.097f }' \ FILAMENT_HEAT_CAPACITY_PERMM '{ 5.6e-3f, 3.6e-3f, 5.6e-3f }' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SWITCHING_TOOLHEAD TOOL_SENSOR MPCTEMP MPC_EDIT_MENU MPC_AUTOTUNE MPC_AUTOTUNE_MENU opt_disable PIDTEMP exec_test $1 $2 "BigTreeTech GTR | MPC | Switching Toolhead | Tool Sensors" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/BIGTREE_GTR_V1_0
Shell
agpl-3.0
2,902
#!/usr/bin/env bash # # Build tests for BigTreeTech GTR 1.0 # # exit on first failure set -e restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT 3 \ EXTRUDERS 8 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 TEMP_SENSOR_5 1 TEMP_SENSOR_6 1 TEMP_SENSOR_7 1 opt_enable SDSUPPORT USB_FLASH_DRIVE_SUPPORT USE_OTG_USB_HOST \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH LCD_BED_TRAMMING BED_TRAMMING_USE_PROBE \ NEOPIXEL_LED Z_SAFE_HOMING FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE # Not necessary to enable auto-fan for all extruders to hit problematic code paths opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ FIL_RUNOUT4_STATE HIGH FIL_RUNOUT8_STATE HIGH opt_enable FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP exec_test $1 $2 "GTT GTR | OTG USB Flash Drive | 8 Extruders | Auto-Fan | Mixed TMC Drivers | Runout Sensors (distinct)" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive
Shell
agpl-3.0
1,212
#!/usr/bin/env bash # # Build tests for STM32F407ZG BigTreeTech SKR Pro # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT 1 exec_test $1 $2 "BigTreeTech SKR Pro | Default Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ EXTRUDERS 3 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 \ E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 opt_enable BLTOUCH EEPROM_SETTINGS AUTO_BED_LEVELING_3POINT Z_SAFE_HOMING PINS_DEBUGGING exec_test $1 $2 "BigTreeTech SKR Pro | 3 Extruders | Auto-Fan | BLTOUCH | Mixed TMC" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ CUTTER_POWER_UNIT PERCENT \ SPINDLE_LASER_PWM_PIN HEATER_1_PIN SPINDLE_LASER_ENA_PIN HEATER_2_PIN \ TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 opt_enable LASER_FEATURE LASER_SAFETY_TIMEOUT_MS REPRAP_DISCOUNT_SMART_CONTROLLER exec_test $1 $2 "BigTreeTech SKR Pro | HD44780 | Laser (Percent) | Cooling | LCD" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/BIGTREE_SKR_PRO
Shell
agpl-3.0
1,169
#!/usr/bin/env bash # # Build tests for BTT_SKR_SE_BX # # exit on first failure set -e # # Build with the default configurations # use_example_configs BIQU/BX exec_test $1 $2 "BIQU/BX" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/BTT_SKR_SE_BX
Shell
agpl-3.0
220
#!/usr/bin/env bash # # Build tests for DUE (Atmel SAM3X8E ARM Cortex-M3) # # exit on first failure set -e restore_configs opt_set MOTHERBOARD BOARD_RAMPS4DUE_EFB \ LCD_LANGUAGE bg \ TEMP_SENSOR_0 -2 TEMP_SENSOR_BED 2 \ GRID_MAX_POINTS_X 16 \ E0_AUTO_FAN_PIN 8 FANMUX0_PIN 53 EXTRUDER_AUTO_FAN_SPEED 100 \ TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 6 HEATER_CHAMBER_PIN 45 \ TRAMMING_POINT_XY '{{20,20},{20,20},{20,20},{20,20},{20,20}}' TRAMMING_POINT_NAME_5 '"Point 5"' opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \ ASSISTED_TRAMMING REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \ EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \ BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN \ NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \ NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE CALIBRATION_GCODE \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_SUPPORT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ PSU_CONTROL AUTO_POWER_CONTROL E_DUAL_STEPPER_DRIVERS \ PIDTEMPBED SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER \ PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL MAX7219_REINIT_ON_POWERUP \ EXTENSIBLE_UI opt_add EXTUI_EXAMPLE exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), ExtUI, S-Curve, many options." "$3" # # RADDS with BLTouch, ABL(B), 3 x Z auto-align # restore_configs opt_set MOTHERBOARD BOARD_RADDS Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z3_DRIVER_TYPE A4988 opt_enable ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \ Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_STEPPER_XY Z_SAFE_HOMING pins_set ramps/RAMPS X_MAX_PIN -1 pins_set ramps/RAMPS Y_MAX_PIN -1 exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3" # # Test SWITCHING_EXTRUDER # restore_configs opt_set MOTHERBOARD BOARD_RAMPS4DUE_EEF LCD_LANGUAGE fi EXTRUDERS 2 TEMP_SENSOR_BED 0 NUM_SERVOS 1 opt_enable SWITCHING_EXTRUDER ULTIMAKERCONTROLLER BEEP_ON_FEEDRATE_CHANGE POWER_LOSS_RECOVERY exec_test $1 $2 "RAMPS4DUE_EEF with SWITCHING_EXTRUDER, POWER_LOSS_RECOVERY" "$3"
2301_81045437/Marlin
buildroot/tests/DUE
Shell
agpl-3.0
2,615
#!/usr/bin/env bash # # Build tests for DUE (Atmel SAM3X8E ARM Cortex-M3) # # exit on first failure set -e # # Test Archim 1 # use_example_configs UltiMachine/Archim1 exec_test $1 $2 "Archim 1 base configuration" "$3" # # Test Archim 2 # use_example_configs UltiMachine/Archim2 opt_enable USB_FLASH_DRIVE_SUPPORT exec_test $1 $2 "Archim 2 base configuration" "$3" restore_configs
2301_81045437/Marlin
buildroot/tests/DUE_archim
Shell
agpl-3.0
384
#!/usr/bin/env bash # # Build tests for FLYF407ZG # # exit on first failure set -e # Build examples restore_configs opt_set MOTHERBOARD BOARD_FLYF407ZG SERIAL_PORT -1 X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 exec_test $1 $2 "FLYF407ZG Default Config with mixed TMC Drivers" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/FLYF407ZG
Shell
agpl-3.0
311
#!/usr/bin/env bash # # Build tests for AVR ATmega FYSETC F6 1.3 # # exit on first failure set -e # # Build with the default config plus DGUS_LCD_UI FYSETC # restore_configs opt_set MOTHERBOARD BOARD_FYSETC_F6_13 LCD_SERIAL_PORT 1 DGUS_LCD_UI FYSETC exec_test $1 $2 "DGUS (FYSETC)" "$3" # # Test DGUS_LCD_UI RELOADED # restore_configs opt_set MOTHERBOARD BOARD_FYSETC_F6_13 TEMP_SENSOR_BED 2 LCD_SERIAL_PORT 1 DGUS_LCD_UI RELOADED GRID_MAX_POINTS_X 5 opt_enable ADVANCED_PAUSE_FEATURE LCD_BED_TRAMMING CLASSIC_JERK BABYSTEPPING BABYSTEP_ALWAYS_AVAILABLE BABYSTEP_ZPROBE_OFFSET \ BLTOUCH Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR NOZZLE_PARK_FEATURE exec_test $1 $2 "ABL | DGUS (RELOADED)" "$3" # # Delta Config (FLSUN AC because it's complex) # use_example_configs delta/FLSUN/auto_calibrate opt_set MOTHERBOARD BOARD_FYSETC_F6_13 exec_test $1 $2 "DELTA / FLSUN Auto-Calibrate" "$3" # # Delta Config (generic) + UBL + ALLEN_KEY + EEPROM_SETTINGS + OLED_PANEL_TINYBOY2 # use_example_configs delta/generic opt_set MOTHERBOARD BOARD_FYSETC_F6_13 LCD_LANGUAGE ko_KR opt_enable RESTORE_LEVELING_AFTER_G28 EEPROM_SETTINGS EEPROM_CHITCHAT \ Z_PROBE_ALLEN_KEY AUTO_BED_LEVELING_UBL UBL_MESH_WIZARD \ OLED_PANEL_TINYBOY2 MESH_EDIT_GFX_OVERLAY DELTA_CALIBRATION_MENU BABYSTEPPING exec_test $1 $2 "DELTA | UBL | Allen Key | EEPROM | OLED_PANEL_TINYBOY2..." "$3" # # Test mixed TMC config # restore_configs opt_set MOTHERBOARD BOARD_FYSETC_F6_13 \ LCD_LANGUAGE vi LCD_LANGUAGE_2 fr \ X_DRIVER_TYPE TMC2160 Y_DRIVER_TYPE TMC5160 Z_DRIVER_TYPE TMC2208_STANDALONE E0_DRIVER_TYPE TMC2130 \ X_MIN_ENDSTOP_HIT_STATE LOW Y_MIN_ENDSTOP_HIT_STATE LOW opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER \ MARLIN_BRICKOUT MARLIN_INVADERS MARLIN_SNAKE \ MONITOR_DRIVER_STATUS STEALTHCHOP_XY STEALTHCHOP_Z STEALTHCHOP_E HYBRID_THRESHOLD \ SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY TMC_DEBUG M114_DETAIL exec_test $1 $2 "Mixed TMC | Sensorless | RRDFGSC | Games" "$3" # # Delta Config (FLSUN AC because it's complex) # use_example_configs delta/FLSUN/auto_calibrate opt_set MOTHERBOARD BOARD_FYSETC_F6_13 exec_test $1 $2 "RAMPS 1.3 | DELTA | FLSUN AC Config" "$3" # # SCARA with Mixed TMC # use_example_configs SCARA/Morgan opt_set MOTHERBOARD BOARD_FYSETC_F6_13 \ LCD_LANGUAGE es \ X_MAX_ENDSTOP_HIT_STATE HIGH \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 Z_DRIVER_TYPE TMC2130_STANDALONE E0_DRIVER_TYPE TMC2660 \ X_HARDWARE_SERIAL Serial2 opt_enable FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR PAUSE_BEFORE_DEPLOY_STOW \ FYSETC_242_OLED_12864 EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL Z_SAFE_HOMING \ STEALTHCHOP_XY STEALTHCHOP_Z STEALTHCHOP_E HYBRID_THRESHOLD SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY EDGE_STEPPING exec_test $1 $2 "SCARA | Mixed TMC | EEPROM" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/FYSETC_F6
Shell
agpl-3.0
2,964
#!/usr/bin/env bash # # Build tests for FYSETC_S6 # # exit on first failure set -e # Build examples restore_configs use_example_configs FYSETC/S6 opt_enable MEATPACK_ON_SERIAL_PORT_1 opt_set Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2130 exec_test $1 $2 "FYSETC S6 Example" "$3" # # Build with FTDI Eve Touch UI and some features # restore_configs opt_set MOTHERBOARD BOARD_FYSETC_S6_V2_0 SERIAL_PORT 1 X_DRIVER_TYPE TMC2130 opt_enable TOUCH_UI_FTDI_EVE LCD_FYSETC_TFT81050 S6_TFT_PINMAP LCD_LANGUAGE_2 SDSUPPORT CUSTOM_MENU_MAIN \ FIX_MOUNTED_PROBE AUTO_BED_LEVELING_UBL Z_SAFE_HOMING \ EEPROM_SETTINGS PRINTCOUNTER CALIBRATION_GCODE LIN_ADVANCE \ FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE exec_test $1 $2 "FYSETC S6 2 with LCD FYSETC TFT81050" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/FYSETC_S6
Shell
agpl-3.0
835
#!/usr/bin/env bash # # Build tests for HC32F460C_aquila_101 # # exit on first failure set -e restore_configs opt_set MOTHERBOARD BOARD_AQUILA_V101 SERIAL_PORT 1 opt_enable EEPROM_SETTINGS SDSUPPORT EMERGENCY_PARSER exec_test $1 $2 "Default Configuration with Fallback SD EEPROM" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/HC32F460C_aquila_101
Shell
agpl-3.0
314
#!/usr/bin/env bash # # Build tests for STM32F407ZG I3DBEEZ9 Board # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_I3DBEEZ9_V1 SERIAL_PORT 1 exec_test $1 $2 "I3DBEE Z9 Board | Default Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_I3DBEEZ9_V1 SERIAL_PORT -1 \ EXTRUDERS 3 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 \ E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 opt_enable BLTOUCH EEPROM_SETTINGS AUTO_BED_LEVELING_3POINT Z_SAFE_HOMING PINS_DEBUGGING exec_test $1 $2 "I3DBEE Z9 Board | 3 Extruders | Auto-Fan | BLTOUCH | Mixed TMC" "$3" restore_configs opt_set MOTHERBOARD BOARD_I3DBEEZ9_V1 SERIAL_PORT -1 \ CUTTER_POWER_UNIT PERCENT \ SPINDLE_LASER_PWM_PIN HEATER_1_PIN SPINDLE_LASER_ENA_PIN HEATER_2_PIN \ TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 opt_enable LASER_FEATURE LASER_SAFETY_TIMEOUT_MS REPRAP_DISCOUNT_SMART_CONTROLLER exec_test $1 $2 "I3DBEE Z9 Board | HD44780 | Laser (Percent) | Cooling | LCD" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/I3DBEEZ9_V1
Shell
agpl-3.0
1,137
#!/usr/bin/env bash # # Build tests for LERDGEK environment # # exit on first failure set -e # # Build with the typical configuration # restore_configs opt_set MOTHERBOARD BOARD_LERDGE_K SERIAL_PORT 1 opt_enable TFT_GENERIC TFT_INTERFACE_FSMC TFT_COLOR_UI COMPACT_MARLIN_BOOT_LOGO exec_test $1 $2 "LERDGE K with Generic FSMC TFT with ColorUI" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/LERDGEK
Shell
agpl-3.0
378
#!/usr/bin/env bash # # Build tests for LERDGEX environment # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_LERDGE_X SERIAL_PORT 1 exec_test $1 $2 "LERDGE X with Default Configuration" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/LERDGEX
Shell
agpl-3.0
291
#!/usr/bin/env bash # # Build tests for LPC1768 (NXP ARM Cortex-M3) # # exit on first failure set -e # # Build with the default configurations # #restore_configs #opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB #exec_test $1 $2 "Default Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \ NEOPIXEL_TYPE NEO_RGB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24 opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED E_DUAL_STEPPER_DRIVERS \ NEOPIXEL_LED NEOPIXEL_IS_SEQUENTIAL NEOPIXEL_STARTUP_TEST NEOPIXEL_BKGD_INDEX_FIRST NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_COLOR NEOPIXEL_BKGD_TIMEOUT_COLOR NEOPIXEL_BKGD_ALWAYS_ON exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3" #restore_configs #use_example_configs Mks/Sbase #exec_test $1 $2 "MKS SBASE Example Config" "$3" restore_configs opt_set MOTHERBOARD BOARD_MKS_SBASE \ EXTRUDERS 2 TEMP_SENSOR_1 1 \ NUM_SERVOS 2 SERVO_DELAY '{ 300, 300 }' SWITCHING_NOZZLE_SERVO_ANGLES '{ { 0, 90 }, { 90, 0 } }' opt_enable SWITCHING_NOZZLE SWITCHING_NOZZLE_E1_SERVO_NR EDITABLE_SERVO_ANGLES SERVO_DETACH_GCODE \ ULTIMAKERCONTROLLER REALTIME_REPORTING_COMMANDS FULL_REPORT_TO_HOST_FEATURE exec_test $1 $2 "MKS SBASE with SWITCHING_NOZZLE, Grbl Realtime Report" "$3" restore_configs opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EEB \ EXTRUDERS 2 TEMP_SENSOR_1 -4 TEMP_SENSOR_BED 5 \ GRID_MAX_POINTS_X 16 \ NOZZLE_TO_PROBE_OFFSET '{ 0, 0, 0 }' \ NOZZLE_CLEAN_MIN_TEMP 170 \ NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \ NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }" opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ADAPTIVE_FAN_SLOWING TEMP_TUNING_MAINTAIN_FAN \ FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING SOUND_MENU_ITEM \ NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR PREHEAT_BEFORE_LEVELING G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \ BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET EP_BABYSTEPPING BABYSTEP_GFX_OVERLAY \ PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \ Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \ HOST_KEEPALIVE_FEATURE HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT HOST_STATUS_NOTIFICATIONS \ LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES \ SDSUPPORT SDCARD_SORT_ALPHA AUTO_REPORT_SD_STATUS EMERGENCY_PARSER SOFT_RESET_ON_KILL SOFT_RESET_VIA_SERIAL exec_test $1 $2 "Re-ARM with NOZZLE_AS_PROBE and many features." "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_V1_3 EXTRUDERS 2 \ TEMP_SENSOR_0 1 TEMP_SENSOR_1 1 TEMP_SENSOR_BED 1 TEMP_SENSOR_CHAMBER 1 \ TEMP_CHAMBER_PIN P1_30 HEATER_CHAMBER_PIN P0_28 opt_enable PIDTEMPBED PIDTEMPCHAMBER PID_EXTRUSION_SCALING PID_FAN_SCALING exec_test $1 $2 "SKR v1.3 with 2*Extr, bed, chamber all PID." "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/LPC1768
Shell
agpl-3.0
3,345
#!/usr/bin/env bash # # Build tests for LPC1769 (NXP ARM Cortex-M3) # # exit on first failure set -e # # Build with the default configurations # use_example_configs Azteeg/X5GT exec_test $1 $2 "Azteeg X5GT Example Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_SMOOTHIEBOARD \ EXTRUDERS 2 TEMP_SENSOR_0 -5 TEMP_SENSOR_1 -4 TEMP_SENSOR_BED 5 TEMP_0_CS_PIN P1_29 \ GRID_MAX_POINTS_X 16 \ NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \ NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }" opt_enable TFTGLCD_PANEL_SPI SDSUPPORT ADAPTIVE_FAN_SLOWING REPORT_ADAPTIVE_FAN_SLOWING TEMP_TUNING_MAINTAIN_FAN \ MAX31865_SENSOR_OHMS_0 MAX31865_CALIBRATION_OHMS_0 \ MAG_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BED_TRAMMING_USE_PROBE BED_TRAMMING_VERIFY_RAISED \ PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \ Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \ LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA EMERGENCY_PARSER exec_test $1 $2 "Smoothieboard with TFTGLCD_PANEL_SPI and many features" "$3" #restore_configs #opt_set MOTHERBOARD BOARD_AZTEEG_X5_MINI_WIFI #opt_enable COREYX DAC_MOTOR_CURRENT_DEFAULT \ # REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT BABYSTEPPING \ # AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 EEPROM_SETTINGS \ # FILAMENT_LCD_DISPLAY FILAMENT_WIDTH_SENSOR FAN_SOFT_PWM \ # SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER \ # SD_ABORT_ON_ENDSTOP_HIT ADVANCED_OK GCODE_MACROS \ # VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS \ # EXTRA_FAN_SPEED FWRETRACT MENU_ADDAUTOSTART SDCARD_SORT_ALPHA #opt_set FAN_MIN_PWM 50 FAN_KICKSTART_TIME 100 XY_FREQUENCY_LIMIT 15 #exec_test $1 $2 "Azteeg X5 MINI WIFI Many less common options" "$3" restore_configs use_example_configs delta/generic opt_set MOTHERBOARD BOARD_COHESION3D_REMIX \ TEMP_SENSOR_0 1 \ X_DRIVER_TYPE TMC2130 Y_DRIVER_TYPE TMC2130 Z_DRIVER_TYPE TMC2130 I_DRIVER_TYPE TB6560 \ DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400, 500, 80 }' \ DEFAULT_MAX_FEEDRATE '{ 300, 300, 5, 25, 300 }' \ DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100, 10000, 3000 }' \ MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60, 2*60, 50*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false, false, false }' \ HOMING_FEEDRATE_MM_M '{ (50*60), (50*60), (4*60), (50*60) }' \ HOMING_BUMP_MM '{ 0, 0, 0, 0 }' HOMING_BUMP_DIVISOR '{ 1, 1, 1, 1 }' \ NOZZLE_TO_PROBE_OFFSET '{ 0, 0, 0, 0 }' \ I_MIN_PIN P1_25 \ X_CURRENT_HOME 750 Y_CURRENT_HOME 750 Z_CURRENT_HOME 750 opt_enable AUTO_BED_LEVELING_BILINEAR EEPROM_SETTINGS EEPROM_CHITCHAT MECHANICAL_GANTRY_CALIBRATION \ TMC_USE_SW_SPI MONITOR_DRIVER_STATUS STEALTHCHOP_XY STEALTHCHOP_Z HYBRID_THRESHOLD \ SENSORLESS_PROBING SENSORLESS_HOMING Z_SAFE_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY TMC_DEBUG \ AXIS4_ROTATES I_MIN_POS I_MAX_POS I_HOME_DIR I_ENABLE_ON INVERT_I_DIR \ EXPERIMENTAL_I2CBUS opt_disable PSU_CONTROL Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN exec_test $1 $2 "Cohesion3D Remix DELTA | ABL Bilinear | EEPROM | Sensorless Homing/Probing | I Axis" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/LPC1769
Shell
agpl-3.0
3,642
#!/usr/bin/env bash # # Build tests for NUCLEO_F767ZI # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_NUCLEO_F767ZI SERIAL_PORT -1 X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2208 opt_enable BLTOUCH Z_SAFE_HOMING REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SPEAKER STARTUP_TUNE SOFTWARE_DRIVER_ENABLE exec_test $1 $2 "Mixed timer usage" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/NUCLEO_F767ZI
Shell
agpl-3.0
440
#!/usr/bin/env bash # # Build tests for Opulo_Lumen_REV3 # # exit on first failure set -e use_example_configs Opulo/Lumen_REV3 opt_disable TMC_DEBUG exec_test $1 $2 "Opulo Lumen REV3 Pick-and-Place" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/Opulo_Lumen_REV3
Shell
agpl-3.0
233
#!/usr/bin/env bash # # Build tests for PANDA_PI_V29 # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_PANDA_PI_V29 SERIAL_PORT -1 \ Z_CLEARANCE_DEPLOY_PROBE 0 Z_CLEARANCE_BETWEEN_PROBES 1 Z_CLEARANCE_MULTI_PROBE 1 opt_enable BD_SENSOR AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING BABYSTEPPING exec_test $1 $2 "Panda Pi V29 | BD Sensor | ABL-B" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/PANDA_PI_V29
Shell
agpl-3.0
453
#!/usr/bin/env bash # # Build tests for REMRAM_V1 # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_REMRAM_V1 opt_set SERIAL_PORT 1 exec_test $1 $2 "Default Configuration" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/REMRAM_V1
Shell
agpl-3.0
276
#!/usr/bin/env bash # # Build tests for SAMD21 (Minitronics 2.0) # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_MINITRONICS20 SERIAL_PORT -1 \ TEMP_SENSOR_0 11 TEMP_SENSOR_BED 11 \ X_DRIVER_TYPE DRV8825 Y_DRIVER_TYPE DRV8825 Z_DRIVER_TYPE DRV8825 E0_DRIVER_TYPE DRV8825 \ RESTORE_LEVELING_AFTER_G28 false \ LCD_LANGUAGE it \ SDCARD_CONNECTION LCD \ HOMING_BUMP_MM '{ 0, 0, 0 }' opt_enable ENDSTOP_INTERRUPTS_FEATURE BLTOUCH Z_MIN_PROBE_REPEATABILITY_TEST \ FILAMENT_RUNOUT_SENSOR G26_MESH_VALIDATION MESH_EDIT_GFX_OVERLAY Z_SAFE_HOMING \ EEPROM_SETTINGS NOZZLE_PARK_FEATURE SDSUPPORT SD_CHECK_AND_RETRY \ REPRAPWORLD_GRAPHICAL_LCD ADAPTIVE_STEP_SMOOTHING \ STATUS_MESSAGE_SCROLLING SET_PROGRESS_MANUALLY SHOW_REMAINING_TIME SET_REMAINING_TIME \ LONG_FILENAME_HOST_SUPPORT CUSTOM_FIRMWARE_UPLOAD M20_TIMESTAMP_SUPPORT \ SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \ MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_GFX_OVERLAY \ LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS exec_test $1 $2 "Minitronics 2.0 with assorted features" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/SAMD21_minitronics20
Shell
agpl-3.0
1,326
#!/usr/bin/env bash # # Build tests for Adafruit Grand Central M4 (ATMEL ARM Cortex-M4) # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_AGCM4_RAMPS_144 SERIAL_PORT -1 \ TEMP_SENSOR_0 11 TEMP_SENSOR_BED 11 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2209 Z2_DRIVER_TYPE TMC2209 E0_DRIVER_TYPE TMC2209 \ RESTORE_LEVELING_AFTER_G28 false \ LCD_LANGUAGE it \ SDCARD_CONNECTION LCD \ HOMING_BUMP_MM '{ 0, 0, 0 }' opt_enable ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION BLTOUCH Z_MIN_PROBE_REPEATABILITY_TEST \ FILAMENT_RUNOUT_SENSOR G26_MESH_VALIDATION MESH_EDIT_GFX_OVERLAY Z_SAFE_HOMING \ EEPROM_SETTINGS NOZZLE_PARK_FEATURE SDSUPPORT SD_CHECK_AND_RETRY \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER Z_STEPPER_AUTO_ALIGN ADAPTIVE_STEP_SMOOTHING \ STATUS_MESSAGE_SCROLLING SET_PROGRESS_MANUALLY SHOW_REMAINING_TIME SET_REMAINING_TIME \ LONG_FILENAME_HOST_SUPPORT CUSTOM_FIRMWARE_UPLOAD M20_TIMESTAMP_SUPPORT \ SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \ MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_GFX_OVERLAY \ LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS \ SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY Z2_STALL_SENSITIVITY \ EDGE_STEPPING TMC_DEBUG exec_test $1 $2 "Grand Central M4 with assorted features" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/SAMD51_grandcentral_m4
Shell
agpl-3.0
1,586
#!/usr/bin/env bash # # Build tests for STM32F070CB Malyan M200 v2 # # exit on first failure set -e restore_configs opt_set MOTHERBOARD BOARD_MALYAN_M200_V2 SERIAL_PORT -1 exec_test $1 $2 "Malyan M200 v2 Default Config" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F070CB_malyan
Shell
agpl-3.0
254
#!/usr/bin/env bash # # Build tests for STM32F070RB Malyan M200 v2 # # exit on first failure set -e restore_configs opt_set MOTHERBOARD BOARD_MALYAN_M200_V2 opt_set SERIAL_PORT -1 exec_test $1 $2 "Malyan M200 v2 Default Config" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F070RB_malyan
Shell
agpl-3.0
262
#!/usr/bin/env bash # # Build tests for STM32F103CB Malyan M200 # # exit on first failure set -e use_example_configs Malyan/M200 exec_test $1 $2 "Malyan M200" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103CB_malyan
Shell
agpl-3.0
193
#!/usr/bin/env bash # # Build tests for STM32F103RC_btt (BigTreeTech SKR Mini E3) # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_E3_V1_0 SERIAL_PORT 1 SERIAL_PORT_2 -1 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2209 E0_DRIVER_TYPE TMC2209 opt_enable CR10_STOCKDISPLAY PINS_DEBUGGING Z_IDLE_HEIGHT FT_MOTION FT_MOTION_MENU ADAPTIVE_STEP_SMOOTHING NONLINEAR_EXTRUSION exec_test $1 $2 "BigTreeTech SKR Mini E3 1.0 - TMC2209 HW Serial, FT_MOTION" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RC_btt
Shell
agpl-3.0
591
#!/usr/bin/env bash # # Build tests for STM32F103RC BigTreeTech (SKR Mini v1.1) # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 TEMP_SENSOR_SOC 1 exec_test $1 $2 "BigTreeTech SKR Mini v1.1 - SOC Temperature" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RC_btt_USB
Shell
agpl-3.0
363
#!/usr/bin/env bash # # Build tests for STM32F103RC BigTreeTech (SKR Mini v1.1) with LibMaple STM32F1 HAL # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 BAUDRATE_2 115200 exec_test $1 $2 "BigTreeTech SKR Mini v1.1 - Basic Configuration" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RC_btt_USB_maple
Shell
agpl-3.0
393
#!/usr/bin/env bash # # Build tests for STM32F103RC BigTreeTech (SKR Mini E3) with LibMaple STM32F1 HAL # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_E3_V1_0 SERIAL_PORT 1 SERIAL_PORT_2 -1 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2209 E0_DRIVER_TYPE TMC2209 opt_enable PINS_DEBUGGING Z_IDLE_HEIGHT exec_test $1 $2 "BigTreeTech SKR Mini E3 1.0 - Basic Config with TMC2209 HW Serial" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RC_btt_maple
Shell
agpl-3.0
533
#!/usr/bin/env bash # # Build tests for STM32F103RC_fysetc # # exit on first failure set -e # # Build with the default configurations # use_example_configs "Creality/Ender-3/FYSETC Cheetah 1.2/BLTouch" exec_test $1 $2 "Ender-3 with Cheetah 1.2 | BLTouch" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RC_fysetc
Shell
agpl-3.0
290
#!/usr/bin/env bash # # Build tests for STM32F103RC_fysetc_maple # # exit on first failure set -e # # Build with the default configurations # use_example_configs "Creality/Ender-3/FYSETC Cheetah 1.2/base" exec_test $1 $2 "Maple build of Cheetah 1.2 Configuration" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RC_fysetc_maple
Shell
agpl-3.0
299
#!/usr/bin/env bash # # Build tests for STM32F103RC MEEB_3DP (ccrobot-online.com) # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_CCROBOT_MEEB_3DP SERIAL_PORT 1 SERIAL_PORT_2 -1 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2208 Z_DRIVER_TYPE TMC2208 E0_DRIVER_TYPE TMC2208 exec_test $1 $2 "MEEB_3DP - Basic Config with TMC2208 SW Serial" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RC_meeb_maple
Shell
agpl-3.0
448
#!/usr/bin/env bash # # Build tests for STM32F103RE # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_STM32F103RE SERIAL_PORT -1 EXTRUDERS 2 \ NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 } }" \ NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 } }" opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT SDSUPPORT \ PAREN_COMMENTS GCODE_MOTION_MODES SINGLENOZZLE TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_PARK \ BAUD_RATE_GCODE GCODE_MACROS NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE exec_test $1 $2 "STM32F1R EEPROM_SETTINGS EEPROM_CHITCHAT SDSUPPORT PAREN_COMMENTS GCODE_MOTION_MODES" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RE
Shell
agpl-3.0
694
#!/usr/bin/env bash # # Build tests for STM32F103RE BigTreeTech (SKR E3 DIP v1.0) # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_E3_DIP \ SERIAL_PORT 1 SERIAL_PORT_2 -1 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 opt_enable SERIAL_DMA exec_test $1 $2 "BTT SKR E3 DIP 1.0 | Mixed TMC Drivers" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RE_btt
Shell
agpl-3.0
425
#!/usr/bin/env bash # # Build tests for STM32F103RE BigTreeTech (SKR E3 DIP v1.0) # # exit on first failure set -e # # Build with the default configurations # restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_E3_DIP SERIAL_PORT 1 SERIAL_PORT_2 -1 opt_enable SDSUPPORT EMERGENCY_PARSER exec_test $1 $2 "BigTreeTech SKR E3 DIP v1.0 - Basic Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_CR6 SERIAL_PORT -1 SERIAL_PORT_2 2 TEMP_SENSOR_BED 1 opt_enable CR10_STOCKDISPLAY SDSUPPORT EMERGENCY_PARSER FAN_SOFT_PWM \ NOZZLE_AS_PROBE Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN Z_SAFE_HOMING \ PROBE_ACTIVATION_SWITCH PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE \ PROBING_HEATERS_OFF PREHEAT_BEFORE_PROBING opt_disable NOZZLE_TO_PROBE_OFFSET exec_test $1 $2 "BigTreeTech SKR CR6 PROBE_ACTIVATION_SWITCH, Probe Tare" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RE_btt_USB
Shell
agpl-3.0
888
#!/usr/bin/env bash # # Build tests for STM32F103RE_creality # # exit on first failure set -e # # Build with configs included in the PR # use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_enable MARLIN_DEV_MODE BUFFER_MONITORING BLTOUCH AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING exec_test $1 $2 "Ender-3 V2 - CrealityUI" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY exec_test $1 $2 "Ender-3 V2 - JyersUI (ABL Bilinear/Manual)" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD PIDTEMP opt_enable DWIN_MARLINUI_LANDSCAPE LCD_ENDSTOP_TEST AUTO_BED_LEVELING_UBL BLTOUCH Z_SAFE_HOMING MPCTEMP MPC_AUTOTUNE exec_test $1 $2 "Ender-3 V2 - MarlinUI (UBL+BLTOUCH, MPCTEMP, LCD_ENDSTOP_TEST)" "$3" use_example_configs "Creality/Ender-3 S1/STM32F1" opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CANCEL_OBJECTS FWRETRACT EVENT_GCODE_SD_ABORT opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT STATUS_MESSAGE_SCROLLING \ SOUND_MENU_ITEM PRINTCOUNTER NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR \ BLTOUCH Z_SAFE_HOMING AUTO_BED_LEVELING_UBL MESH_EDIT_MENU LCD_BED_TRAMMING \ LIMITED_MAX_FR_EDITING LIMITED_MAX_ACCEL_EDITING LIMITED_JERK_EDITING BAUD_RATE_GCODE \ CASE_LIGHT_ENABLE CASE_LIGHT_MENU CASE_LIGHT_NO_BRIGHTNESS opt_set PREHEAT_3_LABEL '"CUSTOM"' PREHEAT_3_TEMP_HOTEND 240 PREHEAT_3_TEMP_BED 60 PREHEAT_3_FAN_SPEED 128 BOOTSCREEN_TIMEOUT 1100 CASE_LIGHT_PIN 4 exec_test $1 $2 "Ender-3 S1 - ProUI (PIDTEMP)" "$3" restore_configs opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1 opt_disable NOZZLE_TO_PROBE_OFFSET opt_enable NOZZLE_AS_PROBE Z_SAFE_HOMING Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN FAN_SOFT_PWM \ PROBE_ACTIVATION_SWITCH PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE exec_test $1 $2 "Creality V4.5.2 PROBE_ACTIVATION_SWITCH, Probe Tare" "$3" restore_configs opt_set MOTHERBOARD BOARD_CREALITY_V422 SERIAL_PORT 1 DGUS_LCD_UI IA_CREALITY opt_enable NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE LCD_BED_TRAMMING CLASSIC_JERK BABYSTEPPING \ AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY FAN_SOFT_PWM opt_add NO_CREALITY_422_DRIVER_WARNING opt_add NO_AUTO_ASSIGN_WARNING exec_test $1 $2 "Creality V4.2.2 with IA_CREALITY" "$3" # clean up restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103RE_creality
Shell
agpl-3.0
2,542
#!/usr/bin/env bash # # Build tests for STM32F103VE_ZM3E4V2_USB # # exit on first failure set -e restore_configs opt_set MOTHERBOARD BOARD_ZONESTAR_ZM3E4V2 SERIAL_PORT 1 exec_test $1 $2 "Zonestar ZM3E4 V2.0" "$3" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103VE_ZM3E4V2_USB_maple
Shell
agpl-3.0
242
#!/usr/bin/env bash # # Build tests for STM32F103VET6 # # exit on first failure set -e use_example_configs Alfawise/U20 opt_enable BAUD_RATE_GCODE exec_test $1 $2 "CLASSIC_UI U20 config" "$3" use_example_configs Alfawise/U20 opt_enable BAUD_RATE_GCODE TFT_COLOR_UI opt_disable TFT_CLASSIC_UI CUSTOM_STATUS_SCREEN_IMAGE exec_test $1 $2 "COLOR_UI U20 config" "$3" use_example_configs Alfawise/U20-bltouch opt_enable BAUD_RATE_GCODE exec_test $1 $2 "BLTouch U20 config" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103VE_longer
Shell
agpl-3.0
498
#!/usr/bin/env bash # # Build tests for STM32F103VET6 (using maple STM32F1 framework) # # exit on first failure set -e use_example_configs Alfawise/U20 opt_enable BAUD_RATE_GCODE exec_test $1 $2 "Maple - Alfawise U20 - CLASSIC_UI" "$3" use_example_configs Alfawise/U20 opt_enable BAUD_RATE_GCODE TFT_COLOR_UI opt_disable TFT_CLASSIC_UI CUSTOM_STATUS_SCREEN_IMAGE exec_test $1 $2 "Maple - Alfawise U20 - COLOR_UI" "$3" use_example_configs Alfawise/U20-bltouch opt_enable BAUD_RATE_GCODE exec_test $1 $2 "Maple - Alfawise U20 - BLTouch" # cleanup restore_configs
2301_81045437/Marlin
buildroot/tests/STM32F103VE_longer_maple
Shell
agpl-3.0
566