Skip to content

Commit

Permalink
code reduction & cleanup (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
digant73 authored May 23, 2024
1 parent 48f4dad commit ea49361
Show file tree
Hide file tree
Showing 170 changed files with 12,283 additions and 12,252 deletions.
10 changes: 5 additions & 5 deletions TFT/src/User/API/AddonHardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ static bool sfs_alive = false; // use an encoder disc to toggles the runout. Su
void FIL_Runout_Init(void)
{
GPIO_MODE pull =
#if defined(MKS_TFT)
MGPIO_MODE_IPN; // MKS TFTs already have an external pull-up resistor on PB0 and PB1 pins
#else
(GET_BIT(infoSettings.runout, RUNOUT_INVERTED) ^ GET_BIT(infoSettings.runout, RUNOUT_NO_NC)) ? MGPIO_MODE_IPD : MGPIO_MODE_IPU;
#endif
#if defined(MKS_TFT)
MGPIO_MODE_IPN; // MKS TFTs already have an external pull-up resistor on PB0 and PB1 pins
#else
(GET_BIT(infoSettings.runout, RUNOUT_INVERTED) ^ GET_BIT(infoSettings.runout, RUNOUT_NO_NC)) ? MGPIO_MODE_IPD : MGPIO_MODE_IPU;
#endif

GPIO_InitSet(FIL_RUNOUT_PIN, pull, 0);

Expand Down
15 changes: 7 additions & 8 deletions TFT/src/User/API/BabystepControl.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#include "BabystepControl.h"
#include "includes.h"

static float babystep_value = BABYSTEP_DEFAULT_VALUE;

#define BABYSTEP_CMD "M290 Z%.2f\n"
#define BABYSTEP_CMD_SMW "G43.2 Z%.2f\n"

// Set current babystep value
static float babystep_value = BABYSTEP_DEFAULT_VALUE;

// set current babystep value
void babystepSetValue(float value)
{
babystep_value = value;
}

// Get current babystep value
// get current babystep value
float babystepGetValue(void)
{
return babystep_value;
}

// Reset babystep value to default value
// reset babystep value to default value
float babystepResetValue(void)
{
if (babystep_value != BABYSTEP_DEFAULT_VALUE) // if already default value, nothing to do
Expand All @@ -39,18 +39,17 @@ float babystepResetValue(void)
}

last_unit = (BABYSTEP_DEFAULT_VALUE - babystep_value) - (BABYSTEP_MAX_STEP * step_count * direction);

if (last_unit != 0.0f)
{
mustStoreCmd(babyStepCmd, last_unit);
}

babystep_value = BABYSTEP_DEFAULT_VALUE;
}

return babystep_value;
}

// Update babystep value
// update babystep value
float babystepUpdateValue(float unit)
{
unit = NOBEYOND(BABYSTEP_MIN_VALUE, babystep_value + unit, BABYSTEP_MAX_VALUE) - babystep_value;
Expand Down
15 changes: 4 additions & 11 deletions TFT/src/User/API/BabystepControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@ extern "C" {

#include <stdint.h>

// Set current babystep value
void babystepSetValue(float value);

// Get current babystep value
float babystepGetValue(void);

// Reset babystep value to default value
float babystepResetValue(void);

// Update babystep value
float babystepUpdateValue(float unit);
void babystepSetValue(float value); // set current babystep value
float babystepGetValue(void); // get current babystep value
float babystepResetValue(void); // reset babystep value to default value
float babystepUpdateValue(float unit); // update babystep value

#ifdef __cplusplus
}
Expand Down
20 changes: 10 additions & 10 deletions TFT/src/User/API/FlashStore.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ void readStoredPara(void)
uint32_t index = 0;
uint32_t sign = 0;

#ifdef I2C_EEPROM // added I2C_EEPROM suppport for MKS_TFT35_V1_0
EEPROM_FlashRead(data, PARA_SIZE);
#else
HAL_FlashRead(data, PARA_SIZE);
#endif
#ifdef I2C_EEPROM // added I2C_EEPROM suppport for MKS_TFT35_V1_0
EEPROM_FlashRead(data, PARA_SIZE);
#else
HAL_FlashRead(data, PARA_SIZE);
#endif

sign = byteToWord(data + (index += 4), 4);

Expand Down Expand Up @@ -98,11 +98,11 @@ void storePara(void)
wordToByte(PARA_SIGN, data + (index += 4));
memcpy(data + (index += 4), &infoSettings, sizeof(SETTINGS));

#ifdef I2C_EEPROM // added I2C_EEPROM suppport for MKS_TFT35_V1_0
EEPROM_FlashWrite(data, PARA_SIZE); // store settings in I2C_EEPROM
#else
HAL_FlashWrite(data, PARA_SIZE);
#endif
#ifdef I2C_EEPROM // added I2C_EEPROM suppport for MKS_TFT35_V1_0
EEPROM_FlashWrite(data, PARA_SIZE); // store settings in I2C_EEPROM
#else
HAL_FlashWrite(data, PARA_SIZE);
#endif
}

