Choco OS  V.0.16.9.0
Join to the chocolate world
Screen

Module for storing informations about the screen. More...

Typedefs

typedef struct Screen_toC_Screen_t
 Screen object pointer. More...
 

Functions

oC_Screen_t oC_Screen_New (oC_Driver_t Driver, const void *Config, const char *Name)
 creates new screen object More...
 
bool oC_Screen_IsCorrect (oC_Screen_t Screen)
 checks if the Screen object is correct More...
 
bool oC_Screen_Delete (oC_Screen_t *Screen)
 Destroys the Screen object. More...
 
bool oC_Screen_IsConfigured (oC_Screen_t Screen)
 checks if the screen is configured to work More...
 
oC_ErrorCode_t oC_Screen_Configure (oC_Screen_t Screen)
 configures graphics driver to work More...
 
oC_ErrorCode_t oC_Screen_Unconfigure (oC_Screen_t Screen)
 unconfigures graphics driver More...
 
oC_ErrorCode_t oC_Screen_ReadColorMap (oC_Screen_t Screen, oC_ColorMap_t **outColorMap)
 reads pointer to the color map More...
 
oC_ErrorCode_t oC_Screen_ReadResolution (oC_Screen_t Screen, oC_Pixel_ResolutionUInt_t *outWidth, oC_Pixel_ResolutionUInt_t *outHeight)
 reads resolution of the screen More...
 
const char * oC_Screen_GetName (oC_Screen_t Screen)
 returns name of the screen More...
 
oC_Driver_t oC_Screen_GetDriver (oC_Screen_t Screen)
 returns driver associated with the screen More...
 

Detailed Description

The "Screen" is a special object that stores information about a screen. I know, that it does not sounds very well, but it means exactly what it does. You should use screens objects, when you want to use some graphics drivers or modules. Generally you should not create them - they are created during startup of the system. Of course it also can be created during it's work, but remember, that it is not allocated for the current process - so if you don't delete the screen, it will cause memory leak.

Each screen object handles only one physical object. So, for example if you have 2 LCD displays, you will need 2 the Screen objects.

