Property definitions

bcm2835 $ RotaryEncoder :: defaultinit
class RotaryEncoder
	var pin_a: RPiPin
	var pin_b: RPiPin
	var old_a= false
	var old_b= false

	# returns '<', '>' or null accoring to rotation or lack thereof
	fun update: nullable Char
	do
		var new_a = pin_a.lev
		var new_b = pin_b.lev
		var res = null

		if new_a != old_a or new_b != old_b then
			if not old_a and not old_b then
				# everything was on
				if not new_a and new_b then
					res = '<'
				else if new_a and not new_b then
					res = '>'
				end
			else if old_a and old_b then
				# everything was off
				if not new_a and new_b then
					res = '>'
				else if new_a and not new_b then
					res = '<'
				end
			end

			old_a = new_a
			old_b = new_b
		end

		return res
	end
end
lib/bcm2835/bcm2835.nit:126,1--162,3