Skip to content

File led.h

File List > external-docs > libDaisy > src > hid > led.h

Go to the documentation of this file

Source Code

#pragma once
#ifndef DSY_LED_H
#define DSY_LED_H
#include "daisy_core.h"
#include "per/gpio.h"

/* TODO - Get this set up to work with the dev_leddriver stuff as well
- Setup Hardware PWM for pins that have it
*/

namespace daisy
{
class Led
{
  public:
    Led() {}
    ~Led() {}

    void Init(Pin pin, bool invert, float samplerate = 1000.0f);

    void Set(float val);

    void Update();

    inline void SetSampleRate(float sample_rate) { samplerate_ = sample_rate; }

  private:
    size_t pwm_cnt_, pwm_thresh_;
    float  bright_;
    float  pwm_;
    float  samplerate_;
    bool   invert_, on_, off_;
    GPIO   hw_pin_;
};

} // namespace daisy

#endif