This commit is contained in:
kraus 2021-09-26 19:05:09 +02:00
parent ae3c8d4cc4
commit af8ba07b31
4 changed files with 158 additions and 6 deletions

View File

@ -850,12 +850,12 @@ void mui_RestoreForm(mui_t *ui)
void mui_NextField(mui_t *ui)
{
do
{
{
if ( mui_send_cursor_msg(ui, MUIF_MSG_EVENT_NEXT) )
return;
mui_send_cursor_msg(ui, MUIF_MSG_CURSOR_LEAVE);
mui_next_field(ui);
} while ( mui_send_cursor_enter_msg(ui) == 255 );
} while ( mui_send_cursor_enter_msg(ui) == 255 );
}
/*

View File

@ -242,6 +242,54 @@ void mui_u8g2_draw_button_pf(mui_t *ui, u8g2_uint_t width, u8g2_uint_t padding_h
}
static uint8_t mui_u8g2_handle_scroll_next_prev_events(mui_t *ui, uint8_t msg) MUI_NOINLINE;
static uint8_t mui_u8g2_handle_scroll_next_prev_events(mui_t *ui, uint8_t msg)
{
uint8_t arg = ui->arg;
switch(msg)
{
case MUIF_MSG_CURSOR_ENTER:
if ( (arg > 0) && (ui->form_scroll_top + arg >= ui->form_scroll_total) )
return 255;
break;
case MUIF_MSG_EVENT_NEXT:
if ( arg+1 == ui->form_scroll_visible )
{
if ( ui->form_scroll_visible + ui->form_scroll_top < ui->form_scroll_total )
{
ui->form_scroll_top++;
return 1;
}
else
{
ui->form_scroll_top = 0;
}
}
break;
case MUIF_MSG_EVENT_PREV:
if ( arg == 0 )
{
if ( ui->form_scroll_top > 0 )
{
ui->form_scroll_top--;
return 1;
}
else
{
if ( ui->form_scroll_total > ui->form_scroll_visible )
{
ui->form_scroll_top = ui->form_scroll_total - ui->form_scroll_visible;
}
else
{
ui->form_scroll_top = 0;
}
}
}
break;
}
return 0;
}
/*=========================================================================*/
/* field functions */
@ -1082,9 +1130,12 @@ uint8_t mui_u8g2_u8_opt_child_mse_common(mui_t *ui, uint8_t msg)
case MUIF_MSG_FORM_END:
break;
case MUIF_MSG_CURSOR_ENTER:
if ( ui->form_scroll_top + arg >= ui->form_scroll_total )
return mui_u8g2_handle_scroll_next_prev_events(ui, msg);
/*
if ( (arg > 0) && (ui->form_scroll_top + arg >= ui->form_scroll_total) )
return 255;
break;
*/
case MUIF_MSG_CURSOR_SELECT:
if ( value != NULL )
*value = ui->form_scroll_top + arg;
@ -1097,7 +1148,8 @@ uint8_t mui_u8g2_u8_opt_child_mse_common(mui_t *ui, uint8_t msg)
case MUIF_MSG_TOUCH_UP:
break;
case MUIF_MSG_EVENT_NEXT:
//printf("MUIF_MSG_EVENT_NEXT: arg=%d visible=%d top=%d total=%d\n", arg, ui->form_scroll_visible, ui->form_scroll_top, ui->form_scroll_total);
return mui_u8g2_handle_scroll_next_prev_events(ui, msg);
/*
if ( arg+1 == ui->form_scroll_visible )
{
if ( ui->form_scroll_visible + ui->form_scroll_top < ui->form_scroll_total )
@ -1111,7 +1163,10 @@ uint8_t mui_u8g2_u8_opt_child_mse_common(mui_t *ui, uint8_t msg)
}
}
break;
*/
case MUIF_MSG_EVENT_PREV:
return mui_u8g2_handle_scroll_next_prev_events(ui, msg);
/*
if ( arg == 0 )
{
if ( ui->form_scroll_top > 0 )
@ -1121,10 +1176,18 @@ uint8_t mui_u8g2_u8_opt_child_mse_common(mui_t *ui, uint8_t msg)
}
else
{
ui->form_scroll_top = ui->form_scroll_total - ui->form_scroll_visible;
if ( ui->form_scroll_total > ui->form_scroll_visible )
{
ui->form_scroll_top = ui->form_scroll_total - ui->form_scroll_visible;
}
else
{
ui->form_scroll_top = 0;
}
}
}
break;
*/
}
return 0;
}
@ -1470,7 +1533,7 @@ static uint8_t mui_u8g2_u16_list_child_mse_common(mui_t *ui, uint8_t msg)
case MUIF_MSG_FORM_END:
break;
case MUIF_MSG_CURSOR_ENTER:
break;
return mui_u8g2_handle_scroll_next_prev_events(ui, msg);
case MUIF_MSG_CURSOR_SELECT:
if ( selection != NULL )
*selection = ui->form_scroll_top + arg;
@ -1483,6 +1546,8 @@ static uint8_t mui_u8g2_u16_list_child_mse_common(mui_t *ui, uint8_t msg)
case MUIF_MSG_TOUCH_UP:
break;
case MUIF_MSG_EVENT_NEXT:
return mui_u8g2_handle_scroll_next_prev_events(ui, msg);
/*
if ( arg+1 == ui->form_scroll_visible )
{
if ( ui->form_scroll_visible + ui->form_scroll_top < ui->form_scroll_total )
@ -1496,7 +1561,10 @@ static uint8_t mui_u8g2_u16_list_child_mse_common(mui_t *ui, uint8_t msg)
}
}
break;
*/
case MUIF_MSG_EVENT_PREV:
return mui_u8g2_handle_scroll_next_prev_events(ui, msg);
/*
if ( arg == 0 )
{
if ( ui->form_scroll_top > 0 )
@ -1510,6 +1578,7 @@ static uint8_t mui_u8g2_u16_list_child_mse_common(mui_t *ui, uint8_t msg)
}
}
break;
*/
}
return 0;
}

