-
Notifications
You must be signed in to change notification settings - Fork 0
/
JayD-Library.ino
161 lines (128 loc) · 3.37 KB
/
JayD-Library.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include <Arduino.h>
#include <CircuitOS.h>
#include "src/JayD.h"
#include <Loop/LoopManager.h>
#include "src/AudioLib/SourceWAV.h"
#include "src/AudioLib/OutputI2S.h"
#include "src/AudioLib/Mixer.h"
#include "src/PerfMon.h"
#include "src/Services/SDScheduler.h"
#include "src/Input/InputJayD.h"
#include "src/Settings.h"
#include "src/AudioLib/Systems/MixSystem.h"
#include <Display/Display.h>
#include <SPI.h>
#include <Devices/Matrix/Matrix.h>
#include <Devices/SerialFlash/SerialFlashFileAdapter.h>
#include <SD.h>
#include <WiFi.h>
#include <Util/Task.h>
#include <esp_partition.h>
#include <SPIFFS.h>
Display display(160, 128, -1, -1);
int pixel = 0;
Matrix* matrix = &matrixManager.matrixBig;
void lightPixel(int pixel, bool turnoff = false){
if(turnoff){
matrix->drawPixel(::pixel, MatrixPixel::Off);
}
pixel = max(pixel, 0);
pixel = min(pixel, 16 * 9 - 1);
matrix->drawPixel(pixel, MatrixPixel::White);
::pixel = pixel;
}
void recurseDir(File dir){
File f;
while(f = dir.openNextFile()){
if(f.isDirectory()){
recurseDir(f);
continue;
}
Serial.println(f.name());
f.close();
}
}
void listSD(){
File root = SD.open("/");
if(!root){
Serial.println("List SD: can't open root");
return;
}
recurseDir(root);
root.close();
}
MixSystem* mix = nullptr;
void setup(){
Serial.begin(115200);
JayD.begin();
/*
pinMode(25, OUTPUT);
digitalWrite(25, HIGH);
WiFi.mode(WIFI_OFF);
btStop();
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
chip_info.cores,
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
printf("silicon revision %d, ", chip_info.revision);
printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
fflush(stdout);
if(psramFound()){
Serial.printf("PSRAM init: %s, free: %d B\n", psramInit() ? "Yes" : "No", ESP.getFreePsram());
}else{
Serial.println("No PSRAM");
}
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI, SPI_SS);
SPI.setFrequency(60000000);
if(!SD.begin(22, SPI)){
Serial.println("No SD card");
for(;;);
}
if(!SPIFFS.begin()){
Serial.println("SPIFFS error");
}
display.begin();
SPI.setFrequency(20000000);
if(!LEDmatrix.begin(I2C_SDA, I2C_SCL)){
Serial.println("couldn't start matrix");
for(;;);
}*/
/* Settings.begin();
LEDmatrix.setBrightness(80.0f * (float) Settings.get().brightnessLevel / 255.0f);
LoopManager::addListener(&Sched);
LoopManager::addListener(&matrixManager);
LoopManager::addListener(new InputJayD());
InputJayD::getInstance()->begin();
mix = new MixSystem(SD.open("/Walter2.aac"), SD.open("/Recesija2.aac"));
mix->setMix(128);
mix->setVolume(0, 50);
mix->setVolume(1, 50);
mix->start();*/
/* InputJayD* input = new InputJayD();
input->begin();
LoopManager::addListener(input);
digitalWrite(JDNV_PIN_RESET, LOW);
LEDMatrix.begin(26, 27);
LEDMatrix.clear();
LEDMatrix.push();*/
InputJayD::getInstance()->setEncoderMovedCallback(1, [](int8_t value){
lightPixel(pixel + value, true);
matrix->push();
Serial.printf("%d\n", pixel);
});
}
int i = 0;
void loop(){
LoopManager::loop();
/*i++;
LEDMatrix.clear();
lightPixel((i/13) % 144);
lightPixel((i/17) % 144);
lightPixel((i/5) % 144);
lightPixel((i/7) % 144);
lightPixel((i/11) % 144);
LEDMatrix.push();*/
}