Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

48 Replies - 2298 Views - Last Post: 13 April 2018 - 04:19 AM Rate Topic: -----

#1 wolfrose   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 20-January 16

Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 10:18 AM

Hello,


I'm working on 8x8 led dot matrix project, and download hex basic font for ASCII chars and symbols from a library.

Everything is good, but when testing the data is flipped over, where the array is 760 bytes divided by 8.

Then I have to flip each 8-bytes which would be 95 times on the calculator website.

My link

Example of data:
uint8_t ascii_array[760] = {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // U+0020 (space)
     0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00,   // U+0021 (!)
     0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // U+0022 (")
     0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00,   // U+0023 (#)
.
.
.
};


For example, A is:
0xc, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x0


And when flipping it on the website, the result is:
0x0, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x78, 0x30


Could I develop a function to flip all the bytes in the array?

Is This A Good Question/Topic? 0
  • +

Replies To: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

#2 jimblumberg   User is offline

  • member icon

Reputation: 5525
  • View blog
  • Posts: 17,115
  • Joined: 25-December 09

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 10:41 AM

Quote

Could I develop a function to flip all the bytes in the array?

I don't know, can you?

What have you tried?

It is possible to do almost anything if you really understand what is happening.



Jim
Was This Post Helpful? 1
  • +
  • -

#3 wolfrose   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 20-January 16

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 11:10 AM

I don't know I was looking at the original 8-bytes and the flipped 8-bytes result! I thought what can I do here? Can I AND it with specific value? XOR it? Hmmm, I don't think any one would work.

I can do it manually, by copying the 8-bytes packets and flip them on the website.

But, I'd love to find an automatic way.

This post has been edited by ndc85430: 01 April 2018 - 11:15 AM
Reason for edit:: Removed quote of previous post. Please just press "Reply" in future.

Was This Post Helpful? 0
  • +
  • -

#4 cardgage   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 16-August 17

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 01:01 PM

#include <stdio.h>
#include <string.h>

unsigned char a[] = {
    0xc, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x0
};

void print_byte(unsigned char B)/> {
    unsigned char mask = 0x80;
    for ( ; mask; mask >>= 1)
        putchar('0' + !!(b & mask));
}

void print_row_bits(unsigned char *a) {
    for (int n = 8; n-- > 0; ) print_byte(*a++);
    putchar('\n');
}

unsigned char flip_byte(unsigned char B)/> {
    unsigned char t = 0;
    for (int n = 8; n--; b >>= 1) t = (t << 1) | (b & 1);
    return t;
}

void flip_row(unsigned char *a) {
    unsigned char t[8], *p = a;
    for (int n = 8; n--; ) t[n] = flip_byte(*p++);
    memcpy(a, t, 8);
}

int main() {
    print_row_bits(a);
    flip_row(a);
    print_row_bits(a);
    flip_row(a);
    print_row_bits(a);

// Flip all rows
//    for (int i = 0; i < sizeof a; i += 8)
//        flip_row(a + i);
    return 0;
}


Was This Post Helpful? 0
  • +
  • -

#5 wolfrose   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 20-January 16

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 01:23 PM

I'm sorry, your code didn't work because it prints hex into binary.

Anyway, I guess I have to do it manually.
Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg   User is offline

  • member icon

Reputation: 5525
  • View blog
  • Posts: 17,115
  • Joined: 25-December 09

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 01:34 PM

Quote

Anyway, I guess I have to do it manually.

Why?

It seems to me that you really don't understand what that website is actually doing with the numbers. But if the website is able to "flip" (no idea what you really mean by this term) the values then it is definitely possible to do it in a C/C++ program. But first you need to understand exactly what they are actually doing.

Jim
Was This Post Helpful? 1
  • +
  • -

#7 cardgage   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 16-August 17

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 01:57 PM

View Postwolfrose, on 01 April 2018 - 01:23 PM, said:

I'm sorry, your code didn't work because it prints hex into binary.

What? It prints out the binary representation as a demonstration that it works. It actually flips all of the bits in the given 8-byte string. If you want to print the result in hex, then just go ahead and print it in hex. What's stopping you?

#include <stdio.h>
#include <string.h>

unsigned char a[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00,
    0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00,
    0x0c, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x00
};

unsigned char flip_byte(unsigned char B)/> {
    unsigned char t = 0;
    for (int n = 8; n--; b >>= 1) t = (t << 1) | (b & 1);
    return t;
}

void flip_row(unsigned char *a) {
    unsigned char t[8], *p = a;
    for (int n = 8; n--; ) t[n] = flip_byte(*p++);
    memcpy(a, t, 8);
}

int main() {
    // Flip all rows
    for (size_t i = 0; i < sizeof a; i += 8)
        flip_row(a + i);

    for (size_t i = 0; i < sizeof a; i++) {
        printf("0x%02X, ", a[i]);
        if (i % 8 == 7) printf("\n");
    }

    return 0;
}


Was This Post Helpful? 1
  • +
  • -

#8 wolfrose   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 20-January 16

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 02:03 PM

View Postjimblumberg, on 01 April 2018 - 01:34 PM, said:

Quote

Anyway, I guess I have to do it manually.

