mirror of https://github.com/radex/radmatrix.git
Compare commits
2 Commits
cd4aa9ba09
...
e1b4f4b275
Author | SHA1 | Date |
---|---|---|
radex | e1b4f4b275 | |
radex | 137f4d4907 |
|
@ -1,9 +1,13 @@
|
||||||
## convert video
|
## convert video
|
||||||
|
|
||||||
|
automatically:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
scripts/convert.sh ../badapple.webm
|
scripts/convert.sh ../badapple.webm
|
||||||
```
|
```
|
||||||
|
|
||||||
|
the output is in video_output
|
||||||
|
|
||||||
or manually:
|
or manually:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -30,4 +34,12 @@ move to `audio` folder, then:
|
||||||
python3 scripts/audio_convert.py
|
python3 scripts/audio_convert.py
|
||||||
```
|
```
|
||||||
|
|
||||||
on the SD card, create a folder named `badapple` and inside, add `audio.bin` from `audio` and `gfx.bin` and `gfx_len.bin` from `gfx_output`.
|
## play videos on device
|
||||||
|
|
||||||
|
create `video/YOURNAME/` folder, with files:
|
||||||
|
|
||||||
|
(where files are audio.bin, gfx.bin, gfx_len.bin)
|
||||||
|
|
||||||
|
NOTE: yourname MUST be at most 8 characters long
|
||||||
|
|
||||||
|
also `video/playlist.txt` with names of videos in order
|
||||||
|
|
|
@ -8,11 +8,11 @@ uint16_t frameCount = 0;
|
||||||
|
|
||||||
uint8_t gfxFrameBuffer[6400] = {0};
|
uint8_t gfxFrameBuffer[6400] = {0};
|
||||||
|
|
||||||
bool gfx_decoder_loadNextFrame() {
|
int32_t gfx_decoder_loadNextFrame() {
|
||||||
// load frame from SD card
|
// load frame from SD card
|
||||||
auto frameSize = sd_loadNextFrame();
|
auto frameSize = sd_loadNextFrame();
|
||||||
if (frameSize < 0) {
|
if (frameSize < 0) {
|
||||||
return false;
|
return frameSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode PNG
|
// decode PNG
|
||||||
|
@ -44,16 +44,16 @@ bool gfx_decoder_loadNextFrame() {
|
||||||
// TODO: mutex? double buffer? or something...
|
// TODO: mutex? double buffer? or something...
|
||||||
memcpy(framebuffer, buffer, ROW_COUNT * COL_COUNT);
|
memcpy(framebuffer, buffer, ROW_COUNT * COL_COUNT);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return true;
|
return frameSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long frameLastChangedAt = 0;
|
unsigned long frameLastChangedAt = 0;
|
||||||
|
|
||||||
bool gfx_decoder_handleLoop() {
|
int32_t gfx_decoder_handleLoop() {
|
||||||
auto now = millis();
|
auto now = millis();
|
||||||
if (now - frameLastChangedAt > MS_PER_FRAME) {
|
if (now - frameLastChangedAt > MS_PER_FRAME) {
|
||||||
frameLastChangedAt = now;
|
frameLastChangedAt = now;
|
||||||
return gfx_decoder_loadNextFrame();
|
return gfx_decoder_loadNextFrame();
|
||||||
}
|
}
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ extern uint16_t gfxFrameLengthsBuffer[24000];
|
||||||
extern uint16_t frameCount;
|
extern uint16_t frameCount;
|
||||||
extern uint8_t gfxFrameBuffer[6400];
|
extern uint8_t gfxFrameBuffer[6400];
|
||||||
|
|
||||||
bool gfx_decoder_loadNextFrame();
|
int32_t gfx_decoder_loadNextFrame();
|
||||||
bool gfx_decoder_handleLoop();
|
int32_t gfx_decoder_handleLoop();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,11 +52,15 @@ void loadVideo(size_t index) {
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void nextSong() {
|
||||||
if (digitalRead(4) == LOW) {
|
|
||||||
Serial.println("Next song!");
|
Serial.println("Next song!");
|
||||||
currentVideoIndex = (currentVideoIndex + 1) % playlistSize;
|
currentVideoIndex = (currentVideoIndex + 1) % playlistSize;
|
||||||
loadVideo(currentVideoIndex);
|
loadVideo(currentVideoIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (digitalRead(4) == LOW) {
|
||||||
|
nextSong();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (Serial.available() > 0) {
|
// if (Serial.available() > 0) {
|
||||||
|
@ -75,8 +79,12 @@ void loop() {
|
||||||
if (isLoaded) {
|
if (isLoaded) {
|
||||||
sd_loadNextAudio();
|
sd_loadNextAudio();
|
||||||
|
|
||||||
if (!gfx_decoder_handleLoop()) {
|
auto loopStatus = gfx_decoder_handleLoop();
|
||||||
|
|
||||||
|
if (loopStatus == -1) {
|
||||||
Serial.println("Failed to load frame...");
|
Serial.println("Failed to load frame...");
|
||||||
|
} else if (loopStatus == -2) {
|
||||||
|
nextSong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,8 +271,10 @@ void sd_loadNextAudio() {
|
||||||
auto bytesRead = audioFile.read(next_buffer, BUFFER_LEN);
|
auto bytesRead = audioFile.read(next_buffer, BUFFER_LEN);
|
||||||
|
|
||||||
if (bytesRead < BUFFER_LEN) {
|
if (bytesRead < BUFFER_LEN) {
|
||||||
Serial.println("End of audio file, rewinding...");
|
// Serial.println("End of audio file, rewinding...");
|
||||||
audioFile.seek(0);
|
// audioFile.seek(0);
|
||||||
|
Serial.println("End of audio.");
|
||||||
|
audio_stop();
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
Serial.print("Read ");
|
Serial.print("Read ");
|
||||||
|
@ -374,9 +376,11 @@ int32_t sd_loadNextFrame() {
|
||||||
|
|
||||||
// increment
|
// increment
|
||||||
if (frameIdx == frameCount - 1) {
|
if (frameIdx == frameCount - 1) {
|
||||||
Serial.println("Last frame, rewinding...");
|
// Serial.println("Last frame, rewinding...");
|
||||||
gfxFile.seek(0);
|
// gfxFile.seek(0);
|
||||||
frameIdx = 0;
|
// frameIdx = 0;
|
||||||
|
Serial.println("Last frame, next video!");
|
||||||
|
return -2;
|
||||||
} else {
|
} else {
|
||||||
frameIdx++;
|
frameIdx++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue