Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This is a first attempt on how pins can be assigned to variables, and then the variable appears in the dropdown for digitalRead block.
There are some issues here which are to discuss:
1/ we need to test what typed variables are present for the dropdown in the block, but now statictyping is only instantiated in the generator. I hack this here so as to have it accessible in the io.js dropdown code also. No idea how to do this clean...
2/ Again, for the dropdown, we need to query the blocks to know what variables are present. I don't know how to obtain the workspace, I hack it with a call to Blockly.getMainWorkspace() ...
Also some extra cleanup needed: when deleting a variable, the block must be updated.
Also, to test in ardublockly, you need to expose the block 'io_pin_dig' and assign it to a variable.
The idea however on how to do this is present, so as to decide what is good approach to this. So, ideally you can use this PR as a start to provide a nice patch to allow this. Doing this in other blocks that have pins as input can then be done with future patches (analogread, pulsein, ....)