fix change level

This commit is contained in:
YiChin
2020-08-05 16:05:21 +08:00
parent 2340b0e88c
commit a04d5f2ae5
5 changed files with 48 additions and 15 deletions
@@ -203,13 +203,17 @@ static void AutoGainChange(int32_t Real_Current){
GAIN_200K_counter++;
if(GAIN_200K_counter > 2){
INSTRUCTION.ADCGainLevel = GAIN_200K;
ADCGainControl(INSTRUCTION.ADCGainLevel);
GAIN_200K_counter = 0;
record_flag = false;
}
}else{
GAIN_10K_counter++;
if(GAIN_10K_counter > 2){
INSTRUCTION.ADCGainLevel = GAIN_10K;
ADCGainControl(INSTRUCTION.ADCGainLevel);
GAIN_10K_counter = 0;
record_flag = false;
}
}
}else{
@@ -227,7 +231,9 @@ static void AutoGainChange(int32_t Real_Current){
GAIN_200R_counter++;
if(GAIN_200R_counter > 2){
INSTRUCTION.ADCGainLevel = GAIN_200R;
ADCGainControl(INSTRUCTION.ADCGainLevel);
GAIN_200R_counter = 0;
record_flag = false;
}
}
@@ -236,7 +242,9 @@ static void AutoGainChange(int32_t Real_Current){
GAIN_200K_counter++;
if(GAIN_200K_counter > 2){
INSTRUCTION.ADCGainLevel = GAIN_200K;
ADCGainControl(INSTRUCTION.ADCGainLevel);
GAIN_200K_counter = 0;
record_flag = false;
}
}else{
if(GAIN_200R_counter > 0){
@@ -255,14 +263,18 @@ static void AutoGainChange(int32_t Real_Current){
GAIN_200R_counter++;
if(GAIN_200R_counter > 2){
INSTRUCTION.ADCGainLevel = GAIN_200R;
ADCGainControl(INSTRUCTION.ADCGainLevel);
GAIN_200R_counter = 0;
record_flag = false;
}
}else{
GAIN_10K_counter++;
if(GAIN_10K_counter > 2){
INSTRUCTION.ADCGainLevel = GAIN_10K;
ADCGainControl(INSTRUCTION.ADCGainLevel);
GAIN_10K_counter = 0;
record_flag = false;
}
}
@@ -275,7 +287,6 @@ static void AutoGainChange(int32_t Real_Current){
}
}
}
ADCGainControl(INSTRUCTION.ADCGainLevel);
}
#endif
@@ -155,11 +155,16 @@ static void CC_Plot(WorkMode *WorkModeData){
if(BatSwitch == 0){
if(ADCSwitch == 0){ /**read Iin(buffer),read bat**/
readIin(WorkModeData);
InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent);
DACenable(WorkModeData, VoltData, AFTER_READ_I);
if(record_flag == false){
ReadCurrent(spi_ADC_rxbuf);
ADCSwitch = 3;
}else{
InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent);
DACenable(WorkModeData, VoltData, AFTER_READ_I);
ReadBatVolt(spi_ADC_rxbuf);
BatSwitch++;
ReadBatVolt(spi_ADC_rxbuf);
BatSwitch++;
}
}else if(ADCSwitch == 1 || ADCSwitch == 3){ /**read Bat**/
ReadBatVolt(spi_ADC_rxbuf);
BatSwitch++;
@@ -191,11 +196,16 @@ static void CC_Plot(WorkMode *WorkModeData){
BatSwitch = 0;
if(ADCSwitch == 0){ /**read Iin(buffer),read V**/
readIin(WorkModeData);
InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent);
DACenable(WorkModeData, VoltData, AFTER_READ_I);
if(record_flag == false){
ReadCurrent(spi_ADC_rxbuf);
ADCSwitch = 3;
}else{
InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent);
DACenable(WorkModeData, VoltData, AFTER_READ_I);
ReadADCVolt(CURRENT_MODE->_VoViSwitch);
ADCSwitch++;
ReadADCVolt(CURRENT_MODE->_VoViSwitch);
ADCSwitch++;
}
}
else if(ADCSwitch == 1){ /**read V**/
ReadADCVolt(CURRENT_MODE->_VoViSwitch);
@@ -216,8 +226,18 @@ static void CC_Plot(WorkMode *WorkModeData){
ADCSwitch++;
}
else if(ADCSwitch == 3){ /**read Iin**/
if(record_flag == false){
static int count = 0;
count++;
ADCSwitch = 3;
if(count == 4){
count = 0;
record_flag = true;
}
}else{
ADCSwitch = 0;
}
ReadCurrent(spi_ADC_rxbuf);
ADCSwitch = 0;
}
}
#undef CURRENT_MODE
@@ -3,10 +3,10 @@
#define VERSION_DATE
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 7
#define VERSION_DATE_DAY 29
#define VERSION_DATE_HOUR 15
#define VERSION_DATE_MINUTE 21
#define VERSION_DATE_MONTH 8
#define VERSION_DATE_DAY 5
#define VERSION_DATE_HOUR 16
#define VERSION_DATE_MINUTE 5
// this is NOT the version hash !!
// it's the last version hash
@@ -532,6 +532,7 @@ static bool ADC_flag;
static bool vscan_flag;
static bool notify_flag;
static bool notifyFirst_flag;
static bool record_flag;
static bool vscanReset;
static bool EliteWorkReset;
static bool leadTimeReset;
@@ -113,8 +113,9 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
if(EliteWorkReset){
InitEliteGPtimer();
EliteWorkReset = false;
EliteWorkReset = false;
batteryADC_flag = false;
record_flag = true;
if( Ve1MatchVe2Mode() ){
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.Ve1));