Misc. improvements (#12747)
* Make ExtUI respect MAXTEMP limits - Temperatures are now clamped by MAXTEMP limits rather than arbitrary values. * Speed up USB init, add status - Speed up USB initialization - Show status message if init failed * Enable status messages for EXTENSIBLE_UI * Adjust max limit to MAX_TEMP - 15 * Misc. tweaks to formatting, const, etc.
This commit is contained in:
committed by
Scott Lahteine
parent
4f2473053c
commit
60cb36bef3
@@ -31,6 +31,10 @@
|
||||
|
||||
#include "Sd2Card_FlashDrive.h"
|
||||
|
||||
#if ENABLED(ULTRA_LCD) || ENABLED(EXTENSIBLE_UI)
|
||||
#include "../../lcd/ultralcd.h"
|
||||
#endif
|
||||
|
||||
USB usb;
|
||||
BulkOnly bulk(&usb);
|
||||
|
||||
@@ -46,25 +50,27 @@ void Sd2Card::idle() {
|
||||
|
||||
switch (state) {
|
||||
case USB_HOST_DELAY_INIT:
|
||||
next_retry = millis() + 10000;
|
||||
next_retry = millis() + 2000;
|
||||
state = USB_HOST_WAITING;
|
||||
break;
|
||||
case USB_HOST_WAITING:
|
||||
if (ELAPSED(millis(), next_retry)) {
|
||||
next_retry = millis() + 10000;
|
||||
next_retry = millis() + 2000;
|
||||
state = USB_HOST_UNINITIALIZED;
|
||||
}
|
||||
break;
|
||||
case USB_HOST_UNINITIALIZED:
|
||||
SERIAL_ECHOLNPGM("Starting USB host");
|
||||
SERIAL_ECHOPGM("Starting USB host...");
|
||||
if (!usb.start()) {
|
||||
SERIAL_ECHOLNPGM("USB host failed to start. Will retry in 10 seconds.");
|
||||
SERIAL_ECHOPGM(" Failed. Retrying in 2s.");
|
||||
#if ENABLED(ULTRA_LCD) || ENABLED(EXTENSIBLE_UI)
|
||||
LCD_MESSAGEPGM("USB start failed");
|
||||
#endif
|
||||
state = USB_HOST_DELAY_INIT;
|
||||
}
|
||||
else {
|
||||
SERIAL_ECHOLNPGM("USB host initialized");
|
||||
else
|
||||
state = USB_HOST_INITIALIZED;
|
||||
}
|
||||
SERIAL_EOL();
|
||||
break;
|
||||
case USB_HOST_INITIALIZED:
|
||||
const uint8_t lastUsbTaskState = usb.getUsbTaskState();
|
||||
@@ -91,10 +97,10 @@ void Sd2Card::idle() {
|
||||
// This is equivalent to polling the SD_DETECT when using SD cards.
|
||||
bool Sd2Card::isInserted() {
|
||||
return usb.getUsbTaskState() == USB_STATE_RUNNING;
|
||||
};
|
||||
}
|
||||
|
||||
// Marlin calls this to initialize an SD card once it is inserted.
|
||||
bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
|
||||
bool Sd2Card::init(const uint8_t sckRateID/*=0*/, const pin_t chipSelectPin/*=SD_CHIP_SELECT_PIN*/) {
|
||||
if (!ready()) return false;
|
||||
|
||||
if (!bulk.LUNIsGood(0)) {
|
||||
@@ -121,7 +127,7 @@ uint32_t Sd2Card::cardSize() {
|
||||
#ifndef USB_DEBUG
|
||||
const uint32_t
|
||||
#endif
|
||||
lun0_capacity = bulk.GetCapacity(0);
|
||||
lun0_capacity = bulk.GetCapacity(0);
|
||||
return lun0_capacity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user