Files
spore/examples/multimatrix/main.cpp
2025-10-14 18:01:37 +02:00

55 lines
1.4 KiB
C++

#include <Arduino.h>
#include <memory>
#include "spore/Spore.h"
#include "spore/util/Logging.h"
#include "../pixelstream/PixelStreamController.h"
#include "MultiMatrixService.h"
namespace {
constexpr uint8_t MATRIX_PIN = D2;
constexpr uint16_t MATRIX_PIXEL_COUNT = 256;
constexpr uint8_t MATRIX_BRIGHTNESS = 40;
constexpr uint16_t MATRIX_WIDTH = 16;
constexpr bool MATRIX_SERPENTINE = false;
constexpr neoPixelType MATRIX_PIXEL_TYPE = NEO_GRB + NEO_KHZ800;
constexpr uint8_t MP3PLAYER_PIN_RX = D3;
constexpr uint8_t MP3PLAYER_PIN_TX = D4;
constexpr uint8_t POTENTIOMETER_PIN = A0;
}
Spore spore({
{"app", "multimatrix"},
{"role", "media"},
{"matrix", String(MATRIX_PIXEL_COUNT)}
});
std::unique_ptr<PixelStreamController> pixelController;
std::shared_ptr<MultiMatrixService> audioService;
void setup() {
spore.setup();
PixelStreamConfig config{
MATRIX_PIN,
MATRIX_PIXEL_COUNT,
MATRIX_BRIGHTNESS,
MATRIX_WIDTH,
MATRIX_SERPENTINE,
MATRIX_PIXEL_TYPE
};
pixelController = std::make_unique<PixelStreamController>(spore.getContext(), config);
pixelController->begin();
audioService = std::make_shared<MultiMatrixService>(spore.getContext(), spore.getTaskManager(), MP3PLAYER_PIN_RX, MP3PLAYER_PIN_TX, POTENTIOMETER_PIN);
spore.registerService(audioService);
spore.begin();
LOG_INFO("MultiMatrix", "Setup complete");
}
void loop() {
spore.loop();
}