//board STM32F103C9T6 (64Kb**(64Kb you should beliefe but STM building in 128KB and sellers dont tell)** 72Mhz) || tft: ILI9341 (240x320pixel 2,8" COLOR LCD SPI) || testprogramm uses Adafruit library have fun =^.^= marderchen //pins TFT ::VCC on 3.3V ::LED on 5V (with 94 Ohm resistor) ::GND on GND :: CS on A0 :: Reset on A1 :: DC/RS on A2 :: SCK on A5 :: MISO on A6 :: MOSI on A7 //pins touch T_clk = PB13 | T_cs = PA8 | T_din = MOSI = PB15 | T_D0 = PB13 | T_IRQ = PB12 #include "SPI.h" #include "Adafruit_GFX_AS.h" #include "Adafruit_ILI9341_STM.h" #include "XPT2046_touch.h" #include #define TFT_CS PA0 #define TFT_DC PA2 #define TFT_RST PA1 #define swap(a, b) { int16_t t = a; a = b; b = t; } #define screeny 9 Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC, TFT_RST); // Use hardware SPI #define CS_PIN PA8 // Chip Select pin #define UPDATES_PER_SECOND 5000 SPIClass mySPI(2); //Create an SPI instance on SPI1 port. XPT2046_touch ts(CS_PIN, mySPI); // Chip Select pin, SPI port its not the chip from touchmodule but working fine uint16_t xy[2]; //led #define LED_PIN PB8 #define BRIGHTNESS 255 #define LED_TYPE WS2812 #define COLOR_ORDER GRB CRGB leds[screeny]; CRGBPalette16 currentPalette; TBlendType currentBlending; #define UPDATES_PER_SECOND 5000 extern CRGBPalette16 myRedWhiteBluePalette; #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF int rainbows [] ={0xF800,0xF81F,0x001F,0x07FF,0x07E0,0xFFE0}; const unsigned char PROGMEM cat [] = { 0xF8, 0x00, 0x00, 0x78, // ##### #### 0xCC, 0x00, 0x01, 0xBC, // ## ## ## #### 0xB3, 0x00, 0x06, 0x24, // # ## ## ## # # 0x99, 0x80, 0x0C, 0xC4, // # ## ## ## ## # 0x8C, 0xC0, 0x31, 0x84, // # ## ## ## ## # 0x84, 0x60, 0x21, 0x04, // # # ## # # # 0x84, 0x20, 0x02, 0x08, // # # # # # 0x84, 0x00, 0x02, 0x08, // # # # # 0x80, 0x00, 0x00, 0x18, // # ## 0xC3, 0x80, 0x0C, 0x10, // ## ### ## # 0x44, 0x40, 0x12, 0x10, // # # # # # # 0x4C, 0x40, 0x31, 0x20, // # ## # ## # # 0x08, 0x60, 0x21, 0x20, // # ## # # # 0x08, 0x20, 0x41, 0x00, // # # # # 0x08, 0x20, 0x41, 0x00, // # # # # 0x00, 0x00, 0x00, 0x00, // 0x00, 0x00, 0x00, 0x00, // 0x07, 0x06, 0x00, 0x00, // ### ## 0x18, 0xCF, 0x0F, 0x80, // ## ## #### ##### 0x61, 0xE6, 0x3C, 0x60, // ## #### ## #### ## 0x86, 0x12, 0x43, 0x10, // # ## # # # ## # 0x18, 0x00, 0x00, 0x80, // ## # 0x20, 0x40, 0x20, 0x40, // # # # # 0x00, 0x84, 0x10, 0x00, // # # # 0x00, 0x8E, 0x20, 0x00, // # ### # 0x00, 0x71, 0xC0, 0x00, // ### ### }; const unsigned char PROGMEM cat2 [] = { 0x3E, 0x00, 0x01, 0xA0, // ##### ## # 0x72, 0x00, 0x02, 0x14, // ### # # # # 0x41, 0x80, 0x0C, 0xC4, // # ## ## ## # 0x4C, 0xC0, 0x11, 0x84, // # ## ## # ## # 0xC4, 0x40, 0x21, 0x04, // ## # # # # # 0x84, 0x20, 0x02, 0x04, // # # # # # 0x84, 0x00, 0x00, 0x04, // # # # 0x83, 0xC0, 0x02, 0x0C, // # #### # ## 0x87, 0xE0, 0x1E, 0x08, // # ###### #### # 0x45, 0xC0, 0x3E, 0x18, // # # ### ##### ## 0x4D, 0xC0, 0x3F, 0x10, // # ## ### ###### # 0x08, 0xA0, 0x27, 0x10, // # # # # ### # 0x00, 0x20, 0x61, 0x30, // # ## # ## 0x0F, 0xC0, 0x71, 0x00, // ###### ### # 0x08, 0x20, 0x1F, 0x00, // # # ##### 0x00, 0x00, 0x03, 0x00, // ## 0x00, 0x06, 0x00, 0x00, // ## 0x15, 0x0F, 0x05, 0x80, // # # # #### # ## 0x60, 0xE7, 0x38, 0x60, // ## ### ### ### ## 0x43, 0x02, 0x42, 0x00, // # ## # # # 0x48, 0x00, 0x00, 0x80, // # # # 0x98, 0x60, 0x60, 0x40, // # ## ## ## # 0x10, 0xC4, 0x30, 0x00, // # ## # ## 0x20, 0x8E, 0x30, 0x00, // # # ### ## 0x00, 0xFB, 0xE0, 0x00, // ##### ##### }; const unsigned char PROGMEM cat3 [] = { 0x1F, 0x00, 0x01, 0xF4, // ##### ##### # 0x36, 0xE0, 0x05, 0x3C, // ## ## ### # # #### 0x23, 0x20, 0x00, 0x64, // # ## # ## # 0x40, 0x98, 0x00, 0x44, // # # ## # # 0x40, 0x48, 0x01, 0x80, // # # # ## 0x40, 0x00, 0x00, 0x04, // # # 0x43, 0xE0, 0x0A, 0x04, // # ##### # # # 0x43, 0xF0, 0x1E, 0x04, // # ###### #### # 0x4E, 0xF0, 0x39, 0x84, // # ### #### ### ## # 0x4B, 0xE0, 0x37, 0x80, // # # ##### ## #### 0x05, 0xF0, 0x2F, 0x8C, // # ##### # ##### ## 0x0F, 0xD0, 0x3B, 0x80, // ###### # ### ### 0x08, 0xF0, 0x27, 0x90, // # #### # #### # 0x08, 0x00, 0x20, 0xA0, // # # # # 0x07, 0xE0, 0x3B, 0x80, // ###### ### ### 0x07, 0x04, 0x00, 0x00, // ### # 0x00, 0x06, 0x00, 0x00, // ## 0x1B, 0x0F, 0x8F, 0x80, // ## ## ##### ##### 0x60, 0xA7, 0x34, 0x60, // ## # # ### ## # ## 0x45, 0x00, 0x03, 0x10, // # # # ## # 0x48, 0x02, 0x00, 0x80, // # # # # 0x98, 0x10, 0x40, 0x40, // # ## # # # 0x10, 0x17, 0x40, 0x00, // # # ### # 0x00, 0x1D, 0xC0, 0x00, // ### ### }; const unsigned char PROGMEM star1 [] = // +5,5, 1,1 { 0x80, // # }; const unsigned char PROGMEM star2 [] = //+4,2,3,3 { 0x40, // # 0xA0, // # # 0x40, // # }; const unsigned char PROGMEM star3 [] = //4,4,3,3 { 0xE0, // ### 0xE0, // ### 0xE0, // ### }; const unsigned char PROGMEM star4 [] = //3,3,5,5 { 0x20, // # 0x00, // 0x88, // # # 0x00, // 0x20, // # }; const unsigned char PROGMEM star5 [] = //2,2,7,7 { 0x10, // # 0x10, // # 0x00, // 0xD6, // ## # ## 0x00, // 0x10, // # 0x10, // # }; const unsigned char PROGMEM star6 [] = //2,2,7,7 { 0x44, // # # 0xC6, // ## ## 0x18, // ## 0x30, // ## 0x20, // # 0xC6, // ## ## 0x44, // # # }; const unsigned char PROGMEM star7 [] = //1,1,9,9 { 0x08, 0x00, // # 0x08, 0x00, // # 0x22, 0x00, // # # 0x1C, 0x00, // ### 0xD3, 0x80, // ## # ### 0x14, 0x00, // # # 0x2A, 0x00, // # # # 0x08, 0x00, // # 0x08, 0x00, // # }; const unsigned char PROGMEM star8 [] = //1,1,10,10 { 0x1C, 0x00, // ### 0x08, 0x00, // # 0x08, 0x00, // # 0x80, 0x80, // # # 0xE9, 0xC0, // ### # ### 0x80, 0x80, // # # 0x00, 0x00, // 0x08, 0x00, // # 0x1C, 0x00, // ### 0x08, 0x00, // # }; const unsigned char PROGMEM star9 [] = //+2,2,7,7 s { 0x10, // # 0x44, // # # 0x00, // 0x82, // # # 0x00, // 0x44, // # # 0x10, // # }; const unsigned char PROGMEM star10 [] = //1,1,10,10 { 0x08, 0x00, // # 0x2A, 0x00, // # # # 0x63, 0x00, // ## ## 0x00, 0x00, // 0xC1, 0x80, // ## ## 0x00, 0x00, // 0x63, 0x00, // ## ## 0x2A, 0x00, // # # # 0x08, 0x00, // # }; const unsigned char PROGMEM star11 [] = // 11,11 { 0x04, 0x00, // # 0x04, 0x00, // # 0x00, 0x00, // 0x00, 0x00, // 0x00, 0x00, // 0xC1, 0x60, // ## # ## 0x00, 0x00, // 0x04, 0x00, // # 0x00, 0x00, // 0x04, 0x00, // # 0x04, 0x00, // # }; #define NUMFLAKES3 140 #define NUMFLAKES4 140 #define NUMFLAKES5 120 //anizeugs int nyans1 =2; int cats33 =5; int nyansc1 =0; int nyanc1 =0; int nyanc2 =0; int nyanc3 =0; int nyand1 =0; int nyand2 =0; int cats2 =70; int stary1 = 7; int stary2 = 0; int starc1 = 0; int stars1 = 40; int stars1b = 40; int starposy =0; int starposx =100; int star2posy =0; int star2posx =100; long color =0; long colorc =0; int g = 0; int f1 = 0; uint8_t starys[NUMFLAKES5][52]; uint8_t starys2[NUMFLAKES5][52]; int rgb [] ={0xFF0000,0xFFFF00,0x00FFFF,0x0000FF,0xFF00FF}; int rgb2 [] ={ 16711680,16776960, 4095, 255,16711935}; int rgb3 [] ={0x000000,0xF8E000,0x08FCF8,0x001CF8,0x001CF8}; int ttt[3] ; //------------------- long colorcounta1 =0; long colorcounta2 =1000; //ende anizeugs int schneezahl =4096; int schneezahl2 =0; int menge =20; int speedy =0; int achsex =0; int achsey =0; int colorcountv2 =0; void setup() { FastLED.addLeds(leds, screeny).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); currentPalette = RainbowColors_p; currentBlending = BLEND; tft.begin(); ts.begin(); tft.fillScreen(ILI9341_BLACK); tft.setRotation(1); for (uint8_t g=0; g< stars1; g++) { starys[g][starposy] =100;// random(45,90) ; starys[g][starposx] =random(0,320); starys2[g][starposy] =100;// random(45,90) ; starys2[g][starposx] =random(10,320); } delay( 3000 ); } void loop() { zeigmal(); WS2812rainbow(); } int tspedy =0; int rhc =45; int rwc =210; int blacky =0; void zeigmal(void) { blacky++; //tft._rest; if (blacky >1) { blacky=0;} tft.fillScreen(ILI9341_BLACK); speedy =random(3,12); if (speedy >= 62) {speedy=0;} colorcounta1++; if (colorcounta1 >= 6) { colorcounta1 =0;} tft.setTextSize(1); tft.setCursor(0,0); tft.setTextColor(rainbows[colorcounta1]); tft.println("MEOW TOUCH-screen test by marderchen"); /* cattz++; colorcount3 +=20; if (cattz == 1) {tft.drawBitmap(102,50, cat,30, 26, colorcount3);} if (cattz == 2) {tft.drawBitmap(102,50+1, cat2,30, 25, colorcount3);} if (cattz == 3) {tft.drawBitmap(102,50+2, cat3,30, 24, colorcount3);} if (cattz == 4) {tft.drawBitmap(102,50+1, cat2,30, 25, colorcount3);} if (cattz == 5) {cattz = 0;} if (colorcount3 >= 65535) {colorcount3=1;} */ ts.read_XY(xy); //if before if only should sett on touching tft.drawRect(ttt[0]-20,ttt[1]-20,40,40,rainbows[colorcounta1]); tft.setTextSize(4); tft.setCursor(0,170); tft.println(xy[1]/11-15); tft.println(xy[0]/15-10); ttt[0] = xy[1]/11-15; ttt[1] = xy[0]/15-10; drawMLine(0, 0, ttt[0], ttt[1], rainbows[colorcounta1]); //coil drawMLine(320, 240, ttt[0], ttt[1], rainbows[colorcounta1]); //coil drawMLine(320, 0, ttt[0], ttt[1], rainbows[colorcounta1]); //coil drawMLine(0, 240, ttt[0], ttt[1], rainbows[colorcounta1]); //coil if (schneezahl2 ==1) { for (uint8_t x1=0; x1< random(15,40); x1++) { for (uint8_t q1=0; q1< menge; q1++) { achsex =random(0,320); if ((achsex % 2) == 0 && (achsey % 2) ==0) { tft.drawPixel(achsex, achsey, rainbows[colorcounta2]); } if ((achsex % 2) == 1 && (achsey % 2) ==1) { tft.drawPixel(achsex, achsey, rainbows[colorcounta2]); } } achsey++; if (achsey >= 240) {achsey = 0;}} } if (schneezahl2 ==2) { for (uint8_t x1=0; x1< random(10,20); x1++) { for (uint8_t q1=0; q1< menge; q1++) { achsex =random(0,320); if ((achsex % 2) == 1 && (achsey % 2) ==0) { tft.drawPixel(achsex, achsey, rainbows[colorcounta2]); } if ((achsex % 2) == 1 && (achsey % 2) ==1) { tft.drawPixel(achsex, achsey, rainbows[colorcounta2]); colorcounta2++; } if (colorcounta2 >= 6) {colorcounta2=0;} } achsey++; if (achsey >= 240) {achsey = 0;}} } schneezahl2++; if (schneezahl2>= 3) {schneezahl2 = 1;} // menge1++; menge = random(30,55); for (uint8_t g=0; g< stars1; g++) { starc1++; starys[g][starposy] *= 0.97; starys[g][starposy] -= random(1,3); if (starys[g][starposy] < 10) { starys[g][starposy] =random(240.250);//(45,80) ; starys[g][starposx] =random(0,320); } if (starc1 == 1) { tft.drawBitmap((starys2[g][star2posx]) +5, (starys2[g][star2posy]) +5, star1,1, 1, (long) random(65535)); } if (starc1 == 2) { tft.drawBitmap((starys2[g][star2posx]) +4, (starys2[g][star2posy]) +4, star2,3, 3, (long) random(65535)); } if (starc1 == 3) { tft.drawBitmap((starys2[g][star2posx]) +4, (starys2[g][star2posy]) +4, star3,3, 3, (long) random(65535)); } if (starc1 == 4) { tft.drawBitmap((starys2[g][star2posx]) +3, (starys2[g][star2posy]) +3, star4,5, 5, (long) random(65535)); } if (starc1 == 5) { tft.drawBitmap((starys2[g][star2posx]) +2, (starys2[g][star2posy]) +2, star5,7, 7, (long) random(65535)); } if (starc1 == 6) { tft.drawBitmap((starys2[g][star2posx]) +2, (starys2[g][star2posy]) +2, star6,7, 7, (long) random(65535)); } if (starc1 == 7) { tft.drawBitmap((starys2[g][star2posx]) +1, (starys2[g][star2posy]) +1, star7,9, 9, (long) random(65535)); } if (starc1 == 8) { tft.drawBitmap((starys2[g][star2posx]) +1, (starys2[g][star2posy]) +1, star8,10, 10, (long) random(65535)); } if (starc1 == 9) { tft.drawBitmap((starys2[g][star2posx]) +2, (starys2[g][star2posy]) +2, star9,7, 7, (long) random(65535)); } if (starc1 == 10) { tft.drawBitmap((starys2[g][star2posx]) +1, (starys2[g][star2posy]) +1, star10,10, 10, (long) random(65535)); } if (starc1 == 11) { tft.drawBitmap((starys2[g][star2posx]), (starys2[g][star2posy]), star11,11, 11, (long) random(65535)); } if (starc1 == 12) { starc1 = 0; } starys2[g][star2posy] *= 0.96; starys2[g][star2posy] -= random(0,6); if (starys2[g][star2posy] < 10) { starys[g][starposy] =random(240.250);//(45,80) ; starys[g][starposx] =random(0,320); } }} int rgbdlm =0; int x10=0; int rgbc=0; long leinmovcolor =0; int wenig=0; void drawMLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) { int16_t steep = abs(y1 - y0) > abs(x1 - x0); if (steep) { swap(x0, y0); swap(x1, y1); } if (x0 > x1) { swap(x0, x1); swap(y0, y1); } int16_t dx, dy; dx = x1 - x0; dy = abs(y1 - y0); x10=x0; int16_t err = dx / 2; int16_t err2 = dx / 2; int y10 =y0; int16_t ystep; if (y0 < y1) { ystep = 1; } else { ystep = -1; } for (; x0<=x1; x0++) { leinmovcolor +=random(29,31); //leinmovcolor +=prozi *1; if (leinmovcolor >= 16711935) { leinmovcolor =0;} if (steep) { tft.drawPixel(y0, x0, leinmovcolor); } else { tft.drawPixel(x0, y0, leinmovcolor); } err -= dy; if (err < 0) { y0 += ystep; err += dx; } } for (; x10<=x1; x10++) { // if (x10 % random(5,10)==1){ rgbc +=1; //leinmovcolor +=prozi *1; if (rgbc >= 6) {rgbc =0;} wenig += random(0,50); if (wenig > 50) { if (steep) { tft.drawPixel(y10 +random(-3,3), x10+random(-3,5), rainbows[rgbc]); } else { tft.drawPixel(x10+random(-3,3), y10+random(-3,3), rainbows[rgbc]); } err2 -= dy; if (err2 < 0) { y10 += ystep; err2 += dx; } } } } void rainbowRect(int16_t x, int16_t y, int16_t w, int16_t h) { for (int16_t i=y; i=65535) { colorcountv2 =0;} } } int colorw =0; int colorIndex =0; void WS2812rainbow() { colorw +=1; if (colorw > 500) {colorw=0;} for( int iy = 0; iy < screeny; iy++) { colorIndex+=3; //leds[iy] = rainbow[round(colorw)]; leds[iy] = ColorFromPalette( currentPalette, colorIndex, 255, currentBlending); } FastLED.show(); FastLED.delay(1000 / 1000); } /* * MEOW! STM32F103C8T6 program for ILI9341 2.8" colorTFT with XPT2048 TOUCHscreen Module * by marderchen =^.^= working fine its just a testing programm *ITs free! ( copy parts or use it in any kind if its usefull for you ) * ___ * _.-| | / |\__/,| (`\ { | | -- |^ ^ |__ _) ) "-.|___| \ _.( Y ) ` / .--'-`-. _((_ `^--' /__< \ ....-+|______|__.-||__)`-' (((/ (((/ CATS are awesome! */