Skip to content

Commit

Permalink
Merge pull request #56 from ShikOfTheRa/Shiki-R1.4-dev
Browse files Browse the repository at this point in the history
Shiki r1.4 dev
  • Loading branch information
ShikOfTheRa committed May 22, 2015
2 parents 360cd07 + f6b2560 commit 69e1146
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 63 deletions.
28 changes: 19 additions & 9 deletions MW_OSD/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
// #define SWAPVOLTAGEPINS // For RTFQ boards with batt voltage appearing on vid voltage
// #define ALTERNATEDIVIDERS // For RFTQ boards with voltage unable to be adjusted high enough


/******************** CONTROLLER SOFTWARE *********************/
//Choose ONLY ONE option:-
//#define MULTIWII_V24 // Uncomment this if you are using MW versions 2.4
#define MULTIWII_V24 // Uncomment this if you are using MW versions 2.4
//#define MULTIWII_V23 // Uncomment this if you are using MW versions 2.2/2.3
//#define MULTIWII_V21 // Uncomment this if you are using MW versions 2.0/2.1 (for BOXNAMES compatibility)
//#define BASEFLIGHT // Uncomment this if you are using BASEFLIGHT
//#define CLEANFLIGHT180 // Uncomment this if you are using CLEANFLIGHT versions up to and including 1.8.0
//#define CLEANFLIGHT181 // Uncomment this if you are using CLEANFLIGHT versions 1.8.1
//#define CLEANFLIGHT190 // Uncomment this if you are using CLEANFLIGHT versions 1.9.0 onwards
//#define HARIKIRI // Uncomment this if you are using HARIKIRI (for BOXNAMES compatibility)
#define NOCONTROLLER // Uncomment this if you are using GPSOSD or not using a flight controller
//#define GPSOSD // Uncomment this if you are using a GPS module for a GPS based OSD
//#define NOCONTROLLER // Uncomment this if you ahave nothing connected to the serial port - no controller or GPS module


/******************** AIRCRAFT/INSTALLATION TYPE settings *********************/
Expand Down Expand Up @@ -79,7 +80,7 @@
/******************** GPS OSD settings *********************/
// **ONLY** FOR STANDALONE GPS MODE WITH NO FLIGHT CONTROLLER
// Choose ONLY ONE option:
#define NMEA // Enable if using a standard NMEA based GPS
//#define NMEA // Enable if using a standard NMEA based GPS
//#define UBLOX // currently not working // Enable if using a standard UBLOX based GPS
//#define MTK // Enable if using a standard MTK based GPS
//#define MTK_BINARY16 // Enable if using MTK3329 chipset based GPS with DIYDrones binary firmware v1.6
Expand All @@ -88,9 +89,9 @@

/******************** Serial speed settings *********************/
// Choose ONLY ONE option:
//#define BAUDRATE 115200
#define BAUDRATE 115200
//#define BAUDRATE 57600
#define BAUDRATE 38400
//#define BAUDRATE 38400
//#define BAUDRATE 19200


Expand All @@ -103,7 +104,7 @@


/******************** STARTUP settings *********************/
#define INTRO_VERSION "SHIKI-OSD - R1.4" // Call the OSD something else if you prefer. KVOSD is not permitted - LOL.
//#define INTRO_VERSION "SHIKI-OSD - R1.4" // Call the OSD something else if you prefer. KVOSD is not permitted - LOL.
//#define INTRO_CALLSIGN // Enable to display callsign at startup
//#define INTRO_TIMEZONE // Enable to display timezone at startup - if GPS TIME is enabled
//#define INTRO_DELAY 5 // Seconds intro screen should show for. Default is 10
Expand Down Expand Up @@ -148,6 +149,7 @@
//#define FASTMSP // Enable for soft serial / slow baud rates if don't need GPS/BARO/HORIZON data. Speeds up remainder
//#define NOTHROTTLESPACE // Enable to remove space between throttle symbol and the data
//#define REVERSEAHI // Reverse pitch / roll direction of AHI - for DJI / Eastern bloc OSD users
//#define AHICORRECT 10 // Enable to adjust AHI on display to match horizon. -10 = -1 degree
#define APINDICATOR // Enable to display AUTOPILOT instead of RTH distance


