Fix LCD compile error, etc. (#12472)
This commit is contained in:
parent
826d570162
commit
1f93d2bcf7
|
@ -26,8 +26,6 @@
|
|||
* Conditionals that need to be set before Configuration_adv.h or pins.h
|
||||
*/
|
||||
|
||||
#define LCD_HAS_DIRECTIONAL_BUTTONS (BUTTON_EXISTS(UP) || BUTTON_EXISTS(DWN) || BUTTON_EXISTS(LFT) || BUTTON_EXISTS(RT))
|
||||
|
||||
#if ENABLED(CARTESIO_UI)
|
||||
|
||||
#define DOGLCD
|
||||
|
@ -305,8 +303,11 @@
|
|||
#define HAS_GRAPHICAL_LCD ENABLED(DOGLCD)
|
||||
#define HAS_CHARACTER_LCD (HAS_SPI_LCD && !HAS_GRAPHICAL_LCD)
|
||||
#define HAS_LCD_MENU (ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS))
|
||||
#define HAS_DIGITAL_BUTTONS ENABLED(NEWPANEL)
|
||||
#define HAS_ENCODER_WHEEL (ENABLED(NEWPANEL) && DISABLED(ADC_KEYPAD))
|
||||
|
||||
#define HAS_ADC_BUTTONS ENABLED(ADC_KEYPAD)
|
||||
#define HAS_DIGITAL_BUTTONS (!HAS_ADC_BUTTONS && ENABLED(NEWPANEL))
|
||||
#define HAS_SHIFT_ENCODER (!HAS_ADC_BUTTONS && (ENABLED(REPRAPWORLD_KEYPAD) || (HAS_SPI_LCD && DISABLED(NEWPANEL))))
|
||||
#define HAS_ENCODER_WHEEL (!HAS_ADC_BUTTONS && ENABLED(NEWPANEL))
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#define LCD_CLASS LiquidCrystal
|
||||
#endif
|
||||
extern LCD_CLASS lcd;
|
||||
LCD_CLASS *plcd = &lcd;
|
||||
|
||||
int lcd_glyph_height(void) { return 1; }
|
||||
|
||||
|
@ -868,11 +867,7 @@ static const hd44780_charmap_t g_hd44780_charmap_common[] PROGMEM = {
|
|||
|
||||
/* return v1 - v2 */
|
||||
static int hd44780_charmap_compare(hd44780_charmap_t * v1, hd44780_charmap_t * v2) {
|
||||
if (v1->uchar < v2->uchar)
|
||||
return -1;
|
||||
else if (v1->uchar > v2->uchar)
|
||||
return 1;
|
||||
return 0;
|
||||
return (v1->uchar < v2->uchar) ? -1 : (v1->uchar > v2->uchar) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int pf_bsearch_cb_comp_hd4map_pgm(void *userdata, size_t idx, void * data_pin) {
|
||||
|
@ -882,7 +877,88 @@ static int pf_bsearch_cb_comp_hd4map_pgm(void *userdata, size_t idx, void * data
|
|||
return hd44780_charmap_compare(&localval, (hd44780_charmap_t *)data_pin);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
void lcd_moveto(const uint8_t col, const uint8_t row) { lcd.setCursor(col, row); }
|
||||
|
||||
void lcd_put_int(const int i) { lcd.print(i); }
|
||||
|
||||
// return < 0 on error
|
||||
// return the advanced cols
|
||||
int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
|
||||
|
||||
// find the HD44780 internal ROM first
|
||||
int ret;
|
||||
size_t idx = 0;
|
||||
hd44780_charmap_t pinval;
|
||||
hd44780_charmap_t *copy_address = NULL;
|
||||
pinval.uchar = c;
|
||||
pinval.idx = -1;
|
||||
|
||||
if (max_length < 1) return 0;
|
||||
|
||||
// TODO: fix the '\\' that doesnt exist in the HD44870
|
||||
if (c < 128) {
|
||||
lcd.write((uint8_t)c);
|
||||
return 1;
|
||||
}
|
||||
copy_address = NULL;
|
||||
ret = pf_bsearch_r((void *)g_hd44780_charmap_device, NUM_ARRAY(g_hd44780_charmap_device), pf_bsearch_cb_comp_hd4map_pgm, (void *)&pinval, &idx);
|
||||
if (ret >= 0) {
|
||||
copy_address = (hd44780_charmap_t *)(g_hd44780_charmap_device + idx);
|
||||
}
|
||||
else {
|
||||
ret = pf_bsearch_r((void *)g_hd44780_charmap_common, NUM_ARRAY(g_hd44780_charmap_common), pf_bsearch_cb_comp_hd4map_pgm, (void *)&pinval, &idx);
|
||||
if (ret >= 0) copy_address = (hd44780_charmap_t *)(g_hd44780_charmap_common + idx);
|
||||
}
|
||||
|
||||
if (ret >= 0) {
|
||||
hd44780_charmap_t localval;
|
||||
// found
|
||||
memcpy_P(&localval, copy_address, sizeof(localval));
|
||||
lcd.write(localval.idx);
|
||||
if (max_length >= 2 && localval.idx2 > 0) {
|
||||
lcd.write(localval.idx2);
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Not found, print '?' instead
|
||||
lcd.write((uint8_t)'?');
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draw a UTF-8 string
|
||||
*
|
||||
* @param utf8_str : the UTF-8 string
|
||||
* @param cb_read_byte : the callback function to read one byte from the utf8_str (from RAM or ROM)
|
||||
* @param max_length : the pixel length of the string allowed (or number of slots in HD44780)
|
||||
*
|
||||
* @return the number of pixels advanced
|
||||
*
|
||||
* Draw a UTF-8 string
|
||||
*/
|
||||
static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) {
|
||||
pixel_len_t ret = 0;
|
||||
uint8_t *p = (uint8_t *)utf8_str;
|
||||
while (ret < max_length) {
|
||||
wchar_t ch = 0;
|
||||
p = get_utf8_value_cb(p, cb_read_byte, &ch);
|
||||
if (!ch) break;
|
||||
ret += lcd_put_wchar_max(ch, max_length - ret);
|
||||
}
|
||||
return (int)ret;
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length);
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length);
|
||||
}
|
||||
|
||||
#if ENABLED(DEBUG_LCDPRINT)
|
||||
|
||||
int test_hd44780_charmap(hd44780_charmap_t *data, size_t size, char *name, char flg_show_contents) {
|
||||
int ret;
|
||||
|
@ -954,87 +1030,6 @@ int test_hd44780_charmap_all(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
void lcd_moveto(int col, int row) {
|
||||
plcd->setCursor(col, row);
|
||||
}
|
||||
|
||||
// return < 0 on error
|
||||
// return the advanced cols
|
||||
int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
|
||||
|
||||
// find the HD44780 internal ROM first
|
||||
int ret;
|
||||
size_t idx = 0;
|
||||
hd44780_charmap_t pinval;
|
||||
hd44780_charmap_t *copy_address = NULL;
|
||||
pinval.uchar = c;
|
||||
pinval.idx = -1;
|
||||
|
||||
if (max_length < 1) return 0;
|
||||
|
||||
// TODO: fix the '\\' that doesnt exist in the HD44870
|
||||
if (c < 128) {
|
||||
plcd->write((uint8_t)c);
|
||||
return 1;
|
||||
}
|
||||
copy_address = NULL;
|
||||
ret = pf_bsearch_r((void *)g_hd44780_charmap_device, NUM_ARRAY(g_hd44780_charmap_device), pf_bsearch_cb_comp_hd4map_pgm, (void *)&pinval, &idx);
|
||||
if (ret >= 0) {
|
||||
copy_address = (hd44780_charmap_t *)(g_hd44780_charmap_device + idx);
|
||||
}
|
||||
else {
|
||||
ret = pf_bsearch_r((void *)g_hd44780_charmap_common, NUM_ARRAY(g_hd44780_charmap_common), pf_bsearch_cb_comp_hd4map_pgm, (void *)&pinval, &idx);
|
||||
if (ret >= 0) copy_address = (hd44780_charmap_t *)(g_hd44780_charmap_common + idx);
|
||||
}
|
||||
|
||||
if (ret >= 0) {
|
||||
hd44780_charmap_t localval;
|
||||
// found
|
||||
memcpy_P(&localval, copy_address, sizeof(localval));
|
||||
plcd->write(localval.idx);
|
||||
if (max_length >= 2 && localval.idx2 > 0) {
|
||||
plcd->write(localval.idx2);
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Not found, print '?' instead
|
||||
plcd->write((uint8_t)'?');
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draw a UTF-8 string
|
||||
*
|
||||
* @param utf8_str : the UTF-8 string
|
||||
* @param cb_read_byte : the callback function to read one byte from the utf8_str (from RAM or ROM)
|
||||
* @param max_length : the pixel length of the string allowed (or number of slots in HD44780)
|
||||
*
|
||||
* @return the number of pixels advanced
|
||||
*
|
||||
* Draw a UTF-8 string
|
||||
*/
|
||||
static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) {
|
||||
pixel_len_t ret = 0;
|
||||
uint8_t *p = (uint8_t *)utf8_str;
|
||||
while (ret < max_length) {
|
||||
wchar_t ch = 0;
|
||||
p = get_utf8_value_cb(p, cb_read_byte, &ch);
|
||||
if (!ch) break;
|
||||
ret += lcd_put_wchar_max(ch, max_length - ret);
|
||||
}
|
||||
return (int)ret;
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length);
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length);
|
||||
}
|
||||
#endif // DEBUG_LCDPRINT
|
||||
|
||||
#endif // HAS_CHARACTER_LCD
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#if HAS_CHARACTER_LCD
|
||||
|
||||
/**
|
||||
* ultralcd_impl_HD44780.cpp
|
||||
* ultralcd_HD44780.cpp
|
||||
*
|
||||
* LCD display implementations for Hitachi HD44780.
|
||||
* These are the most common LCD character displays.
|
||||
|
|
|
@ -23,13 +23,11 @@ extern U8GLIB *pu8g;
|
|||
#include "u8g_fontutf8.h"
|
||||
#include "../lcdprint.h"
|
||||
|
||||
int lcd_glyph_height(void) {
|
||||
return u8g_GetFontBBXHeight(pu8g->getU8g());
|
||||
}
|
||||
int lcd_glyph_height(void) { return u8g_GetFontBBXHeight(pu8g->getU8g()); }
|
||||
|
||||
void lcd_moveto(int col, int row) {
|
||||
_lcd_setcursor(col, row);
|
||||
}
|
||||
void lcd_moveto(const uint8_t col, const uint8_t row) { _lcd_setcursor(col, row); }
|
||||
|
||||
void lcd_put_int(const int i) { pu8g->print(i); }
|
||||
|
||||
// return < 0 on error
|
||||
// return the advanced pixels
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* ultralcd_impl_DOGM.cpp
|
||||
* ultralcd_DOGM.cpp
|
||||
*
|
||||
* Implementation of the LCD display routines for a DOGM128 graphic display.
|
||||
* by STB for ErikZalm/Marlin. Common LCD 128x64 pixel graphic displays.
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* ultralcd_impl_DOGM.h
|
||||
* ultralcd_DOGM.h
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
|
|
@ -48,10 +48,12 @@ int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
|
|||
*/
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
|
||||
|
||||
void lcd_moveto(int col, int row);
|
||||
void lcd_moveto(const uint8_t col, const uint8_t row);
|
||||
|
||||
void lcd_put_int(const int i);
|
||||
|
||||
inline int lcd_put_u8str_P(PGM_P str) { return lcd_put_u8str_max_P(str, PIXEL_LEN_NOLIMIT); }
|
||||
|
||||
inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); }
|
||||
|
||||
inline int lcd_put_wchar(wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); }
|
||||
inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); }
|
||||
|
|
|
@ -66,7 +66,7 @@ static void lcd_factory_settings() {
|
|||
ui.encoderPosition = 0;
|
||||
draw_menu_item_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
|
||||
lcd_moveto((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2);
|
||||
lcd_put_u8str(int(bar_percent)); lcd_put_wchar('%');
|
||||
lcd_put_int(bar_percent); lcd_put_wchar('%');
|
||||
lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent);
|
||||
}
|
||||
|
||||
|
|
|
@ -207,12 +207,6 @@ void MarlinUI::init() {
|
|||
SET_INPUT_PULLUP(BTN_ENC);
|
||||
#endif
|
||||
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD) && DISABLED(ADC_KEYPAD)
|
||||
SET_OUTPUT(SHIFT_CLK);
|
||||
OUT_WRITE(SHIFT_LD, HIGH);
|
||||
SET_INPUT_PULLUP(SHIFT_OUT);
|
||||
#endif
|
||||
|
||||
#if BUTTON_EXISTS(UP)
|
||||
SET_INPUT(BTN_UP);
|
||||
#endif
|
||||
|
@ -226,19 +220,27 @@ void MarlinUI::init() {
|
|||
SET_INPUT(BTN_RT);
|
||||
#endif
|
||||
|
||||
#else // !HAS_DIGITAL_BUTTONS
|
||||
#endif // !HAS_DIGITAL_BUTTONS
|
||||
|
||||
#if HAS_SHIFT_ENCODER
|
||||
|
||||
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
|
||||
|
||||
SET_OUTPUT(SR_DATA_PIN);
|
||||
SET_OUTPUT(SR_CLK_PIN);
|
||||
|
||||
#elif defined(SHIFT_CLK)
|
||||
|
||||
SET_OUTPUT(SHIFT_CLK);
|
||||
OUT_WRITE(SHIFT_LD, HIGH);
|
||||
#if defined(SHIFT_EN) && SHIFT_EN >= 0
|
||||
OUT_WRITE(SHIFT_EN, LOW);
|
||||
#endif
|
||||
SET_INPUT_PULLUP(SHIFT_OUT);
|
||||
#endif // SR_LCD_2W_NL
|
||||
|
||||
#endif // !HAS_DIGITAL_BUTTONS
|
||||
#endif
|
||||
|
||||
#endif // HAS_SHIFT_ENCODER
|
||||
|
||||
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||
|
@ -273,9 +275,9 @@ bool MarlinUI::get_blink() {
|
|||
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD) && HAS_ENCODER_ACTION
|
||||
|
||||
volatile uint8_t MarlinUI::buttons_reprapworld_keypad;
|
||||
volatile uint8_t MarlinUI::keypad_buttons;
|
||||
|
||||
#if DISABLED(ADC_KEYPAD) && HAS_LCD_MENU
|
||||
#if HAS_LCD_MENU && !HAS_ADC_BUTTONS
|
||||
|
||||
void lcd_move_x();
|
||||
void lcd_move_y();
|
||||
|
@ -296,10 +298,10 @@ bool MarlinUI::get_blink() {
|
|||
|
||||
bool MarlinUI::handle_keypad() {
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
#if HAS_ADC_BUTTONS
|
||||
|
||||
#define ADC_MIN_KEY_DELAY 100
|
||||
if (buttons_reprapworld_keypad) {
|
||||
if (keypad_buttons) {
|
||||
#if HAS_ENCODER_ACTION
|
||||
refresh(LCDVIEW_REDRAW_NOW);
|
||||
if (encoderDirection == -1) { // side effect which signals we are inside a menu
|
||||
|
@ -310,15 +312,16 @@ bool MarlinUI::get_blink() {
|
|||
else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) { return_to_status(); quick_feedback(); }
|
||||
#endif
|
||||
}
|
||||
else if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition += ENCODER_PULSES_PER_STEP;
|
||||
else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition -= ENCODER_PULSES_PER_STEP;
|
||||
else if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition -= ENCODER_PULSES_PER_STEP;
|
||||
else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition += ENCODER_PULSES_PER_STEP;
|
||||
else if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); }
|
||||
else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) encoderPosition = 0;
|
||||
#endif
|
||||
next_button_update_ms = millis() + ADC_MIN_KEY_DELAY;
|
||||
return true;
|
||||
}
|
||||
|
||||
#else // !ADC_KEYPAD
|
||||
#else // !HAS_ADC_BUTTONS
|
||||
|
||||
static uint8_t keypad_debounce = 0;
|
||||
|
||||
|
@ -408,7 +411,9 @@ void MarlinUI::status_screen() {
|
|||
// share the same line on the display.
|
||||
//
|
||||
|
||||
#if DISABLED(PROGRESS_MSG_ONCE) || (PROGRESS_MSG_EXPIRE > 0)
|
||||
millis_t ms = millis();
|
||||
#endif
|
||||
|
||||
// If the message will blink rather than expire...
|
||||
#if DISABLED(PROGRESS_MSG_ONCE)
|
||||
|
@ -818,8 +823,8 @@ void MarlinUI::update() {
|
|||
break;
|
||||
} // switch
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
buttons_reprapworld_keypad = 0;
|
||||
#if HAS_ADC_BUTTONS
|
||||
keypad_buttons = 0;
|
||||
#endif
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
|
@ -890,7 +895,7 @@ void MarlinUI::update() {
|
|||
} // ELAPSED(ms, next_lcd_update_ms)
|
||||
}
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
#if HAS_ADC_BUTTONS
|
||||
|
||||
typedef struct {
|
||||
uint16_t ADCKeyValueMin, ADCKeyValueMax;
|
||||
|
@ -953,11 +958,13 @@ void MarlinUI::update() {
|
|||
* Warning: This function is called from interrupt context!
|
||||
*/
|
||||
void MarlinUI::update_buttons() {
|
||||
static uint8_t lastEncoderBits;
|
||||
const millis_t now = millis();
|
||||
if (ELAPSED(now, next_button_update_ms)) {
|
||||
|
||||
#if HAS_DIGITAL_BUTTONS
|
||||
|
||||
#if BUTTON_EXISTS(EN1) || BUTTON_EXISTS(EN2) || BUTTON_EXISTS(ENC) || BUTTON_EXISTS(BACK)
|
||||
|
||||
uint8_t newbutton = 0;
|
||||
|
||||
#if BUTTON_EXISTS(EN1)
|
||||
|
@ -973,10 +980,16 @@ void MarlinUI::update() {
|
|||
if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
constexpr uint8_t newbutton = 0;
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Directional buttons
|
||||
//
|
||||
#if LCD_HAS_DIRECTIONAL_BUTTONS
|
||||
#if BUTTON_EXISTS(UP) || BUTTON_EXISTS(DWN) || BUTTON_EXISTS(LFT) || BUTTON_EXISTS(RT)
|
||||
|
||||
const int8_t pulses = (ENCODER_PULSES_PER_STEP) * encoderDirection;
|
||||
|
||||
|
@ -1008,18 +1021,7 @@ void MarlinUI::update() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // LCD_HAS_DIRECTIONAL_BUTTONS
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
|
||||
buttons = 0;
|
||||
if (buttons_reprapworld_keypad == 0) {
|
||||
uint8_t newbutton_reprapworld_keypad = get_ADC_keyValue();
|
||||
if (WITHIN(newbutton_reprapworld_keypad, 1, 8))
|
||||
buttons_reprapworld_keypad = _BV(newbutton_reprapworld_keypad - 1);
|
||||
}
|
||||
|
||||
#else
|
||||
#endif // UP || DWN || LFT || RT
|
||||
|
||||
buttons = newbutton
|
||||
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
|
||||
|
@ -1027,21 +1029,32 @@ void MarlinUI::update() {
|
|||
#endif
|
||||
;
|
||||
|
||||
#elif HAS_ADC_BUTTONS
|
||||
|
||||
buttons = 0;
|
||||
if (keypad_buttons == 0) {
|
||||
const uint8_t b = get_ADC_keyValue();
|
||||
if (WITHIN(b, 1, 8)) keypad_buttons = _BV(b - 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if HAS_SHIFT_ENCODER
|
||||
|
||||
GET_SHIFT_BUTTON_STATES(
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
GET_SHIFT_BUTTON_STATES(buttons_reprapworld_keypad);
|
||||
keypad_buttons
|
||||
#else
|
||||
buttons
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#else // !HAS_DIGITAL_BUTTONS
|
||||
|
||||
GET_SHIFT_BUTTON_STATES(buttons);
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
} // next_button_update_ms
|
||||
|
||||
#if HAS_ENCODER_WHEEL
|
||||
static uint8_t lastEncoderBits;
|
||||
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
LCDVIEW_CALL_NO_REDRAW
|
||||
};
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
#if HAS_ADC_BUTTONS
|
||||
uint8_t get_ADC_keyValue();
|
||||
#endif
|
||||
|
||||
|
@ -88,6 +88,30 @@
|
|||
|
||||
#endif
|
||||
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
#define REPRAPWORLD_BTN_OFFSET 0 // Bit offset into buttons for shift register values
|
||||
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F1 2
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_DOWN 3
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_UP 6
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
|
||||
|
||||
#define EN_REPRAPWORLD_KEYPAD_F1 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F2 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F3 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
|
||||
#define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
|
||||
#define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
|
||||
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
|
||||
#define EN_REPRAPWORLD_KEYPAD_UP (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
|
||||
#define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
|
||||
|
||||
#define RRK(B) (keypad_buttons & (B))
|
||||
#endif
|
||||
|
||||
#if HAS_DIGITAL_BUTTONS
|
||||
|
||||
// Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
|
||||
|
@ -112,27 +136,6 @@
|
|||
#endif
|
||||
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
#define REPRAPWORLD_BTN_OFFSET 0 // Bit offset into buttons for shift register values
|
||||
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F1 2
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_DOWN 3
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_UP 6
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
|
||||
|
||||
#define EN_REPRAPWORLD_KEYPAD_F1 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F2 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F3 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
|
||||
#define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
|
||||
#define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
|
||||
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
|
||||
#define EN_REPRAPWORLD_KEYPAD_UP (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
|
||||
#define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
|
||||
|
||||
#define RRK(B) (buttons_reprapworld_keypad & (B))
|
||||
|
||||
#ifdef EN_C
|
||||
#define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE))
|
||||
|
@ -180,6 +183,8 @@
|
|||
|
||||
#else
|
||||
|
||||
#define BUTTON_EXISTS(BN) 0
|
||||
|
||||
// Shift register bits correspond to buttons:
|
||||
#define BL_LE 7 // Left
|
||||
#define BL_UP 6 // Up
|
||||
|
@ -463,7 +468,7 @@ public:
|
|||
|
||||
static volatile uint8_t buttons;
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
static volatile uint8_t buttons_reprapworld_keypad;
|
||||
static volatile uint8_t keypad_buttons;
|
||||
static bool handle_keypad();
|
||||
#endif
|
||||
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
|
||||
|
|
|
@ -217,7 +217,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
|
|||
bool Temperature::heater_idle_timeout_exceeded[HOTENDS] = { false };
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
#if HAS_ADC_BUTTONS
|
||||
uint32_t Temperature::current_ADCKey_raw = 0;
|
||||
uint8_t Temperature::ADCKey_count = 0;
|
||||
#endif
|
||||
|
@ -1869,7 +1869,7 @@ void Temperature::isr() {
|
|||
// avoid multiple loads of pwm_count
|
||||
uint8_t pwm_count_tmp = pwm_count;
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
#if HAS_ADC_BUTTONS
|
||||
static unsigned int raw_ADCKey_value = 0;
|
||||
#endif
|
||||
|
||||
|
@ -2290,7 +2290,7 @@ void Temperature::isr() {
|
|||
break;
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
#if HAS_ADC_BUTTONS
|
||||
case Prepare_ADC_KEY:
|
||||
HAL_START_ADC(ADC_KEYPAD_PIN);
|
||||
break;
|
||||
|
|
|
@ -112,7 +112,7 @@ enum ADCSensorState : char {
|
|||
Prepare_FILWIDTH,
|
||||
Measure_FILWIDTH,
|
||||
#endif
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
#if HAS_ADC_BUTTONS
|
||||
Prepare_ADC_KEY,
|
||||
Measure_ADC_KEY,
|
||||
#endif
|
||||
|
@ -291,7 +291,7 @@ class Temperature {
|
|||
#endif
|
||||
|
||||
public:
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
#if HAS_ADC_BUTTONS
|
||||
static uint32_t current_ADCKey_raw;
|
||||
static uint8_t ADCKey_count;
|
||||
#endif
|
||||
|
|
|
@ -161,9 +161,6 @@
|
|||
#define LCD_PINS_D5 11
|
||||
#define LCD_PINS_D6 16
|
||||
#define LCD_PINS_D7 17
|
||||
#define BTN_EN1 -1
|
||||
#define BTN_EN2 -1
|
||||
#define BTN_ENC -1
|
||||
#define ADC_KEYPAD_PIN 1
|
||||
#elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) || ENABLED(ANET_FULL_GRAPHICS_LCD)
|
||||
// Pin definitions for the Anet A6 Full Graphics display and the RepRapDiscount Full Graphics
|
||||
|
|
Loading…
Reference in a new issue