4040import com .pi4j .drivers .sensor .environment .bmx280 .Bmx280Driver ;
4141import com .pi4j .drivers .sensor .environment .bmx280 .Bmx280Driver .Measurement ;
4242import com .pi4j .drivers .sensor .environment .bmx280 .Bmx280Driver .Model ;
43- import com .pi4j .io .gpio .digital .DigitalOutput ;
44- import com .pi4j .io .gpio .digital .DigitalState ;
4543import com .pi4j .io .spi .Spi ;
4644import com .pi4j .io .spi .SpiBus ;
4745import com .pi4j .io .spi .SpiMode ;
@@ -81,7 +79,6 @@ public class BME280DeviceSPI {
8179
8280 private static final int chipSelect = 0 ;
8381 private static final SpiBus spiBus = SpiBus .BUS_0 ;
84- private static DigitalOutput csGpio ;
8582 private static Spi spi ;
8683
8784 public static void main (String [] args ) throws Exception {
@@ -91,31 +88,13 @@ public static void main(String[] args) throws Exception {
9188 // Initialize SPI
9289 console .println ("Initializing the sensor via SPI" );
9390
94- String helpString = " parms: -csp chipSelectGPIO \n " ;
91+ String helpString = " parms: NONE \n " ;
9592 for (int i = 0 ; i < args .length ; i ++) {
9693 String o = args [i ];
97- if (o .contentEquals ("-csp" )) { // device address
98- String a = args [i + 1 ];
99- i ++;
100- csPin = Integer .parseInt (a );
101- } else if (o .contentEquals ("-h" )) {
102- console .println (helpString );
103- System .exit (39 );
104- } else {
105- console .println (" !!! Invalid Parm " + args );
106- console .println (helpString );
107- System .exit (42 );
108- }
94+ console .println (helpString );
95+ System .exit (39 );
10996 }
11097
111- var csGpioConfig = DigitalOutput .newConfigBuilder (pi4j )
112- .id ("CS_pin" )
113- .name ("CS" )
114- .bcm (csPin )
115- .shutdown (DigitalState .HIGH )
116- .initial (DigitalState .HIGH );
117- csGpio = pi4j .create (csGpioConfig );
118-
11998 var spiConfig = Spi .newConfigBuilder (pi4j )
12099 .id (SPI_PROVIDER_ID )
121100 .name (SPI_PROVIDER_NAME )
@@ -126,7 +105,7 @@ public static void main(String[] args) throws Exception {
126105 .build ();
127106 spi = pi4j .create (spiConfig );
128107
129- Bmx280Driver bmx280Driver = new Bmx280Driver (spi , csGpio );
108+ Bmx280Driver bmx280Driver = new Bmx280Driver (spi );
130109
131110 console .println ("Device model detected: " + bmx280Driver .getModel ());
132111
0 commit comments