Skip to content

Commit 328ade1

Browse files
committed
Update display headers and SPI platform config
Bump copyright years to 2026 and tidy header formatting. Refactor display::Defaults and compact namespace/struct formatting; simplify Display::PutString to a while loop with postfix increment. Extend SPI config: add RASPPI platform (include gpio_rasppi.h) and ODROID handling, provide sane default zero GPIO defines for unknown platforms, and normalize spacing/comments around SPI GPIO macros. Add timing.h include to st7789.h and adjust minor header-guard comment spacing.
1 parent ae63e90 commit 328ade1

4 files changed

Lines changed: 31 additions & 25 deletions

File tree

lib-display/include/display.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file display.h
33
*
44
*/
5-
/* Copyright (C) 2022-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2022-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,10 +28,8 @@
2828

2929
#include <cstdint>
3030

31-
namespace display
32-
{
33-
struct Defaults
34-
{
31+
namespace display {
32+
struct Defaults {
3533
static constexpr uint32_t kSleepTimeout = 5;
3634
};
3735
} // namespace display
@@ -51,4 +49,4 @@ struct Defaults
5149
#include STR(EXPAND(DISPLAY_USE_CUSTOM_INCLUDE)/custom/display.h)
5250
#endif
5351

54-
#endif // DISPLAY_H_
52+
#endif // DISPLAY_H_

lib-display/include/spi/config.h

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file config.h
33
*
44
*/
5-
/* Copyright (C) 2022-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2022-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
@@ -47,21 +47,29 @@ inline constexpr uint32_t kHeight = 160;
4747
} // namespace config
4848

4949
#if defined(H3)
50-
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO6
51-
#define SPI_LCD_DC_GPIO GPIO_EXT_26 // GPIO10
52-
#define SPI_LCD_BL_GPIO GPIO_EXT_22 // GPIO2
50+
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO6
51+
#define SPI_LCD_DC_GPIO GPIO_EXT_26 // GPIO10
52+
#define SPI_LCD_BL_GPIO GPIO_EXT_22 // GPIO2
5353
#if defined(SPI_LCD_HAVE_CS_GPIO)
54-
#define SPI_LCD_CS_GPIO GPIO_EXT_24 // GPIO13 / SPI CS0
55-
#endif
54+
#define SPI_LCD_CS_GPIO GPIO_EXT_24 // GPIO13 / SPI CS0
55+
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
5656
#elif defined(GD32) // See board file
57+
#elif defined(RASPPI)
58+
#include "gpio_rasppi.h"
59+
#define SPI_LCD_RST_GPIO GPIO_EXT_7 // GPIO4
60+
#define SPI_LCD_DC_GPIO GPIO_EXT_31 // GPIO6
61+
#define SPI_LCD_BL_GPIO GPIO_EXT_29 // GPIO5
62+
#if defined(SPI_LCD_HAVE_CS_GPIO)
63+
#define SPI_LCD_CS_GPIO GPIO_EXT_22 // GPIO25
64+
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
65+
#elif defined(ODROID)
5766
#else
58-
#include "bcm2835.h"
59-
#define SPI_LCD_RST_GPIO RPI_V2_GPIO_P1_07 // GPIO4
60-
#define SPI_LCD_DC_GPIO RPI_V2_GPIO_P1_31 // GPIO6
61-
#define SPI_LCD_BL_GPIO RPI_V2_GPIO_P1_29 // GPIO5
67+
#define SPI_LCD_RST_GPIO 0
68+
#define SPI_LCD_DC_GPIO 0
69+
#define SPI_LCD_BL_GPIO 0
6270
#if defined(SPI_LCD_HAVE_CS_GPIO)
63-
#define SPI_LCD_CS_GPIO RPI_V2_GPIO_P1_24 // GPIO8 / SPI CS0
64-
#endif
71+
#define SPI_LCD_CS_GPIO 0
72+
#endif // defined(SPI_LCD_HAVE_CS_GPIO)
6573
#endif
6674

6775
#endif // SPI_CONFIG_H_

lib-display/include/spi/display.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,11 @@ class Display : public LcdDriver {
131131
}
132132
}
133133

134-
void PutString(const char* p) {
135-
for (uint32_t i = 0; *p != '\0'; i++) {
136-
PutChar(static_cast<int>(*p));
137-
p++;
138-
}
139-
}
134+
void PutString(const char* p) {
135+
while (*p != '\0') {
136+
PutChar(static_cast<int>(*p++));
137+
}
138+
}
140139

141140
void ClearLine(const uint32_t nLine) {
142141
if (__builtin_expect((!(nLine <= rows_)), 0)) {

lib-display/include/spi/st7789.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file st7789.h
33
*
44
*/
5-
/* Copyright (C) 2022-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2022-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
@@ -31,6 +31,7 @@
3131

3232
#include "spi/config.h"
3333
#include "spi/st77xx.h"
34+
#include "timing.h"
3435
#include "firmware/debug/debug_debug.h"
3536

3637
namespace st7789 {

0 commit comments

Comments
 (0)