issue #2200 added NO_WRAP option

This commit is contained in:
kraus 2023-06-11 12:15:54 +02:00
parent a143183f0d
commit 9e39e9c9ab
3 changed files with 124 additions and 8 deletions

View File

@ -316,3 +316,4 @@ https://github.com/olikraus/u8g2 ChangeLog
* Bugfix for ESP32 HW SPI Pin Remapping (issue 377, PR 2123)
* Bugfix for LoadFromSD examle (issue 2179)
* Changed MUI_LABEL to support UTF8 (issue 2196)
* Compiler Warning Cleanup for polygon draw (issue 1999, PR 2101)

View File

@ -1000,6 +1000,8 @@ uint8_t mui_u8g2_u8_bar_wm_mse_pi(mui_t *ui, uint8_t msg)
uint8_t min = mui_u8g2_u8mms_get_min(vmms);
uint8_t max = mui_u8g2_u8mms_get_max(vmms);
uint8_t step = mui_u8g2_u8mms_get_step(vmms);
uint8_t flags = mui_u8g2_u8mms_get_flags(vmms);
switch(msg)
{
case MUIF_MSG_DRAW:
@ -1014,10 +1016,24 @@ uint8_t mui_u8g2_u8_bar_wm_mse_pi(mui_t *ui, uint8_t msg)
case MUIF_MSG_CURSOR_SELECT:
case MUIF_MSG_VALUE_INCREMENT:
(*value)+=step;
if ( *value > max ) *value = min;
if ( *value > max )
{
if ( flags & MUI_MMS_NO_WRAP )
*value = max;
else
*value = min;
}
break;
case MUIF_MSG_VALUE_DECREMENT:
if ( *value >= min+step ) (*value)-=step; else *value = max;
if ( *value >= min+step )
(*value)-=step;
else
{
if ( flags & MUI_MMS_NO_WRAP )
*value = min;
else
*value = max;
}
break;
case MUIF_MSG_CURSOR_LEAVE:
break;
@ -1037,6 +1053,7 @@ uint8_t mui_u8g2_u8_bar_wm_mud_pi(mui_t *ui, uint8_t msg)
uint8_t min = mui_u8g2_u8mms_get_min(vmms);
uint8_t max = mui_u8g2_u8mms_get_max(vmms);
uint8_t step = mui_u8g2_u8mms_get_step(vmms);
uint8_t flags = mui_u8g2_u8mms_get_flags(vmms);
switch(msg)
{
case MUIF_MSG_DRAW:
@ -1065,7 +1082,12 @@ uint8_t mui_u8g2_u8_bar_wm_mud_pi(mui_t *ui, uint8_t msg)
{
(*value)+=step;
if ( *value > max )
*value = min;
{
if ( flags & MUI_MMS_NO_WRAP )
*value = max;
else
*value = min;
}
return 1;
}
break;
@ -1073,7 +1095,12 @@ uint8_t mui_u8g2_u8_bar_wm_mud_pi(mui_t *ui, uint8_t msg)
if ( ui->is_mud )
{
if ( *value <= min || *value > max)
*value = max;
{
if ( flags & MUI_MMS_NO_WRAP )
*value = min;
else
*value = max;
}
else
(*value)-=step;
return 1;
@ -1090,6 +1117,7 @@ uint8_t mui_u8g2_u8_bar_wm_mse_pf(mui_t *ui, uint8_t msg)
uint8_t min = mui_u8g2_u8mms_get_min(vmms);
uint8_t max = mui_u8g2_u8mms_get_max(vmms);
uint8_t step = mui_u8g2_u8mms_get_step(vmms);
uint8_t flags = mui_u8g2_u8mms_get_flags(vmms);
switch(msg)
{
case MUIF_MSG_DRAW:
@ -1104,10 +1132,24 @@ uint8_t mui_u8g2_u8_bar_wm_mse_pf(mui_t *ui, uint8_t msg)
case MUIF_MSG_CURSOR_SELECT:
case MUIF_MSG_VALUE_INCREMENT:
(*value)+=step;
if ( *value > max ) *value = min;
if ( *value > max )
{
if ( flags & MUI_MMS_NO_WRAP )
*value = max;
else
*value = min;
}
break;
case MUIF_MSG_VALUE_DECREMENT:
if ( *value >= min+step ) (*value)-=step; else *value = max;
if ( *value >= min+step )
(*value)-=step;
else
{
if ( flags & MUI_MMS_NO_WRAP )
*value = min;
else
*value = max;
}
break;
case MUIF_MSG_CURSOR_LEAVE:
break;
@ -1126,6 +1168,7 @@ uint8_t mui_u8g2_u8_bar_wm_mud_pf(mui_t *ui, uint8_t msg)
uint8_t min = mui_u8g2_u8mms_get_min(vmms);
uint8_t max = mui_u8g2_u8mms_get_max(vmms);
uint8_t step = mui_u8g2_u8mms_get_step(vmms);
uint8_t flags = mui_u8g2_u8mms_get_flags(vmms);
switch(msg)
{
case MUIF_MSG_DRAW:
@ -1154,7 +1197,12 @@ uint8_t mui_u8g2_u8_bar_wm_mud_pf(mui_t *ui, uint8_t msg)
{
(*value)+=step;
if ( *value > max )
*value = min;
{
if ( flags & MUI_MMS_NO_WRAP )
*value = max;
else
*value = min;
}
return 1;
}
break;
@ -1162,7 +1210,12 @@ uint8_t mui_u8g2_u8_bar_wm_mud_pf(mui_t *ui, uint8_t msg)
if ( ui->is_mud )
{
if ( *value <= min || *value > max)
*value = max;
{
if ( flags & MUI_MMS_NO_WRAP )
*value = min;
else
*value = max;
}
else
(*value)-=step;
return 1;

View File

@ -33,6 +33,33 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Reference Manual:
https://github.com/olikraus/u8g2/wiki/muiref
MUIF_U8G2_LABEL()
replacement for MUIF_LABEL(mui_u8g2_draw_text),
used by MUI_LABEL(x,y,"text")
Supports UTF8
MUIF_U8G2_FONT_STYLE(n, font)
A special u8g2 style function, which replaces MUIF_STYLE, but restricts the style change to the
specific font argument (however, this should be good enough in most cases).
As usual, the style "n" can be activated with MUI_STYLE(n) in FDS.
Example:
muif_t muif_list[] MUI_PROGMEM = {
MUIF_U8G2_LABEL(),
MUIF_U8G2_FONT_STYLE(0, u8g2_font_5x8_tr)
};
fds_t fds[] MUI_PROGMEM =
MUI_FORM(1)
MUI_STYLE(0)
MUI_LABEL(5,12, "5x8 Font")
;
*/
#ifndef MUI_U8G2_H
@ -122,6 +149,35 @@ typedef const struct mui_u8g2_u8_min_max_step_struct mui_u8g2_u8_min_max_step_t;
#endif
struct mui_u8g2_u8_min_max_width_step_struct
{
uint8_t *value;
uint8_t min;
uint8_t max;
uint8_t width;
uint8_t step;
uint8_t flags;
} MUI_PROGMEM;
typedef const struct mui_u8g2_u8_min_max_width_step_struct mui_u8g2_u8_min_max_width_step_t;
#if defined(__GNUC__) && defined(__AVR__)
# define mui_u8g2_u8mmws_get_step(u8mm) mui_pgm_read(&((u8mm)->step))
# define mui_u8g2_u8mmws_get_width(u8mm) mui_pgm_read(&((u8mm)->width))
# define mui_u8g2_u8mmws_get_flags(u8mm) mui_pgm_read(&((u8mm)->flags))
# define mui_u8g2_u8mmws_get_min(u8mm) mui_pgm_read(&((u8mm)->min))
# define mui_u8g2_u8mmws_get_max(u8mm) mui_pgm_read(&((u8mm)->max))
# define mui_u8g2_u8mmws_get_valptr(u8mm) ((uint8_t *)mui_pgm_wread(&((u8mm)->value)))
#else
# define mui_u8g2_u8mmws_get_step(u8mm) ((u8mm)->step)
# define mui_u8g2_u8mmws_get_width(u8mm) ((u8mm)->width)
# define mui_u8g2_u8mmws_get_flags(u8mm) ((u8mm)->flags)
# define mui_u8g2_u8mmws_get_min(u8mm) ((u8mm)->min)
# define mui_u8g2_u8mmws_get_max(u8mm) ((u8mm)->max)
# define mui_u8g2_u8mmws_get_valptr(u8mm) ((u8mm)->value)
#endif
/* helper functions */
u8g2_uint_t mui_get_x(mui_t *ui);
@ -224,12 +280,18 @@ uint8_t mui_u8g2_u8_min_max_wm_mud_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G
#define MUI_MMS_2X_BAR 0x01
#define MUI_MMS_4X_BAR 0x02
#define MUI_MMS_SHOW_VALUE 0x04
#define MUI_MMS_NO_WRAP 0x08
uint8_t mui_u8g2_u8_bar_wm_mse_pi(mui_t *ui, uint8_t msg);
uint8_t mui_u8g2_u8_bar_wm_mud_pi(mui_t *ui, uint8_t msg);
uint8_t mui_u8g2_u8_bar_wm_mse_pf(mui_t *ui, uint8_t msg);
uint8_t mui_u8g2_u8_bar_wm_mud_pf(mui_t *ui, uint8_t msg);
/*===== data = mui_u8g2_u8_min_max_width_step_t* =====*/
/*===== data = mui_u8g2_list_t* =====*/
/* similar to mui_u8g2_u8_opt_line, but u16 and dynamic list */