mirror of
https://github.com/nqrduck/ATM.git
synced 2024-11-29 13:23:15 +00:00
Implemented ControlSwitch command.
This commit is contained in:
parent
1ecf275b60
commit
cd22f0c8ad
3 changed files with 81 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include "commands/SetVoltages.h"
|
#include "commands/SetVoltages.h"
|
||||||
#include "commands/MeasureReflection.h"
|
#include "commands/MeasureReflection.h"
|
||||||
#include "commands/VoltageSweep.h"
|
#include "commands/VoltageSweep.h"
|
||||||
|
#include "commands/ControlSwitch.h"
|
||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ Homing homing;
|
||||||
SetVoltages setVoltages;
|
SetVoltages setVoltages;
|
||||||
MeasureReflection measureReflection;
|
MeasureReflection measureReflection;
|
||||||
VoltageSweep voltageSweep;
|
VoltageSweep voltageSweep;
|
||||||
|
ControlSwitch controlSwitch;
|
||||||
|
|
||||||
// Frequency Settings
|
// Frequency Settings
|
||||||
#define FREQUENCY_STEP 100000U // 100kHz frequency steps for initial frequency sweep
|
#define FREQUENCY_STEP 100000U // 100kHz frequency steps for initial frequency sweep
|
||||||
|
@ -58,6 +60,7 @@ void setup()
|
||||||
commandManager.registerCommand('v', &setVoltages);
|
commandManager.registerCommand('v', &setVoltages);
|
||||||
commandManager.registerCommand('m', &measureReflection);
|
commandManager.registerCommand('m', &measureReflection);
|
||||||
commandManager.registerCommand('s', &voltageSweep);
|
commandManager.registerCommand('s', &voltageSweep);
|
||||||
|
commandManager.registerCommand('c', &controlSwitch);
|
||||||
|
|
||||||
pinMode(MISO_PIN, INPUT_PULLUP); // Seems to be necessary for SPI to work
|
pinMode(MISO_PIN, INPUT_PULLUP); // Seems to be necessary for SPI to work
|
||||||
|
|
||||||
|
@ -118,10 +121,6 @@ void setup()
|
||||||
digitalWrite(FILTER_SWITCH_A, LOW);
|
digitalWrite(FILTER_SWITCH_A, LOW);
|
||||||
digitalWrite(FILTER_SWITCH_B, HIGH);
|
digitalWrite(FILTER_SWITCH_B, HIGH);
|
||||||
|
|
||||||
// RF Switch for switching between preamp and tuning and matching module
|
|
||||||
pinMode(RF_SWITCH_PIN, OUTPUT);
|
|
||||||
digitalWrite(RF_SWITCH_PIN, HIGH);
|
|
||||||
|
|
||||||
// ADAC module
|
// ADAC module
|
||||||
adac.enable_internal_Vref();
|
adac.enable_internal_Vref();
|
||||||
adac.set_DAC_max_2x_Vref();
|
adac.set_DAC_max_2x_Vref();
|
||||||
|
|
52
src/commands/ControlSwitch.cpp
Normal file
52
src/commands/ControlSwitch.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#include "Utilities.h"
|
||||||
|
#include "ControlSwitch.h"
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
ControlSwitch::ControlSwitch()
|
||||||
|
{
|
||||||
|
pinMode(RF_SWITCH_PIN, OUTPUT);
|
||||||
|
switch_state = ATM_SYSTEM;
|
||||||
|
digitalWrite(RF_SWITCH_PIN, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlSwitch::execute(String input_line)
|
||||||
|
{
|
||||||
|
char switch_to = input_line[1];
|
||||||
|
|
||||||
|
if ((switch_to == PRE_AMP) && (switch_state != PRE_AMP))
|
||||||
|
{
|
||||||
|
switch_state = PRE_AMP;
|
||||||
|
digitalWrite(RF_SWITCH_PIN, HIGH);
|
||||||
|
result = "Switched to preamp";
|
||||||
|
}
|
||||||
|
else if ((switch_to == ATM_SYSTEM) && (switch_state != ATM_SYSTEM))
|
||||||
|
{
|
||||||
|
switch_state = ATM_SYSTEM;
|
||||||
|
digitalWrite(RF_SWITCH_PIN, LOW);
|
||||||
|
result = "Switched to atm system";
|
||||||
|
}
|
||||||
|
else if (switch_to == switch_state)
|
||||||
|
{
|
||||||
|
result = "Already switched to " + String(switch_to);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = "Invalid switch state";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlSwitch::printResult()
|
||||||
|
{
|
||||||
|
printInfo(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlSwitch::printHelp()
|
||||||
|
{
|
||||||
|
Serial.println("Control switch command");
|
||||||
|
Serial.println("Syntax: s<switch state>");
|
||||||
|
Serial.println("Example: sa");
|
||||||
|
Serial.println("This will switch to the atm system");
|
||||||
|
Serial.println("Possible switch states:");
|
||||||
|
Serial.println("p: preamp");
|
||||||
|
Serial.println("a: atm system");
|
||||||
|
}
|
26
src/commands/ControlSwitch.h
Normal file
26
src/commands/ControlSwitch.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef CONTROLSWITCH_H
|
||||||
|
#define CONTROLSWITCH_H
|
||||||
|
|
||||||
|
#define PRE_AMP 'p'
|
||||||
|
#define ATM_SYSTEM 'a'
|
||||||
|
|
||||||
|
#include "Command.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This class is used to control the switch which is used to switch between the preamplifier and the atm system.
|
||||||
|
* It can take the command <switch_state> where switch_state is either p or a for preamp or atm system respectively.
|
||||||
|
*/
|
||||||
|
class ControlSwitch : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ControlSwitch();
|
||||||
|
void execute(String input_line) override;
|
||||||
|
void printResult() override;
|
||||||
|
void printHelp() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
char switch_state;
|
||||||
|
String result;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue