1234567891011121314151617181920212223242526272829303132333435 |
- #define MAT_WIDTH 16
- constexpr uint32_t compress(int **mat) {
- uint32_t mat_compressed = 0;
- for (uint8_t r = 0; r < MAT_WIDTH; ++r) {
- for (uint8_t c = 0; c < MAT_WIDTH; ++c) {
- uint32_t oneDInd = 1 << (r * MAT_WIDTH + c);
- if (mat[r][c])
- mat_compressed |= oneDInd;
- }
- }
- return mat_compressed;
- }
- constexpr uint32_t dikk() {
- const int[MAT_WIDTH][MAT_WIDTH] arrayMap = {{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,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,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,1,1,0,0,1,0,0,0,0,0,0},{0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0},{0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0},{0,0,0,0,1,0,0,0,1,1,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,0,0,0,1,1,0,0,0,0,0,0,0},{0,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0},{0,0,0,1,1,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,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,0,0,0,0,0,0}};
- return compress(arrayMap);
- }
- void decompress(uint32_t mat_compressed) {
- for (uint8_t r = 0; r < MAT_WIDTH; ++r) {
- for (uint8_t c = 0; c < MAT_WIDTH; ++c) {
- uint32_t oneDInd = 1 << (r * MAT_WIDTH + c);
- Serial.print((mat_compressed & oneDInd) > 1);
- }
- Serial.println();
- }
- }
- void setup() {
- const uint32_t dik = dikk();
- decompress(dik);
- }
- void loop() {}
|