organism #3
21
organism/Makefile
Normal file
21
organism/Makefile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Uncomment lines below if you have problems with $PATH
|
||||||
|
#SHELL := /bin/bash
|
||||||
|
#PATH := /usr/local/bin:$(PATH)
|
||||||
|
|
||||||
|
all:
|
||||||
|
pio.exe -f -c vim run
|
||||||
|
|
||||||
|
upload:
|
||||||
|
pio.exe -f -c vim run --target upload
|
||||||
|
|
||||||
|
clean:
|
||||||
|
pio.exe -f -c vim run --target clean
|
||||||
|
|
||||||
|
program:
|
||||||
|
pio.exe -f -c vim run --target program
|
||||||
|
|
||||||
|
uploadfs:
|
||||||
|
pio.exe -f -c vim run --target uploadfs
|
||||||
|
|
||||||
|
update:
|
||||||
|
pio.exe -f -c vim update
|
22
organism/platformio.ini
Normal file
22
organism/platformio.ini
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env:adafruit_matrixportal_esp32s3]
|
||||||
|
platform = espressif32
|
||||||
|
board = adafruit_matrixportal_esp32s3
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
lib_deps =
|
||||||
|
adafruit/Adafruit GFX Library
|
||||||
|
adafruit/Adafruit BusIO
|
||||||
|
Wire
|
||||||
|
fastled/FastLED
|
||||||
|
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA.git
|
105
organism/src/main.cpp
Normal file
105
organism/src/main.cpp
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
#include "xtensa/core-macros.h"
|
||||||
|
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#define R1 42
|
||||||
|
#define G1 40
|
||||||
|
#define BL1 41
|
||||||
|
#define R2 38
|
||||||
|
#define G2 37
|
||||||
|
#define BL2 39
|
||||||
|
#define CH_A 45
|
||||||
|
#define CH_B 36
|
||||||
|
#define CH_C 48
|
||||||
|
#define CH_D 35
|
||||||
|
#define CH_E 21
|
||||||
|
#define CLK 2
|
||||||
|
#define LAT 47
|
||||||
|
#define OE 14
|
||||||
|
|
||||||
|
#define PIN_E 21
|
||||||
|
#define PANEL_WIDTH 64
|
||||||
|
#define PANEL_HEIGHT 32 // Panel height of 64 will required PIN_E to be defined.
|
||||||
|
|
||||||
|
#define PANELS_NUMBER 1
|
||||||
|
|
||||||
|
#define PANE_WIDTH PANEL_WIDTH * PANELS_NUMBER
|
||||||
|
#define PANE_HEIGHT PANEL_HEIGHT
|
||||||
|
#define NUM_LEDS PANE_WIDTH*PANE_HEIGHT
|
||||||
|
|
||||||
|
#define ONBOARD_LED 13
|
||||||
|
|
||||||
|
MatrixPanel_I2S_DMA *matrix = nullptr;
|
||||||
|
|
||||||
|
int start_x = 5;
|
||||||
|
int start_y = 5;
|
||||||
|
int end_x = 59;
|
||||||
|
int end_y = 27;
|
||||||
|
|
||||||
|
int anchor_x = 16;
|
||||||
|
int anchor_y = 24;
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
Serial.begin(BAUD_RATE);
|
||||||
|
pinMode(ONBOARD_LED, OUTPUT);
|
||||||
|
|
||||||
|
// redefine pins if required
|
||||||
|
HUB75_I2S_CFG::i2s_pins _pins={R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK};
|
||||||
|
HUB75_I2S_CFG mxconfig(PANEL_WIDTH, PANEL_HEIGHT, PANELS_NUMBER, _pins);
|
||||||
|
|
||||||
|
mxconfig.gpio.e = PIN_E;
|
||||||
|
mxconfig.driver = HUB75_I2S_CFG::FM6126A; // for panels using FM6126A chips
|
||||||
|
|
||||||
|
mxconfig.latch_blanking = 4;
|
||||||
|
mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M;
|
||||||
|
mxconfig.clkphase = false;
|
||||||
|
|
||||||
|
//mxconfig.double_buff = true;
|
||||||
|
|
||||||
|
matrix = new MatrixPanel_I2S_DMA(mxconfig);
|
||||||
|
matrix->begin();
|
||||||
|
matrix->setBrightness8(64);
|
||||||
|
matrix->fillScreenRGB888(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int interpolate(int from, int to, float percent) {
|
||||||
|
int difference = to - from;
|
||||||
|
return from + ( difference * percent );
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_bezier(int x1, int y1, int x2, int y2, int x3, int y3, float percent) {
|
||||||
|
// draw lines to p2
|
||||||
|
matrix->drawLine(x1, y1, x2, y2, matrix->color565(16, 16, 16));
|
||||||
|
matrix->drawLine(x2, y2, x3, y3, matrix->color565(16, 16, 16));
|
||||||
|
|
||||||
|
int xa = interpolate(x1, x2, percent);
|
||||||
|
int ya = interpolate(y1, y2, percent);
|
||||||
|
int xb = interpolate(x2, x3, percent);
|
||||||
|
int yb = interpolate(y2, y3, percent);
|
||||||
|
//matrix->drawLine(xa, ya, xb, yb, matrix->color565(0, 128, 0));
|
||||||
|
|
||||||
|
int x = interpolate(xa, xb, percent);
|
||||||
|
int y = interpolate(ya, yb, percent);
|
||||||
|
|
||||||
|
matrix->drawPixel(x, y, matrix->color565(255, 255, 255));
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// matrix ->flipDMABuffer();
|
||||||
|
matrix->clearScreen();
|
||||||
|
// delay(25);
|
||||||
|
anchor_y += 1;
|
||||||
|
if (anchor_y >= 32) {
|
||||||
|
anchor_y = 0;
|
||||||
|
}
|
||||||
|
for (float i = 0; i < 1; i += 0.02) {
|
||||||
|
draw_bezier(start_x, start_y, anchor_x, anchor_y, end_x, end_y, i);
|
||||||
|
}
|
||||||
|
matrix->drawPixel(start_x, start_y, matrix->color565(255, 0, 0));
|
||||||
|
matrix->drawPixel(end_x, end_y, matrix->color565(255, 0, 0));
|
||||||
|
matrix->drawPixel(anchor_x, anchor_y, matrix->color565(255, 0, 255));
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
10
organism/src/main.h
Normal file
10
organism/src/main.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <FastLED.h>
|
||||||
|
|
||||||
|
#define BAUD_RATE 115200 // serial debug port baud rate
|
||||||
|
|
||||||
|
void buffclear(CRGB *buf);
|
||||||
|
uint16_t XY16( uint16_t x, uint16_t y);
|
||||||
|
void mxfill(CRGB *leds);
|
||||||
|
uint16_t colorWheel(uint8_t pos);
|
||||||
|
void drawText(int colorWheelOffset);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user