Skip to content

Commit

Permalink
resolves #1377 + cleanup (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
digant73 authored Dec 15, 2020
1 parent 04faecd commit d0593f5
Show file tree
Hide file tree
Showing 68 changed files with 877 additions and 707 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Copy to SD Card root directory to update/BIQU_TFT28_V1.0.26.x.bin
Binary file not shown.
Binary file not shown.
Binary file modified Copy to SD Card root directory to update/BIQU_TFT35_V1.0.26.x.bin
Binary file not shown.
Binary file modified Copy to SD Card root directory to update/BIQU_TFT35_V1.1.26.x.bin
Binary file not shown.
Binary file modified Copy to SD Card root directory to update/BIQU_TFT35_V1.2.26.x.bin
Binary file not shown.
Binary file modified Copy to SD Card root directory to update/MKSTFT28.bin
Binary file not shown.
Binary file modified Copy to SD Card root directory to update/MKS_32_V1_4.26.x.bin
Binary file not shown.
10 changes: 10 additions & 0 deletions Copy to SD Card root directory to update/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,16 @@ lcd_idle_brightness:5
#
lcd_idle_delay:4

#### Enable Print Summary Popup
# This will enable a popup at print end.
# The popup shows the approximate print time and approximate filament used.
# Displayed values are calculated by approximation and may differ from the actual values.
# When enabled also the menu jumps to the status screen after the popup
#
# Options: [enable: 1, disable: 0]
#
print_summary:1


#--------------------------------------------------------------------
# Custom Gcode Commands
Expand Down
13 changes: 13 additions & 0 deletions TFT/src/User/API/BabystepControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ float babystepResetValue(void)
for (; step_count > 0; step_count--)
{
mustStoreCmd("M290 Z%.2f\n", -(BABYSTEP_MAX_UNIT * neg));

processed_baby_step += BABYSTEP_MAX_UNIT;
}

last_unit = (babystep_value * neg) - processed_baby_step;
if (last_unit > 0.0f)
{
mustStoreCmd("M290 Z%.2f\n", -(last_unit * neg));

processed_baby_step += last_unit;
}

babystep_value -= (processed_baby_step * neg);

return babystep_value;
}

Expand All @@ -55,10 +58,14 @@ float babystepDecreaseValue(float unit)
if (babystep_value > BABYSTEP_MIN_VALUE)
{
float diff = babystep_value - BABYSTEP_MIN_VALUE;

unit = (diff > unit) ? unit : diff;

mustStoreCmd("M290 Z-%.2f\n", unit);

babystep_value -= unit;
}

return babystep_value;
}

Expand All @@ -68,20 +75,26 @@ float babystepIncreaseValue(float unit)
if (babystep_value < BABYSTEP_MAX_VALUE)
{
float diff = BABYSTEP_MAX_VALUE - babystep_value;

unit = (diff > unit) ? unit : diff;

mustStoreCmd("M290 Z%.2f\n", unit);

babystep_value += unit;
}

return babystep_value;
}

// Update babystep value by encoder
float babystepUpdateValueByEncoder(float unit, int8_t direction)
{
float overall_unit = (direction > 0) ? (direction * unit) : (-direction * unit); // always positive unit

if (direction < 0) // if negative encoder value, decrease the value. Otherwise increase the value
babystepDecreaseValue(overall_unit);
else
babystepIncreaseValue(overall_unit);

return babystep_value;
}
5 changes: 3 additions & 2 deletions TFT/src/User/API/FanControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ uint8_t fanType[MAX_FAN_COUNT];
static uint8_t desiredFanSpeed[MAX_FAN_COUNT] = {0};
static uint8_t newFanSpeed[MAX_FAN_COUNT] = {0};
static uint8_t curFanSpeed[MAX_FAN_COUNT] = {0};

static bool fan_send_waiting[MAX_FAN_COUNT] = {false};
static bool fanQueryWait = false;
static bool fanQueryEnable = false;

static uint32_t nextFanTime = 0;

#define NEXT_FAN_WAIT 500 // 1 second is 1000

uint8_t fanGetTypID(uint8_t startIndex, uint8_t type)
Expand Down Expand Up @@ -153,8 +155,7 @@ void loopFan(void)

