@@ -120,8 +120,6 @@ bool have_pre_pic(char *path) {
120
120
static void event_handler (lv_obj_t *obj, lv_event_t event) {
121
121
if (event != LV_EVENT_RELEASED) return ;
122
122
uint8_t i, file_count = 0 ;
123
- // switch (obj->mks_obj_id)
124
- // {
125
123
if (obj->mks_obj_id == ID_P_UP) {
126
124
if (dir_offset[curDirLever].curPage > 0 ) {
127
125
// 2015.05.19
@@ -130,9 +128,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
130
128
if (dir_offset[curDirLever].cur_page_first_offset >= FILE_NUM)
131
129
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset - FILE_NUM;
132
130
133
- #if HAS_MEDIA
134
- file_count = search_file ();
135
- #endif
131
+ TERN_ (HAS_MEDIA, file_count = search_file ());
136
132
if (file_count != 0 ) {
137
133
dir_offset[curDirLever].curPage --;
138
134
lv_clear_print_file ();
@@ -144,9 +140,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
144
140
if (dir_offset[curDirLever].cur_page_last_offset > 0 ) {
145
141
list_file.Sd_file_cnt = 0 ;
146
142
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_last_offset + 1 ;
147
- #if HAS_MEDIA
148
- file_count = search_file ();
149
- #endif
143
+ TERN_ (HAS_MEDIA, file_count = search_file ());
150
144
if (file_count != 0 ) {
151
145
dir_offset[curDirLever].curPage ++;
152
146
lv_clear_print_file ();
@@ -161,17 +155,13 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
161
155
int8_t *ch = (int8_t *)strrchr (list_file.curDirPath , ' /' );
162
156
if (ch) {
163
157
*ch = 0 ;
164
- #if HAS_MEDIA
165
- card.cdup ();
166
- #endif
158
+ TERN_ (HAS_MEDIA, card.cdup ());
167
159
dir_offset[curDirLever].curPage = 0 ;
168
160
dir_offset[curDirLever].cur_page_first_offset = 0 ;
169
161
dir_offset[curDirLever].cur_page_last_offset = 0 ;
170
162
curDirLever--;
171
163
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset ;
172
- #if HAS_MEDIA
173
- file_count = search_file ();
174
- #endif
164
+ TERN_ (HAS_MEDIA, file_count = search_file ());
175
165
lv_clear_print_file ();
176
166
disp_gcode_icon (file_count);
177
167
}
@@ -189,9 +179,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
189
179
strcpy (list_file.curDirPath , list_file.file_name [i]);
190
180
curDirLever++;
191
181
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset ;
192
- #if HAS_MEDIA
193
- file_count = search_file ();
194
- #endif
182
+ TERN_ (HAS_MEDIA, file_count = search_file ());
195
183
lv_clear_print_file ();
196
184
disp_gcode_icon (file_count);
197
185
}
@@ -396,8 +384,7 @@ int ascii2dec_test(char *ascii) {
396
384
397
385
void lv_gcode_file_read (uint8_t *data_buf) {
398
386
#if HAS_MEDIA
399
- uint16_t i = 0 , j = 0 , k = 0 ;
400
- uint16_t row_1 = 0 ;
387
+ uint16_t i = 0 , j = 0 , k = 0 , row_1 = 0 ;
401
388
bool ignore_start = true ;
402
389
char temp_test[200 ];
403
390
volatile uint16_t *p_index;
@@ -435,24 +422,13 @@ void lv_gcode_file_read(uint8_t *data_buf) {
435
422
break ;
436
423
}
437
424
}
438
- #if HAS_TFT_LVGL_UI_SPI
439
- for (i = 0 ; i < 200 ;) {
440
- p_index = (uint16_t *)(&public_buf[i]);
441
-
442
- // Color = (*p_index >> 8);
443
- // *p_index = Color | ((*p_index & 0xFF) << 8);
444
- i += 2 ;
445
- if (*p_index == 0x0000 ) *p_index = LV_COLOR_BACKGROUND.full ;
446
- }
447
- #else // !HAS_TFT_LVGL_UI_SPI
448
- for (i = 0 ; i < 200 ;) {
449
- p_index = (uint16_t *)(&public_buf[i]);
450
- // Color = (*p_index >> 8);
451
- // *p_index = Color | ((*p_index & 0xFF) << 8);
452
- i += 2 ;
453
- if (*p_index == 0x0000 ) *p_index = LV_COLOR_BACKGROUND.full ; // 0x18C3;
454
- }
455
- #endif // !HAS_TFT_LVGL_UI_SPI
425
+ for (i = 0 ; i < 200 ;) {
426
+ p_index = (uint16_t *)(&public_buf[i]);
427
+ // Color = (*p_index >> 8);
428
+ // *p_index = Color | ((*p_index & 0xFF) << 8);
429
+ i += 2 ;
430
+ if (*p_index == 0x0000 ) *p_index = LV_COLOR_BACKGROUND.full ;
431
+ }
456
432
memcpy (data_buf, public_buf, 200 );
457
433
#endif // HAS_MEDIA
458
434
}
0 commit comments