Skip to content

Commit

Permalink
fix M109/M190 bug (bigtreetech#818)
Browse files Browse the repository at this point in the history
Co-authored-by: Msq001 <Msq001@gmail.com>
  • Loading branch information
Msq001 and Msq001 authored Jul 3, 2020
1 parent caf5836 commit 2ef4cc9
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 47 deletions.
2 changes: 1 addition & 1 deletion TFT/src/User/API/MachineParameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ void resetEepromSettings(void)
{
if(infoMachineSettings.EEPROM == 1)
mustStoreCmd("M502\nM500\n");
}
}
4 changes: 2 additions & 2 deletions TFT/src/User/API/MachineParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ float LinAdvance[1];

extern PARAMETERS infoParameters;

char *const axisDisplayID[STEPPER_COUNT];
extern char *const axisDisplayID[STEPPER_COUNT];
extern const LABEL accel_disp_ID[];
extern const LABEL retract_disp_ID[];
extern const LABEL recover_disp_ID[];
Expand Down Expand Up @@ -89,4 +89,4 @@ void restoreEepromSettings(void);
//reset settings and eeprom to default values
void resetEepromSettings(void);

#endif
#endif
2 changes: 1 addition & 1 deletion TFT/src/User/API/Printing.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ void loopCheckPrinting(void);



#endif
#endif
2 changes: 1 addition & 1 deletion TFT/src/User/API/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ void setupMachine(void);



#endif
#endif
2 changes: 1 addition & 1 deletion TFT/src/User/API/Temperature.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ void loopCheckHeater(void)
}
}
}
}
}
2 changes: 1 addition & 1 deletion TFT/src/User/API/Temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ void loopCheckHeater(void);



#endif
#endif
2 changes: 1 addition & 1 deletion TFT/src/User/API/UI/Numpad.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ int32_t numPadInt(u8* title, int32_t old_val, bool negative)
setLargeFont(false);
touchSound = true;
return old_val;
break;

