Add support of refreshing time in widgets

Issue #260 new
Patryk Kubiak created an issue

Implementation reason

Actually it is not possible to update progress bar value in asynchronous mode. It is only possible by calling oC_WidgetScreen_SetValue but to do it, we have to run another thread.

Generic Description

The goal of the task is to add possibility to set a handler in the widget screen module, that allows for update value in some other way, for example by requesting a value in each 500 ms.

// Type for storing pointer to the function that should be called when widget is redrawn and value for the widget has to be updated
typedef oC_WidgetScreen_Value_t (*oC_WidgetScreen_GetWidgetValueHandler_t)( oC_WidgetScreen_t Screen, oC_WidgetScreen_UserContext_t Context, oC_WidgetScreen_WidgetIndex_t Index );

typedef struct
{
    oC_WidgetScreen_WidgetType_t            Type;
    oC_Pixel_Position_t                     Position;
    oC_Pixel_ResolutionUInt_t               Height;
    oC_Pixel_ResolutionUInt_t               Width;
    oC_WidgetScreen_ZPosition_t             ZPosition;
    const oC_WidgetScreen_Palette_t *       Palette;
    const oC_WidgetScreen_DrawStyle_t *     DrawStyle;
    oC_DefaultPathString_t                  ImagePath;
    oC_WidgetScreen_WidgetHandlers_t        Handlers;
    oC_WidgetScreen_GetWidgetValueHandler_t GetValueHandler;  // Called when value should be updated
} oC_WidgetScreen_WidgetDefinition_t;


typedef struct
{
    oC_Pixel_Position_t                                 Position;
    oC_Pixel_ResolutionUInt_t                           Height;
    oC_Pixel_ResolutionUInt_t                           Width;
    oC_Color_t                                          BackgroundColor;
    oC_ColorFormat_t                                    ColorFormat;
    oC_WidgetScreen_ScreenHandler_t                     PrepareHandler;
    oC_WidgetScreen_ScreenHandler_t                     Handler;
    const oC_WidgetScreen_WidgetDefinition_t *          WidgetsDefinitions;
    uint32_t                                            NumberOfWidgetsDefinitions;
    oC_Time_t                                           RefreshPeriod;       // Maximum time after which the screen should be refreshed and redrawn
} oC_WidgetScreen_ScreenDefinition_t;

Bitbucket

https://bitbucket.org/chocos/chocos/issues/260/add-support-of-refreshing-time-in-widgets

Trello

https://trello.com/c/wgeYxpoV

Story

  • [ #240 ] - Preparation of the sample graphic program

List of requirements

  • [ #260 ] - WidgetScreen handles refresh period
  • [ #260 ] - WidgetScreen supports setting handler for getting widget value

Comments (2)

  1. Log in to comment