diff options
author | Nick Van Doorn <vandoorn.nick@gmail.com> | 2017-12-27 17:01:44 -0800 |
---|---|---|
committer | Nick Van Doorn <vandoorn.nick@gmail.com> | 2017-12-27 17:01:44 -0800 |
commit | 122f3c2a48a5be50bf1ff9ab3953db482838d3ff (patch) | |
tree | 4889db40f9afe364e0a8402bf536328bc74fcd11 | |
parent | 9e5efd8f669832efacd76c02c69cb71cd469292e (diff) |
Fix progress computation
-rw-r--r-- | camera.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -445,7 +445,6 @@ bool cam_readImageBlocks (Camera *cam, FILE *filePtr) { int jpgLen = cam_frameLength(cam); int imgSize = jpgLen; int nWrites = 0; - int totalDataRead = 0; while (jpgLen > 0) { uint8_t bytesToRead = cam_getImageBlockSize(jpgLen); uint8_t *buff = cam_readPicture(cam, bytesToRead); @@ -453,10 +452,10 @@ bool cam_readImageBlocks (Camera *cam, FILE *filePtr) { LE_ERROR("Failed to read image data"); return false; } - totalDataRead += bytesToRead; fwrite(buff, sizeof(*buff), bytesToRead, filePtr); + // give progress every 30 writes if (++nWrites % 30 == 0) { - double percentComplete = (double)totalDataRead * 100.0 / (double)imgSize; + double percentComplete = (double)imgSize - jpgLen * 100.0 / (double)imgSize; LE_INFO("Image write %f%% complete", percentComplete); } jpgLen -= bytesToRead; |