Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
VPotDisplay.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <AH/STL/cmath>
4#include <AH/STL/utility> // std::forward
8
10
11namespace MCU {
12
17template <class VPot_t = Interfaces::MCU::IVPot &>
19
20 public:
26
27 void draw() override {
29 if (vpot.getCenterLed())
31 else
33 uint8_t startOn = vpot.getStartOn();
34 uint8_t startOff = vpot.getStartOff();
37 vpot.clearDirty();
38 }
39
40 bool getDirty() const override { return vpot.getDirty(); }
41
42 void setAngleSpacing(float spacing) { this->angleSpacing = spacing; }
43 float getAngleSpacing() const { return this->angleSpacing; }
44
45 private:
47
50
51 float angleSpacing = 0.4887; // 28°
52
53 protected:
55 // Segment 5 (i.e. the sixth segment) = 0° (i.e. 12 o'clock, the middle)
56 float angle = angleSpacing * (segment - 5);
57
58 uint16_t x_start = x + std::round((float)innerRadius * sin(angle) / 2);
59 uint16_t y_start = y - std::round((float)innerRadius * cos(angle) / 2);
60
61 uint16_t x_end = x + std::round((float)innerRadius * sin(angle));
62 uint16_t y_end = y - std::round((float)innerRadius * cos(angle));
63
65 }
66};
67
68} // namespace MCU
69
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
An interface for elements that draw to a display.
DisplayInterface & display
An interface for displays.
virtual void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a disk (filled circle).
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)=0
Draw a line between two points.
virtual void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a circle.
Displays the position of a MCU V-Pot.
bool getDirty() const override
Check if this DisplayElement has to be re-drawn.
VPotDisplay(DisplayInterface &display, VPot_t &&vpot, PixelLocation loc, uint16_t radius, uint16_t innerRadius, uint16_t color)
void setAngleSpacing(float spacing)
float getAngleSpacing() const
void drawVPotSegment(uint8_t segment)
void draw() override
Draw this DisplayElement to the display buffer.
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32
A simple struct representing a pixel with integer coordinates.
Definition Def.hpp:62