Esempio n. 1
0
/* returns the number of requested digits */
static uint8_t m2_el_u32_get_digits(m2_rom_void_p element)
{
  uint8_t c = m2_opt_get_val_any_default(m2_el_fnfmt_get_fmt_by_element(element), 'c', 9);
  if ( c == 0 )
    c = 1;
  if ( c > 9 )
    c = 9;
  return c;
}
Esempio n. 2
0
static M2_EL_FN_DEF(m2_el_s8num_sub_fn)
{
  uint8_t digits;
  uint8_t width;
  uint8_t font;

  font = m2_el_fmfmt_get_font(fn_arg);

  /* maybe the width is needed, precalculate the pixel width */
  
  /* get number of digits to show */
  digits = m2_opt_get_val_any_default(m2_el_fnfmt_get_fmt(fn_arg), 'c', 3);

  /* calculate pixel width */
  width = digits;
  width++;	/* add one char for the sign */
  width *= m2_gfx_get_num_char_width(font);

  switch(fn_arg->msg)
  {
    case M2_EL_MSG_GET_HEIGHT:
      return m2_gfx_add_normal_border_height(font, m2_gfx_get_char_height(font));
    case M2_EL_MSG_GET_WIDTH:
      return m2_gfx_add_normal_border_width(font, width);
#ifdef M2_EL_MSG_DBG_SHOW
    case M2_EL_MSG_DBG_SHOW:
      {
	m2_pos_p b = (m2_pos_p)(fn_arg->data);
	printf("u8  w:%d arg:%d x:%d y:%d %u\n", 
	  width, 
	  (fn_arg->arg), b->x, b->y, (unsigned)m2_el_s8_get_val(fn_arg));
      }
      return 0;
#endif
    case M2_EL_MSG_SHOW:
    {
	m2_pos_p b = (m2_pos_p)(fn_arg->data);
	if ( m2_is_frame_draw_at_end == 0 )
	  m2_el_s8base_fn(fn_arg);
	
	m2_gfx_draw_text_add_normal_border_offset(b->x, b->y, 0, 0, font, m2_utl_s8d(m2_el_s8_get_val(fn_arg), digits, m2_el_fmfmt_opt_get_val_zero_default(fn_arg, '+')));
	
	if ( m2_is_frame_draw_at_end != 0 )
	  m2_el_s8base_fn(fn_arg);
      }
      return 1;
  }
  return m2_el_s8base_fn(fn_arg);
}
Esempio n. 3
0
uint8_t m2_opt_get_val_zero_default(m2_rom_char_p str, char cmd)
{
  return m2_opt_get_val_any_default(str, cmd, 0);
}
Esempio n. 4
0
uint8_t m2_opt_get_val(m2_rom_char_p str, char cmd)
{
  return m2_opt_get_val_any_default(str, cmd, M2_OPT_NOT_FOUND);
}