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

M5 Tough #1

Closed
GrandeRipper opened this issue Apr 4, 2024 · 10 comments
Closed

M5 Tough #1

GrandeRipper opened this issue Apr 4, 2024 · 10 comments

Comments

@GrandeRipper
Copy link

GrandeRipper commented Apr 4, 2024

Hello,
I would like to use the lib with an M5Tough. For this I had to change line 27 in UnifiedButton::begin(LovyanGFX* gfx, const appearance_t app) function as follows:

 _enable = /*M5.getBoard() == m5::board_t::board_M5StackCoreS3 &&*/ M5.Touch.isEnabled();

This displayed the buttons and they changed colour when I clicked on them. However, conditions such as "M5.BtnA.wasHold()" were never true. I found out that this is probably due to line 1207 - 1209 in M5Unified.cpp (version 0.1.14) => M5.update()

    BtnA.setRawState(ms, btn_bits & 1);
    BtnB.setRawState(ms, btn_bits & 2);
    BtnC.setRawState(ms, btn_bits & 4);

The lib works at least if I comment out these lines. An alternative solution seems to be the execution of unifiedButton.update() BEFORE M5.update()

Is there a better way to solve the problem? I am also not clear why running unifiedButton.update() BEFORE M5.update() seems to be a solution.

@GrandeRipper
Copy link
Author

GrandeRipper commented Apr 4, 2024

OK with unifiedButton.update() BEFORE M5.update() it doesn't really work either. Only isPressed() and pressedFor() are working wasClicked() doesn't work. probably because the corresponding variables are reset in M5.update().
I am a little confused how it can work with the CoreS3 at all... because the line 1207 - 1209 in M5Unified.cpp should also influence the behaviour.

@GOB52
Copy link
Owner

GOB52 commented Apr 4, 2024

Hi @GrandeRipper , Thanks for using my library.

As you guessed, it seems to be caused by overwriting values on the M5Unified side.
I have already discussed this issue with the M5Unified maintainer.

When the M5Unified side is updated, I would like to include M5Tough support in this library as well.

@GOB52
Copy link
Owner

GOB52 commented Apr 5, 2024

@GrandeRipper

M5Unified develop branch has been updated.

Could you try the following configuration?

lib_deps=https://github.com/m5stack/M5Unified.git#develop

@GrandeRipper
Copy link
Author

Hi @GOB52 , i forgot to thank you for your work and your library. Sorry about that. With the develop version of M5Unified everything works as it should! (with customised UnifiedButton::begin)
Thank you very much

@GOB52
Copy link
Owner

GOB52 commented Apr 5, 2024

Hi @GrandeRipper .

Thanks for trying.
Are the following the only areas you have customized?

 _enable = /*M5.getBoard() == m5::board_t::board_M5StackCoreS3 &&*/ M5.Touch.isEnabled();

@GrandeRipper
Copy link
Author

GrandeRipper commented Apr 11, 2024

Hi @GOB52
i only customized that line:

_enable = /*M5.getBoard() == m5::board_t::board_M5StackCoreS3 &&*/ M5.Touch.isEnabled();

@GOB52
Copy link
Owner

GOB52 commented Apr 11, 2024

Thanks for the reply.

The next update would be the following code.

auto bd = M5.getBoard();
_enable = (bd ==  m5::board_t::board_M5StackCoreS3 || bd == m5::board_t::board_M5Tough)
               && M5.Touch.isEnabled();

The reason why "M5.Touch.isEnabled()" alone is not enough is that there are devices like Core2 that are touch capable and have touch buttons outside the screen..

I will start after the official update of M5Unified.

@GrandeRipper
Copy link
Author

On a side note, it would be great if the buttons could be labelled differently during the execution of the programme.

@GOB52
Copy link
Owner

GOB52 commented Apr 12, 2024

@GOB52
Copy link
Owner

GOB52 commented Jun 3, 2024

Hi @GrandeRipper

As M5Unified has been updated, gob_unifiedButton has also been updated and published 0.1.5.

If you have tried it and there are no problems, would you please close the issue?

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

2 participants