Added support for Reflection Raw mode for the color sensor to the simulator (#1017)
* redesigned-code-to-support-ref-raw Code that adds reflection raw support for the color sensor. The range of values for this is from 0 to 1023, because analog to digital converter is 10 bits. In fact, the color sensor gives values of about 400 - 700, but I decided to leave the range, which could theoretically be. For other cases (reflections and ambient lighting), the range remains from 0 to 100. The average value when setting the mode in the simulator is displayed as 512, for other modes 50%. * block-description-update Block description update, as it did not take into account the mode of raw reflection values.
This commit is contained in:
		@@ -21,7 +21,7 @@ namespace pxsim {
 | 
			
		||||
    export class ColorSensorNode extends UartSensorNode {
 | 
			
		||||
        id = NodeType.ColorSensor;
 | 
			
		||||
 | 
			
		||||
        private color: number = 50;
 | 
			
		||||
        private color: number = 0;
 | 
			
		||||
 | 
			
		||||
        constructor(port: number) {
 | 
			
		||||
            super(port);
 | 
			
		||||
@@ -40,5 +40,13 @@ namespace pxsim {
 | 
			
		||||
        getValue() {
 | 
			
		||||
            return this.color;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setMode(mode: number) {
 | 
			
		||||
            this.mode = mode;
 | 
			
		||||
            if (this.mode == ColorSensorMode.RefRaw) this.color = 512; 
 | 
			
		||||
            else this.color = 50;
 | 
			
		||||
            this.changed = true;
 | 
			
		||||
            this.modeChanged = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user