Why?

It seems to me that you really don't understand what that website is actually doing with the numbers. But if the website is able to "flip" (no idea what you really mean by this term) the values then it is definitely possible to do it in a C/C++ program. But first you need to understand exactly what they are actually doing.

Jim


You're right! I don't know what's doing exactly, but of course there's an arithmetic operations behind the scene which do different calculations to the input data.

Yes, also you're correct of what I mean by "flip" is it horizontal or vertical. Well, I mean horizontal.

I think I just thought of an idea to flip those bits in each byte, so it's just about the location of the bit to shift it the opposite location; for example, bit0 goes to bit7, bit3 to bit4, bit1 to bit6 and so on.
Was This Post Helpful? 0
  • +
  • -

#9 wolfrose   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 20-January 16

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 01 April 2018 - 02:12 PM

View Postcardgage, on 01 April 2018 - 01:57 PM, said:

View Postwolfrose, on 01 April 2018 - 01:23 PM, said:

I'm sorry, your code didn't work because it prints hex into binary.

What? It prints out the binary representation as a demonstration that it works. It actually flips all of the bits in the given 8-byte string. If you want to print the result in hex, then just go ahead and print it in hex. What's stopping you?


I'm sorry I didn't mean to not appreciating your help! Your effort and also your next reply insisting to help me is really kind and I feel honor to communicate with engineers and enthusiasts around the world. I'm not trying to loose friends here :)

The code is of course working but didn't work for what I want, even I actually didn't explain precisely what I want and you even provided the code according to the information I declared, so really I'm sorry, It's my mistake.

As I mentioned in the above reply that I just have to flip the location of the bit.
Was This Post Helpful? 0
  • +
  • -

#10 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6293
  • View blog
  • Posts: 21,632
  • Joined: 05-May 12

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 02 April 2018 - 05:30 AM

cardgage: Please do not just dump code in response to a user's thread. This doesn't help in many ways. The first is that spoonfeeding doesn't teach the OP, letting them discover/understand things on their own is a much better approach. Second is that you just dumped the code without explaining what the code was doing. You had to do a follow up post to say what it does after the OP complained that it wasn't working. Third is this site is for community learning, not a code writing service.
Was This Post Helpful? 1
  • +
  • -

#11 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6293
  • View blog
  • Posts: 21,632
  • Joined: 05-May 12

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 02 April 2018 - 05:47 AM

It looks like wolfrose wants to mirror the bits within a byte:
0x1E      --> 0x78
0001 1110 --> 0111 1000 


as well as reverse the order of the 8 bytes.

So one brute force approach would be to simply reverse each 8 byte chunk, and then mirror the bits within the byte. I suspect that there some bit twiddling tricks in the "Hacker's Delight" book which can do these set of operations more efficiently (like shifting right into a 64 bit register while simultaneously shifting left into another register).
Was This Post Helpful? 1
  • +
  • -

#12 baavgai   User is offline

  • Dreaming Coder
  • member icon


Reputation: 7199
  • View blog
  • Posts: 15,008
  • Joined: 16-October 07

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 02 April 2018 - 07:03 AM

It's not a bit flip, but rather a reverse. Oddly, applied at both a bit and row level.

So, here's the header:
#include <stdio.h>
#include <stdint.h>

#define ROW_SIZE 8

void showBits(uint8_t);
uint8_t reverseBits(uint8_t);
void reverseBytes(uint8_t *, size_t);
void showRows(uint8_t *, size_t);
void showBytes(uint8_t *, size_t);
void applyBitReverse(uint8_t *, size_t);

void transformRows(uint8_t *, size_t);


int main(void) {
    uint8_t data[] = {
        0x0c, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x00, // "flipped": 0x0, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x78, 0x30
        0x0c, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x00, // duped, for second test
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // U+0020 (space)
        0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00,   // U+0021 (!)
    };
    const size_t data_size = sizeof(data) / sizeof(*data);

    uint8_t x = 0x0c;
    uint8_t y = reverseBits(x);
    printf("%02x %02x\n", x, y); showBits(x); printf(" "); showBits(y); printf("\n");
    printf("---------\n");

    // do first row
    printf("Inital Data:   "); showBytes(data, ROW_SIZE);
    printf("Row Reverse:   "); reverseBytes(data, ROW_SIZE); showBytes(data, ROW_SIZE);
    printf("Final Result:  "); applyBitReverse(data, ROW_SIZE); showBytes(data, ROW_SIZE);
    printf("Expect Result: 0x00 0xcc 0xcc 0xfc 0xcc 0xcc 0x78 0x30\n");
    printf("---------\n");

    // do the rest
    transformRows(data +  ROW_SIZE, data_size - ROW_SIZE);
    showRows(data, data_size);

    return 0;
}



Results:
0c 30
00001100 00110000
---------
Inital Data:   0x0c 0x1e 0x33 0x33 0x3f 0x33 0x33 0x00
Row Reverse:   0x00 0x33 0x33 0x3f 0x33 0x33 0x1e 0x0c
Final Result:  0x00 0xcc 0xcc 0xfc 0xcc 0xcc 0x78 0x30
Expect Result: 0x00 0xcc 0xcc 0xfc 0xcc 0xcc 0x78 0x30
---------
0x00 0xcc 0xcc 0xfc 0xcc 0xcc 0x78 0x30
0x00 0xcc 0xcc 0xfc 0xcc 0xcc 0x78 0x30
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x18 0x00 0x18 0x18 0x3c 0x3c 0x18



