comparison Discovery/Src/t7.c @ 770:8deb28b2d4da

CCR overview in surface mode. Makes it easy to quickly check that all settings (mode, setpoints, diluent, scrubber timer) are correct when preparing to dive (also makes the OC gas list available in surface mode for the same reason).
author heinrichsweikamp
date Fri, 21 Apr 2023 09:47:44 +0200
parents 9825dcf50675
children 2c243233c999
comparison
equal deleted inserted replaced
769:6b248bcdbf28 770:8deb28b2d4da
139 // CVIEW_CompassDebug, 139 // CVIEW_CompassDebug,
140 CVIEW_Hello, 140 CVIEW_Hello,
141 CVIEW_sensors, 141 CVIEW_sensors,
142 CVIEW_Compass, 142 CVIEW_Compass,
143 CVIEW_Tissues, 143 CVIEW_Tissues,
144 CVIEW_Gaslist,
144 CVIEW_sensors_mV, 145 CVIEW_sensors_mV,
145 CVIEW_Charger, 146 CVIEW_Charger,
147 CVIEW_CcrSummary,
146 CVIEW_END 148 CVIEW_END
147 }; 149 };
148 150
149 151
150 static uint8_t selection_custom_field = LLC_Temperature; 152 static uint8_t selection_custom_field = LLC_Temperature;
170 #define CUSTOMBOX_SPACE_INSIDE (CUSTOMBOX_LINE_RIGHT + 1 - (CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_INSIDE_OFFSET)) 172 #define CUSTOMBOX_SPACE_INSIDE (CUSTOMBOX_LINE_RIGHT + 1 - (CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_INSIDE_OFFSET))
171 #define TOP_LINE_HIGHT (25) 173 #define TOP_LINE_HIGHT (25)
172 174
173 #define SHOW_AMBIENTE_SURFACE_DELTA (0.02f) 175 #define SHOW_AMBIENTE_SURFACE_DELTA (0.02f)
174 #define SHOW_AMBIENTE_DEBOUNCE (0.003f) 176 #define SHOW_AMBIENTE_DEBOUNCE (0.003f)
177
178 #define MAX_NUM_SUMMARY_LINES 6
175 179
176 /* Exported functions --------------------------------------------------------*/ 180 /* Exported functions --------------------------------------------------------*/
177 181
178 void t7_init(void) 182 void t7_init(void)
179 { 183 {
1644 1648
1645 uint8_t t7_customview_disabled(uint8_t view) 1649 uint8_t t7_customview_disabled(uint8_t view)
1646 { 1650 {
1647 uint8_t i = 0; 1651 uint8_t i = 0;
1648 uint8_t cv_disabled = 0; 1652 uint8_t cv_disabled = 0;
1653 SSettings *settings = settingsGetPointer();
1649 1654
1650 while(cv_changelist[i] != CVIEW_END) 1655 while(cv_changelist[i] != CVIEW_END)
1651 { 1656 {
1652 if((view == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i])) 1657 if((view == cv_changelist[i]) && !CHECK_BIT_THOME(settings->cv_configuration, cv_changelist[i]))
1653 { 1658 {
1654 cv_disabled = 1; 1659 cv_disabled = 1;
1655 break; 1660 break;
1656 } 1661 }
1657 i++; 1662 i++;
1666 if ((view == CVIEW_Charger) && (stateUsed->chargeStatus != CHARGER_running) && (stateUsed->chargeStatus != CHARGER_lostConnection)) 1671 if ((view == CVIEW_Charger) && (stateUsed->chargeStatus != CHARGER_running) && (stateUsed->chargeStatus != CHARGER_lostConnection))
1667 { 1672 {
1668 cv_disabled = 1; 1673 cv_disabled = 1;
1669 } 1674 }
1670 1675
1676 if (view == CVIEW_CcrSummary && !isLoopMode(settings->dive_mode)) {
1677 cv_disabled = 1;
1678 }
1671 1679
1672 return cv_disabled; 1680 return cv_disabled;
1673 } 1681 }
1674 1682
1675 uint8_t t7_change_customview(uint8_t action) 1683 uint8_t t7_change_customview(uint8_t action)
1754 1762
1755 1763
1756 bool isCompassCalibrated(void) 1764 bool isCompassCalibrated(void)
1757 { 1765 {
1758 return stateUsed->lifeData.compass_heading != -1; 1766 return stateUsed->lifeData.compass_heading != -1;
1767 }
1768
1769
1770 static void t7_CcrSummary(SSettings *settings)
1771 {
1772 unsigned numLines = 1; // CCR Mode
1773
1774 SGasLine *diluentsToShow[MAX_NUM_SUMMARY_LINES - 1] = { NULL };
1775 unsigned i = NUM_OFFSET_DILUENT + 1;
1776 // Add diluent at start of dive
1777 while (i <= NUM_OFFSET_DILUENT + 1 + NUM_GASES) {
1778 if (settings->gas[i].note.ub.active && settings->gas[i].note.ub.first) {
1779 diluentsToShow[0] = &settings->gas[i];
1780 numLines++;
1781
1782 break;
1783 }
1784
1785 i++;
1786 }
1787
1788 bool showScrubberTime = false;
1789 if (settings->scrubTimerMode != SCRUB_TIMER_OFF) {
1790 numLines++;
1791 showScrubberTime = true;
1792 }
1793
1794 bool showManualSetpoints = false;
1795 unsigned offset;
1796 SSetpointLine *setpointsToShow[MAX_NUM_SUMMARY_LINES - 1] = { NULL };
1797 if (settings->CCR_Mode == CCRMODE_FixedSetpoint || settings->fallbackToFixedSetpoint) {
1798 // Add setpoint at start of dive
1799 offset = numLines;
1800 i = 1;
1801 while (i <= NUM_GASES) {
1802 if (settings->setpoint[i].note.ub.active && settings->setpoint[i].note.ub.first) {
1803 setpointsToShow[numLines - offset] = &settings->setpoint[i];
1804 numLines++;
1805
1806 break;
1807 }
1808
1809 i++;
1810 }
1811
1812 if (settings->autoSetpoint) {
1813 i = 1;
1814 while (i <= NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) {
1815 if (settings->setpoint[i].note.ub.active && !settings->setpoint[i].note.ub.first && settings->setpoint[i].depth_meter) {
1816 setpointsToShow[numLines - offset] = &settings->setpoint[i];
1817 numLines++;
1818 }
1819
1820 i++;
1821 }
1822 } else {
1823 showManualSetpoints = true;
1824 }
1825 }
1826
1827 // Add remaining active diluents
1828 i = NUM_OFFSET_DILUENT + 1;
1829 offset = numLines;
1830 if (diluentsToShow[0]) {
1831 offset--;
1832 }
1833 while (i < NUM_OFFSET_DILUENT + 1 + NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) {
1834 if (settings->gas[i].note.ub.active && !settings->gas[i].note.ub.first) {
1835 diluentsToShow[numLines - offset] = &settings->gas[i];
1836 numLines++;
1837 }
1838
1839 i++;
1840 }
1841
1842 if (showManualSetpoints) {
1843 // Fill up the remaining lines with setpoints
1844 offset = numLines;
1845 if (setpointsToShow[0]) {
1846 offset--;
1847 }
1848 i = 2;
1849 while (i <= NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) {
1850 if (settings->setpoint[i].note.ub.active && !settings->setpoint[i].note.ub.first) {
1851 setpointsToShow[numLines - offset] = &settings->setpoint[i];
1852 numLines++;
1853 }
1854
1855 i++;
1856 }
1857 }
1858
1859 char heading[128];
1860 unsigned headingIndex = 0;
1861
1862 char data[128];
1863 unsigned dataIndex = 0;
1864
1865 heading[headingIndex++] = '\032';
1866 heading[headingIndex++] = '\016';
1867 heading[headingIndex++] = '\016';
1868 heading[headingIndex++] = TXT_CCRmode;
1869
1870 data[dataIndex++] = '\t';
1871 char *modeText;
1872 if (settings->CCR_Mode == CCRMODE_Sensors) {
1873 if (settings->fallbackToFixedSetpoint) {
1874 modeText = (char *)&"Sens/FB";
1875 } else {
1876 modeText = (char *)&"Sensor";
1877 }
1878 } else {
1879 modeText = (char *)&"Fixed";
1880 }
1881 dataIndex += snprintf(&data[dataIndex], 10, "\020%s", modeText);
1882
1883 i = 0;
1884 while (setpointsToShow[i] != NULL && i < MAX_NUM_SUMMARY_LINES - 1) {
1885 heading[headingIndex++] = '\n';
1886 heading[headingIndex++] = '\r';
1887 if (i == 0) {
1888 heading[headingIndex++] = TXT_2BYTE;
1889 heading[headingIndex++] = TXT2BYTE_Setpoint;
1890 }
1891
1892 data[dataIndex++] = '\n';
1893 data[dataIndex++] = '\r';
1894 data[dataIndex++] = '\t';
1895 dataIndex += snprintf(&data[dataIndex], 10, "\020%01.2f", setpointsToShow[i]->setpoint_cbar / 100.0);
1896 if (settings->autoSetpoint) {
1897 dataIndex += snprintf(&data[dataIndex], 10, "\016\016 %um\017", setpointsToShow[i]->depth_meter);
1898 }
1899
1900 i++;
1901 }
1902
1903 i = 0;
1904 while (diluentsToShow[i] != NULL && i < MAX_NUM_SUMMARY_LINES - 1) {
1905 heading[headingIndex++] = '\n';
1906 heading[headingIndex++] = '\r';
1907 if (i == 0) {
1908 heading[headingIndex++] = TXT_Diluent_Gas_Edit;
1909 }
1910
1911 data[dataIndex++] = '\n';
1912 data[dataIndex++] = '\r';
1913 data[dataIndex++] = '\t';
1914 data[dataIndex++] = '\020';
1915 dataIndex += write_gas(&data[dataIndex], diluentsToShow[i]->oxygen_percentage, diluentsToShow[i]->helium_percentage);
1916 if (diluentsToShow[i]->note.ub.deco) {
1917 char *space = " ";
1918 if (diluentsToShow[i]->depth_meter > 99) {
1919 space = (char *)"";
1920 }
1921 dataIndex += snprintf(&data[dataIndex], 10, "\016\016%s%um\017", space, diluentsToShow[i]->depth_meter);
1922 }
1923
1924 i++;
1925 }
1926
1927 if (showScrubberTime) {
1928 heading[headingIndex++] = '\n';
1929 heading[headingIndex++] = '\r';
1930 heading[headingIndex++] = TXT_2BYTE;
1931 heading[headingIndex++] = TXT2BYTE_Scrubber;
1932
1933 data[dataIndex++] = '\n';
1934 data[dataIndex++] = '\r';
1935 data[dataIndex++] = '\t';
1936 dataIndex += printScrubberText(&data[dataIndex], 10, settings);
1937 }
1938
1939 heading[headingIndex++] = '\017';
1940 heading[headingIndex++] = 0;
1941
1942 data[dataIndex++] = 0;
1943
1944 t7cY0free.WindowLineSpacing = 48;
1945 t7cY0free.WindowNumberOfTextLines = 6;
1946 t7cY0free.WindowTab = 375;
1947
1948 t7cY0free.WindowY0 = t7cC.WindowY0 - 10;
1949 if (!settings->FlipDisplay) {
1950 t7cY0free.WindowX0 += 10;
1951 t7cY0free.WindowY0 += 10;
1952 t7cY0free.WindowY1 = 355;
1953 GFX_write_string(&FontT24, &t7cY0free, heading, 1);
1954 t7cY0free.WindowX0 -= 10;
1955 t7cY0free.WindowY0 -= 10;
1956 } else {
1957 t7cY0free.WindowY1 -= 10;
1958 t7cY0free.WindowX1 -= 10;
1959 GFX_write_string(&FontT24, &t7cY0free, heading, 1);
1960 t7cY0free.WindowY1 += 10;
1961 t7cY0free.WindowX1 += 10;
1962 }
1963
1964 t7_colorscheme_mod(data);
1965
1966 GFX_write_string(&FontT42, &t7cY0free, data, 1);
1759 } 1967 }
1760 1968
1761 1969
1762 void t7_refresh_customview(void) 1970 void t7_refresh_customview(void)
1763 { 1971 {
2294 } 2502 }
2295 2503
2296 t7cY0free.WindowLineSpacing = 48; 2504 t7cY0free.WindowLineSpacing = 48;
2297 t7cY0free.WindowNumberOfTextLines = 6; 2505 t7cY0free.WindowNumberOfTextLines = 6;
2298 GFX_write_string(&FontT42, &t7cY0free, text, 1); 2506 GFX_write_string(&FontT42, &t7cY0free, text, 1);
2507 break;
2508 case CVIEW_CcrSummary:
2509 snprintf(text, 100, "\032\f\001%c%c", TXT_2BYTE, TXT2BYTE_CcrSummary);
2510 GFX_write_string(&FontT42, &t7cH, text, 0);
2511
2512 t7_CcrSummary(pSettings);
2513
2299 break; 2514 break;
2300 } 2515 }
2301 } 2516 }
2302 2517
2303 2518