Expand Down Expand Up @@ -203,6 +205,14 @@
#define BOXNAMES // required to support legacy protocol
#endif

#ifdef NOCONTROLLER
#undef INTRO_MENU
#undef MSPACTIVECHECK
#undef SATACTIVECHECK
#undef GPSACTIVECHECK
#undef OSD_SWITCH_RC
#endif

#ifdef MULTIWII_V24
#endif

Expand Down Expand Up @@ -292,8 +302,8 @@
#if defined GPSOSD
#undef INTRO_MENU
#undef MSPACTIVECHECK
#undef SATACTIVECHECK
#undef GPSACTIVECHECK
// #undef SATACTIVECHECK
// #undef GPSACTIVECHECK
#undef OSD_SWITCH_RC
#define FORCESENSORS
#define HIDEARMEDSTATUS
Expand Down
86 changes: 51 additions & 35 deletions MW_OSD/GPS.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// GPS protocol GGA and RMC sentences are needed
// Ublox config con be set using u-blox-config.ublox.txt

Expand Down Expand Up @@ -159,18 +158,23 @@
}


void GPS_update(){
void GPS_updateRMC(){
GPS_speed=GPS_parse.GPS_speed;
GPS_ground_course=GPS_parse.GPS_ground_course;
}


void GPS_updateGGA(){
uint8_t GPS_fix_temp=GPS_parse.GPS_fix;
if (GPS_fix_temp){
GPS_fix=1;
}
GPS_numSat=GPS_parse.GPS_numSat;
GPS_altitude=GPS_parse.GPS_altitude;
GPS_speed=GPS_parse.GPS_speed;
GPS_ground_course=GPS_parse.GPS_ground_course;
GPS_coord[LAT]=GPS_parse.GPS_coord[LAT];
GPS_coord[LON]=GPS_parse.GPS_coord[LON];
GPS_Present=GPS_parse.GPS_Present;
gpsvario();
}


Expand All @@ -197,7 +201,7 @@ void GPS_NewData() {
GPS_distanceToHome = dist/100;
GPS_directionToHome = dir/100;
GPS_altitude = GPS_altitude- GPS_altitude_home;
MwAltitude = (int32_t) GPS_altitude *100;
MwAltitude = (int32_t)GPS_altitude *100;
GPS_latitude = GPS_coord[LAT];
GPS_longitude = GPS_coord[LON];
int16_t MwHeading360=GPS_ground_course/10;
Expand Down Expand Up @@ -353,57 +357,52 @@ bool GPS_newFrame(char c) {
static char string[15];
static uint8_t checksum_param, frame = 0;

if ((c == '$') ||(param>15) ) {
if (c == '$') {
param = 0; offset = 0; parity = 0;
}
else if (c == ',' || c == '*') {
} else if (c == ',' || c == '*') {
string[offset] = 0;
if (param == 0) { //frame identification
frame = 0;
if (string[0] == 'G' && string[1] == 'P' && string[2] == 'G' && string[3] == 'G' && string[4] == 'A') frame = FRAME_GGA;
if (string[0] == 'G' && string[1] == 'P' && string[2] == 'R' && string[3] == 'M' && string[4] == 'C') frame = FRAME_RMC;
}
else if (frame == FRAME_GGA) {
} else if (frame == FRAME_GGA) {
if (param == 2) {GPS_parse.GPS_coord[LAT] = GPS_coord_to_degrees(string);}
else if (param == 3 && string[0] == 'S') {GPS_parse.GPS_coord[LAT] = -GPS_parse.GPS_coord[LAT];}
else if (param == 3 && string[0] == 'S') GPS_parse.GPS_coord[LAT] = -GPS_parse.GPS_coord[LAT];
else if (param == 4) {GPS_parse.GPS_coord[LON] = GPS_coord_to_degrees(string);}
else if (param == 5 && string[0] == 'W') {GPS_parse.GPS_coord[LON] = -GPS_parse.GPS_coord[LON];}
else if (param == 5 && string[0] == 'W') GPS_parse.GPS_coord[LON] = -GPS_parse.GPS_coord[LON];
else if (param == 6) {GPS_parse.GPS_fix = (string[0] > '0');}
else if (param == 7) {GPS_parse.GPS_numSat = grab_fields(string,0);}
else if (param == 9) {GPS_parse.GPS_altitude = grab_fields(string,0);}
}
else if (frame == FRAME_RMC) {
if (param == 7) {GPS_parse.GPS_speed = ((uint32_t)grab_fields(string,1)*5144L)/1000L;} //gps speed in cm/s
else if (param == 9) {GPS_parse.GPS_altitude = grab_fields(string,0);} // altitude in meters added by Mis
} else if (frame == FRAME_RMC) {
if (param == 7) {GPS_parse.GPS_speed = ((uint32_t)grab_fields(string,1)*5144L)/1000L;} //gps speed in cm/s will be used for navigation
else if (param == 8) {GPS_parse.GPS_ground_course = grab_fields(string,1); } //ground course deg*10
#ifdef GPSACTIVECHECK
timer.GPS_active=GPSACTIVECHECK;
#endif //GPSACTIVECHECK

}
param++; offset = 0;
if (c == '*') {
checksum_param=1;
}
else {
parity ^= c;
}
}
else if (c == '\r' || c == '\n') {
if (c == '*') checksum_param=1;
else parity ^= c;
} else if (c == '\r' || c == '\n') {
if (checksum_param) { //parity checksum
uint8_t checksum = hex_c(string[0]);
checksum <<= 4;
checksum += hex_c(string[1]);
if (checksum == parity) {
frameOK = 1;
GPS_update();
if (frame == FRAME_GGA){
GPS_updateGGA();
}
if (frame == FRAME_RMC){
GPS_updateRMC();
}
}
}
checksum_param=0;
}
else {
if (offset < 15) {
string[offset++] = c;
}
else{
// param = 0, offset = 0, parity = 0;
}
if (!checksum_param) parity ^= c;
} else {
if (offset < 15) string[offset++] = c;
if (!checksum_param) parity ^= c;
}
if (frame) GPS_Present = 1;
return frameOK && (frame==FRAME_GGA);
Expand Down Expand Up @@ -587,8 +586,12 @@ bool GPS_newFrame(char c) {
GPS_coord[LON] = _buffer.posllh.longitude;
GPS_coord[LAT] = _buffer.posllh.latitude;
GPS_altitude = _buffer.posllh.altitude_msl / 1000; //alt in m
gpsvario();
}
GPS_fix = _fix_ok;
#ifdef GPSACTIVECHECK
timer.GPS_active=GPSACTIVECHECK;
#endif //GPSACTIVECHECK
return true; // POSLLH message received, allow blink GUI icon and LED
break;
case MSG_SOL:
Expand Down Expand Up @@ -740,6 +743,9 @@ restart:
}

GPS_fix = ((_buffer.msg.fix_type == FIX_3D) || (_buffer.msg.fix_type == FIX_3D_SBAS));
#ifdef GPSACTIVECHECK
timer.GPS_active=GPSACTIVECHECK;
#endif //GPSACTIVECHECK

#if defined(MTK_BINARY16)
GPS_coord[LAT] = _buffer.msg.latitude * 10; // XXX doc says *10e7 but device says otherwise
Expand All @@ -750,6 +756,7 @@ restart:
GPS_coord[LON] = _buffer.msg.longitude;
#endif
GPS_altitude = _buffer.msg.altitude /100; // altitude in meter
gpsvario();
GPS_speed = _buffer.msg.ground_speed; // in m/s * 100 == in cm/s
GPS_ground_course = _buffer.msg.ground_course/100; //in degrees
GPS_numSat = _buffer.msg.satellites;
Expand All @@ -761,4 +768,13 @@ restart:
}
#endif //MTK

#endif // GPS
#endif // GPS

void gpsvario(){
if (millis()>timer.fwAltitudeTimer){ // To make vario from GPS altitude
timer.fwAltitudeTimer +=1000;
previousfwaltitude=interimfwaltitude;
interimfwaltitude=GPS_altitude;
MwVario=(GPS_altitude-previousfwaltitude)*20;
}
}
5 changes: 1 addition & 4 deletions MW_OSD/MW_OSD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ uint16_t UntouchedStack(void)
#include "GlobalVariables.h"
#include "math.h"

int16_t gbug[4];
char screen[480]; // Main screen ram for MAX7456
char screenBuffer[20];
uint32_t modeMSPRequests;
Expand Down Expand Up @@ -134,9 +133,7 @@ void setup()
//------------------------------------------------------------------------
void loop()
{
debug[0]++;
if (GPS_fix==0) debug[1]++;
if (GPS_numSat!=9) debug[2]++;
if (GPS_numSat!=9) debug[0]++;
#ifdef MEMCHECK
debug[MEMCHECK] = UntouchedStack();
#endif
Expand Down
16 changes: 8 additions & 8 deletions MW_OSD/Screen.ino
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ void displayHorizon(int rollAngle, int pitchAngle)
if(pitchAngle<-250) pitchAngle=-250;
if(rollAngle>400) rollAngle=400;
if(rollAngle<-400) rollAngle=-400;

#ifndef AHICORRECT
#define AHICORRECT 10
#endif
pitchAngle=pitchAngle+AHICORRECT;
#if defined REVERSEAHI
pitchAngle=pitchAngle-10;
pitchAngle=-pitchAngle;
rollAngle=-rollAngle;
#else
pitchAngle=pitchAngle+10;
#endif //REVERSEAHI

if(Settings[S_DISPLAY_HORIZON_BR]&fieldIsVisible(horizonPosition)){
Expand Down Expand Up @@ -902,8 +902,8 @@ void displayCursor(void)
}
#endif
#ifdef PAGE2
#ifdef CLEANFLIGHT
if(configPage==2){
#if defined(CLEANFLIGHT181) || defined(CLEANFLIGHT190)
if(configPage==2){
COL=3;
cursorpos=(ROW+2)*30+10+6+6;
}
Expand Down Expand Up @@ -1069,8 +1069,8 @@ void displayConfigScreen(void)
#ifdef PAGE2
if(configPage==2)
{
#ifdef CLEANFLIGHT
for(uint8_t X=0; X<=8; X++) {
#if defined(CLEANFLIGHT181) || defined(CLEANFLIGHT190)
for(uint8_t X=0; X<=8; X++) {
strcpy_P(screenBuffer, (char*)pgm_read_word(&(menu_rc[X])));
MAX7456_WriteString(screenBuffer, ROLLT+ (X*30));
}
Expand Down
9 changes: 2 additions & 7 deletions MW_OSD/Serial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,7 @@ void serialMSPCheck()
{
#if defined(USEGPSALTITUDE)
MwAltitude = (int32_t)GPS_altitude*100;
if (millis()>timer.fwAltitudeTimer){
timer.fwAltitudeTimer +=1000;
previousfwaltitude=interimfwaltitude;
interimfwaltitude=GPS_altitude;
MwVario=(GPS_altitude-previousfwaltitude)*20;
}
gpsvario();
#else
MwAltitude =read32();
MwVario = read16();
Expand Down Expand Up @@ -299,7 +294,7 @@ void serialMSPCheck()
tpa_breakpoint16 = read16();
rcYawExpo8 = read8();
modeMSPRequests &=~ REQ_MSP_RC_TUNING;
#elif CLEANFLIGHT181
#elif defined CLEANFLIGHT181
rcRate8 = read8();
rcExpo8 = read8();
PitchRate = read8();
Expand Down

0 comments on commit 69e1146

Please sign in to comment.