From 38d90de7b3ec44fe6e674fb334959ad48d600b68 Mon Sep 17 00:00:00 2001 From: hybris Date: Fri, 18 Aug 2023 00:03:31 +0200 Subject: [PATCH] initial commit --- data/matrix2.html | 624 +++++++++++ fonts.h | 1234 +++++++++++++++++++++ matrix_websocket_2023_18x18_udponly.ino | 1351 +++++++++++++++++++++++ tetris.h | 532 +++++++++ 4 files changed, 3741 insertions(+) create mode 100644 data/matrix2.html create mode 100644 fonts.h create mode 100644 matrix_websocket_2023_18x18_udponly.ino create mode 100644 tetris.h diff --git a/data/matrix2.html b/data/matrix2.html new file mode 100644 index 0000000..be434ff --- /dev/null +++ b/data/matrix2.html @@ -0,0 +1,624 @@ + + + + + + + + + +
+ Matrix Output +
+
+
+
+ Video Input & Controls +
+
+
+
+ +
+
🔊
+ + +
+
+ +
+
+
+
+ Channel Saturation + + + +
+
+ Contrast + +
+
+ Zoom + +
+
+ Offset + + +
+ + +
+
+ + diff --git a/fonts.h b/fonts.h new file mode 100644 index 0000000..aaf9161 --- /dev/null +++ b/fonts.h @@ -0,0 +1,1234 @@ +/* FONT */ + +bool font[85][12][8] = { + // a + { + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 1, 1, 1, 1, 0, 0, 0 }, + { 1, 1, 1, 1, 1, 0, 0, 0 }, + { 1, 1, 0, 1, 1, 0, 0, 0 }, + { 1, 1, 0, 1, 1, 0, 0, 0 }, + { 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 0, 0, 0 } + }, + // b + { + { 1, 1, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1, 1, 0, 0, 0, 0 }, + { 1, 1, 1, 1, 1, 0, 0, 0 }, + { 1, 1, 0, 1, 1,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 0, 0, 0 }, + { 0, 1, 1, 0, 0, 0, 0, 0 } + }, + // K + { + { 1, 1, 0, 1, 1, 0, 0, 0 }, + { 1, 1, 0, 1, 1, 0, 0, 0 }, + { 1, 1, 0, 1, 1, 0, 0, 0 }, + { 1, 1, 1, 1, 0, 0, 0, 0 }, + { 1, 1, 1, 1, 1, 0, 0, 0 }, + { 1, 1, 0, 1, 1, 0, 0, 0 }, + { 1, 1, 0, 1, 1, 0, 0, 0 }, + { 1, 1, 0, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 0, 0, 0 } + }, + // L + { + { 1, 1, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1, 1, 1, 0, 0, 0 }, + { 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 0, 0, 0 } + }, + // M + { + { 1, 1, 1, 1, 1, 1, 1, 0 }, + { 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 0, 1, 1, 0, 1, 1 }, + { 1, 1, 0, 1, 1, 0, 1, 1 }, + { 1, 1, 0, 1, 1, 0, 1, 1 }, + { 1, 1, 0, 1, 1, 0, 1, 1 }, + { 1, 1, 0, 1, 1, 0, 1, 1 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 1, 0, 0, 1, 0, 0, 0, 0 } + }, + // N + { + { 1, 1, 1, 1, 0, 0, 0, 0 }, + { 1,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0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 1, 0, 1, 0, 0, 0, 0, 0 } + } +}; + +/* TEXTSCROLL */ +bool fontcontainer[24][32]; +char mytext[195]=" out of order $"; +int fontoffset=1; +int textlength = sizeof(mytext); +int letter_index[195]; +int fontcheckframe=3; +int fontvalmultiply=5; +char myfont[85]="abcdefghijklmnopqrstuvwxyz 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.,!?-<>#+$:;()[]_"; +unsigned long last_time = millis(); +unsigned long current_time = millis(); + +/* Font Functions */ + +int get_letter_index(char c) { + for (int i=0; i=0 && offset_x+i<32 && offset_y+j>=0 && offset_y+j<24 && font[letter][j][i]==1) { + fontcontainer[offset_y+j][offset_x+i]=1; + } + } + } +} + +void print_mytext () { + /* clear font canvas */ + init_fontcontainer(); + for (int i=0; i32) break; + + /* PRINT LETTER */ + if (letter_index[i]-fontoffset>=-8 && letter_index[i]-fontoffset<32) { + if (i == 4 || i == 15) { + if (random(4)>2) { + print_letter(get_letter_index(mytext[i]),1+letter_index[i]-fontoffset,8); + } + } else { + print_letter(get_letter_index(mytext[i]),1+letter_index[i]-fontoffset,8); + } + } + } +} + +void change_text(String newtext) { + int i=0; + for (i=0; newtext[i] != NULL; i++) { + mytext[i] = newtext[i]; + } + + mytext[i] = '$'; + calculate_letter_index(); +} diff --git a/matrix_websocket_2023_18x18_udponly.ino b/matrix_websocket_2023_18x18_udponly.ino new file mode 100644 index 0000000..f0d2547 --- /dev/null +++ b/matrix_websocket_2023_18x18_udponly.ino @@ -0,0 +1,1351 @@ +/* + WebSocket Video Matrix +*/ + +#include "WiFi.h" +#include "WiFiUdp.h" +#include "esp32_digital_led_lib.h" + +/* GAMMA */ +int gc_red = 0; +int gc_green = 2; +int gc_blue = 2; + +/* DISPLAY SETUP VARIABLES */ +int display_width=32; +int display_height=24; +int gamcor_i=0; +int light_mode = 5; +uint32_t randval = 0; +int tempshine = 0; +int currentshine = 0; + +/* WEBSOCKET BUFFER */ +uint8_t wsleds[1680*3]; +uint8_t udpleds[1152]; + +/* UDP SETUP */ +unsigned int udp_port = 2390; +unsigned int udp_port2 = 2490; +char packetBuffer[8192]; +char ReplyBuffer[] = "ack"; + +uint8_t ReceiveBuffer[8192]; + +WiFiUDP Udp; +WiFiUDP Udp2; + +const unsigned int tcp_port = 2342; +WiFiServer Server(tcp_port); + +/* FRAME COUNTERS */ +unsigned long frame=0, frame2=0; + +/* DIFFERENT BACKGROUND COLOR DEFINITIONS */ +uint32_t gamcor_tests[] = { 0x000000, 0x00090c, 0x00060a, 0x00060b, 0x00060c, 0x00060d, 0x00060e, 0x00060f, 0x000610, 0x000611, 0x000612, 0x000607, 0x000608, +0x000003, 0x000004, 0x000005, 0x000006, 0x000300, 0x000400, 0x000500, 0x000600, 0x030000, 0x040000, 0x050000, 0x060000, }; + +uint8_t heatmap[768]; + +const uint16_t heatcolors[] = {0x480F, +0x400F,0x400F,0x400F,0x4010,0x3810,0x3810,0x3810,0x3810,0x3010,0x3010, +0x3010,0x2810,0x2810,0x2810,0x2810,0x2010,0x2010,0x2010,0x1810,0x1810, +0x1811,0x1811,0x1011,0x1011,0x1011,0x0811,0x0811,0x0811,0x0011,0x0011, +0x0011,0x0011,0x0011,0x0031,0x0031,0x0051,0x0072,0x0072,0x0092,0x00B2, +0x00B2,0x00D2,0x00F2,0x00F2,0x0112,0x0132,0x0152,0x0152,0x0172,0x0192, +0x0192,0x01B2,0x01D2,0x01F3,0x01F3,0x0213,0x0233,0x0253,0x0253,0x0273, +0x0293,0x02B3,0x02D3,0x02D3,0x02F3,0x0313,0x0333,0x0333,0x0353,0x0373, +0x0394,0x03B4,0x03D4,0x03D4,0x03F4,0x0414,0x0434,0x0454,0x0474,0x0474, +0x0494,0x04B4,0x04D4,0x04F4,0x0514,0x0534,0x0534,0x0554,0x0554,0x0574, +0x0574,0x0573,0x0573,0x0573,0x0572,0x0572,0x0572,0x0571,0x0591,0x0591, +0x0590,0x0590,0x058F,0x058F,0x058F,0x058E,0x05AE,0x05AE,0x05AD,0x05AD, +0x05AD,0x05AC,0x05AC,0x05AB,0x05CB,0x05CB,0x05CA,0x05CA,0x05CA,0x05C9, +0x05C9,0x05C8,0x05E8,0x05E8,0x05E7,0x05E7,0x05E6,0x05E6,0x05E6,0x05E5, +0x05E5,0x0604,0x0604,0x0604,0x0603,0x0603,0x0602,0x0602,0x0601,0x0621, +0x0621,0x0620,0x0620,0x0620,0x0620,0x0E20,0x0E20,0x0E40,0x1640,0x1640, +0x1E40,0x1E40,0x2640,0x2640,0x2E40,0x2E60,0x3660,0x3660,0x3E60,0x3E60, +0x3E60,0x4660,0x4660,0x4E60,0x4E80,0x5680,0x5680,0x5E80,0x5E80,0x6680, +0x6680,0x6E80,0x6EA0,0x76A0,0x76A0,0x7EA0,0x7EA0,0x86A0,0x86A0,0x8EA0, +0x8EC0,0x96C0,0x96C0,0x9EC0,0x9EC0,0xA6C0,0xAEC0,0xAEC0,0xB6E0,0xB6E0, +0xBEE0,0xBEE0,0xC6E0,0xC6E0,0xCEE0,0xCEE0,0xD6E0,0xD700,0xDF00,0xDEE0, +0xDEC0,0xDEA0,0xDE80,0xDE80,0xE660,0xE640,0xE620,0xE600,0xE5E0,0xE5C0, +0xE5A0,0xE580,0xE560,0xE540,0xE520,0xE500,0xE4E0,0xE4C0,0xE4A0,0xE480, +0xE460,0xEC40,0xEC20,0xEC00,0xEBE0,0xEBC0,0xEBA0,0xEB80,0xEB60,0xEB40, +0xEB20,0xEB00,0xEAE0,0xEAC0,0xEAA0,0xEA80,0xEA60,0xEA40,0xF220,0xF200, +0xF1E0,0xF1C0,0xF1A0,0xF180,0xF160,0xF140,0xF100,0xF0E0,0xF0C0,0xF0A0, +0xF080,0xF060,0xF040,0xF020,0xFFFF,}; + +/* GAMMA CURVE FOR BAD LEDS */ +uint8_t gamcor_curve[256] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, +30, 30, 31, 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, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, +92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, +124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, +156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, +188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, +220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251 }; + +/* GAMMA CORRECTION LEDS */ +int8_t gamcor_offset[768] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, +0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1 }; + +/* LOOKUP I TO XY */ +int lookup[768][2] = {{17, 0}, {16, 0}, {15, 0}, {14, 0}, {13, 0}, {12, 0}, {11, 0}, {10, 0}, {9, 0}, {8, 0}, {7, 0}, {6, 0}, {5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}, +{0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {9, 1}, {10, 1}, {11, 1}, {12, 1}, {13, 1}, {14, 1}, {15, 1}, {16, 1}, {17, 1}, +{17, 2}, {16, 2}, {15, 2}, {14, 2}, {13, 2}, {12, 2}, {11, 2}, {10, 2}, {9, 2}, {8, 2}, {7, 2}, {6, 2}, {5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}, +{0, 3}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}, {6, 3}, {7, 3}, {8, 3}, {9, 3}, {10, 3}, {11, 3}, {12, 3}, {13, 3}, {14, 3}, {15, 3}, {16, 3}, {17, 3}, +{17, 4}, {16, 4}, {15, 4}, {14, 4}, {13, 4}, {12, 4}, {11, 4}, {10, 4}, {9, 4}, {8, 4}, {7, 4}, {6, 4}, {5, 4}, {4, 4}, {3, 4}, {2, 4}, {1, 4}, {0, 4}, +{0, 5}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {5, 5}, {6, 5}, {7, 5}, {8, 5}, {9, 5}, {10, 5}, {11, 5}, {12, 5}, {13, 5}, {14, 5}, {15, 5}, {16, 5}, {17, 5}, +{17, 6}, {16, 6}, {15, 6}, {14, 6}, {13, 6}, {12, 6}, {11, 6}, {10, 6}, {9, 6}, {8, 6}, {7, 6}, {6, 6}, {5, 6}, {4, 6}, {3, 6}, {2, 6}, {1, 6}, {0, 6}, +{0, 7}, {1, 7}, {2, 7}, {3, 7}, {4, 7}, {5, 7}, {6, 7}, {7, 7}, {8, 7}, {9, 7}, {10, 7}, {11, 7}, {12, 7}, {13, 7}, {14, 7}, {15, 7}, {16, 7}, {17, 7}, +{17, 8}, {16, 8}, {15, 8}, {14, 8}, {13, 8}, {12, 8}, {11, 8}, {10, 8}, {9, 8}, {8, 8}, {7, 8}, {6, 8}, {5, 8}, {4, 8}, {3, 8}, {2, 8}, {1, 8}, {0, 8}, +{0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 9}, {5, 9}, {6, 9}, {7, 9}, {8, 9}, {9, 9}, {10, 9}, {11, 9}, {12, 9}, {13, 9}, {14, 9}, {15, 9}, {16, 9}, {17, 9}, +{17, 10}, {16, 10}, {15, 10}, {14, 10}, {13, 10}, {12, 10}, {11, 10}, {10, 10}, {9, 10}, {8, 10}, {7, 10}, {6, 10}, {5, 10}, {4, 10}, {3, 10}, {2, 10}, {1, 10}, {0, 10}, +{0, 11}, {1, 11}, {2, 11}, {3, 11}, {4, 11}, {5, 11}, {6, 11}, {7, 11}, {8, 11}, {9, 11}, {10, 11}, {11, 11}, {12, 11}, {13, 11}, {14, 11}, {15, 11}, {16, 11}, {17, 11}, +{17, 12}, {16, 12}, {15, 12}, {14, 12}, {13, 12}, {12, 12}, {11, 12}, {10, 12}, {9, 12}, {8, 12}, {7, 12}, {6, 12}, {5, 12}, {4, 12}, {3, 12}, {2, 12}, {1, 12}, {0, 12}, +{0, 13}, {1, 13}, {2, 13}, {3, 13}, {4, 13}, {5, 13}, {6, 13}, {7, 13}, {8, 13}, {9, 13}, {10, 13}, {11, 13}, {12, 13}, {13, 13}, {14, 13}, {15, 13}, {16, 13}, {17, 13}, +{17, 14}, {16, 14}, {15, 14}, {14, 14}, {13, 14}, {12, 14}, {11, 14}, {10, 14}, {9, 14}, {8, 14}, {7, 14}, {6, 14}, {5, 14}, {4, 14}, {3, 14}, {2, 14}, {1, 14}, {0, 14}, +{0, 15}, {1, 15}, {2, 15}, {3, 15}, {4, 15}, {5, 15}, {6, 15}, {7, 15}, {8, 15}, {9, 15}, {10, 15}, {11, 15}, {12, 15}, {13, 15}, {14, 15}, {15, 15}, {16, 15}, {17, 15}, +{17, 16}, {16, 16}, {15, 16}, {14, 16}, {13, 16}, {12, 16}, {11, 16}, {10, 16}, {9, 16}, {8, 16}, {7, 16}, {6, 16}, {5, 16}, {4, 16}, {3, 16}, {2, 16}, {1, 16}, {0, 16}, +{0, 17}, {1, 17}, {2, 17}, {3, 17}, {4, 17}, {5, 17}, {6, 17}, {7, 17}, {8, 17}, {9, 17}, {10, 17}, {11, 17}, {12, 17}, {13, 17}, {14, 17}, {15, 17}, {16, 17}, {17, 17}, +{18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}, {18,18}}; + +/* LOOKUP YX TO I */ +int lookup_yx[24][32] = {{ 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, +{ 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 }, +{ 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64 }, +{ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127 }, +{ 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128 }, +{ 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191 }, +{ 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192 }, +{ 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 }, +{ 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256 }, +{ 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319 }, +{ 351, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, 324, 323, 322, 321, 320 }, +{ 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383 }, +{ 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, 391, 390, 389, 388, 387, 386, 385, 384 }, +{ 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447 }, +{ 479, 478, 477, 476, 475, 474, 473, 472, 471, 470, 469, 468, 467, 466, 465, 464, 463, 462, 461, 460, 459, 458, 457, 456, 455, 454, 453, 452, 451, 450, 449, 448 }, +{ 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511 }, +{ 543, 542, 541, 540, 539, 538, 537, 536, 535, 534, 533, 532, 531, 530, 529, 528, 527, 526, 525, 524, 523, 522, 521, 520, 519, 518, 517, 516, 515, 514, 513, 512 }, +{ 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575 }, +{ 607, 606, 605, 604, 603, 602, 601, 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, 578, 577, 576 }, +{ 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639 }, +{ 671, 670, 669, 668, 667, 666, 665, 664, 663, 662, 661, 660, 659, 658, 657, 656, 655, 654, 653, 652, 651, 650, 649, 648, 647, 646, 645, 644, 643, 642, 641, 640 }, +{ 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703 }, +{ 735, 734, 733, 732, 731, 730, 729, 728, 727, 726, 725, 724, 723, 722, 721, 720, 719, 718, 717, 716, 715, 714, 713, 712, 711, 710, 709, 708, 707, 706, 705, 704 }, +{ 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767 }}; + +/* SINUS ARRAY */ +float my_sin[256] = { 0.0, 0.0245412285229, 0.0490676743274, 0.0735645635997, 0.0980171403296, 0.122410675199, + 0.146730474455, 0.17096188876, 0.195090322016, 0.219101240157, 0.242980179903, 0.266712757475, 0.290284677254, + 0.313681740399, 0.336889853392, 0.359895036535, 0.382683432365, 0.405241314005, 0.42755509343, 0.449611329655, + 0.471396736826, 0.49289819223, 0.514102744193, 0.534997619887, 0.55557023302, 0.575808191418, 0.595699304492, + 0.615231590581, 0.634393284164, 0.653172842954, 0.671558954847, 0.689540544737, 0.707106781187, 0.724247082951, + 0.740951125355, 0.757208846506, 0.773010453363, 0.788346427627, 0.803207531481, 0.817584813152, 0.831469612303, + 0.84485356525, 0.85772861, 0.870086991109, 0.881921264348, 0.893224301196, 0.903989293123, 0.914209755704, + 0.923879532511, 0.932992798835, 0.941544065183, 0.949528180593, 0.956940335732, 0.963776065795, 0.970031253195, + 0.975702130039, 0.980785280403, 0.985277642389, 0.989176509965, 0.992479534599, 0.995184726672, 0.997290456679, + 0.998795456205, 0.999698818696, 1.0, 0.999698818696, 0.998795456205, 0.997290456679, 0.995184726672, 0.992479534599, + 0.989176509965, 0.985277642389, 0.980785280403, 0.975702130039, 0.970031253195, 0.963776065795, 0.956940335732, + 0.949528180593, 0.941544065183, 0.932992798835, 0.923879532511, 0.914209755704, 0.903989293123, 0.893224301196, + 0.881921264348, 0.870086991109, 0.85772861, 0.84485356525, 0.831469612303, 0.817584813152, 0.803207531481, + 0.788346427627, 0.773010453363, 0.757208846506, 0.740951125355, 0.724247082951, 0.707106781187, 0.689540544737, + 0.671558954847, 0.653172842954, 0.634393284164, 0.615231590581, 0.595699304492, 0.575808191418, 0.55557023302, + 0.534997619887, 0.514102744193, 0.49289819223, 0.471396736826, 0.449611329655, 0.42755509343, 0.405241314005, 0.382683432365, + 0.359895036535, 0.336889853392, 0.313681740399, 0.290284677254, 0.266712757475, 0.242980179903, 0.219101240157, 0.195090322016, + 0.17096188876, 0.146730474455, 0.122410675199, 0.0980171403296, 0.0735645635997, 0.0490676743274, 0.0245412285229, + 0, -0.0245412285229, -0.0490676743274, -0.0735645635997, -0.0980171403296, -0.122410675199, -0.146730474455, + -0.17096188876, -0.195090322016, -0.219101240157, -0.242980179903, -0.266712757475, -0.290284677254, -0.313681740399, + -0.336889853392, -0.359895036535, -0.382683432365, -0.405241314005, -0.42755509343, -0.449611329655, -0.471396736826, + -0.49289819223, -0.514102744193, -0.534997619887, -0.55557023302, -0.575808191418, -0.595699304492, -0.615231590581, + -0.634393284164, -0.653172842954, -0.671558954847, -0.689540544737, -0.707106781187, -0.724247082951, -0.740951125355, + -0.757208846506, -0.773010453363, -0.788346427627, -0.803207531481, -0.817584813152, -0.831469612303, -0.84485356525, + -0.85772861, -0.870086991109, -0.881921264348, -0.893224301196, -0.903989293123, -0.914209755704, -0.923879532511, + -0.932992798835, -0.941544065183, -0.949528180593, -0.956940335732, -0.963776065795, -0.970031253195, -0.975702130039, + -0.980785280403, -0.985277642389, -0.989176509965, -0.992479534599, -0.995184726672, -0.997290456679, -0.998795456205, + -0.999698818696, -1.0, -0.999698818696, -0.998795456205, -0.997290456679, -0.995184726672, -0.992479534599, -0.989176509965, + -0.985277642389, -0.980785280403, -0.975702130039, -0.970031253195, -0.963776065795, -0.956940335732, -0.949528180593, + -0.941544065183, -0.932992798835, -0.923879532511, -0.914209755704, -0.903989293123, -0.893224301196, -0.881921264348, + -0.870086991109, -0.85772861, -0.84485356525, -0.831469612303, -0.817584813152, -0.803207531481, -0.788346427627, + -0.773010453363, -0.757208846506, -0.740951125355, -0.724247082951, -0.707106781187, -0.689540544737, -0.671558954847, + -0.653172842954, -0.634393284164, -0.615231590581, -0.595699304492, -0.575808191418, -0.55557023302, -0.534997619887, + -0.514102744193, -0.49289819223, -0.471396736826, -0.449611329655, -0.42755509343, -0.405241314005, -0.382683432365, + -0.359895036535, -0.336889853392, -0.313681740399, -0.290284677254, -0.266712757475, -0.242980179903, -0.219101240157, + -0.195090322016, -0.17096188876, -0.146730474455, -0.122410675199, -0.0980171403296, -0.0735645635997, -0.0490676743274, 0 }; + +#include "tetris.h" +#include "fonts.h" + + +/* PARTICLES */ +#define particleamount 70 +float particles[particleamount][4]; +/* RANGE FROM 0 TO 255 */ +int particle_map[768]; +int shine_map[768]; +/* PARTICLE COUNTER VARIABLE */ +int particle_index=0; + +/* SHOW TEXT */ +int activate_text = 1; + + +int x,y; +uint32_t hex; +uint8_t r,g,b; + +/* GAME OF LIFE SETUP */ +#define MAX_GEN_COUNT 300 +#define GRIDX 32 +#define GRIDY 24 + +uint8_t grid[GRIDX][GRIDY]; +uint8_t newgrid[GRIDX][GRIDY]; + +int genCount = 0; + +/* PLASMA VARS */ + +float range1 = .68; +float range2 = 0.33; +float range3 = 2.2; +float range4 = 0; +float range5 = .11; +float range6 = 1; +float scale = 1.2; +float pspeed = 0.1; + +void printHex(uint8_t num) { + char hexCar[2]; + + sprintf(hexCar, "%02X", num); + Serial.print(hexCar); +} + +/* SIMPLE SINUS FUNCTION VIA LOOKUP TABLE */ +float mysin(int input_val) { + if (input_val<0) input_val*=-1; + return my_sin[input_val%256]; +} + +float mysin2(float input_val) { + if (input_val<0) input_val*=-1; + input_val = int(input_val*256); + return my_sin[int(input_val)%256]; +} + +unsigned int sqrt32(unsigned long n) +{ + unsigned int c = 0x8000; + unsigned int g = 0x8000; + + for(;;) { + if(g*g > n) + g ^= c; + c >>= 1; + if(c == 0) + return g; + g |= c; + } +} + +void hsvtorgb(unsigned char *r, unsigned char *g, unsigned char *b, unsigned char h, unsigned char s, unsigned char v) { + unsigned char region, fpart, p, q, t; + + if(s == 0) { + /* color is grayscale */ + *r = *g = *b = v; + return; + } + + /* make hue 0-5 */ + region = h / 43; + /* find remainder part, make it from 0-255 */ + fpart = (h - (region * 43)) * 6; + + /* calculate temp vars, doing integer multiplication */ + p = (v * (255 - s)) >> 8; + q = (v * (255 - ((s * fpart) >> 8))) >> 8; + t = (v * (255 - ((s * (255 - fpart)) >> 8))) >> 8; + + /* assign temp vars based on color cone region */ + switch(region) { + case 0: + *r = v; *g = t; *b = p; break; + case 1: + *r = q; *g = v; *b = p; break; + case 2: + *r = p; *g = v; *b = t; break; + case 3: + *r = p; *g = q; *b = v; break; + case 4: + *r = t; *g = p; *b = v; break; + default: + *r = v; *g = p; *b = q; break; + } + + return; +} + +/* hsv to hex color function */ +unsigned long HSVtoHEX( float hue, float sat, float value ) { + float pr = 0; + float pg = 0; + float pb = 0; + + short ora = 0; + short og = 0; + short ob = 0; + + float ro = fmod( hue * 6, 6. ); + + float avg = 0; + + ro = fmod( ro + 6 + 1, 6 ); //Hue was 60* off... + + if( ro < 1 ) { + pr = 1; + pg = 1. - ro; + } else if( ro < 2 ) { + pr = 1; + pb = ro - 1.; + } else if( ro < 3 ) { + pr = 3. - ro; + pb = 1; + } else if( ro < 4 ) { + pb = 1; + pg = ro - 3; + } else if( ro < 5 ) { + pb = 5 - ro; + pg = 1; + } else { + pg = 1; + pr = ro - 5; + } + + //Actually, above math is backwards, oops! + pr *= value; + pg *= value; + pb *= value; + + avg += pr; + avg += pg; + avg += pb; + + pr = pr * sat + avg * (1.-sat); + pg = pg * sat + avg * (1.-sat); + pb = pb * sat + avg * (1.-sat); + + ora = pr * 255; + og = pb * 255; + ob = pg * 255; + + if( ora < 0 ) ora = 0; + if( ora > 255 ) ora = 255; + if( og < 0 ) og = 0; + if( og > 255 ) og = 255; + if( ob < 0 ) ob = 0; + if( ob > 255 ) ob = 255; + + return (ob<<16) | (og<<8) | ora; +} + + +/* GAME OF LIFE */ +void initGrid(void) { + for (int16_t x = 0; x < GRIDX; x++) { + for (int16_t y = 0; y < GRIDY; y++) { + newgrid[x][y] = 0; + + if (random(4) == 1) { + grid[x][y] = 1; + } else { + grid[x][y] = 0; + } + } + } +} + +void computeCA() { + for (int x = 0; x < GRIDX; x++) { + for (int y = 0; y < GRIDY; y++) { + int neighbors = getNumberOfNeighbors(x, y); + if (grid[x][y] == 1 && (neighbors == 2 || neighbors == 3 )) + { + newgrid[x][y] = 1; + } + else if (grid[x][y] == 1) newgrid[x][y] = 0; + if (grid[x][y] == 0 && (neighbors == 3)) + { + newgrid[x][y] = 1; + } + else if (grid[x][y] == 0) newgrid[x][y] = 0; + } + } +} + +int getNumberOfNeighbors(int x, int y) { + int x_min_one = (x-1+GRIDX)%GRIDX; + int y_min_one = (y-1+GRIDY)%GRIDY; + int x_plus_one = (x+1)%GRIDX; + int y_plus_one = (y+1)%GRIDY; + return grid[x_min_one][y] + grid[x_min_one][y_min_one] + grid[x][y_min_one] + grid[x_plus_one][y_min_one] + grid[x_plus_one][y] + grid[x_plus_one][y_plus_one] + grid[x][y_plus_one] + grid[x_min_one][y_plus_one]; +} + +void playGameOfLife() { + computeCA(); + + for (int x = 0; x < GRIDX; x++) { + for (int y = 0; y < GRIDY; y++) { + grid[x][y] = newgrid[x][y]; + } + } +} + + + + +/* BEGIN RMT & DEBUG */ +#if defined(ARDUINO) && ARDUINO >= 100 + // No extras +#elif defined(ARDUINO) // pre-1.0 + // No extras +#elif defined(ESP_PLATFORM) + #include "arduinoish.hpp" +#endif + +#define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) + +// **Required** if debugging is enabled in library header +// TODO: Is there any way to put this in digitalLeds_addStrands() and avoid undefined refs? +#if DEBUG_ESP32_DIGITAL_LED_LIB + int digitalLeds_debugBufferSz = 1024; + char * digitalLeds_debugBuffer = static_cast(calloc(digitalLeds_debugBufferSz, sizeof(char))); +#endif + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" // It's noisy here with `-Wall` + + +strand_t STRANDS[] = { // Avoid using any of the strapping pins on the ESP32, anything >=32, 16, 17... not much left. + {.rmtChannel = 0, .gpioNum = 14, .ledType = LED_WS2812B_V2, .brightLimit = 12, .numPixels = 324}, +}; + +#pragma GCC diagnostic pop + +int STRANDCNT = COUNT_OF(STRANDS); + +void dumpDebugBuffer(int, char *); + +//**************************************************************************// +int getMaxMalloc(int min_mem, int max_mem) { + int prev_size = min_mem; + int curr_size = min_mem; + int max_free = 0; + + while (1) { + void * foo1 = malloc(curr_size); + if (foo1 == nullptr) { + max_mem = min(curr_size, max_mem); + curr_size = (int)(curr_size - (curr_size - prev_size) / 2.0); + } + else { + free(foo1); + max_free = curr_size; + prev_size = curr_size; + curr_size = min(curr_size * 2, max_mem); + } + if (abs(curr_size - prev_size) == 0) { + break; + } + } + Serial.print("checkmem: max free heap = "); + Serial.print(esp_get_free_heap_size()); + Serial.print(" bytes, max allocable = "); + Serial.print(max_free); + Serial.println(" bytes"); + return max_free; +} + +void dumpSysInfo() { + esp_chip_info_t sysinfo; + esp_chip_info(&sysinfo); + Serial.print("Model: "); + Serial.print((int)sysinfo.model); + Serial.print("; Features: 0x"); + Serial.print((int)sysinfo.features, HEX); + Serial.print("; Cores: "); + Serial.print((int)sysinfo.cores); + Serial.print("; Revision: r"); + Serial.println((int)sysinfo.revision); +} + +void dumpDebugBuffer(int id, char * debugBuffer) +{ + Serial.print("DEBUG: ("); + Serial.print(id); + Serial.print(") "); + Serial.println(debugBuffer); + debugBuffer[0] = 0; +} + +boolean initStrands() +{ + digitalLeds_initDriver(); + + for (int i = 0; i < STRANDCNT; i++) { + gpioSetup(STRANDS[i].gpioNum, OUTPUT, LOW); + } + + strand_t * strands[1]; + for (int i = 0; i < STRANDCNT; i++) { + strands[i] = &STRANDS[i]; + } + int rc = digitalLeds_addStrands(strands, STRANDCNT); + if (rc) { + Serial.print("Init rc = "); + Serial.println(rc); + return false; + } + + for (int i = 0; i < STRANDCNT; i++) { + strand_t * pStrand = strands[i]; + Serial.print("Strand "); + Serial.print(i); + Serial.print(" = "); + Serial.print((uint32_t)(pStrand->pixels), HEX); + Serial.println(); + #if DEBUG_ESP32_DIGITAL_LED_LIB + dumpDebugBuffer(-2, digitalLeds_debugBuffer); + #endif + } + + return true; +} + +/* END RMT & DEBUG */ + + + +WiFiClient RemoteClient; + +void CheckForConnections() +{ + if (Server.hasClient()) + { + // If we are already connected to another computer, + // then reject the new connection. Otherwise accept + // the connection. + if (RemoteClient.connected()) + { + Serial.println("Connection rejected"); + Server.available().stop(); + } + else + { + Serial.println("Connection accepted"); + RemoteClient = Server.available(); + } + } +} + + + + + +/* MAIN */ + +/* WIFI */ +/* ACCESS POINT */ +//const char* ssid = "freethelong3"; +//const char* password = "alle_informationen"; + +/* CLIENT */ +const char* ssid = "ESPionage"; +const char* password = "intranetofshit"; + +int update_matrix=1; // switch whether to update led-matrix or not +int update_video=0; +int iinc2=0; // framecount +int ws_count=0; // incoming websocket message count +char datacontent[4250]; // placeholder for incoming websocket message + +/* WEBSOCKET RETURN MESSAGE */ +char websocket_message[4250]; + +/* SETUP */ +void setup() { + /* INIT SERIAL */ + Serial.begin(115200); + while (!Serial); + + /* FONT */ + calculate_letter_index(); + + /* INIT */ + Serial.println("WebSocket Video Matrix"); + + + /* WIFI */ + delay(1000); + /* ACCESS POINT */ + //WiFi.softAP(ssid, password); + /* CLIENT */ + WiFi.begin(ssid, password); + delay(1000); + Serial.println("Connecting WiFi.."); + + Serial.println(WiFi.localIP()); + + /* DEBUG */ + dumpSysInfo(); + getMaxMalloc(1*1024, 16*1024*1024); + + /* LED INIT */ + if (!initStrands()) { + Serial.println("Init FAILURE: halting"); + while (true) { + delay(100); + } + } + delay(100); + + Udp.begin(udp_port); + Udp2.begin(udp_port2); + + /* Init Lights (Tetris) */ + init_lights(); + + initGrid(); + + Server.begin(); + + Serial.println("Init complete"); +} + +void receiveTcpData() +{ + while (RemoteClient.connected() && RemoteClient.available()) + { + int Received = RemoteClient.read(ReceiveBuffer, sizeof(ReceiveBuffer)); + light_mode = 8; + + for (int vp=0; vp128 ? 128 : value); } + + + + + + + +/* LOOP */ +void loop() { + current_time = millis(); + randval = random(10000); + receiveTcpData(); + + CheckForConnections(); + + /* Tetris */ + if (light_mode==1) { + if (frame%256==0) { + check_movement(0, 0, 1, 0); + check_movement(1, 0, 1, 0); + } + } + + /* VIDEO UDP */ + int packetSize2 = Udp2.parsePacket(); + if (packetSize2) { + IPAddress remoteIp2 = Udp2.remoteIP(); + //Serial.println(remoteIp); + + int len = Udp2.read(packetBuffer,8192); + if (len>0) { + packetBuffer[len] = 0; + } + + light_mode = 8; + for (int vp=0; vp0) { + packetBuffer[len] = 0; + + } + + + //Serial.println(packetBuffer[0]); + //Serial.println(int(packetBuffer[0])); + + if (int(packetBuffer[0])==100) { + if (int(packetBuffer[1])==49) { + range1-=.1; + } + + if (int(packetBuffer[1])==50) { + range2-=.1; + } + + if (int(packetBuffer[1])==51) { + range3-=.1; + } + + if (int(packetBuffer[1])==52) { + range4-=.1; + } + + if (int(packetBuffer[1])==53) { + range5-=.1; + } + + if (int(packetBuffer[1])==54) { + pspeed-=.1; + } + + if (int(packetBuffer[1])==55) { + scale-=.1; + } + } + + if (int(packetBuffer[0])==105) { + if (int(packetBuffer[1])==49) { + range1+=.1; + } + + if (int(packetBuffer[1])==50) { + range2+=.1; + } + + if (int(packetBuffer[1])==51) { + range3+=.1; + } + + if (int(packetBuffer[1])==52) { + range4+=.1; + } + + if (int(packetBuffer[1])==53) { + range5+=.1; + } + + if (int(packetBuffer[1])==54) { + pspeed+=.1; + } + + if (int(packetBuffer[1])==55) { + scale+=.1; + } + } + + + + + + + if (packetBuffer[0] == 123) { + light_mode = 4; + + for(int i=0; i<768; i++){ + //printHex(packetBuffer[i]); + heatmap[i] = packetBuffer[i]; + } + + //Serial.println(); + } else { + /* If first byte equals "c" (like control) */ + if (packetBuffer[0] == 99) { + scale = .01*int(packetBuffer[1]); + range2 = .01*int(packetBuffer[2]); + range3 = .01*int(packetBuffer[3]); + light_mode = 5; + + } + } + + /* If first byte equals "t" (like text) */ + if (int(packetBuffer[0])==116) { + char mynewtext[190] = " "; + for (int pbi=1; pbi9) frame2=0; + //Serial.println("frame2: "+String(frame2)+" randval: "+String(randval)); + //Serial.println(""); + for (int pa=0; pa<5; pa++) { + //Serial.println("pa"+String(pa)+"_y: "+String(particles[pa][1])); + } + } + + /* CALCULATE AND UPDATE STAR PARTICLES */ + if (light_mode==11 || light_mode==1) { + /* GENERATE PARTICLE IF RANDOM VALUE > LIMIT */ + if (randval>(7000-frame2*300)) { + /* X */ + particles[particle_index][0]=randval%32; + /* Y */ + particles[particle_index][1]=25; + /* SPEED */ + particles[particle_index][3]=(randval%30+50)*.012; + /* STRENGTH */ + particles[particle_index][2]=randval%140+65-(60/(particles[particle_index][3]*200))*50; + //Serial.println(String(particle_index)+" - x: "+String(particles[particle_index][0])+" y: "+String(particles[particle_index][1])); + + /* LAST PARTICLE OVERWRITES OLDEST PARTICLE */ + particle_index++; + if (particle_index==particleamount){ + particle_index=0; + } + } + + /* EVERY SECOND FRAME */ + if (current_time-last_time>30) { + /* DIM SHINE MAP */ + //Serial.print("-"); + for (int sw=0; sw<768; sw++) { + if (shine_map[sw]>0) { + shine_map[sw]-=10; + } + } + + /* RESET PARTICLE MAP */ + for (int rw=0; rw<768; rw++) { + particle_map[rw]=0; + } + + /* LOOP THROUGH PARTICLES */ + for (int aw=0; aw0 && particles[aw][1]>0) { + /* GENERATE RANDOM GLOW */ + //uint32_t rand_glow = rand(); + + //Serial.print("/"); + + /* UPDATE/DECREASE PARTICLE PROPERTIES */ + particles[aw][1]=particles[aw][1]-particles[aw][3]; + particles[aw][2]=particles[aw][2]-.25-particles[aw][3]*2; + + /* INTERPOLATION */ + int inter_x=(int)particles[aw][0]; + int inter_y=(int)particles[aw][1]; + + /* IF Y IN LIMITS */ + if (inter_y > 0 && inter_y < display_height && inter_x >= 0 && inter_x < display_width) { + /* SET INTERPOLATION VALUES 1 & 2 [0..1] each */ + float interp_2 = inter_y + 1 - particles[aw][1]; + float interp_1 = 1 - interp_2; + + /* SET INDEX FOR INTERPOLATED PIXEL AND +1 */ + int particle_map_index = lookup_yx[inter_y ][inter_x]; + int particle_map_index2 = lookup_yx[inter_y-1][inter_x]; + + /* SET PARTICLE MAP FOR FIRST PIXEL */ + if (particle_map[particle_map_index]+(int)((particles[aw][2]+(my_sin[frame%256]+1)*20)*interp_1)<245) { + particle_map[particle_map_index]+=(int)((particles[aw][2]+(my_sin[frame%256]+1)*20)*interp_1); + } else { + particle_map[particle_map_index]=245; + } + + /* SET SHINE MAP VALUE FOR CURRENT PIXEL */ + if (particle_map_index2 >=0 && particle_map_index2 < 768) { + currentshine = shine_map[particle_map_index2]; + /* CALCULATE SHINE-ADDING TO PIXEL */ + /* STRENGTH [0..255] interp_2 [0..1] */ + tempshine = (80-(int)((particles[aw][2])*interp_2)); + /* IF CALCULATED NEW SHINE IS GREATER THAN 0 */ + if (tempshine>0) { + if ((currentshine+tempshine) > 245) { + /* RAISE SHINE VALUE IF IN LIMITS */ + shine_map[particle_map_index2] += tempshine; + } + } + + /* SET SECOND PIXEL IF ON DISPLAY */ + if (inter_y+1MAX_GEN_COUNT) { + initGrid(); + genCount=0; + } + } + + + + strand_t * strands [STRANDCNT]; + + /* ACTUAL PAINTING */ + if (update_matrix) { + + unsigned char h, s, v; + unsigned char r, g, b; + + s=255; + + for (int i = 0; i < STRANDCNT; i++) { + strand_t * pStrand = &STRANDS[i]; + for (int j = 0; j < 324; j++) { + int p_i = i*324+j; + + + x = lookup[p_i][0]; + y = lookup[p_i][1]; + + + pStrand->pixels[j] = pixelFromRGB(0, 0, 0); + + /* GAME OF LIFE */ + if (light_mode == 2) { + if (grid[x][y]==1) { + pStrand->pixels[j] = pixelFromRGB(123, 0, 0); + } else { + pStrand->pixels[j] = pixelFromRGB(0, x, y); + } + } + + /* PLASMA */ + if (light_mode == 3) { + h=frame/4+40.0 + 40*mysin(x*16+frame) + 40 + 40*mysin(y*32+frame) + 40 + 40*mysin((x+y)*16+frame) + 40 + 40*mysin(sqrt32(x*x*256 + y*y*256 + frame)); + v=(h+128+frame)%256; + + hsvtorgb(&r,&g,&b,h,s,v); + pStrand->pixels[j] = pixelFromRGB(int(r*.1), int(g*.1), int(b*.1)); + } + + /* HEATCAM */ + if (light_mode == 4) { + h=heatmap[y*32+x]; + v=int(h*.5); + //hsvtorgb(&r,&g,&b,h,s,v); + r = ((heatcolors[h] >> 11) & 0x1F); + g = ((heatcolors[h] >> 5) & 0x3F); + b = (heatcolors[h] & 0x1F); + + pStrand->pixels[j] = pixelFromRGB(r, g, b); + } + + /* PLASMA #4 */ + if (light_mode == 5) { + v=scale*120 + (range2)*(range2)*400*mysin(128+x*(range3+.5)*(range3+.5)*100+mysin(frame)*30+frame) + (range2)*(range2)*400*mysin(128+y*(range3+.5)*(range3+.5)*100+mysin(frame)*30+frame); + h=v+frame/2; + + hsvtorgb(&r,&g,&b,h,s,v); + pStrand->pixels[j] = pixelFromRGB(int(r*.5), int(g*.25), int(b*.5)); + } + + /* PLASMA #2 */ + if (light_mode == 6) { + int roundtestnice2= 130.0 + (70.0 * mysin(frame+sqrt32((x - 19 / 2.0) * (x - 19 / 2.0) *1000 + (y - 19 / 2.0) * (y - 19 / 2.0) * 1000))); + v=130.0 + (70.0 * mysin(frame*2+sqrt32((x - 19 / 2.0) * (x - 19 / 2.0) *2000 + (y - 19 / 2.0) * (y - 19 / 2.0) * 2000))); + hsvtorgb(&r,&g,&b,h,s,v); + + pStrand->pixels[j] = pixelFromRGB(int(r*.1), int(roundtestnice2*.1), int(b*.1)); + } + + /* TEXT */ + if (light_mode == 7) { + int color_time=frame2*0.25; + //hsvtorgb(&r,&g,&b,h,s,v); + + if (((frame2*4+p_i)%256)>120) { + h=(x+y+color_time)%256; + v=140; + hsvtorgb(&r,&g,&b, h, s, v); + } else { + r=0; + g=0; + b=0; + } + pStrand->pixels[j] = pixelFromRGB(int(r*.1), int(g*.1), int(b*.1)); + } + + /* PLASMA #5 */ + if (light_mode == 9) { + v=120.0 + 40*mysin(128+x*x+frame) + 40*mysin(128+y*y+frame); + h=v+frame/2; + + hsvtorgb(&r,&g,&b,h,s,v); + pStrand->pixels[j] = pixelFromRGB(int(r*.5), int(g*.25), int(b*.5)); + } + + /* PLASMA W VARS */ + if (light_mode == 6) { + float t = pspeed*frame; + float ts = mysin2(t/167); + float tc = mysin2(128+(t/167)); + + float px = scale * ( x - display_width/2.0); + px = px + 0.2*display_width* mysin2(t/337); + + float py = scale * ( y - display_height/2.0); + py = py + 0.3*display_height * mysin2(t/413); + + float nx = 2*range1*(tc * px - ts * py); + float ny = 2*range1*(ts * px + tc * py); + + v=255-3*range2*(60.0 + 80*range3*mysin2(mysin2(nx*ny*.0012+t/19)*2 + nx/19+t/37) + 80*range4*mysin2(mysin2(nx*ny*.01+t/17) + ny/19 + t/31 )); + h=v*range5+nx+ny+t/2; + + hsvtorgb(&r,&g,&b,h,s,v); + pStrand->pixels[j] = pixelFromRGB(int(r*.5), int(g*.25), int(b*.5)); + } + + /* DISPLAY STARS */ + if (light_mode == 11) { + int myred = 23-gamcor_curve[y]; + if (myred<0) myred=0; + + if (particle_map[p_i] != 0) { + /* SHOW PARTICLE - COLOR CALCULATION */ + pStrand->pixels[j] = pixelFromRGB(myred, int(particle_map[p_i]*.95), int(shine_map[p_i]*.65)+12); + } else { + pStrand->pixels[j] = pixelFromRGB(myred, 0, int(shine_map[p_i]*.65)+12); + } + } + + /* Tetris */ + if (light_mode==1) { + int myred = 23-gamcor_curve[y]; + if (myred<0) myred=0; + + /* IF PIXEL ON TETRIS FIELD */ + if ((x >= p_field_pos[0][0] && x <= p_field_pos[0][0]+9 && y >= p_field_pos[0][1] && y <= p_field_pos[0][1]+19) || (x >= p_field_pos[1][0] && x <= p_field_pos[1][0]+9 && y >= p_field_pos[1][1] && y <= p_field_pos[1][1]+19)) { + /* SHOW PARTICLE - COLOR CALCULATION */ + + int lledsum = last_leds[p_i*3]+last_leds[p_i*3+1]+last_leds[p_i*3+2]; + int lledred = last_leds[p_i*3]; + int lledgreen = last_leds[p_i*3+1]; + int lledblue = last_leds[p_i*3+2]; + + if (lledred>0) lledred=42; + if (lledgreen>0) lledgreen=42; + if (lledblue>0) lledblue=42; + + if (lledsum>0) { + pStrand->pixels[j] = pixelFromRGB(lledred, lledgreen, lledblue); + } + } else { + if (particle_map[p_i] != 0) { + /* SHOW PARTICLE - COLOR CALCULATION */ + pStrand->pixels[j] = pixelFromRGB(myred, int(particle_map[p_i]*.95), int(shine_map[p_i]*.65)+12); + } else { + pStrand->pixels[j] = pixelFromRGB(myred, 0, int(shine_map[p_i]*.65)+12); + } + } + } + + if (light_mode == 8) { + uint8_t x2; + int p_i2; + if (y%2!=0) { + p_i2 = lookup_yx[y][x]; + } else { + p_i2 = lookup_yx[y][31-x]; + } + + uint8_t pix_y = udpleds[p_i2]; + uint8_t pix_u = udpleds[(768+(int)(floor(y/2)*16)+(int)(floor(x/2)))]; + uint8_t pix_v = udpleds[(960+(int)(floor(y/2)*16)+(int)(floor(x/2)))]; + + uint8_t red = clamp((int)((1.164 * (pix_y - 16) + 1.596 * (pix_v - 128))*.15)); + uint8_t green = clamp((int)((1.164 * (pix_y - 16) - 0.813 * (pix_v - 128) - 0.391 * (pix_u - 128))*.15)); + uint8_t blue = clamp((int)((1.164 * (pix_y - 16) + 2.018 * (pix_u - 128))*.15)); + + if (p_i<64 || p_i>703) { + red = clamp(red-gc_red); + green = clamp(green-gc_green); + blue = clamp(blue-gc_blue); + } + + /* + uint8_t red = (udpleds[p_i2] >> 5)*8; + uint8_t green = ((udpleds[p_i2] & 28) >> 2)*8; + uint8_t blue = (udpleds[p_i2] & 3)*8; + */ + pStrand->pixels[j] = pixelFromRGB(red, green, blue); //hex=HSVtoHEX(y*x*0.0007 + frame*.00019,1,.4); + } + + /* PRINT TEXT */ + if (fontcontainer[y][31-x]==1 && activate_text == 1) { + pStrand->pixels[j] = pixelFromRGB(100, 100, 100); //hex=HSVtoHEX(y*x*0.0007 + frame*.00019,1,.4); + } + + /* SHOW WEBSOCKET VIDEO */ + if (update_video) { + uint8_t red = (wsleds[p_i] >> 5)*8; + uint8_t green = ((wsleds[p_i] & 28) >> 2)*8; + uint8_t blue = (wsleds[p_i] & 3)*8; + pStrand->pixels[j] = pixelFromRGB(red, green, blue); //hex=HSVtoHEX(y*x*0.0007 + frame*.00019,1,.4); + } + + //pStrand->pixels[j] = gamcor_curve[pStrand->pixels[j]]; + } + + strands[i] = &STRANDS[i]; + } + + /* DRAW ALL PIXELS */ + digitalLeds_drawPixels(strands, 1); + iinc2++; + + /* MOVE TEXT */ + if (current_time-last_time>30) { + fontoffset+=1; + last_time=current_time; + } + + if (fontoffset>4+textlength) { + fontoffset=-32; + } + } +} diff --git a/tetris.h b/tetris.h new file mode 100644 index 0000000..7491586 --- /dev/null +++ b/tetris.h @@ -0,0 +1,532 @@ +/* TETRIS */ + +uint8_t last_leds[768*3]; +int last_led_count = 768; + + +// First dimension: which shape +// Second dimension: which rotation, + color +// Third & fourth dimensions: rows and columns of shape +bool shapetypes[7][5][4][4] = { + { + // Line of four + { + { 0, 0, 0, 0 }, + { 1, 1, 1, 1 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 1, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 1, 1, 1, 1 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 1, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 0, 0 } + }, + { + {1}, {1}, {0} + } + }, + + { + // S-shape (orientation 1) + { + { 0, 0, 0, 0 }, + { 1, 1, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 1, 0 }, + { 0, 1, 1, 0 }, + { 0, 1, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 1, 1, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 1, 0 }, + { 0, 1, 1, 0 }, + { 0, 1, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + {0}, {0}, {1} + } + + }, + + { + // S-shape (orientation 2) + { + { 0, 0, 0, 0 }, + { 0, 1, 1, 0 }, + { 1, 1, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 1, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 0, 1, 1, 0 }, + { 1, 1, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 1, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + {1}, {0}, {0} + } + + }, + + { + // T-piece + { + { 0, 0, 0, 0 }, + { 0, 1, 0, 0 }, + { 1, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 1, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 1, 1, 1, 0 }, + { 0, 1, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 1, 0, 0 }, + { 1, 1, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + {1}, {1}, {1} + } + + }, + + { + // L-piece (orientation 1) + { + { 0, 1, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 1, 1, 1, 0 }, + { 1, 0, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 1, 1, 0 }, + { 0, 0, 1, 0 }, + { 0, 0, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 0, 0, 1, 0 }, + { 1, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + {0}, {1}, {0} + } + + }, + + { + // L-piece (orientation 2) + { + { 0, 0, 1, 0 }, + { 0, 0, 1, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 1, 1 }, + { 0, 0, 0, 0 } + }, + { + { 0, 1, 1, 0 }, + { 0, 1, 0, 0 }, + { 0, 1, 0, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 0, 1, 1, 1 }, + { 0, 0, 0, 1 }, + { 0, 0, 0, 0 } + }, + { + {0}, {1}, {1} + } + + }, + + { + // Cube + { + { 0, 0, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0 }, + { 0, 1, 1, 0 }, + { 0, 1, 1, 0 }, + { 0, 0, 0, 0 } + }, + { + {1}, {0}, {1} + } + + } +}; + +/* SOMEBRICKS: Position, Type and Rotation of current piece (array index = player) */ +/* number of players */ +int players=2; + +/* field position */ +int p_field_pos[2][2] = {{2,2},{20,2}}; + +/* set players current shape xy-position */ +int set_x[2]={3,3}; +int set_y[2]={0,0}; + +/* set players current shapetype & rotation */ +int current_btype[2]={0,1}; +int current_brot[2]={0,0}; + + +/* Somebricks Functions */ + +void init_lights() { + int arrsize = last_led_count*3; + + int i; + int x; + int y; + + int idx = 0; + + for (int led=0;led=0 && field_y<24 && field_y>=0) { + light_i = lookup_yx[field_y][field_x]; + + /* set rgb of pieces separately */ + if (shapetypes[current_btype[p]][4][0][0]==1) { last_leds[light_i*3] = 100; } else { last_leds[light_i*3] = 0; } + if (shapetypes[current_btype[p]][4][1][0]==1) { last_leds[light_i*3+1] = 100; } else { last_leds[light_i*3+1] = 0; } + if (shapetypes[current_btype[p]][4][2][0]==1) { last_leds[light_i*3+2] = 100; } else { last_leds[light_i*3+2] = 0; } + } + } + } + } + } +} + +void clear_lines(int player_id) { + int stones_in_line; + int pixel_value; + int light_int; + int light_int_old; + + int field_newx; + int field_newy; + + for (int j=p_field_pos[player_id][1]+19; j>p_field_pos[player_id][1]; j--) { + /* Count stones in line */ + stones_in_line=0; + for (int i=p_field_pos[player_id][0]; i99) { + stones_in_line++; + } + } + + /* Found complete line */ + if (stones_in_line==10) { + /* Move down everything by 1 line */ + for (int y=j; y>p_field_pos[player_id][1]; y--) { + for (int x=p_field_pos[player_id][0]; x<10+p_field_pos[player_id][0]; x++) { + light_int = lookup_yx[y][x]; + if ((y-1)>=0) { + light_int_old = lookup_yx[y-1][x]; + + last_leds[light_int*3+0]=last_leds[(light_int_old)*3+0]; + last_leds[light_int*3+1]=last_leds[(light_int_old)*3+1]; + last_leds[light_int*3+2]=last_leds[(light_int_old)*3+2]; + } + } + } + /* Set index to last line */ + j++; + + /* Change Enemy Field - Move up everything by 1 line */ + for (int p=0; p=0 && field_newx<32 && field_newy>=0 && field_newy<22) { + + light_int = lookup_yx[field_newy][field_newx]; + + pixel_value=last_leds[light_int*3+0]+last_leds[light_int*3+1]+last_leds[light_int*3+2]; + + int p_min_x = p_field_pos[player_id][0]; + int p_min_y = p_field_pos[player_id][1]; + int p_max_x = p_field_pos[player_id][0]+9; + int p_max_y = p_field_pos[player_id][1]+19; + + /* collision */ + if (field_newx>p_max_x || field_newxp_max_y || field_newy 99) { + if (y==1) { + merge_stone(player_id); + } + + update_stones(); + + return false; + } + } else { + /* piece at the lowest point -> merge */ + if (y==1) { + merge_stone(player_id); + } + update_stones(); + return false; + } + } + } + } + + /* Place future position (eventually will not be reached) */ + for (int i=0; i<4; i++) { + for (int j=0; j<4; j++) { + if (shapetypes[current_btype[player_id]][temp_brot][i][j] == 1) { + field_newx=p_field_pos[player_id][0]+temp_set_x+j; + field_newy=p_field_pos[player_id][1]+temp_set_y+i; + + light_int = lookup_yx[field_newy][field_newx]; + + if (shapetypes[current_btype[player_id]][4][0][0]==1) { last_leds[light_int*3] = 100; } else { last_leds[light_int*3] = 0; } + if (shapetypes[current_btype[player_id]][4][1][0]==1) { last_leds[light_int*3+1] = 100; } else { last_leds[light_int*3+1] = 0; } + if (shapetypes[current_btype[player_id]][4][2][0]==1) { last_leds[light_int*3+2] = 100; } else { last_leds[light_int*3+2] = 0; } + } + } + } + + set_x[player_id] = temp_set_x; + set_y[player_id] = temp_set_y; + current_brot[player_id] = temp_brot; + + update_stones(); + + return true; +}