<commit_before>package grovepi.sensors;

import grovepi.GrovePi;
import grovepi.PinMode;

public abstract class Sensor
{
    protected final GrovePi device;
    protected final int pin;

    protected Sensor(GrovePi device, int pin, PinMode pinMode)
    {
        device.pinMode(pin, pinMode);
        this.device = device;
        this.pin = pin;
    }

    public boolean getState()
    {
    	return device.digitalRead(pin) == 0 ? SensorStatus.OFF : SensorStatus.ON;
    }

    public void setState(float newState)
    {
    	byte value = (byte)(int)(255 * newState + 0.5);
        device.analogWrite(pin, value);
    }
    
    public void setState(int newState)
    {
        device.digitalWrite(pin, (byte)newState);
    }
    
    public void setState(boolean newState)
    {
    	setState(!newState ? 0 : 1);
    }
    
}<commit_msg>Potentially fixed analogue out.<commit_after>package grovepi.sensors;

import grovepi.GrovePi;
import grovepi.PinMode;

public abstract class Sensor
{
    protected final GrovePi device;
    protected final int pin;

    protected Sensor(GrovePi device, int pin, PinMode pinMode) {
        device.pinMode(pin, pinMode);
        this.device = device;
        this.pin = pin;
    }

    public boolean getState() {
    	return device.digitalRead(pin) == 0 ? SensorStatus.OFF : SensorStatus.ON;
    }

    public void setState(float newState) {
    	int value = (int)(255 * newState + 0.5);
System.out.println("pin-" + pin + "=" + value);
        device.analogWrite(pin, value);
    }
    
    public void setState(int newState) {
        device.digitalWrite(pin, (byte)newState);
    }
    
    public void setState(boolean newState) {
    	setState(!newState ? 0 : 1);
    }
    
}
{'fraction_non_alphanumeric': 0.1063335270191749, 'fraction_numerical': 0.009296920395119116, 'mean_word_length': 2.6405919661733614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6623167', 'n_tokens_mistral': 581, 'n_tokens_neox': 548, 'n_words': 132}