Merge remote-tracking branch 'prusa3d/MK3_dev' into simplify_EEPROM_M500

Known limitation: Unable to compile.
This commit is contained in:
Marek Bel 2018-10-08 15:58:49 +02:00
parent 4151e19781
commit 1585dc66b0
32 changed files with 1226 additions and 1190 deletions

View File

@ -13,10 +13,11 @@ M500_conf cs;
#ifdef DEBUG_EEPROM_WRITE
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value), #value)
static void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size, char* name)
#else //DEBUG_EEPROM_WRITE
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value), 0)
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
static void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size)
#endif //DEBUG_EEPROM_WRITE
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size, char* name)
{
#ifdef DEBUG_EEPROM_WRITE
printf_P(PSTR("EEPROM_WRITE_VAR addr=0x%04x size=0x%02hhx name=%s\n"), pos, size, name);
@ -41,10 +42,11 @@ void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size, char* name)
#ifdef DEBUG_EEPROM_READ
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value), #value)
static void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size, char* name)
#else //DEBUG_EEPROM_READ
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value), 0)
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
static void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
#endif //DEBUG_EEPROM_READ
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size, char* name)
{
#ifdef DEBUG_EEPROM_READ
printf_P(PSTR("EEPROM_READ_VAR addr=0x%04x size=0x%02hhx name=%s\n"), pos, size, name);

View File

@ -34,7 +34,6 @@ void print_eeprom(uint16_t address, uint16_t count, uint8_t countperline = 16)
uint8_t count_line = countperline;
while (count && count_line)
{
uint8_t data = 0;
putchar(' ');
print_hex_byte(eeprom_read_byte((uint8_t*)address++));
count_line--;
@ -115,7 +114,7 @@ void dcode_3()
count = parse_hex(strchr_pointer + 1, data, 16);
if (count > 0)
{
for (int i = 0; i < count; i++)
for (uint16_t i = 0; i < count; i++)
eeprom_write_byte((uint8_t*)(address + i), data[i]);
printf_P(_N("%d bytes written to EEPROM at address 0x%04x"), count, address);
putchar('\n');

View File

@ -148,7 +148,7 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#else
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
#define disable_z() ;
#define disable_z() {}
#endif
#else
#ifdef Z_DUAL_STEPPER_DRIVERS
@ -160,8 +160,8 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#endif
#endif
#else
#define enable_z() ;
#define disable_z() ;
#define enable_z() {}
#define disable_z() {}
#endif
@ -278,6 +278,7 @@ extern float max_pos[3];
extern bool axis_known_position[3];
extern int fanSpeed;
extern void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0);
extern int8_t lcd_change_fil_state;
#ifdef FAN_SOFT_PWM
@ -328,10 +329,6 @@ extern uint8_t active_extruder;
#endif
//Long pause
extern int saved_feedmultiply;
extern float HotendTempBckp;
extern int fanSpeedBckp;
extern float pause_lastpos[4];
extern unsigned long pause_time;
extern unsigned long start_pause_print;
extern unsigned long t_fan_rising_edge;
@ -355,12 +352,14 @@ extern uint8_t print_percent_done_normal;
extern uint16_t print_time_remaining_normal;
extern uint8_t print_percent_done_silent;
extern uint16_t print_time_remaining_silent;
#define PRINT_TIME_REMAINING_INIT 0xffff
extern uint16_t mcode_in_progress;
extern uint16_t gcode_in_progress;
extern bool wizard_active; //autoload temporarily disabled during wizard
#define PRINT_TIME_REMAINING_INIT 0xffff
#define PRINT_PERCENT_DONE_INIT 0xff
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CUSTOM_MSG_TYPE_TEMCAL) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved)
@ -373,6 +372,7 @@ extern void delay_keep_alive(unsigned int ms);
extern void check_babystep();
extern void long_pause();
extern void crashdet_stop_and_save_print();
#ifdef DIS
@ -413,6 +413,9 @@ extern void print_world_coordinates();
extern void print_physical_coordinates();
extern void print_mesh_bed_leveling_table();
extern void stop_and_save_print_to_ram(float z_move, float e_move);
extern void restore_print_from_ram_and_continue(float e_move);
//estimated time to end of the print
extern uint16_t print_time_remaining();
@ -467,5 +470,5 @@ void proc_commands();
void M600_load_filament();
void M600_load_filament_movements();
void M600_wait_for_user();
void M600_wait_for_user(float HotendTempBckp);
void M600_check_state();

File diff suppressed because it is too large Load Diff

View File

