1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   Display Management (Display)                                        */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_display.h"
28 /**************************************************************************/
29 /*                                                                        */
30 /*  FUNCTION                                               RELEASE        */
31 /*                                                                        */
32 /*    _gx_display_driver_1bpp_pixel_write                 PORTABLE C      */
33 /*                                                           6.1          */
34 /*  AUTHOR                                                                */
35 /*                                                                        */
36 /*    Kenneth Maxwell, Microsoft Corporation                              */
37 /*                                                                        */
38 /*  DESCRIPTION                                                           */
39 /*                                                                        */
40 /*    Pixel write function for the 1bpp display driver.                   */
41 /*                                                                        */
42 /*  INPUT                                                                 */
43 /*                                                                        */
44 /*    context                               Drawing context               */
45 /*    x                                     X coordinate                  */
46 /*    y                                     Y coordinate                  */
47 /*    color                                 Color of pixel to write       */
48 /*                                                                        */
49 /*  OUTPUT                                                                */
50 /*                                                                        */
51 /*    None                                                                */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLED BY                                                             */
58 /*                                                                        */
59 /*    GUIX Internal Code                                                  */
60 /*                                                                        */
61 /*  RELEASE HISTORY                                                       */
62 /*                                                                        */
63 /*    DATE              NAME                      DESCRIPTION             */
64 /*                                                                        */
65 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
66 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
67 /*                                            resulting in version 6.1    */
68 /*                                                                        */
69 /**************************************************************************/
_gx_display_driver_1bpp_pixel_write(GX_DRAW_CONTEXT * context,INT x,INT y,GX_COLOR color)70 VOID _gx_display_driver_1bpp_pixel_write(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color)
71 {
72 GX_UBYTE *put = (GX_UBYTE *)context -> gx_draw_context_memory;
73 GX_UBYTE  mask;
74 UINT      stride;
75 
76     /* Get row pitch in bytes. */
77     stride = _gx_display_driver_1bpp_row_pitch_get((USHORT)(context -> gx_draw_context_pitch));
78 
79     /* Calculate address of writing byte.  */
80     put = (GX_UBYTE *)((INT)put + y * (INT)stride);
81     put += x >> 3;
82 
83     mask = (GX_UBYTE)(0x80 >> (x & 0x07));
84 
85     /* Write the pixel value.  */
86     if (color == 0x00)
87     {
88         *put = (GX_UBYTE)(*put & (~mask));
89     }
90     else if (color == 0x01)
91     {
92         *put |= mask;
93     }
94 }
95 
96