|
39 | 39 |
|
40 | 40 | import com.pi4j.context.Context; |
41 | 41 | import com.pi4j.io.spi.Spi; |
| 42 | +import com.pi4j.io.spi.SpiBus; |
42 | 43 | import com.pi4j.io.spi.SpiConfig; |
43 | 44 | import com.pi4j.io.spi.SpiMode; |
44 | 45 | import com.pi4j.util.Console; |
@@ -89,6 +90,12 @@ public class NeoPixel94V extends Component { |
89 | 90 | * Default frequency of a WS2812 Neopixel Strip |
90 | 91 | */ |
91 | 92 | private final int frequency = 6400000; |
| 93 | + /** |
| 94 | + * Default frequency of a WS2812 Neopixel Strip |
| 95 | + */ |
| 96 | + private static final int DEFAULT_FREQUENCY_PI3 = 800_000; //use this for a Pi4 |
| 97 | + private static final int DEFAULT_FREQUENCY_PI4 = 500_000; //use this for a Pi4 |
| 98 | + |
92 | 99 | /** |
93 | 100 | * between each rendering of the strip, there has to be a reset-time where nothing is written to the SPI |
94 | 101 | */ |
@@ -184,9 +191,10 @@ private SpiConfig buildSpiConfig(Context pi4j, int channel, int frequency) { |
184 | 191 | return Spi.newConfigBuilder(pi4j) |
185 | 192 | .id("SPI" + 1) |
186 | 193 | .name("LED Matrix") |
| 194 | + .bus(SpiBus.BUS_0) |
187 | 195 | .address(channel) |
188 | 196 | .mode(SpiMode.MODE_0) |
189 | | - .baud(frequency) // bit-banging from Bit to SPI-Byte |
| 197 | + .baud(8 * DEFAULT_FREQUENCY_PI4) // bit-banging from Bit to SPI-Byte |
190 | 198 | .provider("pigpio-spi") |
191 | 199 | .build(); |
192 | 200 |
|
@@ -369,16 +377,17 @@ public void setBrightness(double brightness) { |
369 | 377 | /** |
370 | 378 | * Helper Class specific for only LEDStrips and matrices |
371 | 379 | * can calculate different colors, and gets the individual color channels |
| 380 | + * G R B |
372 | 381 | */ |
373 | 382 | public class PixelColor { |
374 | 383 | public static final int WHITE = 0xFFFFFF; |
375 | 384 | public static final int RED = 0x00FF00; |
376 | | - public static final int ORANGE = 0xFFC800; |
| 385 | + public static final int ORANGE = 0x66CC00; |
377 | 386 | public static final int YELLOW = 0xFFFF00; |
378 | 387 | public static final int GREEN = 0xFF0000; |
379 | 388 | public static final int LIGHT_BLUE = 0xadd8e6; |
380 | 389 | public static final int BLUE = 0x0000FF; |
381 | | - public static final int PURPLE = 0x800080; |
| 390 | + public static final int PURPLE = 0x008080; |
382 | 391 | public static final int PINK = 0xFFC0CB; |
383 | 392 | public static final int Color_COMPONENT_MAX = 0xff; |
384 | 393 | private static final int WHITE_MASK = 0xffffff; |
|
0 commit comments