Clean up comments, USB flash, NULLs

This commit is contained in:
Scott Lahteine
2020-10-24 17:13:10 -05:00
parent 00fbe50bbe
commit ec23e37a4a
45 changed files with 231 additions and 238 deletions

View File

@ -79,7 +79,7 @@ void CANVAS::AddText(uint16_t x, uint16_t y, uint16_t color, uint8_t *string, ui
void CANVAS::AddImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) {
uint16_t *data = (uint16_t *)Images[image].data;
if (data == NULL) return;
if (!data) return;
uint16_t image_width = Images[image].width,
image_height = Images[image].height;

View File

@ -23,7 +23,7 @@
#include "tft_image.h"
#include <stddef.h>
const tImage NoLogo = { (void *)NULL, 0, 0, NOCOLORS };
const tImage NoLogo = { nullptr, 0, 0, NOCOLORS };
const tImage MarlinLogo112x38x1 = { (void *)marlin_logo_112x38x1, 112, 38, GREYSCALE1 };
const tImage MarlinLogo228x255x2 = { (void *)marlin_logo_228x255x2, 228, 255, GREYSCALE2 };

View File

@ -30,19 +30,19 @@
uint8_t TFT_Queue::queue[];
uint8_t *TFT_Queue::end_of_queue = queue;
uint8_t *TFT_Queue::current_task = NULL;
uint8_t *TFT_Queue::last_task = NULL;
uint8_t *TFT_Queue::current_task = nullptr;
uint8_t *TFT_Queue::last_task = nullptr;
void TFT_Queue::reset() {
tft.abort();
end_of_queue = queue;
current_task = NULL;
last_task = NULL;
current_task = nullptr;
last_task = nullptr;
}
void TFT_Queue::async() {
if (current_task == NULL) return;
if (!current_task) return;
queueTask_t *task = (queueTask_t *)current_task;
// Check IO busy status
@ -63,7 +63,7 @@ void TFT_Queue::async() {
}
void TFT_Queue::finish_sketch() {
if (last_task == NULL) return;
if (!last_task) return;
queueTask_t *task = (queueTask_t *)last_task;
if (task->state == TASK_STATE_SKETCH) {
@ -71,7 +71,7 @@ void TFT_Queue::finish_sketch() {
task->nextTask = end_of_queue;
task->state = TASK_STATE_READY;
if (current_task == NULL) current_task = (uint8_t *)task;
if (!current_task) current_task = (uint8_t *)task;
}
}
@ -184,7 +184,7 @@ void TFT_Queue::fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, ui
task->state = TASK_STATE_READY;
task->type = TASK_FILL;
if (current_task == NULL) current_task = (uint8_t *)task;
if (!current_task) current_task = (uint8_t *)task;
}
void TFT_Queue::canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) {
@ -195,7 +195,7 @@ void TFT_Queue::canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
task->state = TASK_STATE_SKETCH;
task->type = TASK_CANVAS;
task->nextTask = NULL;
task->nextTask = nullptr;
end_of_queue += sizeof(queueTask_t);
parametersCanvas_t *task_parameters = (parametersCanvas_t *)end_of_queue;
@ -207,7 +207,7 @@ void TFT_Queue::canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
task_parameters->height = height;
task_parameters->count = 0;
if (current_task == NULL) current_task = (uint8_t *)task;
if (!current_task) current_task = (uint8_t *)task;
}
void TFT_Queue::set_background(uint16_t color) {

View File

@ -42,7 +42,7 @@ void TFT_String::set_font(const uint8_t *font) {
font_header = (font_t *)font;
uint32_t glyph;
for (glyph = 0; glyph < 256; glyph++) glyphs[glyph] = NULL;
for (glyph = 0; glyph < 256; glyph++) glyphs[glyph] = nullptr;
DEBUG_ECHOLNPAIR("Format: ", font_header->Format);
DEBUG_ECHOLNPAIR("BBXWidth: ", font_header->BBXWidth);

View File

@ -119,9 +119,8 @@ void Touch::idle() {
NOMORE(y, current_control->y + current_control->height);
touch(current_control);
}
else {
current_control = NULL;
}
else
current_control = nullptr;
}
else {
for (i = 0; i < controls_count; i++) {
@ -133,7 +132,7 @@ void Touch::idle() {
}
}
if (current_control == NULL)
if (!current_control)
touch_time = last_touch_ms;
}
x = _x;
@ -141,7 +140,7 @@ void Touch::idle() {
}
else {
x = y = 0;
current_control = NULL;
current_control = nullptr;
touch_time = 0;
touch_control_type = NONE;
time_to_hold = 0;

View File

@ -452,7 +452,7 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const valu
void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
uint16_t line = 1;
if (string == NULL) line++;
if (!string) line++;
menu_line(line++);
tft_string.set(pref);

View File

@ -457,7 +457,7 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const valu
void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
uint16_t line = 1;
if (string == NULL) line++;
if (!string) line++;
menu_line(line++);
tft_string.set(pref);
@ -945,7 +945,7 @@ static void drawBtn(int x, int y, const char* label, int32_t data, MarlinImage i
tft.add_image(0, 0, imgBtn52Rounded, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY);
// TODO: Make an add_text() taking a font arg
if (label != NULL) {
if (label) {
tft_string.set(label);
tft_string.trim();
tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string);