Treehouse Mbed Team / Mbed 2 deprecated APS_1U5x

Dependencies:   mbed

Committer:
mfwic
Date:
Mon Dec 03 01:03:14 2018 +0000
Revision:
6:39442d493098
Parent:
5:09be5bbb5020
Child:
7:860b3a8275cb
Added data line with periodic refresh.; Added MY12 menu function.; Fixed menu functions MULT, BRDS, MY12 so that commandData is properly assigned, LUT is used, and settings displayed.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfwic 4:db38665c3727 1 //-------------------------------------------------------------------------------
mfwic 4:db38665c3727 2 //
mfwic 4:db38665c3727 3 // Treehouse Designs Inc.
mfwic 4:db38665c3727 4 // Colorado Springs, Colorado
mfwic 4:db38665c3727 5 //
mfwic 4:db38665c3727 6 // Copyright (c) 2016 by Treehouse Designs Inc.
mfwic 4:db38665c3727 7 // Copyright (c) 2018 by Agility Power Systems Inc.
mfwic 4:db38665c3727 8 //
mfwic 4:db38665c3727 9 // This code is the property of Treehouse Designs, Inc. (Treehouse) and
mfwic 4:db38665c3727 10 // Agility Power Systems Inc. (Agility) and may not be redistributed
mfwic 4:db38665c3727 11 // in any form without prior written permission from
mfwic 4:db38665c3727 12 // both copyright holders, Treehouse and Agility.
mfwic 4:db38665c3727 13 //
mfwic 4:db38665c3727 14 // The above copyright notice and this permission notice shall be included in
mfwic 4:db38665c3727 15 // all copies or substantial portions of the Software.
mfwic 4:db38665c3727 16 //
mfwic 4:db38665c3727 17 //
mfwic 4:db38665c3727 18 //-------------------------------------------------------------------------------
mfwic 4:db38665c3727 19 //
mfwic 4:db38665c3727 20 // REVISION HISTORY:
mfwic 4:db38665c3727 21 //
mfwic 4:db38665c3727 22 // $Author: $
mfwic 4:db38665c3727 23 // $Rev: $
mfwic 4:db38665c3727 24 // $Date: $
mfwic 4:db38665c3727 25 // $URL: $
mfwic 4:db38665c3727 26 //
mfwic 4:db38665c3727 27 //-------------------------------------------------------------------------------
mfwic 4:db38665c3727 28
mfwic 4:db38665c3727 29 #include "mbed.h"
mfwic 5:09be5bbb5020 30 #include "stdint.h"
mfwic 6:39442d493098 31 #include "globals.h"
mfwic 4:db38665c3727 32 #include "lut.h"
mfwic 4:db38665c3727 33
mfwic 4:db38665c3727 34 //unsigned int binCode[6];
mfwic 4:db38665c3727 35
mfwic 5:09be5bbb5020 36 #define MAX_LUT_ENTRIES 1024
mfwic 5:09be5bbb5020 37
mfwic 6:39442d493098 38 uint8_t binC[MAX_LUT_ENTRIES] { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
mfwic 6:39442d493098 39 uint8_t thermC[MAX_LUT_ENTRIES]{ 0, 0, 1, 1, 2, 2, 3, 3, 4, 5};
mfwic 5:09be5bbb5020 40
mfwic 6:39442d493098 41 /*******************************************************************************
mfwic 6:39442d493098 42 dec2bin_fix - Converts decimal to binary with fixed width as specified.
mfwic 6:39442d493098 43 *******************************************************************************/
mfwic 6:39442d493098 44 void dec2bin_fix(unsigned int dec, unsigned int n){
mfwic 4:db38665c3727 45 int k;
mfwic 4:db38665c3727 46
mfwic 6:39442d493098 47 for (int c = 5; c >= 0; c--){
mfwic 4:db38665c3727 48 k = dec >> c;
mfwic 4:db38665c3727 49 if (k & 1)
mfwic 4:db38665c3727 50 binCode[n] = 1;
mfwic 4:db38665c3727 51 else
mfwic 4:db38665c3727 52 binCode[n] = 0;
mfwic 4:db38665c3727 53 n--;
mfwic 4:db38665c3727 54 }
mfwic 4:db38665c3727 55 }
mfwic 4:db38665c3727 56
mfwic 6:39442d493098 57 /*******************************************************************************
mfwic 6:39442d493098 58 dec2therm_fix - Converts decimal to thermometer code with fixed width as specified.
mfwic 6:39442d493098 59 *******************************************************************************/
mfwic 6:39442d493098 60 void dec2therm_fix(unsigned int dec, unsigned int n){
mfwic 6:39442d493098 61 for (int i = 0; i <= n; i++){
mfwic 4:db38665c3727 62 thermCode[i] = 0;
mfwic 4:db38665c3727 63 }
mfwic 4:db38665c3727 64
mfwic 6:39442d493098 65 for (int i = 0; i <= dec; i++){
mfwic 4:db38665c3727 66 thermCode[i] = 1;
mfwic 4:db38665c3727 67 }
mfwic 6:39442d493098 68 }
mfwic 6:39442d493098 69
mfwic 6:39442d493098 70 /*******************************************************************************
mfwic 6:39442d493098 71 getLUTcode - gets output codes from LUT using row reference.
mfwic 6:39442d493098 72 *******************************************************************************/
mfwic 6:39442d493098 73 void getLUTcode(unsigned short row){
mfwic 6:39442d493098 74
mfwic 6:39442d493098 75 dec2bin_fix(binC[row], (unsigned int)WEIGHT_BIN_WIDTH);
mfwic 6:39442d493098 76 dec2therm_fix(thermC[row], (unsigned int)BOARDS_THERMCODE_WIDTH);
mfwic 4:db38665c3727 77
mfwic 4:db38665c3727 78 }
mfwic 4:db38665c3727 79
mfwic 6:39442d493098 80 /*******************************************************************************
mfwic 6:39442d493098 81 getLUT_binCode - gets output codes from LUT using row reference.
mfwic 6:39442d493098 82 *******************************************************************************/
mfwic 6:39442d493098 83 unsigned int getLUT_binCode(unsigned short row){
mfwic 6:39442d493098 84 return binC[row];
mfwic 6:39442d493098 85 }
mfwic 4:db38665c3727 86
mfwic 6:39442d493098 87 /*******************************************************************************
mfwic 6:39442d493098 88 getLUT_binCode - gets output codes from LUT using row reference.
mfwic 6:39442d493098 89 *******************************************************************************/
mfwic 6:39442d493098 90 unsigned int getLUT_thermCode(unsigned short row){
mfwic 6:39442d493098 91 return thermC[row];
mfwic 4:db38665c3727 92 }