@ -288,6 +288,76 @@ void CardReader::getAbsFilename(char *t)
else
t[0]=0;
}
/**
* @brief Dive into subfolder
*
* Method sets curDir to point to root, in case fileName is null.
* Method sets curDir to point to workDir, in case fileName path is relative
* (doesn't start with '/')
* Method sets curDir to point to dir, which is specified by absolute path
* specified by fileName. In such case fileName is updated so it points to
* file name without the path.
*
* @param[in,out] fileName
* expects file name including path
* in case of absolute path, file name without path is returned
* @param[in,out] dir SdFile object to operate with,
* in case of absolute path, curDir is modified to point to dir,
* so it is not possible to create on stack inside this function,
* as curDir would point to destroyed object.
*/
void CardReader::diveSubfolder (const char *fileName, SdFile& dir)
{
curDir=&root;
if (!fileName) return;
const char *dirname_start, *dirname_end;
if (fileName[0] == '/') // absolute path
{
dirname_start = fileName + 1;
while (*dirname_start)
{
dirname_end = strchr(dirname_start, '/');
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if (dirname_end && dirname_end > dirname_start)
{
const size_t maxLen = 12;
char subdirname[maxLen+1];
subdirname[maxLen] = 0;
const size_t len = ((static_cast<size_t>(dirname_end-dirname_start))>maxLen) ? maxLen : (dirname_end-dirname_start);
strncpy(subdirname, dirname_start, len);
SERIAL_ECHOLN(subdirname);
if (!dir.open(curDir, subdirname, O_READ))
{
SERIAL_PROTOCOLRPGM(_T(MSG_SD_OPEN_FILE_FAIL));
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
}
else
{
//SERIAL_ECHOLN("dive ok");
}
curDir = &dir;
dirname_start = dirname_end + 1;
}
else // the reminder after all /fsa/fdsa/ is the filename
{
fileName = dirname_start;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break;
}
}
}
else //relative path
{
curDir = &workDir;
}
}
void CardReader::openFile(const char* name,bool read, bool replace_current/*=true*/)
{
@ -340,53 +410,9 @@ void CardReader::openFile(const char* name,bool read, bool replace_current/*=tru
SdFile myDir;
curDir=&root;
const char *fname=name;
char *dirname_start,*dirname_end;
if(name[0]=='/')
{
dirname_start=strchr(name,'/')+1;
while(dirname_start>0)
{
dirname_end=strchr(dirname_start,'/');
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if(dirname_end>0 && dirname_end>dirname_start)
{
char subdirname[13];
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
subdirname[dirname_end-dirname_start]=0;
SERIAL_ECHOLN(subdirname);
if(!myDir.open(curDir,subdirname,O_READ))
{
SERIAL_PROTOCOLRPGM(_T(MSG_SD_OPEN_FILE_FAIL));
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
}
else
{
//SERIAL_ECHOLN("dive ok");
}
curDir=&myDir;
dirname_start=dirname_end+1;
}
else // the reminder after all /fsa/fdsa/ is the filename
{
fname=dirname_start;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break;
}
}
}
else //relative path
{
curDir=&workDir;
}
diveSubfolder(fname,myDir);
if(read)
{
if (file.open(curDir, fname, O_READ))
@ -431,60 +457,14 @@ void CardReader::openFile(const char* name,bool read, bool replace_current/*=tru
void CardReader::removeFile(const char* name)
{
if(!cardOK)
return;
file.close();
sdprinting = false;
SdFile myDir;
curDir=&root;
const char *fname=name;
char *dirname_start,*dirname_end;
if(name[0]=='/')
{
dirname_start=strchr(name,'/')+1;
while(dirname_start>0)
{
dirname_end=strchr(dirname_start,'/');
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if(dirname_end>0 && dirname_end>dirname_start)
{
char subdirname[13];
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
subdirname[dirname_end-dirname_start]=0;
SERIAL_ECHOLN(subdirname);
if(!myDir.open(curDir,subdirname,O_READ))
{
SERIAL_PROTOCOLRPGM("open failed, File: ");
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
}
else
{
//SERIAL_ECHOLN("dive ok");
}
curDir=&myDir;
dirname_start=dirname_end+1;
}
else // the reminder after all /fsa/fdsa/ is the filename
{
fname=dirname_start;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break;
}
}
}
else //relative path
{
curDir=&workDir;
}
if(!cardOK) return;
file.close();
sdprinting = false;
SdFile myDir;
const char *fname=name;
diveSubfolder(fname,myDir);
if (file.remove(curDir, fname))
{
SERIAL_PROTOCOLPGM("File deleted:");

View File

@ -154,6 +154,8 @@ private:
LsAction lsAction; //stored for recursion.
int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
char* diveDirName;
void diveSubfolder (const char *fileName, SdFile& dir);
void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
#ifdef SDCARD_SORT_ALPHA
void flush_presort();

View File

@ -453,7 +453,7 @@ EXTRACT_PACKAGE = NO
# included in the documentation.
# The default value is: NO.
EXTRACT_STATIC = NO
EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO,
@ -2421,7 +2421,7 @@ DIAFILE_DIRS =
# generate a warning when it encounters a \startuml command in this case and
# will not generate output for the diagram.
PLANTUML_JAR_PATH =
PLANTUML_JAR_PATH = /usr/share/plantuml/
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
# configuration file for plantuml.

View File

@ -7,6 +7,7 @@
#include "planner.h"
#include "fastio.h"
#include "cmdqueue.h"
#include "ultralcd.h"
#include "ConfigurationStore.h"
//Basic params
@ -28,10 +29,6 @@ const char ERRMSG_PAT9125_NOT_RESP[] PROGMEM = "PAT9125 not responding (%d)!\n";
#define FSENSOR_INT_PIN 63 //filament sensor interrupt pin PK1
#define FSENSOR_INT_PIN_MSK 0x02 //filament sensor interrupt pin mask (bit1)
extern void stop_and_save_print_to_ram(float z_move, float e_move);
extern void restore_print_from_ram_and_continue(float e_move);
extern int8_t FSensorStateMenu;
void fsensor_stop_and_save_print(void)
{
printf_P(PSTR("fsensor_stop_and_save_print\n"));
@ -102,9 +99,9 @@ uint16_t fsensor_oq_er_sum;
//max error counter value durring meassurement
uint8_t fsensor_oq_er_max;
//minimum delta value
uint16_t fsensor_oq_yd_min;
int16_t fsensor_oq_yd_min;
//maximum delta value
uint16_t fsensor_oq_yd_max;
int16_t fsensor_oq_yd_max;
//sum of shutter value
uint16_t fsensor_oq_sh_sum;
@ -219,7 +216,9 @@ bool fsensor_check_autoload(void)
fsensor_autoload_check_start();
return false;
}
#if 0
uint8_t fsensor_autoload_c_old = fsensor_autoload_c;
#endif
if ((millis() - fsensor_autoload_last_millis) < 25) return false;
fsensor_autoload_last_millis = millis();
if (!pat9125_update_y()) //update sensor
@ -244,9 +243,11 @@ bool fsensor_check_autoload(void)
else if (fsensor_autoload_c > 0)
fsensor_autoload_c--;
if (fsensor_autoload_c == 0) fsensor_autoload_sum = 0;
// puts_P(_N("fsensor_check_autoload\n"));
// if (fsensor_autoload_c != fsensor_autoload_c_old)
// printf_P(PSTR("fsensor_check_autoload dy=%d c=%d sum=%d\n"), dy, fsensor_autoload_c, fsensor_autoload_sum);
#if 0
puts_P(_N("fsensor_check_autoload\n"));
if (fsensor_autoload_c != fsensor_autoload_c_old)
printf_P(PSTR("fsensor_check_autoload dy=%d c=%d sum=%d\n"), dy, fsensor_autoload_c, fsensor_autoload_sum);
#endif
// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30))
if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20))
{
@ -427,6 +428,11 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
}
}
//! update (perform M600 on filament runout)
//!
//! Works only if filament sensor is enabled.
//! When the filament sensor error count is larger then FSENSOR_ERR_MAX, pauses print, tries to move filament back and forth.
//! If there is still no plausible signal from filament sensor plans M600 (Filament change).
void fsensor_update(void)
{
if (fsensor_enabled)
@ -449,19 +455,6 @@ void fsensor_update(void)
fsensor_err_cnt = 0;
fsensor_oq_meassure_start(0);
// st_synchronize();
// for (int axis = X_AXIS; axis <= E_AXIS; axis++)
// current_position[axis] = st_get_position_mm(axis);
/*
current_position[E_AXIS] -= 3;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 200 / 60, active_extruder);
st_synchronize();
current_position[E_AXIS] += 3;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 200 / 60, active_extruder);
st_synchronize();
*/
enquecommand_front_P((PSTR("G1 E-3 F200")));
process_commands();
cmdqueue_pop_front();

View File

@ -27,7 +27,6 @@ extern void fsensor_disable(void);
extern bool fsensor_autoload_enabled;
extern void fsensor_autoload_set(bool State);
//update (perform M600 on filament runout)
extern void fsensor_update(void);
//setup pin-change interrupt

View File

@ -56,7 +56,7 @@
#define LCD_5x8DOTS 0x00
FILE _lcdout = {0};
FILE _lcdout; // = {0}; Global variable is always zero initialized, no need to explicitly state that.
uint8_t lcd_rs_pin; // LOW: command. HIGH: character.
@ -157,7 +157,7 @@ uint8_t lcd_write(uint8_t value)
return 1; // assume sucess
}
void lcd_begin(uint8_t cols, uint8_t lines, uint8_t dotsize, uint8_t clear)
static void lcd_begin(uint8_t lines, uint8_t dotsize, uint8_t clear)
{
if (lines > 1) lcd_displayfunction |= LCD_2LINE;
lcd_numlines = lines;
@ -221,7 +221,7 @@ void lcd_begin(uint8_t cols, uint8_t lines, uint8_t dotsize, uint8_t clear)
lcd_escape[0] = 0;
}
int lcd_putchar(char c, FILE *stream)
int lcd_putchar(char c, FILE *)
{
lcd_write(c);
return 0;
@ -247,20 +247,20 @@ void lcd_init(void)
pinMode(lcd_enable_pin, OUTPUT);
if (fourbitmode) lcd_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
else lcd_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
lcd_begin(LCD_WIDTH, LCD_HEIGHT, LCD_5x8DOTS, 1);
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 1);
//lcd_clear();
fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream
}
void lcd_refresh(void)
{
lcd_begin(LCD_WIDTH, LCD_HEIGHT, LCD_5x8DOTS, 1);
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 1);
lcd_set_custom_characters();
}
void lcd_refresh_noclear(void)
{
lcd_begin(LCD_WIDTH, LCD_HEIGHT, LCD_5x8DOTS, 0);
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 0);
lcd_set_custom_characters();
}
@ -506,7 +506,6 @@ uint8_t lcd_escape_write(uint8_t chr)
break;
}
escape_cnt = 0; // reset escape
end:
return 1; // assume sucess
}
@ -684,10 +683,22 @@ ShortTimer longPressTimer;
LongTimer lcd_timeoutToStatus;
//! @brief Was button clicked?
//!
//! Consume click event, following call would return 0.
//! See #LCD_CLICKED macro for version not consuming the event.
//!
//! Generally is used in modal dialogs.
//!
//! @retval 0 not clicked
//! @retval nonzero clicked
uint8_t lcd_clicked(void)
{
bool clicked = LCD_CLICKED;
if(clicked) lcd_button_pressed = 0;
if(clicked)
{
lcd_consume_click();
}
return clicked;
}
@ -695,7 +706,7 @@ void lcd_beeper_quick_feedback(void)
{
SET_OUTPUT(BEEPER);
//-//
Sound_MakeSound(e_SOUND_CLASS_Echo,e_SOUND_TYPE_ButtonEcho);
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
/*
for(int8_t i = 0; i < 10; i++)
{
@ -710,7 +721,7 @@ Sound_MakeSound(e_SOUND_CLASS_Echo,e_SOUND_TYPE_ButtonEcho);
void lcd_quick_feedback(void)
{
lcd_draw_update = 2;
lcd_button_pressed = false;
lcd_button_pressed = false;
lcd_beeper_quick_feedback();
}
@ -727,7 +738,6 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
lcd_draw_update = lcdDrawUpdateOverride;
if (!lcd_update_enabled)
return;
lcd_buttons_update();
if (lcd_lcdupdate_func)
lcd_lcdupdate_func();
}
@ -761,57 +771,45 @@ void lcd_update_enable(uint8_t enabled)
extern LongTimer safetyTimer;
void lcd_buttons_update(void)
{
static bool _lock = false;
if (_lock) return;
_lock = true;
uint8_t newbutton = 0;
if (READ(BTN_EN1) == 0) newbutton |= EN_A;
if (READ(BTN_EN2) == 0) newbutton |= EN_B;
if (lcd_update_enabled)
{ //if we are in non-modal mode, long press can be used and short press triggers with button release
if (READ(BTN_ENC) == 0)
{ //button is pressed
lcd_timeoutToStatus.start();
if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
buttonBlanking.start();
safetyTimer.start();
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
{
longPressTimer.start();
lcd_button_pressed = 1;
}
else
{
if (longPressTimer.expired(LONG_PRESS_TIME))
{
lcd_long_press_active = 1;
if (lcd_longpress_func)
lcd_longpress_func();
}
}
}
}
else
{ //button not pressed
if (lcd_button_pressed)
{ //button was released
buttonBlanking.start();
if (lcd_long_press_active == 0)
{ //button released before long press gets activated
newbutton |= EN_C;
}
//else if (menu_menu == lcd_move_z) lcd_quick_feedback();
//lcd_button_pressed is set back to false via lcd_quick_feedback function
}
else
lcd_long_press_active = 0;
}
}
else
{ //we are in modal mode
if (READ(BTN_ENC) == 0)
newbutton |= EN_C;
}
if (READ(BTN_ENC) == 0)
{ //button is pressed
lcd_timeoutToStatus.start();
if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
buttonBlanking.start();
safetyTimer.start();
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
{
//long press is not possible in modal mode
if (lcd_update_enabled) longPressTimer.start();
lcd_button_pressed = 1;
}
else if (longPressTimer.expired(LONG_PRESS_TIME))
{
lcd_long_press_active = 1;
if (lcd_longpress_func)
lcd_longpress_func();
}
}
}
else
{ //button not pressed
if (lcd_button_pressed)
{ //button was released
buttonBlanking.start();
if (lcd_long_press_active == 0)
{ //button released before long press gets activated
newbutton |= EN_C;
}
//else if (menu_menu == lcd_move_z) lcd_quick_feedback();
//lcd_button_pressed is set back to false via lcd_quick_feedback function
}
else
lcd_long_press_active = 0;
}
lcd_buttons = newbutton;
//manage encoder rotation
@ -849,7 +847,6 @@ void lcd_buttons_update(void)
}
}
lcd_encoder_bits = enc;
_lock = false;
}

View File

@ -1,4 +1,4 @@
//lcd.h
//! @file
#ifndef _LCD_H
#define _LCD_H
@ -131,7 +131,6 @@ extern lcd_lcdupdate_func_t lcd_lcdupdate_func;
extern uint8_t lcd_clicked(void);
extern void lcd_beeper_quick_feedback(void);
//Cause an LCD refresh, and give the user visual or audible feedback that something has happened
@ -150,6 +149,29 @@ extern void lcd_update_enable(uint8_t enabled);
extern void lcd_buttons_update(void);
//! @brief Helper class to temporarily disable LCD updates
//!
//! When constructed (on stack), original state state of lcd_update_enabled is stored
//! and LCD updates are disabled.
//! When destroyed (gone out of scope), original state of LCD update is restored.
//! It has zero overhead compared to storing bool saved = lcd_update_enabled
//! and calling lcd_update_enable(false) and lcd_update_enable(saved).
class LcdUpdateDisabler
{
public:
LcdUpdateDisabler(): m_updateEnabled(lcd_update_enabled)
{
lcd_update_enable(false);
}
~LcdUpdateDisabler()
{
lcd_update_enable(m_updateEnabled);
}
private:
bool m_updateEnabled;
};
@ -187,7 +209,16 @@ extern void lcd_buttons_update(void);
#define EN_A (1<<BLEN_A)
#define BLEN_C 2
#define EN_C (1<<BLEN_C)
//! @brief Was button clicked?
//!
//! Doesn't consume button click event. See lcd_clicked()
//! for function consuming the event.
//!
//! Generally is used in non-modal menus.
//!
//! @retval 0 button was not clicked
//! @retval 1 button was clicked
#define LCD_CLICKED (lcd_buttons&EN_C)
////////////////////////
@ -221,6 +252,12 @@ extern void lcd_set_custom_characters_progress(void);
extern void lcd_set_custom_characters_nextpage(void);
extern void lcd_set_custom_characters_degree(void);
//! @brief Consume click event
inline void lcd_consume_click()
{
lcd_button_pressed = 0;
lcd_buttons &= 0xff^EN_C;
}
#endif //_LCD_H

View File

@ -236,6 +236,7 @@ uint8_t menu_item_function_P(const char* str, menu_func_t func)
if (menu_clicked && (lcd_encoder == menu_item))
{
menu_clicked = false;
lcd_consume_click();
lcd_update_enabled = 0;
if (func) func();
lcd_update_enabled = 1;

View File

@ -132,7 +132,7 @@ const float bed_ref_points[] PROGMEM = {
static inline float sqr(float x) { return x * x; }
#ifdef HEATBED_V2
static inline bool point_on_1st_row(const uint8_t i)
static inline bool point_on_1st_row(const uint8_t /*i*/)
{
return false;
}
@ -147,7 +147,7 @@ static inline bool point_on_1st_row(const uint8_t i)
// The first row of points may not be fully reachable
// and the y values may be shortened a bit by the bed carriage
// pulling the belt up.
static inline float point_weight_x(const uint8_t i, const uint8_t npts, const float &y)
static inline float point_weight_x(const uint8_t i, const float &y)
{
float w = 1.f;
if (point_on_1st_row(i)) {
@ -169,7 +169,7 @@ static inline float point_weight_x(const uint8_t i, const uint8_t npts, const fl
// The first row of points may not be fully reachable
// and the y values may be shortened a bit by the bed carriage
// pulling the belt up.
static inline float point_weight_y(const uint8_t i, const uint8_t npts, const float &y)
static inline float point_weight_y(const uint8_t i, const float &y)
{
float w = 1.f;
if (point_on_1st_row(i)) {
@ -209,7 +209,10 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
float *vec_x,
float *vec_y,
float *cntr,
int8_t verbosity_level
int8_t
#ifdef SUPPORT_VERBOSITY
verbosity_level
#endif //SUPPORT_VERBOSITY
)
{
float angleDiff;
@ -291,7 +294,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
(c == 0) ? 1.f :
((c == 2) ? (-s1 * measured_pts[2 * i]) :
(-c2 * measured_pts[2 * i + 1]));
float w = point_weight_x(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_x(i, measured_pts[2 * i + 1]);
acc += a * b * w;
}
// Second for the residuum in the y axis.
@ -306,7 +309,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
(c == 1) ? 1.f :
((c == 2) ? ( c1 * measured_pts[2 * i]) :
(-s2 * measured_pts[2 * i + 1]));
float w = point_weight_y(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_y(i, measured_pts[2 * i + 1]);
acc += a * b * w;
}
}
@ -322,7 +325,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
((r == 2) ? (-s1 * measured_pts[2 * i]) :
(-c2 * measured_pts[2 * i + 1])));
float fx = c1 * measured_pts[2 * i] - s2 * measured_pts[2 * i + 1] + cntr[0] - pgm_read_float(true_pts + i * 2);
float w = point_weight_x(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_x(i, measured_pts[2 * i + 1]);
acc += j * fx * w;
}
{
@ -332,7 +335,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
((r == 2) ? ( c1 * measured_pts[2 * i]) :
(-s2 * measured_pts[2 * i + 1])));
float fy = s1 * measured_pts[2 * i] + c2 * measured_pts[2 * i + 1] + cntr[1] - pgm_read_float(true_pts + i * 2 + 1);
float w = point_weight_y(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_y(i, measured_pts[2 * i + 1]);
acc += j * fy * w;
}
}
@ -453,7 +456,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
#ifdef SUPPORT_VERBOSITY
if(verbosity_level >= 20) SERIAL_ECHOPGM("Point on first row");
#endif // SUPPORT_VERBOSITY
float w = point_weight_y(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_y(i, measured_pts[2 * i + 1]);
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X ||
(w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y)) {
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
@ -550,7 +553,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
for (int8_t i = 0; i < npts; ++ i) {
float x = vec_x[0] * measured_pts[i * 2] + vec_y[0] * measured_pts[i * 2 + 1];
float y = vec_x[1] * measured_pts[i * 2] + vec_y[1] * measured_pts[i * 2 + 1];
float w = point_weight_x(i, npts, y);
float w = point_weight_x(i, y);
cntr[0] += w * (pgm_read_float(true_pts + i * 2) - x);
wx += w;
#ifdef SUPPORT_VERBOSITY
@ -567,7 +570,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
MYSERIAL.print(wx);
}
#endif // SUPPORT_VERBOSITY
w = point_weight_y(i, npts, y);
w = point_weight_y(i, y);
cntr[1] += w * (pgm_read_float(true_pts + i * 2 + 1) - y);
wy += w;
#ifdef SUPPORT_VERBOSITY
@ -960,7 +963,11 @@ static inline void update_current_position_z()
}
// At the current position, find the Z stop.
inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int verbosity_level)
inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
#ifdef SUPPORT_VERBOSITY
verbosity_level
#endif //SUPPORT_VERBOSITY
)
{
#ifdef TMC2130
FORCE_HIGH_POWER_START;
@ -1047,7 +1054,11 @@ extern bool xyzcal_find_bed_induction_sensor_point_xy();
#endif //HEATBED_V2
#ifdef HEATBED_V2
inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
inline bool find_bed_induction_sensor_point_xy(int
#if !defined (NEW_XYZCAL) && defined (SUPPORT_VERBOSITY)
verbosity_level
#endif
)
{
#ifdef NEW_XYZCAL
return xyzcal_find_bed_induction_sensor_point_xy();

View File

@ -21,7 +21,7 @@ static inline bool vec_undef(const float v[2])
return vx[0] == 0x0FFFFFFFF || vx[1] == 0x0FFFFFFFF;
}
void mesh_bed_leveling::get_meas_xy(int ix, int iy, float &x, float &y, bool use_default)
void mesh_bed_leveling::get_meas_xy(int ix, int iy, float &x, float &y, bool /*use_default*/)
{
#if 0
float cntr[2] = {

View File

@ -29,12 +29,13 @@ bool mmu_enabled = false;
bool mmu_ready = false;
int8_t mmu_state = 0;
static int8_t mmu_state = 0;
uint8_t mmu_cmd = 0;
uint8_t mmu_extruder = 0;
//! This variable probably has no meaning and is planed to be removed
uint8_t tmp_extruder = 0;
int8_t mmu_finda = -1;
@ -494,15 +495,11 @@ void mmu_M600_wait_and_beep() {
void mmu_M600_load_filament(bool automatic)
{
//load filament for mmu v2
bool response = false;
bool yes = false;
tmp_extruder = mmu_extruder;
if (!automatic) {
#ifdef MMU_M600_SWITCH_EXTRUDER
yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
bool yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
if(yes) tmp_extruder = choose_extruder_menu();
else tmp_extruder = mmu_extruder;
#endif //MMU_M600_SWITCH_EXTRUDER
}
else {
@ -541,7 +538,11 @@ void extr_mov(float shift, float feed_rate)
}
void change_extr(int extr) { //switches multiplexer for extruders
void change_extr(int
#ifdef SNMM
extr
#endif //SNMM
) { //switches multiplexer for extruders
#ifdef SNMM
st_synchronize();
delay(100);
@ -1011,23 +1012,24 @@ void mmu_eject_filament(uint8_t filament, bool recover)
if (degHotend0() > EXTRUDE_MINTEMP)
{
st_synchronize();
lcd_update_enable(false);
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_i("Ejecting filament"));
current_position[E_AXIS] -= 80;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
st_synchronize();
lcd_update_enable(true);
mmu_command(MMU_CMD_E0 + filament);
manage_response(false, false);
if (recover)
{
lcd_show_fullscreen_message_and_wait_P(_i("Please remove filament and then press the knob."));
mmu_command(MMU_CMD_R0);
manage_response(false, false);
}
LcdUpdateDisabler disableLcdUpdate;
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_i("Ejecting filament"));
current_position[E_AXIS] -= 80;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
st_synchronize();
mmu_command(MMU_CMD_E0 + filament);
manage_response(false, false);
if (recover)
{
lcd_show_fullscreen_message_and_wait_P(_i("Please remove filament and then press the knob."));
mmu_command(MMU_CMD_R0);
manage_response(false, false);
}
}
}
else
{

View File

@ -5,8 +5,6 @@
extern bool mmu_enabled;
extern int8_t mmu_state;
extern uint8_t mmu_extruder;
extern uint8_t tmp_extruder;

View File

@ -272,7 +272,6 @@ void optiboot_w25x20cl_enter()
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
uint32_t addr = (((uint32_t)rampz) << 16) | address;
uint8_t desttype;
register pagelen_t i;
// Read the page length, with the length transferred each nibble separately to work around
// the Prusa's USB to serial infamous semicolon issue.
@ -280,8 +279,8 @@ void optiboot_w25x20cl_enter()
length |= ((pagelen_t)getch()) << 8;
length |= getch();
length |= getch();
// Read the destination type. It should always be 'F' as flash.
desttype = getch();
// Read the destination type. It should always be 'F' as flash. It is not checked.
(void)getch();
verifySpace();
w25x20cl_wait_busy();
w25x20cl_rd_data(addr, buff, length);

View File

@ -872,22 +872,22 @@ block->steps_y.wide = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-p
enable_e0();
g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[1] == 0) disable_e1();
if(g_uc_extruder_last_move[2] == 0) disable_e2();
if(g_uc_extruder_last_move[1] == 0) {disable_e1();}
if(g_uc_extruder_last_move[2] == 0) {disable_e2();}
break;
case 1:
enable_e1();
g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[0] == 0) disable_e0();
if(g_uc_extruder_last_move[2] == 0) disable_e2();
if(g_uc_extruder_last_move[0] == 0) {disable_e0();}
if(g_uc_extruder_last_move[2] == 0) {disable_e2();}
break;
case 2:
enable_e2();
g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[0] == 0) disable_e0();
if(g_uc_extruder_last_move[1] == 0) disable_e1();
if(g_uc_extruder_last_move[0] == 0) {disable_e0();}
if(g_uc_extruder_last_move[1] == 0) {disable_e1();}
break;
}
}

