Skip to content

Commit

Permalink
More fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 28, 2020
1 parent 26f18bc commit 53279b0
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 53 deletions.
10 changes: 5 additions & 5 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,15 @@
#elif ENABLED(MAKRPANEL)
#define _LCD_CONTRAST_INIT 17
#elif ENABLED(MINIPANEL)
#define _LCD_CONTRAST_INIT 150
#define _LCD_CONTRAST_INIT 150
#elif ENABLED(ZONESTAR_12864OLED)
#define _LCD_CONTRAST_MIN 64
#define _LCD_CONTRAST_INIT 128
#define _LCD_CONTRAST_MAX 255
#elif IS_TFTGLCD_PANEL
#define _LCD_CONTRAST_MIN 0
#define _LCD_CONTRAST_INIT 250
#define _LCD_CONTRAST_MAX 255
#define _LCD_CONTRAST_MIN 0
#define _LCD_CONTRAST_INIT 250
#define _LCD_CONTRAST_MAX 255
#endif

#ifdef _LCD_CONTRAST_INIT
Expand Down Expand Up @@ -2459,7 +2459,7 @@
*/
#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER, IS_TFTGLCD_PANEL)
#define HAS_BUZZER 1
#if NONE(LCD_USE_I2C_BUZZER, PCA9632_BUZZER, IS_TFTGLCD_PANEL)
#if PIN_EXISTS(BEEPER)
#define USE_BEEPER 1
#endif
#endif
Expand Down
77 changes: 49 additions & 28 deletions Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
/**
* @file lcdprint_hd44780.cpp
* @brief LCD print api for HD44780
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

/**
* @file lcdprint_TFTGLCD.cpp
* @brief LCD print API for TFT-GLCD interface
* @author Yunhui Fu (yhfudev@gmail.com)
* @version 1.0
* @date 2016-08-19
* @copyright GPL/BSD
*/

/**
* Due to the limitation of the HD44780 hardware, the current available LCD modules can only support
* Western(English), Cyrillic(Russian), Kana(Japanese) charsets.
* The TFTGLCD only supports ??? languages.
*/

#include "../../inc/MarlinConfigPre.h"
Expand All @@ -26,19 +47,19 @@

int lcd_glyph_height(void) { return 1; }

typedef struct _hd44780_charmap_t {
typedef struct _TFTGLCD_charmap_t {
wchar_t uchar; // the unicode char
uint8_t idx; // the glyph of the char in the ROM
uint8_t idx2; // the char used to be combined with the idx to simulate a single char
} hd44780_charmap_t;
} TFTGLCD_charmap_t;

#ifdef __AVR__
#define IV(a) U##a
#else
#define IV(a) L##a
#endif

