🧑💻 Macro OBJZERO
This commit is contained in:
@@ -256,6 +256,7 @@
|
||||
// Array shorthand
|
||||
#define COUNT(a) (sizeof(a)/sizeof(*a))
|
||||
#define ZERO(a) memset((void*)a,0,sizeof(a))
|
||||
#define OBJZERO(a) memset(&a,0,sizeof(a))
|
||||
#define COPY(a,b) do{ \
|
||||
static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \
|
||||
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
|
||||
|
||||
@@ -300,7 +300,7 @@ int uxg_GetUtf8StrPixelWidth(u8g_t *pu8g, const char *utf8_msg) {
|
||||
|
||||
if (!uxg_Utf8FontIsInited()) return -1;
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
OBJZERO(data);
|
||||
data.pu8g = pu8g;
|
||||
data.adv = 0;
|
||||
fontgroup_drawstring(group, fnt_default, utf8_msg, read_byte_ram, (void*)&data, fontgroup_cb_draw_u8gstrlen);
|
||||
@@ -326,7 +326,7 @@ int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, PGM_P utf8_msg) {
|
||||
|
||||
if (!uxg_Utf8FontIsInited()) return -1;
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
OBJZERO(data);
|
||||
data.pu8g = pu8g;
|
||||
data.adv = 0;
|
||||
fontgroup_drawstring(group, fnt_default, utf8_msg, read_byte_rom, (void*)&data, fontgroup_cb_draw_u8gstrlen);
|
||||
|
||||
@@ -513,7 +513,7 @@ void RTS::sendData() {
|
||||
delay_us(1);
|
||||
}
|
||||
|
||||
memset(&snddat, 0, sizeof(snddat));
|
||||
OBJZERO(snddat);
|
||||
ZERO(databuf);
|
||||
snddat.head[0] = FHONE;
|
||||
snddat.head[1] = FHTWO;
|
||||
@@ -626,7 +626,7 @@ void RTS::sendData(const unsigned long n, uint32_t addr, uint8_t cmd/*=VarAddr_W
|
||||
void RTS::handleData() {
|
||||
int16_t Checkkey = -1;
|
||||
if (waitway > 0) { // for waiting
|
||||
memset(&recdat, 0, sizeof(recdat));
|
||||
OBJZERO(recdat);
|
||||
recdat.head[0] = FHONE;
|
||||
recdat.head[1] = FHTWO;
|
||||
return;
|
||||
@@ -684,7 +684,7 @@ void RTS::handleData() {
|
||||
}
|
||||
|
||||
if (Checkkey < 0) {
|
||||
memset(&recdat, 0, sizeof(recdat));
|
||||
OBJZERO(recdat);
|
||||
recdat.head[0] = FHONE;
|
||||
recdat.head[1] = FHTWO;
|
||||
return;
|
||||
@@ -1639,7 +1639,7 @@ void RTS::handleData() {
|
||||
default: break;
|
||||
}
|
||||
|
||||
memset(&recdat, 0, sizeof(recdat));
|
||||
OBJZERO(recdat);
|
||||
recdat.head[0] = FHONE;
|
||||
recdat.head[1] = FHTWO;
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ void ui_cfg_init() {
|
||||
uiCfg.filament_unloading_time_cnt = 0;
|
||||
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
memset(&wifiPara, 0, sizeof(wifiPara));
|
||||
memset(&ipPara, 0, sizeof(ipPara));
|
||||
OBJZERO(wifiPara);
|
||||
OBJZERO(ipPara);
|
||||
strcpy_P(wifiPara.ap_name, PSTR(WIFI_AP_NAME));
|
||||
strcpy_P(wifiPara.keyCode, PSTR(WIFI_KEY_CODE));
|
||||
// client
|
||||
|
||||
@@ -1376,7 +1376,7 @@ static void net_msg_handle(const uint8_t * const msg, const uint16_t msgLen) {
|
||||
ZERO(wifiPara.ap_name);
|
||||
memcpy(wifiPara.ap_name, &msg[9], wifiNameLen);
|
||||
|
||||
memset(&wifi_list.wifiConnectedName, 0, sizeof(wifi_list.wifiConnectedName));
|
||||
OBJZERO(wifi_list.wifiConnectedName);
|
||||
memcpy(&wifi_list.wifiConnectedName, &msg[9], wifiNameLen);
|
||||
|
||||
// WiFi key
|
||||
|
||||
@@ -177,7 +177,7 @@ void RTS::sdCardInit() {
|
||||
for (uint8_t j = 0; j < MAX_NUM_FILES; j++)
|
||||
for (uint8_t i = 0; i < FILENAME_LEN; i++)
|
||||
sendData(0, cardRec.addr[j] + i);
|
||||
ZERO(&cardRec);
|
||||
OBJZERO(cardRec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ void RTS::sdCardUpdate() {
|
||||
sendData(0, PRINT_FILE_TEXT_VP + j);
|
||||
sendData(0, SELECT_FILE_TEXT_VP + j);
|
||||
}
|
||||
ZERO(&cardRec);
|
||||
OBJZERO(cardRec);
|
||||
}
|
||||
lcd_sd_status = sd_status;
|
||||
}
|
||||
@@ -422,7 +422,7 @@ void RTS::sendData() {
|
||||
for (uint16_t i = 0; i < snddat.len + 3; i++)
|
||||
LCD_SERIAL.write(databuf[i]);
|
||||
|
||||
ZERO(&snddat);
|
||||
OBJZERO(snddat);
|
||||
ZERO(databuf);
|
||||
snddat.head[0] = FHONE;
|
||||
snddat.head[1] = FHTWO;
|
||||
@@ -543,7 +543,7 @@ void RTS::handleData() {
|
||||
int16_t checkKey = -1;
|
||||
// For waiting
|
||||
if (waitway > 0) {
|
||||
memset(&recdat, 0, sizeof(recdat));
|
||||
OBJZERO(recdat);
|
||||
recdat.head[0] = FHONE;
|
||||
recdat.head[1] = FHTWO;
|
||||
return;
|
||||
@@ -556,7 +556,7 @@ void RTS::handleData() {
|
||||
}
|
||||
|
||||
if (checkKey < 0) {
|
||||
ZERO(&recdat);
|
||||
OBJZERO(recdat);
|
||||
recdat.head[0] = FHONE;
|
||||
recdat.head[1] = FHTWO;
|
||||
return;
|
||||
@@ -1512,7 +1512,7 @@ void RTS::handleData() {
|
||||
|
||||
default: break;
|
||||
}
|
||||
ZERO(&recdat);
|
||||
OBJZERO(recdat);
|
||||
recdat.head[0] = FHONE;
|
||||
recdat.head[1] = FHTWO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user