Fix indentation in lcd_update() and split some of the preprocessor disabled functionality into separate functions. No change in resulting binary.

This commit is contained in:
Marek Bel 2018-07-13 18:03:05 +02:00
parent 9d72062cd7
commit 49dd8d83fb
2 changed files with 128 additions and 104 deletions

View file

@ -2482,8 +2482,8 @@ static void lcd_menu_xyz_skew()
//|01234567890123456789| //|01234567890123456789|
//|Measured skew: N/A | //|Measured skew: N/A |
//|--------------------| //|--------------------|
//|Slight skew: 0.12°| //|Slight skew: 0.12d|
//|Severe skew: 0.25°| //|Severe skew: 0.25d|
//---------------------- //----------------------
float angleDiff = eeprom_read_float((float*)(EEPROM_XYZ_CAL_SKEW)); float angleDiff = eeprom_read_float((float*)(EEPROM_XYZ_CAL_SKEW));
lcd_printf_P(_N( lcd_printf_P(_N(
@ -7498,22 +7498,76 @@ void lcd_update_enable(bool enabled)
} }
} }
static inline void debugBlink()
{
#ifdef DEBUG_BLINK_ACTIVE
static bool active_led = false;
active_led = !active_led;
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, active_led?HIGH:LOW);
#endif //DEBUG_BLINK_ACTIVE
}
static inline void handleReprapKeyboard()
{
#ifdef REPRAPWORLD_KEYPAD
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP)
{
reprapworld_keypad_move_z_up();
}
if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN)
{
reprapworld_keypad_move_z_down();
}
if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT)
{
reprapworld_keypad_move_x_left();
}
if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT)
{
reprapworld_keypad_move_x_right();
}
if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN)
{
reprapworld_keypad_move_y_down();
}
if (REPRAPWORLD_KEYPAD_MOVE_Y_UP)
{
reprapworld_keypad_move_y_up();
}
if (REPRAPWORLD_KEYPAD_MOVE_HOME)
{
reprapworld_keypad_move_home();
}
#endif
}
static inline void readSlowButtons()
{
#ifdef LCD_HAS_SLOW_BUTTONS
slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
#endif
}
/**
* @brief Handle keyboard input and update display
*
* @param lcdDrawUpdateOverride
* @param forceRedraw if true, force redraw of display regardless of timer
*/
void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw) void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw)
{ {
if (lcdDrawUpdate < lcdDrawUpdateOverride) if (lcdDrawUpdate < lcdDrawUpdateOverride)
{
lcdDrawUpdate = lcdDrawUpdateOverride; lcdDrawUpdate = lcdDrawUpdateOverride;
}
if (!lcd_update_enabled) if (!lcd_update_enabled) return;
return;
#ifdef LCD_HAS_SLOW_BUTTONS
slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
#endif
readSlowButtons();
lcd_buttons_update(); lcd_buttons_update();
#if (SDCARDDETECT > 0) #if (SDCARDDETECT > 0)
if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected())) if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected()))
{ {
@ -7529,7 +7583,6 @@ void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw)
{ {
card.initsd(); card.initsd();
LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0 LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0
//get_description();
} }
else else
{ {
@ -7537,47 +7590,19 @@ void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw)
LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0 LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0
} }
} }
#endif//CARDINSERTED #endif //(SDCARDDETECT > 0)
if (lcd_next_update_millis.expired(LCD_UPDATE_INTERVAL) || forceRedraw) if (lcd_next_update_millis.expired(LCD_UPDATE_INTERVAL) || forceRedraw)
{ {
lcd_next_update_millis.start(); lcd_next_update_millis.start();
#ifdef DEBUG_BLINK_ACTIVE debugBlink();
static bool active_led = false;
active_led = !active_led;
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, active_led?HIGH:LOW);
#endif //DEBUG_BLINK_ACTIVE
#ifdef ULTIPANEL #ifdef ULTIPANEL
#ifdef REPRAPWORLD_KEYPAD handleReprapKeyboard();
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) {
reprapworld_keypad_move_z_up();
}
if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) {
reprapworld_keypad_move_z_down();
}
if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) {
reprapworld_keypad_move_x_left();
}
if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) {
reprapworld_keypad_move_x_right();
}
if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) {
reprapworld_keypad_move_y_down();
}
if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) {
reprapworld_keypad_move_y_up();
}
if (REPRAPWORLD_KEYPAD_MOVE_HOME) {
reprapworld_keypad_move_home();
}
#endif
if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP) if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP)
{ {
if (lcdDrawUpdate == 0) if (lcdDrawUpdate == 0) lcdDrawUpdate = 1;
lcdDrawUpdate = 1;
encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP; encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP;
encoderDiff = 0; encoderDiff = 0;
lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
@ -7587,10 +7612,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw)
#endif//ULTIPANEL #endif//ULTIPANEL
(*currentMenu)(); (*currentMenu)();
#ifdef LCD_HAS_STATUS_INDICATORS
lcd_implementation_update_indicators(); lcd_implementation_update_indicators();
#endif
#ifdef ULTIPANEL #ifdef ULTIPANEL
if (lcd_timeoutToStatus < millis() && currentMenu != lcd_status_screen) if (lcd_timeoutToStatus < millis() && currentMenu != lcd_status_screen)
@ -7598,7 +7620,8 @@ void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw)
// Exiting a menu. Let's call the menu function the last time with menuExiting flag set to true // Exiting a menu. Let's call the menu function the last time with menuExiting flag set to true
// to give it a chance to save its state. // to give it a chance to save its state.
// This is useful for example, when the babystep value has to be written into EEPROM. // This is useful for example, when the babystep value has to be written into EEPROM.
if (currentMenu != NULL) { if (currentMenu != NULL)
{
menuExiting = true; menuExiting = true;
(*currentMenu)(); (*currentMenu)();
menuExiting = false; menuExiting = false;

View file

@ -1390,9 +1390,10 @@ static void lcd_implementation_quick_feedback()
#endif #endif
} }
#ifdef LCD_HAS_STATUS_INDICATORS
static void lcd_implementation_update_indicators() static void lcd_implementation_update_indicators()
{ {
#ifdef LCD_HAS_STATUS_INDICATORS
#if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI)
//set the LEDS - referred to as backlights by the LiquidTWI2 library //set the LEDS - referred to as backlights by the LiquidTWI2 library
static uint8_t ledsprev = 0; static uint8_t ledsprev = 0;
@ -1408,8 +1409,8 @@ static void lcd_implementation_update_indicators()
ledsprev = leds; ledsprev = leds;
} }
#endif #endif
}
#endif #endif
}
#ifdef LCD_HAS_SLOW_BUTTONS #ifdef LCD_HAS_SLOW_BUTTONS
extern uint32_t blocking_enc; extern uint32_t blocking_enc;