@@ -75,12 +75,14 @@ extern "C" {
75
75
76
76
/** Sets up the hardware cursor. */
77
77
#define lcd_CrsrSetup () \
78
+ do { \
78
79
lcd_Timing2 = (uint32_t)(lcd_Timing2 & ~(uint32_t)0x03FF0000) | (uint32_t)(LCD_WIDTH - 1) << 16; \
79
80
lcd_CrsrConfig = 0; \
80
81
lcd_CrsrPalette0 = 0x00000000; \
81
82
lcd_CrsrPalette1 = 0x00FFFFFF; \
82
83
lcd_CrsrXY = 0; \
83
- lcd_CrsrClip = 0;
84
+ lcd_CrsrClip = 0; \
85
+ } while (0)
84
86
85
87
/**
86
88
* Hardware cursor sizes.
@@ -97,16 +99,17 @@ typedef enum {
97
99
* @see lcd_cursor_size_t
98
100
*/
99
101
#define lcd_CrsrSetSize (size ) \
100
- (lcd_CrsrConfig = ((lcd_CrsrConfig >> 1) << 1) | (size & 1))
102
+ do { \
103
+ lcd_CrsrConfig = ((lcd_CrsrConfig >> 1) << 1) | (size & 1); \
104
+ } while (0)
101
105
102
106
/**
103
107
* Gets cursor size.
104
108
*
105
109
* @returns The cursor size.
106
110
* @see lcd_cursor_size_t
107
111
*/
108
- #define lcd_CrsrGetSize () \
109
- ((lcd_cursor_size_t)(lcd_CrsrConfig & 1))
112
+ #define lcd_CrsrGetSize () ((lcd_cursor_size_t)(lcd_CrsrConfig & 1))
110
113
111
114
/**
112
115
* Sets cursor image.
@@ -120,7 +123,9 @@ typedef enum {
120
123
* to your image(s).
121
124
*/
122
125
#define lcd_CrsrSetImage (data ) \
123
- (memcpy(lcd_CrsrImage, data, lcd_CrsrGetSize() == LCD_CURSOR_SIZE_LARGE ? lcd_CrsrImageLen64 : lcd_CrsrImageLen32))
126
+ do { \
127
+ memcpy(lcd_CrsrImage, data, lcd_CrsrGetSize() == LCD_CURSOR_SIZE_LARGE ? lcd_CrsrImageLen64 : lcd_CrsrImageLen32); \
128
+ } while (0)
124
129
125
130
/**
126
131
* Sets the position of the cursor on screen.
@@ -129,20 +134,28 @@ typedef enum {
129
134
* @param[in] y Y coordinate.
130
135
*/
131
136
#define lcd_CrsrSetPosition (x , y ) \
137
+ do { \
132
138
lcd_CrsrX = x; \
133
- lcd_CrsrY = y;
139
+ lcd_CrsrY = y; \
140
+ } while (0)
134
141
135
142
/** Shows the cursor. */
136
143
#define lcd_CrsrShow () \
137
- lcd_CrsrCtrl = 1;
144
+ do { \
145
+ lcd_CrsrCtrl = 1; \
146
+ } while (0)
138
147
139
148
/** Hides the cursor. */
140
149
#define lcd_CrsrHide () \
141
- lcd_CrsrCtrl = 0;
150
+ do { \
151
+ lcd_CrsrCtrl = 0; \
152
+ } while (0)
142
153
143
154
#define lcd_CrsrCleanup () \
155
+ do { \
144
156
lcd_CrsrHide(); \
145
- lcd_Timing2 = (uint32_t)(lcd_Timing2 & ~(uint32_t)0x03FF0000) | (uint32_t)(LCD_HEIGHT - 1) << 16;
157
+ lcd_Timing2 = (uint32_t)(lcd_Timing2 & ~(uint32_t)0x03FF0000) | (uint32_t)(LCD_HEIGHT - 1) << 16; \
158
+ } while (0)
146
159
147
160
#ifdef __cplusplus
148
161
}
0 commit comments