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

Comments

@MaBecker
Copy link
Contributor

@MaBecker MaBecker commented Sep 23, 2020

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.

@gfwilliams
Copy link
Member

@gfwilliams gfwilliams commented Sep 24, 2020

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

@MaBecker MaBecker commented Sep 24, 2020

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

gfwilliams added a commit that referenced this issue Sep 24, 2020
fix #1930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants