added support for ls013b7dh03 128x128 display

This commit is contained in:
olikraus 2016-05-24 20:26:46 +02:00
parent 44bf9f3a72
commit 2e72f214dd
12 changed files with 322 additions and 36 deletions

View File

@ -701,6 +701,42 @@ class U8G2_ST7920_128X64_F_SW_SPI : public U8G2 {
u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset);
}
};
class U8G2_LS913B7DH03_128X128_1_4W_SW_SPI : public U8G2 {
public: U8G2_LS913B7DH03_128X128_1_4W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ls913b7dh03_128x128_1(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
class U8G2_LS913B7DH03_128X128_1_4W_HW_SPI : public U8G2 {
public: U8G2_LS913B7DH03_128X128_1_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ls913b7dh03_128x128_1(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_LS913B7DH03_128X128_2_4W_SW_SPI : public U8G2 {
public: U8G2_LS913B7DH03_128X128_2_4W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ls913b7dh03_128x128_2(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
class U8G2_LS913B7DH03_128X128_2_4W_HW_SPI : public U8G2 {
public: U8G2_LS913B7DH03_128X128_2_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ls913b7dh03_128x128_2(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_LS913B7DH03_128X128_F_4W_SW_SPI : public U8G2 {
public: U8G2_LS913B7DH03_128X128_F_4W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ls913b7dh03_128x128_f(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
class U8G2_LS913B7DH03_128X128_F_4W_HW_SPI : public U8G2 {
public: U8G2_LS913B7DH03_128X128_F_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ls913b7dh03_128x128_f(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_UC1701_DOGS102_1_4W_SW_SPI : public U8G2 {
public: U8G2_UC1701_DOGS102_1_4W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_uc1701_dogs102_1(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);

View File

@ -349,6 +349,18 @@ class U8X8_ST7920_128X64_SW_SPI : public U8X8 {
u8x8_SetPin_3Wire_SW_SPI(getU8x8(), clock, data, cs, reset);
}
};
class U8X8_LS913B7DH03_128X128_4W_SW_SPI : public U8X8 {
public: U8X8_LS913B7DH03_128X128_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_ls913b7dh03_128x128, u8x8_cad_001, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
class U8X8_LS913B7DH03_128X128_4W_HW_SPI : public U8X8 {
public: U8X8_LS913B7DH03_128X128_4W_HW_SPI(uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_ls913b7dh03_128x128, u8x8_cad_001, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8X8_UC1701_DOGS102_4W_SW_SPI : public U8X8 {
public: U8X8_UC1701_DOGS102_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_uc1701_dogs102, u8x8_cad_001, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);

View File

@ -381,6 +381,9 @@ uint8_t *u8g2_m_st7920_24_f(uint8_t *page_cnt);
uint8_t *u8g2_m_st7920_16_1(uint8_t *page_cnt);
uint8_t *u8g2_m_st7920_16_2(uint8_t *page_cnt);
uint8_t *u8g2_m_st7920_16_f(uint8_t *page_cnt);
uint8_t *u8g2_m_ls913b7dh03_16_1(uint8_t *page_cnt);
uint8_t *u8g2_m_ls913b7dh03_16_2(uint8_t *page_cnt);
uint8_t *u8g2_m_ls913b7dh03_16_f(uint8_t *page_cnt);
uint8_t *u8g2_m_uc1701_13_1(uint8_t *page_cnt);
uint8_t *u8g2_m_uc1701_13_2(uint8_t *page_cnt);
uint8_t *u8g2_m_uc1701_13_f(uint8_t *page_cnt);
@ -419,6 +422,9 @@ void u8g2_Setup_st7920_p_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_
void u8g2_Setup_st7920_s_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_st7920_s_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_st7920_s_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_ls913b7dh03_128x128_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_ls913b7dh03_128x128_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_ls913b7dh03_128x128_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_uc1701_dogs102_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_uc1701_dogs102_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_uc1701_dogs102_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);

View File

@ -75,6 +75,24 @@ uint8_t *u8g2_m_st7920_16_f(uint8_t *page_cnt)
*page_cnt = 8;
return buf;
}
uint8_t *u8g2_m_ls913b7dh03_16_1(uint8_t *page_cnt)
{
static uint8_t buf[128];
*page_cnt = 1;
return buf;
}
uint8_t *u8g2_m_ls913b7dh03_16_2(uint8_t *page_cnt)
{
static uint8_t buf[256];
*page_cnt = 2;
return buf;
}
uint8_t *u8g2_m_ls913b7dh03_16_f(uint8_t *page_cnt)
{
static uint8_t buf[2048];
*page_cnt = 16;
return buf;
}
uint8_t *u8g2_m_uc1701_13_1(uint8_t *page_cnt)
{
static uint8_t buf[104];

View File

@ -283,6 +283,34 @@ void u8g2_Setup_st7920_s_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_
buf = u8g2_m_st7920_16_f(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
}
/* ls913b7dh03 */
/* ls913b7dh03 1 */
void u8g2_Setup_ls913b7dh03_128x128_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_ls913b7dh03_128x128, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_ls913b7dh03_16_1(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
}
/* ls913b7dh03 2 */
void u8g2_Setup_ls913b7dh03_128x128_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_ls913b7dh03_128x128, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_ls913b7dh03_16_2(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
}
/* ls913b7dh03 f */
void u8g2_Setup_ls913b7dh03_128x128_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_ls913b7dh03_128x128, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_ls913b7dh03_16_f(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
}
/* uc1701 */
/* uc1701 1 */
void u8g2_Setup_uc1701_dogs102_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)

View File

@ -651,6 +651,7 @@ uint8_t u8x8_d_sh1106_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
uint8_t u8x8_d_st7920_192x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_st7920_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_ssd1306_128x32_univision(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_ls913b7dh03_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
/*==========================================*/
@ -674,11 +675,37 @@ uint8_t u8x8_GetUTF8Len(u8x8_t *u8x8, const char *s);
/*==========================================*/
/* u8x8_string.c */
uint8_t u8x8_GetStringLineCnt(const char *str);
const char *u8x8_GetStringLine(uint8_t line_idx, const char *str );
uint8_t u8x8_GetStringLineCnt(const char *str); /* return 0 for str==NULL */
const char *u8x8_GetStringLineStart(uint8_t line_idx, const char *str );
void u8x8_CopyStringLine(char *dest, const char *str);
uint8_t u8x8_DrawUTF8Line(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t w, const char *s);
uint8_t u8x8_DrawUTF8Lines(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t w, const char *s);
/*==========================================*/
/* u8x8_sl.c scrollable list */
struct _u8sl_struct
{
uint8_t visible; /* number of visible elements in the menu */
uint8_t total; /* total number of elements in the menu */
uint8_t first_pos; /* position of the first visible line */
uint8_t current_pos; /* current cursor position, starts at 0 */
uint8_t x;
uint8_t y;
};
typedef struct _u8sl_struct u8sl_t;
typedef void (*u8x8_sl_cb)(u8x8_t *u8x8, u8sl_t *u8sl, uint8_t idx, const void *aux);
uint8_t u8x8_UserInterfaceSelectionList(u8x8_t *u8x8, const char *title, uint8_t start_pos, const char *sl);
/*==========================================*/
/* u8x8_message.c */
uint8_t u8x8_UserInterfaceMessage(u8x8_t *u8x8, const char *title1, const char *title2, const char *title3, const char *buttons);
/*==========================================*/
/* start font list */
@ -723,24 +750,6 @@ extern const uint8_t u8x8_font_pcsenior_u[] U8X8_FONT_SECTION("u8x8_font_pcsenio
/* end font list */
/*==========================================*/
/* u8x8_sl.c scrollable list */
struct _u8sl_struct
{
uint8_t visible; /* number of visible elements in the menu */
uint8_t total; /* total number of elements in the menu */
uint8_t first_pos; /* position of the first visible line */
uint8_t current_pos; /* current cursor position, starts at 0 */
uint8_t x;
uint8_t y;
};
typedef struct _u8sl_struct u8sl_t;
typedef void (*u8x8_sl_cb)(u8x8_t *u8x8, u8sl_t *u8sl, uint8_t idx, const void *aux);
uint8_t u8x8_UserInterfaceSelectionList(u8x8_t *u8x8, const char *title, uint8_t start_pos, const char *sl);
#ifdef __cplusplus
}

120
csrc/u8x8_d_ls013b7dh03.c Normal file
View File

@ -0,0 +1,120 @@
/*
u8x8_d_ls013b7dh03.c
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
Copyright (c) 2016, 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.
* 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.
The LS013B7DH02 is a simple display and controller
--> no support for contrast adjustment, flip and power down.
*/
#include "u8x8.h"
static const u8x8_display_info_t u8x8_ls913b7dh03_128x128_display_info =
{
/* chip_enable_level = */ 1,
/* chip_disable_level = */ 0,
/* post_chip_enable_wait_ns = */ 255, /* 6000ns ??? */
/* pre_chip_disable_wait_ns = */ 255, /* 2000ns ??? */
/* reset_pulse_width_ms = */ 1,
/* post_reset_wait_ms = */ 6,
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
/* sck_takeover_edge = */ 1, /* rising edge */
/* i2c_bus_clock_100kHz = */ 37,
/* data_setup_time_ns = */ 100,
/* write_pulse_width_ns = */ 100,
/* tile_width = */ 16,
/* tile_hight = */ 16,
/* default_x_offset = */ 0,
/* pixel_width = */ 128,
/* pixel_height = */ 128
};
uint8_t u8x8_d_ls913b7dh03_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
uint8_t x, y, c, i;
uint8_t *ptr;
switch(msg)
{
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls913b7dh03_128x128_display_info);
break;
case U8X8_MSG_DISPLAY_INIT:
u8x8_d_helper_display_init(u8x8);
/* u8x8_cad_SendSequence(u8x8, u8x8_d_ls913b7dh03_init_seq); */
break;
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
/* not available for the ls913b7dh03 */
break;
case U8X8_MSG_DISPLAY_DRAW_TILE:
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
y++; /* lines are from 1..128, so add 1 here */
/* x has to be zero for all transfers to the ls913b7dh03 */
/* in fact all data has to start at the left edge */
u8x8_cad_StartTransfer(u8x8);
/*
Tile structure is reused here for the ls913b7dh03, however u8x8 is not supported
tile_ptr points to data which has cnt*8 bytes (same as SSD1306 tiles)
Buffer is expected to have 8 lines of code fitting to the ls913b7dh03 internal memory
"cnt" includes the number of horizontal bytes. width is equal to cnt*8
*/
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles. This must be 16 for the ls913b7dh03 128x128 */
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
for( i = 0; i < 8; i++ )
{
u8x8_cad_SendCmd(u8x8, 0x080 ); /* data mode byte */
u8x8_cad_SendCmd(u8x8, y ); /* y pos */
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
u8x8_cad_SendCmd(u8x8, 0); /* two bytes of dummy data */
u8x8_cad_SendCmd(u8x8, 0); /* two bytes of dummy data */
ptr += c;
}
u8x8_cad_EndTransfer(u8x8);
break;
default:
return 0;
}
return 1;
}

View File

@ -48,7 +48,7 @@ uint8_t u8x8_draw_button_line(u8x8_t *u8x8, uint8_t y, uint8_t w, uint8_t cursor
total = 0;
for( i = 0; i < cnt; i++ )
{
total += u8x8_GetUTF8Len(u8x8, u8x8_GetStringLine(i, s));
total += u8x8_GetUTF8Len(u8x8, u8x8_GetStringLineStart(i, s));
}
total += (cnt-1); /* had one space between the buttons */
@ -63,45 +63,65 @@ uint8_t u8x8_draw_button_line(u8x8_t *u8x8, uint8_t y, uint8_t w, uint8_t cursor
/* draw the buttons */
x = d;
u8x8_SetInverseFont(u8x8, 0);
for( i = 0; i < cnt; i++ )
{
if ( i == cursor )
u8x8_SetInverseFont(u8x8, 1);
else
u8x8_SetInverseFont(u8x8, 0);
x+=u8x8_DrawUTF8(x, y, u8x8_GetStringLine(i, s));
x+=u8x8_DrawUTF8(x, y, " ");
x+=u8x8_DrawUTF8(u8x8, x, y, u8x8_GetStringLineStart(i, s));
u8x8_SetInverseFont(u8x8, 0);
x+=u8x8_DrawUTF8(u8x8, x, y, " ");
}
/* return the number of buttons */
return cnt;
}
uint8_t u8x8_UserInterfaceMessage(u8x8_t *u8x8, const char *title1, const char *title2, const char *buttons, )
/*
title1: Multiple lines,separated by '\n'
title2: A single line/string which is terminated by '\0' or '\n' . "title2" accepts the return value from u8x8_GetStringLineStart()
title3: Multiple lines,separated by '\n'
buttons: one more more buttons separated by '\n' and terminated with '\0'
*/
uint8_t u8x8_UserInterfaceMessage(u8x8_t *u8x8, const char *title1, const char *title2, const char *title3, const char *buttons)
{
uint8_t height;
uint8_t y;
uint8_t cursor = 0;
uint8_t button_cnt;
uint8_t event;
/* calculate overall height of the message box */
u8x8_SetInverseFont(u8x8, 0);
height = 1; /* button line */
height += u8x8_GetStringLineCnt(title1);
height += u8x8_GetStringLineCnt(title2);
if ( title2 != NULL )
height ++;
height += u8x8_GetStringLineCnt(title3);
/* calculate offset from the top */
y = 0;
if ( u8x8_GetRows(u8x8) < height )
if ( height < u8x8_GetRows(u8x8) )
{
y = height;
y -= u8x8_GetRows(u8x8);
y = u8x8_GetRows(u8x8);
y -= height;
y /= 2;
}
u8x8_ClearDisplay(u8x8); /* required, because not everything is filled */
y += u8x8_DrawUTF8Lines(u8x8, 0, y, u8x8_GetCols(u8x8), title1);
y += u8x8_DrawUTF8Lines(u8x8, 0, y, u8x8_GetCols(u8x8), title2);
if ( title2 != NULL )
{
u8x8_DrawUTF8Line(u8x8, 0, y, u8x8_GetCols(u8x8), title2);
y++;
}
y += u8x8_DrawUTF8Lines(u8x8, 0, y, u8x8_GetCols(u8x8), title3);
button_cnt = u8x8_draw_button_line(u8x8, y, u8x8_GetCols(u8x8), cursor, buttons);
for(;;)

View File

@ -102,12 +102,13 @@ void u8x8_sl_string_line_cb(u8x8_t *u8x8, u8sl_t *u8sl, uint8_t idx, const void
u8x8_SetInverseFont(u8x8, 0);
/* get the line from the array */
s = u8x8_GetStringLine(idx, (const char *)aux);
s = u8x8_GetStringLineStart(idx, (const char *)aux);
/* draw the line */
if ( s == NULL )
s = "";
u8x8_DrawUTF8Line(u8x8, u8sl->x, row, u8x8_GetCols(u8x8), s);
u8x8_SetInverseFont(u8x8, 0);
}
/*
@ -131,6 +132,7 @@ uint8_t u8x8_UserInterfaceSelectionList(u8x8_t *u8x8, const char *title, uint8_t
u8sl.y = 0;
//u8x8_ClearDisplay(u8x8); /* not required because all is 100% filled */
u8x8_SetInverseFont(u8x8, 0);
if ( title != NULL )
{

View File

@ -63,7 +63,7 @@ uint8_t u8x8_GetStringLineCnt(const char *str)
Returns "xyz" for line_idx = 1 with str = "abc\nxyz"
Support both UTF8 and normal strings.
*/
const char *u8x8_GetStringLine(uint8_t line_idx, const char *str )
const char *u8x8_GetStringLineStart(uint8_t line_idx, const char *str )
{
char e;
uint8_t line_cnt = 1;
@ -84,10 +84,28 @@ const char *u8x8_GetStringLine(uint8_t line_idx, const char *str )
line_cnt++;
}
}
return NULL; /* line not found */
}
/* copy until first '\n' or '\0' in str */
void u8x8_CopyStringLine(char *dest, const char *str)
{
if ( dest == NULL )
return;
if ( str != NULL )
{
for(;;)
{
if ( *str == '\n' || *str == '\0' )
break;
*dest = *str;
dest++;
str++;
}
}
*dest = '\0';
}
/*
Draw a string
Extend the string to size "w"
@ -135,6 +153,7 @@ uint8_t u8x8_DrawUTF8Line(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t w, const c
draw several lines at position x,y.
lines are stored in s and must be separated with '\n'.
lines can be centered with respect to "w" if the first char in the line is a '\t'
if s == NULL nothing is drawn and 0 is returned
returns the number of lines in s
*/
uint8_t u8x8_DrawUTF8Lines(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t w, const char *s)
@ -144,7 +163,7 @@ uint8_t u8x8_DrawUTF8Lines(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t w, const
cnt = u8x8_GetStringLineCnt(s);
for( i = 0; i < cnt; i++ )
{
u8x8_DrawUTF8Line(u8x8, x, y, w, u8x8_GetStringLine(i, s));
u8x8_DrawUTF8Line(u8x8, x, y, w, u8x8_GetStringLineStart(i, s));
y++;
}
return cnt;

View File

@ -87,10 +87,19 @@ uint8_t current_selection = 0;
void loop(void) {
current_selection = u8x8_UserInterfaceSelectionList(
u8x8.getU8x8(),
"\tCloud Types\n\t-----------",
current_selection,
string_list);
u8x8_UserInterfaceMessage(
u8x8.getU8x8(),
"\tSelection:",
u8x8_GetStringLineStart(current_selection, string_list ),
"",
" ok \n cancel ");
}

View File

@ -135,6 +135,13 @@ struct controller controller_list[] =
{ NULL }
}
},
{
"ls913b7dh03", 16, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "", COM_4WSPI, /* cad procedure is not required (no DC for this display) so it could be a dummy procedure here */
{
{ "128x128" },
{ NULL }
}
},
{
"uc1701", 13, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
{