/*********************************************************************************
*  _   _                _______           _                                _     *
* | \ | |              | |  _  \         (_)                              | |    *
* |  \| | _____   _____| | | | |_____   ___  ___ ___  ___   ___ ___  _   _| | __ *
* | . ` |/ _ \ \ / / _ \ | | | / _ \ \ / / |/ __/ _ \/ __| / __/ _ \| | | | |/ / *
* | |\  | (_) \ V /  __/ | |/ /  __/\ V /| | (_|  __/\__ \| (_| (_) | |_| |   <  *
* \_| \_/\___/ \_/ \___|_|___/ \___| \_/ |_|\___\___||___(_)___\___(_)__,_|_|\_\ *
*                                                                                *
* Transpose function                     JST Lawrence.                           *
*                                                                                *
* Purpose: Swap eight 3-byte blocks starting at the given address.               *
*                                                                                *
* 15-May-2024 V1.0 JSTL Written.                                                 *
*                                                                                *
*                                                                                *
*********************************************************************************/
/*********************************************************************************
*                                                                                *
* Transpose() - swaps eight 3-byte blocks of LED data                            *
*                                                                                *
*********************************************************************************/
void Transpose(int StartingAt)
{
// Lo is the starting address of the first 3-byte block
// Hi is the starting address of the last 3-byte block
  int Lo=StartingAt,Hi=Lo+21;

// Buffer for temporary data
  unsigned char Saved[3];

// Transpose blocks: 1st and 8th, 2nd and 7th, 3rd and 6th, 4th and 5th
  for(int i=0;i<4;i++)
  {
    memcpy(Saved,Memory+Lo,3);
    memcpy(Memory+Lo,Memory+Hi,3);
    memcpy(Memory+Hi,Saved,3);
    Lo=Lo+3;
    Hi=Hi-3;
  }
}
