# HG changeset patch # User Thorsten # Date 1552846619 -3600 # Node ID d328abe2e44e30e93d9a36abf02965b5430f0764 # Parent 4073b80912244fbc83a9efbd4ad9c2afbe2a132d# Parent cca59de24fe08775840c1c519a115c49bb7137e7 Merged heinrichsweikamp/ostc4 into default diff -r 4073b8091224 -r d328abe2e44e Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Discovery/Src/data_exchange_main.c Sun Mar 17 19:16:59 2019 +0100 @@ -771,6 +771,20 @@ return (depth[0] + depth[1] + depth[2] + depth[3])/4.0f; } +#define TEMP_AVERAGE_COUNT 3 +static float getTemperature(SDataExchangeSlaveToMaster *d) +{ + static uint8_t c = 0; + static float temp[TEMP_AVERAGE_COUNT] = {0}; + + temp[c] = d->data[d->boolPressureData].temperature; + + c++; + if (c == TEMP_AVERAGE_COUNT) c = 0; + + return (temp[0] + temp[1] + temp[2])/3.0f; +} + void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) { SDiveState *pStateReal = stateRealGetPointerWrite(); @@ -937,7 +951,7 @@ pStateReal->lifeData.depth_meter = meter; } - pStateReal->lifeData.temperature_celsius = dataIn.data[dataIn.boolPressureData].temperature; + pStateReal->lifeData.temperature_celsius = getTemperature(&dataIn); pStateReal->lifeData.ascent_rate_meter_per_min = dataIn.data[dataIn.boolPressureData].ascent_rate_meter_per_min; if(pStateReal->mode != MODE_DIVE) pStateReal->lifeData.max_depth_meter = 0; diff -r 4073b8091224 -r d328abe2e44e Discovery/Src/show_logbook.c --- a/Discovery/Src/show_logbook.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Discovery/Src/show_logbook.c Sun Mar 17 19:16:59 2019 +0100 @@ -40,58 +40,27 @@ /* Private variables ---------------------------------------------------------*/ -GFX_DrawCfgScreen tLOGscreen; -GFX_DrawCfgScreen tLOGbackground; +static GFX_DrawCfgScreen tLOGscreen; +static GFX_DrawCfgScreen tLOGbackground; -void print_gas_name(char* output,uint8_t lengh,uint8_t oxygen,uint8_t helium); -int16_t get_colour(int16_t color); +static void print_gas_name(char* output,uint8_t lengh,uint8_t oxygen,uint8_t helium); +static int16_t get_colour(int16_t color); /* Overview */ -void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); +static void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); /* Temperature */ -void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); +static void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); /* Gas List */ -void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); +static void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); /* ppO2 */ -void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); +static void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); - -inline uint32_t MinU32LOG(uint32_t a, uint32_t b) -{ - return ((ab)?a:b); } -void write_label_(GFX_DrawCfgScreen *screenInput, SWindowGimpStyle win, const tFont *Font, uint8_t color, const char *text) -{ - GFX_DrawCfgWindow hgfx; - - if( win.right > 799) - win.right = 799; - - if(win.top > 479) - win.top = 479; - hgfx.Image = screenInput; - hgfx.WindowNumberOfTextLines = 1; - hgfx.WindowLineSpacing = 0; - hgfx.WindowTab = 0; - hgfx.WindowX0 = win.left; - hgfx.WindowX1 = win.right; - hgfx.WindowY1 = 479 - win.top; - if(hgfx.WindowY1 < Font->height) - hgfx.WindowY0 = 0; - else - hgfx.WindowY0 = hgfx.WindowY1 - Font->height; - - GFX_write_label(Font, &hgfx, text, color); -} - - /** ****************************************************************************** * @brief GFX write label. / print coordinate system & depth graph @@ -108,7 +77,7 @@ * @param colordata: 1 * @retval None */ -void show_logbook_draw_depth_graph(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards, SWindowGimpStyle* window, short mode, uint16_t dataLength, uint16_t* depthdata, uint8_t * colordata, uint16_t * decostopdata) +static void show_logbook_draw_depth_graph(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards, SWindowGimpStyle* window, short mode, uint16_t dataLength, uint16_t* depthdata, uint8_t * colordata, uint16_t * decostopdata) { SLogbookHeader logbookHeader; SWindowGimpStyle wintemp = *window; @@ -285,7 +254,7 @@ * fit to multiples of 1�C (data format is 1/10�C) */ -void scaleAdapt( int InputTop, int InputBottom, +static void scaleAdapt( int InputTop, int InputBottom, int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom, uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale) { @@ -387,7 +356,7 @@ * for temperature, input is �C * 10 */ -void scaleHelper( uint16_t InputDataLength, int16_t *InputDataArray, int InputTop, int InputBottom, +static void scaleHelper( uint16_t InputDataLength, int16_t *InputDataArray, int InputTop, int InputBottom, int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom, uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale) { @@ -441,7 +410,7 @@ * @param hgfx: * @retval None */ -void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx,uint8_t StepBackwards) +static void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx,uint8_t StepBackwards) { SWindowGimpStyle wintemp; SWindowGimpStyle winsmal; @@ -661,7 +630,7 @@ } -void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) +static void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) { //*** Page2: Depth and Temperature **** @@ -751,189 +720,7 @@ } -void show_logbook_logbook_show_log_page2_original(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) -{ - //*** Page2: Depth and Temperature **** - - SWindowGimpStyle wintemp; - SWindowGimpStyle winsmal; - wintemp.left = 50; - wintemp.right = 799 - wintemp.left; - wintemp.top = 50; - wintemp.bottom = 479 - 40; - - SLogbookHeader logbookHeader; - - logbook_getHeader(StepBackwards,&logbookHeader); - uint16_t dataLength = 0; - uint16_t depthdata[1000]; - uint8_t gasdata[1000]; - int16_t tempdata[1000]; - uint16_t decoDepthdata[1000]; - uint16_t *pDecoDepthData = 0; - - dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, decoDepthdata); - -/* test - for(int i = 0; i= 300) - { - pDecoDepthData = decoDepthdata; - break; - } - } - //--- print coordinate system & depth graph --- - show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, pDecoDepthData); - - //*** Temperature ************************************************* - - - int16_t datamax = -1000; // �C * 10 - int16_t datamin = +1000; - for(int i = 0; i < dataLength;i++) - { - if(tempdata[i]>datamax) - datamax = tempdata[i]; - if(tempdata[i]< datamin) - datamin = tempdata[i]; - } - float maxTmp = ((float)datamax) /10.f; - float minTmp = ((float)datamin) /10.f; - int deltaTmp = maxTmp - minTmp; - int tmpstep = 2; - - // 5 different scales: 1�C, 2�C, 4�C, 5�C, 10�C - // with 6 lines == 5 steps - if((deltaTmp) <=5) - { - tmpstep = 1; - } - else - if(deltaTmp <= (5*2)) - { - tmpstep = 2; - } - else - if(deltaTmp <= (5 * 4)) - { - tmpstep = 4; - } - else - if(deltaTmp <= (5 * 5)) - { - tmpstep = 5; - } - else - { - tmpstep = 10; - } -// int steps = deltaTmp/tmpstep; - - -// int steps = deltaTmp/5; -// int tmpstep = 5; -// if(steps > 4) -// tmpstep = 10; - - int maxtmpline = 0; - int mintmpline = 0; - if(minTmp < 0) - { - if(minTmp >= -5) - { - mintmpline = -5; - - } - else if(minTmp >= -10) - { - mintmpline = -10; - } - else - mintmpline = -15; - } - - if(maxTmp > 0) - { - while(maxtmpline < maxTmp) - maxtmpline += tmpstep; - } - - if(tmpstep < 5) - maxtmpline = MaxU32LOG(maxtmpline, 10); - else if(tmpstep == 5) - maxtmpline = MaxU32LOG(maxtmpline, 25); - else - maxtmpline = 50; - - maxtmpline += mintmpline; - - //--- print temperature labels --- - // input maxtmpline, tmpstep, deltaline - - winsmal.left = wintemp.right +6; - winsmal.top = wintemp.top - 3; - winsmal.right = wintemp.right + 30; - winsmal.bottom = winsmal.top + 16; - - write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,"[C]"); - - int deltaline = (wintemp.bottom - wintemp.top)/5; - char msg[3]; - int tmp = maxtmpline; - for(int i = 1; i<=5; i++) - { - tmp -= tmpstep; - //if(tmp < 0) - //break; - winsmal.top = wintemp.top + deltaline * i - 14; - winsmal.bottom = winsmal.top + 16; - snprintf(msg,3,"%2i",tmp); - write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,msg); - } - - - //--- print temperature graph --- - // input tempdata[i], maxtmpline, mintmpline, maxTmp, minTmp, deltaline, wintemp.top, dataLength, datamax, - - //adapt window - float ftmp =((maxtmpline - minTmp) * deltaline) /tmpstep + wintemp.top; - wintemp.bottom = ftmp; - if((ftmp - (int)ftmp) >= 0.5f) - wintemp.bottom++; - - ftmp = ((maxtmpline - maxTmp) * deltaline) /tmpstep + wintemp.top; - wintemp.top = ftmp; - if((ftmp - (int)ftmp) >= 0.5f) - wintemp.top++; - - if(wintemp.top <= wintemp.bottom) - { - for(int i = 0; i < dataLength;i++) - { - tempdata[i] -= mintmpline; - } - datamax -= mintmpline; - // hw 160518 - // es wird nur das Fenster (wintemp.top, wintemp.bottom) verwendet in dem Daten sind - // daher muss datamin angegeben werden - // der Gesamtbereich ist uninteressant - // Bsp Temperatur von 8�C bis 5�C - // Y-Achse ist 10�C (oben) bis 0�C (unten) - // aber wintemp.top ist 127 - // und wintemp.bottom ist 243 - GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, (uint16_t *)tempdata,dataLength,CLUT_LogbookTemperature, NULL); - } -} - - -void build_logbook_test(uint8_t page, uint8_t StepBackwards) +static void build_logbook_test(uint8_t page, uint8_t StepBackwards) { uint32_t lastScreen,lastBackground; @@ -1000,7 +787,7 @@ } -void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) +static void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) { SWindowGimpStyle wintemp; SWindowGimpStyle winsmal; @@ -1051,7 +838,7 @@ */ } -void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) +static void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) { SWindowGimpStyle wintemp; SWindowGimpStyle winsmal; wintemp.left = 50; @@ -1217,7 +1004,7 @@ //button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next); } -void print_gas_name(char* output,uint8_t length,uint8_t oxygen,uint8_t helium) +static void print_gas_name(char* output,uint8_t length,uint8_t oxygen,uint8_t helium) { if(helium == 0) { @@ -1238,7 +1025,7 @@ } -int16_t get_colour(int16_t color) +static int16_t get_colour(int16_t color) { return CLUT_GasSensor1 + color; } diff -r 4073b8091224 -r d328abe2e44e Discovery/Src/t3.c --- a/Discovery/Src/t3.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Discovery/Src/t3.c Sun Mar 17 19:16:59 2019 +0100 @@ -52,9 +52,6 @@ GFX_DrawCfgWindow t3c1; GFX_DrawCfgWindow t3c2; -extern float temperatureLastCall[3]; -extern uint8_t idTemperatureLastCall; - uint8_t t3_selection_customview = 0; /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/ @@ -507,7 +504,6 @@ uint16_t textpointer = 0; // CVIEW_T3_Temperature - float temperatureThisCall; float temperature; SDivetime TotalDivetime = {0,0,0,0}; @@ -527,13 +523,7 @@ snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature); GFX_write_string(&FontT42,tXc1,text,0); - // mean value - temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius); - temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f; - idTemperatureLastCall++; - if(idTemperatureLastCall >= 3) - idTemperatureLastCall = 0; - temperatureLastCall[idTemperatureLastCall] = temperatureThisCall; + temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius); textpointer = snprintf(text,TEXTSIZE,"\020\003\016%01.0f\016\016\140",temperature); // "\016\016%01.1f `" + C or F if(settingsGetPointer()->nonMetricalSystem == 0) text[textpointer++] = 'C'; @@ -606,7 +596,6 @@ uint8_t oxygen_percentage = 0; // CVIEW_T3_Temperature - float temperatureThisCall; float temperature; // CVIEW_T3_GasList @@ -619,7 +608,6 @@ SDivetime Stopwatch = {0,0,0,0}; float fAverageDepth, fAverageDepthAbsolute; - uint16_t tempWinX0; uint16_t tempWinX1; uint16_t tempWinY0; @@ -749,13 +737,8 @@ case CVIEW_T3_Temperature: snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature); GFX_write_string(&FontT42,tXc1,text,0); - // mean value - temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius); - temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f; - idTemperatureLastCall++; - if(idTemperatureLastCall >= 3) - idTemperatureLastCall = 0; - temperatureLastCall[idTemperatureLastCall] = temperatureThisCall; + + temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius); textpointer = snprintf(text,TEXTSIZE,"\030\003\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F if(settingsGetPointer()->nonMetricalSystem == 0) text[textpointer++] = 'C'; diff -r 4073b8091224 -r d328abe2e44e Discovery/Src/t6_apnea.c --- a/Discovery/Src/t6_apnea.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Discovery/Src/t6_apnea.c Sun Mar 17 19:16:59 2019 +0100 @@ -74,8 +74,6 @@ void t6_refresh_customview(float depth); uint8_t t6_test_customview_warnings(void); -void t6_show_customview_warnings(void); -void t6_compass(uint16_t ActualHeading, uint16_t UserSetHeading); /* Exported functions --------------------------------------------------------*/ @@ -331,398 +329,3 @@ count = 0; return count; } - -/* - - char text[512]; - uint16_t textpointer = 0; - - - // CVIEW_T3_Temperature - float temperatureThisCall; - float temperature; - - - // CVIEW_T3_StopWatch - SDivetime Stopwatch = {0,0,0,0}; - float fAverageDepth, fAverageDepthAbsolute; - uint16_t tempWinX0; - uint16_t tempWinY0; - - switch(t6_selection_customview) - { - case CVIEW_T3_ApnoeTimes: - break; - - case CVIEW_T3_StopWatch: - Stopwatch.Total = timer_Stopwatch_GetTime(); - Stopwatch.Minutes = Stopwatch.Total / 60; - Stopwatch.Seconds = Stopwatch.Total - ( Stopwatch.Minutes * 60 ); - fAverageDepth = timer_Stopwatch_GetAvarageDepth_Meter(); - fAverageDepthAbsolute = stateUsed->lifeData.average_depth_meter; - - snprintf(text,TEXTSIZE,"\032\f%c",TXT_AvgDepth); - GFX_write_string(&FontT42,&t6c1,text,0); - snprintf(text,TEXTSIZE,"\030\003\016%01.1f",fAverageDepthAbsolute); - GFX_write_string(&FontT105,&t6c1,text,0); - - tempWinX0 = t6c1.WindowX0; - tempWinY0 = t6c1.WindowY0; - t6c1.WindowX0 = 480; -// snprintf(text,TEXTSIZE,"\032\f%c%c - %c",TXT_2BYTE, TXT2BYTE_Clock, TXT_AvgDepth); - snprintf(text,TEXTSIZE,"\032\f%c", TXT_Stopwatch); - GFX_write_string(&FontT42,&t6c1,text,0); - snprintf(text,TEXTSIZE,"\030\016%01.1f",fAverageDepth); - GFX_write_string(&FontT105,&t6c1,text,0); - t6c1.WindowY0 = 100; - snprintf(text,TEXTSIZE,"\030%u:\016\016%02u",Stopwatch.Minutes, Stopwatch.Seconds); - GFX_write_string(&FontT105,&t6c1,text,0); - t6c1.WindowX0 = tempWinX0; - t6c1.WindowY0 = tempWinY0; - break; - - case CVIEW_T3_Temperature: - snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature); - GFX_write_string(&FontT42,&t6c1,text,0); - // mean value - temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius); - temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f; - idTemperatureLastCall++; - if(idTemperatureLastCall >= 3) - idTemperatureLastCall = 0; - temperatureLastCall[idTemperatureLastCall] = temperatureThisCall; - textpointer = snprintf(text,TEXTSIZE,"\030\003\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F - if(settingsGetPointer()->nonMetricalSystem == 0) - text[textpointer++] = 'C'; - else - text[textpointer++] = 'F'; - text[textpointer++] = 0; - GFX_write_string(&FontT105,&t6c1,text,0); - break; - - case CVIEW_Compass: - snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE, TXT2BYTE_Compass); - GFX_write_string(&FontT42,&t6c1,text,0); - snprintf(text,100,"\030\003%03i`",(uint16_t)stateUsed->lifeData.compass_heading); - GFX_write_string(&FontT105,&t6c1,text,0); - t6_compass((uint16_t)stateUsed->lifeData.compass_heading, stateUsed->diveSettings.compassHeading); - break; - - case CVIEW_T3_MaxDepth: - default: - snprintf(text,TEXTSIZE,"\032\f%c",TXT_MaxDepth); - GFX_write_string(&FontT42,&t6c1,text,0); - snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); - t3_basics_colorscheme_mod(text); - GFX_write_string(&FontT105,&t6c1,text,1); - break; - } -} - - -void t6_show_customview_warnings(void) -{ - char text[256], textMain[256]; - uint8_t textpointer, textpointerMain, lineFree, more; - - snprintf(text,TEXTSIZE,"\025\f%c",TXT_Warning); - GFX_write_string(&FontT42,&t6c1,text,0); - - lineFree = 1; - more = 0; - - textpointerMain = 0; - textMain[textpointerMain++] = '\025'; - textMain[textpointerMain++] = '\003'; - - textpointer = 0; - - text[textpointer++] = '\021'; - text[textpointer++] = TXT_2BYTE; - text[textpointer++] = TXT2BYTE_WarnDecoMissed; - if(stateUsed->warnings.decoMissed) - { - text[textpointer - 3] = '\025'; - if(lineFree) - { - textMain[textpointerMain++] = TXT_2BYTE; - textMain[textpointerMain++] = text[textpointer - 1]; - textMain[textpointerMain] = 0; - lineFree--; - } - else - { - more++; - } - } - - text[textpointer++] = '\t'; - text[textpointer++] = '\021'; - text[textpointer++] = TXT_2BYTE; - text[textpointer++] = TXT2BYTE_WarnPPO2Low; - if(stateUsed->warnings.ppO2Low) - { - text[textpointer - 3] = '\025'; - if(lineFree) - { - textMain[textpointerMain++] = TXT_2BYTE; - textMain[textpointerMain++] = text[textpointer - 1]; - textMain[textpointerMain] = 0; - lineFree--; - } - else - { - more++; - } - } - - text[textpointer++] = '\n'; - text[textpointer++] = '\r'; - text[textpointer++] = '\021'; - text[textpointer++] = TXT_2BYTE; - text[textpointer++] = TXT2BYTE_WarnPPO2High; - if(stateUsed->warnings.ppO2High) - { - text[textpointer - 3] = '\025'; - if(lineFree) - { - textMain[textpointerMain++] = TXT_2BYTE; - textMain[textpointerMain++] = text[textpointer - 1]; - textMain[textpointerMain] = 0; - lineFree--; - } - else - { - more++; - } - } - - text[textpointer++] = '\t'; - text[textpointer++] = '\021'; - text[textpointer++] = TXT_2BYTE; - text[textpointer++] = TXT2BYTE_WarnFallback; - if(stateUsed->warnings.fallback) - { - text[textpointer - 3] = '\025'; - if(lineFree) - { - textMain[textpointerMain++] = TXT_2BYTE; - textMain[textpointerMain++] = text[textpointer - 1]; - textMain[textpointerMain] = 0; - lineFree--; - } - else - { - more++; - } - } - - text[textpointer++] = '\n'; - text[textpointer++] = '\r'; - text[textpointer++] = '\021'; - text[textpointer++] = TXT_2BYTE; - text[textpointer++] = TXT2BYTE_WarnSensorLinkLost; - if(stateUsed->warnings.sensorLinkLost) - { - text[textpointer - 3] = '\025'; - if(lineFree) - { - textMain[textpointerMain++] = TXT_2BYTE; - textMain[textpointerMain++] = text[textpointer - 1]; - textMain[textpointerMain] = 0; - lineFree--; - } - else - { - more++; - } - } - - text[textpointer] = 0; - GFX_write_string(&FontT48,&t6c1,textMain,1); - if(more) - { - GFX_write_string(&FontT48,&t6c2,text,1); - } -} - - -void t6_change_customview(void) -{ - const uint8_t *pViews; - pViews = t6_customviews; - - while((*pViews != CVIEW_T3_END) && (*pViews != t6_selection_customview)) - {pViews++;} - - if(*pViews < CVIEW_T3_END) - pViews++; - - if(*pViews == CVIEW_T3_END) - { - t6_selection_customview = t6_customviews[0]; - } - else - t6_selection_customview = *pViews; -} - - -void t3_basics_colorscheme_mod(char *text) -{ - if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard()) - { - text[0] = '\027'; - } -} - -point_t t6_compass_circle(uint8_t id, uint16_t degree) -{ - float fCos, fSin; - const float piMult = ((2 * 3.14159) / 360); -// const int radius[4] = {95,105,115,60}; - const int radius[4] = {85,95,105,90}; - const point_t offset = {.x = 600, .y = 116}; - - static point_t r[4][360] = { 0 }; - - if(r[0][0].y == 0) - { - for(int i=0;i<360;i++) - { - fCos = cos(i * piMult); - fSin = sin(i * piMult); - for(int j=0;j<4;j++) - { - r[j][i].x = offset.x + (int)(fSin * radius[j]); - r[j][i].y = offset.y + (int)(fCos * radius[j]); - } - } - } - if(id > 3) id = 0; - if(degree > 359) degree = 0; - return r[id][degree]; -} - - -void t6_compass(uint16_t ActualHeading, uint16_t UserSetHeading) -{ - uint16_t LineHeading; - point_t center; - static int32_t LastHeading = 0; - int32_t newHeading = 0; - int32_t diff = 0; - int32_t diff2 = 0; - - int32_t diffAbs = 0; - int32_t diffAbs2 = 0; - - newHeading = ActualHeading; - - diff = newHeading - LastHeading; - - if(newHeading < LastHeading) - diff2 = newHeading + 360 - LastHeading; - else - diff2 = newHeading - 360 - LastHeading; - - diffAbs = diff; - if(diffAbs < 0) - diffAbs *= -1; - - diffAbs2 = diff2; - if(diffAbs2 < 0) - diffAbs2 *= -1; - - - if(diffAbs <= diffAbs2) - newHeading = LastHeading + (diff / 2); - else - newHeading = LastHeading + (diff2 / 2); - - if(newHeading < 0) - newHeading += 360; - else - if(newHeading >= 360) - newHeading -= 360; - - LastHeading = newHeading; - ActualHeading = newHeading; - - if (ActualHeading < 90) - ActualHeading += 360; - - while(ActualHeading > 359) ActualHeading -= 360; - - LineHeading = 360 - ActualHeading; - GFX_draw_thick_line(9,&t6screen, t6_compass_circle(0,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font030); // North - LineHeading += 90; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(9,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); // Maintick - LineHeading += 90; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(9,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - LineHeading += 90; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(9,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - - LineHeading = 360 - ActualHeading; - LineHeading += 45; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(5,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); // Subtick - LineHeading += 90; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(5,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - LineHeading += 90; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(5,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - LineHeading += 90; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(5,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - - LineHeading = 360 - ActualHeading; - LineHeading += 22; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); // Subtick - LineHeading += 45; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - LineHeading += 45; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - LineHeading += 45; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - LineHeading += 45; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); // Subtick - LineHeading += 45; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - LineHeading += 45; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - LineHeading += 45; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); - - if(UserSetHeading) - { - LineHeading = UserSetHeading + 360 - ActualHeading; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(9,&t6screen, t6_compass_circle(3,LineHeading), t6_compass_circle(2,LineHeading), CLUT_CompassUserHeadingTick); - - // R�ckpeilung, User Back Heading - LineHeading = UserSetHeading + 360 + 180 - ActualHeading; - if(LineHeading > 359) LineHeading -= 360; - if(LineHeading > 359) LineHeading -= 360; - GFX_draw_thick_line(9,&t6screen, t6_compass_circle(3,LineHeading), t6_compass_circle(2,LineHeading), CLUT_CompassUserBackHeadingTick); - } - - center.x = 600; - center.y = 116; - GFX_draw_circle(&t6screen, center, 106, CLUT_Font030); - GFX_draw_circle(&t6screen, center, 107, CLUT_Font030); - GFX_draw_circle(&t6screen, center, 108, CLUT_Font030); -} -*/ - diff -r 4073b8091224 -r d328abe2e44e Discovery/Src/t7.c --- a/Discovery/Src/t7.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Discovery/Src/t7.c Sun Mar 17 19:16:59 2019 +0100 @@ -74,10 +74,6 @@ /* Exported variables --------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ -float depthLastCall[9] = { 0,0,0,0,0,0,0,0,0}; -uint8_t idDepthLastCall = 0; -float temperatureLastCall[3] = { 0,0,0}; -uint8_t idTemperatureLastCall = 0; GFX_DrawCfgScreen t7screen; GFX_DrawCfgScreen t7screenCompass; @@ -663,7 +659,7 @@ ytop = 800 - state; else ytop = 0 + state; - Gfx_write_label_var(&t7screen, 300,800, ytop,&FontT48,CLUT_Font020,"SLEEP SLEEP SLEEP"); + Gfx_write_label_var(&t7screen, 300,800, ytop,&FontT48,CLUT_Font020,"Shutting down..."); } void t7_refresh_surface(void) @@ -2053,7 +2049,7 @@ t7_colorscheme_mod(TextL2); GFX_write_string(&FontT105,&t7l2,TextL2,1); - /* ascentrate graph */ + /* ascent rate graph */ if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) { if(!pSettings->FlipDisplay) @@ -2474,8 +2470,6 @@ const SDecoinfo * pDecoinfoStandard; const SDecoinfo * pDecoinfoFuture; float fCNS; - - float temperatureThisCall; float temperature; if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) @@ -2503,14 +2497,7 @@ /* Temperature */ case 1: default: - // mean value - temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius); - temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f; - idTemperatureLastCall++; - if(idTemperatureLastCall >= 3) - idTemperatureLastCall = 0; - temperatureLastCall[idTemperatureLastCall] = temperatureThisCall; - // output + temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius); headerText[2] = TXT_Temperature; textpointer = snprintf(text,TEXTSIZE,"\020\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F if(settingsGetPointer()->nonMetricalSystem == 0) diff -r 4073b8091224 -r d328abe2e44e Discovery/Src/tInfoLog.c --- a/Discovery/Src/tInfoLog.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Discovery/Src/tInfoLog.c Sun Mar 17 19:16:59 2019 +0100 @@ -57,7 +57,6 @@ SInfoLogMemory infolog; /* Private function prototypes -----------------------------------------------*/ -void nextLineInfoLog(void); void tInfoLog_BuildAndShowNextPage(void); void tInfoLog_nextLine(void); void showLog(void); @@ -162,6 +161,7 @@ case ACTION_MODE_CHANGE: case ACTION_BUTTON_BACK: stepBackInfo(); + break; default: break; case ACTION_IDLE_TICK: @@ -192,6 +192,7 @@ showLogExit(); } show_logbook_exit(); + break; default: break; case ACTION_IDLE_TICK: diff -r 4073b8091224 -r d328abe2e44e Discovery/Src/timer.c --- a/Discovery/Src/timer.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Discovery/Src/timer.c Sun Mar 17 19:16:59 2019 +0100 @@ -28,11 +28,10 @@ #include "data_central.h" -long stopWatchTime_Second = 0; -_Bool bStopWatch = false; -float stopWatchAverageDepth_Meter = 0.0f; -long safetyStopCountDown_Second = 0; -_Bool bSafetyStop = false; +static long stopWatchTime_Second = 0; +static _Bool bStopWatch = false; +static float stopWatchAverageDepth_Meter = 0.0f; +static long safetyStopCountDown_Second = 0; void timer_init(void) { @@ -48,7 +47,7 @@ static int last_second = -1; static _Bool bSafetyStop = false; static float last_depth_meter = 0; - //static _Bool CountDownStarted = false; + if(checkOncePerSecond) { int now = current_second(); diff -r 4073b8091224 -r d328abe2e44e Small_CPU/Src/pressure.c --- a/Small_CPU/Src/pressure.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Small_CPU/Src/pressure.c Sun Mar 17 19:16:59 2019 +0100 @@ -46,30 +46,24 @@ #define CMD_ADC_4096 0x08 // ADC OSR=4096 #define CMD_PROM_RD 0xA0 // Prom read command +static uint16_t get_ci_by_coef_num(uint8_t coef_num); +//void pressure_calculation_new(void); +//void pressure_calculation_old(void); +static void pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015(void); +static uint8_t crc4(uint16_t n_prom[]); -//uint16_t get_ci(uint8_t cmd); -//uint8_t get_ci_crc(void); -uint16_t get_ci_by_coef_num(uint8_t coef_num); -void pressure_calculation_new(void); -void pressure_calculation_old(void); -void pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015(void); - -uint8_t crc4(uint16_t n_prom[]); - -HAL_StatusTypeDef pressure_sensor_get_data(void); -uint32_t get_adc(void); +static HAL_StatusTypeDef pressure_sensor_get_data(void); +static uint32_t get_adc(void); uint8_t pressureSensorInitSuccess = 0; -//void test_calculation(void); +static uint16_t C[8] = { 1 }; +static uint32_t D1 = 1; +static uint32_t D2 = 1; +static uint8_t n_crc; -uint16_t C[8] = { 1 }; -uint32_t D1 = 1; -uint32_t D2 = 1; -uint8_t n_crc; - -int64_t C5_x_2p8 = 1; -int64_t C2_x_2p16 = 1; -int64_t C1_x_2p15 = 1; +static int64_t C5_x_2p8 = 1; +static int64_t C2_x_2p16 = 1; +static int64_t C1_x_2p15 = 1; /* short C2plus10000 = -1; @@ -79,10 +73,10 @@ short C6plus100 = -1; */ -float ambient_temperature = 0; -float ambient_pressure_mbar = 0; -float surface_pressure_mbar = 1000; -float surface_ring_mbar[31] = { 0 }; +static float ambient_temperature = 0; +static float ambient_pressure_mbar = 0; +static float surface_pressure_mbar = 1000; +static float surface_ring_mbar[31] = { 0 }; uint8_t secondCounterSurfaceRing = 0; @@ -91,15 +85,11 @@ return ambient_temperature; } -//float test = 1000; - float get_pressure_mbar(void) { -// return test; return ambient_pressure_mbar; } - float get_surface_mbar(void) { return surface_pressure_mbar; @@ -142,7 +132,7 @@ surface_ring_mbar[hole] = 0; } - +#ifdef DEMOMODE float demo_modify_temperature_helper(float bottom_mbar_diff_to_surface) { const float temperature_surface = 31.0; @@ -217,9 +207,11 @@ return 0; } } +#endif /* called just once on power on */ +/* TBD old DR5 code? */ void init_pressure_DRx(void) { uint8_t resetCommand[1] = {0x1E}; @@ -277,12 +269,12 @@ } -uint32_t get_adc(void) +static uint32_t get_adc(void) { uint8_t buffer[1]; uint8_t resivebuf[4]; uint32_t answer = 0; - // + buffer[0] = 0x00; // Get ADC I2C_Master_Transmit( DEVICE_PRESSURE, buffer, 1); I2C_Master_Receive( DEVICE_PRESSURE, resivebuf, 4); @@ -293,7 +285,7 @@ } -uint16_t get_ci_by_coef_num(uint8_t coef_num) +static uint16_t get_ci_by_coef_num(uint8_t coef_num) { uint8_t resivebuf[2]; @@ -315,7 +307,7 @@ } -uint32_t pressure_sensor_get_one_value(uint8_t cmd, HAL_StatusTypeDef *statusReturn) +static uint32_t pressure_sensor_get_one_value(uint8_t cmd, HAL_StatusTypeDef *statusReturn) { uint8_t command = CMD_ADC_CONV + cmd; HAL_StatusTypeDef statusReturnTemp = HAL_TIMEOUT; @@ -339,7 +331,7 @@ } -HAL_StatusTypeDef pressure_sensor_get_data(void) +static HAL_StatusTypeDef pressure_sensor_get_data(void) { HAL_StatusTypeDef statusReturn1 = HAL_TIMEOUT; HAL_StatusTypeDef statusReturn2 = HAL_TIMEOUT; @@ -372,14 +364,9 @@ return; pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015(); - return; - - // before October 2016: pressure_calculation_old(); - -// pressure_calculation_new(); } -void pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015(void) +static void pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015(void) { uint32_t local_D1; // ADC value of the pressure conversion uint32_t local_D2; // ADC value of the temperature conversion @@ -446,6 +433,7 @@ } +/* void pressure_calculation_new(void) { #define POW2_8 (256) @@ -511,8 +499,9 @@ ambient_temperature = ((float)T) / 100; ambient_pressure_mbar = ((float)P) / 10; } +*/ - +/* void pressure_calculation_old(void) { // double ambient_temperature_centigrad = 0; @@ -528,12 +517,6 @@ static int64_t sens2 = 0; static int64_t t2 = 0; -/* info -uint16_t C[8] = { 1 }; -uint32_t D1 = 1; -uint32_t D2 = 1; -uint8_t n_crc; -*/ if((D2 == 0) || (D1 == 0)) return; // @@ -597,12 +580,13 @@ ambient_pressure_decimbar = temp; // to float/double ambient_pressure_mbar = ambient_pressure_decimbar / 10; } +*/ /* taken from AN520 by meas-spec.com dated 9. Aug. 2011 * short and int are both 16bit according to AVR/GCC google results */ -uint8_t crc4(uint16_t n_prom[]) +static uint8_t crc4(uint16_t n_prom[]) { uint16_t cnt; // simple counter uint16_t n_rem; // crc reminder diff -r 4073b8091224 -r d328abe2e44e Small_CPU/Src/scheduler.c --- a/Small_CPU/Src/scheduler.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Small_CPU/Src/scheduler.c Sun Mar 17 19:16:59 2019 +0100 @@ -458,11 +458,9 @@ */ void scheduleDiveMode(void) { -// uint32_t tickstart = 0; uint32_t ticksdiff = 0; uint32_t lasttick = 0; - uint32_t turbo_seconds = 0; uint8_t counterAscentRate = 0; float lastPressure_bar = 0.0f; global.dataSendToMaster.mode = MODE_DIVE; @@ -498,9 +496,10 @@ global.check_sync_not_running++; pressure_update(); scheduleUpdateDeviceData(); +#ifdef DEMOMODE if(global.demo_mode) { - turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, Scheduler.counterPressure100msec, global.ceiling_from_main_CPU_mbar); + int turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, Scheduler.counterPressure100msec, global.ceiling_from_main_CPU_mbar); if(turbo_seconds) { global.lifeData.dive_time_seconds += turbo_seconds; @@ -510,7 +509,7 @@ if((global.lifeData.counterSecondsShallowDepth > 1) && (global.lifeData.counterSecondsShallowDepth < (global.settings.timeoutDiveReachedZeroDepth - 10))) global.lifeData.counterSecondsShallowDepth = (global.settings.timeoutDiveReachedZeroDepth - 10); } - +#endif //Calc ascentrate every two second (20 * 100 ms) counterAscentRate++; @@ -1543,7 +1542,7 @@ } -//save time diffenrence +//save time difference uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow) { if(ticksstart <= ticksnow)