Treehouse Mbed Team / Mbed 2 deprecated APS_1U5x

Dependencies:   mbed

src/lut.cpp

Committer:
mfwic
Date:
2018-12-01
Revision:
5:09be5bbb5020
Parent:
4:db38665c3727
Child:
6:39442d493098

File content as of revision 5:09be5bbb5020:

//-------------------------------------------------------------------------------
// 
//  Treehouse Designs Inc.
//  Colorado Springs, Colorado
// 
//  Copyright (c) 2016 by Treehouse Designs Inc. 
//  Copyright (c) 2018 by Agility Power Systems Inc. 
// 
//  This code is the property of Treehouse Designs, Inc. (Treehouse) and
//  Agility Power Systems Inc. (Agility) and may not be redistributed
//  in any form without prior written permission from 
//  both copyright holders, Treehouse and Agility.
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
//   
//-------------------------------------------------------------------------------
// 
//  REVISION HISTORY:
//  
//   $Author: $
//   $Rev: $
//   $Date: $
//   $URL: $
// 
//-------------------------------------------------------------------------------

#include "mbed.h"
#include "stdint.h"
#include "lut.h"

//unsigned int binCode[6];

#define MAX_LUT_ENTRIES 1024

uint8_t binC[MAX_LUT_ENTRIES]{ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
uint8_t thermC[MAX_LUT_ENTRIES]{ 0, 0, 1, 1, 2, 2, 3, 3, 4, 5};

void dec2bin(int dec){
   
   int k;
   int n=5;
   
   for (int c = 5; c >= 0; c--)
   {
      k = dec >> c;
 
      if (k & 1)
         binCode[n] = 1;
      else
         binCode[n] = 0;
         
      n--;
   }
}


void dec2therm(int dec){
 
   for (int i = 0; i <= 16; i++)
   {
      thermCode[i] = 0;
   }
   
   for (int i = 0; i <= dec; i++)
   {
      thermCode[i] = 1;
   }

}

void getLUTcode(int row){
    
    dec2bin(binC[row]);
    dec2therm(thermC[row]);

}