Schupp

SPIFF LCD1

Dec 9th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.07 KB | None | 0 0
  1. #include "FS.h"
  2. #include "SPIFFS.h"
  3. //#include<SPIFlash.h>
  4. #define TRUE 1
  5. #define FALSE 0
  6. //SPIFlash flash(SS1, &SPI1);       //Use this constructor if using an SPI bus other than the default SPI. Only works with chips with more than one hardware SPI bus
  7. //SPIFlash flash(4,&SPI);
  8.  
  9. #define SPI2_NSS_PIN 28
  10.  
  11.  
  12.  
  13.  
  14. #include "SPI.h"
  15. #include <Adafruit_GFX.h>
  16. //#include <ILI9488.h>
  17. // Use hardware SPI (on Uno, #13, #12, #11) and the above for Enable,CS/DC,Reset
  18.  
  19.  
  20. void setup() {
  21.   unsigned long micross = micros();
  22.  
  23.  
  24.  // transparentImage(Startbyte Pic,Startbyte background,x,y, width, height, Transparency Color);
  25.   transparentImage(0,198900,0,0, 100, 100, 0xFFFFFF);
  26.  
  27.  
  28.   Serial.println((micros() - micross) / 1000);
  29. }
  30. int z = 0;
  31. int p = 0;
  32.  
  33. void loop() {
  34.  
  35. }
  36.  
  37. void transparentImage(uint32_t startpic, uint32_t startbackground, int x, int y, int width, int height, uint32_t tcolor) {
  38.   //read background clipping
  39.   File f = SPIFFS.open( "/pics.bin", "r");
  40.   char *buf = (char*)malloc(width * height * 3);
  41.   char *temp = (char*)malloc(width * 3);
  42.   // Serial.println("1");
  43.   unsigned long offset = 0;
  44.   for (int i; i < height; i++) {
  45.     unsigned long offset = startbackground + (x * width - (width - y) + (i * width * 3));
  46.     f.seek(offset, SeekSet);
  47.     f.readBytes((char*)temp, width * 3) ;
  48.     memcpy( buf + (i * width), temp, (width * 3) );
  49.   }
  50.   // Inhalt der Textdatei wird gelesen...
  51.   f.close();
  52.  
  53.     File fc = SPIFFS.open( "/pics.bin", "r");
  54.  
  55.   for (int i; i < height; i++) {
  56.     unsigned long offset = startpic+i*width;
  57.     fc.seek(offset, SeekSet);
  58.     fc.readBytes((char*)temp, width * 3) ;
  59.    for(int h=0;h<width*3;h=h+3)
  60.    {
  61. uint32_t b = temp[h];
  62.     b = (b<<8) | temp[h+1];
  63.     b = (b<<8) | temp[h+2];
  64. uint32_t bp = buf[width*i+h];
  65.     bp = (b<<8) |buf[width*i+h+1];
  66.     bp = (b<<8) |buf[width*i+h+2];
  67.     if(b!=bp){
  68.     buf[width*i+h]=temp[h];
  69.     buf[width*i+h+1]=temp[h+1];
  70.     buf[width*i+h+2]=temp[h+2];
  71.     }
  72.     //memcpy( buf + (i * width), temp, (width * 3) );
  73.   }
  74.   // Inhalt der Textdatei wird gelesen...
  75.   fc.close();
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment