esp32 support

Issue #82 closed
Jack Jansen created an issue

I'm trying to use the library on an ESP32 (via platformio), but I'm running into a silly issue: the code that optionally uses analogWrite() in setBacklight() disables the calls to analogWrite() with an if(0) instead of with preprocessor #if.

The esp32 does not have analogWrite (and hence digitalPinHasPWM and digitalPinToTimer are not defined), but because if the if(0) construct compilation fails.

Comments (10)

  1. Francisco Malpartida repo owner

    OK, looking into this. The code is solid. The way it works is that the code always evaluates to false. Therefore going directly to the else if part. This shouldn't be a preprocessor flag.

    It looks as if your compiler doesn't like the if (0) construct.

  2. Francisco Malpartida repo owner

    The if (0) statement is valid and should always evaluate to false and never execute the code underneath. The error that the compiler may be reporting is a warning and it may be configured to fail on warning as it is detecting dead code.

  3. Francisco Malpartida repo owner

    Just changed the statement in the integration branch to if(false).

    This may help out on with other compilers to identify that the construct is valid.

  4. Jack Jansen reporter

    Francisco, the issue is that the function analogWrite() does not exist on the ESP32. So the issue isn't that it tries to execute that branch (which it won't, because the if(0) is enough guard for that) but the whole module doesn't compile, because there's an undefined reference to analogWrite().

    (the reason that the ESP32 doesn't have analogWrite() is that it has two distinct and completely different ways to get similar effect, but there's no 1-to-1 mapping so the esp32-arduino maintainers decided not to include analogWrite. Their choice...)

  5. Francisco Malpartida repo owner

    Thanks for the update. Your pull request addresses nicely this item. I will close issue.

  6. Francisco Malpartida repo owner

    Closed as per pulll request #10.

    Available on release branch (rel 1.4.0) and integration branches.

  7. Francisco Malpartida repo owner

    In platformIO it shows as eel 1.5.0 as it is coming from the integration branch.

  8. Log in to comment