|
|
|
|
@ -8,13 +8,10 @@ with MicroBit.Display; |
|
|
|
|
with MicroBit.Accelerometer; |
|
|
|
|
with MicroBit.Console; |
|
|
|
|
with MicroBit.Buttons; use MicroBit.Buttons; |
|
|
|
|
-- with MicroBit.IOs; |
|
|
|
|
with MicroBit.Time; |
|
|
|
|
with nRF.GPIO; use nRF.GPIO; |
|
|
|
|
--with HAL.GPIO; use HAL.GPIO; |
|
|
|
|
|
|
|
|
|
use MicroBit; |
|
|
|
|
-- use MicroBit.IOs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure Main is |
|
|
|
|
@ -32,7 +29,6 @@ procedure Main is |
|
|
|
|
DO_2_Pt : GPIO_Point; |
|
|
|
|
DO_3_Pt : GPIO_Point; |
|
|
|
|
DO_4_Pt : GPIO_Point; |
|
|
|
|
--DO_Conf : GPIO_Configuration; |
|
|
|
|
DI_Conf_Up : GPIO_Configuration; |
|
|
|
|
DI_Conf_Down : GPIO_Configuration; |
|
|
|
|
|
|
|
|
|
@ -51,10 +47,6 @@ begin |
|
|
|
|
DO_2_Pt := MB_P8; |
|
|
|
|
DO_3_Pt := MB_P9; |
|
|
|
|
DO_4_Pt := MB_P16; |
|
|
|
|
--DO_Conf.Mode := Mode_Out; |
|
|
|
|
--DO_Conf.Resistors := No_Pull; |
|
|
|
|
--DO_Conf.Input_Buffer := Input_Buffer_Connect; |
|
|
|
|
--DO_Conf.Sense := Sense_Disabled; |
|
|
|
|
|
|
|
|
|
DI_Conf_Up.Mode := Mode_In; |
|
|
|
|
DI_Conf_Up.Resistors := Pull_Up; |
|
|
|
|
@ -68,29 +60,11 @@ begin |
|
|
|
|
|
|
|
|
|
-- APPLY IO CONFIGURATION |
|
|
|
|
DO_1_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
--DO_1_Pt.Clear; |
|
|
|
|
DO_2_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
--DO_2_Pt.Clear; |
|
|
|
|
DO_3_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
--DO_3_Pt.Clear; |
|
|
|
|
DO_4_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
--DO_4_Pt.Set_Pull_Resistor(HAL.GPIO.Pull_Down); |
|
|
|
|
--DO_4_Pt.Clear; |
|
|
|
|
--Set_Pull_Resistor(DO_4_Pt,Pull => Pull_Down); |
|
|
|
|
|
|
|
|
|
loop |
|
|
|
|
if Buttons.State (Button_A) = Pressed then |
|
|
|
|
DO_1_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
DO_2_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
DO_3_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
DO_4_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
end if; |
|
|
|
|
if Buttons.State (Button_B) = Pressed then |
|
|
|
|
DO_1_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
DO_2_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
DO_3_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
DO_4_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
end if; |
|
|
|
|
-- Read the accelerometer data |
|
|
|
|
Data := Accelerometer.Data; |
|
|
|
|
|
|
|
|
|
@ -123,11 +97,13 @@ begin |
|
|
|
|
|
|
|
|
|
-- Check, wether FreeFallCondition was triggered |
|
|
|
|
if FreeFallCondition then |
|
|
|
|
-- set outputs |
|
|
|
|
-- set outputs -> motor on |
|
|
|
|
DO_1_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
DO_2_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
DO_3_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
DO_4_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
-- maybe timeout and stop motor |
|
|
|
|
-- deep sleep afterwards |
|
|
|
|
Display.Display ('X'); |
|
|
|
|
else |
|
|
|
|
Display.Display ('0'); |
|
|
|
|
|