Note
Each screen object should be added to the list in the screens manager (#ScreenMan).

You always can check if the Screen object is correct by using function named oC_Screen_IsCorrect. It returns true if the Screen was correctly initialized.

To create the screen you will need pointer to the graphics driver and its configuration. After creation of the object, you also have to configure the graphics driver. You have to do it by using the function named oC_Screen_Configure. You cannot configure a driver by your own, because the Screen object requires context of the configuration to work.

Warning
You should always use oC_Screen_Configure function to configure the graphics drivers.

To unconfigure the driver call oC_Screen_Unconfigure function.

To draw something on the screen, you should use the #oc_ColorMap_t. Pointer to the color map you can read by using the function oC_Screen_ReadColorMap. You can also read resolution of the screen by calling the function oC_Screen_ReadResolution

Typedef Documentation

typedef struct Screen_t* oC_Screen_t

This type stores all informations about the screen. It is a main module object. All data inside are private, and cannot be changed without using an interface functions.

The screen is an object, so it must be created before usage. You can do it by using a function called oC_Screen_New. When the object is not needed anymore, you can destroy it by calling a function named oC_Screen_Delete.

Warning
Screen objects are allocated with a special allocator. Because of that, you should not create a screen in programs unless you exactly know what are you doing.

Definition at line 88 of file oc_screen.h.

Function Documentation

oC_ErrorCode_t oC_Screen_Configure ( oC_Screen_t  Screen)

The function is for configuration of the graphic drivers to work with the screen. You can check if the driver was configured before by calling the function oC_Screen_IsConfigured. The screen will work only if the graphic driver is configured by calling this function (it cannot be configured manually).

If the driver is already correctly configured, the function will return error #oC_ErrorCode_AlreadyConfigured. To unconfigure driver please call the function oC_Screen_Unconfigure.

Parameters
ScreenThe Screen object created by the function oC_Screen_New
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 257 of file oc_screen.c.

bool oC_Screen_Delete ( oC_Screen_t Screen)

The function is for destroying the Screen object. It also deconfigures the graphic driver.

Warning
The function takes pointer to the Screen object pointer. Thanks to that it also fills your screen pointer with NULL value after destroying to prevent usage of the object after destroying. If you give wrong pointer to this function, the function will not delete it and it will return "false" value. Please verify, that the function returns true, otherwise it can causes be memory leak.

The function returns only result of the operation (success or failure), so if you want to know what kind of error occurs you can use function 'oC_ReadLastError' to read it or just use the chell's command "system".

Parameters
ScreenPointer to the screen created before by using the function called oC_Screen_New
Returns
true if success

Definition at line 185 of file oc_screen.c.

oC_Driver_t oC_Screen_GetDriver ( oC_Screen_t  Screen)

The function returns driver associated with the screen or NULL if some error has occured.

Parameters
ScreenScreen object created by the function oC_Screen_New
Returns
pointer to the driver

Definition at line 415 of file oc_screen.c.

const char* oC_Screen_GetName ( oC_Screen_t  Screen)

The function returns name of the screen.

Parameters
ScreenScreen object created by the function oC_Screen_New and configured by oC_Screen_Configure
Returns
string with name of the screen

Definition at line 386 of file oc_screen.c.

bool oC_Screen_IsConfigured ( oC_Screen_t  Screen)

The function is for verification if the driver associated with the screen was correctly configured before. The function returns true only if the screen is correct, and the driver configuration function has been called by using the Screen object (oC_Screen_Configure). If the driver is configured without using the Screen object, the screen object will be not usable.

Parameters
ScreenThe screen allocated and initialized before by function #pC_Screen_New
Returns
true if driver was configured and the screen is correct

Definition at line 234 of file oc_screen.c.

bool oC_Screen_IsCorrect ( oC_Screen_t  Screen)

The function is for verification if the Screen object is correct. The function returns true if the address is correct and object is initialized.

Parameters
ScreenPointer to the screen object
Returns
true if object is correct

Definition at line 160 of file oc_screen.c.

oC_Screen_t oC_Screen_New ( oC_Driver_t  Driver,
const void *  Config,
const char *  Name 
)

The function allocates and initializes new oC_Screen_t object. The object is always allocated with the screen allocator. When the oC_Screen_t is not needed anymore, it should be destroyed by the function named oC_Screen_Delete.

This function does not configures the driver to work. It should be done manually by calling the function oC_Screen_Configure.

If the error occurs, you can use function 'oC_ReadLastError' to read it or just use the chell's command "system".

Parameters
DriverPointer to the graphics driver that should be used for screen configuration and managing
ConfigPointer to the driver configuration. It will be copied
NameFriendly name of the screen
Returns
pointer to the initialized and allocated screen object or NULL if there was some error.

Definition at line 101 of file oc_screen.c.

oC_ErrorCode_t oC_Screen_ReadColorMap ( oC_Screen_t  Screen,
oC_ColorMap_t **  outColorMap 
)

The function returns color map that can be used for drawing on the screen. Before usage of this function you have to call the function oC_Screen_Configure function.

Parameters
ScreenThe screen object created by the function oC_Screen_New and configured by the function oC_Screen_Configure
outColorMapDestination pointer for the color map pointer
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 324 of file oc_screen.c.

oC_ErrorCode_t oC_Screen_ReadResolution ( oC_Screen_t  Screen,
oC_Pixel_ResolutionUInt_t *  outWidth,
oC_Pixel_ResolutionUInt_t *  outHeight 
)

The function is for reading resolution of the screen (width and the height). The graphics driver associated with the screen object have to be configured by the function oC_Screen_Configure.

Parameters
ScreenScreen object created by the function oC_Screen_New and configured by oC_Screen_Configure
outWidthDestination for the width of the screen
outHeightDestination for the height of the screen
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 356 of file oc_screen.c.

oC_ErrorCode_t oC_Screen_Unconfigure ( oC_Screen_t  Screen)

The function is for unconfiguration of the driver associated with the screen.. When this function is called, the context of the driver should be destroyed, and the screen is not usable.

If the driver is not configured, the function will return #oC_ErrorCode_NotConfiguredYet

Parameters
ScreenThe screen object created by the function oC_Screen_New
Returns
code of error or #oc_ErrorCode_None if success
See also
oC_Screen_IsConfigured , oC_Screen_Configure

Definition at line 292 of file oc_screen.c.