12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #include <MD_MAX72xx.h>
- #include <SPI.h>
- #include <SD.h>
- #include <ESP32Servo.h> //Require ESP32Servo
- #define STP_DATA_PIN 4
- #define STP_CLOCK_PIN 16
- #define STP_LATCH_PIN 17
- #define SERVO_SWITCH 27
- #define SERVO_COVER 14
- #define DP_CLK_PIN 32
- #define DP_DATA_PIN 33
- #define DP_CS_PIN 25
- #define SD_CS_PIN 5
- #define TOGGLE_SWITCH 13
- #define HARDWARE_TYPE MD_MAX72XX::DR1CR0RR0_HW
- #define MAX_DEVICES 8
- #define SERVO_ALIGNMENT_OFFSET -1
- Servo servoSwitchPusher;
- Servo servoCoverPusher;
- MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, DP_DATA_PIN, DP_CLK_PIN, DP_CS_PIN, MAX_DEVICES);
- char animation = 'a';
- bool SD_exists = true;
- void setup() {
- Serial.begin(115200);
-
- ESP32PWM::allocateTimer(0);
- ESP32PWM::allocateTimer(1);
- ESP32PWM::allocateTimer(2);
- ESP32PWM::allocateTimer(3);
-
- pinMode(STP_DATA_PIN, OUTPUT);
- pinMode(STP_CLOCK_PIN, OUTPUT);
- pinMode(STP_LATCH_PIN, OUTPUT);
- standbySteppers();
-
- servoSwitchPusher.setPeriodHertz(50);
- servoCoverPusher.setPeriodHertz(50);
- servoSwitchPusher.attach(SERVO_SWITCH);
- servoCoverPusher.attach(SERVO_COVER);
- servoCoverPusher.write(0);
- servoSwitchPusher.write(0);
-
-
- if (!SD.begin(SD_CS_PIN)) {
- Serial.println("[Error] Unable to mount SD card");
- SD_exists = false;
- }
-
- mx.begin();
- setDisplayBrightness(0x4);
- renderFrame();
- delay(5000);
-
- createSemaphore();
- startCoreTasks();
- }
- void loop() {
-
-
- }
|