DanielMartensson / OpenSourceLogger-Web

Use and STM32 to store measurements into a MySQL server over the web
MIT License
4 stars 0 forks source link

remove explicit provider reference #1

Closed savageautomate closed 4 years ago

savageautomate commented 4 years ago

I realize the Pi4J examples in some cases reference an explicit provider, but we probably should not (except for in test cases) to allow for any IO provider to be provided at runtime.

So, in this project, I would change:

https://github.com/DanielMartensson/OpenSourceLogger/blob/f6ee79838ea634a46ada029cf4acd7091c7730ea/src/main/java/se/danielmartensson/pi4j/ADS1115_ADS1015.java#L136

To:

I2CProvider i2CProvider = pi4j.i2c();

This should use the default I2C provided as detected by the Pi4J framework.

DanielMartensson commented 4 years ago

I realize the Pi4J examples in some cases reference an explicit provider, but we probably should not (except for in test cases) to allow for any IO provider to be provided at runtime.

So, in this project, I would change:

https://github.com/DanielMartensson/OpenSourceLogger/blob/f6ee79838ea634a46ada029cf4acd7091c7730ea/src/main/java/se/danielmartensson/pi4j/ADS1115_ADS1015.java#L136

To:

I2CProvider i2CProvider = pi4j.i2c();

This should use the default I2C provided as detected by the Pi4J framework.

Thanks! How about this one?

Pwm pwm = pi4j.providers().get(PiGpioPwmProvider.class).create(config);

I got this examples from Deporte.

DanielMartensson commented 4 years ago

@savageautomate

DanielMartensson commented 4 years ago

I realize the Pi4J examples in some cases reference an explicit provider, but we probably should not (except for in test cases) to allow for any IO provider to be provided at runtime.

So, in this project, I would change:

https://github.com/DanielMartensson/OpenSourceLogger/blob/f6ee79838ea634a46ada029cf4acd7091c7730ea/src/main/java/se/danielmartensson/pi4j/ADS1115_ADS1015.java#L136

To:

I2CProvider i2CProvider = pi4j.i2c();

This should use the default I2C provided as detected by the Pi4J framework.

@savageautomate

I think this is a bug, because now the digital input does not work at all. Have a look:

https://github.com/DanielMartensson/OpenSourceLogger/blob/master/src/main/java/se/danielmartensson/pi4j/IO.java

DanielMartensson commented 4 years ago

I realize the Pi4J examples in some cases reference an explicit provider, but we probably should not (except for in test cases) to allow for any IO provider to be provided at runtime.

So, in this project, I would change:

https://github.com/DanielMartensson/OpenSourceLogger/blob/f6ee79838ea634a46ada029cf4acd7091c7730ea/src/main/java/se/danielmartensson/pi4j/ADS1115_ADS1015.java#L136

To:

I2CProvider i2CProvider = pi4j.i2c();

This should use the default I2C provided as detected by the Pi4J framework.

@savageautomate

Sorry. Your advise did not work. I need to use the string provider.

savageautomate commented 4 years ago

It must be a bug then, it's supposed to work. The Pi4J framework should auto-assign a default provider, in this case an I2CProvider in runtime at startup.

DanielMartensson commented 4 years ago

It must be a bug then, it's supposed to work. The Pi4J framework should auto-assign a default provider, in this case an I2CProvider in runtime at startup.

@savageautomate

Yes. Also you should check out the PWM class as well. I can't measure 3.3 volt as output when I have 100% duty call. Check out my IO.java class in this project.

Input and I2C works if I have the string provider argument.