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

Add new functions to the js interpreter: random, analogWrite, digitalRead, analogRead #677

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

Tawank
Copy link
Contributor

@Tawank Tawank commented Jan 12, 2025

Proposed Changes

  • Added new functions to the JavaScript interpreter: random, analogWrite, digitalRead, analogRead.
  • Added new global variables to the JavaScript interpreter: HIGH, LOW, INPUT, OUTPUT, PULLUP, etc.
  • Modified the 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

- Added new functions to the JavaScript interpreter: random, analogWrite, digitalRead, analogRead.
- Added new global variables to the JavaScript interpreter: HIGH, LOW, INPUT, OUTPUT, PULLUP, etc.

@pr3y pr3y merged commit b427deb into pr3y:main Jan 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants