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

M5Core2 Power LED #102

Open
forstner-m opened this issue Mar 6, 2024 · 8 comments
Open

M5Core2 Power LED #102

forstner-m opened this issue Mar 6, 2024 · 8 comments

Comments

@forstner-m
Copy link

Hello,

I have tried this function on the M5Core2:
M5.Power.setLed(0);
M5.Power.setLed(1);
M5.Power.setLed(255);

I tried that too:
auto cfg = M5.config();
cfg.led_brightness = 1;
M5.begin(cfg);

Unfortunately, nothing happens with it. There is no problem with the normal M5Core2 library. Therefore, the LED is not broken.

Am I doing something wrong or is the LED not implented?

Thank you very much!

Best regards,
Michael

@lovyan03
Copy link
Collaborator

lovyan03 commented Mar 8, 2024

Hello, @forstner-m
If the main unit type is Core2 v1.0, you can control the LED, but if it is v1.1, you cannot make detailed adjustments.
This is due to the difference in specifications between AXP192 and AXP2101.

As far as I have checked, it is working in v1.0. What model are you using?

IMG_0435.MOV

@forstner-m
Copy link
Author

I have a Core2 v1.0 and the led is not switchable. Do you have a code for this function?

@lovyan03
Copy link
Collaborator

lovyan03 commented Mar 9, 2024

As a precaution, please update M5Unified & M5GFX library version to the latest released 0.1.13.

#include <M5Unified.h>

void setup(void)
{
  auto cfg = M5.config();
  cfg.led_brightness = 255;
  M5.begin(cfg);
}

void loop(void)
{
  M5.delay(1000);
  M5.Power.setLed(0);
  M5.delay(1000);
  M5.Power.setLed(255);
}

If this doesn't work, please show me the program you tried that works with M5Core2.h

@forstner-m
Copy link
Author

Your code works, but this do not work:

#include <Arduino.h>
#include <M5GFX.h>
#include <M5Unified.h>

M5GFX display;

void setup(void)
{
auto cfg = M5.config();
cfg.led_brightness = 255;
M5.begin(cfg);
display.begin();
}

void loop(void)
{
while(1)
{
M5.delay(1000);
M5.Power.setLed(0);
M5.delay(1000);
M5.Power.setLed(255);
}
}

If the line "display.begin();" is active the LED is off.

@lovyan03
Copy link
Collaborator

lovyan03 commented Mar 9, 2024

M5Unified includes M5GFX.
M5.Display is an instance of M5GFX.
You must not create your own instances of M5GFX.
Examples of such code are sometimes introduced, but they should be avoided as they can cause problems.

@forstner-m
Copy link
Author

Now it works! Is the line M5.Display.begin(); necessary?
It would still be good if an example were created with canvas. But with this line it works: M5Canvas canvas(&M5.Display);

@lovyan03
Copy link
Collaborator

lovyan03 commented Mar 9, 2024

M5.Display.begin() is not required.
This is included in M5.begin().

@mdxs
Copy link

mdxs commented Apr 17, 2024

This ticket can be closed as resolved.

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

3 participants