Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Oct 30, 2023
1 parent 44315e3 commit 8f50950
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 78 deletions.
73 changes: 1 addition & 72 deletions src/utility/ScreenShotService/ScreenShot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@

#include "ScreenShot.hpp"

/*
ScreenShotService::ScreenShotService( M5Display *tft, fs::FS &fileSystem )
{
// wut ?
}
*/

ScreenShotService::~ScreenShotService()
{
if( _begun ) {
Expand Down Expand Up @@ -220,7 +215,6 @@ void ScreenShotService::snap( const char* name, bool displayAfter )




void ScreenShotService::snapAVI( AVI_Params_t *params, bool finalize )
{
assert( params );
Expand Down Expand Up @@ -348,66 +342,6 @@ void ScreenShotService::snap( const char* name, bool displayAfter )
}
}


#else // no JPEGENC library found, use the TinyJpegEncoder

// // this is lame
// static uint32_t jpeg_encoder_xoffset = 0;
// static uint32_t jpeg_encoder_yoffset = 0;
// static uint32_t jpeg_encoder_w = 0;
//
// static void readRectRGB(uint32_t y, uint32_t h, unsigned char* rgbBuffer, void* device)
// {
// auto tft = (LGFX*)device;
// tft->readRectRGB( jpeg_encoder_xoffset, jpeg_encoder_yoffset+y, jpeg_encoder_w, h, rgbBuffer );
// }
//
// void ScreenShotService::snapJPG( const char* name, bool displayAfter )
// {
// if( !jpegCapture ) return;
// jpeg_encoder_xoffset = _x;
// jpeg_encoder_yoffset = _y;
// jpeg_encoder_w = _w;
// genFileName( name, "jpg" );
// [[maybe_unused]] uint32_t time_start = millis();
//
// screenShotBufSize = (_w*8*3)+1;
//
// if( _psram && psramInit() ) {
// log_v("Will attempt to allocate psram for screenshots");
// screenShotBuffer = (uint8_t*)ps_calloc( screenShotBufSize, sizeof( uint8_t ) );
// } else {
// log_v("Will attempt to allocate ram for screenshots");
// screenShotBuffer = (uint8_t*)calloc( screenShotBufSize, sizeof( uint8_t ) );
// _psram = false;
// }
// if( screenShotBuffer != NULL ) {
// log_v( "ScreenShot Service can use JPG capture" );
// } else {
// log_i( "Not enough ram to use jpeg screenshot" );
// jpegCapture = false;
// return;
// }
//
// JPEG_Encoder* JPEGEncoder = new JPEG_Encoder( _fileSystem );
// JPEGEncoder->begin( _psram );
//
// if ( !JPEGEncoder->encodeToFile( fileName, _w, _h, 3 /*3=RGB,4=RGBA*/, screenShotBuffer, &readRectRGB, _src ) ) {
// log_i( "[ERROR] Could not write JPG file to: %s", fileName );
// } else {
// fs::File outFile = _fileSystem->open( fileName );
// log_i( "[SUCCESS] Screenshot saved as %s (%d bytes). Total time %u ms", fileName, outFile.size(), millis()-time_start);
// outFile.close();
// if( displayAfter ) {
// snapAnimation();
// _src->drawJpgFile( *_fileSystem, fileName, _x, _y, _w, _h, 0, 0 );
// delay(5000);
// }
// }
// delete JPEGEncoder;
// free( screenShotBuffer );
// }

#endif


Expand Down Expand Up @@ -468,11 +402,6 @@ void ScreenShotService::snapGIF( const char* name, bool displayAfter )
fs::File outFile = _fileSystem->open( fileName );
log_i( "[SUCCESS] Screenshot saved as %s (%d bytes). Total time %u ms", fileName, outFile.size(), millis()-time_start);
outFile.close();
//if( displayAfter ) {
// snapAnimation();
// _src->drawGifFile( *_fileSystem, fileName, 0, 0 );
// delay(5000);
//}
}
delete GIFEncoder;
}
Expand Down
7 changes: 1 addition & 6 deletions src/utility/ScreenShotService/ScreenShot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,8 @@ class ScreenShotService

}; // end class

#if !defined HAS_JPEGENC
// #include "./JPG/TinyJPEGEncoder.hpp" // this JPG Encoder is slow
#else
//#include "./JPG/
#endif
#include "./BMP/TinyBMPEncoder.hpp"
#include "./PNG/FatPNGEncoder.hpp" // requires miniz.c patched with TDEFL_LESS_MEMORY=1
#include "./PNG/FatPNGEncoder.hpp"
#include "./GIF/TinyGIFEncoder.hpp"
#include "./QOI/QOIEncoder.hpp"

0 comments on commit 8f50950

Please sign in to comment.