rpi need to change threshold function