View File

@ -835,6 +835,7 @@ uint8_t u8x8_d_sh1106_64x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
uint8_t u8x8_d_sh1107_64x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_sh1107_seeed_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_sh1107_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_sh1107_128x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_sh1107_pimoroni_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_sh1107_seeed_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_sh1108_160x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);

View File

@ -398,6 +398,88 @@ uint8_t u8x8_d_sh1107_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
return 1;
}
/*==================================================*/
/* 128x80 OLED, copyied from 128x128 oled, this display has a very strange x offset */
/* https://github.com/olikraus/u8g2/issues/1598 */
/* sequence taken over from 64x128 sequence, because it seems to work mostly */
static const uint8_t u8x8_d_sh1107_128x80_init_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0ae), /* display off */
U8X8_CA(0x0dc, 24), /* start line */
U8X8_CA(0x081, 0x02f), /* [2] set contrast control */
U8X8_C(0x020), /* use page addressing mode */
// U8X8_C(0x0a1), /* segment remap a0/a1*/
// U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
// Flipmode
U8X8_C(0x0a0), /* segment remap a0/a1*/
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
U8X8_CA(0x0a8, 0x7f), /* 0x03f multiplex ratio */
//U8X8_CA(0x0d3, 0x060), /* display offset (removed, not in datasheet ) */
U8X8_CA(0x0d5, 0x050), /* clock divide ratio (0x00=1) and oscillator frequency (0x8), changed to 0x051, issue 501 */
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1*/
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
U8X8_C(0x0b0), /* set page address */
U8X8_CA(0x0da, 0x012), /* set com pins */
U8X8_C(0x0a4), /* output ram to display */
U8X8_C(0x0a6), /* none inverted normal display mode */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const u8x8_display_info_t u8x8_sh1107_128x128_display_info =
{
/* chip_enable_level = */ 0,
/* chip_disable_level = */ 1,
/* post_chip_enable_wait_ns = */ 20,
/* pre_chip_disable_wait_ns = */ 10,
/* reset_pulse_width_ms = */ 100, /* */
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 40,
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
/* tile_width = */ 16,
/* tile_hight = */ 10,
/* default_x_offset = */ 96,
/* flipmode_x_offset = */ 96,
/* pixel_width = */ 128,
/* pixel_height = */ 80
};
uint8_t u8x8_d_sh1107_128x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
return 1;
switch(msg)
{
case U8X8_MSG_DISPLAY_INIT:
u8x8_d_helper_display_init(u8x8);
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x80_init_seq);
break;
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_128x80_display_info);
break;
default:
return 0;
}
return 1;
}
/*==================================================*/
/* pimoroni_128x128_display */