comparison Discovery/Src/t7.c @ 539:d784f281833a

Added inertia simulation for compass heading: In previous version calculated compass values were directly used for visualization of the compass. This causes a fast changing (jumping) of values. With the inertia introduction the compass behalfs more like an analog compass. The final value is reached slowly and the displayed values are more stable. For configuration a new menu item has been added to the compass menu allowing to switch inertia off (default), small and large inertia simulation
author Ideenmodellierer
date Sat, 10 Oct 2020 16:59:18 +0200
parents 0ad0b26ec56b
children 43a2dd4ba30f
comparison
equal deleted inserted replaced
538:b1eee27cd02b 539:d784f281833a
1632 { 1632 {
1633 static uint8_t last_customview = CVIEW_END; 1633 static uint8_t last_customview = CVIEW_END;
1634 1634
1635 char text[256]; 1635 char text[256];
1636 uint16_t textpointer = 0; 1636 uint16_t textpointer = 0;
1637 uint16_t heading = 0;
1637 int16_t start; 1638 int16_t start;
1638 uint8_t lineCountCustomtext = 0; 1639 uint8_t lineCountCustomtext = 0;
1639 int16_t shiftWindowY0; 1640 int16_t shiftWindowY0;
1640 RTC_DateTypeDef Sdate; 1641 RTC_DateTypeDef Sdate;
1641 RTC_TimeTypeDef Stime; 1642 RTC_TimeTypeDef Stime;
1675 break; 1676 break;
1676 1677
1677 case CVIEW_CompassDebug: 1678 case CVIEW_CompassDebug:
1678 snprintf(text,100,"\032\f\001Compass raw"); 1679 snprintf(text,100,"\032\f\001Compass raw");
1679 GFX_write_string(&FontT42,&t7cH,text,0); 1680 GFX_write_string(&FontT42,&t7cH,text,0);
1680 /*
1681 pStateReal->lifeData.compass_heading = dataIn.data[dataIn.boolCompassData].compass_heading;
1682 pStateReal->lifeData.compass_roll = dataIn.data[dataIn.boolCompassData].compass_roll;
1683 pStateReal->lifeData.compass_pitch = dataIn.data[dataIn.boolCompassData].compass_pitch;
1684
1685 pStateReal->lifeData.compass_DX_f = dataIn.data[dataIn.boolCompassData].compass_DX_f;
1686 pStateReal->lifeData.compass_DY_f = dataIn.data[dataIn.boolCompassData].compass_DY_f;
1687 pStateReal->lifeData.compass_DZ_f = dataIn.data[dataIn.boolCompassData].compass_DZ_f;
1688 */
1689 snprintf(text,255,"%1.1f\n\r%1.1f\n\r%1.1f\n\r%i\n\r%i\n\r%i" 1681 snprintf(text,255,"%1.1f\n\r%1.1f\n\r%1.1f\n\r%i\n\r%i\n\r%i"
1690 ,stateUsed->lifeData.compass_heading 1682 ,stateUsed->lifeData.compass_heading
1691 ,stateUsed->lifeData.compass_roll 1683 ,stateUsed->lifeData.compass_roll
1692 ,stateUsed->lifeData.compass_pitch 1684 ,stateUsed->lifeData.compass_pitch
1693 ,stateUsed->lifeData.compass_DX_f 1685 ,stateUsed->lifeData.compass_DX_f
1976 } 1968 }
1977 break; 1969 break;
1978 1970
1979 case CVIEW_Compass: 1971 case CVIEW_Compass:
1980 default: 1972 default:
1973
1974 if(pSettings->compassInertia)
1975 {
1976 heading = (uint16_t)compass_getCompensated();
1977 }
1978 else
1979 {
1980 heading = (uint16_t)stateUsed->lifeData.compass_heading;
1981 }
1981 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE, TXT2BYTE_Compass); 1982 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE, TXT2BYTE_Compass);
1982 GFX_write_string(&FontT42,&t7cH,text,0); 1983 GFX_write_string(&FontT42,&t7cH,text,0);
1983 t7_compass((uint16_t)stateUsed->lifeData.compass_heading, stateUsed->diveSettings.compassHeading); 1984 t7_compass(heading, stateUsed->diveSettings.compassHeading);
1984 1985
1985 if(!pSettings->FlipDisplay) 1986 if(!pSettings->FlipDisplay)
1986 { 1987 {
1987 t7cY0free.WindowX0 += 15; 1988 t7cY0free.WindowX0 += 15;
1988 t7cY0free.WindowY0 = 230; 1989 t7cY0free.WindowY0 = 230;
1991 { 1992 {
1992 t7cY0free.WindowX0 -= 15; 1993 t7cY0free.WindowX0 -= 15;
1993 t7cY0free.WindowY0 = 0; 1994 t7cY0free.WindowY0 = 0;
1994 t7cY0free.WindowY1 = 250; 1995 t7cY0free.WindowY1 = 250;
1995 } 1996 }
1996 snprintf(text,100,"\030\001%03i`",(uint16_t)stateUsed->lifeData.compass_heading); 1997 snprintf(text,100,"\030\001%03i`",heading);
1997 GFX_write_string(&FontT54,&t7cY0free,text,0); 1998 GFX_write_string(&FontT54,&t7cY0free,text,0);
1998 if(!pSettings->FlipDisplay) 1999 if(!pSettings->FlipDisplay)
1999 { 2000 {
2000 t7cY0free.WindowX0 -= 15; 2001 t7cY0free.WindowX0 -= 15;
2001 } 2002 }
2745 2746
2746 uint8_t t7_customtextPrepare(char * text) 2747 uint8_t t7_customtextPrepare(char * text)
2747 { 2748 {
2748 uint8_t i, j, textptr, lineCount; 2749 uint8_t i, j, textptr, lineCount;
2749 char nextChar; 2750 char nextChar;
2751 uint8_t alignmentChanged = 0;
2750 2752
2751 textptr = 0; 2753 textptr = 0;
2752 lineCount = 0; 2754 lineCount = 0;
2753 2755
2754 text[textptr++] = TXT_MINIMAL; 2756 text[textptr++] = TXT_MINIMAL;
2760 j += i; 2762 j += i;
2761 i = 0; 2763 i = 0;
2762 do 2764 do
2763 { 2765 {
2764 nextChar = settingsGetPointer()->customtext[i+j]; 2766 nextChar = settingsGetPointer()->customtext[i+j];
2765 if(nextChar == '^') /* center */ 2767 if((nextChar == '^') && (alignmentChanged == 0)) /* center */
2766 { 2768 {
2767 text[textptr++] = '\001'; 2769 text[textptr++] = '\001';
2770 alignmentChanged = 1;
2768 i++; 2771 i++;
2769 }else 2772 }else
2770 if(nextChar == 180) /* '´' => Right */ 2773 if((nextChar == 180) && (alignmentChanged == 0)) /* '�' => Right */
2771 { 2774 {
2772 text[textptr++] = '\002'; 2775 text[textptr++] = '\002';
2776 alignmentChanged = 1;
2773 i++; 2777 i++;
2774 }else 2778 }else
2775 { 2779 {
2776 i++; 2780 i++;
2777 if((!nextChar) || (nextChar =='\n') || (nextChar =='\r')) 2781 if((!nextChar) || (nextChar =='\n') || (nextChar =='\r'))
2796 if(lineCount < 3) 2800 if(lineCount < 3)
2797 { 2801 {
2798 text[textptr++] = '\n'; 2802 text[textptr++] = '\n';
2799 text[textptr++] = '\r'; 2803 text[textptr++] = '\r';
2800 } 2804 }
2805 alignmentChanged = 0;
2801 lineCount++; 2806 lineCount++;
2802 for(uint8_t k=0;k<2;k++) 2807 for(uint8_t k=0;k<2;k++)
2803 { 2808 {
2804 nextChar = settingsGetPointer()->customtext[i+j+k]; 2809 nextChar = settingsGetPointer()->customtext[i+j+k];
2805 if((nextChar =='\n') || (nextChar =='\r')) 2810 if((nextChar =='\n') || (nextChar =='\r'))