Clean up comments, USB flash, NULLs
This commit is contained in:
@ -1036,7 +1036,7 @@ void MarlinUI::draw_status_screen() {
|
||||
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
|
||||
ui.encoder_direction_normal();
|
||||
uint8_t n = lcd_put_u8str_ind_P(0, 1, pstr, itemIndex, itemString, LCD_WIDTH - 1);
|
||||
if (value != nullptr) {
|
||||
if (value) {
|
||||
lcd_put_wchar(':'); n--;
|
||||
const uint8_t len = utf8_strlen(value) + 1; // Plus one for a leading space
|
||||
const lcd_uint_t valrow = n < len ? 2 : 1; // Value on the next row if it won't fit
|
||||
|
@ -863,7 +863,7 @@ void MarlinUI::draw_status_screen() {
|
||||
lcd.setCursor(0, MIDDLE_Y);
|
||||
lcd.write(COLOR_EDIT);
|
||||
lcd_put_u8str_P(pstr);
|
||||
if (value != nullptr) {
|
||||
if (value) {
|
||||
lcd.write(':');
|
||||
lcd.setCursor((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), MIDDLE_Y); // Right-justified, padded by spaces
|
||||
lcd.write(' '); // Overwrite char if value gets shorter
|
||||
|
@ -423,7 +423,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
if (onpage) lcd_put_u8str_ind_P(0, baseline, pstr, itemIndex, itemString);
|
||||
|
||||
// If a value is included, print a colon, then print the value right-justified
|
||||
if (value != nullptr) {
|
||||
if (value) {
|
||||
lcd_put_wchar(':');
|
||||
if (extra_row) {
|
||||
// Assume that value is numeric (with no descender)
|
||||
|
@ -346,7 +346,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
||||
|
||||
switch (msg) {
|
||||
case U8G_DEV_MSG_INIT:
|
||||
dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, NULL);
|
||||
dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, nullptr);
|
||||
tftio.Init();
|
||||
tftio.InitTFT();
|
||||
|
||||
|
@ -294,7 +294,7 @@ namespace Anycubic {
|
||||
}
|
||||
|
||||
void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) {
|
||||
if (str != nullptr) {
|
||||
if (str) {
|
||||
#if ACDEBUG(AC_SOME)
|
||||
SERIAL_ECHOPGM("> ");
|
||||
#endif
|
||||
|
@ -218,12 +218,12 @@ void AnycubicTFTClass::OnUserConfirmRequired(const char * const msg) {
|
||||
}
|
||||
|
||||
float AnycubicTFTClass::CodeValue() {
|
||||
return (strtod(&TFTcmdbuffer[TFTbufindr][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindr] + 1], NULL));
|
||||
return (strtod(&TFTcmdbuffer[TFTbufindr][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindr] + 1], nullptr));
|
||||
}
|
||||
|
||||
bool AnycubicTFTClass::CodeSeen(char code) {
|
||||
TFTstrchr_pointer = strchr(TFTcmdbuffer[TFTbufindr], code);
|
||||
return (TFTstrchr_pointer != NULL); // Return True if a character was found
|
||||
return !!TFTstrchr_pointer; // Return True if a character was found
|
||||
}
|
||||
|
||||
bool AnycubicTFTClass::IsNozzleHomed() {
|
||||
@ -536,7 +536,7 @@ void AnycubicTFTClass::OnPrintTimerStopped() {
|
||||
}
|
||||
|
||||
void AnycubicTFTClass::GetCommandFromTFT() {
|
||||
char *starpos = NULL;
|
||||
char *starpos = nullptr;
|
||||
while (LCD_SERIAL.available() > 0 && TFTbuflen < TFTBUFSIZE) {
|
||||
serial3_char = LCD_SERIAL.read();
|
||||
if (serial3_char == '\n' ||
|
||||
@ -549,10 +549,10 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
||||
|
||||
TFTcmdbuffer[TFTbufindw][serial3_count] = 0; // terminate string
|
||||
|
||||
if ((strchr(TFTcmdbuffer[TFTbufindw], 'A') != NULL)) {
|
||||
if ((strchr(TFTcmdbuffer[TFTbufindw], 'A') != nullptr)) {
|
||||
int16_t a_command;
|
||||
TFTstrchr_pointer = strchr(TFTcmdbuffer[TFTbufindw], 'A');
|
||||
a_command = ((int)((strtod(&TFTcmdbuffer[TFTbufindw][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindw] + 1], NULL))));
|
||||
a_command = ((int)((strtod(&TFTcmdbuffer[TFTbufindw][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindw] + 1], nullptr))));
|
||||
|
||||
#if ENABLED(ANYCUBIC_LCD_DEBUG)
|
||||
if ((a_command > 7) && (a_command != 20)) { // No debugging of status polls, please!
|
||||
@ -682,8 +682,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
||||
else {
|
||||
SelectedDirectory[0] = 0;
|
||||
|
||||
if (starpos != NULL)
|
||||
*(starpos - 1) = '\0';
|
||||
if (starpos) *(starpos - 1) = '\0';
|
||||
|
||||
strcpy(SelectedFile, TFTstrchr_pointer + 4);
|
||||
SENDLINE_DBG_PGM_VAL("J20", "TFT Serial Debug: File Selected... J20 ", SelectedFile); // J20 File Selected
|
||||
|
@ -146,9 +146,9 @@
|
||||
uint16_t FTDI::get_utf8_char_width(utf8_char_t c, font_size_t fs) {
|
||||
int x = 0, y = 0;
|
||||
#ifdef TOUCH_UI_UTF8_WESTERN_CHARSET
|
||||
WesternCharSet::render_glyph(NULL, x, y, fs, c) ||
|
||||
WesternCharSet::render_glyph(nullptr, x, y, fs, c) ||
|
||||
#endif
|
||||
StandardCharSet::render_glyph(NULL, x, y, fs, c);
|
||||
StandardCharSet::render_glyph(nullptr, x, y, fs, c);
|
||||
return x;
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@
|
||||
*/
|
||||
|
||||
uint16_t FTDI::get_utf8_text_width(const char *str, font_size_t fs) {
|
||||
return render_utf8_text(NULL, 0, 0, str, fs);
|
||||
return render_utf8_text(nullptr, 0, 0, str, fs);
|
||||
}
|
||||
|
||||
uint16_t FTDI::get_utf8_text_width(progmem_str pstr, font_size_t fs) {
|
||||
|
@ -110,7 +110,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) {
|
||||
draw_return_ui();
|
||||
}
|
||||
else {
|
||||
lv_kb_set_ta(kb, nullptr); /*De-assign the text area to hide it cursor if needed*/
|
||||
lv_kb_set_ta(kb, nullptr); // De-assign the text area to hide it cursor if needed
|
||||
lv_obj_del(kb);
|
||||
return;
|
||||
}
|
||||
@ -174,7 +174,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*Add the characters to the text area if set*/
|
||||
// Add the characters to the text area if set
|
||||
if (!ext->ta) return;
|
||||
|
||||
if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0)
|
||||
@ -214,7 +214,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) {
|
||||
void lv_draw_keyboard() {
|
||||
scr = lv_screen_create(KEY_BOARD_UI, "");
|
||||
|
||||
/*Create styles for the keyboard*/
|
||||
// Create styles for the keyboard
|
||||
static lv_style_t rel_style, pr_style;
|
||||
|
||||
lv_style_copy(&rel_style, &lv_style_btn_rel);
|
||||
@ -229,7 +229,7 @@ void lv_draw_keyboard() {
|
||||
pr_style.body.main_color = lv_color_make(0x72, 0x42, 0x15);
|
||||
pr_style.body.grad_color = lv_color_make(0x6A, 0x3A, 0x0C);
|
||||
|
||||
/*Create a keyboard and apply the styles*/
|
||||
// Create a keyboard and apply the styles
|
||||
lv_obj_t *kb = lv_kb_create(scr, nullptr);
|
||||
lv_obj_set_event_cb(kb, lv_kb_event_cb);
|
||||
lv_kb_set_cursor_manage(kb, true);
|
||||
@ -243,7 +243,7 @@ void lv_draw_keyboard() {
|
||||
}
|
||||
#endif
|
||||
|
||||
/*Create a text area. The keyboard will write here*/
|
||||
// Create a text area. The keyboard will write here
|
||||
lv_obj_t *ta = lv_ta_create(scr, nullptr);
|
||||
lv_obj_align(ta, nullptr, LV_ALIGN_IN_TOP_MID, 0, 10);
|
||||
if (keyboard_value == gcodeCommand) {
|
||||
@ -255,7 +255,7 @@ void lv_draw_keyboard() {
|
||||
lv_ta_set_text(ta, "");
|
||||
}
|
||||
|
||||
/*Assign the text area to the keyboard*/
|
||||
// Assign the text area to the keyboard
|
||||
lv_kb_set_ta(kb, ta);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) {
|
||||
if (ui.should_draw())
|
||||
draw_edit_screen(strfunc(ui.encoderPosition + minEditValue));
|
||||
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
|
||||
if (editValue != nullptr) loadfunc(editValue, ui.encoderPosition + minEditValue);
|
||||
if (editValue) loadfunc(editValue, ui.encoderPosition + minEditValue);
|
||||
if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
|
||||
if (ui.use_click()) ui.goto_previous_screen();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 };
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user