add gains commands

This commit is contained in:
Pritimay Sarkar
2024-01-08 23:31:47 +05:30
parent c0ab29f7dc
commit f3a1aba0fc

View File

@@ -1,43 +1,70 @@
#include <EEPROM.h>
struct DeviceData {
char deviceId[20]; // Assuming a device ID of up to 19 characters
// int intValue;
// float floatValue;
};
void writeDataToEEPROM(DeviceData data, int address) {
EEPROM.put(address, data);
}
void readDataFromEEPROM(DeviceData &data, int address) {
EEPROM.get(address, data);
}
void setup() { void setup() {
// put your setup code here, to run once: // put your setup code here, to run once:
Serial.begin(115200); // Serial.begin(115200);
// Serial.begin(9600); Serial.begin(9600);
// DeviceData myDevice;
// strcpy(myDevice.deviceId, "HCV-000-3001");
// writeDataToEEPROM(myDevice, 0);
// // Read data from EEPROM
// DeviceData readDevice;
// readDataFromEEPROM(readDevice, 0);
// Serial.print("Device ID: ");
// Serial.println(readDevice.deviceId);
} }
void loop() { void loop() {
// put your main code here, to run repeatedly: // put your main code here, to run repeatedly:
// TEST: Buffer + Sample // // TEST: Buffer + Sample
while (Serial.available() == 0) {} //wait for data available // while (Serial.available() == 0) {} //wait for data available
String bufferCommand = Serial.readString(); //read until timeout // String bufferCommand = Serial.readString(); //read until timeout
bufferCommand.trim(); // remove any \r \n whitespace at the end of the String // bufferCommand.trim(); // remove any \r \n whitespace at the end of the String
if (bufferCommand == "B") { // if (bufferCommand == "B") {
Serial.println("#Start Buffer"); // Serial.println("#Start Buffer");
delay(2000); // delay(2000);
Serial.println("#Buffer Completed"); // Serial.println("#Buffer Completed");
} // }
while (Serial.available() == 0) {} //wait for data available // while (Serial.available() == 0) {} //wait for data available
String SampleCommand = Serial.readString(); //read until timeout // String SampleCommand = Serial.readString(); //read until timeout
SampleCommand.trim(); // remove any \r \n whitespace at the end of the String // SampleCommand.trim(); // remove any \r \n whitespace at the end of the String
if (SampleCommand == "S") { // if (SampleCommand == "S") {
Serial.println("#Sample Started"); // Serial.println("#Sample Started");
delay(2000); // delay(2000);
Serial.println("#Sample Completed"); // Serial.println("#Sample Completed");
} // }
while (Serial.available() == 0) {} //wait for data available // while (Serial.available() == 0) {} //wait for data available
String resultCommand = Serial.readString(); //read until timeout // String resultCommand = Serial.readString(); //read until timeout
resultCommand.trim(); // remove any \r \n whitespace at the end of the String // resultCommand.trim(); // remove any \r \n whitespace at the end of the String
if (resultCommand == "P") { // if (resultCommand == "P") {
delay(3000); // delay(3000);
// RESULT SN HCV1002 BUFFER_555_GREEN_INTENSITY BUFFER_427_BLUE_INTENSITY SAMPLE_555_GREEN_INTENSITY SAMPLE_427_BLUE_INTENSITY REND // // RESULT SN HCV1002 BUFFER_555_GREEN_INTENSITY BUFFER_427_BLUE_INTENSITY SAMPLE_555_GREEN_INTENSITY SAMPLE_427_BLUE_INTENSITY REND
// Serial.println("RESULT SN HCV1002 23729 24801.67 19190.67 6995.67 REND"); // normal // // Serial.println("RESULT SN HCV1002 23729 24801.67 19190.67 6995.67 REND"); // normal
// Serial.println("RESULT SN HCV1002 24900.67 26578.33 19760.00 9071.67 REND"); // NBL // // Serial.println("RESULT SN HCV1002 24900.67 26578.33 19760.00 9071.67 REND"); // NBL
Serial.println("RESULT SN HCV1002 17974.33 9247.67 19952 12217 REND"); // negative abs // Serial.println("RESULT SN HCV1002 17974.33 9247.67 19952 12217 REND"); // negative abs
delay(15000); // delay(15000);
} // }
@@ -142,4 +169,111 @@ void loop() {
// Serial.println("REND"); // Serial.println("REND");
// delay(15000); // delay(15000);
// } // }
// V2 - New board
// TEST: Device Info + Buffer + Sample
while (Serial.available() == 0) {
String command = Serial.readString();
command.trim();
if (command == "I") {
DeviceData readDevice;
readDataFromEEPROM(readDevice, 0);
Serial.print("SNS "); Serial.print(readDevice.deviceId); Serial.print(" SNE");
}
if (command == "B") {
Serial.println("#BS");
delay(2000);
Serial.println("#BC");
}
if (command == "C") {
Serial.println("#CS");
delay(2000);
Serial.println("LED1_DAC: 1856");
Serial.println("LED2_DAC: 824");
Serial.println("LED3_DAC: 2400");
Serial.println("LED4_DAC: 1992");
Serial.println("#CC");
}
if (command == "D") {
Serial.println("#CS");
delay(2000);
Serial.println("LED1_DAC: 1856");
Serial.println("LED2_DAC: 824");
Serial.println("LED3_DAC: 2400");
Serial.println("LED4_DAC: 1992");
Serial.println("#CC");
}
if (command == "S") {
Serial.println("#SS1");
delay(2000);
Serial.println("#SC1");
}
if (command == "T") {
Serial.println("#SS2");
delay(3000);
Serial.println("#SC2");
}
if (command == "U") {
Serial.println("#SS3");
delay(3000);
Serial.println("#SC3");
}
// if (command == "V") {
// Serial.println("#SS4");
// delay(5000);
// Serial.println("#SC4");
// }
if (command == "W") {
Serial.println("#SS5");
delay(3000);
Serial.println("#SC5");
}
if (command == "P") {
delay(1000);
Serial.println("RESULT");
// // deoxy error
// Serial.println("LB1 25215");
// Serial.println("LB2 25599");
// Serial.println("LB3 24856");
// Serial.println("LB4 25584");
// Serial.println("LS1 560");
// Serial.println("LS2 71");
// Serial.println("LS3 3447");
// Serial.println("LS4 4092");
// // // SCT, no error
Serial.println("LB1 23777");
Serial.println("LB2 24130");
Serial.println("LB3 23442");
Serial.println("LB4 23945");
Serial.println("LS1 2521");
Serial.println("LS2 973");
Serial.println("LS3 10252");
Serial.println("LS4 11017");
// buffer high error
// Serial.println("LB1 21616");
// Serial.println("LB2 21002");
// Serial.println("LB3 24402");
// Serial.println("LB4 24076");
// Serial.println("LS1 507");
// Serial.println("LS2 720");
// Serial.println("LS3 2293");
// Serial.println("LS4 6601");
Serial.println("REND");
}
}
} }