// Redraw General Data void redrawDigit(screenItemInfo * item, volatile dataItem * data, double currentValue){ if(data->value == currentValue){ return; } // Set Backround Color uint16_t fillColor; if(data->value >= data->warnThreshold){ if(data->value >= data->errThreshold){ fillColor = errorColor; }else{ fillColor = warningColor; } }else{ fillColor = backgroundColor; } // Calculate Fill Rectangle width uint16_t wholeNums, decNums; wholeNums = data->wholeDigits; decNums = data->decDigits; uint16_t fillWidth = (item->size)*(wholeNums+decNums)+(item->size)*0.2*(wholeNums+decNums-1); if(decNums){ fillWidth += (item->size)/5; } fillRect(item->x, item->y, fillWidth, (item->size)*1.75, fillColor); sevenSegmentDecimal(item->x,item->y,item->size,wholeNums+decNums,decNums,foregroundColor,data->value); }
// Redraw General Data double redrawDigit(screenItemInfo * item, volatile dataItem * data, double currentValue){ uint8_t warning = data->thresholdDir ? data->value >= data->warnThreshold: data->value <= data->warnThreshold; uint8_t error = data->thresholdDir ? data->value >= data->errThreshold: data->value <= data->errThreshold; uint8_t stale = millis - data->refreshTime > 1000; if(stale) { data->value = 0; } if(!error && !stale && !checkDataChange(data, currentValue)) { return data->value; } // Set Backround Color uint16_t fillColor; uint16_t numColor; if(warning){ if(error){ fillColor = errorColor; numColor = RA8875_WHITE; }else{ fillColor = warningColor; numColor = RA8875_BLUE; } } else if(stale) { fillColor = errorColor; } else{ fillColor = backgroundColor; numColor = foregroundColor; } // Calculate Fill Rectangle width uint16_t wholeNums, decNums; wholeNums = data->wholeDigits; decNums = data->decDigits; uint16_t fillWidth = (item->size)*(wholeNums+decNums)+(item->size)*0.2*(wholeNums+decNums-1); if(decNums){ fillWidth += (item->size)/5; } fillRect(item->x, item->y, fillWidth, (item->size)*1.75, fillColor); if(!stale && (!error || millis%500 > 200)) { // draw number if normal, or blink at 1hz sevenSegmentDecimal(item->x,item->y,item->size,wholeNums+decNums,decNums,numColor,data->value); } return data->value; }