static const hd44780_charmap_t g_hd44780_charmap_device[] PROGMEM = {
static const TFTGLCD_charmap_t g_TFTGLCD_charmap_device[] PROGMEM = {
// sorted by uchar:
#if DISPLAY_CHARSET_HD44780 == JAPANESE

Expand Down Expand Up @@ -690,7 +711,7 @@ static const hd44780_charmap_t g_hd44780_charmap_device[] PROGMEM = {
};

// the plain ASCII replacement for various char
static const hd44780_charmap_t g_hd44780_charmap_common[] PROGMEM = {
static const TFTGLCD_charmap_t g_TFTGLCD_charmap_common[] PROGMEM = {
{IV('¡'), 'i', 0}, // A1
{IV('¢'), 'c', 0}, // A2
{IV('°'), 0x09, 0}, // B0 Marlin special: '°' LCD_STR_DEGREE (0x09)
Expand Down Expand Up @@ -950,15 +971,15 @@ 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) {
static int TFTGLCD_charmap_compare(TFTGLCD_charmap_t * v1, TFTGLCD_charmap_t * v2) {
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) {
hd44780_charmap_t localval;
hd44780_charmap_t *p_hd44780_charmap = (hd44780_charmap_t *)userdata;
memcpy_P(&localval, p_hd44780_charmap + idx, sizeof(localval));
return hd44780_charmap_compare(&localval, (hd44780_charmap_t *)data_pin);
TFTGLCD_charmap_t localval;
TFTGLCD_charmap_t *p_TFTGLCD_charmap = (TFTGLCD_charmap_t *)userdata;
memcpy_P(&localval, p_TFTGLCD_charmap + idx, sizeof(localval));
return TFTGLCD_charmap_compare(&localval, (TFTGLCD_charmap_t *)data_pin);
}

void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) { lcd.setCursor(col, row); }
Expand All @@ -975,8 +996,8 @@ 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 = nullptr;
TFTGLCD_charmap_t pinval;
TFTGLCD_charmap_t *copy_address = nullptr;
pinval.uchar = c;
pinval.idx = -1;

Expand All @@ -987,17 +1008,17 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
return 1;
}
copy_address = nullptr;
ret = pf_bsearch_r((void *)g_hd44780_charmap_device, COUNT(g_hd44780_charmap_device), pf_bsearch_cb_comp_hd4map_pgm, (void *)&pinval, &idx);
ret = pf_bsearch_r((void *)g_TFTGLCD_charmap_device, COUNT(g_TFTGLCD_charmap_device), pf_bsearch_cb_comp_hd4map_pgm, (void *)&pinval, &idx);
if (ret >= 0) {
copy_address = (hd44780_charmap_t *)(g_hd44780_charmap_device + idx);
copy_address = (TFTGLCD_charmap_t *)(g_TFTGLCD_charmap_device + idx);
}
else {
ret = pf_bsearch_r((void *)g_hd44780_charmap_common, COUNT(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);
ret = pf_bsearch_r((void *)g_TFTGLCD_charmap_common, COUNT(g_TFTGLCD_charmap_common), pf_bsearch_cb_comp_hd4map_pgm, (void *)&pinval, &idx);
if (ret >= 0) copy_address = (TFTGLCD_charmap_t *)(g_TFTGLCD_charmap_common + idx);
}

if (ret >= 0) {
hd44780_charmap_t localval;
TFTGLCD_charmap_t localval;
// found
memcpy_P(&localval, copy_address, sizeof(localval));
lcd.write(localval.idx);
Expand Down Expand Up @@ -1046,11 +1067,11 @@ int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {

#if ENABLED(DEBUG_LCDPRINT)

int test_hd44780_charmap(hd44780_charmap_t *data, size_t size, char *name, char flg_show_contents) {
int test_TFTGLCD_charmap(TFTGLCD_charmap_t *data, size_t size, char *name, char flg_show_contents) {
int ret;
size_t idx = 0;
hd44780_charmap_t preval = {0, 0, 0};
hd44780_charmap_t pinval = {0, 0, 0};
TFTGLCD_charmap_t preval = {0, 0, 0};
TFTGLCD_charmap_t pinval = {0, 0, 0};
char flg_error = 0;

int i;
Expand Down Expand Up @@ -1098,15 +1119,15 @@ int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
return 0;
}

int test_hd44780_charmap_all(void) {
int test_TFTGLCD_charmap_all(void) {
int flg_error = 0;
if (test_hd44780_charmap(g_hd44780_charmap_device, COUNT(g_hd44780_charmap_device), "g_hd44780_charmap_device", 0) < 0) {
if (test_TFTGLCD_charmap(g_TFTGLCD_charmap_device, COUNT(g_TFTGLCD_charmap_device), "g_TFTGLCD_charmap_device", 0) < 0) {
flg_error = 1;
test_hd44780_charmap(g_hd44780_charmap_device, COUNT(g_hd44780_charmap_device), "g_hd44780_charmap_device", 1);
test_TFTGLCD_charmap(g_TFTGLCD_charmap_device, COUNT(g_TFTGLCD_charmap_device), "g_TFTGLCD_charmap_device", 1);
}
if (test_hd44780_charmap(g_hd44780_charmap_common, COUNT(g_hd44780_charmap_common), "g_hd44780_charmap_common", 0) < 0) {
if (test_TFTGLCD_charmap(g_TFTGLCD_charmap_common, COUNT(g_TFTGLCD_charmap_common), "g_TFTGLCD_charmap_common", 0) < 0) {
flg_error = 1;
test_hd44780_charmap(g_hd44780_charmap_common, COUNT(g_hd44780_charmap_common), "g_hd44780_charmap_common", 1);
test_TFTGLCD_charmap(g_TFTGLCD_charmap_common, COUNT(g_TFTGLCD_charmap_common), "g_TFTGLCD_charmap_common", 1);
}
if (flg_error) {
TRACE("\nFAILED in hd44780 tests!\n");
Expand Down
9 changes: 5 additions & 4 deletions Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,18 @@
#define SDSS PA4

/**
* -------------------------------------BTT002 V1.0-----------------------------------------------
* _____ _____ |
* -------------------------------------BTT002 V1.0--------------------------------------------
* ----- ----- |
* PA3 | · · | GND 5V | · · | GND |
* NRESET | · · | PC4(SD_DET) (LCD_D7) PE13 | · · | PE12 (LCD_D6) |
* (MOSI)PA7 | · · | PB0(BTN_EN2) (LCD_D5) PE11 | · · | PE10 (LCD_D4) |
* (SD_SS)PA4 | · · | PC5(BTN_EN1) (LCD_RS) PE8 | · · | PE9 (LCD_EN) |
* (SCK)PA5 | · · | PA6(MISO) (BTN_ENC) PB1 | · · | PE7 (BEEPER) |
*  ̄ ̄  ̄ ̄ |
* ----- ----- |
* EXP2 EXP1 |
* ---------------------------------------------------------------------------------------------
* --------------------------------------------------------------------------------------------
*/

//
// LCDs and Controllers
//
Expand Down
10 changes: 7 additions & 3 deletions Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,12 @@
// overriding pins to access.
//
#if SD_CONNECTION_IS(LCD)

#define SD_DETECT_PIN PB10
#define SDSS PB12

#elif SD_CONNECTION_IS(ONBOARD)

// Instruct the STM32 HAL to override the default SPI pins from the variant.h file
#define CUSTOM_SPI_PINS
#define SDSS PA4
Expand All @@ -301,18 +304,19 @@
#define MISO_PIN PA6
#define MOSI_PIN PA7
#define SD_DETECT_PIN PC4

#elif SD_CONNECTION_IS(CUSTOM_CABLE)
#define "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board"
#error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board"
#endif

/**
* _____ _____
* ----- -----
* NC | · · | GND 5V | · · | GND
* RESET | · · | PB10(SD_DETECT) (LCD_D7) PG5 | · · | PG6 (LCD_D6)
* (MOSI)PB15 | · · | PH10(BTN_EN2) (LCD_D5) PG7 | · · | PG8 (LCD_D4)
* (SD_SS)PB12 | · · | PD10(BTN_EN1) (LCD_RS) PA8 | · · | PC10 (LCD_EN)
* (SCK)PB13 | · · | PB14(MISO) (BTN_ENC) PA15 | · · | PC11 (BEEPER)
*  ̄ ̄  ̄ ̄
* ----- -----
* EXP2 EXP1
*/

Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@
#endif

/**
* _____ _____
* ----- -----
* NC | · · | GND 5V | · · | GND
* RESET | · · | PF12(SD_DETECT) (LCD_D7) PG7 | · · | PG6 (LCD_D6)
* (MOSI)PB15 | · · | PF11(BTN_EN2) (LCD_D5) PG3 | · · | PG2 (LCD_D4)
* (SD_SS)PB12 | · · | PG10(BTN_EN1) (LCD_RS) PD10 | · · | PD11 (LCD_EN)
* (SCK)PB13 | · · | PB14(MISO) (BTN_ENC) PA8 | · · | PG4 (BEEPER)
*  ̄ ̄ ̄  ̄ ̄ ̄
* ----- -----
* EXP2 EXP1
*/

Expand Down Expand Up @@ -377,12 +377,12 @@
//

/**
* _____
* -----
* TX | 1 2 | GND Enable PG1 // Must be high for module to run
* Enable | 3 4 | GPIO2 Reset PG0 // active low, probably OK to leave floating
* Reset | 5 6 | GPIO0 GPIO2 PF15 // must be high (ESP3D software configures this with a pullup so OK to leave as floating)
* 3.3V| 7 8 | RX GPIO0 PF14 // Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating)
*  ̄ ̄
* 3.3V | 7 8 | RX GPIO0 PF14 // Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating)
* -----
* W1
*/
#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this
Expand Down
4 changes: 0 additions & 4 deletions buildroot/share/PlatformIO/scripts/common-dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@
#define USES_LIQUIDCRYSTAL
#endif

#if BOTH(ANYCUBIC_LCD_I3MEGA, EXTENSIBLE_UI)
#define HAS_ANYCUBIC_TFT_EXTUI
#endif

#if SAVED_POSITIONS
#define HAS_SAVED_POSITIONS
#endif
Expand Down
8 changes: 4 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
-<src/lcd/extui/example.cpp>
-<src/lcd/extui/malyan_lcd.cpp>
-<src/lcd/extui/lib/ftdi_eve_touch_ui>
-<src/lcd/extui/lib/anycubic_i3mega>
-<src/lcd/extui/anycubic_tft.cpp>
-<src/lcd/extui/anycubic_chiron_lcd.cpp> -<src/lcd/extui/lib/anycubic_i3mega>
-<src/lcd/extui/anycubic_i3mega_lcd.cpp>
-<src/lcd/lcdprint.cpp>
-<src/sd/usb_flashdrive>
-<src/feature/backlash.cpp>
Expand Down Expand Up @@ -241,10 +241,10 @@ HAS_MENU_TEMPERATURE = src_filter=+<src/lcd/menu/menu_temperature.cpp>
HAS_MENU_TMC = src_filter=+<src/lcd/menu/menu_tmc.cpp>
HAS_MENU_TOUCH_SCREEN = src_filter=+<src/lcd/menu/menu_touch_screen.cpp>
HAS_MENU_UBL = src_filter=+<src/lcd/menu/menu_ubl.cpp>
ANYCUBIC_LCD_I3MEGA = src_filter=+<src/lcd/extui/lib/anycubic_i3mega>
ANYCUBIC_LCD_CHIRON = src_filter=+<src/lcd/extui/anycubic_chiron_lcd.cpp>
ANYCUBIC_LCD_I3MEGA = src_filter=+<src/lcd/extui/anycubic_i3mega_lcd.cpp> +<src/lcd/extui/lib/anycubic_i3mega>
HAS_DGUS_LCD = src_filter=+<src/lcd/extui/lib/dgus> +<src/lcd/extui/dgus_lcd.cpp>
TOUCH_UI_FTDI_EVE = src_filter=+<src/lcd/extui/lib/ftdi_eve_touch_ui>
HAS_ANYCUBIC_TFT_EXTUI = src_filter=+<src/lcd/extui/anycubic_tft.cpp>
EXTUI_EXAMPLE = src_filter=+<src/lcd/extui/example.cpp>
MALYAN_LCD = src_filter=+<src/lcd/extui/malyan_lcd.cpp>
HAS_SPI_LCD = src_filter=+<src/lcd/lcdprint.cpp>
Expand Down

0 comments on commit 53279b0

Please sign in to comment.