Skip to content

Provide a way to automatically fall back to mocks if a real device is not detected #619

Description

@FDelporte

As reported by @DieterHolz

Lots of our student teams combine the RPi with a GUI, for example, using JavaFX. For them, it is very convenient to start the app on the laptop without any Pi4J exceptions, to implement and test the GUI and application logic, without connections to sensors, etc.

Current solution:

pi4J = (BoardInfoHelper.runningOnRaspberryPi()) ?
        Pi4J.newAutoContext() :
        Pi4J.newContextBuilder()
                .add(new MockDigitalInputProviderImpl())
                .add(new MockDigitalOutputProviderImpl())
                .add(new MockPwmProviderImpl())
                .add(new MockSpiProviderImpl())
                .add(new MockI2CProviderImpl())
                .build();

It would be great if something like this is incorporated in newAutoContext or some similar method.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions