comparison Discovery/Src/t7.c @ 737:5071d554aaa5

NEW: Add mini compass with marker declination indication Contribution from mikeller
author heinrichsweikamp
date Mon, 06 Mar 2023 16:03:00 +0100
parents 8adf9b8fc7fa
children 5078da3845c0
comparison
equal deleted inserted replaced
736:8a2337c7af52 737:5071d554aaa5
25 /// You should have received a copy of the GNU General Public License 25 /// You should have received a copy of the GNU General Public License
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
27 ////////////////////////////////////////////////////////////////////////////// 27 //////////////////////////////////////////////////////////////////////////////
28 28
29 /* Includes ------------------------------------------------------------------*/ 29 /* Includes ------------------------------------------------------------------*/
30 #include <stdlib.h>
31
30 #include "t7.h" 32 #include "t7.h"
31 #include "t3.h" 33 #include "t3.h"
32 #include "settings.h" 34 #include "settings.h"
33 #include "data_exchange_main.h" 35 #include "data_exchange_main.h"
34 #include "decom.h" 36 #include "decom.h"
2896 headerText[2] = TXT_AtemGasVorrat; 2898 headerText[2] = TXT_AtemGasVorrat;
2897 tinyHeaderFont = 1; 2899 tinyHeaderFont = 1;
2898 snprintf(text,TEXTSIZE,"%d\016\016\017", stateUsed->lifeData.bottle_bar[stateUsed->lifeData.actualGas.GasIdInSettings]); 2900 snprintf(text,TEXTSIZE,"%d\016\016\017", stateUsed->lifeData.bottle_bar[stateUsed->lifeData.actualGas.GasIdInSettings]);
2899 break; 2901 break;
2900 #endif 2902 #endif
2901 } 2903 case LLC_Compass:
2902 headerText[3] = 0; 2904 headerText[2] = TXT_2BYTE;
2905 headerText[3] = TXT2BYTE_Compass;
2906 tinyHeaderFont = 1;
2907
2908 uint16_t heading;
2909 if(settingsGetPointer()->compassInertia) {
2910 heading = (uint16_t)compass_getCompensated();
2911 } else {
2912 heading = (uint16_t)stateUsed->lifeData.compass_heading;
2913 }
2914
2915 uint16_t userSetHeading = stateUsed->diveSettings.compassHeading;
2916 if (!userSetHeading) {
2917 snprintf(text, TEXTSIZE, "\020\002\034%u ", heading);
2918 } else {
2919 snprintf(text, TEXTSIZE, "\020\002\034\016\016%u ", heading);
2920
2921 int16_t declinationFromForwardMark = ((userSetHeading - heading + 180 + 360) % 360) - 180;
2922 int16_t declinationFromNearestMark = ((declinationFromForwardMark + 90 + 180) % 180) - 90;
2923
2924 uint16_t colour;
2925 if (abs(declinationFromForwardMark) <= 90) {
2926 colour = CLUT_CompassUserHeadingTick;
2927 } else {
2928 colour = CLUT_CompassUserBackHeadingTick;
2929 }
2930
2931 char direction[] = "\001 \004 \004 ";
2932 if (abs(declinationFromNearestMark) <= 10) {
2933 direction[2] = '>';
2934 direction[6] = '<';
2935
2936 if (abs(declinationFromForwardMark) <= 10) {
2937 direction[4] = 'X';
2938 } else {
2939 direction[4] = 'O';
2940 }
2941
2942 if (abs(declinationFromNearestMark) <= 3) {
2943 direction[3] = '\a';
2944 direction[5] = '\a';
2945 }
2946 } else {
2947 if (declinationFromForwardMark < -90) {
2948 direction[7] = 'O';
2949 } else if (declinationFromForwardMark < 0) {
2950 direction[1] = 'X';
2951 } else if (declinationFromForwardMark <= 90) {
2952 direction[7] = 'X';
2953 } else {
2954 direction[1] = 'O';
2955 }
2956
2957 if (declinationFromNearestMark >= 0) {
2958 direction[6] = '>';
2959 }
2960 if (declinationFromNearestMark > 30) {
2961 direction[4] = '>';
2962 }
2963 if (declinationFromNearestMark > 60 || declinationFromForwardMark == 90) {
2964 direction[2] = '>';
2965 }
2966 if (declinationFromNearestMark < 0) {
2967 direction[2] = '<';
2968 }
2969 if (declinationFromNearestMark < -30) {
2970 direction[4] = '<';
2971 }
2972 if (declinationFromNearestMark < -60 || declinationFromForwardMark == -90) {
2973 direction[6] = '<';
2974 }
2975 }
2976
2977 GFX_write_string_color(&FontT48, &t7l3, direction, 1, colour);
2978 }
2979
2980 break;
2981 }
2982
2983 if (headerText[2] != TXT_2BYTE) {
2984 headerText[3] = 0;
2985 } else {
2986 headerText[4] = 0;
2987 }
2903 2988
2904 if(tinyHeaderFont) 2989 if(tinyHeaderFont)
2905 GFX_write_string(&FontT24,&t7l3,headerText,0); 2990 GFX_write_string(&FontT24,&t7l3,headerText,0);
2906 else 2991 else
2907 GFX_write_string(&FontT42,&t7l3,headerText,0); 2992 GFX_write_string(&FontT42,&t7l3,headerText,0);