I think there's enough hints in there to get the juices flowing, if the OP is actually looking to do the work. Given the dismissal of a prior complete answer, I'm dubious at this point.

This post has been edited by baavgai: 02 April 2018 - 07:06 AM
Reason for edit:: bloody code tag

Was This Post Helpful? 1
  • +
  • -

#13 wolfrose   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 20-January 16

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 02 April 2018 - 11:49 AM

View PostSkydiver, on 02 April 2018 - 05:47 AM, said:

It looks like wolfrose wants to mirror the bits within a byte:
0x1E      --> 0x78
0001 1110 --> 0111 1000 


as well as reverse the order of the 8 bytes.

So one brute force approach would be to simply reverse each 8 byte chunk, and then mirror the bits within the byte. I suspect that there some bit twiddling tricks in the "Hacker's Delight" book which can do these set of operations more efficiently (like shifting right into a 64 bit register while simultaneously shifting left into another register).


Thank you very much for the clarification. Yes, I want to mirror the bits :^: It took me time to understand what I want :)

I managed to develop this code:
uint8_t var=0x44;

    if (var & 0x81)
        var ^= 0x81;
    if (var & 0x42)
            var ^= 0x42;
    if (var & 0x24)
            var ^= 0x24;
    if (var & 0x18)
            var ^= 0x18;

    printf("0x%.2x\n",var);


I'm also looking to optimize it more in a for loop, or just put it in a function and receives multiple bytes from an array and mirror all the bytes.
Was This Post Helpful? 0
  • +
  • -

#14 baavgai   User is offline

  • Dreaming Coder
  • member icon


Reputation: 7199
  • View blog
  • Posts: 15,008
  • Joined: 16-October 07

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 02 April 2018 - 01:04 PM

I'm at a loss as to the transformation you're after.

However, out of curiousity:
#include <stdio.h>
#include <stdint.h>

uint8_t bitsWtf(uint8_t var) {
    if (var & 0x81) { var ^= 0x81; }
    if (var & 0x42) { var ^= 0x42; }
    if (var & 0x24) { var ^= 0x24; }
    if (var & 0x18) { var ^= 0x18; }
    return var;
}
uint8_t reverseBits(uint8_t);
void showBits(uint8_t);

int main(void) {
    for (int x = 0; x < 0x100; x++) {
        uint8_t y = bitsWtf(x), z = reverseBits(x);
        printf("Orig 0x%02x ", x); showBits(x); printf(" %c=\n", (y == z) ? '=' : '!');
        printf("Fun1 0x%02x ", y); showBits(y); printf("\n");
        printf("Fun2 0x%02x ", z); showBits(z); printf("\n\n");
    }
}



Result:
Orig 0x00 00000000 ==
Fun1 0x00 00000000
Fun2 0x00 00000000

Orig 0x01 00000001 ==
Fun1 0x80 10000000
Fun2 0x80 10000000

Orig 0x02 00000010 ==
Fun1 0x40 01000000
Fun2 0x40 01000000

Orig 0x03 00000011 ==
Fun1 0xc0 11000000
Fun2 0xc0 11000000

Orig 0x04 00000100 ==
Fun1 0x20 00100000
Fun2 0x20 00100000

Orig 0x05 00000101 ==
Fun1 0xa0 10100000
Fun2 0xa0 10100000

Orig 0x06 00000110 ==
Fun1 0x60 01100000
Fun2 0x60 01100000

Orig 0x07 00000111 ==
Fun1 0xe0 11100000
Fun2 0xe0 11100000

Orig 0x08 00001000 ==
Fun1 0x10 00010000
Fun2 0x10 00010000

Orig 0x09 00001001 ==
Fun1 0x90 10010000
Fun2 0x90 10010000

Orig 0x0a 00001010 ==
Fun1 0x50 01010000
Fun2 0x50 01010000

Orig 0x0b 00001011 ==
Fun1 0xd0 11010000
Fun2 0xd0 11010000

Orig 0x0c 00001100 ==
Fun1 0x30 00110000
Fun2 0x30 00110000

Orig 0x0d 00001101 ==
Fun1 0xb0 10110000
Fun2 0xb0 10110000

Orig 0x0e 00001110 ==
Fun1 0x70 01110000
Fun2 0x70 01110000

Orig 0x0f 00001111 ==
Fun1 0xf0 11110000
Fun2 0xf0 11110000

Orig 0x10 00010000 ==
Fun1 0x08 00001000
Fun2 0x08 00001000

Orig 0x11 00010001 ==
Fun1 0x88 10001000
Fun2 0x88 10001000

Orig 0x12 00010010 ==
Fun1 0x48 01001000
Fun2 0x48 01001000

Orig 0x13 00010011 ==
Fun1 0xc8 11001000
Fun2 0xc8 11001000

