comparison Discovery/Src/show_logbook.c @ 653:269e57ac4e56

Bugfix temperature display Logpage2: Temperature was shown in Centidegrees (Fahrenheit as well as Celsius). Root cause was that conversion was done via character cutting (string: removal of last digit). This has been replaced by a factor 10 devision.
author Ideenmodellierer
date Sun, 25 Apr 2021 20:36:18 +0200
parents 2586f7b734f4
children 1b995079c045
comparison
equal deleted inserted replaced
652:f6212495f34f 653:269e57ac4e56
772 int16_t maxVal = 0; 772 int16_t maxVal = 0;
773 int newTop = 0; 773 int newTop = 0;
774 int newBottom = 0; 774 int newBottom = 0;
775 uint16_t step = 0; 775 uint16_t step = 0;
776 int16_t maxValTop = 0; 776 int16_t maxValTop = 0;
777 int16_t tmp = 0;
777 778
778 scaleHelper(dataLength, tempdata, wintemp.top, wintemp.bottom, 779 scaleHelper(dataLength, tempdata, wintemp.top, wintemp.bottom,
779 &minVal, &maxVal, &newTop, &newBottom, 780 &minVal, &maxVal, &newTop, &newBottom,
780 &step, &maxValTop); // newTop is wintemp.top 781 &step, &maxValTop); // newTop is wintemp.top
781 782
784 &step, &maxValTop); 785 &step, &maxValTop);
785 786
786 // temperature in 1/10 �C 787 // temperature in 1/10 �C
787 int deltaline = (1 + wintemp.bottom - wintemp.top)/5; 788 int deltaline = (1 + wintemp.bottom - wintemp.top)/5;
788 char msg[15]; 789 char msg[15];
789 int tmp = maxValTop; 790
790 int converted; 791 /* temperature is provided in centi scaling => convert */
792 maxValTop /= 10;
793 step /= 10;
794
795 tmp = maxValTop;
791 for(int i = 1; i<=5; i++) 796 for(int i = 1; i<=5; i++)
792 { 797 {
793 tmp -= step; 798 tmp -= step;
794 if(settingsGetPointer()->nonMetricalSystem) {
795 converted = unit_temperature_integer(tmp);
796 }
797 else{
798 converted = tmp;
799 }
800 //if(tmp < 0)
801 //break;
802 winsmal.top = wintemp.top + deltaline * i - 14; 799 winsmal.top = wintemp.top + deltaline * i - 14;
803 winsmal.bottom = winsmal.top + 16; 800 winsmal.bottom = winsmal.top + 16;
804 if((converted >= 0) && (converted < 100)) 801 snprintf(msg,15,"%2i",unit_temperature_integer(tmp));
805 snprintf(msg,15,"%1i",converted);
806 else
807 snprintf(msg,15,"%2i",converted);
808 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_LogbookTemperature,msg); 802 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_LogbookTemperature,msg);
809 } 803 }
810 804
811 805
812 //--- print temperature graph --- 806 //--- print temperature graph ---