Skip to content

File ui_glue.h

File List > Desktop-DevKit-UI-Template > src > ui_glue.h

Go to the documentation of this file

Source Code

#pragma once

#include "desktop_devkit.h"

static constexpr size_t kLongPressDuration = 1500;

enum CanvasIds { canvasLedDisplay = 0, NUM_CANVASES };

void FlushLeds(const daisy::UiCanvasDescriptor &canvasDescriptor) {
  auto *hw = reinterpret_cast<daisy::desktop_devkit::Hardware *>(
      canvasDescriptor.handle_);
  hw->UpdateLeds();
}

void ClearLeds(const daisy::UiCanvasDescriptor &canvasDescriptor) {
  auto *hw = reinterpret_cast<daisy::desktop_devkit::Hardware *>(
      canvasDescriptor.handle_);
  hw->ClearLeds();
}

class PotListener {
public:
  void Init(daisy::desktop_devkit::Hardware *hw) { hw_ = hw; }

  float GetPotValue(uint16_t potId) { return hw_->pot[potId].Value(); }

private:
  daisy::desktop_devkit::Hardware *hw_;
};