Orig 0x14 00010100 ==
Fun1 0x28 00101000
Fun2 0x28 00101000

Orig 0x15 00010101 ==
Fun1 0xa8 10101000
Fun2 0xa8 10101000

Orig 0x16 00010110 ==
Fun1 0x68 01101000
Fun2 0x68 01101000

Orig 0x17 00010111 ==
Fun1 0xe8 11101000
Fun2 0xe8 11101000

Orig 0x18 00011000 !=
Fun1 0x00 00000000
Fun2 0x18 00011000

Orig 0x19 00011001 !=
Fun1 0x80 10000000
Fun2 0x98 10011000

Orig 0x1a 00011010 !=
Fun1 0x40 01000000
Fun2 0x58 01011000

Orig 0x1b 00011011 !=
Fun1 0xc0 11000000
Fun2 0xd8 11011000

Orig 0x1c 00011100 !=
Fun1 0x20 00100000
Fun2 0x38 00111000

Orig 0x1d 00011101 !=
Fun1 0xa0 10100000
Fun2 0xb8 10111000

Orig 0x1e 00011110 !=
Fun1 0x60 01100000
Fun2 0x78 01111000

Orig 0x1f 00011111 !=
Fun1 0xe0 11100000
Fun2 0xf8 11111000

Orig 0x20 00100000 ==
Fun1 0x04 00000100
Fun2 0x04 00000100

Orig 0x21 00100001 ==
Fun1 0x84 10000100
Fun2 0x84 10000100

Orig 0x22 00100010 ==
Fun1 0x44 01000100
Fun2 0x44 01000100

Orig 0x23 00100011 ==
Fun1 0xc4 11000100
Fun2 0xc4 11000100

Orig 0x24 00100100 !=
Fun1 0x00 00000000
Fun2 0x24 00100100

Orig 0x25 00100101 !=
Fun1 0x80 10000000
Fun2 0xa4 10100100

Orig 0x26 00100110 !=
Fun1 0x40 01000000
Fun2 0x64 01100100

Orig 0x27 00100111 !=
Fun1 0xc0 11000000
Fun2 0xe4 11100100

Orig 0x28 00101000 ==
Fun1 0x14 00010100
Fun2 0x14 00010100

Orig 0x29 00101001 ==
Fun1 0x94 10010100
Fun2 0x94 10010100

Orig 0x2a 00101010 ==
Fun1 0x54 01010100
Fun2 0x54 01010100

Orig 0x2b 00101011 ==
Fun1 0xd4 11010100
Fun2 0xd4 11010100

Orig 0x2c 00101100 !=
Fun1 0x10 00010000
Fun2 0x34 00110100

Orig 0x2d 00101101 !=
Fun1 0x90 10010000
Fun2 0xb4 10110100

Orig 0x2e 00101110 !=
Fun1 0x50 01010000
Fun2 0x74 01110100

Orig 0x2f 00101111 !=
Fun1 0xd0 11010000
Fun2 0xf4 11110100

Orig 0x30 00110000 ==
Fun1 0x0c 00001100
Fun2 0x0c 00001100

Orig 0x31 00110001 ==
Fun1 0x8c 10001100
Fun2 0x8c 10001100

Orig 0x32 00110010 ==
Fun1 0x4c 01001100
Fun2 0x4c 01001100

Orig 0x33 00110011 ==
Fun1 0xcc 11001100
Fun2 0xcc 11001100

Orig 0x34 00110100 !=
Fun1 0x08 00001000
Fun2 0x2c 00101100

Orig 0x35 00110101 !=
Fun1 0x88 10001000
Fun2 0xac 10101100

Orig 0x36 00110110 !=
Fun1 0x48 01001000
Fun2 0x6c 01101100

Orig 0x37 00110111 !=
Fun1 0xc8 11001000
Fun2 0xec 11101100

Orig 0x38 00111000 !=
Fun1 0x04 00000100
Fun2 0x1c 00011100

Orig 0x39 00111001 !=
Fun1 0x84 10000100
Fun2 0x9c 10011100

Orig 0x3a 00111010 !=
Fun1 0x44 01000100
Fun2 0x5c 01011100

Orig 0x3b 00111011 !=
Fun1 0xc4 11000100
Fun2 0xdc 11011100

Orig 0x3c 00111100 !=
Fun1 0x00 00000000
Fun2 0x3c 00111100

Orig 0x3d 00111101 !=
Fun1 0x80 10000000
Fun2 0xbc 10111100

Orig 0x3e 00111110 !=
Fun1 0x40 01000000
Fun2 0x7c 01111100

Orig 0x3f 00111111 !=
Fun1 0xc0 11000000
Fun2 0xfc 11111100

Orig 0x40 01000000 ==
Fun1 0x02 00000010
Fun2 0x02 00000010

Orig 0x41 01000001 ==
Fun1 0x82 10000010
Fun2 0x82 10000010

Orig 0x42 01000010 !=
Fun1 0x00 00000000
Fun2 0x42 01000010

Orig 0x43 01000011 !=
Fun1 0x80 10000000
Fun2 0xc2 11000010

Orig 0x44 01000100 ==
Fun1 0x22 00100010
Fun2 0x22 00100010

