All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ociweb.iot.hardware.impl.test.SinTestPortReader Maven / Gradle / Ivy

Go to download

FogLight is a lightweight runtime that enables makers of all ages and skill levels to create highly performant apps for embedded devices like Raspberry Pi's.

The newest version!
package com.ociweb.iot.hardware.impl.test;

import com.ociweb.iot.maker.Port;

public class SinTestPortReader implements TestPortReader {
    private long iteration =  360;
    @Override
    public int read(Port port, int pinData, int hardwareRange) {long degrees = iteration % 360;
        double radians = degrees * Math.PI / 180.0;
        double s = (Math.sin(radians) + 1.0) / 2.0;
        long value = Math.round(hardwareRange * s);
        iteration++;
        return (int) value;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy