Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DMBasicGUI by
lpc_swim.h
00001 /* 00002 * @brief Simple Windowing Interface Manager (SWIM) 00003 * 00004 * @note 00005 * Copyright(C) NXP Semiconductors, 2012 00006 * All rights reserved. 00007 * 00008 * @par 00009 * Software that is described herein is for illustrative purposes only 00010 * which provides customers with programming information regarding the 00011 * LPC products. This software is supplied "AS IS" without any warranties of 00012 * any kind, and NXP Semiconductors and its licensor disclaim any and 00013 * all warranties, express or implied, including all implied warranties of 00014 * merchantability, fitness for a particular purpose and non-infringement of 00015 * intellectual property rights. NXP Semiconductors assumes no responsibility 00016 * or liability for the use of the software, conveys no license or rights under any 00017 * patent, copyright, mask work right, or any other intellectual property rights in 00018 * or to any products. NXP Semiconductors reserves the right to make changes 00019 * in the software without notification. NXP Semiconductors also makes no 00020 * representation or warranty that such application will be suitable for the 00021 * specified use without further testing or modification. 00022 * 00023 * @par 00024 * Permission to use, copy, modify, and distribute this software and its 00025 * documentation is hereby granted, under NXP Semiconductors' and its 00026 * licensor's relevant copyrights in the software, without fee, provided that it 00027 * is used in conjunction with NXP Semiconductors microcontrollers. This 00028 * copyright, permission, and disclaimer notice must appear in all copies of 00029 * this code. 00030 */ 00031 00032 #ifndef __LPC_SWIM_H_ 00033 #define __LPC_SWIM_H_ 00034 00035 #include "lpc_types.h" 00036 #include "lpc_fonts.h" 00037 #include "lpc_colors.h" 00038 00039 #if defined(__cplusplus) 00040 extern "C" 00041 { 00042 #endif 00043 00044 /** @defgroup GUI_SWIM_SWIM Simple Windowing Interface Manager (SWIM) 00045 * @ingroup GUI_SWIM 00046 * This package provides the core SWIM capabilities such as 00047 * Windows initialization and validity checks, Color support for 00048 * background/primary/fill pens, graphics primatives, and Window 00049 * deallocation. 00050 * @{ 00051 */ 00052 00053 /** 00054 * @brief Structure used to store information about a specific window 00055 */ 00056 typedef struct { 00057 int32_t xpsize; /* Physical (absolute) horizontal screen size */ 00058 int32_t ypsize; /* Physical (absolute) vertical screen size */ 00059 int32_t xpmin; /* Physical left edge of window */ 00060 int32_t ypmin; /* Physical top edge of window */ 00061 int32_t xpmax; /* Physical right edge of window */ 00062 int32_t ypmax; /* Physical bottom edge of window */ 00063 int32_t bdsize; /* Size of window frame in pixels */ 00064 int32_t xvsize; /* Virtual horizontal window size */ 00065 int32_t yvsize; /* Virtual vertical window size */ 00066 int32_t xpvmin; /* Physical left edge of draw window */ 00067 int32_t ypvmin; /* Physical top edge of draw window */ 00068 int32_t xpvmax; /* Physical right edge of draw window */ 00069 int32_t ypvmax; /* Physical bottom edge of draw window */ 00070 int32_t xvpos; /* Next virtual 'x' position of output */ 00071 int32_t yvpos; /* Next virtual 'y' position of output */ 00072 COLOR_T pen; /* Pen/text color */ 00073 COLOR_T bkg; /* Window/text background color */ 00074 COLOR_T fill; /* Fill/border color */ 00075 FONT_T *font; /* Selected font structure */ 00076 int32_t tfont; /* Transparent font background flag when true */ 00077 COLOR_T *fb; /* Frame buffer address for the physical display */ 00078 int32_t winused; /* Window used flag */ 00079 BOOL_32 tfonts; /* Transparent font background flag */ 00080 } SWIM_WINDOW_T; 00081 00082 /** 00083 * @brief Puts a pixel at the virtual X, Y coordinate in the window 00084 * @param win : Pointer to window data structure 00085 * @param x1 : Virtual X position of pixel 00086 * @param y1 : Virtual Y position of pixel 00087 * @return Nothing 00088 * @note The pixel will not be displayed if the pixel exceeds the window 00089 * virtual size. Pixel positions below 0 should not be used with 00090 * this function. 00091 */ 00092 void swim_put_pixel(SWIM_WINDOW_T *win, 00093 int32_t x1, 00094 int32_t y1); 00095 00096 /** 00097 * @brief Draw a line in the virtual window with clipping 00098 * @param win : Pointer to window data structure 00099 * @param x1 : Virtual X position of X line start 00100 * @param y1 : Virtual Y position of Y line start 00101 * @param x2 : Virtual X position of X line end 00102 * @param y2 : Virtual Y position of Y line end 00103 * @return Nothing 00104 */ 00105 void swim_put_line(SWIM_WINDOW_T *win, 00106 int32_t x1, 00107 int32_t y1, 00108 int32_t x2, 00109 int32_t y2); 00110 00111 /** 00112 * @brief Draw a diamond in the virtual window 00113 * @param win : Pointer to window data structure 00114 * @param x : Virtual X position of the diamond 00115 * @param y : Virtual Y position of the diamond 00116 * @param rx : Radius for horizontal 00117 * @param ry : Radius for vertical 00118 * @return Nothing 00119 */ 00120 void swim_put_diamond(SWIM_WINDOW_T *win, 00121 int32_t x, 00122 int32_t y, 00123 int32_t rx, 00124 int32_t ry); 00125 00126 /** 00127 * @brief Draws a circle in the virtual window 00128 * @param win : Pointer to window data structure 00129 * @param cx : Virtual center X position of the circle 00130 * @param cy : Virtual center Y position of the circle 00131 * @param radius : Radius of the circle 00132 * @param Filled : Flag to indicate whether the circle should be filled 00133 * @return Nothing 00134 */ 00135 void swim_put_circle(SWIM_WINDOW_T *win, 00136 int32_t cx, 00137 int32_t cy, 00138 int32_t radius, 00139 int32_t Filled); 00140 00141 /** 00142 * @brief Fills the draw area of the display with the selected color 00143 * @param win : Pointer to window data structure 00144 * @param colr : Color to place in the window 00145 * @return Nothing 00146 */ 00147 void swim_clear_screen(SWIM_WINDOW_T *win, 00148 COLOR_T colr); 00149 00150 /** 00151 * @brief Place a box with corners (X1, Y1) and (X2, Y2) 00152 * @param win : Pointer to window data structure 00153 * @param x1 : Virtual left position of box 00154 * @param y1 : Virtual upper position of box 00155 * @param x2 : Virtual right position of box 00156 * @param y2 : Virtual lower position of box 00157 * @return Nothing 00158 * @note Use pen color for edges and fill color for center. 00159 */ 00160 void swim_put_box(SWIM_WINDOW_T *win, 00161 int32_t x1, 00162 int32_t y1, 00163 int32_t x2, 00164 int32_t y2); 00165 00166 /** 00167 * @brief Initializes a window and the default values for the window 00168 * @param win : Pointer to window data structure 00169 * @param xsize : Physical horizontal dimension of the display 00170 * @param ysize : Physical vertical dimension of the display 00171 * @param fbaddr : Address of the display's frame buffer 00172 * @param xwin_min : Physical window left coordinate 00173 * @param ywin_min : Physical window top coordinate 00174 * @param xwin_max : Physical window right coordinate 00175 * @param ywin_max : Physical window bottom coordinate 00176 * @param border_width : Width of the window border in pixels 00177 * @param pcolor : Pen color 00178 * @param bkcolor : Background color 00179 * @param fcolor : Fill color 00180 * @return true if the window was initialized correctly, otherwise false 00181 * @note This function must be called prior to any other window function. The 00182 * window will be drawn in the background color. 00183 */ 00184 BOOL_32 swim_window_open(SWIM_WINDOW_T *win, 00185 int32_t xsize, 00186 int32_t ysize, 00187 COLOR_T *fbaddr, 00188 int32_t xwin_min, 00189 int32_t ywin_min, 00190 int32_t xwin_max, 00191 int32_t ywin_max, 00192 int32_t border_width, 00193 COLOR_T pcolor, 00194 COLOR_T bkcolor, 00195 COLOR_T fcolor); 00196 00197 /** 00198 * @brief Initializes a window without clearing it 00199 * @param win s: Pointer to window data structure 00200 * @param xsize : Physical horizontal dimension of the display 00201 * @param ysize : Physical vertical dimension of the display 00202 * @param fbaddr : Address of the display's frame buffer 00203 * @param xwin_min : Physical window left coordinate 00204 * @param ywin_min : Physical window top coordinate 00205 * @param xwin_max : Physical window right coordinate 00206 * @param ywin_max : Physical window bottom coordinate 00207 * @param border_width : Width of the window border in pixels 00208 * @param pcolor : Pen color 00209 * @param bkcolor : Background color 00210 * @param fcolor : Fill color 00211 * @return true if the window was initialized correctly, otherwise false 00212 * @note This function must be called prior to any other window function. 00213 */ 00214 BOOL_32 swim_window_open_noclear(SWIM_WINDOW_T *win, 00215 int32_t xsize, 00216 int32_t ysize, 00217 COLOR_T *fbaddr, 00218 int32_t xwin_min, 00219 int32_t ywin_min, 00220 int32_t xwin_max, 00221 int32_t ywin_max, 00222 int32_t border_width, 00223 COLOR_T pcolor, 00224 COLOR_T bkcolor, 00225 COLOR_T fcolor); 00226 00227 /** 00228 * @brief Deallocates a window 00229 * @param win : Pointer to window data structure 00230 * @return Nothing 00231 * @note This function does nothing. 00232 */ 00233 void swim_window_close(SWIM_WINDOW_T *win); 00234 00235 /** 00236 * @brief Sets the pen color 00237 * @param win : Pointer to window data structure 00238 * @param pen_color : New pen color 00239 * @return Nothing 00240 */ 00241 void swim_set_pen_color(SWIM_WINDOW_T *win, 00242 COLOR_T pen_color); 00243 00244 /** 00245 * @brief Sets the fill color 00246 * @param win : Pointer to window data structure 00247 * @param fill_color : New fill color 00248 * @return Nothing 00249 */ 00250 void swim_set_fill_color(SWIM_WINDOW_T *win, 00251 COLOR_T fill_color); 00252 00253 /** 00254 * @brief Sets the color used for backgrounds 00255 * @param win : Pointer to window data structure 00256 * @param bkg_color : New background color 00257 * @return Nothing 00258 */ 00259 void swim_set_bkg_color(SWIM_WINDOW_T *win, 00260 COLOR_T bkg_color); 00261 00262 /** 00263 * @brief Sets the font to be used for all new windows 00264 * @param def_font : New default font 00265 * @return Nothing 00266 */ 00267 void swim_set_default_font(const FONT_T* def_font); 00268 00269 /** 00270 * @brief Get the virtual window horizontal size 00271 * @param win : Pointer to window data structure 00272 * @return The virtual window horizontal size 00273 */ 00274 int32_t swim_get_horizontal_size(SWIM_WINDOW_T *win); 00275 00276 /** 00277 * @brief Get the virtual window vertical size 00278 * @param win : Pointer to window data structure 00279 * @return The virtual window vertical size 00280 */ 00281 int32_t swim_get_vertical_size(SWIM_WINDOW_T *win); 00282 00283 #if defined(SWIM_DRIVER_INDIRECT) 00284 /** 00285 * @brief Puts a pixel at the physical X, Y coordinate. 00286 * 00287 * @param win : Pointer to window data structure 00288 * @param x1 : Physical X coordinate of pixel 00289 * @param y1 : Physical Y coordinate of pixel 00290 * @param color : Value to write to pixel 00291 * @return Nothing 00292 * @note This function must be implemented out side the 00293 * swim library (in application). 00294 */ 00295 STATIC INLINE void swim_put_pixel_physical(SWIM_WINDOW_T *win, 00296 int32_t x1, 00297 int32_t y1, 00298 COLOR_T color); 00299 00300 /** 00301 * @brief Read value of pixel at the physical X, Y coordinate. 00302 * 00303 * Note that this function must be implemented by the application! 00304 * If not defined, there will be a link error. 00305 * 00306 * @param win : Pointer to window data structure 00307 * @param x1 : Physical X coordinate of pixel 00308 * @param y1 : Physical Y coordinate of pixel 00309 * @param color : Value to write to pixel 00310 * @return Nothing 00311 * @note This function must be implemented out side the 00312 * swim library (in application). 00313 */ 00314 STATIC INLINE COLOR_T swim_get_pixel_physical(SWIM_WINDOW_T *win, int32_t x1, int32_t y1); 00315 00316 #else /* Using frame buffers */ 00317 /** 00318 * @brief Read value of pixel at the physical X, Y coordinate from Frame Buffer. 00319 * 00320 * @param win : Pointer to window data structure 00321 * @param x1 : Physical X coordinate of pixel 00322 * @param y1 : Physical Y coordinate of pixel 00323 * @param color : Value to write to pixel 00324 * @return Nothing 00325 */ 00326 STATIC INLINE COLOR_T swim_get_pixel_physical(SWIM_WINDOW_T *win, int32_t x1, int32_t y1) 00327 { 00328 return *(win->fb + x1 + (y1 * win->xpsize)); 00329 } 00330 00331 /** 00332 * @brief Writes pixel color to Frame buffer at the physical X, Y coordinate 00333 * 00334 * @param win : Pointer to window data structure 00335 * @param x1 : Physical X coordinate of pixel 00336 * @param y1 : Physical Y coordinate of pixel 00337 * @param color : Value to write to pixel 00338 * @return Nothing 00339 */ 00340 STATIC INLINE void swim_put_pixel_physical(SWIM_WINDOW_T *win, int32_t x1, int32_t y1, COLOR_T color) 00341 { 00342 *(win->fb + x1 + (y1 * win->xpsize)) = color; 00343 } 00344 #endif 00345 00346 #if defined(__cplusplus) 00347 } 00348 #endif 00349 00350 /** 00351 * @} 00352 */ 00353 00354 #endif /* __LPC_SWIM_H_ */ 00355
Generated on Wed Jul 13 2022 03:01:50 by
1.7.2
