void RUNNER_StartTask(RUNNER_WindowDesc *desc) { UI1_PixelDim yPos, h; UI1_CreateScreen(&desc->screen, UI1_COLOR_WHITE); (void)UI1_CreateWindow(&desc->screen, &desc->window, UI1_COLOR_BRIGHT_GREEN, 0, 0, UI1_GetWidth(), UI1_GetHeight()); (void)UI1_CreateHeader(&desc->window, &desc->header, "Zeitmessung", FONT_14, UI1_COLOR_BLUE); UI1_ChangeTextFgColor(&desc->header.element, UI1_COLOR_WHITE); UI1_SetWindowEventCallback(&desc->window, runnerW_WindowCallback); /* Icon: Close */ h = (UI1_PixelDim)(UI1_GetElementHeight(&desc->header)); (void)UI1_CreateIcon(&desc->window, &desc->iconClose, 1, 1, (UI1_PixelDim)(h-2), (UI1_PixelDim)(h-2), UI1_ICON_CLOSE); desc->iconClose.element.prop.flags |= UI1_FLAGS_ALIGN_RIGHT; UI1_OnWindowResize(&desc->window); /* right align element(s) if needed */ UI1_ChangeElementColor(&desc->iconClose, UI1_COLOR_BLUE); UI1_ChangeIconFgColor(&desc->iconClose, UI1_COLOR_WHITE); UI1_EnableElementSelection(&desc->iconClose); yPos = (UI1_PixelDim)(UI1_GetElementPosY(&desc->window)+UI1_GetElementHeight(&desc->header)); /* icon for deleting last runner */ (void)UI1_CreateIcon(&desc->window, &desc->iconDelLast, 160, 1, (UI1_PixelDim)(h-2), (UI1_PixelDim)(h-2), UI1_ICON_ARROW_UP); UI1_EnableElementSelection(&desc->iconDelLast); desc->runnerTxtBuf[0] = '\0'; (void)UI1_CreateText(&desc->window, &desc->runnerTxt, 5, yPos, 0, 0, (char*)&desc->runnerTxtBuf, FONT); UI1_UpdateScreen(&desc->screen); FRTOS1_xTaskCreate(TaskRunner, (signed portCHAR *)"Runner", configMINIMAL_STACK_SIZE, desc, tskIDLE_PRIORITY, &xHandleTaskRunner); }
void ACCEL_StartDemoTask(ACCEL_WindowDesc *desc) { UI1_PixelDim yPos, h; UI1_CreateScreen(&desc->screen, UI1_COLOR_WHITE); (void)UI1_CreateWindow(&desc->screen, &desc->window, UI1_COLOR_BRIGHT_GREEN, 0, 0, UI1_GetWidth(), UI1_GetHeight()); (void)UI1_CreateHeader(&desc->window, &desc->header, (unsigned char*)"Accelerometer", FONT, UI1_COLOR_BLUE); UI1_ChangeTextFgColor(&desc->header.element, UI1_COLOR_WHITE); UI1_SetWindowEventCallback(&desc->window, accelW_WindowCallback); /* Icon: Close */ h = (UI1_PixelDim)(UI1_GetElementHeight(&desc->header)); (void)UI1_CreateIcon(&desc->window, &desc->iconClose, 1, 1, (UI1_PixelDim)(h-2), (UI1_PixelDim)(h-2), UI1_ICON_CLOSE); desc->iconClose.element.prop.flags |= UI1_FLAGS_ALIGN_RIGHT; UI1_OnWindowResize(&desc->window); /* right align element(s) if needed */ UI1_ChangeElementColor(&desc->iconClose, UI1_COLOR_BLUE); UI1_ChangeIconFgColor(&desc->iconClose, UI1_COLOR_WHITE); UI1_EnableElementSelection(&desc->iconClose); yPos = (UI1_PixelDim)(UI1_GetElementPosY(&desc->window)+UI1_GetElementHeight(&desc->header)+5); /* barGraph */ desc->data[0] = 0; desc->data[1] = 0; desc->data[2] = 0; (void)UI1_CreateBarGraph(&desc->window, &desc->accelBarGraph, 5, yPos, 170, 170, UI1_COLOR_BRIGHT_GREEN, (byte*)&desc->data, sizeof(desc->data), UI1_COLOR_RED, /* bar color */ 1, /* border width */ UI1_COLOR_BLACK, /* border color */ 5 /* border space */ ); yPos = (UI1_PixelDim)(UI1_GetElementPosY(&desc->accelBarGraph)+UI1_GetElementHeight(&desc->accelBarGraph)+5); /* X */ desc->txtBufX[0] = '\0'; (void)UI1_CreateText(&desc->window, &desc->txtX, 5, yPos, 0, 0, &desc->txtBufX[0], FONT); /* Y */ desc->txtBufY[0] = '\0'; (void)UI1_CreateText(&desc->window, &desc->txtY, 58, yPos, 0, 0, &desc->txtBufY[0], FONT); /* Z */ desc->txtBufZ[0] = '\0'; (void)UI1_CreateText(&desc->window, &desc->txtZ, 110, yPos, 0, 0, &desc->txtBufZ[0], FONT); UIG1_CreateGraph(&desc->window, &desc->graph, (UI1_PixelDim)(UI1_GetElementPosX(&desc->accelBarGraph)+UI1_GetElementWidth(&desc->accelBarGraph)+10), UI1_GetElementPosY(&desc->accelBarGraph), 125, UI1_GetElementHeight(&desc->accelBarGraph)); /* update the screen */ UI1_UpdateScreen(&desc->screen); FRTOS1_xTaskCreate(TaskAccelDemo, (signed portCHAR *)"Accel", configMINIMAL_STACK_SIZE+50, desc, tskIDLE_PRIORITY+1, NULL); }
void MOTOR_StartTask(MOTOR_WindowDesc *desc) { UI1_PixelDim yPos, h; UI1_CreateScreen(&desc->screen, UI1_COLOR_WHITE); (void)UI1_CreateWindow(&desc->screen, &desc->window, UI1_COLOR_BRIGHT_GREEN, 0, 0, UI1_GetWidth(), UI1_GetHeight()); (void)UI1_CreateHeader(&desc->window, &desc->header, (unsigned char*)"Motor", FONT, UI1_COLOR_BLUE); UI1_ChangeTextFgColor(&desc->header.element, UI1_COLOR_WHITE); UI1_SetWindowEventCallback(&desc->window, motorGraphW_WindowCallback); /* Icon: Close */ h = (UI1_PixelDim)(UI1_GetElementHeight(&desc->header)); (void)UI1_CreateIcon(&desc->window, &desc->iconClose, 1, 1, (UI1_PixelDim)(h-2), (UI1_PixelDim)(h-2), UI1_ICON_CLOSE); desc->iconClose.element.prop.flags |= UI1_FLAGS_ALIGN_RIGHT; UI1_OnWindowResize(&desc->window); /* right align element(s) if needed */ UI1_ChangeElementColor(&desc->iconClose, UI1_COLOR_BLUE); UI1_ChangeIconFgColor(&desc->iconClose, UI1_COLOR_WHITE); UI1_EnableElementSelection(&desc->iconClose); yPos = (UI1_PixelDim)(UI1_GetElementPosY(&desc->window)+UI1_GetElementHeight(&desc->header)); #if PL_HAS_SLIDER /* graph */ UIG1_CreateGraph(&desc->window, &desc->graph, 0, yPos, (UI1_PixelDim)(UI1_GetElementWidth(&desc->header)-100), (UI1_PixelDim)(UI1_GetElementHeight(&desc->window)-UI1_GetElementHeight(&desc->header))); /* slider window */ /* create a space so we can catch the events */ (void)UI1_CreateSpace(&desc->window, &desc->sliderSpace, (UI1_PixelDim)(UI1_GetElementWidth(&desc->graph)), yPos, (UI1_PixelDim)(UI1_GetElementWidth(&desc->header)-UI1_GetElementWidth(&desc->graph)), (UI1_PixelDim)(UI1_GetElementHeight(&desc->graph))); UI1_EnableElementSelection(&desc->sliderSpace); SLIDER_CreateSliders(&desc->window, (UI1_PixelDim)(UI1_GetElementPosX(&desc->sliderSpace)+3), (UI1_PixelDim)(UI1_GetElementPosY(&desc->sliderSpace)+3), (UI1_PixelDim)(UI1_GetElementWidth(&desc->sliderSpace)-6), (UI1_PixelDim)(UI1_GetElementHeight(&desc->sliderSpace)-6)); #else /* graph */ UIG1_CreateGraph(&desc->window, &desc->graph, 0, yPos, (UI1_PixelDim)(UI1_GetElementWidth(&desc->header)), (UI1_PixelDim)(UI1_GetElementHeight(&desc->window)-UI1_GetElementHeight(&desc->header))); #endif appWp = desc; /* need to set it, as the update below will call the callback, and we need it there! */ /* update the screen */ UI1_UpdateScreen(&desc->screen); FRTOS1_xTaskCreate(TaskMotorDemo, (signed portCHAR *)"Motor", configMINIMAL_STACK_SIZE, desc, tskIDLE_PRIORITY+1, &xHandleTaskMotorDemo); }