Skip to content

Commit

Permalink
Latest changes to V3 firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
maxritter committed Jul 5, 2021
1 parent f9db764 commit 1648b7d
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 116 deletions.
3 changes: 2 additions & 1 deletion Firmware_V3/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"files.associations": {
"*.tcc": "cpp",
"functional": "cpp"
"functional": "cpp",
"typeinfo": "cpp"
}
}
2 changes: 1 addition & 1 deletion Firmware_V3/include/globalvariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ extern volatile bool longTouch;
extern volatile bool serialMode;
extern volatile byte loadTouch;
extern volatile bool leptonBufferValid;
extern volatile bool displayUpdated;
extern volatile bool disableSPIIRQ;

#endif /* GLOBALVARIABLES_H */
10 changes: 5 additions & 5 deletions Firmware_V3/include/loadmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ bool convertPrompt();
void convertVideo(char* dirname);
void deleteImage(char* filename);
void deleteVideo(char* dirname);
void displayGUI(int imgCount, char* infoText);
void displayVideoFrame(int i);
uint16_t getVideoFrameNumber();
void displayGUI(uint32_t imgCount, char* infoText);
void displayVideoFrame(uint32_t imgCount);
uint32_t getVideoFrameNumber();
int loadMenu(char* title, int* array, int length);
void openImage(char* filename, int imgCount);
void playVideo(char* dirname, int imgCount);
void openImage(char* filename, uint32_t imgCount);
void playVideo(char* dirname, uint32_t imgCount);

#endif /* LOADMENU_H */
7 changes: 3 additions & 4 deletions Firmware_V3/include/save.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

/*########################## PUBLIC PROCEDURES ################################*/

void createBMPFile(char* filename);
void createSDName(char* filename, boolean folder = false);
void frameFilename(char* filename, uint16_t count);
void frameFilename(char* filename, uint32_t count);
void imgSaveEnd();
void imgSaveStart();
void processVideoFrames(int framesCaptured, char* dirname);
void processVideoFrames(uint32_t framesCaptured, char* dirname);
void saveBuffer(char* filename);
void saveRawData(bool isImage, char* name, uint16_t framesCaptured = 0);
void saveRawData(bool isImage, char* name, uint32_t framesCaptured = 0);
void saveVideoFrame(char* filename);

#endif /* SAVE_H */
4 changes: 2 additions & 2 deletions Firmware_V3/include/videomenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

/*########################## PUBLIC PROCEDURES ################################*/

void videoCaptureInterval(int16_t* remainingTime, int* framesCaptured);
void videoCaptureNormal(int* framesCaptured);
void videoCaptureInterval(int16_t* remainingTime, uint32_t* framesCaptured, uint16_t* folderFrames, char* buffer, char* dirName);
void videoCaptureNormal(uint32_t* framesCaptured, uint16_t* folderFrames, char* buffer, char* dirName);
void videoCapture();
bool videoIntervalChooser();
bool videoIntervalHandler(byte* pos);
Expand Down
2 changes: 1 addition & 1 deletion Firmware_V3/lib/SdFat/src/SdFatConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ typedef uint8_t SdCsPin_t;
* Set USE_SD_CRC to 2 to used a larger table driven CRC-CCITT function. This
* function is faster for AVR but may be slower for ARM and other processors.
*/
#define USE_SD_CRC 0
#define USE_SD_CRC 1
//------------------------------------------------------------------------------
/** If the symbol USE_FCNTL_H is nonzero, open flags for access modes O_RDONLY,
* O_WRONLY, O_RDWR and the open modifiers O_APPEND, O_CREAT, O_EXCL, O_SYNC
Expand Down
Binary file modified Firmware_V3/other/platformio_teensy4.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions Firmware_V3/src/general/globalvariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/*############################# PUBLIC VARIABLES ##############################*/

//Current firmware version
char versionString[] = "Firmware 3.02 from 21.06.2021";
char versionString[] = "Firmware 3.02 from 05.07.2021";
uint16_t fwVersion = 302;

//320x240 buffer
Expand Down Expand Up @@ -150,4 +150,4 @@ volatile byte loadTouch;
//Current buffer valid
volatile bool leptonBufferValid;
//Display is currently updated, do not use SPI in IRQ
volatile bool displayUpdated;
volatile bool disableSPIIRQ;
40 changes: 20 additions & 20 deletions Firmware_V3/src/gui/loadmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/*######################## PUBLIC FUNCTION BODIES #############################*/

