def main():
    try:
        camera_control = CameraControl()
        camera_control.start()
        while True:
            qrcode = camera_control.get_qr_code()
            if qrcode:
                print qrcode
            time.sleep(1)
    except KeyboardInterrupt:
        camera_control.stop()
        camera_control.join()
def main():
    servo_control = ServoControl(11)
    servo_control.setup_gpio()
    camera_control = CameraControl()
    camera_control.start()
    try:
        camera_control.wait_for_camera()
        while True:
            scanned_qrcode = []
            if is_at_start(camera_control):
                # If at start we will work towards left
                print('is_at_start')
                direction = DIRECTION_LEFT
                state = STATE_START
            #elif is_at_end(camera_control):
            #    # If at the end we will work towards right
            #    print('is_at_end')
            #    direction = DIRECTION_RIGHT
            #    state = STATE_STOP
            else:
                # If not at start or not at end, move to start
                print('Not at start or end, moving to start')
                state = move_to_start(camera_control, servo_control)
                direction = DIRECTION_LEFT
                servo_control.move_stop()
            while True:
                curr_state = work(camera_control, servo_control,
                                  scanned_qrcode, direction, state)
                state = curr_state
                if state == STATE_STOP:
                    print('at stop')
                    break
                time.sleep(1)
    except KeyboardInterrupt:
        servo_control.stop()
        camera_control.stop()
        camera_control.join()