case NUM_KEY_MINUS:
if (negative)
{
Expand Down
43 changes: 21 additions & 22 deletions TFT/src/User/API/interfaceCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,6 @@ void sendQueueCmd(void)
if(cmd_seen('E')) setParameter(P_STEPS_PER_MM, E_AXIS, cmd_float());
break;

case 104: //M104
if (fromTFT)
{
TOOL i = heatGetCurrentToolNozzle();
if(cmd_seen('T')) i = (TOOL)(cmd_value() + NOZZLE0);
if(cmd_seen('S'))
{
heatSyncTargetTemp(i, cmd_value());
}
else if (!cmd_seen('\n'))
{
char buf[12];
sprintf(buf, "S%u\n", heatGetTargetTemp(i));
strcat(infoCmd.queue[infoCmd.index_r].gcode,(const char*)buf);
heatSetSendWaiting(i, false);
}
}
break;

case 105: //M105
if (fromTFT)
{
Expand Down Expand Up @@ -510,7 +491,7 @@ void sendQueueCmd(void)
{
TOOL i = heatGetCurrentToolNozzle();
if(cmd_seen('T')) i = (TOOL)(cmd_value() + NOZZLE0);
infoCmd.queue[infoCmd.index_r].gcode[3]='4';
infoCmd.queue[infoCmd.index_r].gcode[3]='4'; // Avoid send M109 to Marlin
if (cmd_seen('R'))
{
infoCmd.queue[infoCmd.index_r].gcode[cmd_index-1] = 'S';
Expand All @@ -521,6 +502,24 @@ void sendQueueCmd(void)
heatSetIsWaiting(i, WAIT_HEATING);
}
}
// No break here, The data processing of M109 is the same as that of M104 below
case 104: //M104
if (fromTFT)
{
TOOL i = heatGetCurrentToolNozzle();
if(cmd_seen('T')) i = (TOOL)(cmd_value() + NOZZLE0);
if(cmd_seen('S'))
{
heatSyncTargetTemp(i, cmd_value());
}
else if (!cmd_seen('\n'))
{
char buf[12];
sprintf(buf, "S%u\n", heatGetTargetTemp(i));
strcat(infoCmd.queue[infoCmd.index_r].gcode,(const char*)buf);
heatSetSendWaiting(i, false);
}
}
break;

case 114: //M114
Expand Down Expand Up @@ -554,9 +553,9 @@ void sendQueueCmd(void)
case 190: //M190
if (fromTFT)
{
infoCmd.queue[infoCmd.index_r].gcode[2]='4'; // Avoid send M190 to Marlin
if (cmd_seen('R'))
{
infoCmd.queue[infoCmd.index_r].gcode[2]='4';
infoCmd.queue[infoCmd.index_r].gcode[cmd_index-1] = 'S';
heatSetIsWaiting(BED, WAIT_COOLING_HEATING);
}
Expand All @@ -565,7 +564,7 @@ void sendQueueCmd(void)
heatSetIsWaiting(BED, WAIT_HEATING);
}
}
break;
// No break here, The data processing of M190 is the same as that of M140 below
case 140: //M140
if (fromTFT)
{
Expand Down
8 changes: 4 additions & 4 deletions TFT/src/User/API/parseACK.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ void parseACK(void)
// parse temperature
if(ack_seen("T:") || ack_seen("T0:"))
{
heatSetCurrentTemp(NOZZLE0, ack_value()+0.5);
heatSetCurrentTemp(NOZZLE0, ack_value()+0.5f);
if(!heatGetSendWaiting(NOZZLE0)) {
heatSyncTargetTemp(NOZZLE0, ack_second_value()+0.5);
heatSyncTargetTemp(NOZZLE0, ack_second_value()+0.5f);
}
for(TOOL i = BED; i < HEATER_COUNT; i++)
{
if(ack_seen(toolID[i]))
{
heatSetCurrentTemp(i, ack_value()+0.5);
heatSetCurrentTemp(i, ack_value()+0.5f);
if(!heatGetSendWaiting(i)) {
heatSyncTargetTemp(i, ack_second_value()+0.5);
heatSyncTargetTemp(i, ack_second_value()+0.5f);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/printf/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,4 +914,4 @@ int fctprintf(void (*out)(char character, void* arg), void* arg, const char* for
const int ret = _vsnprintf(_out_fct, (char*)(uintptr_t)&out_fct_wrap, MAX_BUFFER_LENGTH, format, va);
va_end(va);
return ret;
}
}
4 changes: 2 additions & 2 deletions TFT/src/User/API/printf/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern "C" {
* \param character Character to output
*/
void _putchar(char character);

#define _putchar(n)

/**
* Tiny printf implementation
Expand Down Expand Up @@ -137,4 +137,4 @@ int fctprintf(void (*out)(char character, void* arg), void* arg, const char* for
#endif


#endif // _PRINTF_H_
#endif // _PRINTF_H_
1 change: 0 additions & 1 deletion TFT/src/User/Menu/FeatureSettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ void updateFeatureSettings(uint8_t key_val)

default:
return;
break;
}
featureSettingsItems.items[key_val] = settingPage[item_index];
}
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/Menu/Popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ void showDialog(DIALOG_TYPE type, u8 * title, u8 * msg, u8 *ok_txt, u8* cancel_t
}
if (infoMenu.menu[infoMenu.cur] != menuDialog)
infoMenu.menu[++infoMenu.cur] = menuDialog;
}
}
9 changes: 4 additions & 5 deletions TFT/src/User/Menu/ScreenSettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,12 @@ void menuScreenSettings(void)
{ICON_BACKGROUND, LABEL_BACKGROUND},
{ICON_BACK, LABEL_BACK},}
};
u8 item_silent_i = 0;
#ifdef ST7920_SPI
u8 item_marlin_bg_color_i = 0;
u8 item_marlin_font_color_i = 0;
#endif

KEY_VALUES key_num = KEY_IDLE;
SETTINGS now = infoSettings;

#ifdef BUZZER_PIN
u8 item_silent_i = 0;
for(u8 i = 0; i < ITEM_SILENT_NUM; i++)
{
if(infoSettings.silent == item_silent[i])
Expand All @@ -284,6 +281,8 @@ void menuScreenSettings(void)
#endif

#ifdef ST7920_SPI
u8 item_marlin_bg_color_i = 0;
u8 item_marlin_font_color_i = 0;
// LCD12864 background color
bool inArry = false;
for(u8 i = 0; i < LCD_COLOR_COUNT; i++)
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/SanityCheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ SIZE_CHECK( sizeof(STRINGS_STORE) > STRINGS_STORE_MAX_SIZE); // check size of st
SIZE_CHECK( sizeof(CUSTOM_GCODES) > CUSTOM_GCODE_MAX_SIZE); // check size of custom_gcodes is larger tha allocated size in flash.
SIZE_CHECK( sizeof(PRINT_GCODES) > PRINT_GCODES_MAX_SIZE); // check size of print_gcodes is larger tha allocated size in flash.

}
}
2 changes: 0 additions & 2 deletions TFT/src/User/delay.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#include "includes.h"

static u16 fac_ms=0;
static u8 fac_us=0;

void Delay_init(void)
{
SysTick->CTRL&=0xfffffffb; // bit2 is cleared, select external clock HCLK / 8
fac_us=mcuClocks.rccClocks.HCLK_Frequency/(8*1000000); // 8 Frequency after frequency division Unit M is 1us times
fac_ms=(u16)fac_us * 1000; // The number of times in 1ms is 1000 times of 1us
}

void Delay_us(u32 us) //Delay is less than 1800 * 1000us
Expand Down

0 comments on commit 2ef4cc9

Please sign in to comment.