v1.5增加一个舵机控制前档,实现踢球效果。

This commit is contained in:
myperworld committed 2025-12-23 20:56:06 +08:00
1 parent cc61eda1c7
commit 6395a5f9c3
3693 files changed
+476152 -1

No files matched your search

@@ -0,0 +1,136 @@
/// @file SdCard.ino
/// @brief Demonstrates playing a video on FastLED.
/// @author Zach Vorhies
///
/// This sketch is fully compatible with the FastLED web compiler. To use it do the following:
/// 1. Install Fastled: `pip install fastled`
/// 2. cd into this examples page.
/// 3. Run the FastLED web compiler at root: `fastled`
/// 4. When the compiler is done a web page will open.
#include "FastLED.h"
#if !SKETCH_HAS_LOTS_OF_MEMORY
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
#else
#include "Arduino.h"
#include "fx/2d/noisepalette.h"
// #include "fx/2d/animartrix.hpp"
#include "fx/fx_engine.h"
#include "fx/video.h"
#include "fl/file_system.h"
#include "fl/ui.h"
#include "fl/screenmap.h"
#include "fl/file_system.h"
using namespace fl;
#define LED_PIN 2
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define FPS 60
#define CHIP_SELECT_PIN 5
#define MATRIX_WIDTH 32
#define MATRIX_HEIGHT 32
#define NUM_VIDEO_FRAMES 2 // enables interpolation with > 1 frame.
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
#define IS_SERPINTINE true
UITitle title("SDCard Demo - Mapped Video");
UIDescription description("Video data is streamed off of a SD card and displayed on a LED strip. The video data is mapped to the LED strip using a ScreenMap.");
CRGB leds[NUM_LEDS];
ScreenMap screenMap;
FileSystem filesystem;
Video video;
Video video2;
UISlider videoSpeed("Video Speed", 1.0f, -1, 2.0f, 0.01f);
UINumberField whichVideo("Which Video", 0, 0, 1);
bool gError = false;
void setup() {
Serial.begin(115200);
Serial.println("Sketch setup");
// Initialize the file system and check for errors
if (!filesystem.beginSd(CHIP_SELECT_PIN)) {
Serial.println("Failed to initialize file system.");
}
// Open video files from the SD card
video = filesystem.openVideo("data/video.rgb", NUM_LEDS, FPS, 2);
if (!video) {
FASTLED_WARN("Failed to instantiate video");
gError = true;
return;
}
video2 = filesystem.openVideo("data/color_line_bubbles.rgb", NUM_LEDS, FPS, 2);
if (!video2) {
FASTLED_WARN("Failed to instantiate video2");
gError = true;
return;
}
// Read the screen map configuration
ScreenMap screenMap;
bool ok = filesystem.readScreenMap("data/screenmap.json", "strip1", &screenMap);
if (!ok) {
Serial.println("Failed to read screen map");
gError = true;
return;
}
// Configure FastLED with the LED type, pin, and color order
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
.setCorrection(TypicalLEDStrip)
.setScreenMap(screenMap);
FastLED.setBrightness(96);
Serial.println("FastLED setup done");
}
void loop() {
static bool s_first = true;
if (s_first) {
s_first = false;
Serial.println("First loop.");
}
if (gError) {
// If an error occurred, print a warning every second
EVERY_N_SECONDS(1) {
FASTLED_WARN("No loop because an error occured.");
}
return;
}
// Select the video to play based on the UI input
Video& vid = !bool(whichVideo.value()) ? video : video2;
vid.setTimeScale(videoSpeed);
// Get the current time and draw the video frame
uint32_t now = millis();
vid.draw(now, leds);
FastLED.show();
}
#endif
@@ -0,0 +1,4 @@
data/ directory will appear automatically in emscripten web builds.
* The .rgb file represents uncompressed RGB video data.
* the the screenmap.json is the screenmap for "strip1"
@@ -0,0 +1,2 @@
{"map": {"strip1": {"x": [-0.5, -1.21, -1.91, -2.62, -3.33, -4.04, -4.74, -5.45, -6.16, -6.86, -7.57, -8.28, -8.98, -9.69, -10.4, -11.11, -11.81, -11.11, -10.4, -9.69, -8.98, -8.28, -7.57, -6.86, -6.16, -5.45, -4.74, -4.04, -3.33, -2.62, -1.91, -1.21, -1.91, -2.62, -3.33, -4.04, -4.74, -5.45, -6.16, -6.86, -7.57, -8.28, -8.98, -9.69, -10.4, -11.11, -11.81, -12.52, -13.23, -12.52, -11.81, -11.11, -10.4, -9.69, -8.98, -8.28, -7.57, -6.86, -6.16, -5.45, -4.74, -4.04, -3.33, -2.62, -3.33, -4.04, -4.74, -5.45, -6.16, -6.86, -7.57, -8.28, -8.98, -9.69, -10.4, -11.11, -11.81, -12.52, -13.23, -13.94, -14.64, -13.94, -13.23, -12.52, -11.81, -11.11, -10.4, -9.69, -8.98, -8.28, -7.57, -6.86, -6.16, -5.45, -4.74, -4.04, -4.74, -5.45, -6.16, -6.86, -7.57, -8.28, -8.98, -9.69, -10.4, -11.11, -11.81, -12.52, -13.23, -13.94, -14.64, -15.35, -16.06, -15.35, -14.64, -13.94, -13.23, -12.52, -11.81, -11.11, -10.4, -9.69, -8.98, -8.28, -7.57, -6.86, -6.16, -5.45, -6.16, -6.86, -7.57, -8.28, -8.98, -9.69, -10.4, -11.11, -11.81, -12.52, -13.23, -13.94, -14.64, -15.35, -16.06, -16.76, -17.47, -16.76, -16.06, -15.35, -14.64, -13.94, -13.23, -12.52, -11.81, -11.11, -10.4, -9.69, -8.98, -8.28, -7.57, -6.86, -7.57, -8.28, -8.98, -9.69, -10.4, -11.11, -11.81, -12.52, -13.23, -13.94, -14.64, -15.35, -16.06, -16.76, -17.47, -18.18, -18.89, -18.18, -17.47, -16.76, -16.06, -15.35, -14.64, -13.94, -13.23, -12.52, -11.81, -11.11, -10.4, -9.69, -8.98, -8.28, -8.98, -9.69, -10.4, -11.11, -11.81, -12.52, -13.23, -13.94, -14.64, -15.35, -16.06, -16.76, -17.47, -18.18, -18.89, -19.59, -20.3, -19.59, -18.89, -18.18, -17.47, -16.76, -16.06, -15.35, -14.64, -13.94, -13.23, -12.52, -11.81, -11.11, -10.4, -9.69, -10.4, -11.11, -11.81, -12.52, -13.23, -13.94, -14.64, -15.35, -16.06, -16.76, -17.47, -18.18, -18.89, -19.59, -20.3, -21.01, -21.71, -21.01, -20.3, -19.59, -18.89, -18.18, -17.47, -16.76, -16.06, -15.35, -14.64, -13.94, -13.23, -12.52, -11.81, -11.11, 0.0, 0.71, 1.41, 2.12, 2.83, 3.54, 4.24, 4.95, 5.66, 6.36, 7.07, 7.78, 8.48, 9.19, 9.9, 10.61, 9.9, 9.19, 8.48, 7.78, 7.07, 6.36, 5.66, 4.95, 4.24, 3.54, 2.83, 2.12, 1.41, 0.71, 0.0, -0.71, -1.41, -0.71, 0.0, 0.71, 1.41, 2.12, 2.83, 3.54, 4.24, 4.95, 5.66, 6.36, 7.07, 7.78, 8.48, 9.19, 8.48, 7.78, 7.07, 6.36, 5.66, 4.95, 4.24, 3.54, 2.83, 2.12, 1.41, 0.71, 0.0, -0.71, -1.41, -2.12, -2.83, -2.12, -1.41, -0.71, 0.0, 0.71, 1.41, 2.12, 2.83, 3.54, 4.24, 4.95, 5.66, 6.36, 7.07, 7.78, 7.07, 6.36, 5.66, 4.95, 4.24, 3.54, 2.83, 2.12, 1.41, 0.71, 0.0, -0.71, -1.41, -2.12, -2.83, -3.54, -4.24, -3.54, -2.83, -2.12, -1.41, -0.71, 0.0, 0.71, 1.41, 2.12, 2.83, 3.54, 4.24, 4.95, 5.66, 6.36, 5.66, 4.95, 4.24, 3.54, 2.83, 2.12, 1.41, 0.71, 0.0, -0.71, -1.41, -2.12, -2.83, -3.54, -4.24, -4.95, -5.66, -4.95, -4.24, -3.54, -2.83, -2.12, -1.41, -0.71, 0.0, 0.71, 1.41, 2.12, 2.83, 3.54, 4.24, 4.95, 4.24, 3.54, 2.83, 2.12, 1.41, 0.71, 0.0, -0.71, -1.41, -2.12, -2.83, -3.54, -4.24, -4.95, -5.66, -6.36, -7.07, -6.36, -5.66, -4.95, -4.24, -3.54, -2.83, -2.12, -1.41, -0.71, 0.0, 0.71, 1.41, 2.12, 2.83, 3.54, 2.83, 2.12, 1.41, 0.71, 0.0, -0.71, -1.41, -2.12, -2.83, -3.54, -4.24, -4.95, -5.66, -6.36, -7.07, -7.78, -8.48, -7.78, -7.07, -6.36, -5.66, -4.95, -4.24, -3.54, -2.83, -2.12, -1.41, -0.71, 0.0, 0.71, 1.41, 2.12, 1.41, 0.71, 0.0, -0.71, -1.41, -2.12, -2.83, -3.54, -4.24, -4.95, -5.66, -6.36, -7.07, -7.78, -8.48, -9.19, -9.9, -9.19, -8.48, -7.78, -7.07, -6.36, -5.66, -4.95, -4.24, -3.54, -2.83, -2.12, -1.41, -0.71, 0.0, 0.71, 0.0, -0.71, -1.41, -2.12, -2.83, -3.54, -4.24, -4.95, -5.66, -6.36, -7.07, -7.78, -8.48, -9.19, -9.9, -10.61, 0.5, 1.21, 1.91, 2.62, 3.33, 4.04, 4.74, 5.45, 6.16, 6.86, 7.57, 8.28, 8.98, 9.69, 10.4, 11.11, 11.81, 11.11, 10.4, 9.69, 8.98, 8.28, 7.57, 6.86, 6.16, 5.45, 4.74, 4.04, 3.33, 2.62, 1.91, 1.21, 1.91, 2.62, 3.33, 4.04, 4.74, 5.45, 6.16, 6.86, 7.57, 8.28, 8.98, 9.69, 10.4, 11.11, 11.81, 12.52, 13.23, 12.52, 11.81, 11.11, 10.4, 9.69, 8.98, 8.28, 7.57, 6.86, 6.16, 5.45, 4.74, 4.04, 3.33, 2.62, 3.33, 4.04, 4.74, 5.45, 6.16, 6.86, 7.57, 8.28, 8.98, 9.69, 10.4, 11.11, 11.81, 12.52, 13.23, 13.94, 14.64, 13.94, 13.23, 12.52, 11.81, 11.11, 10.4, 9.69, 8.98, 8.28, 7.57, 6.86, 6.16, 5.45, 4.74, 4.04, 4.74, 5.45, 6.16, 6.86, 7.57, 8.28, 8.98, 9.69, 10.4, 11.11, 11.81, 12.52, 13.23, 13.94, 14.64, 15.35, 16.06, 15.35, 14.64, 13.94, 13.23, 12.52, 11.81, 11.11, 10.4, 9.69, 8.98, 8.28, 7.57, 6.86, 6.16, 5.45, 6.16, 6.86, 7.57, 8.28, 8.98, 9.69, 10.4, 11.11, 11.81, 12.52, 13.23, 13.94, 14.64, 15.35, 16.06, 16.76, 17.47, 16.76, 16.06, 15.35, 14.64, 13.94, 13.23, 12.52, 11.81, 11.11, 10.4, 9.69, 8.98, 8.28, 7.57, 6.86, 7.57, 8.28, 8.98, 9.69, 10.4, 11.11, 11.81, 12.52, 13.23, 13.94, 14.64, 15.35, 16.06, 16.76, 17.47, 18.18, 18.89, 18.18, 17.47, 16.76, 16.06, 15.35, 14.64, 13.94, 13.23, 12.52, 11.81, 11.11, 10.4, 9.69, 8.98, 8.28, 8.98, 9.69, 10.4, 11.11, 11.81, 12.52, 13.23, 13.94, 14.64, 15.35, 16.06, 16.76, 17.47, 18.18, 18.89, 19.59, 20.3, 19.59, 18.89, 18.18, 17.47, 16.76, 16.06, 15.35, 14.64, 13.94, 13.2Line truncated
Binary file not shown.