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

jsiDumpHardwareInitialisation for ESPXX #1930

Closed
MaBecker opened this issue Sep 23, 2020 · 2 comments
Closed

jsiDumpHardwareInitialisation for ESPXX #1930

MaBecker opened this issue Sep 23, 2020 · 2 comments
Labels
ESP32 This is only a problem on ESP32-based devices ESP8266 This is only a problem on ESP8266 devices

Comments

@MaBecker
Copy link
Contributor

conversation http://forum.espruino.com/comments/15534057/

It is amazing, there are still so many things I have not realized how the work.

I would suggest to keep those pin settings for ESPXX boards as they, because changing this could break a lot of user code and pepper jsinteractive.c with ifdef like this

#if defined(ESP32) || defined(ESP8266)
      // don't bother with normal inputs, as they come up in this state (ish) anyway
      if (statem != JSHPINSTATE_GPIO_IN_PULLUP && statem != JSHPINSTATE_ADC_IN) {
        // use getPinMode to get the correct string (remove some duplication)
        JsVar *s = jswrap_io_getPinMode(pin);
        if (s) cbprintf(user_callback, user_data, "pinMode(%p, %q%s);\n",pin,s,jshGetPinStateIsManual(pin)?"":", true");
        jsvUnLock(s);
      }
#else
      // don't bother with normal inputs, as they come up in this state (ish) anyway
      if (statem != JSHPINSTATE_GPIO_IN && statem != JSHPINSTATE_ADC_IN) {
        // use getPinMode to get the correct string (remove some duplication)
        JsVar *s = jswrap_io_getPinMode(pin);
        if (s) cbprintf(user_callback, user_data, "pinMode(%p, %q%s);\n",pin,s,jshGetPinStateIsManual(pin)?"":", true");
        jsvUnLock(s);
      }
#endif

Please let me know if this is ok.

@MaBecker MaBecker added ESP8266 This is only a problem on ESP8266 devices ESP32 This is only a problem on ESP32-based devices labels Sep 23, 2020
@gfwilliams
Copy link
Member

I'm not sure I understand what your suggestion is?

I guess one option might be to add a jshIsPinStateDefault(pin, state) which we could define as __WEAK in jshardware_common.c:

__attribute__((weak)) bool jshIsPinStateDefault(Pin pin, JshPinState state) {
  return state == JSHPINSTATE_GPIO_IN || state == JSHPINSTATE_ADC_IN;
}

Then ESPxx could override this by adding its own function in jshardware.c :

bool jshIsPinStateDefault(Pin pin, JshPinState state) {
  return state == JSHPINSTATE_GPIO_IN_PULLUP || state == JSHPINSTATE_ADC_IN;
}

@MaBecker
Copy link
Contributor Author

Thanks, much better than just removing it from being printed out, will do some tests and send a pr for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ESP32 This is only a problem on ESP32-based devices ESP8266 This is only a problem on ESP8266 devices
Projects
None yet
Development

No branches or pull requests

2 participants