some updates
This commit is contained in:
parent
f972a1bb95
commit
a7ee7b77a6
|
@ -19,4 +19,7 @@ https://github.com/olikraus/u8g2 ChangeLog
|
|||
2016-06-26 v2.0.7 olikraus@gmail.com
|
||||
* drawLine
|
||||
* GraphicsTest Example
|
||||
2016-07-02 v2.1.0 olikraus@gmail.com
|
||||
* T6963 Support
|
||||
|
||||
|
||||
|
|
|
@ -1164,6 +1164,24 @@ class U8G2_T6963_240X128_F_8080 : public U8G2 {
|
|||
u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset);
|
||||
}
|
||||
};
|
||||
class U8G2_T6963_128X64_1_8080 : public U8G2 {
|
||||
public: U8G2_T6963_128X64_1_8080(const u8g2_cb_t *rotation, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
|
||||
u8g2_Setup_t6963_128x64_1(&u8g2, rotation, u8x8_byte_8bit_8080mode, u8x8_gpio_and_delay_arduino);
|
||||
u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset);
|
||||
}
|
||||
};
|
||||
class U8G2_T6963_128X64_2_8080 : public U8G2 {
|
||||
public: U8G2_T6963_128X64_2_8080(const u8g2_cb_t *rotation, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
|
||||
u8g2_Setup_t6963_128x64_2(&u8g2, rotation, u8x8_byte_8bit_8080mode, u8x8_gpio_and_delay_arduino);
|
||||
u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset);
|
||||
}
|
||||
};
|
||||
class U8G2_T6963_128X64_F_8080 : public U8G2 {
|
||||
public: U8G2_T6963_128X64_F_8080(const u8g2_cb_t *rotation, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
|
||||
u8g2_Setup_t6963_128x64_f(&u8g2, rotation, u8x8_byte_8bit_8080mode, u8x8_gpio_and_delay_arduino);
|
||||
u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset);
|
||||
}
|
||||
};
|
||||
|
||||
/* Arduino constructor list end */
|
||||
|
||||
|
|
|
@ -507,6 +507,12 @@ class U8X8_T6963_240X128_8080 : public U8X8 {
|
|||
u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset);
|
||||
}
|
||||
};
|
||||
class U8X8_T6963_128X64_8080 : public U8X8 {
|
||||
public: U8X8_T6963_128X64_8080(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
|
||||
u8x8_Setup(getU8x8(), u8x8_d_t6963_128x64, u8x8_cad_100, u8x8_byte_8bit_8080mode, u8x8_gpio_and_delay_arduino);
|
||||
u8x8_SetPin_8Bit_8080(getU8x8(), d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset);
|
||||
}
|
||||
};
|
||||
|
||||
// constructor list end
|
||||
|
||||
|
|
|
@ -399,6 +399,9 @@ uint8_t *u8g2_m_st7565_16_f(uint8_t *page_cnt);
|
|||
uint8_t *u8g2_m_t6963_30_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_t6963_30_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_t6963_30_f(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_t6963_16_1(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_t6963_16_2(uint8_t *page_cnt);
|
||||
uint8_t *u8g2_m_t6963_16_f(uint8_t *page_cnt);
|
||||
|
||||
/* u8g2_d_memory.c generated code end */
|
||||
|
||||
|
@ -455,6 +458,9 @@ void u8g2_Setup_st7565_nhd_c12832_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x
|
|||
void u8g2_Setup_t6963_240x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t6963_240x128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t6963_240x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t6963_128x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t6963_128x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
void u8g2_Setup_t6963_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
|
||||
/* u8g2_d_setup.c generated code end */
|
||||
|
||||
|
|
|
@ -165,4 +165,22 @@ uint8_t *u8g2_m_t6963_30_f(uint8_t *page_cnt)
|
|||
*page_cnt = 16;
|
||||
return buf;
|
||||
}
|
||||
uint8_t *u8g2_m_t6963_16_1(uint8_t *page_cnt)
|
||||
{
|
||||
static uint8_t buf[128];
|
||||
*page_cnt = 1;
|
||||
return buf;
|
||||
}
|
||||
uint8_t *u8g2_m_t6963_16_2(uint8_t *page_cnt)
|
||||
{
|
||||
static uint8_t buf[256];
|
||||
*page_cnt = 2;
|
||||
return buf;
|
||||
}
|
||||
uint8_t *u8g2_m_t6963_16_f(uint8_t *page_cnt)
|
||||
{
|
||||
static uint8_t buf[1024];
|
||||
*page_cnt = 8;
|
||||
return buf;
|
||||
}
|
||||
/* end of generated code */
|
||||
|
|
|
@ -479,4 +479,32 @@ void u8g2_Setup_t6963_240x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ms
|
|||
buf = u8g2_m_t6963_30_f(&tile_buf_height);
|
||||
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
|
||||
}
|
||||
/* t6963 */
|
||||
/* t6963 1 */
|
||||
void u8g2_Setup_t6963_128x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
|
||||
{
|
||||
uint8_t tile_buf_height;
|
||||
uint8_t *buf;
|
||||
u8g2_SetupDisplay(u8g2, u8x8_d_t6963_128x64, u8x8_cad_100, byte_cb, gpio_and_delay_cb);
|
||||
buf = u8g2_m_t6963_16_1(&tile_buf_height);
|
||||
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
|
||||
}
|
||||
/* t6963 2 */
|
||||
void u8g2_Setup_t6963_128x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
|
||||
{
|
||||
uint8_t tile_buf_height;
|
||||
uint8_t *buf;
|
||||
u8g2_SetupDisplay(u8g2, u8x8_d_t6963_128x64, u8x8_cad_100, byte_cb, gpio_and_delay_cb);
|
||||
buf = u8g2_m_t6963_16_2(&tile_buf_height);
|
||||
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
|
||||
}
|
||||
/* t6963 f */
|
||||
void u8g2_Setup_t6963_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
|
||||
{
|
||||
uint8_t tile_buf_height;
|
||||
uint8_t *buf;
|
||||
u8g2_SetupDisplay(u8g2, u8x8_d_t6963_128x64, u8x8_cad_100, byte_cb, gpio_and_delay_cb);
|
||||
buf = u8g2_m_t6963_16_f(&tile_buf_height);
|
||||
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
|
||||
}
|
||||
/* end of generated code */
|
||||
|
|
|
@ -672,6 +672,7 @@ uint8_t u8x8_d_st7565_ea_dogm128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, voi
|
|||
uint8_t u8x8_d_st7565_nhd_c12832(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_ld7032_60x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_t6963_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_d_t6963_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
|
|
|
@ -40,55 +40,6 @@
|
|||
#include "u8x8.h"
|
||||
|
||||
|
||||
/* 240x128 */
|
||||
static const uint8_t u8x8_d_t6963_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
|
||||
U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
|
||||
U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
|
||||
U8X8_AAC(240/8,0x00,0x041), /* low, high, set text columns */
|
||||
U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
|
||||
U8X8_AAC(240/8,0x00,0x043), /* low, high, graphics columns */
|
||||
U8X8_DLY(2), /* delay 2ms */
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
|
||||
|
||||
//U8X8_C(0x0b0), /* autowrite start */
|
||||
//U8X8_D1(255),
|
||||
//U8X8_D1(255),
|
||||
//U8X8_D1(255),
|
||||
//U8X8_D1(255),
|
||||
//U8X8_D1(255),
|
||||
//U8X8_D1(255),
|
||||
//U8X8_D1(255),
|
||||
//U8X8_D1(255),
|
||||
//U8X8_C(0x0b2), /* autowrite reset */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
static const uint8_t u8x8_d_t6963_powersave0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
|
@ -116,11 +67,9 @@ uint8_t u8x8_d_t6963_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
|
|||
/*
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_init_seq);
|
||||
break;
|
||||
*/
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
if ( arg_int == 0 )
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_powersave0_seq);
|
||||
|
@ -194,6 +143,63 @@ static const u8x8_display_info_t u8x8_t6963_240x128_display_info =
|
|||
/* pixel_height = */ 128
|
||||
};
|
||||
|
||||
/* 240x128 */
|
||||
static const uint8_t u8x8_d_t6963_240x128_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
|
||||
U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
|
||||
U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
|
||||
U8X8_AAC(240/8,0x00,0x041), /* low, high, set text columns */
|
||||
U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
|
||||
U8X8_AAC(240/8,0x00,0x043), /* low, high, graphics columns */
|
||||
U8X8_DLY(2), /* delay 2ms */
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_t6963_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_240x128_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_240x128_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_t6963_128x64_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 1,
|
||||
|
@ -217,18 +223,44 @@ static const u8x8_display_info_t u8x8_t6963_128x64_display_info =
|
|||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_t6963_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_240x128_display_info);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* 240x128 */
|
||||
static const uint8_t u8x8_d_t6963_128x64_init_seq[] = {
|
||||
U8X8_DLY(100),
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_DLY(100),
|
||||
|
||||
U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
|
||||
U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
|
||||
U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
|
||||
U8X8_AAC(128/8,0x00,0x041), /* low, high, set text columns */
|
||||
U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
|
||||
U8X8_AAC(128/8,0x00,0x043), /* low, high, graphics columns */
|
||||
U8X8_DLY(2), /* delay 2ms */
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
U8X8_C(0x090), /* All Off */
|
||||
U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
|
||||
|
||||
U8X8_DLY(100),
|
||||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_DLY(100),
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_t6963_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
|
@ -237,6 +269,10 @@ uint8_t u8x8_d_t6963_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
|
|||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_128x64_display_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8x8);
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_128x64_init_seq);
|
||||
break;
|
||||
default:
|
||||
return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
//U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND
|
||||
U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND
|
||||
|
||||
|
||||
|
||||
|
@ -90,6 +90,8 @@
|
|||
//#define MINI_LOGO
|
||||
|
||||
void setup(void) {
|
||||
pinMode(18, OUTPUT);
|
||||
digitalWrite(18, 1);
|
||||
u8g2.begin();
|
||||
}
|
||||
|
||||
|
|
|
@ -214,11 +214,147 @@ const uint8_t scrollosprites[6642] U8G2_FONT_SECTION("scrollosprites") =
|
|||
"\24\16E\203\261\220(\205\22:D\16\7\3\0\0\0";
|
||||
|
||||
|
||||
/*
|
||||
maze_Redraw()
|
||||
maze_SetData()
|
||||
maze->px upper left corner (pixel pos)
|
||||
maze->py
|
||||
maze_SetPixelPos()
|
||||
maze_GetTile(tx, ty)
|
||||
|
||||
gm_SetTilePos(tx, ty)
|
||||
gm_GetCurrTile()
|
||||
gm_GetNeighborTile(dir) dir=0,1,2,3
|
||||
gm->state
|
||||
gm->tx, ty
|
||||
gm->walk_dir
|
||||
gm->px_delta, py_delta
|
||||
*/
|
||||
|
||||
/*=================================================*/
|
||||
struct map_struct
|
||||
{
|
||||
/* input: upper left corner of the visible area in the map */
|
||||
uint16_t pmx;
|
||||
uint16_t pmy;
|
||||
|
||||
/* input: dimensions of the visible window */
|
||||
uint8_t pdw;
|
||||
uint8_t pdh;
|
||||
|
||||
/* input: offset for the visible window on the display fromt he upper left display corner */
|
||||
u8g2_uint_t pdx;
|
||||
u8g2_uint_t pdy;
|
||||
|
||||
|
||||
|
||||
/* upper left tile, derived from px, py */
|
||||
uint16_t tmx;
|
||||
uint16_t tmy;
|
||||
|
||||
/* visible area in tiles */
|
||||
uint8_t tmw;
|
||||
uint8_t tmh;
|
||||
|
||||
/* offset from the upper left tile corner to pmx/pmy */
|
||||
u8g2_uint_t dpx;
|
||||
u8g2_uint_t dpy;
|
||||
|
||||
};
|
||||
typedef struct map_struct map_t;
|
||||
|
||||
void map_Init(map_t *m)
|
||||
{
|
||||
/* constants */
|
||||
m->pdw = 128;
|
||||
m->pdh = 64;
|
||||
m->pdx = 0;
|
||||
m->pdy = 0;
|
||||
|
||||
m->tmw = (m->pdw + 15)/16;
|
||||
m->tmh = (m->pdh + 15)/16;
|
||||
}
|
||||
|
||||
/* set the position of the visible window in the map */
|
||||
void map_SetWindowPos(map_t *m, uint16_t x, uint16_t y)
|
||||
{
|
||||
m->pmx = x;
|
||||
x >>= 4;
|
||||
m->tmx = x;
|
||||
m->dpx = (m->pmx - (x<<4));
|
||||
|
||||
m->pmy = y;
|
||||
y >>= 4;
|
||||
m->tmy = y;
|
||||
m->dpy = (m->pmy - (y<<4));
|
||||
|
||||
printf("pmx=%u tmx=%u delta-x=%u\n", m->pmx, m->tmx, m->dpx);
|
||||
printf("pmy=%u tmy=%u delta-y=%u\n", m->pmy, m->tmy, m->dpy);
|
||||
}
|
||||
|
||||
uint8_t map_GetTile(map_t *m, uint16_t tx, uint16_t ty)
|
||||
{
|
||||
static uint8_t map[12][12+1] =
|
||||
{
|
||||
"\x80\x7d\x7d\x7d\x7d\x7d\x7d\x7d\x7d\x7d\x7d\x81",
|
||||
"\x7e\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x7e",
|
||||
"\x7e\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x7e",
|
||||
"\x7e\x20\x43\x20\x20\x20\x20\x20\x20\x4e\x20\x7e",
|
||||
"\x7e\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x7e",
|
||||
"\x7e\x20\x20\x20\x20\x20\x45\x20\x20\x20\x20\x7e",
|
||||
"\x7e\x20\x20\x20\x20\x20\x20\x20\x20\x20\x93\x7e",
|
||||
"\x7e\x20\x20\x20\x20\x20\x20\xa0\x20\x20\x20\x7e",
|
||||
"\x7e\x20\x50\x20\x20\x20\x20\x20\x20\x20\x20\x7e",
|
||||
"\x7e\x20\x20\x20\x91\x20\x20\x20\x20\x92\x20\x7e",
|
||||
"\x7e\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x7e",
|
||||
"\x82\x7d\x7d\x7d\x7d\x7d\x7d\x7d\x7d\x7d\x7d\x83"
|
||||
};
|
||||
|
||||
/* pixel dimensions are 2^16 * 2^16, this means tile dimension is 4096x4096 */
|
||||
/* as a consequence, wrap around at 4096 */
|
||||
/* am not sure to do this here, maybe it should be done outside this proc */
|
||||
tx &= 0x0fff;
|
||||
ty &= 0x0fff;
|
||||
if ( tx > 12 )
|
||||
return 32;
|
||||
if ( ty > 12 )
|
||||
return 32;
|
||||
return map[ty][tx];
|
||||
}
|
||||
|
||||
void map_Draw(map_t *m, u8g2_t *u8g2)
|
||||
{
|
||||
uint16_t tx;
|
||||
uint16_t ty;
|
||||
u8g2_uint_t px, ppx;
|
||||
u8g2_uint_t py;
|
||||
|
||||
px = m->pdx;
|
||||
px -= m->dpx;
|
||||
|
||||
py = m->pdy;
|
||||
py -= m->dpy;
|
||||
|
||||
for( ty = 0; ty < m->tmh; ty++ )
|
||||
{
|
||||
ppx = px;
|
||||
for( tx = 0; tx < m->tmw; tx++ )
|
||||
{
|
||||
u8g2_DrawGlyph(u8g2, ppx, py, map_GetTile(m, tx+m->tmx, ty+m->tmy));
|
||||
ppx += 16;
|
||||
}
|
||||
py += 16;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
u8g2_t u8g2;
|
||||
map_t map;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x, y;
|
||||
uint16_t x, y;
|
||||
int k;
|
||||
int i;
|
||||
|
||||
|
@ -231,6 +367,9 @@ int main(void)
|
|||
x = 50;
|
||||
y = 30;
|
||||
|
||||
map_Init(&map);
|
||||
map_SetWindowPos(&map, 0, 0);
|
||||
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
@ -241,9 +380,13 @@ int main(void)
|
|||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawStr(&u8g2, x, y, "\x80\x7d\x81");
|
||||
map_Draw(&map, &u8g2);
|
||||
/*
|
||||
u8g2_DrawGlyph(&u8g2, -1, 48, 0x052);
|
||||
u8g2_DrawStr(&u8g2, x, y , "\x80\x7d\x86\x7d\x7d\x7d");
|
||||
u8g2_DrawStr(&u8g2, x, y+16, "\x7e\x52\x7e");
|
||||
u8g2_DrawStr(&u8g2, x, y+32, "\x82\x7d\x83");
|
||||
*/
|
||||
|
||||
|
||||
i++;
|
||||
|
@ -266,6 +409,8 @@ int main(void)
|
|||
if ( k == 's' ) x -= 1;
|
||||
if ( k == 'd' ) x += 1;
|
||||
if ( k == 'q' ) break;
|
||||
|
||||
map_SetWindowPos(&map, x, y);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -185,6 +185,13 @@ struct controller controller_list[] =
|
|||
{ NULL }
|
||||
}
|
||||
},
|
||||
{
|
||||
"t6963", 16, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080,
|
||||
{
|
||||
{ "128x64" },
|
||||
{ NULL }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct interface interface_list[] =
|
||||
|
|
Loading…
Reference in New Issue