Guest User

FASTLED and u8x8 Conflict

a guest
Jan 10th, 2023
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <Arduino.h>
  2. #include <U8x8lib.h>
  3. #include <FastLED.h>
  4.  
  5. #ifdef U8X8_HAVE_HW_SPI
  6. #include <SPI.h>
  7. #endif
  8.  
  9. //OLED
  10. U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
  11.  
  12. //LED Stripe
  13. #define LED_PIN 5
  14. #define COLOR_ORDER GRB
  15. #define CHIPSET WS2813
  16. #define NUM_LEDS 30
  17.  
  18. #define BRIGHTNESS 50
  19. #define FRAMES_PER_SECOND 60
  20.  
  21. CRGB leds[NUM_LEDS];
  22.  
  23. void setup() {
  24. delay(3000); // sanity delay
  25.  
  26. //initOLED
  27. u8x8.begin();
  28.  
  29. //init LED Stripe
  30. FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  31. FastLED.setBrightness( BRIGHTNESS );
  32. }
  33.  
  34. void loop()
  35. {
  36.  
  37. resetStripe();
  38. updateOLED();
  39. FastLED.show();
  40. FastLED.delay(1000 / FRAMES_PER_SECOND);
  41.  
  42. }
  43.  
  44. void resetStripe(){
  45. for(int i = 0; i < NUM_LEDS; i++) {
  46. leds[i] = CRGB::Green;
  47. }
  48. }
  49.  
  50. void updateOLED(){
  51. u8x8.clearDisplay();
  52. u8x8.setFont(u8x8_font_px437wyse700a_2x2_r);
  53. u8x8.drawString(0, 0, "Hello World");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment