Skip to content

Commit ab47eaf

Browse files
committed
Fix JSON format helpers, update HAL and LCD driver
Fix snprintf usage and UTC offset formatting in json_format_helpers.h to avoid buffer-size issues and correct sign handling. Update lib-hal/include/gd32/hal.h: bump copyright years, add IWYU pragmas for retained includes, and simplify ENABLE_USB_HOST conditional + unify usbh_host usage; preserve softwaretimers/hwclock includes. Refactor lib-rdmsubdevice/src/spi/rdmsubdevicebwlcd.cpp: bump copyright year, modernize naming and formatting, introduce constants for DMX footprint and default line, replace TO_HEX macro with common hex utility, clean up Data/Display/Update logic and formatting, and improve overall readability without changing intended functionality.
1 parent 01957b7 commit ab47eaf

3 files changed

Lines changed: 245 additions & 226 deletions

File tree

common/include/json/json_format_helpers.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,22 @@ constexpr size_t kOffsetBufferSize = 12; // For timezone offsets e.g. "+01:00"
3636

3737
[[nodiscard]] inline const char* FormatFloat(float value, char (&buf)[kFloatBufferSize], const char* fmt = "%.2f")
3838
{
39-
snprintf(buf, sizeof(buf) - 1, fmt, value);
39+
snprintf(buf, sizeof(buf), fmt, value);
4040
return buf;
4141
}
4242

4343
[[nodiscard]] inline const char* FormatUtcOffset(int32_t hours, uint32_t minutes, char (&buf)[kOffsetBufferSize])
4444
{
45-
if (hours == 0)
45+
if (hours <= 0)
4646
{
47-
snprintf(buf, sizeof(buf) - 1, "%.2d:%.2u", hours, minutes);
47+
snprintf(buf, sizeof(buf), "%.2d:%.2u", hours, minutes);
4848
}
4949
else
5050
{
51-
snprintf(buf, sizeof(buf) - 1, "%c%.2d:%.2u", hours < 0 ? '-' : '+', hours, minutes);
51+
snprintf(buf, sizeof(buf), "+%.2d:%.2u", hours, minutes);
5252
}
5353
return buf;
5454
}
55-
5655
} // namespace format
5756

5857
#endif // JSON_JSON_FORMAT_HELPERS_H_

lib-hal/include/gd32/hal.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file hal.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -28,17 +28,13 @@
2828

2929
#include <cstdint>
3030

31-
#include "gd32.h"
31+
#include "gd32.h" // IWYU pragma: keep
3232

33-
#if defined(ENABLE_USB_HOST) && defined(CONFIG_USB_HOST_MSC)
33+
#if defined(ENABLE_USB_HOST)
3434
extern "C"
3535
{
3636
#include "usbh_core.h"
37-
#if defined(GD32H7XX) || defined(GD32F4XX)
38-
extern usbh_host usb_host_msc;
39-
#else
4037
extern usbh_host usb_host;
41-
#endif
4238
}
4339
#endif
4440

@@ -54,10 +50,10 @@ void emac_debug_run();
5450
#include "task.h"
5551
#endif
5652

57-
#include "softwaretimers.h"
53+
#include "softwaretimers.h" // IWYU pragma: keep
5854

5955
#if !defined(DISABLE_RTC)
60-
#include "hwclock.h"
56+
#include "hwclock.h" // IWYU pragma: keep
6157
#endif
6258

6359
#include "hal_panelled.h"
@@ -74,13 +70,9 @@ inline constexpr float kCoreTemperatureMax = +85.0;
7470

7571
inline void Run()
7672
{
77-
#if defined(ENABLE_USB_HOST) && defined(CONFIG_USB_HOST_MSC)
78-
#if defined(GD32H7XX) || defined(GD32F4XX)
79-
usbh_core_task(&usb_host_msc);
80-
#else
73+
#if defined(ENABLE_USB_HOST)
8174
usbh_core_task(&usb_host);
8275
#endif
83-
#endif
8476
#if !defined(USE_FREE_RTOS)
8577
SoftwareTimerRun();
8678
#endif

0 commit comments

Comments
 (0)