Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: src/command.cpp
- Revision:
- 35:ec224d706f7c
- Parent:
- 34:419242dc004d
- Child:
- 36:849c22bd60b0
--- a/src/command.cpp Thu Aug 22 18:31:39 2019 +0000 +++ b/src/command.cpp Tue Oct 22 20:59:27 2019 +0000 @@ -39,9 +39,10 @@ #include "command.h" #include "SOFBlock.h" #include "adc.h" +#include "adc_defs.h" uint8_t *storo; -char storoBuild[200], storoFrag[10]; +char storoBuild[200], storoFrag[10], storoLUT[100]; char storoSpace[2] = ":"; unsigned int boardsActive = ALLON; unsigned int boardMults = 32; @@ -63,8 +64,15 @@ double VSTORE_1; double VSTORE_2; double VSTORE_3; + +bool LUTA = false; +bool LUTB = false; +unsigned int luta = 0; +unsigned int lutb = 0; + struct adcValues adcVals; struct displayValues dvals; + signed int CURRENT_48_DIV_FACTOR5 = -370; signed int CURRENT_48_DIV_FACTOR4 = -570; signed int CURRENT_48_DIV_FACTOR3 = -740; @@ -1026,6 +1034,8 @@ adcValues adcVals = getADCresults(); CURRENT_REF_6 = adcVals.i12; Aloc = 0; + sprintf(strbuf, " %f;%d;%d", CURRENT_12_OFFSET,CURRENT_12_DIV_THRESH5,CURRENT_12_DIV_THRESH1); + sendSerial(strbuf); if ((CURRENT_REF_6 - CURRENT_12_OFFSET < 0 && CURRENT_REF_1 - CURRENT_12_OFFSET < 0 && CURRENT_REF_6 > CURRENT_REF_1) || (CURRENT_REF_6 - CURRENT_12_OFFSET > 0 && CURRENT_REF_1 - CURRENT_12_OFFSET > 0 && CURRENT_REF_6 < CURRENT_REF_1)) { @@ -1068,11 +1078,127 @@ CURRENT_12_DIV_FACTOR5 = (CURRENT_REF_6-CURRENT_REF_5)/(CURRENT_IN_6-CURRENT_IN_5); CURRENT_12_CORRECTION5 = ((CURRENT_REF_6-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR5)-CURRENT_IN_6; } + sprintf(strbuf, " %f;%d;%d", CURRENT_12_OFFSET,CURRENT_12_DIV_THRESH5,CURRENT_12_DIV_THRESH1); + sendSerial(strbuf); printf("\r\n12V current calibration completed.\r\n"); //printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET); } } } + else if (!strcmp(commandString, "LUT")) + { + if (readback) + { + int lut = 0; + int una = 0; + int due = 0; + while(lut < 1023) + { + lut += 1; + una = binC_12[lut]; + due = binC_12[lut-1]; + if (una != due) + { + sprintf(strbuf, " %d", lut); + sendSerial(strbuf); + } + } + } + } + else if (!strcmp(commandString, "LUTA")) + { + if (readback) + { + sprintf(strbuf, " %d", luta); + sendSerial(strbuf); + } + if (LUTB == false) + { + luta = commandData/ROW_CORRECTION_FACTOR; + LUTA = true; + } + else if (LUTB == true) + { + luta = commandData/ROW_CORRECTION_FACTOR; + int lut = 1; + int luts = 0; + int LUTS = 0; + while (lut < 32 && luts < 1024) + { + if (luts >= luta) + { + LUTS += 1; + if (LUTS == 1) + { + lut += 1; + sprintf(storoFrag, "%d", luts); + strcat(storoLUT, storoFrag); + strcat(storoLUT, storoSpace); + } else if (LUTS == lutb) + { + LUTS = 0; + } + } + binC_12[luts] = lut; + binC_13[luts] = lut; + luts += 1; + } + while (luts < 1024) + { + binC_12[luts] = lut; + binC_13[luts] = lut; + luts += 1; + } + printf("LUT updated."); + } + } + else if (!strcmp(commandString, "LUTB")) + { + if (readback) + { + sprintf(strbuf, " %d", lutb); + sendSerial(strbuf); + } + if (LUTA == false) + { + lutb = commandData/ROW_CORRECTION_FACTOR; + LUTB = true; + } + else if (LUTA == true) + { + lutb = commandData/ROW_CORRECTION_FACTOR; + int lut = 1; + int luts = 0; + int LUTS = 0; + while (lut < 32 && luts < 1024) + { + if (luts >= luta) + { + LUTS += 1; + if (LUTS == 1) + { + lut += 1; + sprintf(storoFrag, "%d", luts); + strcat(storoLUT, storoFrag); + strcat(storoLUT, storoSpace); + } else if (LUTS == lutb) + { + LUTS = 0; + } + } + binC_12[luts] = lut; + binC_13[luts] = lut; + luts += 1; + } + while (luts < 1024) + { + binC_12[luts] = lut; + binC_13[luts] = lut; + luts += 1; + } + printf("LUT updated."); + } + } else if (!strcmp(commandString, "RCRD")) { if(checkRange(boardMults, 0, 63) == 1){