Add new functions to the js interpreter: random, analogWrite, digitalRead, analogRead #677
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.
Proposed Changes
gpio mode
serial command to accept values between 0 and 9.In the documentation there is an error in this fragment:
https://github.com/pr3y/Bruce/wiki/Serial
gpio mode <pin number> <0/1> - set GPIO pins mode (0=input, 1=output).
While this is true for Arduino boards, it is not accurate for ESP32:
https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-gpio.h#L46
Here, 1 is for input, while 2 and 3 is for output.
I've updated documentation according to this, and also added new functions:
https://github.com/Tawank/Bruce-wiki/pull/1/files
I've also added the gobal variables INPUT, OUTPUT, HIGH, LOW, so you can initialize pin like this in the js script:
pinMode(25, OUTPUT);
Types of Changes
Bugfix, New Feature
Verification
I wired up potentiometer and tested the analogRead command on pins 25 and 26.
And tested analogWrite, digitalRead and random commands.
User-Facing Change