sow: correction in presence detection
sow: corrections and code changes
sow: rewritten to use GPIO macros