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

Pass board option to five.Pin() #155

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mphasize
Copy link

@mphasize mphasize commented Dec 29, 2022

When working with multiple boards in Johnny Five it's necessary to specify the board as an option. (http://johnny-five.io/api/pin/)

By changing this.rstPin = new this.five.Pin(this.RESETPIN) to this.rstPin = new this.five.Pin({pin: this.RESETPIN, board: this.board}) we can successfully work in environments where the board definition would otherwise be ambiguous.

After this relatively simple change, I encountered a number of (unrelated) problems with building the Typescript.
On the first try I got the error:

node_modules/@types/johnny-five/index.d.ts:663:21 - error TS1005: ',' expected.
663     song: [frequency: string | null, duration: number][];

Upgrading to Typescript 4.x solves this issue.

On the second try I got:

oled.ts - error TS4094: Property '...(many different properties and functions)...' of exported class expression may not be private or protected.

If I read this issue microsoft/TypeScript#17293 correctly, the private definition is not really supported, so I'm commenting it out for now.

…ith multiple boards.

When working with multiple boards, Johnny Five can get confused which board to use. By using the optional `board` parameter and passing the board variable used to initialize Oled, we can fix that.
When building the Johnny Fives types, we get the error:

```
node_modules/@types/johnny-five/index.d.ts:663:21 - error TS1005: ',' expected.
663     song: [frequency: string | null, duration: number][];
```

Upgrading to Typescript 4.x solves this issue.
When building with Typescript 4 we get the following build error for all private properties and functions:

```
oled.ts - error TS4094: Property '[all private variables and functions]' of exported class expression may not be private or protected.
```

If I read this issue correctly, the `private` definition is not really supported, so I'm commenting it out for now.
We need the build output in order to reference this branch directly in a package.json file. If the PR is merged and released, these files can be removed again.
Since the most current version of serialport is >10 and the serialport dependency seems to be unused in this repo, let's remove it.
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.

1 participant