bool readIsTSCExist(void)
Expand Down
14 changes: 7 additions & 7 deletions TFT/src/User/API/HomeOffsetControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
static float z_offset_value = HOME_Z_OFFSET_DEFAULT_VALUE;
static bool home_offset_enabled = false;

// Enable home offset
// enable home offset
void homeOffsetEnable(float shim)
{
home_offset_enabled = true;
Expand All @@ -17,7 +17,7 @@ void homeOffsetEnable(float shim)
probeHeightRelative(); // set relative position mode
}

// Disable home offset
// disable home offset
void homeOffsetDisable(void)
{
home_offset_enabled = false;
Expand All @@ -29,13 +29,13 @@ void homeOffsetDisable(void)
probeHeightDisable(); // restore original software endstops state and ABL state
}

// Get home offset status
// get home offset status
bool homeOffsetGetStatus(void)
{
return home_offset_enabled;
}

// Set Z offset value
// set Z offset value
float homeOffsetSetValue(float value)
{
sendParameterCmd(P_HOME_OFFSET, AXIS_INDEX_Z, value);
Expand All @@ -45,15 +45,15 @@ float homeOffsetSetValue(float value)
return z_offset_value;
}

// Get current Z offset value
// get current Z offset value
float homeOffsetGetValue(void)
{
z_offset_value = getParameter(P_HOME_OFFSET, AXIS_INDEX_Z);

return z_offset_value;
}

// Reset Z offset value to default value
// reset Z offset value to default value
float homeOffsetResetValue(void)
{
if (z_offset_value != HOME_Z_OFFSET_DEFAULT_VALUE) // if not default value
Expand All @@ -67,7 +67,7 @@ float homeOffsetResetValue(void)
return z_offset_value;
}

// Update Z offset value
// update Z offset value
float homeOffsetUpdateValue(float unit)
{
unit = z_offset_value - NOBEYOND(HOME_Z_OFFSET_MIN_VALUE, z_offset_value - unit, HOME_Z_OFFSET_MAX_VALUE);
Expand Down
27 changes: 7 additions & 20 deletions TFT/src/User/API/HomeOffsetControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,13 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>

// Enable home offset
void homeOffsetEnable(float shim);

// Disable home offset
void homeOffsetDisable(void);

// Get home offset status
bool homeOffsetGetStatus(void);

// Set Z offset value
float homeOffsetSetValue(float value);

// Get current Z offset value
float homeOffsetGetValue(void);

// Reset Z offset value to default value
float homeOffsetResetValue(void);

// Update Z offset value
float homeOffsetUpdateValue(float unit);
void homeOffsetEnable(float shim); // enable home offset
void homeOffsetDisable(void); // disable home offset
bool homeOffsetGetStatus(void); // get home offset status
float homeOffsetSetValue(float value); // set Z offset value
float homeOffsetGetValue(void); // get current Z offset value
float homeOffsetResetValue(void); // reset Z offset value to default value
float homeOffsetUpdateValue(float unit); // update Z offset value

#ifdef __cplusplus
}
Expand Down
6 changes: 0 additions & 6 deletions TFT/src/User/API/LCD_Dimming.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ void LCD_Wake(void)

#ifdef KNOB_LED_COLOR_PIN
if (infoSettings.knob_led_idle)
{
Knob_LED_SetColor(knob_led_colors[infoSettings.knob_led_color], infoSettings.neopixel_pixels);
}
#endif
}

Expand Down Expand Up @@ -126,9 +124,7 @@ void LCD_CheckDimming(void)

#ifdef KNOB_LED_COLOR_PIN
if (infoSettings.knob_led_idle)
{
Knob_LED_SetColor(knob_led_colors[KNOB_LED_OFF], infoSettings.neopixel_pixels);
}
#endif

return;
Expand All @@ -152,9 +148,7 @@ void LCD_CheckDimming(void)

#ifdef KNOB_LED_COLOR_PIN
if (infoSettings.knob_led_idle)
{
Knob_LED_SetColor(knob_led_colors[infoSettings.knob_led_color], infoSettings.neopixel_pixels);
}
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions TFT/src/User/API/LED_Colors.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const LABEL knob_led_color_names[KNOB_LED_COLOR_COUNT] = {

#endif // KNOB_LED_COLOR_PIN

const LED_COLOR ledRed = {0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF};
const LED_COLOR ledRed = {0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF};
const LED_COLOR ledGreen = {0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF};
const LED_COLOR ledBlue = {0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF};
const LED_COLOR ledBlue = {0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF};
const LED_COLOR ledWhite = {0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF};
const LED_COLOR ledOff = {0x00, 0x00, 0x00, 0x00, 0x00, 0xFF};
const LED_COLOR ledOff = {0x00, 0x00, 0x00, 0x00, 0x00, 0xFF};

LED_COLOR ledColor = {0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF};

Expand Down
Loading

0 comments on commit ea49361

Please sign in to comment.