bcm2835 :: Switch :: _last_down
bcm2835 :: Switch :: defaultinit
bcm2835 :: Switch :: last_down=
bcm2835 :: Switch :: _last_down
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
bcm2835 :: Switch :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
bcm2835 :: Switch :: last_down=
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).
# Component for any kind of buttons or switches
class Switch
var pin: RPiPin
init (pin: RPiPin, pud: PUDControl)
do
self.pin = pin
pin.fsel = new FunctionSelect.inpt
pin.pud = pud
end
fun is_down: Bool do return pin.lev
var last_down: nullable Bool = null
# Returns true is state (is_down) changed since last call to `changed`
fun changed: Bool
do
var now = is_down
var last_down = last_down
if last_down == null then
self.last_down = now
return false
else if last_down != now then
self.last_down = now
return true
else return false
end
end
lib/bcm2835/bcm2835.nit:455,1--483,3