// https://forum.arduino.cc/t/newbie-need-help-with-robot/1279686
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <FastLED.h>
#include "kmBitmap.h"
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SCREEN_MIDDLE SCREEN_HEIGHT/2
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define BITMAP_WIDTH 64
#define BITMAP_HEIGHT 64
#define DATA_PIN 6 // Neopixels
#define NUM_PIX 18
#define BRIGHTNESS 255
CRGB led[NUM_PIX];
void setup() {
Serial.begin(115200);
FastLED.addLeds<WS2812, DATA_PIN, GRB>(led, NUM_PIX);
FastLED.setBrightness(BRIGHTNESS);
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // 0x3c = 128x64?
Serial.println(F("SSD1306 allocation failed"));
while (1);
}
drawBitmap();
}
void loop() {
// allpix();
marquee();
// ringpix();
}
void drawBitmap() {
int x = 32, y = 0;
oled.clearDisplay();
oled.drawBitmap(x, y, kmBitmap, BITMAP_WIDTH, BITMAP_HEIGHT, WHITE);
oled.display();
}
void marquee() {
for (int i = 0; i < NUM_PIX; i++) {
if (i % 2)
led[i] = CRGB(255, 255, 255);
else
led[i] = CRGB( 0, 0, 0);
}
FastLED.show();
delay(500);
for (int i = 0; i < NUM_PIX; i++) {
if (i % 2)
led[i] = CRGB( 0, 0, 0);
else
led[i] = CRGB(255, 255, 255);
}
FastLED.show();
delay(500);
}
void allpix() {
for (int i = 0; i < NUM_PIX; i++) {
led[i] = CRGB(random(2) * 255, random(2) * 255, random(2) * 255); // primary colors
}
FastLED.show();
delay(250);
}
void ringpix() {
for (int i = 0; i < NUM_PIX; i++) {
led[i] = CRGB(random(2) * 255, random(2) * 255, random(2) * 255); // primary colors
FastLED.show();
delay(50);
}
}