Orig 0x45 01000101 ==
Fun1 0xa2 10100010
Fun2 0xa2 10100010

Orig 0x46 01000110 !=
Fun1 0x20 00100000
Fun2 0x62 01100010

Orig 0x47 01000111 !=
Fun1 0xa0 10100000
Fun2 0xe2 11100010

Orig 0x48 01001000 ==
Fun1 0x12 00010010
Fun2 0x12 00010010

Orig 0x49 01001001 ==
Fun1 0x92 10010010
Fun2 0x92 10010010

Orig 0x4a 01001010 !=
Fun1 0x10 00010000
Fun2 0x52 01010010

Orig 0x4b 01001011 !=
Fun1 0x90 10010000
Fun2 0xd2 11010010

Orig 0x4c 01001100 ==
Fun1 0x32 00110010
Fun2 0x32 00110010

Orig 0x4d 01001101 ==
Fun1 0xb2 10110010
Fun2 0xb2 10110010

Orig 0x4e 01001110 !=
Fun1 0x30 00110000
Fun2 0x72 01110010

Orig 0x4f 01001111 !=
Fun1 0xb0 10110000
Fun2 0xf2 11110010

Orig 0x50 01010000 ==
Fun1 0x0a 00001010
Fun2 0x0a 00001010

Orig 0x51 01010001 ==
Fun1 0x8a 10001010
Fun2 0x8a 10001010

Orig 0x52 01010010 !=
Fun1 0x08 00001000
Fun2 0x4a 01001010

Orig 0x53 01010011 !=
Fun1 0x88 10001000
Fun2 0xca 11001010

Orig 0x54 01010100 ==
Fun1 0x2a 00101010
Fun2 0x2a 00101010

Orig 0x55 01010101 ==
Fun1 0xaa 10101010
Fun2 0xaa 10101010

Orig 0x56 01010110 !=
Fun1 0x28 00101000
Fun2 0x6a 01101010

Orig 0x57 01010111 !=
Fun1 0xa8 10101000
Fun2 0xea 11101010

Orig 0x58 01011000 !=
Fun1 0x02 00000010
Fun2 0x1a 00011010

Orig 0x59 01011001 !=
Fun1 0x82 10000010
Fun2 0x9a 10011010

Orig 0x5a 01011010 !=
Fun1 0x00 00000000
Fun2 0x5a 01011010

Orig 0x5b 01011011 !=
Fun1 0x80 10000000
Fun2 0xda 11011010

Orig 0x5c 01011100 !=
Fun1 0x22 00100010
Fun2 0x3a 00111010

Orig 0x5d 01011101 !=
Fun1 0xa2 10100010
Fun2 0xba 10111010

Orig 0x5e 01011110 !=
Fun1 0x20 00100000
Fun2 0x7a 01111010

Orig 0x5f 01011111 !=
Fun1 0xa0 10100000
Fun2 0xfa 11111010

Orig 0x60 01100000 ==
Fun1 0x06 00000110
Fun2 0x06 00000110

Orig 0x61 01100001 ==
Fun1 0x86 10000110
Fun2 0x86 10000110

Orig 0x62 01100010 !=
Fun1 0x04 00000100
Fun2 0x46 01000110

Orig 0x63 01100011 !=
Fun1 0x84 10000100
Fun2 0xc6 11000110

Orig 0x64 01100100 !=
Fun1 0x02 00000010
Fun2 0x26 00100110

Orig 0x65 01100101 !=
Fun1 0x82 10000010
Fun2 0xa6 10100110

Orig 0x66 01100110 !=
Fun1 0x00 00000000
Fun2 0x66 01100110

Orig 0x67 01100111 !=
Fun1 0x80 10000000
Fun2 0xe6 11100110

Orig 0x68 01101000 ==
Fun1 0x16 00010110
Fun2 0x16 00010110

Orig 0x69 01101001 ==
Fun1 0x96 10010110
Fun2 0x96 10010110

Orig 0x6a 01101010 !=
Fun1 0x14 00010100
Fun2 0x56 01010110

Orig 0x6b 01101011 !=
Fun1 0x94 10010100
Fun2 0xd6 11010110

Orig 0x6c 01101100 !=
Fun1 0x12 00010010
Fun2 0x36 00110110

Orig 0x6d 01101101 !=
Fun1 0x92 10010010
Fun2 0xb6 10110110

Orig 0x6e 01101110 !=
Fun1 0x10 00010000
Fun2 0x76 01110110

Orig 0x6f 01101111 !=
Fun1 0x90 10010000
Fun2 0xf6 11110110

Orig 0x70 01110000 ==
Fun1 0x0e 00001110
Fun2 0x0e 00001110

Orig 0x71 01110001 ==
Fun1 0x8e 10001110
Fun2 0x8e 10001110

Orig 0x72 01110010 !=
Fun1 0x0c 00001100
Fun2 0x4e 01001110

Orig 0x73 01110011 !=
Fun1 0x8c 10001100
Fun2 0xce 11001110

Orig 0x74 01110100 !=
Fun1 0x0a 00001010
Fun2 0x2e 00101110

