Scott Lahteine
5 years ago
137 changed files with 1959 additions and 1162 deletions
@ -0,0 +1,78 @@ |
|||||
|
/**
|
||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
#include "../../inc/MarlinConfig.h" |
||||
|
|
||||
|
#if ENABLED(QSPI_EEPROM) |
||||
|
|
||||
|
#include "QSPIFlash.h" |
||||
|
|
||||
|
#define INVALID_ADDR 0xffffffff |
||||
|
#define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1)) |
||||
|
#define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1)) |
||||
|
|
||||
|
Adafruit_SPIFlashBase * QSPIFlash::_flashBase = nullptr; |
||||
|
uint8_t QSPIFlash::_buf[SFLASH_SECTOR_SIZE]; |
||||
|
uint32_t QSPIFlash::_addr = INVALID_ADDR; |
||||
|
|
||||
|
void QSPIFlash::begin() { |
||||
|
if (_flashBase != nullptr) return; |
||||
|
|
||||
|
_flashBase = new Adafruit_SPIFlashBase(new Adafruit_FlashTransport_QSPI()); |
||||
|
_flashBase->begin(NULL); |
||||
|
} |
||||
|
|
||||
|
size_t QSPIFlash::size() { |
||||
|
return _flashBase->size(); |
||||
|
} |
||||
|
|
||||
|
uint8_t QSPIFlash::readByte(const uint32_t address) { |
||||
|
if (SECTOR_OF(address) == _addr) return _buf[OFFSET_OF(address)]; |
||||
|
|
||||
|
return _flashBase->read8(address); |
||||
|
} |
||||
|
|
||||
|
void QSPIFlash::writeByte(const uint32_t address, const uint8_t value) { |
||||
|
uint32_t const sector_addr = SECTOR_OF(address); |
||||
|
|
||||
|
// Page changes, flush old and update new cache
|
||||
|
if (sector_addr != _addr) { |
||||
|
flush(); |
||||
|
_addr = sector_addr; |
||||
|
|
||||
|
// read a whole page from flash
|
||||
|
_flashBase->readBuffer(sector_addr, _buf, SFLASH_SECTOR_SIZE); |
||||
|
} |
||||
|
|
||||
|
_buf[OFFSET_OF(address)] = value; |
||||
|
} |
||||
|
|
||||
|
void QSPIFlash::flush() { |
||||
|
if (_addr == INVALID_ADDR) return; |
||||
|
|
||||
|
_flashBase->eraseSector(_addr / SFLASH_SECTOR_SIZE); |
||||
|
_flashBase->writeBuffer(_addr, _buf, SFLASH_SECTOR_SIZE); |
||||
|
|
||||
|
_addr = INVALID_ADDR; |
||||
|
} |
||||
|
|
||||
|
#endif // QSPI_EEPROM
|
@ -0,0 +1,51 @@ |
|||||
|
/**
|
||||
|
* @file QSPIFlash.h |
||||
|
* |
||||
|
* The MIT License (MIT) |
||||
|
* |
||||
|
* Copyright (c) 2019 Ha Thach and Dean Miller for Adafruit Industries 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. |
||||
|
* |
||||
|
* Derived from Adafruit_SPIFlash class with no SdFat references |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include "Adafruit_SPIFlashBase.h" |
||||
|
|
||||
|
// This class extends Adafruit_SPIFlashBase by adding caching support.
|
||||
|
//
|
||||
|
// This class will use 4096 Bytes of RAM as a block cache.
|
||||
|
class QSPIFlash { |
||||
|
public: |
||||
|
static void begin(); |
||||
|
static size_t size(); |
||||
|
static uint8_t readByte(const uint32_t address); |
||||
|
static void writeByte(const uint32_t address, const uint8_t v); |
||||
|
static void flush(); |
||||
|
|
||||
|
private: |
||||
|
static Adafruit_SPIFlashBase * _flashBase; |
||||
|
static uint8_t _buf[SFLASH_SECTOR_SIZE]; |
||||
|
static uint32_t _addr; |
||||
|
}; |
||||
|
|
||||
|
extern QSPIFlash qspi; |
@ -0,0 +1,66 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* |
||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) |
||||
|
* |
||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
#ifdef __SAMD51__ |
||||
|
|
||||
|
#include "../../inc/MarlinConfig.h" |
||||
|
|
||||
|
#if ENABLED(EEPROM_SETTINGS) && NONE(QSPI_EEPROM, FLASH_EEPROM_EMULATION) |
||||
|
|
||||
|
#include "../shared/eeprom_api.h" |
||||
|
|
||||
|
size_t PersistentStore::capacity() { return E2END + 1; } |
||||
|
|
||||
|
bool PersistentStore::access_start() { return true; } |
||||
|
bool PersistentStore::access_finish() { return true; } |
||||
|
|
||||
|
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { |
||||
|
while (size--) { |
||||
|
const uint8_t v = *value; |
||||
|
uint8_t * const p = (uint8_t * const)pos; |
||||
|
if (v != eeprom_read_byte(p)) { |
||||
|
eeprom_write_byte(p, v); |
||||
|
delay(2); |
||||
|
if (eeprom_read_byte(p) != v) { |
||||
|
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
crc16(crc, &v, 1); |
||||
|
pos++; |
||||
|
value++; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { |
||||
|
while (size--) { |
||||
|
uint8_t c = eeprom_read_byte((uint8_t*)pos); |
||||
|
if (writing) *value = c; |
||||
|
crc16(crc, &c, 1); |
||||
|
pos++; |
||||
|
value++; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
#endif // EEPROM_SETTINGS && !(QSPI_EEPROM || FLASH_EEPROM_EMULATION)
|
||||
|
#endif // __SAMD51__
|
@ -0,0 +1,96 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* |
||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) |
||||
|
* |
||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
#ifdef __SAMD51__ |
||||
|
|
||||
|
#include "../../inc/MarlinConfig.h" |
||||
|
|
||||
|
#if ENABLED(FLASH_EEPROM_EMULATION) |
||||
|
|
||||
|
#include "../shared/eeprom_api.h" |
||||
|
|
||||
|
#define NVMCTRL_CMD(c) do{ \ |
||||
|
SYNC(!NVMCTRL->STATUS.bit.READY); \ |
||||
|
NVMCTRL->INTFLAG.bit.DONE = true; \ |
||||
|
NVMCTRL->CTRLB.reg = c | NVMCTRL_CTRLB_CMDEX_KEY; \ |
||||
|
SYNC(NVMCTRL->INTFLAG.bit.DONE); \ |
||||
|
}while(0) |
||||
|
#define NVMCTRL_FLUSH() do{ \ |
||||
|
if (NVMCTRL->SEESTAT.bit.LOAD) \ |
||||
|
NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_SEEFLUSH); \ |
||||
|
}while(0) |
||||
|
|
||||
|
size_t PersistentStore::capacity() { |
||||
|
const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ, |
||||
|
sblk = NVMCTRL->SEESTAT.bit.SBLK; |
||||
|
|
||||
|
return (!psz && !sblk) ? 0 |
||||
|
: (psz <= 2) ? (0x200 << psz) |
||||
|
: (sblk == 1 || psz == 3) ? 4096 |
||||
|
: (sblk == 2 || psz == 4) ? 8192 |
||||
|
: (sblk <= 4 || psz == 5) ? 16384 |
||||
|
: (sblk >= 9 && psz == 7) ? 65536 |
||||
|
: 32768; |
||||
|
} |
||||
|
|
||||
|
bool PersistentStore::access_start() { |
||||
|
NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED; // Buffered mode and segment reallocation active
|
||||
|
if (NVMCTRL->SEESTAT.bit.RLOCK) |
||||
|
NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE); // Unlock E2P data write access
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
bool PersistentStore::access_finish() { |
||||
|
NVMCTRL_FLUSH(); |
||||
|
if (!NVMCTRL->SEESTAT.bit.LOCK) |
||||
|
NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_LSEE); // Lock E2P data write access
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { |
||||
|
while (size--) { |
||||
|
const uint8_t v = *value; |
||||
|
SYNC(NVMCTRL->SEESTAT.bit.BUSY); |
||||
|
if (NVMCTRL->INTFLAG.bit.SEESFULL) |
||||
|
NVMCTRL_FLUSH(); // Next write will trigger a sector reallocation. I need to flush 'pagebuffer'
|
||||
|
((volatile uint8_t *)SEEPROM_ADDR)[pos] = v; |
||||
|
SYNC(!NVMCTRL->INTFLAG.bit.SEEWRC); |
||||
|
crc16(crc, &v, 1); |
||||
|
pos++; |
||||
|
value++; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { |
||||
|
while (size--) { |
||||
|
SYNC(NVMCTRL->SEESTAT.bit.BUSY); |
||||
|
uint8_t c = ((volatile uint8_t *)SEEPROM_ADDR)[pos]; |
||||
|
if (writing) *value = c; |
||||
|
crc16(crc, &c, 1); |
||||
|
pos++; |
||||
|
value++; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
#endif // FLASH_EEPROM_EMULATION
|
||||
|
#endif // __SAMD51__
|
@ -0,0 +1,71 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* |
||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) |
||||
|
* |
||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
#ifdef __SAMD51__ |
||||
|
|
||||
|
#include "../../inc/MarlinConfig.h" |
||||
|
|
||||
|
#if ENABLED(QSPI_EEPROM) |
||||
|
|
||||
|
#include "../shared/eeprom_api.h" |
||||
|
|
||||
|
#include "QSPIFlash.h" |
||||
|
|
||||
|
static bool initialized; |
||||
|
|
||||
|
size_t PersistentStore::capacity() { return qspi.size(); } |
||||
|
|
||||
|
bool PersistentStore::access_start() { |
||||
|
if (!initialized) { |
||||
|
qspi.begin(); |
||||
|
initialized = true; |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
bool PersistentStore::access_finish() { |
||||
|
qspi.flush(); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { |
||||
|
while (size--) { |
||||
|
const uint8_t v = *value; |
||||
|
qspi.writeByte(pos, v); |
||||
|
crc16(crc, &v, 1); |
||||
|
pos++; |
||||
|
value++; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { |
||||
|
while (size--) { |
||||
|
uint8_t c = qspi.readByte(pos); |
||||
|
if (writing) *value = c; |
||||
|
crc16(crc, &c, 1); |
||||
|
pos++; |
||||
|
value++; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
#endif // QSPI_EEPROM
|
||||
|
#endif // __SAMD51__
|
@ -1,129 +0,0 @@ |
|||||
/**
|
|
||||
* Marlin 3D Printer Firmware |
|
||||
* |
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) |
|
||||
* |
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
#ifdef __SAMD51__ |
|
||||
|
|
||||
#include "../../inc/MarlinConfig.h" |
|
||||
|
|
||||
#if ENABLED(EEPROM_SETTINGS) |
|
||||
|
|
||||
#include "../shared/persistent_store_api.h" |
|
||||
|
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION) |
|
||||
#define NVMCTRL_CMD(c) do{ \ |
|
||||
SYNC(!NVMCTRL->STATUS.bit.READY); \ |
|
||||
NVMCTRL->INTFLAG.bit.DONE = true; \ |
|
||||
NVMCTRL->CTRLB.reg = c | NVMCTRL_CTRLB_CMDEX_KEY; \ |
|
||||
SYNC(NVMCTRL->INTFLAG.bit.DONE); \ |
|
||||
}while(0) |
|
||||
#define NVMCTRL_FLUSH() do{ \ |
|
||||
if (NVMCTRL->SEESTAT.bit.LOAD) \ |
|
||||
NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_SEEFLUSH); \ |
|
||||
}while(0) |
|
||||
#endif |
|
||||
|
|
||||
bool PersistentStore::access_start() { |
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION) |
|
||||
NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED; // Buffered mode and segment reallocation active
|
|
||||
#endif |
|
||||
|
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
bool PersistentStore::access_finish() { |
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION) |
|
||||
NVMCTRL_FLUSH(); |
|
||||
if (!NVMCTRL->SEESTAT.bit.LOCK) |
|
||||
NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_LSEE); // Lock E2P data write access
|
|
||||
#endif |
|
||||
|
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { |
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION) |
|
||||
if (NVMCTRL->SEESTAT.bit.RLOCK) |
|
||||
NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE); // Unlock E2P data write access
|
|
||||
#endif |
|
||||
|
|
||||
while (size--) { |
|
||||
const uint8_t v = *value; |
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION) |
|
||||
SYNC(NVMCTRL->SEESTAT.bit.BUSY); |
|
||||
if (NVMCTRL->INTFLAG.bit.SEESFULL) |
|
||||
NVMCTRL_FLUSH(); // Next write will trigger a sector reallocation. I need to flush 'pagebuffer'
|
|
||||
((volatile uint8_t *)SEEPROM_ADDR)[pos] = v; |
|
||||
SYNC(!NVMCTRL->INTFLAG.bit.SEEWRC); |
|
||||
#else |
|
||||
uint8_t * const p = (uint8_t * const)pos; |
|
||||
if (v != eeprom_read_byte(p)) { |
|
||||
eeprom_write_byte(p, v); |
|
||||
delay(2); |
|
||||
if (eeprom_read_byte(p) != v) { |
|
||||
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); |
|
||||
return true; |
|
||||
} |
|
||||
} |
|
||||
#endif |
|
||||
crc16(crc, &v, 1); |
|
||||
pos++; |
|
||||
value++; |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { |
|
||||
while (size--) { |
|
||||
uint8_t c; |
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION) |
|
||||
SYNC(NVMCTRL->SEESTAT.bit.BUSY); |
|
||||
c = ((volatile uint8_t *)SEEPROM_ADDR)[pos]; |
|
||||
#else |
|
||||
c = eeprom_read_byte((uint8_t*)pos); |
|
||||
#endif |
|
||||
if (writing) *value = c; |
|
||||
crc16(crc, &c, 1); |
|
||||
pos++; |
|
||||
value++; |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
size_t PersistentStore::capacity() { |
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION) |
|
||||
const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ, |
|
||||
sblk = NVMCTRL->SEESTAT.bit.SBLK; |
|
||||
|
|
||||
if (!psz && !sblk) return 0; |
|
||||
else if (psz <= 2) return (0x200 << psz); |
|
||||
else if (sblk == 1 || psz == 3) return 4096; |
|
||||
else if (sblk == 2 || psz == 4) return 8192; |
|
||||
else if (sblk <= 4 || psz == 5) return 16384; |
|
||||
else if (sblk >= 9 && psz == 7) return 65536; |
|
||||
else return 32768; |
|
||||
#else |
|
||||
return E2END + 1; |
|
||||
#endif |
|
||||
} |
|
||||
|
|
||||
#endif // EEPROM_SETTINGS
|
|
||||
|
|
||||
#endif // __SAMD51__
|
|
@ -0,0 +1,109 @@ |
|||||
|
/**
|
||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
#include "../../inc/MarlinConfig.h" |
||||
|
|
||||
|
#if ENABLED(SDSUPPORT) |
||||
|
|
||||
|
#include "../gcode.h" |
||||
|
#include "../../module/printcounter.h" |
||||
|
|
||||
|
#if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE) |
||||
|
#include "../../lcd/ultralcd.h" |
||||
|
#endif |
||||
|
|
||||
|
#if ENABLED(POWER_LOSS_RECOVERY) |
||||
|
#include "../../feature/powerloss.h" |
||||
|
#endif |
||||
|
|
||||
|
#if HAS_LEDS_OFF_FLAG |
||||
|
#include "../../feature/leds/printer_event_leds.h" |
||||
|
#endif |
||||
|
|
||||
|
#if ENABLED(EXTENSIBLE_UI) |
||||
|
#include "../../lcd/extui/ui_api.h" |
||||
|
#endif |
||||
|
|
||||
|
#if ENABLED(HOST_ACTION_COMMANDS) |
||||
|
#include "../../feature/host_actions.h" |
||||
|
#endif |
||||
|
|
||||
|
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND) |
||||
|
#include "../../module/planner.h" |
||||
|
#endif |
||||
|
|
||||
|
#ifndef PE_LEDS_COMPLETED_TIME |
||||
|
#define PE_LEDS_COMPLETED_TIME (30*60) |
||||
|
#endif |
||||
|
|
||||
|
/**
|
||||
|
* M1001: Execute actions for SD print completion |
||||
|
*/ |
||||
|
void GcodeSuite::M1001() { |
||||
|
|
||||
|
// Report total print time
|
||||
|
const bool long_print = print_job_timer.duration() > 60; |
||||
|
if (long_print) gcode.process_subcommands_now_P(PSTR("M31")); |
||||
|
|
||||
|
// Stop the print job timer
|
||||
|
gcode.process_subcommands_now_P(PSTR("M77")); |
||||
|
|
||||
|
// Set the progress bar "done" state
|
||||
|
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) |
||||
|
ui.set_progress_done(); |
||||
|
#endif |
||||
|
|
||||
|
// Purge the recovery file
|
||||
|
#if ENABLED(POWER_LOSS_RECOVERY) |
||||
|
recovery.purge(); |
||||
|
#endif |
||||
|
|
||||
|
// Announce SD file completion
|
||||
|
SERIAL_ECHOLNPGM(STR_FILE_PRINTED); |
||||
|
|
||||
|
// Update the status LED color
|
||||
|
#if HAS_LEDS_OFF_FLAG |
||||
|
if (long_print) { |
||||
|
printerEventLEDs.onPrintCompleted(); |
||||
|
#if ENABLED(EXTENSIBLE_UI) |
||||
|
ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE)); |
||||
|
#endif |
||||
|
#if ENABLED(HOST_PROMPT_SUPPORT) |
||||
|
host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_PRINT_DONE), CONTINUE_STR); |
||||
|
#endif |
||||
|
wait_for_user_response(1000UL * TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30)); |
||||
|
printerEventLEDs.onResumeAfterWait(); |
||||
|
} |
||||
|
#endif |
||||
|
|
||||
|
// Wait for the queue to empty (and "clean"), inject SD_FINISHED_RELEASECOMMAND
|
||||
|
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND) |
||||
|
planner.finish_and_disable(); |
||||
|
#endif |
||||
|
|
||||
|
// Re-select the last printed file in the UI
|
||||
|
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) |
||||
|
ui.reselect_last_file(); |
||||
|
#endif |
||||
|
} |
||||
|
|
||||
|
#endif // SDSUPPORT
|
@ -0,0 +1,83 @@ |
|||||
|
/********************
|
||||
|
* preheat_menu.cpp * |
||||
|
********************/ |
||||
|
|
||||
|
/****************************************************************************
|
||||
|
* Written By Marcio Teixeira 2020 - Cocoa Press * |
||||
|
* * |
||||
|
* 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. * |
||||
|
* * |
||||
|
* To view a copy of the GNU General Public License, go to the following * |
||||
|
* location: <http://www.gnu.org/licenses/>. *
|
||||
|
****************************************************************************/ |
||||
|
|
||||
|
#include "../config.h" |
||||
|
|
||||
|
#if ENABLED(TOUCH_UI_FTDI_EVE) && defined(TOUCH_UI_COCOA_PRESS) |
||||
|
|
||||
|
#include "screens.h" |
||||
|
|
||||
|
using namespace FTDI; |
||||
|
using namespace ExtUI; |
||||
|
using namespace Theme; |
||||
|
|
||||
|
void PreheatMenu::onRedraw(draw_mode_t what) { |
||||
|
if (what & BACKGROUND) { |
||||
|
CommandProcessor cmd; |
||||
|
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color)) |
||||
|
.cmd(CLEAR(true,true,true)) |
||||
|
.tag(0); |
||||
|
} |
||||
|
|
||||
|
#define GRID_ROWS 3 |
||||
|
#define GRID_COLS 2 |
||||
|
|
||||
|
if (what & FOREGROUND) { |
||||
|
CommandProcessor cmd; |
||||
|
cmd.cmd(COLOR_RGB(bg_text_enabled)) |
||||
|
.font(Theme::font_medium) |
||||
|
.text ( BTN_POS(1,1), BTN_SIZE(2,1), GET_TEXT_F(MSG_PREHEAT_1)) |
||||
|
.colors(normal_btn) |
||||
|
.tag(2).button( BTN_POS(1,2), BTN_SIZE(1,1), F("Dark Chocolate")) |
||||
|
.tag(3).button( BTN_POS(2,2), BTN_SIZE(1,1), F("Milk Chocolate")) |
||||
|
.tag(4).button( BTN_POS(1,3), BTN_SIZE(1,1), F("White Chocolate")) |
||||
|
.colors(action_btn) |
||||
|
.tag(1) .button( BTN_POS(2,3), BTN_SIZE(1,1), GET_TEXT_F(MSG_BACK)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
bool PreheatMenu::onTouchEnd(uint8_t tag) { |
||||
|
switch (tag) { |
||||
|
case 1: GOTO_PREVIOUS(); break; |
||||
|
case 2: |
||||
|
#ifdef COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_SCRIPT |
||||
|
injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_SCRIPT)); |
||||
|
#endif |
||||
|
GOTO_SCREEN(PreheatTimerScreen); |
||||
|
break; |
||||
|
case 3: |
||||
|
#ifdef COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_SCRIPT |
||||
|
injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_SCRIPT)); |
||||
|
#endif |
||||
|
GOTO_SCREEN(PreheatTimerScreen); |
||||
|
break; |
||||
|
case 4: |
||||
|
#ifdef COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_SCRIPT |
||||
|
injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_SCRIPT)); |
||||
|
#endif |
||||
|
GOTO_SCREEN(PreheatTimerScreen); |
||||
|
break; |
||||
|
default: return false; |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
#endif // TOUCH_UI_FTDI_EVE
|
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue