Professional Documents
Culture Documents
RunColorSensorService:
If this event is ES_TIMEOUT from update timer
Re-initialize the timer
If we are transporting the miner
Query the miner location of the current miner
If this location is invalid
Update the current color of tractor
Else
Update the current color of tractor
End if
End if
End if
QueryColor:
Return last known color
SetDesiredColor:
Set color for desired color
UpdateColor:
Call GetRGB
Call RBG2HSV
Return ClassifyColor
GetRGB:
Query RGB and clear values from I2C module
RBG2HSV:
Compute HSV values from RBG using running average
ClassifyColor
Loop through the colors
If color falls within specific HSV range and tolerance
Return that color
End if