View File

@ -85,8 +85,8 @@ void sm4_set_dir(uint8_t axis, uint8_t dir)
uint8_t sm4_get_dir_bits(void)
{
uint8_t register dir_bits = 0;
uint8_t register portL = PORTL;
register uint8_t dir_bits = 0;
register uint8_t portL = PORTL;
//TODO -optimize in asm
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
if (portL & 2) dir_bits |= 1;
@ -106,7 +106,7 @@ uint8_t sm4_get_dir_bits(void)
void sm4_set_dir_bits(uint8_t dir_bits)
{
uint8_t register portL = PORTL;
register uint8_t portL = PORTL;
portL &= 0xb8; //set direction bits to zero
//TODO -optimize in asm
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
@ -129,7 +129,7 @@ void sm4_set_dir_bits(uint8_t dir_bits)
void sm4_do_step(uint8_t axes_mask)
{
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3) || (MOTHERBOARD == BOARD_EINSY_1_0a))
uint8_t register portC = PORTC & 0xf0;
register uint8_t portC = PORTC & 0xf0;
PORTC = portC | (axes_mask & 0x0f); //set step signals by mask
asm("nop");
PORTC = portC; //set step signals to zero

View File

@ -59,7 +59,7 @@ switch(eSoundMode)
Sound_SaveMode();
}
void Sound_MakeSound(eSOUND_CLASS eSoundClass,eSOUND_TYPE eSoundType)
void Sound_MakeSound(eSOUND_TYPE eSoundType)
{
switch(eSoundMode)
{

View File

@ -26,7 +26,7 @@ extern void Sound_Init(void);
extern void Sound_Default(void);
extern void Sound_Save(void);
extern void Sound_CycleState(void);
extern void Sound_MakeSound(eSOUND_CLASS eSoundClass,eSOUND_TYPE eSoundType);
extern void Sound_MakeSound(eSOUND_TYPE eSoundType);
//static void Sound_DoSound_Echo(void);
//static void Sound_DoSound_Prompt(void);

View File

@ -107,8 +107,6 @@ static bool z_endstop_invert = false;
volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
uint8_t LastStepMask = 0;
#ifdef LIN_ADVANCE
static uint16_t nextMainISR = 0;
@ -720,7 +718,6 @@ FORCE_INLINE void stepper_tick_lowres()
counter_x.lo += current_block->steps_x.lo;
if (counter_x.lo > 0) {
WRITE_NC(X_STEP_PIN, !INVERT_X_STEP_PIN);
LastStepMask |= X_AXIS_MASK;
#ifdef DEBUG_XSTEP_DUP_PIN
WRITE_NC(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
#endif //DEBUG_XSTEP_DUP_PIN
@ -735,7 +732,6 @@ FORCE_INLINE void stepper_tick_lowres()
counter_y.lo += current_block->steps_y.lo;
if (counter_y.lo > 0) {
WRITE_NC(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
LastStepMask |= Y_AXIS_MASK;
#ifdef DEBUG_YSTEP_DUP_PIN
WRITE_NC(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
#endif //DEBUG_YSTEP_DUP_PIN
@ -750,7 +746,6 @@ FORCE_INLINE void stepper_tick_lowres()
counter_z.lo += current_block->steps_z.lo;
if (counter_z.lo > 0) {
WRITE_NC(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
LastStepMask |= Z_AXIS_MASK;
counter_z.lo -= current_block->step_event_count.lo;
count_position[Z_AXIS]+=count_direction[Z_AXIS];
WRITE_NC(Z_STEP_PIN, INVERT_Z_STEP_PIN);
@ -785,7 +780,6 @@ FORCE_INLINE void stepper_tick_highres()
counter_x.wide += current_block->steps_x.wide;
if (counter_x.wide > 0) {
WRITE_NC(X_STEP_PIN, !INVERT_X_STEP_PIN);
LastStepMask |= X_AXIS_MASK;
#ifdef DEBUG_XSTEP_DUP_PIN
WRITE_NC(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
#endif //DEBUG_XSTEP_DUP_PIN
@ -800,7 +794,6 @@ FORCE_INLINE void stepper_tick_highres()
counter_y.wide += current_block->steps_y.wide;
if (counter_y.wide > 0) {
WRITE_NC(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
LastStepMask |= Y_AXIS_MASK;
#ifdef DEBUG_YSTEP_DUP_PIN
WRITE_NC(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
#endif //DEBUG_YSTEP_DUP_PIN
@ -815,7 +808,6 @@ FORCE_INLINE void stepper_tick_highres()
counter_z.wide += current_block->steps_z.wide;
if (counter_z.wide > 0) {
WRITE_NC(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
LastStepMask |= Z_AXIS_MASK;
counter_z.wide -= current_block->step_event_count.wide;
count_position[Z_AXIS]+=count_direction[Z_AXIS];
WRITE_NC(Z_STEP_PIN, INVERT_Z_STEP_PIN);
@ -853,8 +845,6 @@ FORCE_INLINE void isr() {
if (current_block == NULL)
stepper_next_block();
LastStepMask = 0;
if (current_block != NULL)
{
stepper_check_endstops();
@ -1079,7 +1069,7 @@ FORCE_INLINE void isr() {
}
#ifdef TMC2130
tmc2130_st_isr(LastStepMask);
tmc2130_st_isr();
#endif //TMC2130
//WRITE_NC(LOGIC_ANALYZER_CH0, false);
@ -1434,13 +1424,10 @@ void babystep(const uint8_t axis,const bool direction)
//perform step
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
LastStepMask |= X_AXIS_MASK;
#ifdef DEBUG_XSTEP_DUP_PIN
WRITE(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
#endif //DEBUG_XSTEP_DUP_PIN
{
volatile float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
}
delayMicroseconds(1);
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
#ifdef DEBUG_XSTEP_DUP_PIN
WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
@ -1460,13 +1447,10 @@ void babystep(const uint8_t axis,const bool direction)
//perform step
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
LastStepMask |= Y_AXIS_MASK;
#ifdef DEBUG_YSTEP_DUP_PIN
WRITE(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
#endif //DEBUG_YSTEP_DUP_PIN
{
volatile float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
}
delayMicroseconds(1);
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
#ifdef DEBUG_YSTEP_DUP_PIN
WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
@ -1489,14 +1473,10 @@ void babystep(const uint8_t axis,const bool direction)
#endif
//perform step
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
LastStepMask |= Z_AXIS_MASK;
#ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
#endif
//wait a tiny bit
{
volatile float x=1./float(axis+1); //absolutely useless
}
delayMicroseconds(1);
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
#ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
@ -1516,16 +1496,16 @@ void babystep(const uint8_t axis,const bool direction)
}
#endif //BABYSTEPPING
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
void digitalPotWrite(int address, int value) // From Arduino DigitalPotControl example
{
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
digitalWrite(DIGIPOTSS_PIN,LOW); // take the SS pin low to select the chip
SPI.transfer(address); // send in the address and value via SPI:
SPI.transfer(value);
digitalWrite(DIGIPOTSS_PIN,HIGH); // take the SS pin high to de-select the chip:
//delay(10);
#endif
}
#endif
void EEPROM_read_st(int pos, uint8_t* value, uint8_t size)
{
@ -1569,19 +1549,19 @@ uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
#ifdef MOTOR_CURRENT_PWM_XY_PIN
void st_current_set(uint8_t driver, int current)
{
#ifdef MOTOR_CURRENT_PWM_XY_PIN
if (driver == 0) analogWrite(MOTOR_CURRENT_PWM_XY_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
if (driver == 1) analogWrite(MOTOR_CURRENT_PWM_Z_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
if (driver == 2) analogWrite(MOTOR_CURRENT_PWM_E_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
#endif
}
#else //MOTOR_CURRENT_PWM_XY_PIN
void st_current_set(uint8_t, int ){}
#endif //MOTOR_CURRENT_PWM_XY_PIN
void microstep_init()
{
const uint8_t microstep_modes[] = MICROSTEP_MODES;
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
pinMode(E1_MS1_PIN,OUTPUT);
@ -1589,6 +1569,7 @@ void microstep_init()
#endif
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
const uint8_t microstep_modes[] = MICROSTEP_MODES;
pinMode(X_MS1_PIN,OUTPUT);
pinMode(X_MS2_PIN,OUTPUT);
pinMode(Y_MS1_PIN,OUTPUT);

View File

@ -90,10 +90,12 @@ extern bool x_min_endstop;
extern bool x_max_endstop;
extern bool y_min_endstop;
extern bool y_max_endstop;
extern volatile long count_position[NUM_AXIS];
void quickStop();
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
void digitalPotWrite(int address, int value);
#endif //defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
void microstep_mode(uint8_t driver, uint8_t stepping);
void st_current_init();

View File

@ -175,7 +175,6 @@ static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
static float analog2temp(int raw, uint8_t e);
static float analog2tempBed(int raw);
static float analog2tempAmbient(int raw);
static float analog2tempPINDA(int raw);
static void updateTemperaturesFromRawValues();
enum TempRunawayStates
@ -493,9 +492,6 @@ void checkFanSpeed()
}
}
extern void stop_and_save_print_to_ram(float z_move, float e_move);
extern void restore_print_from_ram_and_continue(float e_move);
void fanSpeedError(unsigned char _fan) {
if (get_message_level() != 0 && isPrintPaused) return;
//to ensure that target temp. is not set to zero in case taht we are resuming print
@ -504,8 +500,7 @@ void fanSpeedError(unsigned char _fan) {
lcd_print_stop();
}
else {
isPrintPaused = true;
lcd_sdcard_pause();
lcd_pause_print();
}
}
else {
@ -928,35 +923,6 @@ static float analog2tempBed(int raw) {
#endif
}
#ifdef PINDA_THERMISTOR
static float analog2tempPINDA(int raw) {
float celsius = 0;
byte i;
for (i = 1; i<BEDTEMPTABLE_LEN; i++)
{
if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw)
{
celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) +
(raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) *
(float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) /
(float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0]));
break;
}
}
// Overflow: Set to last value in the table
if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
return celsius;
}
#endif //PINDA_THERMISTOR
#ifdef AMBIENT_THERMISTOR
static float analog2tempAmbient(int raw)
{

View File

@ -13,12 +13,6 @@
#define TMC2130_GCONF_SGSENS 0x00003180 // spreadCycle with stallguard (stall activates DIAG0 and DIAG1 [pushpull])
#define TMC2130_GCONF_SILENT 0x00000004 // stealthChop
//externals for debuging
extern float current_position[4];
extern void st_get_position_xy(long &x, long &y);
extern long st_get_position(uint8_t axis);
extern void crashdet_stop_and_save_print();
extern void crashdet_stop_and_save_print2();
//mode
uint8_t tmc2130_mode = TMC2130_MODE_NORMAL;
@ -236,7 +230,7 @@ uint8_t tmc2130_sample_diag()
extern bool is_usb_printing;
void tmc2130_st_isr(uint8_t last_step_mask)
void tmc2130_st_isr()
{
if (tmc2130_mode == TMC2130_MODE_SILENT || tmc2130_sg_stop_on_crash == false) return;
uint8_t crash = 0;
@ -793,7 +787,7 @@ void tmc2130_do_steps(uint8_t axis, uint16_t steps, uint8_t dir, uint16_t delay_
void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_us, uint16_t microstep_resolution)
{
printf_P(PSTR("tmc2130_goto_step %d %d %d %d \n"), axis, step, dir, delay_us, microstep_resolution);
uint8_t shift; for (shift = 0; shift < 8; shift++) if (microstep_resolution == (256 >> shift)) break;
uint8_t shift; for (shift = 0; shift < 8; shift++) if (microstep_resolution == (256u >> shift)) break;
uint16_t cnt = 4 * (1 << (8 - shift));
uint16_t mscnt = tmc2130_rd_MSCNT(axis);
if (dir == 2)
@ -805,7 +799,7 @@ void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_u
dir ^= 1;
steps = -steps;
}
if (steps > (cnt / 2))
if (steps > static_cast<int>(cnt / 2))
{
dir ^= 1;
steps = cnt - steps;
@ -830,7 +824,7 @@ void tmc2130_get_wave(uint8_t axis, uint8_t* data, FILE* stream)
tmc2130_setup_chopper(axis, tmc2130_usteps2mres(256), tmc2130_current_h[axis], tmc2130_current_r[axis]);
tmc2130_goto_step(axis, 0, 2, 100, 256);
tmc2130_set_dir(axis, tmc2130_get_inv(axis)?0:1);
for (int i = 0; i <= 255; i++)
for (unsigned int i = 0; i <= 255; i++)
{
uint32_t val = tmc2130_rd_MSCURACT(axis);
uint16_t mscnt = tmc2130_rd_MSCNT(axis);
@ -847,6 +841,7 @@ void tmc2130_get_wave(uint8_t axis, uint8_t* data, FILE* stream)
delayMicroseconds(100);
}
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
tmc2130_set_pwr(axis, pwr);
}
void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000)
@ -869,7 +864,7 @@ void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000)
int8_t b; //encoded bit value
int8_t dA; //delta value
int i; //microstep index
uint32_t reg; //tmc2130 register
uint32_t reg = 0; //tmc2130 register
tmc2130_wr_MSLUTSTART(axis, 0, amp);
for (i = 0; i < 256; i++)
{

View File

@ -53,7 +53,7 @@ extern tmc2130_chopper_config_t tmc2130_chopper_config[4];
//initialize tmc2130
extern void tmc2130_init();
//check diag pins (called from stepper isr)
extern void tmc2130_st_isr(uint8_t last_step_mask);
extern void tmc2130_st_isr();
//update stall guard (called from st_synchronize inside the loop)
extern bool tmc2130_update_sg();
//temperature watching (called from )

View File

@ -16,7 +16,7 @@ uint8_t uart2_ibuf[14] = {0, 0};
FILE _uart2io = {0};
int uart2_putchar(char c, FILE *stream)
int uart2_putchar(char c, FILE *stream __attribute__((unused)))
{
while (!uart2_txready);
UDR2 = c; // transmit byte
@ -25,7 +25,7 @@ int uart2_putchar(char c, FILE *stream)
return 0;
}
int uart2_getchar(FILE *stream)
int uart2_getchar(FILE *stream __attribute__((unused)))
{
if (rbuf_empty(uart2_ibuf)) return -1;
return rbuf_get(uart2_ibuf);

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
#include "lcd.h"
#include "conv2str.h"
#include "menu.h"
#include "mesh_bed_calibration.h"
extern int lcd_puts_P(const char* str);
extern int lcd_printf_P(const char* format, ...);
@ -31,7 +32,8 @@ void lcd_loading_filament();
void lcd_change_success();
void lcd_loading_color();
void lcd_sdcard_stop();
void lcd_sdcard_pause();
void lcd_pause_print();
void lcd_resume_print();
void lcd_print_stop();
void prusa_statistics(int _message, uint8_t _col_nr = 0);
void lcd_confirm_print();
@ -50,6 +52,8 @@ extern void lcd_wait_for_click();
extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
// 0: no, 1: yes, -1: timeouted
extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
extern int8_t lcd_show_multiscreen_message_two_choices_and_wait_P(const char *msg, bool allow_timeouting, bool default_yes,
const char *first_choice, const char *second_choice);
extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
// Ask the user to move the Z axis up to the end stoppers and let
// the user confirm that it has been done.
@ -59,7 +63,7 @@ extern bool lcd_calibrate_z_end_stop_manual(bool only_z);
#endif
// Show the result of the calibration process on the LCD screen.
extern void lcd_bed_calibration_show_result(uint8_t result, uint8_t point_too_far_mask);
extern void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, uint8_t point_too_far_mask);
extern void lcd_diag_show_end_stops();
@ -76,11 +80,11 @@ extern void lcd_diag_show_end_stops();
#define LCD_COMMAND_STOP_PRINT 2
#define LCD_COMMAND_FARM_MODE_CONFIRM 4
#define LCD_COMMAND_LONG_PAUSE 5
#define LCD_COMMAND_LONG_PAUSE_RESUME 6
#define LCD_COMMAND_PID_EXTRUDER 7
#define LCD_COMMAND_V2_CAL 8
extern int lcd_commands_type;
extern int8_t FSensorStateMenu;
#define CUSTOM_MSG_TYPE_STATUS 0 // status message from lcd_status_message variable
#define CUSTOM_MSG_TYPE_MESHBL 1 // Mesh bed leveling in progress
@ -150,7 +154,7 @@ bool lcd_wait_for_pinda(float temp);
void bowden_menu();
char reset_menu();
char choose_extruder_menu();
uint8_t choose_menu_P(const char *header, const char *item, const char *last_item = nullptr);
void lcd_pinda_calibration_menu();
void lcd_calibrate_pinda();
@ -166,6 +170,26 @@ void lcd_set_progress();
void lcd_language();
void lcd_wizard();
void lcd_wizard(int state);
//! @brief Wizard state
enum class WizState : uint8_t
{
Run, //!< run wizard? Entry point.
Restore, //!< restore calibration status
Selftest,
Xyz, //!< xyz calibration
Z, //!< z calibration
IsFil, //!< Is filament loaded? Entry point for 1st layer calibration
PreheatPla, //!< waiting for preheat nozzle for PLA
Preheat, //!< Preheat for any material
Unload, //!< Unload filament
LoadFil, //!< Load filament
IsPla, //!< Is PLA filament?
Lay1Cal, //!< First layer calibration
RepeatLay1Cal, //!< Repeat first layer calibration?
Finish, //!< Deactivate wizard
};
void lcd_wizard(WizState state);
#endif //ULTRALCD_H

View File

@ -32,8 +32,6 @@
#define _PI 3.14159265F
extern volatile long count_position[NUM_AXIS];
uint8_t check_pinda_0();
uint8_t check_pinda_1();
void xyzcal_update_pos(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de);
@ -87,7 +85,7 @@ uint8_t check_pinda_1()
uint8_t xyzcal_dm = 0;
void xyzcal_update_pos(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de)
void xyzcal_update_pos(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t)
{
// DBG(_n("xyzcal_update_pos dx=%d dy=%d dz=%d dir=%02x\n"), dx, dy, dz, xyzcal_dm);
if (xyzcal_dm&1) count_position[0] -= dx; else count_position[0] += dx;
@ -108,11 +106,9 @@ uint16_t xyzcal_sm4_ac2 = (uint32_t)xyzcal_sm4_ac * 1024 / 10000;
//float xyzcal_sm4_vm = 10000;
#endif //SM4_ACCEL_TEST
#ifdef SM4_ACCEL_TEST
uint16_t xyzcal_calc_delay(uint16_t nd, uint16_t dd)
{
return xyzcal_sm4_delay;
#ifdef SM4_ACCEL_TEST
uint16_t del_us = 0;
if (xyzcal_sm4_v & 0xf000) //>=4096
{
@ -138,9 +134,13 @@ uint16_t xyzcal_calc_delay(uint16_t nd, uint16_t dd)
// return xyzcal_sm4_delay;
// DBG(_n("xyzcal_calc_delay nd=%d dd=%d v=%d del_us=%d\n"), nd, dd, xyzcal_sm4_v, del_us);
return 0;
#endif //SM4_ACCEL_TEST
}
#else //SM4_ACCEL_TEST
uint16_t xyzcal_calc_delay(uint16_t, uint16_t)
{
return xyzcal_sm4_delay;
}
#endif //SM4_ACCEL_TEST
bool xyzcal_lineXYZ_to(int16_t x, int16_t y, int16_t z, uint16_t delay_us, int8_t check_pinda)
{
@ -285,7 +285,7 @@ void xyzcal_scan_pixels_32x32(int16_t cx, int16_t cy, int16_t min_z, int16_t max
xyzcal_lineXYZ_to(cx, cy, z, 2*delay_us, 0);
for (uint8_t r = 0; r < 32; r++)
{
int8_t _pinda = _PINDA;
// int8_t _pinda = _PINDA;
xyzcal_lineXYZ_to((r&1)?(cx+1024):(cx-1024), cy - 1024 + r*64, z, 2*delay_us, 0);
xyzcal_lineXYZ_to(_X, _Y, min_z, delay_us, 1);
xyzcal_lineXYZ_to(_X, _Y, max_z, delay_us, -1);
@ -330,7 +330,7 @@ void xyzcal_scan_pixels_32x32(int16_t cx, int16_t cy, int16_t min_z, int16_t max
}
sm4_do_step(X_AXIS_MASK);
delayMicroseconds(600);
_pinda = pinda;
// _pinda = pinda;
}
sum >>= 6; //div 64
if (z_sum < 0)

View File

@ -2,8 +2,7 @@
1. install `"Arduino Software IDE"` for your preferred operating system
`https://www.arduino.cc -> Software->Downloads`
it is strongly recommended to use older version `"1.6.9"`, by which we can assure correct compilation results
_note: in versions `1.7.x` and `1.8.x` there are known some C/C++ compilator disasters, which disallow correct source code compilation (you can obtain `"... internal compiler error: in extract_insn, at ..."` error message, for example); we are not able to affect this situation afraid_
it is recommended to use older version `"1.6.9"`, as it is used on out build server to produce official builds.
_note: in the case of persistent compilation problems, check the version of the currently used C/C++ compiler (GCC) - should be `4.8.1`; version can be verified by entering the command
`avr-gcc --version`
if you are not sure where the file is placed (depends on how `"Arduino Software IDE"` was installed), you can use the search feature within the file system_
@ -26,8 +25,10 @@ _note: select this item for any variant of board used in printers `'Prusa i3 MKx
'clicking' the item will display the installation button; select choice `"1.0.1"` from the list(last known version as of the date of issue of this document)
_(after installation, the item is labeled as `"INSTALLED"` and can then be used for target board selection)_
3. modify platform.txt to enable float printf support:
`"compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"`
3. modify platform.txt to enable float printf support:
add "-Wl,-u,vfprintf -lprintf_flt -lm" to "compiler.c.elf.flags=" before existing flag "-Wl,--gc-sections"
example:
`"compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"`
# 2. Source code compilation

View File

@ -2,8 +2,7 @@
1. nainstalujte vývojové prostředí `"Arduino Software IDE"` pro operační prostředí, které jste zvyklí používat
`https://www.arduino.cc -> Software->Downloads`
důrazně doporučujeme použít starší verzi `"1.6.8"`, u které jsme schopni garantovat bezproblémový překlad a správné výsledky
_pozn.: ve verzích `1.7.x` a `1.8.x` jsou k datu vydání tohoto dokumentu evidovány chyby v překladači jazyka C/C++, které znemožňují překlad zdrojového kódu (můžete např. obdržet chybové hlášení `"... internal compiler error: in extract_insn, at ..."`); tuto nepříjemnou situaci bohužel nedokážeme nijak ovlivnit_
doporučujeme použít starší verzi `"1.6.9"`, kterou používáme na našem build serveru pro překlad oficiálních buildů
_pozn.: v případě přetrvávajících potíží s překladem zkontrolujte verzi aktuálně použitého překladače jazyka C/C++ (GCC) - měla by být `4.8.1`; verzi ověříte zadáním příkazu
`avr-gcc --version`
pokud si nejste jisti umístěním souboru (závisí na způsobu, jakým bylo `"Arduino Software IDE"` nainstalováno), použijte funkci vyhledání v rámci systému souborů_
@ -26,6 +25,10 @@ _pozn.: tuto položku zvolte pro všechny varianty desek použitých v tiskárn
'kliknutím' na položku se zobrazí tlačítko pro instalaci; ve výběrovém seznamu zvolte verzi `"1.0.1"` (poslední známá verze k datu vydání tohoto dokumentu)
_(po provedení instalace je položka označena poznámkou `"INSTALLED"` a lze ji následně použít při výběru cílové desky)_
3. modify platform.txt to enable float printf support:
add "-Wl,-u,vfprintf -lprintf_flt -lm" to "compiler.c.elf.flags=" before existing flag "-Wl,--gc-sections"
example:
`"compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"`
# 2. Překlad zdrojoveho kódu