''' /* ====================================== (c) 2015, Kre8 Technology, Inc.
PROPRIETARY and CONFIDENTIAL ======================================*/ '''
class RobotAPI(object):
def set_sensors(self, buf, from_hex):
def get_effectors(self, to_hex):
def reset(self): # everthing is set to 0 except setf.set_command(1)
def print_sensors(self, print_hex):
if print_hex:
for i in range(0, HS2_Rx.packet_size):
print ("%2.2x"% int(self._rx_packet[i])),
print ''
else: # this shows human friendly output format
print ("%#3.1x"% self.get_version()),
print ("%#3.1x"% self.get_topology()),
print ("%3d"% self.get_network_id()),
print ("%#3.1x"% self.get_command()),
print ("%#3.1x"% self.get_security()),
print ("%4d"% self.get_signal()),
print ("%3d"% self.get_proximity(0)),
print ("%3d"% self.get_proximity(1)),
print ("%3d"% self.get_floor(0)),
print ("%3d"% self.get_floor(1)),
print ("%6d"% self.get_acceleration(0)),
print ("%6d"% self.get_acceleration(1)),
print ("%6d"% self.get_acceleration(2)),
print ("%3d"% self.get_flag()),
print ("%5d"% self.get_light()),
print ("%5.1f"% self.get_temperature()),
print ("%4.2f"% self.get_battery()),
print ("%#3.1x"% self.get_io_mode(0)),
print ("%#3.1x"% self.get_io_mode(1)),
print ("%3d"% self.get_port(0)),
print ("%3d"% self.get_port(1)),
print ("%3d"% self.get_linetracer_state())
#accesors
def get_version(self):
def get_topology(self):
def get_network_id(self):
def get_command(self):
def get_security(self):
def get_signal(self):
def get_proximity(self, side): #0: left, 1:right
def get_floor(self, side): #0: left, 1:right
def get_acceleration(self, axis): #0:x, 1:y, 2:z
def get_flag(self): #0: (light_high, light_low), 1:(temperature, battery), next 2 bytes
def get_light(self):
def get_temperature(self):
def get_battery(self):
def get_io_mode(self, side): #0: portA, 1: portB
def get_port(self, side): #0: portA, 1: portB
def get_linetracer_state(self):
#mutators
def set_version(self, value):
def set_topology(self, value):
def set_network_id(self, value):
def set_command(self, value):
def set_security(self, value):
def set_wheel(self, side, speed): # 0: left, 1:right #speed: -100 ~ 100 %
def set_led(self, side, color): # 0: left, 1:right #color: 7(white),6(yellow),5(magenta),4(red),3(cyan),2(green),1(blue),0(off)
def set_buzzer(self, value): # 0.01 ~ 167772.15 Hz (0:off)
def set_musical_note(self, value): # 1 ~ 88 (0:off), piano key: 40 = C4 (middle C)
def set_line_tracer_mode_speed(self, mode, speed): # 0x11 ~ 0x6A (0: off), speed 7(100%)
def set_proximity_ir_current(self, value): # 0 ~ 7 (0,2: default)
def set_gravity_range(self, value): # range 0~3(2G, 4G, 8G, 16G)
def set_gravity_bandwidth(self, value): # bandwidth 0~8 (default 0, 3: 31.25 ~ 1000Hz)
def set_io_mode(self, side, value): #0 : portA, 1: portB, #0 ~ 127 #0x00(ADC), 0x01(DI), 0x08(ASC), 0x09(PWM), 0x0A(DO)
def set_port(self, side, value): # 0: portA, 1: portB, # value: 0 ~ 255
def set_wheel_balance(self, value): # -128 ~ 127 (0: off)
def set_input_pull(self, side, value): # side 0: portA, side 1: portB, value: 0~3
def set_reserved(self, value):