Merge branch 'prusa3d:MK3' into gudnimg-patch-1

This commit is contained in:
Guðni Már Gilbert 2023-04-28 19:10:56 +00:00 committed by GitHub
commit d7127c44f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 126 additions and 146 deletions

View File

@ -10,7 +10,6 @@
#include "Configuration.h"
#include "pins.h"
#include <binary.h>
#include <Arduino.h>
#include "Marlin.h"
#include "fastio.h"
@ -635,7 +634,7 @@ uint8_t lcd_draw_update = 2;
int16_t lcd_encoder = 0;
static int8_t lcd_encoder_diff = 0;
uint8_t lcd_buttons = 0;
uint8_t lcd_click_trigger = 0;
uint8_t lcd_update_enabled = 1;
static bool lcd_backlight_wake_trigger; // Flag set by interrupt when the knob is pressed or rotated
@ -751,7 +750,6 @@ void lcd_buttons_update(void)
{
static uint8_t lcd_long_press_active = 0;
static uint8_t lcd_button_pressed = 0;
static uint8_t lcd_encoder_bits = 0;
if (READ(BTN_ENC) == 0)
{ //button is pressed
if (buttonBlanking.expired_cont(BUTTON_BLANKING_TIME)) {
@ -776,7 +774,7 @@ void lcd_buttons_update(void)
lcd_button_pressed = 0; // Reset to prevent double triggering
if (!lcd_long_press_active)
{ //button released before long press gets activated
lcd_buttons |= EN_C; // This flag is reset when the event is consumed
lcd_click_trigger = 1; // This flag is reset when the event is consumed
}
lcd_backlight_wake_trigger = true; // flag event, knob pressed
lcd_long_press_active = 0;
@ -784,24 +782,27 @@ void lcd_buttons_update(void)
}
//manage encoder rotation
#define ENCODER_SPIN(_E1, _E2) switch (lcd_encoder_bits) { case _E1: lcd_encoder_diff++; break; case _E2: lcd_encoder_diff--; }
uint8_t enc = 0;
if (READ(BTN_EN1) == 0) enc |= B01;
if (READ(BTN_EN2) == 0) enc |= B10;
if (enc != lcd_encoder_bits)
static const int8_t encrot_table[] PROGMEM = {
0, -1, 1, 2,
1, 0, 2, -1,
-1, -2, 0, 1,
-2, 1, -1, 0,
};
static uint8_t enc_bits_old = 0;
uint8_t enc_bits = 0;
if (!READ(BTN_EN1)) enc_bits |= _BV(0);
if (!READ(BTN_EN2)) enc_bits |= _BV(1);
if (enc_bits != enc_bits_old)
{
switch (enc)
{
case encrot0: ENCODER_SPIN(encrot3, encrot1); break;
case encrot1: ENCODER_SPIN(encrot0, encrot2); break;
case encrot2: ENCODER_SPIN(encrot1, encrot3); break;
case encrot3: ENCODER_SPIN(encrot2, encrot0); break;
}
int8_t newDiff = pgm_read_byte(&encrot_table[(enc_bits_old << 2) | enc_bits]);
lcd_encoder_diff += newDiff;
if (abs(lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP) {
lcd_backlight_wake_trigger = true; // flag event, knob rotated
}
lcd_encoder_bits = enc;
enc_bits_old = enc_bits;
}
}
@ -810,114 +811,114 @@ void lcd_buttons_update(void)
// Custom character data
const uint8_t lcd_chardata_bedTemp[8] PROGMEM = {
B00000,
B11111,
B10101,
B10001,
B10101,
B11111,
B00000,
B00000}; //thanks Sonny Mounicou
0b00000,
0b11111,
0b10101,
0b10001,
0b10101,
0b11111,
0b00000,
0b00000}; //thanks Sonny Mounicou
const uint8_t lcd_chardata_degree[8] PROGMEM = {
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000};
0b01100,
0b10010,
0b10010,
0b01100,
0b00000,
0b00000,
0b00000,
0b00000};
const uint8_t lcd_chardata_thermometer[8] PROGMEM = {
B00100,
B01010,
B01010,
B01010,
B01010,
B10001,
B10001,
B01110};
0b00100,
0b01010,
0b01010,
0b01010,
0b01010,
0b10001,
0b10001,
0b01110};
const uint8_t lcd_chardata_uplevel[8] PROGMEM = {
B00100,
B01110,
B11111,
B00100,
B11100,
B00000,
B00000,
B00000}; //thanks joris
0b00100,
0b01110,
0b11111,
0b00100,
0b11100,
0b00000,
0b00000,
0b00000}; //thanks joris
const uint8_t lcd_chardata_refresh[8] PROGMEM = {
B00000,
B00110,
B11001,
B11000,
B00011,
B10011,
B01100,
B00000}; //thanks joris
0b00000,
0b00110,
0b11001,
0b11000,
0b00011,
0b10011,
0b01100,
0b00000}; //thanks joris
const uint8_t lcd_chardata_folder[8] PROGMEM = {
B00000,
B11100,
B11111,
B10001,
B10001,
B11111,
B00000,
B00000}; //thanks joris
0b00000,
0b11100,
0b11111,
0b10001,
0b10001,
0b11111,
0b00000,
0b00000}; //thanks joris
/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
B11100,
B10000,
B11000,
B10111,
B00101,
B00110,
B00101,
B00000};*/ //thanks Sonny Mounicou
0b11100,
0b10000,
0b11000,
0b10111,
0b00101,
0b00110,
0b00101,
0b00000};*/ //thanks Sonny Mounicou
/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
B11100,
B10100,
B11000,
B10100,
B00000,
B00111,
B00010,
B00010};*/
0b11100,
0b10100,
0b11000,
0b10100,
0b00000,
0b00111,
0b00010,
0b00010};*/
/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
B01100,
B10011,
B00000,
B01100,
B10011,
B00000,
B01100,
B10011};*/
0b01100,
0b10011,
0b00000,
0b01100,
0b10011,
0b00000,
0b01100,
0b10011};*/
const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
B00000,
B00100,
B10010,
B01001,
B10010,
B00100,
B00000,
B00000};
0b00000,
0b00100,
0b10010,
0b01001,
0b10010,
0b00100,
0b00000,
0b00000};
const uint8_t lcd_chardata_clock[8] PROGMEM = {
B00000,
B01110,
B10011,
B10101,
B10001,
B01110,
B00000,
B00000}; //thanks Sonny Mounicou
0b00000,
0b01110,
0b10011,
0b10101,
0b10001,
0b01110,
0b00000,
0b00000}; //thanks Sonny Mounicou
void lcd_set_custom_characters(void)
{
@ -932,23 +933,24 @@ void lcd_set_custom_characters(void)
}
const uint8_t lcd_chardata_arr2down[8] PROGMEM = {
B00000,
B00000,
B10001,
B01010,
B00100,
B10001,
B01010,
B00100};
0b00000,
0b00000,
0b10001,
0b01010,
0b00100,
0b10001,
0b01010,
0b00100};
const uint8_t lcd_chardata_confirm[8] PROGMEM = {
B00000,
B00001,
B00011,
B10110,
B11100,
B01000,
B00000};
0b00000,
0b00001,
0b00011,
0b10110,
0b11100,
0b01000,
0b00000,
0b00000};
void lcd_set_custom_characters_nextpage(void)
{

View File

@ -100,8 +100,7 @@ extern uint8_t lcd_draw_update;
extern int16_t lcd_encoder;
//the last checked lcd_buttons in a bit array.
extern uint8_t lcd_buttons;
extern uint8_t lcd_click_trigger;
extern uint8_t lcd_update_enabled;
@ -156,20 +155,7 @@ private:
bool m_updateEnabled;
};
////////////////////////////////////
// Setup button and encode mappings for each panel (into 'lcd_buttons' variable
//
// This is just to map common functions (across different panels) onto the same
// macro name. The mapping is independent of whether the button is directly connected or
// via a shift/i2c register.
#define BLEN_B 1
#define BLEN_A 0
#define EN_B (1<<BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
#define EN_A (1<<BLEN_A)
#define BLEN_C 2
#define EN_C (1<<BLEN_C)
//! @brief Was button clicked?
//!
@ -180,17 +166,9 @@ private:
//!
//! @retval 0 button was not clicked
//! @retval 1 button was clicked
#define LCD_CLICKED (lcd_buttons&EN_C)
////////////////////////
// Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
// These values are independent of which pins are used for EN_A and EN_B indications
// The rotary encoder part is also independent to the chipset used for the LCD
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
#define LCD_CLICKED (lcd_click_trigger)
////////////////////////////////////
//Custom characters defined in the first 8 characters of the LCD
#define LCD_STR_BEDTEMP "\x00"
@ -212,7 +190,7 @@ extern void lcd_set_custom_characters_nextpage(void);
//! @brief Consume click and longpress event
inline void lcd_consume_click()
{
lcd_buttons = 0;
lcd_click_trigger = 0;
lcd_longpress_trigger = 0;
}