Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print the JRESULT value returned by jd_prepare function #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions st7789/jpg/tjpgd565.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,3 +950,20 @@ JRESULT jd_decomp (

return rc;
}
/*-----------------------------------------------------------------------*/
/*----------------------Parse the error codes----------------------------*/
/*-----------------------------------------------------------------------*/
const char* jresult_to_string(JRESULT result) {
switch (result) {
case JDR_OK: return "Succeeded";
case JDR_INTR: return "Interrupted by output function";
case JDR_INP: return "Device error or wrong termination of input stream";
case JDR_MEM1: return "Insufficient memory pool for the image";
case JDR_MEM2: return "Insufficient stream input buffer";
case JDR_PAR: return "Parameter error";
case JDR_FMT1: return "Data format error (may be damaged data)";
case JDR_FMT2: return "Right format but not supported";
case JDR_FMT3: return "Not supported JPEG standard";
default: return "Unknown error";
}
}
2 changes: 1 addition & 1 deletion st7789/jpg/tjpgd565.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct JDEC {
/* TJpgDec API functions */
JRESULT jd_prepare (JDEC* jd, unsigned int (*infunc)(JDEC*,uint8_t*,unsigned int), void* pool, unsigned int sz_pool, void* dev);
JRESULT jd_decomp (JDEC* jd, int (*outfunc)(JDEC*,void*,JRECT*), uint8_t scale);

const char* jresult_to_string(JRESULT result);

#ifdef __cplusplus
}
Expand Down
9 changes: 5 additions & 4 deletions st7789/st7789.c
Original file line number Diff line number Diff line change
Expand Up @@ -1667,12 +1667,13 @@ static mp_obj_t st7789_ST7789_jpg(size_t n_args, const mp_obj_t *args) {

JRESULT res; // Result code of TJpgDec API
JDEC jdec; // Decompression object
self->work = (void *)m_malloc(3100); // Pointer to the work area
self->work = (void *)m_malloc(8192); // Pointer to the work area
size_t bufsize;

if (input_func && (devid.fp || devid.data)) {
// Prepare to decompress
res = jd_prepare(&jdec, input_func, self->work, 3100, &devid);
res = jd_prepare(&jdec, input_func, self->work, 8192, &devid);
mp_printf(&mp_plat_print, "Result: %s\r\n", jresult_to_string(res));
if (res == JDR_OK) {
// Initialize output device
if (mode == JPG_MODE_FAST) {
Expand Down Expand Up @@ -1801,15 +1802,15 @@ static mp_obj_t st7789_ST7789_jpg_decode(size_t n_args, const mp_obj_t *args) {
height = mp_obj_get_int(args[5]);
}

self->work = (void *)m_malloc(3100); // Pointer to the work area
self->work = (void *)m_malloc(8192); // Pointer to the work area

JRESULT res; // Result code of TJpgDec API
JDEC jdec; // Decompression object
size_t bufsize = 0;

if (input_func && (devid.fp || devid.data)) {
// Prepare to decompress
res = jd_prepare(&jdec, input_func, self->work, 3100, &devid);
res = jd_prepare(&jdec, input_func, self->work, 8192, &devid);
if (res == JDR_OK) {
if (n_args < 6) {
x = 0;
Expand Down