rjbatista / tm1638-library

Automatically exported from code.google.com/p/tm1638-library
141 stars 76 forks source link

TM1638QYF has swapped first and second four positions on display #36

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Any output to display.

What is the expected output? What do you see instead?
Expected: "01234567"
Reality: "45670123"

What version of the product are you using? On what operating system?
library version: 2.2.0

To solve this problem change following code in TM1638QYF.cpp in function 
TM1638QYF::setDisplay:

change line:
    sendData(i << 1, val);
... to:
    sendData(i << 1, ((val & 0x0F) << 4) | ((val & 0xF0) >> 4)); // swap Hi-Lo nibble

Original issue reported on code.google.com by jiri.sut...@gmail.com on 26 Jul 2015 at 6:23

MyIgel commented 7 years ago

@rjbatista I have this problem too, could you fix it please?

MyIgel commented 7 years ago

Workaround:

/**
 * Fix for https://github.com/rjbatista/tm1638-library/issues/36
 */

#include <TM1638QYF.h>

class TM1638QYFS : public TM1638QYF
{
    public:
        TM1638QYFS(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay = true, byte intensity = 7)
          : TM1638QYF(dataPin, clockPin, strobePin, activateDisplay, intensity)
        {
            // Nothing to do
        }

    protected:
        virtual void sendData(byte address, byte data)
        {
            TM1638QYF::sendData(address, ((data & 0x0F) << 4) | ((data & 0xF0) >> 4)); // swap Hi-Lo nibble
        }
};
rjbatista commented 7 years ago

My TM1638QYF works correctly without this swap, so I'm guessing it's a manufacture "change".

I'll try to support both versions with compile flags as soon as I find a bit of free time!