void fanSpeedQuery(void)
{
if (fanQueryEnable && infoHost.connected &&
!infoHost.wait && !fanQueryWait)
if (infoHost.connected && !infoHost.wait && !fanQueryWait && fanQueryEnable)
{
storeCmd("M710\n");
fanQueryWait = true;
Expand Down
6 changes: 2 additions & 4 deletions TFT/src/User/API/Notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ bool toastAvailable(void)
{
for (int i = 0; i < TOAST_MSG_COUNT; i++)
{
if(toastlist[i].isNew == true)
return true;
if (toastlist[i].isNew == true)
return true;
}
return false;
}
Expand Down Expand Up @@ -121,11 +121,9 @@ void loopToast(void)
else if(_toastRunning == true)
{
_toastRunning = false;

GUI_ClearPrect(&toastIconRect);
GUI_ClearPrect(&toastRect);
menuReDrawCurTitle();

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions TFT/src/User/API/ProbeHeightControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ void probeHeightDisable(void)
}

/* Start probe height */
void probeHeightStart(void)
void probeHeightStart(float initialHeight)
{
mustStoreCmd("G90\n"); // set absolute position mode
mustStoreCmd("G1 Z0\n"); // move nozzle to Z0 absolute point
mustStoreCmd("G1 Z%.2f\n", initialHeight); // move nozzle to provided absolute Z point

mustStoreCmd("G91\n"); // set relative position mode
}
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/ProbeHeightControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void probeHeightEnable(void);
void probeHeightDisable(void);

/* Start probe height */
void probeHeightStart(void);
void probeHeightStart(float initialHeight);

/* Stop probe height */
void probeHeightStop(void);
Expand Down
14 changes: 11 additions & 3 deletions TFT/src/User/API/ProbeOffsetControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ static float z_offset_value = PROBE_OFFSET_DEFAULT_VALUE;
static bool probe_offset_enabled = false;

/* Enable probe offset */
void probeOffsetEnable(void)
void probeOffsetEnable(bool skipZOffset)
{
probe_offset_enabled = true;

Expand All @@ -20,9 +20,17 @@ void probeOffsetEnable(void)
mustStoreCmd("G1 X%.2f Y%.2f F%d\n",
getParameter(P_PROBE_OFFSET, X_STEPPER),
getParameter(P_PROBE_OFFSET, Y_STEPPER),
infoSettings.axis_speed[infoSettings.move_speed]); // move nozzle to X and Y probing coordinates and set feedrate
infoSettings.axis_speed[infoSettings.move_speed]); // move nozzle to XY probing coordinates and set feedrate

probeHeightStart(); // lower nozzle to Z0 point
if (!skipZOffset)
{
probeHeightStart(0.0f); // lower nozzle to absolute Z0 point
}
else
{
probeHeightStart(-probeOffsetGetValue()); // lower nozzle to probing Z0 point
probeOffsetSetValue(0.0f); // reset Z offset in order probing Z0 matches absolute Z0 point
}
}

/* Disable probe offset */
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/ProbeOffsetControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {
#include <stdint.h>

/* Enable probe offset */
void probeOffsetEnable(void);
void probeOffsetEnable(bool skipZOffset);

/* Disable probe offset */
void probeOffsetDisable(void);
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const u8 default_custom_enabled[] = CUSTOM_GCODE_ENABLED;
void infoSettingsReset(void)
{
// General Settings
infoSettings.status_screen = ENABLE_STATUS_SCREEN;
infoSettings.status_screen = ENABLE_STATUS_SCREEN;
infoSettings.baudrate = BAUDRATE;
infoSettings.language = LANG_DEFAULT;

Expand Down
7 changes: 4 additions & 3 deletions TFT/src/User/API/SpeedControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "includes.h"

const char *const speedCmd[SPEED_NUM] = {"M220","M221"};

static uint16_t percent[SPEED_NUM] = {100, 100}; //Speed Flow
static uint16_t lastPercent[SPEED_NUM] = {100, 100}; //Speed Flow
static uint16_t curPercent[SPEED_NUM] = {100, 100}; //Speed Flow
Expand Down Expand Up @@ -55,14 +56,14 @@ bool SpeedChanged(u8 i)

void loopSpeed(void)
{
for (u8 i = 0; i < SPEED_NUM;i++)
for (u8 i = 0; i < SPEED_NUM; i++)
{
if ((curPercent[i] != percent[i]) && (OS_GetTimeMs() > nextSpeedTime))
{
if (send_waiting[i] == false)
{
send_waiting[i] = true;
send_waiting[i] = storeCmd("%s S%d\n",speedCmd[i], percent[i]);
send_waiting[i] = storeCmd("%s S%d\n", speedCmd[i], percent[i]);
}
if (send_waiting[i] == true)
curPercent[i] = percent[i];
Expand All @@ -73,7 +74,7 @@ void loopSpeed(void)

void speedQuery(void)
{
if (infoHost.connected == true && infoHost.wait == false && !queryWait)
if (infoHost.connected && !infoHost.wait && !queryWait)
{
storeCmd("M220\nM221\n");
queryWait = true;
Expand Down
24 changes: 12 additions & 12 deletions TFT/src/User/API/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,13 +960,12 @@ void parseConfigKey(u16 index)
#ifdef PS_ON_PIN

case C_INDEX_PS_ON:
if (config_int() == 1)
infoSettings.auto_off = 1;
else if(config_int() == 2)
infoSettings.auto_off = 2;
else
infoSettings.auto_off = 0;
break;
{
u8 i = config_int();
if (inLimit(i,0,2))
infoSettings.auto_off = i;
break;
}

case C_INDEX_PS_LOGIC:
infoSettings.powerloss_invert = getOnOff();
Expand Down Expand Up @@ -1006,11 +1005,12 @@ void parseConfigKey(u16 index)

#ifdef FIL_RUNOUT_PIN
case C_INDEX_RUNOUT:
if (inLimit(config_int(),0,2))
{
infoSettings.runout = config_int();
}
break;
{
u8 i = config_int();
if (inLimit(i,0,2))
infoSettings.runout = i;
break;
}

case C_INDEX_RUNOUT_LOGIC:
infoSettings.runout_invert = getOnOff();
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/Hal/STM32_USB_HOST_Library/Usr/src/usb_bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE * pdev)
// EXTI_InitTypeDef EXTI_InitStructure;
#ifdef STM32F10X_CL

#if defined(MKS_32_V1_4) || defined (MKS_28_V1_0)
#if defined(MKS_32_V1_4) || defined (MKS_28_V1_0)
RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div2);
#else
RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3);
Expand Down
18 changes: 9 additions & 9 deletions TFT/src/User/Hal/stm32f10x/Serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void Serial_Config(uint8_t port, u32 baud)
dmaL1Data[port].rIndex = dmaL1Data[port].wIndex = 0;
dmaL1Data[port].cache = malloc(dmaL1Data[port].cacheSize);
while(!dmaL1Data[port].cache); // malloc failed
UART_Config(port, baud, USART_IT_IDLE); //IDLE interrupt
UART_Config(port, baud, USART_IT_IDLE); // IDLE interrupt
Serial_DMA_Config(port);
}

Expand Down Expand Up @@ -114,27 +114,27 @@ void USART_IRQHandler(uint8_t port)

void USART1_IRQHandler(void)
{
USART_IRQHandler(_USART1);
USART_IRQHandler(_USART1);
}

void USART2_IRQHandler(void)
{
USART_IRQHandler(_USART2);
USART_IRQHandler(_USART2);
}

void USART3_IRQHandler(void)
{
USART_IRQHandler(_USART3);
USART_IRQHandler(_USART3);
}

void UART4_IRQHandler(void)
{
USART_IRQHandler(_UART4);
USART_IRQHandler(_UART4);
}

void UART5_IRQHandler(void)
{
USART_IRQHandler(_UART5);
USART_IRQHandler(_UART5);
}

void Serial_Puts(uint8_t port, char *s)
Expand All @@ -149,7 +149,7 @@ void Serial_Puts(uint8_t port, char *s)
#include "stdio.h"
int fputc(int ch, FILE *f)
{
while((Serial[SERIAL_PORT].uart->SR&0X40)==0);
Serial[SERIAL_PORT].uart->DR = (u8) ch;
return ch;
while((Serial[SERIAL_PORT].uart->SR&0X40) == 0);
Serial[SERIAL_PORT].uart->DR = (u8) ch;
return ch;
}
18 changes: 9 additions & 9 deletions TFT/src/User/Hal/stm32f2_f4xx/Serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,32 @@ void USART_IRQHandler(uint8_t port)

void USART1_IRQHandler(void)
{
USART_IRQHandler(_USART1);
USART_IRQHandler(_USART1);
}

void USART2_IRQHandler(void)
{
USART_IRQHandler(_USART2);
USART_IRQHandler(_USART2);
}

void USART3_IRQHandler(void)
{
USART_IRQHandler(_USART3);
USART_IRQHandler(_USART3);
}

void UART4_IRQHandler(void)
{
USART_IRQHandler(_UART4);
USART_IRQHandler(_UART4);
}

void UART5_IRQHandler(void)
{
USART_IRQHandler(_UART5);
USART_IRQHandler(_UART5);
}

void USART6_IRQHandler(void)
{
USART_IRQHandler(_USART6);
USART_IRQHandler(_USART6);
}

void Serial_Puts(uint8_t port, char *s)
Expand All @@ -184,7 +184,7 @@ void Serial_Puts(uint8_t port, char *s)
#include "stdio.h"
int fputc(int ch, FILE *f)
{
while((Serial[SERIAL_PORT].uart->SR&0X40)==0);
Serial[SERIAL_PORT].uart->DR = (u8) ch;
return ch;
while((Serial[SERIAL_PORT].uart->SR&0X40) == 0);
Serial[SERIAL_PORT].uart->DR = (u8) ch;
return ch;
}
Loading

0 comments on commit d0593f5

Please sign in to comment.