cyberjax

Members
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About cyberjax

  • Rank
    Newbie

Profile Information

  • Gender
  1. SmartMatrix code puzzling me.

    I still can't see the how the offset is accounted for.
  2. I've been all through the SmartMatrix sketch and circuit. I believe I understand every line of code except for the impact soff has on the Wishbone port. See code below. First. why does it start with 32*128? Looking at the VHDL associated with the circuit, it appears to have no impact at all. Second, why is it incremented by 128 for every increment of y instead of 32? At first I thought that it was to adjust for 4 addresses for every 32 bit word, but the REGISTER macro adjusts for that by shifting the offset parameter by 2; I can't see where the gap in addresses are accounted for in the VHDL void SmartMatrix::apply(void) { uint8_t r,g,b,brightness; uint16_t temp0red,temp0green,temp0blue,temp1red,temp1green,temp1blue; bool bHasForeground = hasForeground; bool bHasCC = SmartMatrix::_ccmode != ccNone; int x,y; unsigned offset = 32*128; unsigned soff = offset; rgb24 *pix = &currentDrawBufferPtr[0][0]; rgb24 tempPixel0; for (y=0;y<MATRIX_HEIGHT;y++) { for (x=0;x<MATRIX_WIDTH;x++) { brightness = dimmingFactor; /* if (bHasForeground && getForegroundPixel(x, y, &tempPixel0)) { if(bHasCC) { // load foreground pixel with color correction r = colorCorrection(tempPixel0.red); g = colorCorrection(tempPixel0.green); b = colorCorrection(tempPixel0.blue); } else { // load foreground pixel without color correction r = tempPixel0.red; g = tempPixel0.green; b = tempPixel0.blue; } } else { if(bHasCC) { // load background pixel with color correction r = backgroundColorCorrection(pix->red); g = backgroundColorCorrection(pix->green); b = backgroundColorCorrection(pix->blue); } else { // load background pixel without color correction r = pix->red; g = pix->green; b = pix->blue; } } */ if (bHasForeground && getForegroundPixel(x, y, &tempPixel0)) { r = tempPixel0.red; g = tempPixel0.green; b = tempPixel0.blue; } else { r = pix->red; g = pix->green; b = pix->blue; } r = ((unsigned)r * brightness)>>8; g = ((unsigned)g * brightness)>>8; b = ((unsigned)b * brightness)>>8; unsigned v = ((unsigned)r<<16) + ((unsigned)g<<8) + ((unsigned)b); REGISTER(IO_SLOT(9),soff + x) = v; pix++; } soff+=128; handleBufferSwap(); handleForegroundDrawingCopy(); calculateBackgroundLUT(); updateForeground(); } }