diff --git a/dioder.go b/dioder.go index 83db123..71a58dd 100644 --- a/dioder.go +++ b/dioder.go @@ -5,7 +5,6 @@ package dioder import ( "bufio" - "errors" "image/color" "os" "strconv" @@ -130,19 +129,10 @@ func (d *Dioder) SetColor(channel int32, value float64) error { //SetChannelInteger check if the value is in the correct range and convert it to float64 func (d *Dioder) SetChannelInteger(value uint8, channel int32) error { - if value > 255 { - return errors.New("Value can not be over 255") - } - - if value < 0 { - return errors.New("Value can not be under 0") - } - floatval := float64(value) / 255.0 - d.SetColor(channel, float64(floatval)) - - return nil + err := d.SetColor(channel, float64(floatval)) + return err } //Release releases all used pins, so that they can be used in other applications diff --git a/dioder_test.go b/dioder_test.go index 05ccef7..385a27d 100644 --- a/dioder_test.go +++ b/dioder_test.go @@ -140,3 +140,12 @@ func TestDioderTurnOn(t *testing.T) { t.Errorf("Value for blue is wrong. Expected 0, got %d", d.ColorConfiguration.B) } } + +func TestDioder_SetChannelInteger(t *testing.T) { + d := New(pinConfiguration, piBlasterFile) + + err := d.SetChannelInteger(255, 1) + if err != nil { + t.Errorf("Error: %s", err) + } +}