static D4D_COLOR D4D_SldrComputeColorBar(D4D_OBJECT* pThis, D4D_SLIDER_VALUE value) { D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis); Byte shade; D4D_CLR_SCHEME *pScheme_tmp = D4D_ObjectGetScheme(pThis); if(value >= pSldr->pData->limits.valueOrg) shade = D4D_MulDivUU8((Byte)(value - pSldr->pData->limits.valueOrg), 255, \ (Byte)(pSldr->pData->limits.valueMax - pSldr->pData->limits.valueOrg)); else shade = D4D_MulDivUU8((Byte)(pSldr->pData->limits.valueOrg - value), 255, \ (Byte)(pSldr->pData->limits.valueOrg - pSldr->pData->limits.valueMin)); return D4D_GetCrossColor(pScheme_tmp->objectDepend.slider.barStart, pScheme_tmp->objectDepend.slider.barEnd, shade); }
// Screen "Main" function called periodically in each D4D_poll runs static void ScreenMain_OnMain() { // if music is enabled if(musicEnable) { // each 100ms if(time.bits.b100ms) { Byte tmp_output; time.bits.b100ms = 0; // add new data into "input audio signal" graph D4D_GraphAddTracesData(&scrMain_graph, pDummyMusic); // if left output signal is enable (check the check box) if(D4D_CheckBoxGetValue(&scrMain_checkBxLeft)) { // modify the input signal to fit to the gauge tmp_output = (Byte)(255 - pDummyMusic[0]); tmp_output /= 2; // Compute with volume of signal tmp_output = D4D_MulDivUU8(tmp_output, (Byte)(D4D_SldrGetValue(&scrMain_sldrVol)), 32); // Compute with balance of signal if(D4D_SldrGetValue(&scrMain_sldrBalance) > 0) tmp_output = D4D_MulDivUU8(tmp_output, (Byte)(17 - D4D_SldrGetValue(&scrMain_sldrBalance)), 16); D4D_GaugSetValue(&scrMain_gaugeLeft, (D4D_GAUGE_VALUE)(tmp_output)); } // if left output signal is enable (check the check box) if(D4D_CheckBoxGetValue(&scrMain_checkBxRight)) { // modify the input signal to fit to the gauge tmp_output = (Byte)(255 - pDummyMusic[1]); tmp_output /= 2; // Compute with volume of signa tmp_output = D4D_MulDivUU8(tmp_output, (Byte)(D4D_SldrGetValue(&scrMain_sldrVol)), 32); // Compute with balance of signal if(D4D_SldrGetValue(&scrMain_sldrBalance) < 0) tmp_output = D4D_MulDivUU8(tmp_output, (Byte)(17 + D4D_SldrGetValue(&scrMain_sldrBalance)), 16); D4D_GaugSetValue(&scrMain_gaugeRight, (D4D_GAUGE_VALUE)(tmp_output)); } // update pointer to dummy data in memory of MCU pDummyMusic += 2; } } }
static D4D_COLOR D4D_PrgrsBarComputeColorBar(D4D_OBJECT* pThis, D4D_PROGRESS_BAR_VALUE value) { D4D_CLR_SCHEME *pScheme_tmp = D4D_ObjectGetScheme(pThis); return D4D_GetCrossColor(pScheme_tmp->objectDepend.progressBar.barFore, pScheme_tmp->objectDepend.progressBar.barEnd, D4D_MulDivUU8(value, 255, D4D_COLOR_PRGRS_BAR_MAX_VAL)); }