Skip to content
Snippets Groups Projects
Commit af64207a authored by ft-Demo's avatar ft-Demo
Browse files

commit by robo pro coding

parent ef2a19c4
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -13,6 +13,9 @@ _active = None
speed = None
thresh_white_red = None
thresh_red_blue = None
calibvalue_white = None
calibvalue_red = None
calibvalue_blue = None
state_code = None
state_active = None
thresh_white_red_defaults = None
......@@ -25,18 +28,52 @@ lastStateCounterSwitch = None
def set_thresh_white_red(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
thresh_white_red = v
def set_thresh_red_blue(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
thresh_red_blue = v
def get_thresh_list():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
return [thresh_white_red, thresh_red_blue]
def calculate_thresh():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
thresh_white_red = (calibvalue_white + calibvalue_red) / 2
thresh_red_blue = (calibvalue_red + calibvalue_blue) / 2
def get_calibvalue_list():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
return [calibvalue_white, calibvalue_red, calibvalue_blue]
def set_calibvalue_white(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
calibvalue_white = v
def set_calibvalue_red(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
calibvalue_red = v
def set_calibvalue_blue(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
calibvalue_blue = v
def thread_SLD():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
calibvalue_white = 0
calibvalue_red = 0
calibvalue_blue = 0
thresh_white_red_defaults = 1150
thresh_white_red = thresh_white_red_defaults
thresh_red_blue_defaults = 1600
......@@ -89,26 +126,26 @@ def thread_SLD():
def get_calib_data_SLD_defaults():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
return [thresh_white_red_defaults, thresh_red_blue_defaults]
def get_calib_data_SLD():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
return [thresh_white_red, thresh_red_blue]
def set_calib_data_SLD(_data):
global v, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, _data)
thresh_white_red = _data[0]
thresh_red_blue = _data[1]
def _set_state_SLD(_code, _active):
global v, _data, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
if state_code != _code or state_active != _active:
_ts_state = 0
......@@ -117,26 +154,26 @@ def _set_state_SLD(_code, _active):
def get_state_code_SLD():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return state_code
def get_state_active_SLD():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return state_active
def setConvBeltSpeedSLD(speed):
global v, _data, _code, _active, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, 'speed: %d', speed)
TXT_SLD_E5_M1_encodermotor.set_speed(int(speed), Motor.CW)
TXT_SLD_E5_M1_encodermotor.start()
def ejectWhite():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
TXT_SLD_E5_O5_magnetic_valve.on()
time.sleep(0.5)
......@@ -150,7 +187,7 @@ def ejectWhite():
def ejectRed():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
TXT_SLD_E5_O6_magnetic_valve.on()
time.sleep(0.5)
......@@ -164,7 +201,7 @@ def ejectRed():
def ejectBlue():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
TXT_SLD_E5_O7_magnetic_valve.on()
time.sleep(0.5)
......@@ -178,37 +215,37 @@ def ejectBlue():
def isColorSensorTriggered():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I1_photo_transistor.is_dark()
def isEjectionTriggered():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I3_photo_transistor.is_dark()
def isWhite():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I6_photo_transistor.is_dark()
def isRed():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I7_photo_transistor.is_dark()
def isBlue():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I8_photo_transistor.is_dark()
def readColorValue():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I2_color_sensor.get_voltage()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment