GithubHelp home page GithubHelp logo

Comments (12)

bxparks avatar bxparks commented on June 18, 2024

Hi,
My guess is that HIGH is not defined by hardware/arduino/avr/cores/arduino/Arduino.h, because it's defined to be 0x1 on my Arduino Nano (non-Every), and it works fine.

I don't have a Nano Every board. Can you create a short program to just print out your HIGH value? Basically, something like:

void setup() {
  Serial.begin(115200);
  while (!Serial);
  Serial.print("HIGH: ");
  Serial.println(HIGH);
}

from acebutton.

seisfeld avatar seisfeld commented on June 18, 2024

Sure, I tried that already. It prints

HIGH: 1

and

LOW: 0

respectively. Which made me google this and I found that location on stack overflow.

from acebutton.

bxparks avatar bxparks commented on June 18, 2024

I just realized that I can compile without actually owning one of these boards, so I installed the "Arduino megaAVR Boards 1.8.1" core, and discovered it in hardware/megaavr/1.8.1/cores/arduino/api/Common.h:

typedef enum {
  LOW     = 0,
  HIGH    = 1,
  CHANGE  = 2,
  FALLING = 3,
  RISING  = 4,
} PinStatus;

This is unfortunate, because that means that HIGH is not a C prepropcessor macro but is an enum value. This also explains the compiler warnings that you should be seeing:

/home/brian/dev/arduino-1.8.9/portable/packages/arduino/hardware/megaavr/1.8.1/cores/arduino/api/Common.h:104:6: note:   initializing argument 2 of 'void digitalWrite(pin_size_t, PinStatus)'
 void digitalWrite(pin_size_t pinNumber, PinStatus status);
      ^~~~~~~~~~~~
/home/brian/dev/AceButton/examples/HelloButton/HelloButton.ino:51:36: warning: invalid conversion from 'int' to 'PinStatus' [-fpermissive]
       digitalWrite(LED_PIN, LED_OFF);

I'm not sure what the solution is. Let me think about this...

from acebutton.

bxparks avatar bxparks commented on June 18, 2024

Related info at arduino/ArduinoCore-API#25

from acebutton.

seisfeld avatar seisfeld commented on June 18, 2024

Allright thank you. For the time being I'll swap my regular Nano back in my circuit. 😉 I have a couple more libraries not working in my project, so I guess this board is just too new. I mean it was literally shipped by Arduino this week...

If you need me to test anything or need more sample code actually run etc., please let me know. I am happy to help.

from acebutton.

bxparks avatar bxparks commented on June 18, 2024

Changing the signature of digitalWrite() to use a PinStatus enum seems like a really bad idea. But AceButton should be able to support this, since the semantics of HIGH did not change. I'll look into it.

from acebutton.

bxparks avatar bxparks commented on June 18, 2024

Hi,

I'm driving blind here, since I don't have this board to test on. Can you try changing in AceButton.h, line 80:

static const uint8_t kButtonStateUnknown = 2;

to

static const uint8_t kButtonStateUnknown = 5

and see if that works? You'll have to comment out the #error of course. (And when you wrote "does not work" above, what did you mean more precisely?)

from acebutton.

seisfeld avatar seisfeld commented on June 18, 2024

Hi Brian,

there was some evidence discovered in the the last hours that there - in addition to the PinStatus change - is actually a bug in the Arduino megaAVR Boards 1.8.1. I opened an issue [1] there because the simplest things (like digitalRead and digitalWrite) did not work at all on the analog pins (my current project uses A0-A2 for button inputs). On the digital pins both worked fine. I have been told that this is known and will be fixed sometime next week. They gave me a beta of 1.8.2 and I went ahead and tested AceButton with that one.

Good news: It appears everything works as expected in AceButton - when i comment out the #error of course. I built a small setup on a breadboard, just one button and the SingleButton example works fine.

So in summary, the only thing you need to check is how to deal with the changes you mentioned here. The reason why it still did not work after commenting out the #error was the bug mentioned in [1] and will be fixed soon. A change of kButtonStateUnknown was not required.

[1] arduino/Arduino#9024

from acebutton.

seisfeld avatar seisfeld commented on June 18, 2024

megaAVR-1.8.2 has been released today.

from acebutton.

bxparks avatar bxparks commented on June 18, 2024

Hi Stephan,
Can you test the latest on the develop branch?
I believe I made this fully compatible with the Nano Every and other megaAVR boards.

from acebutton.

seisfeld avatar seisfeld commented on June 18, 2024

Hi Brian,

I did run a few quick tests (just the Every and one button) on my breadboard - works like charm. Awesome! I did test the SingleButton, HelloButtom and AutoBenchmark examples with no change (except the button pin, I changed that to A0). I will swap the Every into my project this weekend again and see if it works there as well (which I do expect).

If you want me to run specific tests for you, please let me know. Thanks for the quick turnaround!

cheers
Stephan

from acebutton.

bxparks avatar bxparks commented on June 18, 2024

Thanks for testing. I just released version 1.3.4 with this fix. Closing. Let me know if you run into any problems.

from acebutton.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.