Orig 0x75 01110101 !=
Fun1 0x8a 10001010
Fun2 0xae 10101110

Orig 0x76 01110110 !=
Fun1 0x08 00001000
Fun2 0x6e 01101110

Orig 0x77 01110111 !=
Fun1 0x88 10001000
Fun2 0xee 11101110

Orig 0x78 01111000 !=
Fun1 0x06 00000110
Fun2 0x1e 00011110

Orig 0x79 01111001 !=
Fun1 0x86 10000110
Fun2 0x9e 10011110

Orig 0x7a 01111010 !=
Fun1 0x04 00000100
Fun2 0x5e 01011110

Orig 0x7b 01111011 !=
Fun1 0x84 10000100
Fun2 0xde 11011110

Orig 0x7c 01111100 !=
Fun1 0x02 00000010
Fun2 0x3e 00111110

Orig 0x7d 01111101 !=
Fun1 0x82 10000010
Fun2 0xbe 10111110

Orig 0x7e 01111110 !=
Fun1 0x00 00000000
Fun2 0x7e 01111110

Orig 0x7f 01111111 !=
Fun1 0x80 10000000
Fun2 0xfe 11111110

Orig 0x80 10000000 ==
Fun1 0x01 00000001
Fun2 0x01 00000001

Orig 0x81 10000001 !=
Fun1 0x00 00000000
Fun2 0x81 10000001

Orig 0x82 10000010 ==
Fun1 0x41 01000001
Fun2 0x41 01000001

Orig 0x83 10000011 !=
Fun1 0x40 01000000
Fun2 0xc1 11000001

Orig 0x84 10000100 ==
Fun1 0x21 00100001
Fun2 0x21 00100001

Orig 0x85 10000101 !=
Fun1 0x20 00100000
Fun2 0xa1 10100001

Orig 0x86 10000110 ==
Fun1 0x61 01100001
Fun2 0x61 01100001

Orig 0x87 10000111 !=
Fun1 0x60 01100000
Fun2 0xe1 11100001

Orig 0x88 10001000 ==
Fun1 0x11 00010001
Fun2 0x11 00010001

Orig 0x89 10001001 !=
Fun1 0x10 00010000
Fun2 0x91 10010001

Orig 0x8a 10001010 ==
Fun1 0x51 01010001
Fun2 0x51 01010001

Orig 0x8b 10001011 !=
Fun1 0x50 01010000
Fun2 0xd1 11010001

Orig 0x8c 10001100 ==
Fun1 0x31 00110001
Fun2 0x31 00110001

Orig 0x8d 10001101 !=
Fun1 0x30 00110000
Fun2 0xb1 10110001

Orig 0x8e 10001110 ==
Fun1 0x71 01110001
Fun2 0x71 01110001

Orig 0x8f 10001111 !=
Fun1 0x70 01110000
Fun2 0xf1 11110001

Orig 0x90 10010000 ==
Fun1 0x09 00001001
Fun2 0x09 00001001

Orig 0x91 10010001 !=
Fun1 0x08 00001000
Fun2 0x89 10001001

Orig 0x92 10010010 ==
Fun1 0x49 01001001
Fun2 0x49 01001001

Orig 0x93 10010011 !=
Fun1 0x48 01001000
Fun2 0xc9 11001001

Orig 0x94 10010100 ==
Fun1 0x29 00101001
Fun2 0x29 00101001

Orig 0x95 10010101 !=
Fun1 0x28 00101000
Fun2 0xa9 10101001

Orig 0x96 10010110 ==
Fun1 0x69 01101001
Fun2 0x69 01101001

Orig 0x97 10010111 !=
Fun1 0x68 01101000
Fun2 0xe9 11101001

Orig 0x98 10011000 !=
Fun1 0x01 00000001
Fun2 0x19 00011001

Orig 0x99 10011001 !=
Fun1 0x00 00000000
Fun2 0x99 10011001

Orig 0x9a 10011010 !=
Fun1 0x41 01000001
Fun2 0x59 01011001

Orig 0x9b 10011011 !=
Fun1 0x40 01000000
Fun2 0xd9 11011001

Orig 0x9c 10011100 !=
Fun1 0x21 00100001
Fun2 0x39 00111001

Orig 0x9d 10011101 !=
Fun1 0x20 00100000
Fun2 0xb9 10111001

Orig 0x9e 10011110 !=
Fun1 0x61 01100001
Fun2 0x79 01111001

Orig 0x9f 10011111 !=
Fun1 0x60 01100000
Fun2 0xf9 11111001

Orig 0xa0 10100000 ==
Fun1 0x05 00000101
Fun2 0x05 00000101

Orig 0xa1 10100001 !=
Fun1 0x04 00000100
Fun2 0x85 10000101

Orig 0xa2 10100010 ==
Fun1 0x45 01000101
Fun2 0x45 01000101

Orig 0xa3 10100011 !=
Fun1 0x44 01000100
Fun2 0xc5 11000101

Orig 0xa4 10100100 !=
Fun1 0x01 00000001
Fun2 0x25 00100101

Orig 0xa5 10100101 !=
Fun1 0x00 00000000
Fun2 0xa5 10100101

