def __init__(self):
     self.min_speed = 0
     self.max_speed = 100
     self.speed_delta = 5
     self.speed = 0  # int between  to 100
     self.train_enginecar_keys = None  # TODO - do an enum of KEYS_ON and KEYS_OFF, to stop/start the car
     self.direction = RIGHT  # left or right
     self.keys_on = False
     self.msg_to_display = ""
     GPIO_handler.initialize()
     self.speed_control = GPIO_handler.get_speed_control()
Esempio n. 2
0
def update():
	config = ConfigObj('/home/pi/node-fyp/config/general.ini')

	GPIO_handler.write(config['last_state']['plug_state'])
	if config['range_extension']['enable'] == 'true':
		subprocess.call('ifconfig wlan0 ' + config['range_extension']['router'] + ' netmask ' + config['range_extension']['netmask'], shell=True)
		subprocess.call('service isc-dhcp-server restart', shell=True)
		subprocess.call('service hostapd restart', shell=True)
	else:
		subprocess.call('service hostapd stop', shell=True)
		subprocess.call('service udhcpd stop', shell=True)
    def set_direction(self, _direction):
        # TBD - add check if direction is changing.
        # if yes: wait 2 seconds to avoid damage to engine
        if self.keys_on == False:
            return

        if _direction == RIGHT:
            self.direction = RIGHT
            GPIO_handler.set_right()
            # print(">>>",end='')
        else:
            self.direction = LEFT
            GPIO_handler.set_left()
 def train_exit(self):
     self.keys_on = False
     self.speed_control.stop()
     GPIO_handler.cleanup()
 def motor_shut_down(self):
     if self.keys_on == True:
         self.keys_on = False
         self.speed = 0
         self.speed_control.stop()
         GPIO_handler.shut_down()