1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#include <M5Stack.h> #include "bmp_header_8_QVGA.h" // TFT_eSprite img = TFT_eSprite(&M5.Lcd); uint8_t *_sprite_img8; // int SS_COUNT; char ss_name[32]; // void setup() { M5.begin(); img.setColorDepth(8); _sprite_img8=(uint8_t*)img.createSprite(320, 240); } // void loop(){ //Draw appropriately for the sprite. // //Press the A button to spit a screen shot. //(It is good to assign around the button unit) if(digitalRead(BUTTON_A_PIN) == 0) { sprintf(ss_name, "/bmp/ss%03d.bmp", SS_COUNT); Create_BMP_8(ss_name,(uint8_t *)_sprite_img8,320,240); SS_COUNT++; } } //Create BMP uint8_t CB_buffer[320],CB_temp_b[8]; //filename,bytedatapointer,xsize(1-320),ysize(1-x(240)) void Create_BMP_8(char* f_name,uint8_t * b_data,int xsize,int ysize){ //SD_FILE_OPEN File SD_FILE = SD.open(f_name,FILE_WRITE ); if(SD_FILE==-1)return; //Create Size Data CB_temp_b[0]=xsize&0xff;CB_temp_b[1]=(xsize>>8)&0xff;CB_temp_b[2]=(xsize>>16)&0xff;CB_temp_b[3]=xsize>>24; CB_temp_b[4+0]=ysize&0xff;CB_temp_b[4+1]=(ysize>>8)&0xff;CB_temp_b[4+2]=(ysize>>16)&0xff;CB_temp_b[4+3]=ysize>>24; //Header-head Write if(SD_FILE.write(bmp_header_8,0x12)==-1){SD_FILE.close();return;}; //Sizedata Write if(SD_FILE.write(CB_temp_b,0x8)==-1){SD_FILE.close();return;}; //Header-foot Write if(SD_FILE.write(bmp_header_8+0x1a,0x436-0x1a)==-1){SD_FILE.close();return;}; //Data Write for(int i=0;i<ysize;i++){ for(int j=0;j<xsize;j++)CB_buffer[j]=b_data[xsize*(ysize-1-i)+j]; if(SD_FILE.write(CB_buffer,xsize)==-1){SD_FILE.close();return;}; } //SD_FILE_CLOSE SD_FILE.close(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
//8bit QVGA 320*240 const uint8_t bmp_header_8[] PROGMEM = { 0x42,0x4d,0x36,0xe5,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x04,0x00,0x00,0x28,0x00, 0x00,0x00,0x40,0x01,0x00,0x00,0xf0,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0x00, 0x00,0x00,0x00,0xe1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x00,0x00,0x00,0xaa,0x00, 0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x55,0x24,0x00,0x00,0xaa,0x24, 0x00,0x00,0xff,0x24,0x00,0x00,0x00,0x48,0x00,0x00,0x55,0x48,0x00,0x00,0xaa,0x48, 0x00,0x00,0xff,0x48,0x00,0x00,0x00,0x6e,0x00,0x00,0x55,0x6e,0x00,0x00,0xaa,0x6e, 0x00,0x00,0xff,0x6e,0x00,0x00,0x00,0x92,0x00,0x00,0x55,0x92,0x00,0x00,0xaa,0x92, 0x00,0x00,0xff,0x92,0x00,0x00,0x00,0xb6,0x00,0x00,0x55,0xb6,0x00,0x00,0xaa,0xb6, 0x00,0x00,0xff,0xb6,0x00,0x00,0x00,0xdb,0x00,0x00,0x55,0xdb,0x00,0x00,0xaa,0xdb, 0x00,0x00,0xff,0xdb,0x00,0x00,0x00,0xff,0x00,0x00,0x55,0xff,0x00,0x00,0xaa,0xff, 0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x24,0x00,0x55,0x00,0x24,0x00,0xaa,0x00, 0x24,0x00,0xff,0x00,0x24,0x00,0x00,0x24,0x24,0x00,0x55,0x24,0x24,0x00,0xaa,0x24, 0x24,0x00,0xff,0x24,0x24,0x00,0x00,0x48,0x24,0x00,0x55,0x48,0x24,0x00,0xaa,0x48, 0x24,0x00,0xff,0x48,0x24,0x00,0x00,0x6e,0x24,0x00,0x55,0x6e,0x24,0x00,0xaa,0x6e, 0x24,0x00,0xff,0x6e,0x24,0x00,0x00,0x92,0x24,0x00,0x55,0x92,0x24,0x00,0xaa,0x92, 0x24,0x00,0xff,0x92,0x24,0x00,0x00,0xb6,0x24,0x00,0x55,0xb6,0x24,0x00,0xaa,0xb6, 0x24,0x00,0xff,0xb6,0x24,0x00,0x00,0xdb,0x24,0x00,0x55,0xdb,0x24,0x00,0xaa,0xdb, 0x24,0x00,0xff,0xdb,0x24,0x00,0x00,0xff,0x24,0x00,0x55,0xff,0x24,0x00,0xaa,0xff, 0x24,0x00,0xff,0xff,0x24,0x00,0x00,0x00,0x48,0x00,0x55,0x00,0x48,0x00,0xaa,0x00, 0x48,0x00,0xff,0x00,0x48,0x00,0x00,0x24,0x48,0x00,0x55,0x24,0x48,0x00,0xaa,0x24, 0x48,0x00,0xff,0x24,0x48,0x00,0x00,0x48,0x48,0x00,0x55,0x48,0x48,0x00,0xaa,0x48, 0x48,0x00,0xff,0x48,0x48,0x00,0x00,0x6e,0x48,0x00,0x55,0x6e,0x48,0x00,0xaa,0x6e, 0x48,0x00,0xff,0x6e,0x48,0x00,0x00,0x92,0x48,0x00,0x55,0x92,0x48,0x00,0xaa,0x92, 0x48,0x00,0xff,0x92,0x48,0x00,0x00,0xb6,0x48,0x00,0x55,0xb6,0x48,0x00,0xaa,0xb6, 0x48,0x00,0xff,0xb6,0x48,0x00,0x00,0xdb,0x48,0x00,0x55,0xdb,0x48,0x00,0xaa,0xdb, 0x48,0x00,0xff,0xdb,0x48,0x00,0x00,0xff,0x48,0x00,0x55,0xff,0x48,0x00,0xaa,0xff, 0x48,0x00,0xff,0xff,0x48,0x00,0x00,0x00,0x6e,0x00,0x55,0x00,0x6e,0x00,0xaa,0x00, 0x6e,0x00,0xff,0x00,0x6e,0x00,0x00,0x24,0x6e,0x00,0x55,0x24,0x6e,0x00,0xaa,0x24, 0x6e,0x00,0xff,0x24,0x6e,0x00,0x00,0x48,0x6e,0x00,0x55,0x48,0x6e,0x00,0xaa,0x48, 0x6e,0x00,0xff,0x48,0x6e,0x00,0x00,0x6e,0x6e,0x00,0x55,0x6e,0x6e,0x00,0xaa,0x6e, 0x6e,0x00,0xff,0x6e,0x6e,0x00,0x00,0x92,0x6e,0x00,0x55,0x92,0x6e,0x00,0xaa,0x92, 0x6e,0x00,0xff,0x92,0x6e,0x00,0x00,0xb6,0x6e,0x00,0x55,0xb6,0x6e,0x00,0xaa,0xb6, 0x6e,0x00,0xff,0xb6,0x6e,0x00,0x00,0xdb,0x6e,0x00,0x55,0xdb,0x6e,0x00,0xaa,0xdb, 0x6e,0x00,0xff,0xdb,0x6e,0x00,0x00,0xff,0x6e,0x00,0x55,0xff,0x6e,0x00,0xaa,0xff, 0x6e,0x00,0xff,0xff,0x6e,0x00,0x00,0x00,0x92,0x00,0x55,0x00,0x92,0x00,0xaa,0x00, 0x92,0x00,0xff,0x00,0x92,0x00,0x00,0x24,0x92,0x00,0x55,0x24,0x92,0x00,0xaa,0x24, 0x92,0x00,0xff,0x24,0x92,0x00,0x00,0x48,0x92,0x00,0x55,0x48,0x92,0x00,0xaa,0x48, 0x92,0x00,0xff,0x48,0x92,0x00,0x00,0x6e,0x92,0x00,0x55,0x6e,0x92,0x00,0xaa,0x6e, 0x92,0x00,0xff,0x6e,0x92,0x00,0x00,0x92,0x92,0x00,0x55,0x92,0x92,0x00,0xaa,0x92, 0x92,0x00,0xff,0x92,0x92,0x00,0x00,0xb6,0x92,0x00,0x55,0xb6,0x92,0x00,0xaa,0xb6, 0x92,0x00,0xff,0xb6,0x92,0x00,0x00,0xdb,0x92,0x00,0x55,0xdb,0x92,0x00,0xaa,0xdb, 0x92,0x00,0xff,0xdb,0x92,0x00,0x00,0xff,0x92,0x00,0x55,0xff,0x92,0x00,0xaa,0xff, 0x92,0x00,0xff,0xff,0x92,0x00,0x00,0x00,0xb6,0x00,0x55,0x00,0xb6,0x00,0xaa,0x00, 0xb6,0x00,0xff,0x00,0xb6,0x00,0x00,0x24,0xb6,0x00,0x55,0x24,0xb6,0x00,0xaa,0x24, 0xb6,0x00,0xff,0x24,0xb6,0x00,0x00,0x48,0xb6,0x00,0x55,0x48,0xb6,0x00,0xaa,0x48, 0xb6,0x00,0xff,0x48,0xb6,0x00,0x00,0x6e,0xb6,0x00,0x55,0x6e,0xb6,0x00,0xaa,0x6e, 0xb6,0x00,0xff,0x6e,0xb6,0x00,0x00,0x92,0xb6,0x00,0x55,0x92,0xb6,0x00,0xaa,0x92, 0xb6,0x00,0xff,0x92,0xb6,0x00,0x00,0xb6,0xb6,0x00,0x55,0xb6,0xb6,0x00,0xaa,0xb6, 0xb6,0x00,0xff,0xb6,0xb6,0x00,0x00,0xdb,0xb6,0x00,0x55,0xdb,0xb6,0x00,0xaa,0xdb, 0xb6,0x00,0xff,0xdb,0xb6,0x00,0x00,0xff,0xb6,0x00,0x55,0xff,0xb6,0x00,0xaa,0xff, 0xb6,0x00,0xff,0xff,0xb6,0x00,0x00,0x00,0xdb,0x00,0x55,0x00,0xdb,0x00,0xaa,0x00, 0xdb,0x00,0xff,0x00,0xdb,0x00,0x00,0x24,0xdb,0x00,0x55,0x24,0xdb,0x00,0xaa,0x24, 0xdb,0x00,0xff,0x24,0xdb,0x00,0x00,0x48,0xdb,0x00,0x55,0x48,0xdb,0x00,0xaa,0x48, 0xdb,0x00,0xff,0x48,0xdb,0x00,0x00,0x6e,0xdb,0x00,0x55,0x6e,0xdb,0x00,0xaa,0x6e, 0xdb,0x00,0xff,0x6e,0xdb,0x00,0x00,0x92,0xdb,0x00,0x55,0x92,0xdb,0x00,0xaa,0x92, 0xdb,0x00,0xff,0x92,0xdb,0x00,0x00,0xb6,0xdb,0x00,0x55,0xb6,0xdb,0x00,0xaa,0xb6, 0xdb,0x00,0xff,0xb6,0xdb,0x00,0x00,0xdb,0xdb,0x00,0x55,0xdb,0xdb,0x00,0xaa,0xdb, 0xdb,0x00,0xff,0xdb,0xdb,0x00,0x00,0xff,0xdb,0x00,0x55,0xff,0xdb,0x00,0xaa,0xff, 0xdb,0x00,0xff,0xff,0xdb,0x00,0x00,0x00,0xff,0x00,0x55,0x00,0xff,0x00,0xaa,0x00, 0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x24,0xff,0x00,0x55,0x24,0xff,0x00,0xaa,0x24, 0xff,0x00,0xff,0x24,0xff,0x00,0x00,0x48,0xff,0x00,0x55,0x48,0xff,0x00,0xaa,0x48, 0xff,0x00,0xff,0x48,0xff,0x00,0x00,0x6e,0xff,0x00,0x55,0x6e,0xff,0x00,0xaa,0x6e, 0xff,0x00,0xff,0x6e,0xff,0x00,0x00,0x92,0xff,0x00,0x55,0x92,0xff,0x00,0xaa,0x92, 0xff,0x00,0xff,0x92,0xff,0x00,0x00,0xb6,0xff,0x00,0x55,0xb6,0xff,0x00,0xaa,0xb6, 0xff,0x00,0xff,0xb6,0xff,0x00,0x00,0xdb,0xff,0x00,0x55,0xdb,0xff,0x00,0xaa,0xdb, 0xff,0x00,0xff,0xdb,0xff,0x00,0x00,0xff,0xff,0x00,0x55,0xff,0xff,0x00,0xaa,0xff, 0xff,0x00,0xff,0xff,0xff,0x00 }; |