Treehouse Mbed Team / Mbed 2 deprecated APS_1U5x

Dependencies:   mbed

Revision:
25:8bcc8bea0e31
Parent:
22:2c37ac12746e
Child:
27:650cffb6c8ff
--- a/src/lut.cpp	Fri Jan 18 20:17:55 2019 +0000
+++ b/src/lut.cpp	Sun Jan 20 16:56:52 2019 +0000
@@ -34,22 +34,149 @@
 unsigned int binCode[WEIGHT_BIN_WIDTH+1];
 unsigned int thermCode[BOARDS_THERMCODE_WIDTH+1];
 
+#include "lut_data_en_v1p5_1.h"
+#include "lut_data_slot_v1p5_1.h"
 
-#include "lut_data_en_v1p3.h"
-#include "lut_data_slot_v1p3.h"
+#include "lut_data_en_v1p5_2.h"
+#include "lut_data_slot_v1p5_2.h"
+
+#include "lut_data_en_v1p5_3.h"
+#include "lut_data_slot_v1p5_3.h"
+
+#include "lut_data_en_v1p5_12.h"
+#include "lut_data_slot_v1p5_12.h"
+
+#include "lut_data_en_v1p5_13.h"
+#include "lut_data_slot_v1p5_13.h"
+
+/*******************************************************************************
+getLUT_binCodeArray - gets output codes from LUT using row reference.
+*******************************************************************************/
+void getLUT_binCodeArray(unsigned short row){
+    switch(max_boards) {
+        case 1  :
+            if(row<MAX_LUT_ENTRIES_1){
+                for(unsigned int b=0;b<max_boards;b++){
+                    bCodeRow[b] = binC_1[row];
+                }
+            }else{
+                for(unsigned int b=0;b<max_boards;b++){
+                    bCodeRow[b] = binC_1[MAX_LUT_ENTRIES_1-1];
+                }
+            }
+            break;
+        case 2  :
+            if(row<MAX_LUT_ENTRIES_2){
+                for(unsigned int b=0;b<max_boards;b++){
+                    bCodeRow[b] = binC_2[row][b];
+                }
+            }else{
+                for(unsigned int b=0;b<max_boards;b++){
+                    bCodeRow[b] = binC_2[MAX_LUT_ENTRIES_2-1][b];
+                }
+            }
+            break;
+        case 3  :
+            if(row<MAX_LUT_ENTRIES_3){
+                for(unsigned int b=0;b<max_boards;b++){
+                    bCodeRow[b] = binC_3[row][b];
+                }
+            }else{
+                for(unsigned int b=0;b<max_boards;b++){
+                    bCodeRow[b] = binC_3[MAX_LUT_ENTRIES_3-1][b];
+                }
+            }
+            break;
+        default :
+            if(row<MAX_LUT_ENTRIES_3){
+                for(unsigned int b=0;b<max_boards;b++){
+                    bCodeRow[b] = binC_3[row][b];
+                }
+            }else{
+                for(unsigned int b=0;b<max_boards;b++){
+                    bCodeRow[b] = binC_3[MAX_LUT_ENTRIES_3-1][b];
+                }
+            }
+    }
+}
 
 /*******************************************************************************
 getLUT_binCode - gets output codes from LUT using row reference.
 *******************************************************************************/
 unsigned int getLUT_binCode(unsigned short row){
-    //return binC[row/LUT_SCALE_FACTOR];
-    return binC[row];
+    unsigned int binC;
+    switch(max_boards) {
+        case 12  :
+            if(row<MAX_LUT_ENTRIES_12){
+                binC = binC_12[row];
+            }else{
+                binC = binC_12[MAX_LUT_ENTRIES_12-1];
+            }
+            break;
+        case 13  :
+            if(row<MAX_LUT_ENTRIES_13){
+                binC = binC_13[row];
+            }else{
+                binC = binC_13[MAX_LUT_ENTRIES_13-1];
+            }
+            break;
+        default :
+            if(row<MAX_LUT_ENTRIES_13){
+                binC = binC_13[row];
+            }else{
+                binC = binC_13[MAX_LUT_ENTRIES_13-1];
+            }
+    }
+    return binC;
 }
 
 /*******************************************************************************
 getLUT_binCode - gets output codes from LUT using row reference.
 *******************************************************************************/
 unsigned int getLUT_thermCode(unsigned short row){
-    //return thermC[row/LUT_SCALE_FACTOR];
-    return thermC[row];
+    unsigned int thermC;
+    switch(max_boards) {
+        case 1  :
+            if(row<MAX_LUT_ENTRIES_1){
+                thermC = thermC_1[row];
+            }else{
+                thermC = thermC_1[MAX_LUT_ENTRIES_1-1];
+            }
+            break;
+        case 2  :
+            if(row<MAX_LUT_ENTRIES_2){
+                thermC = thermC_2[row];
+            }else{
+                thermC = thermC_2[MAX_LUT_ENTRIES_2-1];
+            }
+            break;
+        case 3  :
+            if(row<MAX_LUT_ENTRIES_3){
+                thermC = thermC_3[row];
+            }else{
+                thermC = thermC_3[MAX_LUT_ENTRIES_3-1];
+            }
+            break;
+        case 12  :
+            if(row<MAX_LUT_ENTRIES_12){
+                thermC = thermC_12[row];
+            }else{
+                thermC = thermC_12[MAX_LUT_ENTRIES_12-1];
+            }
+            break;
+        case 13  :
+            if(row<MAX_LUT_ENTRIES_13){
+                thermC = thermC_13[row];
+            }else{
+                thermC = thermC_13[MAX_LUT_ENTRIES_13-1];
+            }
+            break;
+        default :
+            if(row<MAX_LUT_ENTRIES_13){
+                thermC = thermC_13[row];
+            }else{
+                thermC = thermC_13[MAX_LUT_ENTRIES_13-1];
+            }
+    }
+    return thermC;
 }
\ No newline at end of file