Skip to content
Snippets Groups Projects
Select Git revision
  • 4307d721aa60bb336837e1bbaf443d0b653a5ae8
  • master default protected
  • 1.3.1
  • 1.3.0
  • 1.2.0
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • 1.1.0
  • 1.0.19
  • 1.0.18
  • 1.0.17
  • 1.0.16
  • 1.0.15
  • 1.0.14
  • 1.0.13
  • 1.0.12
  • 1.0.10
  • 1.0.9
  • 1.0.8
22 results

Header.js

Blame
  • Forked from KSZK / DevTeam / kszkepzes / old / kszkepzes-frontend
    Source project has a limited visibility.
    spiframe.cpp 1.42 KiB
    #include "spiframe.h"
    
    bool SpiFrame::LedCoordToPixel(const MxFrame &mxframe, int bitpos,
                                   int colorbit, enum Color color, int column)
    {
        int y = 2*bitpos;
        int x = column;
        if (column >= 32)
        {
            x = 63 - column;
            y = bitpos + 1;
        }
    
    
        if (color == RED)
        {
            return mxframe.pixels[x][y].red() & (1 << colorbit);
        }
        else if (color == GREEN)
        {
            return mxframe.pixels[x][y].green() & (1 << colorbit);
        }
        else if (color == BLUE)
        {
            return mxframe.pixels[x][y].blue() & (1 << colorbit);
        }
        return false;
    }
    
    SpiFrame::SpiFrame()
    {
    
    }
    
    SpiFrame::SpiFrame(const MxFrame& mxframe)
    {
        this->length = mxframe.length;
        for (int i = 0; i < 64*24; i++) {
            data[i] = 0;
        }
        for (int column = 0; column < 64; column++) {
            for (int bitpos = 0; bitpos < 13; bitpos++) {
                for (int colorbit = 0; colorbit < 8; colorbit++) {
                    data[column * 24 + colorbit] |=
                            (LedCoordToPixel(mxframe, bitpos, colorbit, RED, column) ? 1 : 0) << bitpos;
                    data[column * 24 + colorbit + 8] |=
                            (LedCoordToPixel(mxframe, bitpos, colorbit, GREEN, column) ? 1 : 0) << bitpos;
                    data[column * 24 + colorbit + 16] |=
                            (LedCoordToPixel(mxframe, bitpos, colorbit, BLUE, column) ? 1 : 0) << bitpos;
                }
            }
        }
    
    }