Skip to content

Commit c5ba533

Browse files
committed
Release 9.1.1
1 parent b97ba9f commit c5ba533

File tree

9 files changed

+414
-11
lines changed

9 files changed

+414
-11
lines changed

examples/EXT4/EXT4_WS2813C/EXT4_WS2813C.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@
4040
// Include application, user and local libraries
4141
// #include <SPI.h>
4242

43+
// Checks: Pervasive Displays EXT4 only
4344
#if (USE_EXT_BOARD != BOARD_EXT4)
4445
#error Required USE_EXT_BOARD = BOARD_EXT4
4546
#endif // USE_EXT_BOARD
4647

4748
// WS2813C
48-
#include "ezWS2812gpio.h"
49+
// #include "ezWS2812gpio.h"
50+
#include "rawWS2813C.h"
4951

5052
// Set parameters
5153

@@ -55,7 +57,8 @@
5557
const pins_t myBoard = boardArduinoNanoMatter;
5658

5759
// WS2813
58-
ezWS2812gpio myRGB(1, myBoard.ledData);
60+
// ezWS2812gpio myRGB(1, myBoard.ledData);
61+
rawWS2813C myRGB(1, myBoard.ledData);
5962

6063
// Prototypes
6164

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
///
2+
/// @file rawWS2813C.cpp
3+
///
4+
/// @brief Driver for WS2813C
5+
/// @version 103
6+
/// @date 16 Feb 2024
7+
///
8+
/// @author Rei Vilo for Pervasive Displays https://www.pervasivedisplays.com
9+
/// @copyright Copyright (c) 2010-2025 Rei Vilo for Pervasive Displays
10+
/// @copyright License CC-BY-SA Creative Commons - Attribution - Share Alike
11+
/// https://creativecommons.org/licenses/by-sa/4.0/deed.en
12+
///
13+
14+
#include "rawWS2813C.h"
15+
16+
#include <stdio.h>
17+
#include <stdint.h>
18+
#include <stdbool.h>
19+
#include "em_common.h"
20+
#include "em_gpio.h"
21+
#include "sl_udelay.h"
22+
23+
///
24+
/// @brief Define GPIO for WS2813C
25+
/// @param port port, gpioPortA..gpioPortD
26+
/// @param pin pin, O..16 according to port
27+
///
28+
void wsDefine(uint8_t port, uint8_t pin);
29+
30+
///
31+
/// @brief Set RGB values
32+
/// @param red red component, 0..255
33+
/// @param green green component, 0..255
34+
/// @param blue blue component, 0..255
35+
///
36+
void wsWrite(uint8_t red, uint8_t green, uint8_t blue);
37+
38+
uint8_t wsPort;
39+
uint8_t wsBit;
40+
41+
void wsDefine(uint8_t port, uint8_t pin)
42+
{
43+
wsPort = port;
44+
wsBit = pin;
45+
46+
GPIO_PinModeSet(wsPort, wsBit, gpioModePushPull, 0);
47+
wsWrite(0, 0, 0);
48+
}
49+
50+
void wsWrite(uint8_t red, uint8_t green, uint8_t blue)
51+
{
52+
// uint32_t valueG70R70B70 = 0b111100001010101011001100; // 0xf0aacc
53+
uint32_t valueG70R70B70 = (green << 16) | (red << 8) | blue;
54+
uint32_t valueB07R07G07 = 0;
55+
56+
for (uint8_t i = 0; i < 24; i += 1)
57+
{
58+
valueB07R07G07 <<= 1;
59+
valueB07R07G07 |= (valueG70R70B70 & 1);
60+
valueG70R70B70 >>= 1;
61+
}
62+
63+
for (uint8_t i = 0; i < 24; i += 1)
64+
{
65+
if (valueB07R07G07 & 1)
66+
{
67+
// 1 code = T1H T1L
68+
// T1H 1-code, High-level time 580ns~1.6μs
69+
// T1L 1-code, Low-level time 220ns~420ns
70+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
71+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
72+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
73+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
74+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
75+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
76+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
77+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
78+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
79+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
80+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
81+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
82+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
83+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns * 14 = 784 ns
84+
85+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
86+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
87+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
88+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
89+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
90+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns * 6 = 276 ns
91+
}
92+
else
93+
{
94+
// 0 code = T0H T0L
95+
// T0H 0-code, High-level time 220ns~380ns
96+
// T0L 0-code, Low-level time 580ns~1.6μs
97+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
98+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
99+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
100+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
101+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns * 5 = 280 ns
102+
103+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
104+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
105+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
106+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
107+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
108+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
109+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
110+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
111+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
112+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
113+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
114+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
115+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
116+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
117+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns * 15 = 690 ns
118+
}
119+
valueB07R07G07 >>= 1;
120+
}
121+
}
122+
123+
124+
rawWS2813C::rawWS2813C(uint32_t num_leds, pin_size_t pin)
125+
{
126+
wsPinArduino = pin;
127+
}
128+
129+
void rawWS2813C::begin()
130+
{
131+
PinName wsName;
132+
133+
wsName = pinToPinName(wsPinArduino);
134+
wsPort = getSilabsPortFromArduinoPin(wsName);
135+
wsBit = getSilabsPinFromArduinoPin(wsName);
136+
137+
wsDefine(wsPort, wsBit);
138+
}
139+
140+
void rawWS2813C::set_all(uint8_t red, uint8_t green, uint8_t blue)
141+
{
142+
wsWrite(red, green, blue);
143+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
///
2+
/// @file rawWS2813C.h
3+
/// @brief Driver for WS2813C
4+
/// @version 103
5+
/// @date 16 Feb 2024
6+
///
7+
/// @author Rei Vilo for Pervasive Displays https://www.pervasivedisplays.com
8+
/// @copyright Copyright (c) 2010-2025 Rei Vilo for Pervasive Displays
9+
/// @copyright License CC-BY-SA Creative Commons - Attribution - Share Alike
10+
/// https://creativecommons.org/licenses/by-sa/4.0/deed.en
11+
///
12+
/// @see https://github.com/SiliconLabs/arduino/issues/106
13+
///
14+
15+
#ifndef rawWS2813C_RELEASE
16+
#define rawWS2813C_RELEASE 103
17+
18+
#include "Arduino.h"
19+
20+
///
21+
/// @class rawWS2813C
22+
/// @details Minimal class for WS2813C
23+
///
24+
class rawWS2813C
25+
{
26+
public:
27+
///
28+
/// @brief Construct WS2813C object
29+
///
30+
/// @param num_leds 1, ignored
31+
/// @param pin Arduino pin, name `D4` or number `4`
32+
///
33+
rawWS2813C(uint32_t num_leds, pin_size_t pin);
34+
35+
///
36+
/// @brief Initialise
37+
///
38+
void begin();
39+
40+
///
41+
/// @brief Set RGB LED
42+
///
43+
/// @param red red component, 0..255
44+
/// @param green green component, 0..255
45+
/// @param blue blue component, 0..255
46+
///
47+
void set_all(uint8_t red, uint8_t green, uint8_t blue);
48+
49+
private:
50+
uint8_t wsPinArduino;
51+
uint32_t wsBit;
52+
uint8_t wsPort; // enum GPIO_Port_TypeDef
53+
};
54+
55+
#endif // rawWS2813C_RELEASE
56+

examples/EXT4_Matter/EXT4_Matter_RGB/EXT4_Matter_RGB.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
/// @n All rights reserved
4040
///
4141

42-
// SDK
42+
// SDK and configuration
4343
// #include <Arduino.h>
4444
#include "PDLS_Common.h"
4545

@@ -77,7 +77,8 @@
7777
MatterColorLightbulb myMatterRGB;
7878

7979
// WS2813C
80-
#include "ezWS2812gpio.h"
80+
// #include "ezWS2812gpio.h"
81+
#include "rawWS2813C.h"
8182

8283
// Set parameters
8384
#define MATTER_EXAMPLE_NAME "Matter RGB"
@@ -101,7 +102,8 @@ Screen_EPD myScreen(&myDriver);
101102
uint8_t fontSmall, fontMedium, fontLarge, fontVery;
102103

103104
// WS2813
104-
ezWS2812gpio myRGB(1, myBoard.ledData);
105+
// ezWS2812gpio myRGB(1, myBoard.ledData);
106+
rawWS2813C myRGB(1, myBoard.ledData);
105107

106108
static bool wsState = false;
107109
const uint8_t wsLimit = 64; // Limit for each RGB channel
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
///
2+
/// @file rawWS2813C.cpp
3+
///
4+
/// @brief Driver for WS2813C
5+
/// @version 103
6+
/// @date 16 Feb 2024
7+
///
8+
/// @author Rei Vilo for Pervasive Displays https://www.pervasivedisplays.com
9+
/// @copyright Copyright (c) 2010-2025 Rei Vilo for Pervasive Displays
10+
/// @copyright License CC-BY-SA Creative Commons - Attribution - Share Alike
11+
/// https://creativecommons.org/licenses/by-sa/4.0/deed.en
12+
///
13+
14+
#include "rawWS2813C.h"
15+
16+
#include <stdio.h>
17+
#include <stdint.h>
18+
#include <stdbool.h>
19+
#include "em_common.h"
20+
#include "em_gpio.h"
21+
#include "sl_udelay.h"
22+
23+
///
24+
/// @brief Define GPIO for WS2813C
25+
/// @param port port, gpioPortA..gpioPortD
26+
/// @param pin pin, O..16 according to port
27+
///
28+
void wsDefine(uint8_t port, uint8_t pin);
29+
30+
///
31+
/// @brief Set RGB values
32+
/// @param red red component, 0..255
33+
/// @param green green component, 0..255
34+
/// @param blue blue component, 0..255
35+
///
36+
void wsWrite(uint8_t red, uint8_t green, uint8_t blue);
37+
38+
uint8_t wsPort;
39+
uint8_t wsBit;
40+
41+
void wsDefine(uint8_t port, uint8_t pin)
42+
{
43+
wsPort = port;
44+
wsBit = pin;
45+
46+
GPIO_PinModeSet(wsPort, wsBit, gpioModePushPull, 0);
47+
wsWrite(0, 0, 0);
48+
}
49+
50+
void wsWrite(uint8_t red, uint8_t green, uint8_t blue)
51+
{
52+
// uint32_t valueG70R70B70 = 0b111100001010101011001100; // 0xf0aacc
53+
uint32_t valueG70R70B70 = (green << 16) | (red << 8) | blue;
54+
uint32_t valueB07R07G07 = 0;
55+
56+
for (uint8_t i = 0; i < 24; i += 1)
57+
{
58+
valueB07R07G07 <<= 1;
59+
valueB07R07G07 |= (valueG70R70B70 & 1);
60+
valueG70R70B70 >>= 1;
61+
}
62+
63+
for (uint8_t i = 0; i < 24; i += 1)
64+
{
65+
if (valueB07R07G07 & 1)
66+
{
67+
// 1 code = T1H T1L
68+
// T1H 1-code, High-level time 580ns~1.6μs
69+
// T1L 1-code, Low-level time 220ns~420ns
70+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
71+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
72+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
73+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
74+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
75+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
76+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
77+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
78+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
79+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
80+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
81+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
82+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
83+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns * 14 = 784 ns
84+
85+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
86+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
87+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
88+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
89+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
90+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns * 6 = 276 ns
91+
}
92+
else
93+
{
94+
// 0 code = T0H T0L
95+
// T0H 0-code, High-level time 220ns~380ns
96+
// T0L 0-code, Low-level time 580ns~1.6μs
97+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
98+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
99+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
100+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns
101+
GPIO_PinOutSet(wsPort, wsBit); // 56 ns * 5 = 280 ns
102+
103+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
104+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
105+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
106+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
107+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
108+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
109+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
110+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
111+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
112+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
113+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
114+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
115+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
116+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns
117+
GPIO_PinOutClear(wsPort, wsBit); // 46 ns * 15 = 690 ns
118+
}
119+
valueB07R07G07 >>= 1;
120+
}
121+
}
122+
123+
124+
rawWS2813C::rawWS2813C(uint32_t num_leds, pin_size_t pin)
125+
{
126+
wsPinArduino = pin;
127+
}
128+
129+
void rawWS2813C::begin()
130+
{
131+
PinName wsName;
132+
133+
wsName = pinToPinName(wsPinArduino);
134+
wsPort = getSilabsPortFromArduinoPin(wsName);
135+
wsBit = getSilabsPinFromArduinoPin(wsName);
136+
137+
wsDefine(wsPort, wsBit);
138+
}
139+
140+
void rawWS2813C::set_all(uint8_t red, uint8_t green, uint8_t blue)
141+
{
142+
wsWrite(red, green, blue);
143+
};

0 commit comments

Comments
 (0)