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.
Fork of 1TEST_Flight_Protocol by
Diff: main.cpp
- Revision:
- 0:c466d770ffa7
- Child:
- 1:e8a99f19604e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed May 17 11:02:27 2017 +0000
@@ -0,0 +1,109 @@
+#include "mbed.h"
+#include "ROBOFRIEN_GUI.h"
+#include <math.h>
+
+#define PI 3.14159265359 // This value will be used when calculating angles
+
+Timer MainTimer;
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+ROBOFRIEN_GUI GUI;
+int cnt;
+int main() {
+ GUI.Configuration_init();
+ while(1) {
+ GUI.pc_rx_update();
+ if(GUI.rx_bool() == true){
+ cnt ++;
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////// [M/S] Mode and State ///////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ GUI.Mode1 = 8 * sin( PI/180 + cnt/50.0) + 8;
+ GUI.Mode2 = 8 * cos( PI/180 + cnt/50.0) + 8;
+ GUI.MissionState = 8 * sin( PI/180 + cnt/50.0) + 8;
+ GUI.CurrentMarker = 11 * cos( PI/180 + cnt/100.0) + 10;
+ GUI.Bat1 = 50 * sin(PI/180 + cnt/50.0) + 50; // 21.6 ~ 24.6 ( 6cell )
+ GUI.Bat2 = 50 * cos(PI/180 + cnt/50.0) + 50; // 11.1 ~ 12.6 ( 3cell )
+ // Button State is change automatically in "ROBOFRIEN_GUI.cpp" //
+ // You Can not change this setting, just use it ///
+ if(GUI.button[0] == true) myled1 = 1;
+ else myled1 = 0;
+ if(GUI.button[1] == true) myled2 = 1;
+ else myled2 = 0;
+ if(GUI.button[2] == true) myled3 = 1;
+ else myled3 = 0;
+ if(GUI.button[3] == true) myled4 = 1;
+ else myled4 = 0;
+// if(GUI.button[4] == true) myled5 = 1;
+// else myled5 = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////// [GPS] GPS //////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+// GUI.utc_time = cnt * 10;
+// GUI.latitude = 35117030 + 10000 * sin( PI/180 + cnt/50.0);
+// GUI.longitude = 129087896 + 10000 * cos( PI/180 + cnt/50.0);
+// GUI.altitude = 22768 + 32768 * sin( PI/180 + cnt/50.0);
+ GUI.utc_time = GUI.Marker_Speed[0];
+ GUI.latitude = GUI.Marker_Lat[0];
+ GUI.longitude = GUI.Marker_Lng[0];
+ GUI.altitude = GUI.Marker_Alt[0];
+ GUI.SatNum = 10 + 10 * sin( PI/180 + cnt/50.0);
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////// AHRS //////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ GUI.rollx100 = 4500 * sin( PI/180 + cnt/50.0);
+ GUI.pitchx100 = -4500 * sin( PI/180 + cnt/50.0);
+ GUI.yawx100 = 18000 * sin( PI/180 + cnt/50.0) + 18000;
+ GUI.roll_ratex100 = 30000 * sin( PI/180 + cnt/50.0);
+ GUI.pitch_ratex100 = 30000 * sin( PI/180 + cnt/50.0 + PI/4);
+ GUI.yaw_ratex100 = 30000 * sin( PI/180 + cnt/50.0 + PI*3/4);
+ GUI.VXx100 = 1000 * sin(PI/180 + cnt/50.0);
+ GUI.VYx100 = 1000 * cos(PI/180 + cnt/50.0);
+ GUI.VZx100 = 1000 * sin(PI/180 + cnt/50.0 + PI/4);
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////// [C/P] CAP/PWM ////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ GUI.cap[0] = 100 * sin(PI/180 + cnt/50.0);
+ GUI.cap[1] = 100 * sin(PI/180 + cnt/50.0 + PI/8);
+ GUI.cap[2] = 100 * sin(PI/180 + cnt/50.0 + 2*PI/8);
+ GUI.cap[3] = 100 * sin(PI/180 + cnt/50.0 + 3*PI/8);
+ GUI.cap[4] = 100 * sin(PI/180 + cnt/50.0 + 4*PI/8);
+ GUI.cap[5] = 100 * sin(PI/180 + cnt/50.0 + 5*PI/8);
+ GUI.cap[6] = 100 * sin(PI/180 + cnt/50.0 + 6*PI/8);
+ GUI.cap[7] = 100 * sin(PI/180 + cnt/50.0 + 7*PI/8);
+ GUI.pwm[0] = 100 * sin(PI/180 + cnt/50.0) + 100;
+ GUI.pwm[1] = 100 * sin(PI/180 + cnt/50.0 + PI/8) + 100;
+ GUI.pwm[2] = 100 * sin(PI/180 + cnt/50.0 + 2*PI/8) + 100;
+ GUI.pwm[3] = 100 * sin(PI/180 + cnt/50.0 + 3*PI/8) + 100;
+ GUI.pwm[4] = 100 * sin(PI/180 + cnt/50.0 + 4*PI/8) + 100;
+ GUI.pwm[5] = 100 * sin(PI/180 + cnt/50.0 + 5*PI/8) + 100;
+ GUI.pwm[6] = 100 * sin(PI/180 + cnt/50.0 + 6*PI/8) + 100;
+ GUI.pwm[7] = 100 * sin(PI/180 + cnt/50.0 + 7*PI/8) + 100;
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////// [E/D] Extra & Debug /////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ GUI.DEBUGx100[0] = 9000 * sin(PI/180 + cnt/50.0) + 9000;
+ GUI.DEBUGx100[1] += 100;
+ if(GUI.DEBUGx100[1] >= 36000) GUI.DEBUGx100[1] = 0;
+ GUI.DEBUGx100[2] = 25000 * sin(PI/180 + cnt/50.0) + 25000;
+ GUI.DEBUGx100[3] = 11111;
+ GUI.DEBUGx100[4] = 22222;
+ GUI.DEBUGx100[5] = 33333;
+ GUI.DEBUGx100[6] = 44444;
+ GUI.DEBUGx100[7] = 55555;
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////// Refresh ////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////
+ GUI.Refresh();
+
+ }
+
+ }
+}