Orig 0xa6 10100110 !=
Fun1 0x41 01000001
Fun2 0x65 01100101

Orig 0xa7 10100111 !=
Fun1 0x40 01000000
Fun2 0xe5 11100101

Orig 0xa8 10101000 ==
Fun1 0x15 00010101
Fun2 0x15 00010101

Orig 0xa9 10101001 !=
Fun1 0x14 00010100
Fun2 0x95 10010101

Orig 0xaa 10101010 ==
Fun1 0x55 01010101
Fun2 0x55 01010101

Orig 0xab 10101011 !=
Fun1 0x54 01010100
Fun2 0xd5 11010101

Orig 0xac 10101100 !=
Fun1 0x11 00010001
Fun2 0x35 00110101

Orig 0xad 10101101 !=
Fun1 0x10 00010000
Fun2 0xb5 10110101

Orig 0xae 10101110 !=
Fun1 0x51 01010001
Fun2 0x75 01110101

Orig 0xaf 10101111 !=
Fun1 0x50 01010000
Fun2 0xf5 11110101

Orig 0xb0 10110000 ==
Fun1 0x0d 00001101
Fun2 0x0d 00001101

Orig 0xb1 10110001 !=
Fun1 0x0c 00001100
Fun2 0x8d 10001101

Orig 0xb2 10110010 ==
Fun1 0x4d 01001101
Fun2 0x4d 01001101

Orig 0xb3 10110011 !=
Fun1 0x4c 01001100
Fun2 0xcd 11001101

Orig 0xb4 10110100 !=
Fun1 0x09 00001001
Fun2 0x2d 00101101

Orig 0xb5 10110101 !=
Fun1 0x08 00001000
Fun2 0xad 10101101

Orig 0xb6 10110110 !=
Fun1 0x49 01001001
Fun2 0x6d 01101101

Orig 0xb7 10110111 !=
Fun1 0x48 01001000
Fun2 0xed 11101101

Orig 0xb8 10111000 !=
Fun1 0x05 00000101
Fun2 0x1d 00011101

Orig 0xb9 10111001 !=
Fun1 0x04 00000100
Fun2 0x9d 10011101

Orig 0xba 10111010 !=
Fun1 0x45 01000101
Fun2 0x5d 01011101

Orig 0xbb 10111011 !=
Fun1 0x44 01000100
Fun2 0xdd 11011101

Orig 0xbc 10111100 !=
Fun1 0x01 00000001
Fun2 0x3d 00111101

Orig 0xbd 10111101 !=
Fun1 0x00 00000000
Fun2 0xbd 10111101

Orig 0xbe 10111110 !=
Fun1 0x41 01000001
Fun2 0x7d 01111101

Orig 0xbf 10111111 !=
Fun1 0x40 01000000
Fun2 0xfd 11111101

Orig 0xc0 11000000 ==
Fun1 0x03 00000011
Fun2 0x03 00000011

Orig 0xc1 11000001 !=
Fun1 0x02 00000010
Fun2 0x83 10000011

Orig 0xc2 11000010 !=
Fun1 0x01 00000001
Fun2 0x43 01000011

Orig 0xc3 11000011 !=
Fun1 0x00 00000000
Fun2 0xc3 11000011

Orig 0xc4 11000100 ==
Fun1 0x23 00100011
Fun2 0x23 00100011

Orig 0xc5 11000101 !=
Fun1 0x22 00100010
Fun2 0xa3 10100011

Orig 0xc6 11000110 !=
Fun1 0x21 00100001
Fun2 0x63 01100011

Orig 0xc7 11000111 !=
Fun1 0x20 00100000
Fun2 0xe3 11100011

Orig 0xc8 11001000 ==
Fun1 0x13 00010011
Fun2 0x13 00010011

Orig 0xc9 11001001 !=
Fun1 0x12 00010010
Fun2 0x93 10010011

Orig 0xca 11001010 !=
Fun1 0x11 00010001
Fun2 0x53 01010011

Orig 0xcb 11001011 !=
Fun1 0x10 00010000
Fun2 0xd3 11010011

Orig 0xcc 11001100 ==
Fun1 0x33 00110011
Fun2 0x33 00110011

Orig 0xcd 11001101 !=
Fun1 0x32 00110010
Fun2 0xb3 10110011

Orig 0xce 11001110 !=
Fun1 0x31 00110001
Fun2 0x73 01110011

Orig 0xcf 11001111 !=
Fun1 0x30 00110000
Fun2 0xf3 11110011

Orig 0xd0 11010000 ==
Fun1 0x0b 00001011
Fun2 0x0b 00001011

Orig 0xd1 11010001 !=
Fun1 0x0a 00001010
Fun2 0x8b 10001011

Orig 0xd2 11010010 !=
Fun1 0x09 00001001
Fun2 0x4b 01001011

Orig 0xd3 11010011 !=
Fun1 0x08 00001000
Fun2 0xcb 11001011

Orig 0xd4 11010100 ==
Fun1 0x2b 00101011
Fun2 0x2b 00101011

Orig 0xd5 11010101 !=
Fun1 0x2a 00101010
Fun2 0xab 10101011

