Skip to content

Commit

Permalink
Allow TOUCH_BUTTONS to be swapped (MarlinFirmware#15100)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbycandra authored and thinkyhead committed Sep 4, 2019
1 parent 8e044ea commit 6b05d5d
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 129 deletions.
6 changes: 5 additions & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@
#endif

#ifndef STD_ENCODER_PULSES_PER_STEP
#define STD_ENCODER_PULSES_PER_STEP 5
#if ENABLED(TOUCH_BUTTONS)
#define STD_ENCODER_PULSES_PER_STEP 1
#else
#define STD_ENCODER_PULSES_PER_STEP 5
#endif
#endif
#ifndef STD_ENCODER_STEPS_PER_MENU_ITEM
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ bool MarlinUI::detected() {
#if HAS_SLOW_BUTTONS
uint8_t MarlinUI::read_slow_buttons() {
#if ENABLED(LCD_I2C_TYPE_MCP23017)
// Reading these buttons this is likely to be too slow to call inside interrupt context
// so they are called during normal lcd_update
// Reading these buttons is too slow for interrupt context
// so they are read during LCD update in the main loop.
uint8_t slow_bits = lcd.readButtons()
#if !BUTTON_EXISTS(ENC)
<< B_I2C_BTN_OFFSET
Expand All @@ -381,7 +381,7 @@ bool MarlinUI::detected() {
#if ENABLED(LCD_I2C_VIKI)
if ((slow_bits & (B_MI | B_RI)) && PENDING(millis(), next_button_update_ms)) // LCD clicked
slow_bits &= ~(B_MI | B_RI); // Disable LCD clicked buttons if screen is updated
#endif // LCD_I2C_VIKI
#endif
return slow_bits;
#endif // LCD_I2C_TYPE_MCP23017
}
Expand Down
146 changes: 97 additions & 49 deletions Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,51 +267,102 @@ static const uint8_t ili9341_init_sequence[] = { // 0x9341 - ILI9341
B01111111,B11111111,B11111111,B11111110,
};

static const uint8_t buttonA[] = {
B01111111,B11111111,B11111111,B11111110,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B01000000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000001,B11110000,B00000000,B00000001,
B10000011,B11111000,B00000000,B00000001,
B10000111,B11111100,B00111111,B11100001,
B10000000,B11100000,B00111111,B11100001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B01111111,B11111111,B11111111,B11111110,
};
#if ENABLED(REVERSE_MENU_DIRECTION)

static const uint8_t buttonA[] = {
B01111111,B11111111,B11111111,B11111110,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00111111,B11100001,
B10000111,B11111100,B00111111,B11100001,
B10000011,B11111000,B00000000,B00000001,
B10000001,B11110000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B01000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B01111111,B11111111,B11111111,B11111110,
};
static const uint8_t buttonB[] = {
B01111111,B11111111,B11111111,B11111110,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B01100000,B00000010,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00001111,B10000001,
B10000000,B01100000,B00011111,B11000001,
B10000111,B11111110,B00111111,B11100001,
B10000111,B11111110,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B01111111,B11111111,B11111111,B11111110,
};

static const uint8_t buttonB[] = {
B01111111,B11111111,B11111111,B11111110,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000111,B11111110,B00000111,B00000001,
B10000111,B11111110,B00111111,B11100001,
B10000000,B01100000,B00011111,B11000001,
B10000000,B01100000,B00001111,B10000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000010,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B01111111,B11111111,B11111111,B11111110,
};
#else

static const uint8_t buttonA[] = {
B01111111,B11111111,B11111111,B11111110,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B01000000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000001,B11110000,B00000000,B00000001,
B10000011,B11111000,B00000000,B00000001,
B10000111,B11111100,B00111111,B11100001,
B10000000,B11100000,B00111111,B11100001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B11100000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B01111111,B11111111,B11111111,B11111110,
};

static const uint8_t buttonB[] = {
B01111111,B11111111,B11111111,B11111110,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000111,B00000001,
B10000111,B11111110,B00000111,B00000001,
B10000111,B11111110,B00111111,B11100001,
B10000000,B01100000,B00011111,B11000001,
B10000000,B01100000,B00001111,B10000001,
B10000000,B01100000,B00000111,B00000001,
B10000000,B01100000,B00000010,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B10000000,B00000000,B00000000,B00000001,
B01111111,B11111111,B11111111,B11111110,
};

#endif

static const uint8_t buttonC[] = {
B01111111,B11111111,B11111111,B11111110,
Expand Down Expand Up @@ -369,11 +420,8 @@ static const uint8_t ili9341_init_sequence[] = { // 0x9341 - ILI9341

// Used to fill RGB565 (16bits) background
inline void memset2(const void *ptr, uint16_t fill, size_t cnt) {
uint16_t* wptr = (uint16_t*) ptr;
for (size_t i = 0; i < cnt; i += 2) {
*wptr = fill;
wptr++;
}
uint16_t* wptr = (uint16_t*)ptr;
for (size_t i = 0; i < cnt; i += 2) { *wptr = fill; wptr++; }
}

static bool preinit = true;
Expand Down
Loading

0 comments on commit 6b05d5d

Please sign in to comment.