Changeset 657 for trunk/user/display
- Timestamp:
- Mar 18, 2020, 11:16:59 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/display/display.c
r656 r657 15 15 #include <almosmkh.h> 16 16 17 #define FILENAME "misc/images_128.raw" 17 #define PATH_MAX_LENGHT 128 18 18 19 #define FBF_TYPE 420 19 20 #define NPIXELS 128 … … 56 57 } 57 58 } 59 58 60 //////////////// 59 61 int main( void ) … … 64 66 unsigned int fbf_type; 65 67 unsigned int nbytes; 66 unsigned int image = 0;67 68 int val; 68 69 int error; 69 70 unsigned long long start_cycle; 71 72 // get start cycle 73 get_cycle( &start_cycle ); 74 75 printf("\n[display] starts at cycle %d\n", (unsigned int)start_cycle ); 70 char pathname[PATH_MAX_LENGHT]; 76 71 77 72 // check frame buffer size … … 92 87 } 93 88 89 // get pathname for input file 90 while( 1 ) 91 { 92 printf("\n[display] path = "); 93 94 error = get_string( pathname , PATH_MAX_LENGHT ); 95 96 if ( error ) printf("\n[display error] cannot get path for input file\n" ); 97 else break; 98 } 99 94 100 // open file 101 int fd = open( pathname , O_RDONLY , 0 ); 95 102 96 FILE * f = fopen( FILENAME , NULL ); 97 // int fd = open( FILENAME, O_RDONLY , 0 ); 98 99 if( f == NULL ) 103 if( fd < 0 ) 100 104 { 101 printf("\n[display error] Cannot open file <%s>\n", FILENAME);105 printf("\n[display error] Cannot open file <%s>\n", pathname ); 102 106 exit( 0 ); 103 107 } 104 108 105 printf("\n[display] open file <%s>\n", FILENAME);109 printf("\n[display] open file <%s>\n", pathname ); 106 110 107 // loop on images 108 while ( 1 ) 111 // load buffer from file 112 nbytes = read( fd , buffer , NPIXELS * NLINES ); 113 114 if( nbytes != NPIXELS * NLINES ) 109 115 { 110 // load image from file 111 nbytes = fread( buffer , 1 , NPIXELS * NLINES , f ); 112 // nbytes = read( fd , buffer , NPIXELS * NLINES ); 113 if( nbytes != NPIXELS * NLINES ) 114 { 115 printf("\n[display error] Cannot load image %d\n", image ); 116 exit( 0 ); 117 } 118 119 printf("\n[display] load image %d in buffer %x\n", image, buffer ); 120 121 // display image 122 error = fbf_write( buffer , NPIXELS * NLINES , 0 ); 123 124 if( error ) 125 { 126 printf("\n[display error] Cannot access frame buffer\n"); 127 exit( 0 ); 128 } 129 130 printf("\n[display] display image %d\n", image ); 131 132 image++; 133 134 // interactive behaviour 135 val = getchar(); 116 printf("\n[display error] Cannot load image \n" ); 117 exit( 0 ); 136 118 } 137 119 120 printf("\n[display] load image in buffer %x\n", buffer ); 121 122 // display image 123 error = fbf_write( buffer , NPIXELS * NLINES , 0 ); 124 125 if( error ) 126 { 127 printf("\n[display error] Cannot access frame buffer\n"); 128 exit( 0 ); 129 } 130 131 printf("\n[display] display image\n"); 132 138 133 // close file 139 fclose( f ); 140 // close( fd ); 134 close( fd ); 141 135 142 136 exit(0);
Note: See TracChangeset
for help on using the changeset viewer.