Difference between revisions of "DIRTYDEVICE (Sample)"
Line 19: | Line 19: | ||
|} |
|} |
||
− | + | This sample demonstrates how to use DIRTYDEVICEs in emWin. A DIRTYDEVICE monitors the area on the screen that is 'dirty', meaning the area where screen changes happened. |
|
== Code == |
== Code == |
Latest revision as of 14:25, 17 April 2020
GUI_DIRTYDEVICE_Usage.c | |
---|---|
File(s) required |
|
Runs in simulation | Yes |
Runs on target | Yes |
Download | GUI_DIRTYDEVICE_Usage.c |
This sample demonstrates how to use DIRTYDEVICEs in emWin. A DIRTYDEVICE monitors the area on the screen that is 'dirty', meaning the area where screen changes happened.
Code
/*********************************************************************
* SEGGER Microcontroller GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2020 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V6.10 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File : GUI_DIRTYDEVICE_Usage.c
Purpose : Sample that demonstrates how to use DIRTYDEVICES in
emWin. A DIRTYDEVICE monitors the area on the screen
that is 'dirty', meaning the area where screen changes
happened.
This sample has delays between the drawing operations
for better demonstration.
Requirements: WindowManager - ( )
MemoryDevices - (x)
AntiAliasing - ( )
VNC-Server - ( )
PNG-Library - ( )
TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/
#include "DIALOG.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define DELAY_APPLICATION() GUI_Delay(2000) // We delay the application for a better demonstration.
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_DIRTYDEVICE_INFO Info;
GUI_MEMDEV_Handle hMem;
//
// Init emWin.
//
GUI_Init();
while(1) {
//
// Create a dirty device.
//
GUI_DIRTYDEVICE_Create();
//
// Change something on the screen.
//
GUI_DrawLine(100, 100, 199, 149);
DELAY_APPLICATION();
//
// Get information about screen changes.
// Mark the changes by inverting the rectangle.
//
GUI_DIRTYDEVICE_Fetch(&Info);
GUI_InvertRect(Info.x0, Info.y0, Info.x0 + Info.xSize - 1, Info.y0 + Info.ySize - 1);
DELAY_APPLICATION();
//
// Undo marking.
//
GUI_InvertRect(Info.x0, Info.y0, Info.x0 + Info.xSize - 1, Info.y0 + Info.ySize - 1);
DELAY_APPLICATION();
//
// Change a pixel outside of the changed area. Thus, the changed area will expand.
//
GUI_DrawPixel(10, 20);
DELAY_APPLICATION();
//
// Get information about screen changes and mark the changed area again.
//
GUI_DIRTYDEVICE_Fetch(&Info);
GUI_InvertRect(Info.x0, Info.y0, Info.x0 + Info.xSize - 1, Info.y0 + Info.ySize - 1);
DELAY_APPLICATION();
//
// Undo marking.
//
GUI_InvertRect(Info.x0, Info.y0, Info.x0 + Info.xSize - 1, Info.y0 + Info.ySize - 1);
DELAY_APPLICATION();
//
// Create memory device and draw something in it.
// This will demonstrate that the dirty device only detects changes on the screen.
// Memory devices are independent from the screen, therefore changes in memory devices
// do not count as screen changes.
//
hMem = GUI_MEMDEV_Create(210, 10, 100, 100);
GUI_MEMDEV_Select(hMem);
GUI_DrawPixel(210, 10);
GUI_MEMDEV_Select(0);
//
// Get information about screen changes and mark the changed area again.
// The changed area will not include the change made in the memory device.
//
GUI_DIRTYDEVICE_Fetch(&Info);
GUI_InvertRect(Info.x0, Info.y0, Info.x0 + Info.xSize - 1, Info.y0 + Info.ySize - 1);
DELAY_APPLICATION();
//
// Delete memory device and dirty device.
//
GUI_MEMDEV_Delete(hMem);
GUI_DIRTYDEVICE_Delete();
//
// Clear screen and restart demo.
//
GUI_Clear();
GUI_Delay(1000);
}
}
/*************************** End of file ****************************/