Orig 0xd6 11010110 !=
Fun1 0x29 00101001
Fun2 0x6b 01101011

Orig 0xd7 11010111 !=
Fun1 0x28 00101000
Fun2 0xeb 11101011

Orig 0xd8 11011000 !=
Fun1 0x03 00000011
Fun2 0x1b 00011011

Orig 0xd9 11011001 !=
Fun1 0x02 00000010
Fun2 0x9b 10011011

Orig 0xda 11011010 !=
Fun1 0x01 00000001
Fun2 0x5b 01011011

Orig 0xdb 11011011 !=
Fun1 0x00 00000000
Fun2 0xdb 11011011

Orig 0xdc 11011100 !=
Fun1 0x23 00100011
Fun2 0x3b 00111011

Orig 0xdd 11011101 !=
Fun1 0x22 00100010
Fun2 0xbb 10111011

Orig 0xde 11011110 !=
Fun1 0x21 00100001
Fun2 0x7b 01111011

Orig 0xdf 11011111 !=
Fun1 0x20 00100000
Fun2 0xfb 11111011

Orig 0xe0 11100000 ==
Fun1 0x07 00000111
Fun2 0x07 00000111

Orig 0xe1 11100001 !=
Fun1 0x06 00000110
Fun2 0x87 10000111

Orig 0xe2 11100010 !=
Fun1 0x05 00000101
Fun2 0x47 01000111

Orig 0xe3 11100011 !=
Fun1 0x04 00000100
Fun2 0xc7 11000111

Orig 0xe4 11100100 !=
Fun1 0x03 00000011
Fun2 0x27 00100111

Orig 0xe5 11100101 !=
Fun1 0x02 00000010
Fun2 0xa7 10100111

Orig 0xe6 11100110 !=
Fun1 0x01 00000001
Fun2 0x67 01100111

Orig 0xe7 11100111 !=
Fun1 0x00 00000000
Fun2 0xe7 11100111

Orig 0xe8 11101000 ==
Fun1 0x17 00010111
Fun2 0x17 00010111

Orig 0xe9 11101001 !=
Fun1 0x16 00010110
Fun2 0x97 10010111

Orig 0xea 11101010 !=
Fun1 0x15 00010101
Fun2 0x57 01010111

Orig 0xeb 11101011 !=
Fun1 0x14 00010100
Fun2 0xd7 11010111

Orig 0xec 11101100 !=
Fun1 0x13 00010011
Fun2 0x37 00110111

Orig 0xed 11101101 !=
Fun1 0x12 00010010
Fun2 0xb7 10110111

Orig 0xee 11101110 !=
Fun1 0x11 00010001
Fun2 0x77 01110111

Orig 0xef 11101111 !=
Fun1 0x10 00010000
Fun2 0xf7 11110111

Orig 0xf0 11110000 ==
Fun1 0x0f 00001111
Fun2 0x0f 00001111

Orig 0xf1 11110001 !=
Fun1 0x0e 00001110
Fun2 0x8f 10001111

Orig 0xf2 11110010 !=
Fun1 0x0d 00001101
Fun2 0x4f 01001111

Orig 0xf3 11110011 !=
Fun1 0x0c 00001100
Fun2 0xcf 11001111

Orig 0xf4 11110100 !=
Fun1 0x0b 00001011
Fun2 0x2f 00101111

Orig 0xf5 11110101 !=
Fun1 0x0a 00001010
Fun2 0xaf 10101111

Orig 0xf6 11110110 !=
Fun1 0x09 00001001
Fun2 0x6f 01101111

Orig 0xf7 11110111 !=
Fun1 0x08 00001000
Fun2 0xef 11101111

Orig 0xf8 11111000 !=
Fun1 0x07 00000111
Fun2 0x1f 00011111

Orig 0xf9 11111001 !=
Fun1 0x06 00000110
Fun2 0x9f 10011111

Orig 0xfa 11111010 !=
Fun1 0x05 00000101
Fun2 0x5f 01011111

Orig 0xfb 11111011 !=
Fun1 0x04 00000100
Fun2 0xdf 11011111

Orig 0xfc 11111100 !=
Fun1 0x03 00000011
Fun2 0x3f 00111111

Orig 0xfd 11111101 !=
Fun1 0x02 00000010
Fun2 0xbf 10111111

Orig 0xfe 11111110 !=
Fun1 0x01 00000001
Fun2 0x7f 01111111

Orig 0xff 11111111 !=
Fun1 0x00 00000000
Fun2 0xff 11111111



You know, if it's only 255 values, you could just go with a lookup table. Indeed, if you're doing this in something computationally intensive, you probably should.

This post has been edited by baavgai: 02 April 2018 - 01:05 PM
Reason for edit:: format bad

Was This Post Helpful? 1
  • +
  • -

#15 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6293
  • View blog
  • Posts: 21,632
  • Joined: 05-May 12

Re: Want to flip the value of hex data on 8x8 Led Matrix Value Calculator

Posted 02 April 2018 - 01:16 PM

I think that baavgai and bb8 will have infinite delight in seeing the bit reversal code here, and then adapting it for 8 bits, or better yet, 64 bits.
Was This Post Helpful? 2
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »