Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Classic_PID iC_MU mbed-rtos mbed
Diff: ServiceKeyboard.cpp
- Revision:
- 2:dc684c402296
- Parent:
- 1:1ad84260ff59
- Child:
- 3:f8a5c1cee1fa
--- a/ServiceKeyboard.cpp Mon May 18 09:06:07 2015 +0000
+++ b/ServiceKeyboard.cpp Wed May 27 07:13:54 2015 +0000
@@ -6,8 +6,23 @@
extern Serial pc;
extern Classic_PID PanVelocityPID;
extern Classic_PID TiltVelocityPID;
+void Profile(void);
+extern float Demand_Count_Rate;
extern bool joystick;
+extern bool scoping;
+
+extern float fade_tilt;
+extern float fade_time;
+extern float D;
+extern int DoMove;
+extern float T_Position;
+extern float T_Kp;
+extern float Vff;
+float setting;
+extern float Time;
+
+extern float Joy_Zoom;
// Returns the new set point entered via the keyboard
int ServiceKeyboard ()
@@ -17,40 +32,55 @@
key = pc.getc(); // Read the intial keypress
- if (key == 'j') {
- joystick = !joystick;
- if(joystick) {
- pc.printf("\n\r Under Joystick Control");
- } else {
- // Stop both axes
- PanVelocityPID.setSetPoint(0);
- TiltVelocityPID.setSetPoint(0);
- pc.printf("\n\r Under PC Control");
- }
- }
- // Set Velocity for Pan and Tilt here...
- else if(key == 'p') {
- // We are going to set the speed of pan...
- pc.printf("\n\r New Pan Vel: ");
- key = pc.getc();
- if (key == 0x1B) {
- if(pc.getc() == 0x4F) {
- if(pc.getc() == 0x53) {
- pc.printf("-");
- do {
- key = pc.getc(); // Wait for a keypress
- if(key >= '0' && key <= '9') { // Check it is a number
- value *= 10; // Index the old number
- value += (key - '0'); // Add on the new number
- pc.printf("%c",key); // Display the new number
- }
- } while(key != 0x0D);
- PanVelocityPID.setSetPoint(value * -1);
- }
+ switch (key) {
+// List keypresses used:
+ case 'q':
+ pc.printf("\n\r Toggle joystick = j \n\r Scope = s \n\r Fade = f \n\r Stop = c \n\r Set POS gains k, v, \n\r Set Vel Vff, kp: l, m \n\r Set fade time: t \n\r Save Shot = 1");
+ pc.printf("\n\r Zoom Value (1-10) = z");
+ break;
+// Save a shot position:
+ case '1':
+
+ fade_tilt = T_Position;
+ pc.printf("\n\r Saving this postion as %f", fade_tilt);
+ break;
+// Switch Joystick Mode on and off
+ case 'j':
+ joystick = !joystick;
+ if(joystick) {
+ pc.printf("\n\r Under Joystick Control");
+ } else {
+ // Stop both axes
+ //PanVelocityPID.setSetPoint(0);
+ //TiltVelocityPID.setSetPoint(0);
+ pc.printf("\n\r Under PC Control");
+ pc.printf("\n\r");
}
- } else if(key >= '0' && key <= '9') { // Check it is a number
- pc.printf("%c",key);
- value = (key - '0');
+ break;
+// Turn on Scope Tool:
+ case 's':
+ if (!scoping) {
+ Time = 0;
+ pc.printf("\n\r Time, Tilt_JoyStickDem, P_Error, T_Position, P");
+ scoping = true;
+ } else {
+ scoping = false;
+ }
+
+ break;
+// Calling A Fade:
+ case 'f':
+ if (DoMove == 0) {
+ fade_time = 15;
+ Profile();
+ pc.printf("\n\r Fade Distance: %f", D);
+ DoMove = 1;
+ }
+ break;
+ // We are going to set the fade time...
+ case 't':
+ pc.printf("\n\r New Fade Time: ");
+ key = pc.getc();
do {
key = pc.getc(); // Wait for a keypress
if(key >= '0' && key <= '9') { // Check it is a number
@@ -59,30 +89,39 @@
pc.printf("%c",key); // Display the new number
}
} while(key != 0x0D);
- PanVelocityPID.setSetPoint(value);
- }
- } else if(key == 't') {
- // We are going to set the speed of tilt...
- pc.printf("\n\r New Tilt Vel: ");
- key = pc.getc();
- if (key == 0x1B) {
- if(pc.getc() == 0x4F) {
- if(pc.getc() == 0x53) {
- pc.printf("-");
- do {
- key = pc.getc(); // Wait for a keypress
- if(key >= '0' && key <= '9') { // Check it is a number
- value *= 10; // Index the old number
- value += (key - '0'); // Add on the new number
- pc.printf("%c",key); // Display the new number
- }
- } while(key != 0x0D);
- TiltVelocityPID.setSetPoint(value * -1);
+ setting = value;
+ fade_time = (setting);
+ pc.printf("\n\r");
+ break;
+// Stop a fade
+ case 'c':
+ if (DoMove == 1) {
+ pc.printf("\n\r Fade Stop");
+ DoMove = 0;
+ //TiltVelocityPID.setSetPoint(0);
+ }
+ break;
+// Set Tilt Kp
+ case 'k':
+ pc.printf("\n\r New Tilt Pos Kp (Multiply by 100): ");
+ key = pc.getc();
+ do {
+ key = pc.getc(); // Wait for a keypress
+ if(key >= '0' && key <= '9') { // Check it is a number
+ value *= 10; // Index the old number
+ value += (key - '0'); // Add on the new number
+ pc.printf("%c",key); // Display the new number
}
- }
- } else if(key >= '0' && key <= '9') { // Check it is a number
- pc.printf("%c",key);
- value = (key - '0');
+ } while(key != 0x0D);
+ setting = value;
+ T_Kp = (setting/100);
+ //TiltVelocityPID.setKp(value);
+ pc.printf("\n\r");
+ break;
+// We are going to set Pos Feedforward gain for tilt...
+ case 'v':
+ pc.printf("\n\r New Tilt Pos Vff (Multiply by 100): ");
+ key = pc.getc();
do {
key = pc.getc(); // Wait for a keypress
if(key >= '0' && key <= '9') { // Check it is a number
@@ -91,8 +130,62 @@
pc.printf("%c",key); // Display the new number
}
} while(key != 0x0D);
- TiltVelocityPID.setSetPoint(value);
- }
+ setting = value;
+ Vff = (setting/100);
+ pc.printf("\n\r");
+ break;
+// We are going to set Kvelff gain for tilt...
+ case 'l':
+ pc.printf("\n\r New Tilt Velocity Vff (Multiply by 100): ");
+ key = pc.getc();
+ do {
+ key = pc.getc(); // Wait for a keypress
+ if(key >= '0' && key <= '9') { // Check it is a number
+ value *= 10; // Index the old number
+ value += (key - '0'); // Add on the new number
+ pc.printf("%c",key); // Display the new number
+ }
+ } while(key != 0x0D);
+ setting = value;
+ TiltVelocityPID.setKvelff(setting/100);
+ pc.printf("\n\r");
+ break;
+// Set Tilt Velocity Kp
+ case 'm':
+ pc.printf("\n\r New Tilt Velocity Kp (Multiply by 100): ");
+ key = pc.getc();
+ do {
+ key = pc.getc(); // Wait for a keypress
+ if(key >= '0' && key <= '9') { // Check it is a number
+ value *= 10; // Index the old number
+ value += (key - '0'); // Add on the new number
+ pc.printf("%c",key); // Display the new number
+ }
+ } while(key != 0x0D);
+ setting = value;
+ TiltVelocityPID.setKp(setting/100);
+ pc.printf("\n\r");
+ break;
+// Set Zoom level for Zoom proportional
+ case 'z':
+ pc.printf("\n\r Set Zoom Scalar Low 1-9 High): ");
+ key = pc.getc();
+ do {
+ key = pc.getc(); // Wait for a keypress
+ if(key >= '0' && key <= '9') { // Check it is a number
+ value *= 10; // Index the old number
+ value += (key - '0'); // Add on the new number
+ pc.printf("%c",key); // Display the new number
+ }
+ } while(key != 0x0D);
+ setting = value;
+ Joy_Zoom = (setting);
+ pc.printf("\n\r");
+ break;
}
return(1);
-}
\ No newline at end of file
+}
+
+
+
+