|
@@ -166,6 +166,9 @@ char line3_old[line_len]= {0};
|
|
|
char temperature_val[5]={0x00};
|
|
|
char temperature_buf[5]={0x00};
|
|
|
bool old_load=true;
|
|
|
+
|
|
|
+bool usb_enable=false;
|
|
|
+bool trig_key = false;
|
|
|
void setmode(void);
|
|
|
void color_load (bool load);
|
|
|
bool setVoltage(uint16_t output, bool writeEEPROM) {
|
|
@@ -206,12 +209,20 @@ void isr()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+void toggle_usb(void){
|
|
|
+ if (usb_enable){
|
|
|
+ writeNum2("pusb.pic",(int) pic_usb_grey);
|
|
|
+ }else{
|
|
|
+ writeNum2("pusb.pic",(int) pic_usb_black);
|
|
|
+ }
|
|
|
+ usb_enable=!usb_enable;
|
|
|
+}
|
|
|
|
|
|
void serialEvent() {
|
|
|
while (nexSerial.available() > 0 ){
|
|
|
|
|
|
c1 = nexSerial.read();
|
|
|
+ Serial.println(c1,HEX);
|
|
|
if (0x65 == c1 ||__buffer[0] == 0x65)
|
|
|
{
|
|
|
if (0x65 == c1){
|
|
@@ -287,6 +298,12 @@ void serialEvent() {
|
|
|
case 14:
|
|
|
customKey='C';
|
|
|
break;
|
|
|
+ case 29:
|
|
|
+ toggle_usb();
|
|
|
+ break;
|
|
|
+ case button_trig:
|
|
|
+ trig_key = true;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -563,13 +580,20 @@ void readKeypadInput (void) {
|
|
|
}
|
|
|
|
|
|
if(customKey == '>'){ //check if decimal button key pressed
|
|
|
- if (decimalPoint != ('>')){ //test if decimal point entered twice - if so skip
|
|
|
+ if (decimalPoint != '>'){ //test if decimal point entered twice - if so skip
|
|
|
+ uint8_t index_old = index;
|
|
|
+ if (index==0){
|
|
|
+ numbers[index++] = '0';
|
|
|
+ }
|
|
|
numbers[index++] = '.';
|
|
|
- numbers[index] = '\0';
|
|
|
+ numbers[index] = 0x00;
|
|
|
+ if (index_old==0){
|
|
|
+ line3[z++]='0';
|
|
|
+ }
|
|
|
line3[z]='.';
|
|
|
print_chars2(3,20);
|
|
|
z = z+1;
|
|
|
- decimalPoint = ('>'); //used to indicate decimal point has been input
|
|
|
+ decimalPoint = '>'; //used to indicate decimal point has been input
|
|
|
}
|
|
|
customKey ='\0';
|
|
|
}
|
|
@@ -579,7 +603,7 @@ void readKeypadInput (void) {
|
|
|
z = 1; //sets column position for LCD displayed character
|
|
|
print_chars(3,z,(char *) " ",5);
|
|
|
numbers[index] = '\0'; //
|
|
|
- decimalPoint = (' '); //clear decimal point test character reset
|
|
|
+ decimalPoint = ' '; //clear decimal point test character reset
|
|
|
customKey ='\0';
|
|
|
}
|
|
|
|
|
@@ -906,7 +930,7 @@ void LoadSwitch(void) {
|
|
|
//-----------------------Select Constant Current LCD set up--------------------------------
|
|
|
void Current(void) {
|
|
|
Mode = MODE_CC;
|
|
|
- memcpy(line0,(char*)"DC LOAD ",8);
|
|
|
+ memcpy(line0,(char*)"DC LOAD ",12);
|
|
|
print_chars2(0,20);
|
|
|
writeNum2("t0.xcen",(uint16_t) 0);
|
|
|
print_chars(2,0,(char*)"Set I = A",20);
|
|
@@ -920,7 +944,7 @@ void Current(void) {
|
|
|
void Power(void) {
|
|
|
Mode = MODE_CP;
|
|
|
writeNum2("t0.xcen",(int) 0);
|
|
|
- memcpy(line0,(char*)"DC LOAD ",7);
|
|
|
+ memcpy(line0,(char*)"DC LOAD ",12);
|
|
|
print_chars2(0,20);
|
|
|
print_chars(2,0,(char*)"Set W = W",22);
|
|
|
memset(line3,' ',20);
|
|
@@ -933,7 +957,7 @@ void Power(void) {
|
|
|
void Resistance(void) {
|
|
|
Mode = MODE_CR;
|
|
|
writeNum2("t0.xcen",(int) 0);
|
|
|
- memcpy(line0,(char*)"DC LOAD ",8);
|
|
|
+ memcpy(line0,(char*)"DC LOAD ",12);
|
|
|
print_chars2(0,20);
|
|
|
print_chars(2,0,(char*)"Set R = R",20);
|
|
|
memset(line3,' ',20);
|
|
@@ -948,7 +972,9 @@ void BatteryCapacity(void) {
|
|
|
Mode = MODE_BC;
|
|
|
|
|
|
writeNum2("t0.xcen",0);
|
|
|
- print_chars(0,0,(char*)"BATTERY ",20);
|
|
|
+ memcpy(line0,"BATTERY ",20);
|
|
|
+ memcpy(line0+8,(char *)BatteryType.c_str(),4);
|
|
|
+ print_chars2(0,20);
|
|
|
print_chars(2,0,(char*)"Set I = A",20);
|
|
|
memset(line3,' ',20);
|
|
|
print_chars2(3,20);
|
|
@@ -1076,26 +1102,31 @@ void wait_for_key(bool wait){
|
|
|
void inputValue (int r=0){
|
|
|
|
|
|
while(customKey != 'F'){ //check if enter pressed (was previously #)
|
|
|
- customKey=0x00;
|
|
|
- wait_for_key(true);
|
|
|
+ customKey=0x00;
|
|
|
+ wait_for_key(true);
|
|
|
if(customKey >= '0' && customKey <= '9'){ //check for keypad number input
|
|
|
numbers[index++] = customKey;
|
|
|
numbers[index] = '\0';
|
|
|
print_char(r,z,customKey);
|
|
|
- z = z+1;
|
|
|
+ z++;
|
|
|
}
|
|
|
|
|
|
if(customKey == '>'){ //Decimal point
|
|
|
- if (decimalPoint != ('>')){ //test if decimal point entered twice - if so ski
|
|
|
+ if (decimalPoint != '>'){ //test if decimal point entered twice - if so skip
|
|
|
+ if (index==0){
|
|
|
+ numbers[index++] = '0';
|
|
|
+ print_char(r,z,'0');
|
|
|
+ z++;
|
|
|
+ }
|
|
|
numbers[index++] = '.';
|
|
|
numbers[index] = 0x00;
|
|
|
print_char(r,z,'.');
|
|
|
- z = z+1;
|
|
|
- decimalPoint = ('>'); //used to indicate decimal point has been input
|
|
|
- }
|
|
|
- }
|
|
|
+ z++;
|
|
|
+ decimalPoint = '>'; //used to indicate decimal point has been input
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if(customKey == '<'){ //clear entry
|
|
|
+ if(customKey == '<'){ //clear entry
|
|
|
index = 0;
|
|
|
z = y;
|
|
|
|
|
@@ -1204,9 +1235,25 @@ void transientType (void) {
|
|
|
memcpy(line3,(char*)"4 = List",8);
|
|
|
memcpy(line3+11,(char*)"5 = Exit",9);
|
|
|
print_chars2(3,0);
|
|
|
-
|
|
|
- wait_for_key(1); //stop everything till the user press a key.
|
|
|
-
|
|
|
+ while ( customKey == 0x00 ||
|
|
|
+ customKey == '6' ||
|
|
|
+ customKey == '7' ||
|
|
|
+ customKey == '8' ||
|
|
|
+ customKey == '9' ||
|
|
|
+ customKey == '0' ||
|
|
|
+ customKey == 'A' ||
|
|
|
+ customKey == 'B' ||
|
|
|
+ customKey == 'C' ||
|
|
|
+ customKey == 'D' ||
|
|
|
+ customKey == '*' ||
|
|
|
+ customKey == '#' ||
|
|
|
+ customKey == 'E' ||
|
|
|
+ customKey == 'F' ||
|
|
|
+ customKey == '<' ||
|
|
|
+ customKey == '>' ){
|
|
|
+ customKey = 0x00;
|
|
|
+ wait_for_key(1); //stop everything till the user press a key.
|
|
|
+ }
|
|
|
if (customKey == '1'){
|
|
|
Mode = MODE_TC;
|
|
|
}
|
|
@@ -1227,12 +1274,9 @@ void transientType (void) {
|
|
|
exitMode = 1;
|
|
|
}
|
|
|
|
|
|
- if (customKey == '6' || customKey == '7' || customKey == '8' || customKey == '9' || customKey == '0' || customKey == 'A' || customKey == 'B' || customKey == 'C' || customKey == 'D' || customKey == '*' || customKey == '#' || customKey == 'E' || customKey == 'F' || customKey == '<' || customKey == '>' ){
|
|
|
- transientType(); //ignore other keys
|
|
|
- }
|
|
|
-screen_clear(' ');
|
|
|
-customKey=0x00;
|
|
|
-if (exitMode == 1){ //if NO Transient Mode type selected revert to CC Mode
|
|
|
+ screen_clear(' ');
|
|
|
+ customKey=0x00;
|
|
|
+ if (exitMode == 1){ //if NO Transient Mode type selected revert to CC Mode
|
|
|
color_load(0);
|
|
|
Current(); //if selected go to Constant Current Selected routine
|
|
|
encoderPosition = 0; //reset encoder reading to zero
|
|
@@ -1359,9 +1403,10 @@ void transientLoadToggle(){
|
|
|
last_time = current_time;
|
|
|
transientSwitch(LowCurrent, true);
|
|
|
}
|
|
|
- if (digitalRead(TriggerPulse) == LOW){
|
|
|
+ if (digitalRead(TriggerPulse) == LOW || trig_key){
|
|
|
// a trigger pluse is received
|
|
|
// set to the high current
|
|
|
+ trig_key=false;
|
|
|
transientSwitch(HighCurrent, true);
|
|
|
} else {
|
|
|
if ((current_time - last_time) >= (transientPeriod * 1000.0)){
|
|
@@ -1372,7 +1417,8 @@ void transientLoadToggle(){
|
|
|
|
|
|
|
|
|
if(Mode == MODE_TT){ // this function will toggle between high and low current when the trigger pin is taken low
|
|
|
- if (digitalRead(TriggerPulse) == LOW){
|
|
|
+ if (digitalRead(TriggerPulse) == LOW || trig_key){
|
|
|
+ trig_key=false;
|
|
|
switch (transient_mode_status){
|
|
|
case (false):
|
|
|
transientSwitch(LowCurrent, true);
|