Prusa MINI Firmware overview
pngview.c File Reference
#include "main.h"
#include "display.h"
#include "ff.h"
#include "jogwheel.h"
#include "dbg.h"

Functions

int _f_fread (struct _reent *_r, void *pv, char *pc, int n)
 
int _f_fwrite (struct _reent *_r, void *pv, const char *pc, int n)
 
int _f_fclose (struct _reent *_r, void *pv)
 
_fpos_t _f_fseek (struct _reent *_r, void *pv, _fpos_t fpos, int ipos)
 
FILE * f_fopen (char *fn)
 
void f_fclose (FILE *pf)
 
void pngview (void)
 

Variables

char png_fnames [256][8]
 
int png_cnt = 0
 
FIL fil
 

Function Documentation

◆ _f_fread()

int _f_fread ( struct _reent *  _r,
void pv,
char *  pc,
int  n 
)
13  {
14  UINT br = 0;
15  f_read(&fil, pc, n, &br);
16  return br;
17 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _f_fwrite()

int _f_fwrite ( struct _reent *  _r,
void pv,
const char *  pc,
int  n 
)
19  {
20  return 0;
21 }
Here is the caller graph for this function:

◆ _f_fclose()

int _f_fclose ( struct _reent *  _r,
void pv 
)
23  {
24  return 0;
25 }
Here is the caller graph for this function:

◆ _f_fseek()

_fpos_t _f_fseek ( struct _reent *  _r,
void pv,
_fpos_t  fpos,
int  ipos 
)
27  {
28  return 0;
29 }
Here is the caller graph for this function:

◆ f_fopen()

FILE* f_fopen ( char *  fn)
31  {
32  f_open(&fil, fn, FA_READ);
33  FILE *pf = malloc(sizeof(FILE));
34  memset(pf, 0, sizeof(FILE));
35  pf->_read = _f_fread;
36  pf->_write = _f_fwrite;
37  pf->_close = _f_fclose;
38  pf->_seek = _f_fseek;
39  pf->_file = -1;
40  // pf->_flags = __SRD | __SNBF;
41  pf->_flags = __SRD;
42  pf->_lbfsize = 512;
43  pf->_bf._base = (uint8_t *)malloc(pf->_lbfsize);
44  pf->_bf._size = pf->_lbfsize;
45 
46  return pf;
47 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f_fclose()

void f_fclose ( FILE *  pf)
49  {
50  f_close(&fil);
51  if (pf != 0) {
52  if (pf->_bf._base != 0)
53  free(pf->_bf._base);
54  free(pf);
55  }
56 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pngview()

void pngview ( void  )
58  {
59  DIR dir;
60  FRESULT fres = f_opendir(&dir, "/");
61  if (fres == FR_OK) {
62  FILINFO info;
63  fres = f_findfirst(&dir, &info, "", "*.png");
64  while (fres == FR_OK) {
65  strncpy(png_fnames[png_cnt++], info.fname, 8);
66  fres = f_findnext(&dir, &info);
67  if (strncmp(png_fnames[png_cnt - 1], info.fname, 8) == 0) {
68  png_cnt--;
69  break; //hack because f_findnext returns allways FR_OK
70  }
71  }
72  }
73  f_closedir(&dir);
74  jogwheel_encoder_set(0, 0, png_cnt - 1);
75  int old_encoder = -1;
76  while (png_cnt > 0) {
77  if (jogwheel_encoder != old_encoder) {
78  old_encoder = jogwheel_encoder;
79  char fn[16] = "/";
80  _dbg("%d\n", jogwheel_encoder);
81  strncpy(fn + 1, png_fnames[jogwheel_encoder], 8);
82  strcat(fn, ".PNG");
83  _dbg("%s\n", fn);
84  FILE *pf = f_fopen(fn);
85  display->draw_png(point_ui16(0, 0), pf);
86  f_fclose(pf);
87  } else
88  osDelay(1);
89  if (jogwheel_button_down >= 1000)
90  break;
91  }
92 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ png_fnames

char png_fnames[256][8]

◆ png_cnt

int png_cnt = 0

◆ fil

FIL fil
png_cnt
int png_cnt
Definition: pngview.c:10
f_open
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
Definition: ff.c:3296
_f_fread
int _f_fread(struct _reent *_r, void *pv, char *pc, int n)
Definition: pngview.c:13
fil
FIL fil
Definition: pngview.c:11
_f_fseek
_fpos_t _f_fseek(struct _reent *_r, void *pv, _fpos_t fpos, int ipos)
Definition: pngview.c:27
_f_fclose
int _f_fclose(struct _reent *_r, void *pv)
Definition: pngview.c:23
osDelay
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
jogwheel_encoder_set
void jogwheel_encoder_set(int32_t val, int32_t min, int32_t max)
Definition: jogwheel.c:83
jogwheel_encoder
int32_t jogwheel_encoder
Definition: jogwheel.c:10
FA_READ
#define FA_READ
Definition: ff.h:326
f_fopen
FILE * f_fopen(char *fn)
Definition: pngview.c:31
f_opendir
FRESULT f_opendir(DIR *dp, const TCHAR *path)
Definition: ff.c:4221
_display_t::draw_png
display_draw_png_t * draw_png
Definition: display.h:37
jogwheel_button_down
uint16_t jogwheel_button_down
Definition: jogwheel.c:13
_f_fwrite
int _f_fwrite(struct _reent *_r, void *pv, const char *pc, int n)
Definition: pngview.c:19
f_fclose
void f_fclose(FILE *pf)
Definition: pngview.c:49
uint8_t
const uint8_t[]
Definition: 404_html.c:3
_dbg
#define _dbg(...)
Definition: dbg.h:50
display
display_t * display
Definition: display.c:6
FRESULT
FRESULT
Definition: ff.h:214
f_findnext
FRESULT f_findnext(DIR *dp, FILINFO *fno)
png_fnames
char png_fnames[256][8]
Definition: pngview.c:9
FR_OK
Definition: ff.h:215
DIR
Definition: ff.h:178
f_closedir
FRESULT f_closedir(DIR *dp)
Definition: ff.c:4291
f_findfirst
FRESULT f_findfirst(DIR *dp, FILINFO *fno, const TCHAR *path, const TCHAR *pattern)
FILINFO
Definition: ff.h:197
UINT
unsigned int UINT
Definition: onboard_sd.h:16
f_read
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
Definition: ff.c:3499
f_close
FRESULT f_close(FIL *fp)
Definition: ff.c:3801
point_ui16
static point_ui16_t point_ui16(uint16_t x, uint16_t y)
Definition: guitypes.h:154
info
uint8_t info[12]
Definition: masstorage.h:54