static void DisplayRunners(RUNNER_WindowDesc *ui) { static char_t buf[RUNNER_DISPLAY_TEXT_SIZE]; uint16_t minIndex, maxIndex, index; RunnerMsg *runner; uint8_t i; buf[0] = '\0'; if (GetMinMaxExistingRunnerIndexInBuf(&minIndex, &maxIndex)==ERR_OK) { /* there are entries */ if (maxIndex>=NOF_RUNNER_DISPLAY) { index = maxIndex-NOF_RUNNER_DISPLAY+1; } else { index = minIndex; } for(i=0;i<NOF_RUNNER_DISPLAY;i++,index++) { if (FindIndexedRunner(index, &runner)==ERR_OK) { AddToDisplayText(buf, sizeof(buf), runner); } } } /* change and update text on screen */ UI1_ChangeText(&ui->window, (UI1_Element *)&ui->runnerTxt, sizeof(ui->runnerTxtBuf), buf); }
static portTASK_FUNCTION(TaskAccelDemo, pvParameters) { int16_t x,y,z; ACCEL_WindowDesc *ui = (ACCEL_WindowDesc*)pvParameters; unsigned char buf[sizeof("X: 123")]; UIG1_DataPoint data[3], prevData[3]; appWp = ui; #if PL_APP_MODE_I2C_LCD I2C_ClearBuffers(); #endif data[0].color = UI1_COLOR_RED; data[0].data = 0; data[1].color = UI1_COLOR_BLUE; data[1].data = 0; data[2].color = UI1_COLOR_DARK_GREEN; data[3].data = 0; prevData[0].color = UI1_COLOR_RED; prevData[0].data = 0; prevData[1].color = UI1_COLOR_BLUE; prevData[1].data = 0; prevData[2].color = UI1_COLOR_DARK_GREEN; prevData[2].data = 0; for (;;) { /* we are getting the values in milli-g (means: around -1200 to +1200 */ #if PL_HAS_AUTO_DEMO && PL_HAS_HW_ACCELEROMETER /* for demo, make values more interesting */ x = ACCEL1_GetX(); y = ACCEL1_GetY(); z = ACCEL1_GetZ(); while (z>900) { /* put in range */ z /= 2; } #else x = ACCEL_GetX(); y = ACCEL_GetY(); z = ACCEL_GetZ(); #endif /* cap to -100..+100 */ x /= 11; /* little bit more than 10, just to have 1g not always hitting the limit of 100% */ y /= 11; z /= 11; /* make sure it is in the -100..+100 range */ if (x>100) { x = 100; } else if (x<-100) { x = -100; } if (y>100) { y = 100; } else if (y<-100) { y = -100; } if (z>100) { z = 100; } else if (z<-100) { z = -100; } /* midpoint of graph is at 50% */ x = 50+(x/2); /* scale between 0..100% */ y = 50+(y/2); /* scale between 0..100% */ z = 50+(z/2); /* scale between 0..100% */ UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"X: "); UTIL1_strcatNum16s(buf, sizeof(buf), x); UI1_ChangeText(&ui->window, (UI1_Element *)&ui->txtX, sizeof(ui->txtBufX), buf); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"Y: "); UTIL1_strcatNum16s(buf, sizeof(buf), y); UI1_ChangeText(&ui->window, (UI1_Element *)&ui->txtY, sizeof(ui->txtBufY), buf); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"Z: "); UTIL1_strcatNum16s(buf, sizeof(buf), z); UI1_ChangeText(&ui->window, (UI1_Element *)&ui->txtZ, sizeof(ui->txtBufZ), buf); (void)UI1_ChangeBarGraphData(&ui->window, &ui->accelBarGraph, 0, (uint8_t)x); (void)UI1_ChangeBarGraphData(&ui->window, &ui->accelBarGraph, 1, (uint8_t)y); (void)UI1_ChangeBarGraphData(&ui->window, &ui->accelBarGraph, 2, (uint8_t)z); /* graph */ data[0].data = (uint8_t)x; data[1].data = (uint8_t)y; data[2].data = (uint8_t)z; (void)UIG1_AddDataLine((UI1_Element *)&ui->graph, &prevData[0], &data[0], 3); prevData[0].data = data[0].data; prevData[1].data = data[1].data; prevData[2].data = data[2].data; if (EVNT1_GetEvent(EVNT1_APP_MODE_CHANGE)) { /* request to close application */ EVNT1_ClearEvent(EVNT1_APP_MODE_CHANGE); /* reset event flag */ FRTOS1_vTaskDelete(NULL); /* kill ourself */ } FRTOS1_vTaskDelay(25/portTICK_RATE_MS); } /* for */ }