|
|
@ -20,40 +20,39 @@ |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
u8g_dev_tft_320x240_upscale_from_128x64.cpp |
|
|
|
|
|
|
|
Universal 8bit Graphics Library |
|
|
|
|
|
|
|
Copyright (c) 2011, olikraus@gmail.com |
|
|
|
All rights reserved. |
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification, |
|
|
|
are permitted provided that the following conditions are met: |
|
|
|
|
|
|
|
/**
|
|
|
|
* u8g_dev_tft_320x240_upscale_from_128x64.cpp |
|
|
|
* |
|
|
|
* Universal 8bit Graphics Library |
|
|
|
* |
|
|
|
* Copyright (c) 2011, olikraus@gmail.com |
|
|
|
* All rights reserved. |
|
|
|
* |
|
|
|
* Redistribution and use in source and binary forms, with or without modification, |
|
|
|
* are permitted provided that the following conditions are met: |
|
|
|
* |
|
|
|
* Redistributions of source code must retain the above copyright notice, this list |
|
|
|
of conditions and the following disclaimer. |
|
|
|
|
|
|
|
* of conditions and the following disclaimer. |
|
|
|
* |
|
|
|
* Redistributions in binary form must reproduce the above copyright notice, this |
|
|
|
list of conditions and the following disclaimer in the documentation and/or other |
|
|
|
materials provided with the distribution. |
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
|
|
|
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
|
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
|
|
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
|
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|
|
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
|
|
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
|
|
|
|
|
*/ |
|
|
|
* list of conditions and the following disclaimer in the documentation and/or other |
|
|
|
* materials provided with the distribution. |
|
|
|
* |
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
#include "../../inc/MarlinConfig.h" |
|
|
|
|
|
|
@ -84,10 +83,12 @@ |
|
|
|
#define HEIGHT LCD_PIXEL_HEIGHT |
|
|
|
#define PAGE_HEIGHT 8 |
|
|
|
|
|
|
|
#define X_LO LCD_PIXEL_OFFSET_X |
|
|
|
#define Y_LO LCD_PIXEL_OFFSET_Y |
|
|
|
#define X_HI (X_LO + (FSMC_UPSCALE) * WIDTH - 1) |
|
|
|
#define Y_HI (Y_LO + (FSMC_UPSCALE) * HEIGHT - 1) |
|
|
|
#include "../scaled_tft.h" |
|
|
|
|
|
|
|
#define UPSCALE0(M) ((M) * (FSMC_UPSCALE)) |
|
|
|
#define UPSCALE(A,M) (UPSCALE0(M) + (A)) |
|
|
|
#define X_HI (UPSCALE(LCD_PIXEL_OFFSET_X, WIDTH) - 1) |
|
|
|
#define Y_HI (UPSCALE(LCD_PIXEL_OFFSET_Y, HEIGHT) - 1) |
|
|
|
|
|
|
|
// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
|
|
|
|
|
|
|
@ -153,7 +154,6 @@ static uint32_t lcd_id = 0; |
|
|
|
#define ILI9328_VASTART 0x52 /* Vertical address start position (0-511) */ |
|
|
|
#define ILI9328_VAEND 0x53 /* Vertical address end position (0-511) */ |
|
|
|
|
|
|
|
|
|
|
|
static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { |
|
|
|
#if HAS_LCD_IO |
|
|
|
#define IO_REG_DATA(R,D) do { LCD_IO_WriteReg(R); LCD_IO_WriteData(D); }while(0) |
|
|
@ -216,7 +216,6 @@ static void setWindow_st7789v(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_ |
|
|
|
static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {} |
|
|
|
void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none; |
|
|
|
|
|
|
|
|
|
|
|
#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x |
|
|
|
#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF) |
|
|
|
#define ESC_END 0xFFFF, 0x7FFF |
|
|
@ -552,20 +551,20 @@ static const uint16_t st9677_init[] = { |
|
|
|
#define BUTTON_SIZE_Y 20 |
|
|
|
|
|
|
|
// 14, 90, 166, 242, 185 are the original values upscaled 2x.
|
|
|
|
#define BUTTOND_X_LO (14 / 2) * (FSMC_UPSCALE) |
|
|
|
#define BUTTOND_X_HI (BUTTOND_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1) |
|
|
|
#define BUTTOND_X_LO UPSCALE0(14 / 2) |
|
|
|
#define BUTTOND_X_HI (UPSCALE(BUTTOND_X_LO, BUTTON_SIZE_X) - 1) |
|
|
|
|
|
|
|
#define BUTTONA_X_LO (90 / 2) * (FSMC_UPSCALE) |
|
|
|
#define BUTTONA_X_HI (BUTTONA_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1) |
|
|
|
#define BUTTONA_X_LO UPSCALE0(90 / 2) |
|
|
|
#define BUTTONA_X_HI (UPSCALE(BUTTONA_X_LO, BUTTON_SIZE_X) - 1) |
|
|
|
|
|
|
|
#define BUTTONB_X_LO (166 / 2) * (FSMC_UPSCALE) |
|
|
|
#define BUTTONB_X_HI (BUTTONB_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1) |
|
|
|
#define BUTTONB_X_LO UPSCALE0(166 / 2) |
|
|
|
#define BUTTONB_X_HI (UPSCALE(BUTTONB_X_LO, BUTTON_SIZE_X) - 1) |
|
|
|
|
|
|
|
#define BUTTONC_X_LO (242 / 2) * (FSMC_UPSCALE) |
|
|
|
#define BUTTONC_X_HI (BUTTONC_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1) |
|
|
|
#define BUTTONC_X_LO UPSCALE0(242 / 2) |
|
|
|
#define BUTTONC_X_HI (UPSCALE(BUTTONC_X_LO, BUTTON_SIZE_X) - 1) |
|
|
|
|
|
|
|
#define BUTTON_Y_LO (140 / 2) * (FSMC_UPSCALE) + 44 //184 2x, 254 3x
|
|
|
|
#define BUTTON_Y_HI (BUTTON_Y_LO + (FSMC_UPSCALE) * BUTTON_SIZE_Y - 1) |
|
|
|
#define BUTTON_Y_LO UPSCALE0(140 / 2) + 44 // 184 2x, 254 3x
|
|
|
|
#define BUTTON_Y_HI (UPSCALE(BUTTON_Y_LO, BUTTON_SIZE_Y) - 1) |
|
|
|
|
|
|
|
void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) { |
|
|
|
uint16_t buffer[BUTTON_SIZE_X * sq(FSMC_UPSCALE)]; |
|
|
@ -584,8 +583,8 @@ static const uint16_t st9677_init[] = { |
|
|
|
} |
|
|
|
#if HAS_LCD_IO |
|
|
|
LOOP_S_L_N(n, 1, FSMC_UPSCALE) |
|
|
|
for (uint16_t l = 0; l < length * (FSMC_UPSCALE); l++) |
|
|
|
buffer[l + (length * (FSMC_UPSCALE) * n)] = buffer[l]; |
|
|
|
for (uint16_t l = 0; l < UPSCALE0(length); l++) |
|
|
|
buffer[l + n * UPSCALE0(length)] = buffer[l]; |
|
|
|
|
|
|
|
LCD_IO_WriteSequence(buffer, length * sq(FSMC_UPSCALE)); |
|
|
|
#else |
|
|
@ -660,13 +659,13 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u |
|
|
|
} |
|
|
|
|
|
|
|
// Clear Screen
|
|
|
|
setWindow(u8g, dev, 0, 0, LCD_FULL_PIXEL_WIDTH - 1, LCD_FULL_PIXEL_HEIGHT - 1); |
|
|
|
setWindow(u8g, dev, 0, 0, (LCD_FULL_PIXEL_WIDTH) - 1, (LCD_FULL_PIXEL_HEIGHT) - 1); |
|
|
|
#if HAS_LCD_IO |
|
|
|
LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, LCD_FULL_PIXEL_WIDTH * LCD_FULL_PIXEL_HEIGHT); |
|
|
|
LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT)); |
|
|
|
#else |
|
|
|
memset2(buffer, TFT_MARLINBG_COLOR, 160); |
|
|
|
for (uint16_t i = 0; i < 960; i++) |
|
|
|
u8g_WriteSequence(u8g, dev, 160, (uint8_t *)buffer); |
|
|
|
memset2(buffer, TFT_MARLINBG_COLOR, (LCD_FULL_PIXEL_WIDTH) / 2); |
|
|
|
for (uint16_t i = 0; i < (LCD_FULL_PIXEL_WIDTH) * 3; i++) |
|
|
|
u8g_WriteSequence(u8g, dev, (LCD_FULL_PIXEL_WIDTH) / 2, (uint8_t *)buffer); |
|
|
|
#endif |
|
|
|
|
|
|
|
// Bottom buttons
|
|
|
@ -690,7 +689,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u |
|
|
|
|
|
|
|
case U8G_DEV_MSG_PAGE_FIRST: |
|
|
|
page = 0; |
|
|
|
setWindow(u8g, dev, X_LO, Y_LO, X_HI, Y_HI); |
|
|
|
setWindow(u8g, dev, LCD_PIXEL_OFFSET_X, LCD_PIXEL_OFFSET_Y, X_HI, Y_HI); |
|
|
|
break; |
|
|
|
|
|
|
|
case U8G_DEV_MSG_PAGE_NEXT: |
|
|
@ -708,8 +707,8 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u |
|
|
|
} |
|
|
|
#if HAS_LCD_IO |
|
|
|
LOOP_S_L_N(n, 1, FSMC_UPSCALE) |
|
|
|
for (uint16_t l = 0; l < WIDTH * (FSMC_UPSCALE); l++) |
|
|
|
buffer[l + WIDTH * (FSMC_UPSCALE) * n] = buffer[l]; |
|
|
|
for (uint16_t l = 0; l < UPSCALE0(WIDTH); l++) |
|
|
|
buffer[l + n * UPSCALE0(WIDTH)] = buffer[l]; |
|
|
|
|
|
|
|
if (allow_async) { |
|
|
|
if (y > 0 || page > 1) LCD_IO_WaitSequence_Async(); |
|
|
|