Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty with ezLabel #10

Open
vkichline opened this issue Nov 10, 2020 · 0 comments
Open

Difficulty with ezLabel #10

vkichline opened this issue Nov 10, 2020 · 0 comments

Comments

@vkichline
Copy link

I am trying to set up a form with some different attributes. Nothing's working:

#include <M5Core2.h>
#include <Core2ez.h>

ezLabel   label(20, 60, 280, 50, "10000");
int32_t   count = 0;

void setup() {
  ez.begin();
  label.ezFont(FSBI24);
  ez.Screen.add(label);
  ez.Screen.focus();

  ez.Screen.fillScreen(BLACK);
  ez.Screen.setTextColor(WHITE, BLACK);
  ez.Screen.setTextSize(1);
  ez.Screen.drawCentreString("Counter", 160, 4, 4);
  label.colors = { BLACK, WHITE, NODRAW };
  label.setTextDatum(TL_DATUM);
}

void loop() {
  label.text = String(count++, BIN);
  label.draw();
  delay(100);
}

I expect this to show a window with "Counter" centered at the top, and a left-aligned ezLabel below it in a different font.
No matter what font I set, the display does not change.
label.setTextDatum seems to have no effect.
This source code confuses me:

void ezDisplayZone::setFreeFont(const GFXfont *f /* = NULL */) {
  if      (sprite ) sprite ->setFreeFont(f);
  else if (_parent) _parent ->setFreeFont(f);
  else              DISPLAY .setFreeFont(f);
}

...it looks like once I have a parent, all controls MUST be the same font, alignment, etc.
Looks like DrawString, etc., do the same, so the attributes of widgets aren't utilized.
I would really prefer to have a title a different font that the content. I may need different fonts for, example, a clock or meter with numeric-only fonts.
Is there some way for Widgets to use their own properties that I've overlooked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant