# Change XYZ to the UID of your Multi Touch Bricklet

setup:
	# Get current touch state
	subscribe to tinkerforge/response/multi_touch_bricklet/XYZ/get_touch_state
		if a message arrives:
			# message contains state as int
			set result_string to ""
			if bit 12 of state is set
				append "In proximity, " to result_string
			endif

			if bits 0 to 11 of state are not set
				append "No electrodes touched" to result_string
			elseif
				append "Electrodes " to result_string
				for i in 0..12
					if bit i of state is set
						append i and " " to result_string
					endif
				endfor
			endif

			print result_string
		endif
	endsubscribe

	publish '' to tinkerforge/request/multi_touch_bricklet/XYZ/get_touch_state
