-
• #2
It's a bit of a hack at the moment - LEDs and Buttons are treated differently.
The best method is to make your own
jswrap_xx.c
file, and to put something like this in it:/*JSON{ "type" : "variable", "name" : "ADC", "generate_full" : "JSH_PORTD_OFFSET+1", "return" : ["pin","My ADC"] }*/
-
• #3
Right! I had not thought of that... :)
I have 2 goals (not mutually exclusive):
- avoid repeating
ADC=D1
in every program (convenience) - avoid "burning" JS variables on simple aliases (resource optimisation)
I guess this solution addresses 1. but would there be a way to address 2. as well ?
- avoid repeating
-
• #4
It doesn't burn JS variables either - it's one of the big things about Espruino - that all built-in variables/functions exist without taking up any RAM :)
Assuming that the MCU is already supported by Espruino (STM32, ESP8266, nRF5x etc.), how would one define pin aliases (e.g. ADC=D1) without sacrificing a JS variable (e.g. RAM-constrained board) ?
It does not seem to be sufficient to add
to MYBOARD.py to have
ADC
automatically available as a global variable in JS as an alias to D1