Skip to content
Snippets Groups Projects
Commit 1eaee14d authored by Michael DM Dryden's avatar Michael DM Dryden
Browse files

Finish TCS interlock. Completes #6

parent 77e5eb5b
No related merge requests found
......@@ -60,6 +60,8 @@ void experiment_handler(char command){
static uint8_t p5, o1, o2, o3;
static int16_t pcv1, pcv2;
static uint16_t pct1, pct2;
uint16_t tcs_data[] = {0,0,0,0};
uint16_t tcs_data1[] = {0,0,0,0};
switch (command){
case 'A': //ADS Buffer/rate/PGA values from ads1255.h
......@@ -134,14 +136,23 @@ void experiment_handler(char command){
scanf("%hhu", &o1);
printf("#INFO: TCS_check: %hhu\n\r", o1);
if (o1 > 0) {
if (settings.settings.tcs_enabled > 0) {
uint16_t tcs_data[4] = {0,0,0,0};
if (settings.settings.tcs_enabled > 0){
tcs_readvalues(tcs_data);
if (tcs_data[0] > settings.settings.tcs_clear_threshold) {
delay_ms(25);
tcs_readvalues(tcs_data1); // If sensor disconnected, second measurement should be exactly the same
if (tcs_data[0] > settings.settings.tcs_clear_threshold){
printf("#ERR: Ambient light exceeds threshold %u\n\r", tcs_data[0]);
printf("#INFO: TCS—%u %u %u %u\n\r", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]);
return;
}
else if (tcs_data[3] == tcs_data1[3]){
printf("#ERR: Ambient light sensor seems to be disconnected \n\r");
return;
}
}
else {
printf("#ERR: Ambient light sensor disabled.\n\r");
return;
}
}
......@@ -338,7 +349,7 @@ void pot_set_gain(void){
default:
printf("#WAR: Invalid pot gain.\n\r");
break;
return;
}
}
......
......@@ -34,9 +34,15 @@ int8_t command_handler(char command){
break;
case 'T': ;
uint16_t tcs_data[4] = {0,0,0,0};
tcs_readvalues(tcs_data);
printf("#INFO: TCS—%u %u %u %u\n\r", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]);
uint16_t tcs_data[] = {0,0,0,0};
if (settings.settings.tcs_enabled == 0){
printf("T-1.-1.-1.-1\n\r");
}
else{
tcs_readvalues(tcs_data);
printf("#INFO: TCS—%u %u %u %u\n\r", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]);
printf("T%u.%u.%u.%u\n\r", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]);
}
break;
case 'V': //check version
......
......@@ -43,6 +43,7 @@ void settings_read_eeprom(void){
printf("#INFO: max5443_offset = %u\n\r", settings.settings.max5443_offset);
printf("#INFO: tls_enabled = %u\n\r", settings.settings.tcs_enabled);
printf("#INFO: tls_clear_threshold = %u\n\r", settings.settings.tcs_clear_threshold);
printf("Smax5443_offset.%u:tcs_enabled.%u:tcs_clear_threshold.%u\n\r", settings.settings.max5443_offset, settings.settings.tcs_enabled, settings.settings.tcs_clear_threshold);
}
void settings_write_eeprom(void){
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment