Move all the hardware interaction into a library