Skip to content

Commit ac68b6d

Browse files
authored
Fix initialization of GpioController in Atom and M5Stick (#193)
1 parent 6e377c2 commit ac68b6d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

AtomCommon/AtomBase.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,18 @@ public static GpioButton Button
5353
/// <summary>
5454
/// Gets the main <see cref="GpioController"/>.
5555
/// </summary>
56-
public static GpioController GpioController => _gpio;
56+
public static GpioController GpioController
57+
{
58+
get
59+
{
60+
if (_gpio is null)
61+
{
62+
_gpio = new();
63+
}
64+
65+
return _gpio;
66+
}
67+
}
5768

5869
/// <summary>
5970
/// Gets <see cref="DacChannel"/> connected to GPIO 25.

nanoFramework.M5StickCommon/M5StickCBase.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,18 @@ public static Pcf8563 RealTimeClock
134134
/// <summary>
135135
/// Gets the main GPIO Controller.
136136
/// </summary>
137-
public static GpioController GpioController => _gpio;
137+
public static GpioController GpioController
138+
{
139+
get
140+
{
141+
if (_gpio is null)
142+
{
143+
_gpio = new();
144+
}
145+
146+
return _gpio;
147+
}
148+
}
138149

139150
#if M5STICKC
140151
static M5StickC()

0 commit comments

Comments
 (0)