Skip to content

Commit

Permalink
Merge pull request #86 from WildernessLabs/feature/remove-sleep
Browse files Browse the repository at this point in the history
remove sleep/wake from demo app
  • Loading branch information
adrianstevens authored Feb 2, 2024
2 parents 8ee063b + 4308311 commit e3f2a8e
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions Source/ProjectLab_Demo/MeadowApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,58 +99,11 @@ public override Task Initialize()
upButton.PressEnded += (s, e) => displayController.UpButtonState = false;
}

_powerPort = projLab.IOTerminal.Pins.A1.CreateDigitalInterruptPort(InterruptMode.EdgeFalling, ResistorMode.Disabled);
_powerPort.Changed += OnPowerPortChanged;

_backlighPort = projLab.MikroBus1.Pins.INT.CreateDigitalOutputPort(true);

Device.PlatformOS.AfterWake += AfterWake;

PowerOnPeripherals(false);

Resolver.Log.Info("Initialization complete");

return base.Initialize();
}

private void AfterWake(object sender, WakeSource e)
{
if (e == WakeSource.Interrupt)
{
Resolver.Log.Info("Wake on interrupt");
PowerOnPeripherals(true);
}
else
{
PowerOffPeripherals();
}
}

private void PowerOffPeripherals()
{
Resolver.Log.Info("Powering off");
// _backlighPort.State = false;
Device.PlatformOS.Sleep(projLab.IOTerminal.Pins.A1, InterruptMode.EdgeRising);
}

private void PowerOnPeripherals(bool fromWake)
{
Resolver.Log.Info("Powering on");
_backlighPort.State = true;
}

private void OnPowerPortChanged(object sender, DigitalPortResult e)
{
var powerState = _powerPort.State;

Resolver.Log.Info($"Power port state changed to {powerState}");

if (!powerState)
{
PowerOffPeripherals();
}
}

public override Task Run()
{
Resolver.Log.Info("Run...");
Expand Down

0 comments on commit e3f2a8e

Please sign in to comment.