/* ------------------------------------------------------------------ * (c) schick Informatik 2017 * Hilfsprogramm, um Bilder aus einem Verzeichnis auf dem TFT CBerry * anzuzeigen. * ------------------------------------------------------------------ */ #include #include #include #include #include #include #include #include #include #include #include "tft.h" #include "ST7789.h" #include "bmp.h" #include "examples.h" #ifdef CM_262K uint32_t** imageList; #else uint16_t** imageList; #endif #define INTERVAL 15 int MAXCNT = 256; int numImages = 0; int main( int argc, char **argv ) { if(argc < 2) { printf("Usage: bildercycle \n"); return 1; } char *sourcePath = argv[1]; #ifdef CM_262K imageList = calloc(MAXCNT, sizeof(uint32_t*)); #else imageList = calloc(MAXCNT, sizeof(uint16_t*)); #endif if(ReadFromDirectory(sourcePath)) { fprintf(stderr, "Error reading images from source path %s\n", sourcePath); return 1; } printf("%d images read\n", numImages); if (!bcm2835_init()) { fprintf(stderr, "Error initializing TFT (bcm2835_init)\n"); return 1; } TFT_init_board(); TFT_hard_reset(); STcontroller_init(); TFT_SetBacklightPWMValue( 20 ); // depict a BMP file // --------------------------------------------- //example_DepictBMP( &my_filename[0] ); int i; for(i=0;id_name, ".")) continue; if (!strcmp (in_file->d_name, "..")) continue; /* Open directory entry file for common operation */ /* TODO : change permissions to meet your need! */ char *bmpFileName = calloc(strlen(in_file->d_name) + strlen(in_dir) + 2, sizeof(char *)); sprintf(bmpFileName, "%s/%s", in_dir, in_file->d_name); // fprintf(stderr, "reading %s..\n", bmpFileName); #ifdef CM_262K imageList[numImages] = calloc(PICTURE_PIXELS, sizeof(uint32_t)); // Achtung Funktion liest von hinten nach vorn, daher den Bilderzeiger auf das letzte Pixel setzen result = Read_bmp2memory ( bmpFileName, &imageList[numImages][PICTURE_PIXELS - 1] ); #else imageList[numImages] = calloc(PICTURE_PIXELS, sizeof(uint16_t)); result = Read_bmp2memory ( bmpFileName, &imageList[numImages][PICTURE_PIXELS - 1] ); #endif if(result) { fprintf(stderr,"reading BMP %s failed\n", in_file->d_name); } else { result = 0; // at least one! successful numImages++; } /* entry_file = fopen(in_file->d_name, "r"); if (entry_file == NULL) { fprintf(stderr, "Error : Failed to open entry file - %s\n", strerror(errno)); fclose(common_file); return 1; } */ } return result; }