Skip to content

Commit 6b0eb4d

Browse files
Fix GPIO Controller lazy loading (#196)
1 parent 4909565 commit 6b0eb4d

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

AtomCommon/AtomBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static GpioButton Button
4343
{
4444
if (_button == null)
4545
{
46-
_button = new(39, _gpio, false);
46+
_button = new(39, GpioController, false);
4747
}
4848

4949
return _button;

nanoFramework.Fire/Fire.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static GpioButton ButtonLeft
5353
{
5454
if (_left == null)
5555
{
56-
_left = new(39, _gpio, false);
56+
_left = new(39, GpioController, false);
5757
}
5858

5959
return _left;
@@ -69,7 +69,7 @@ public static GpioButton ButtonCenter
6969
{
7070
if (_center == null)
7171
{
72-
_center = new(38, _gpio, false);
72+
_center = new(38, GpioController, false);
7373
}
7474

7575
return _center;
@@ -85,7 +85,7 @@ public static GpioButton ButtonRight
8585
{
8686
if (_right == null)
8787
{
88-
_right = new(37, _gpio, false);
88+
_right = new(37, GpioController, false);
8989
}
9090

9191
return _right;
@@ -166,9 +166,7 @@ static Fire()
166166
_power.ChargingCutOffCurrent = ChargingCutOffCurrent.C500mA;
167167
_power.ChargingCuttOffVoltage = ChargingCutOffVoltage.V4_2;
168168

169-
// Setup buttons
170-
_gpio = new();
171-
169+
172170
// Config GPIOs for SPI (screen and SD Card)
173171
Configuration.SetPinFunction(23, DeviceFunction.SPI1_MOSI);
174172
Configuration.SetPinFunction(19, DeviceFunction.SPI1_MISO);

nanoFramework.M5Core/M5Core.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static GpioButton ButtonLeft
3434
{
3535
if (_left == null)
3636
{
37-
_left = new(39, _gpio, false);
37+
_left = new(39, GpioController, false);
3838
}
3939

4040
return _left;
@@ -50,7 +50,7 @@ public static GpioButton ButtonCenter
5050
{
5151
if (_center == null)
5252
{
53-
_center = new(38, _gpio, false);
53+
_center = new(38, GpioController, false);
5454
}
5555

5656
return _center;
@@ -66,7 +66,7 @@ public static GpioButton ButtonRight
6666
{
6767
if (_right == null)
6868
{
69-
_right = new(37, _gpio, false);
69+
_right = new(37, GpioController, false);
7070
}
7171

7272
return _right;
@@ -151,9 +151,7 @@ static M5Core()
151151
_power.ChargingCutOffCurrent = ChargingCutOffCurrent.C500mA;
152152
_power.ChargingCuttOffVoltage = ChargingCutOffVoltage.V4_2;
153153

154-
// Setup buttons
155-
_gpio = new();
156-
154+
157155
// Config GPIOs for SPI (screen and SD Card)
158156
Configuration.SetPinFunction(23, DeviceFunction.SPI1_MOSI);
159157
Configuration.SetPinFunction(19, DeviceFunction.SPI1_MISO);

nanoFramework.M5StickCommon/M5StickCBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static GpioButton ButtonM5
5252
{
5353
if (_buttonM5 == null)
5454
{
55-
_buttonM5 = new(37, _gpio, false);
55+
_buttonM5 = new(37, GpioController, false);
5656
}
5757

5858
return _buttonM5;
@@ -68,7 +68,7 @@ public static GpioButton ButtonRight
6868
{
6969
if (_buttonRight == null)
7070
{
71-
_buttonRight = new(39, _gpio, false);
71+
_buttonRight = new(39, GpioController, false);
7272
}
7373

7474
return _buttonRight;
@@ -84,7 +84,7 @@ public static GpioPin Led
8484
{
8585
if (_led == null)
8686
{
87-
_led = _gpio.OpenPin(10, PinMode.Output);
87+
_led = GpioController.OpenPin(10, PinMode.Output);
8888
}
8989

9090
return _led;

0 commit comments

Comments
 (0)