Skip to content

Commit

Permalink
Fixed no boot on TFT GD variants + cleanup (#2885)
Browse files Browse the repository at this point in the history
  • Loading branch information
digant73 committed Jan 23, 2024
1 parent fca6044 commit 863de9b
Show file tree
Hide file tree
Showing 37 changed files with 688 additions and 698 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This patcher uploads a bootloader that changes the long beep of the bootloader o

Usage:
Put it on the SD card as any other regular FW file and boot your printer with the SD inserted.
During the update you'll see a red dot and a progress bar. The progress bar will let you know when the upload of the patched FW is finished. Also, at the end of the patched bootloader flash procedure the red dot will change into a blinking green dot. That's when you can eject the SD card and copy your favorite FW file to be flashed over this bootloader patcher FW.
During the update you'll see a red dot and a progress bar. The progress bar will let you know when the upload of the patched bootloaders is finished. Also, at the end of the patched bootloader flash procedure the red dot will change into a blinking green dot. That's when you can eject the SD card and copy to it your favorite FW file to be flashed over this bootloader patcher FW, reinsert the SD Card into the TFT and reboot it.

Attention!!! This is not a functional FW, it's only for uploading the patched bootloader, you must reupload your regular favorite FW after the bootloader patching FW has done its job.

Expand Down
17 changes: 9 additions & 8 deletions TFT/src/User/API/FlashStore.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#include "FlashStore.h"
#include "Touch_Screen.h"
#include "Settings.h"
#include "HAL_Flash.h"
#include <string.h>

#ifdef I2C_EEPROM // added I2C_EEPROM suppport for MKS_TFT35_V1_0
#include "i2c_eeprom.h"
#endif

#define TSC_SIGN 0x20200512 // DO NOT MODIFY
#define PARA_SIGN 0x20220321 // (YYYYMMDD) If a new setting parameter is added,
// modify here and initialize the initial value
// in the "initSettings()" function
#define TSC_SIGN 0x20200512 // (YYYYMMDD) DO NOT MODIFY (Touch Screem Calibration sign)
#define PARA_SIGN 0x20220321 // (YYYYMMDD) if a new setting parameter is added, modify here and
// initialize the initial value in the "initSettings()" function
enum
{
PARA_TSC_EXIST = (1 << 0),
Expand Down Expand Up @@ -57,9 +58,9 @@ void readStoredPara(void)
if (sign == TSC_SIGN)
{
paraStatus |= PARA_TSC_EXIST; // if the touch screen calibration parameter already exists
for (int i = 0; i < sizeof(TSC_Para) / sizeof(TSC_Para[0]); i++)
for (int i = 0; i < sizeof(TS_CalPara) / sizeof(TS_CalPara[0]); i++)
{
TSC_Para[i] = byteToWord(data + (index += 4), 4);
TS_CalPara[i] = byteToWord(data + (index += 4), 4);
}
}

Expand All @@ -82,9 +83,9 @@ void storePara(void)
uint32_t index = 0;

wordToByte(TSC_SIGN, data + (index += 4));
for (int i = 0; i < sizeof(TSC_Para) / sizeof(TSC_Para[0]); i++)
for (int i = 0; i < sizeof(TS_CalPara) / sizeof(TS_CalPara[0]); i++)
{
wordToByte(TSC_Para[i], data + (index += 4));
wordToByte(TS_CalPara[i], data + (index += 4));
}

wordToByte(PARA_SIGN, data + (index += 4));
Expand Down
5 changes: 0 additions & 5 deletions TFT/src/User/API/FlashStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ extern "C" {
#endif

#include <stdbool.h>
#include <stdint.h>
#include "Settings.h"

#define PARA_SIZE (128 * 3) // max size of settings buffer to read/write

extern int32_t TSC_Para[7];
extern SETTINGS infoSettings;

void readStoredPara(void); // read settings parameter if exist, or reset settings parameter
void storePara(void);
bool readIsTSCExist(void);
Expand Down
4 changes: 2 additions & 2 deletions TFT/src/User/API/HW_Init.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void HW_Init(void)
#endif

XPT2046_Init();
OS_TimerInitMs(); // system clock timer, cycle 1ms, called after XPT2046_Init()
OS_InitTimerMs(); // system clock timer, cycle 1ms, called after XPT2046_Init()
W25Qxx_Init();
LCD_Init();

Expand Down Expand Up @@ -105,7 +105,7 @@ void HW_Init(void)
if (readIsTSCExist() == false) // read settings parameter
{
LCD_RefreshDirection(infoSettings.rotated_ui);
TSC_Calibration();
TS_Calibrate();
storePara();
}
else if (readIsNotStored())
Expand Down
6 changes: 3 additions & 3 deletions TFT/src/User/API/LCD_Dimming.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ void LCD_CheckDimming(void)
if (infoSettings.lcd_idle_time == IDLE_TIME_OFF)
return;

if (isPress()
if (TS_IsPressed()
#if LCD_ENCODER_SUPPORT
|| LCD_Enc_CheckState()
#endif
)
{
if (lcd_dim.dimmed)
{
if (infoSettings.lcd_lock_on_idle && isPress()) // if touch is blocked on idle and pressing on the LCD (not on the encoder),
lcd_dim.locked = true; // the first touch will be skipped preventing to trigger any undesired action
if (infoSettings.lcd_lock_on_idle && TS_IsPressed()) // if touch is blocked on idle and pressing on the LCD (not on the encoder),
lcd_dim.locked = true; // the first touch will be skipped preventing to trigger any undesired action

lcd_dim.dimmed = false;
LCD_SET_BRIGHTNESS(lcd_brightness[infoSettings.lcd_brightness]);
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/PowerFailed.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void powerFailedSetDriverSource(void)

bool powerFailedLoad(FIL *print_fp)
{
// set status flag status first
// set status flag first
load_ok = false;
restore_ok = false;

Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/RRFM20Parser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "RRFM20Parser.hpp"
#include "FlashStore.h"
#include "includes.h"

/*
Parses a document like the following for M20 S2
Expand Down
1 change: 1 addition & 0 deletions TFT/src/User/API/RRFSendCmd.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "RRFM20Parser.hpp"
#include "includes.h"

static uint32_t line_number = 0;
Expand Down
11 changes: 4 additions & 7 deletions TFT/src/User/API/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,19 @@ extern "C" {
#include "coordinate.h" // for TOTAL_AXIS
#include "LED_Colors.h" // for LED_COLOR_COMPONENT_COUNT

// Config version support (format YYYYMMDD)
// change if new elements/keywords are added/removed/changed in the Configuration.h
// this number should match CONFIG_VERSION in Configuration.h
#define CONFIG_SUPPPORT 20231119

#define FONT_FLASH_SIGN 20230821 // (YYYYMMDD) change if fonts require updating
#define CONFIG_SUPPPORT 20231119 // (YYYYMMDD) change if any keyword(s) is Configuration.h is added, removed or changed.
// This number should match CONFIGURATION_H_VERSION in Configuration.h
#define CONFIG_FLASH_SIGN 20230929 // (YYYYMMDD) change if any keyword(s) in config.ini is added or removed
#define LANGUAGE_FLASH_SIGN 20230821 // (YYYYMMDD) change if any keyword(s) in language pack is added or removed
#define ICON_FLASH_SIGN 20230821 // (YYYYMMDD) change if any icon(s) is added or removed
#define FONT_FLASH_SIGN 20230821 // (YYYYMMDD) change if fonts require updating

#define FONT_CHECK_SIGN (FONT_FLASH_SIGN + WORD_UNICODE_ADDR + FLASH_SIGN_ADDR)
#define CONFIG_CHECK_SIGN (CONFIG_FLASH_SIGN + STRINGS_STORE_ADDR + \
sizeof(SETTINGS) + sizeof(STRINGS_STORE) + sizeof(PREHEAT_STORE) + \
sizeof(CUSTOM_GCODES) + sizeof(PRINT_GCODES))
#define LANGUAGE_CHECK_SIGN (LANGUAGE_FLASH_SIGN + LANGUAGE_ADDR + LABEL_NUM)
#define ICON_CHECK_SIGN (ICON_FLASH_SIGN + ICON_ADDR(0) + ICON_PREVIEW)
#define FONT_CHECK_SIGN (FONT_FLASH_SIGN + WORD_UNICODE_ADDR + FLASH_SIGN_ADDR)

#define MAX_SERIAL_PORT_COUNT 4
#define MAX_EXT_COUNT 6
Expand Down
4 changes: 2 additions & 2 deletions TFT/src/User/API/Touch_Encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool Touch_Enc_ReadBtn(uint16_t interval)

if (!XPT2046_Read_Pen())
{
TS_Get_Coordinates(&tx, &ty);
TS_GetCoordinates(&tx, &ty);

if (OS_GetTimeMs() - nowTime >= interval)
{
Expand All @@ -60,7 +60,7 @@ uint8_t Touch_Enc_ReadPos(void)

if (!XPT2046_Read_Pen())
{
TS_Get_Coordinates(&ex, &ey);
TS_GetCoordinates(&ex, &ey);

if (!move)
sy = ey;
Expand Down
Loading

0 comments on commit 863de9b

Please sign in to comment.