/* Display the GUI elements for the load menu */
void displayGUI(int imgCount, char* infoText) {
void displayGUI(uint32_t imgCount, char* infoText) {
//Set text color
changeTextColor();
//set Background transparent
Expand Down Expand Up @@ -89,9 +89,9 @@ void deleteVideo(char* dirname) {
sd.chdir(dirname);

//Delete all files
uint16_t videoCounter = 0;
uint32_t videoCounter = 0;
bool exists;
char filename[] = "00000.DAT";
char filename[] = "000000.DAT";

//Go through the frames
while (1) {
Expand All @@ -106,15 +106,15 @@ void deleteVideo(char* dirname) {
else
sd.remove(filename);
//Remove Bitmap if there
strcpy(&filename[5], ".BMP");
strcpy(&filename[6], ".BMP");
if (sd.exists(filename))
sd.remove(filename);
//Remove Jpeg if there
strcpy(&filename[5], ".JPG");
strcpy(&filename[6], ".JPG");
if (sd.exists(filename))
sd.remove(filename);
//Reset ending
strcpy(&filename[5], ".DAT");
strcpy(&filename[6], ".DAT");
//Raise counter
videoCounter++;
}
Expand Down Expand Up @@ -265,8 +265,8 @@ void convertVideo(char* dirname) {
sd.chdir("/");
sd.chdir(dirname);

uint16_t frames = getVideoFrameNumber();
char filename[] = "00000.BMP";
uint32_t frames = getVideoFrameNumber();
char filename[] = "000000.BMP";

//Delete the ending for a video
dirname[14] = '\0';
Expand Down Expand Up @@ -298,7 +298,7 @@ void convertVideo(char* dirname) {
}

/* Loads an image from the SDCard and prints it on screen */
void openImage(char* filename, int imgCount) {
void openImage(char* filename, uint32_t imgCount) {
//Show message on screen
showFullMessage((char*) "Please wait, image is loading..");

Expand Down Expand Up @@ -352,10 +352,10 @@ void openImage(char* filename, int imgCount) {
}

/* Get the number of frames in the video */
uint16_t getVideoFrameNumber() {
uint16_t videoCounter = 0;
uint32_t getVideoFrameNumber() {
uint32_t videoCounter = 0;
bool exists;
char filename[] = "00000.DAT";
char filename[] = "000000.DAT";

//Look how many frames we have
while (true) {
Expand All @@ -375,12 +375,12 @@ uint16_t getVideoFrameNumber() {
}

/* Display the selected video frame */
void displayVideoFrame(int i)
void displayVideoFrame(uint32_t imgCount)
{
char filename[] = "00000.DAT";
char filename[] = "000000.DAT";

//Get the frame name
frameFilename(filename, i);
frameFilename(filename, imgCount);

//Load Raw data
loadRawData(filename);
Expand All @@ -390,24 +390,24 @@ void displayVideoFrame(int i)
}

/* Play a video from the internal storage */
void playVideo(char* dirname, int imgCount) {
void playVideo(char* dirname, uint32_t imgCount) {
char buffer[14];
//Save the current frame number
int frameNumber = 0;
uint32_t frameNumber = 0;

//Switch to video folder
sd.chdir("/");
sd.chdir(dirname);

//Get the total number of frames in the dir
uint16_t numberOfFrames = getVideoFrameNumber();
uint32_t numberOfFrames = getVideoFrameNumber();

//Jump here when pausing a video
showFrame:
//Display frame
displayVideoFrame(frameNumber);
//Create string
sprintf(buffer, "%5d / %-5d", frameNumber + 1, numberOfFrames);
sprintf(buffer, "%6lu / %-6lu", frameNumber + 1, numberOfFrames);
//Display GUI
displayGUI(imgCount, buffer);
//Display play message
Expand Down Expand Up @@ -464,7 +464,7 @@ void playVideo(char* dirname, int imgCount) {
//Display frame
displayVideoFrame(frameNumber);
//Create string
sprintf(buffer, "%5d / %-5d", frameNumber + 1, numberOfFrames);
sprintf(buffer, "%6lu / %-6lu", frameNumber + 1, numberOfFrames);
//Display GUI
displayGUI(imgCount, buffer);
}
Expand Down
3 changes: 3 additions & 0 deletions Firmware_V3/src/gui/mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,9 @@ void mainMenuHandler(byte *pos)
//Main loop
while (true)
{
//Enter mass storage on USB connect
checkMassStorage();

//Check for screen sleep
if (screenOffCheck())
drawMainMenu(*pos);
Expand Down
72 changes: 44 additions & 28 deletions Firmware_V3/src/gui/videomenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,14 @@ bool videoIntervalChooser() {
}

/* Captures video frames in an interval */
void videoCaptureInterval(int16_t* remainingTime, int* framesCaptured) {
char buffer[30];

void videoCaptureInterval(int16_t* remainingTime, uint32_t* framesCaptured, uint16_t* folderFrames, char* buffer, char* dirName) {
//Measure time
long measure = millis();

//If there is no more time or the first frame
if ((*remainingTime <= 0) || (*framesCaptured == 0)) {
saveRawData(false, NULL, *framesCaptured);
if ((*remainingTime <= 0) || (*folderFrames == 0)) {
saveRawData(false, dirName, *folderFrames);
*folderFrames = *folderFrames + 1;
}

//Convert lepton data to RGB565 colors
Expand Down Expand Up @@ -230,11 +229,10 @@ void videoCaptureInterval(int16_t* remainingTime, int* framesCaptured) {
}

/* Normal video capture */
void videoCaptureNormal(int* framesCaptured) {
char buffer[30];

void videoCaptureNormal(uint32_t* framesCaptured, uint16_t* folderFrames, char* buffer, char* dirName) {
//Save video raw frame
saveRawData(false, NULL, *framesCaptured);
saveRawData(false, dirName, *folderFrames);
*folderFrames = *folderFrames + 1;

//Convert the colors
convertColors();
Expand All @@ -252,7 +250,7 @@ void videoCaptureNormal(int* framesCaptured) {
*framesCaptured = *framesCaptured + 1;

//Display current frames captured
sprintf(buffer, "Frames captured: %5d", *framesCaptured);
sprintf(buffer, "Frames captured: %6lu", *framesCaptured);
display_print(buffer, 70, 200);

//Disable image buffer
Expand All @@ -262,31 +260,52 @@ void videoCaptureNormal(int* framesCaptured) {
displayBuffer();
}

void videoCreateFolder(char *dirName) {
createSDName(dirName, true);
if(!sd.chdir("/"))
{
beginSD();
if(!sd.chdir("/"))
{
showFullMessage((char*) "Error creating folder!");
delay(1000);
return;
}
}
sd.mkdir(dirName);
sd.chdir(dirName);
}

/* This screen is shown during the video capture */
void videoCapture() {
//Help variables
char dirname[20];
char dirName[20];
char buffer[30];
int16_t delayTime = videoInterval;
int framesCaptured = 0;
uint32_t framesCaptured = 0;
uint16_t folderFrames = 0;

//Show message
showFullMessage((char*)"Touch screen to turn it off");
display_print((char*) "STARTING VIDEO MODE", CENTER, 50);
display_print((char*) "Press the button to abort", CENTER, 170);
showFullMessage((char*)"Touch screen to turn it on/off");
display_print((char*) "CAPTURING FRAMES..", CENTER, 50);
display_print((char*) "Press push button to stop", CENTER, 170);
delay(1000);

//Create folder
createSDName(dirname, true);
sd.chdir("/");
sd.mkdir(dirname);
sd.chdir(dirname);
videoCreateFolder(dirName);

//Switch to recording mode
videoSave = videoSave_recording;
lepton_startFrame();

//Main loop
lepton_startFrame();
while (videoSave == videoSave_recording) {
//Do not store too many files in one folder, otherwise MTP will make issues
if(folderFrames >= 1000)
{
videoCreateFolder(dirName);
folderFrames = 0;
}

//Touch - turn display on or off
if (!digitalRead(pin_touch_irq)) {
Expand All @@ -299,11 +318,11 @@ void videoCapture() {

//Video capture
if (videoInterval == 0) {
videoCaptureNormal(&framesCaptured);
videoCaptureNormal(&framesCaptured, &folderFrames, buffer, dirName);
}
//Interval capture
else {
videoCaptureInterval(&delayTime, &framesCaptured);
videoCaptureInterval(&delayTime, &framesCaptured, &folderFrames, buffer, dirName);
}

lepton_startFrame();
Expand All @@ -313,19 +332,16 @@ void videoCapture() {
if (!checkScreenLight())
enableScreenLight();

//Post processing for interval videos if enabled and wished
if ((framesCaptured > 0) && (convertPrompt()))
processVideoFrames(framesCaptured, dirname);
//Post processing for interval videos if enabled
if ((framesCaptured > 0) && convertEnabled)
processVideoFrames(framesCaptured, dirName);

//Show finished message
else {
showFullMessage((char*) "Video capture finished");
delay(1000);
}

//Go back to root directory
sd.chdir("/");

//Refresh free space
refreshFreeSpace();

Expand Down
4 changes: 2 additions & 2 deletions Firmware_V3/src/hardware/display/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ void display_exitSleepMode()
/* Write 320x240 RGB565 data to the screen */
void display_writeScreen(unsigned short *pcolors)
{
displayUpdated = true;
disableSPIIRQ = true;
display_begin_spi_transaction();
display_setAddr(0, 0, 319, 239);
display_writecommand_cont(ILI9341_RAMWR);
Expand All @@ -1468,5 +1468,5 @@ void display_writeScreen(unsigned short *pcolors)
}
display_writedata16_last(*pftbft);
display_end_spi_transaction();
displayUpdated = false;
disableSPIIRQ = false;
}
Loading

0 comments on commit 1648b7d

Please sign in to comment.