Skip to content

Commit

Permalink
Make LCD line index 1-based for consistency
Browse files Browse the repository at this point in the history
Cleanup some other "TODO" comments in Audio and Displays
  • Loading branch information
tttapa committed Oct 9, 2020
1 parent c2c24f0 commit 1a21d13
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Audio/AudioVU.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#ifdef TEST_COMPILE_ALL_HEADERS_SEPARATELY
// #include "AudioVU.hpp" // TODO
// #include "AudioVU.hpp" // TODO: Mock Audio library
#endif
2 changes: 1 addition & 1 deletion src/Audio/AudioVU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AudioVU : public Interfaces::MCU::IVU {
}

/** @note This function will always return false for an AudioVU. */
bool getOverload() override { return false; } // TODO
bool getOverload() override { return false; }

/**
* @brief Set the gain for the VU meter.
Expand Down
2 changes: 1 addition & 1 deletion src/Audio/AudioVULEDs.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#ifdef TEST_COMPILE_ALL_HEADERS_SEPARATELY
// #include "AudioVULEDs.hpp" // TODO
// #include "AudioVULEDs.hpp" // TODO: Mock Audio library
#endif
2 changes: 1 addition & 1 deletion src/Audio/VolumeControl.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#ifdef TEST_COMPILE_ALL_HEADERS_SEPARATELY
// #include "VolumeControl.hpp" // TODO
// #include "VolumeControl.hpp" // TODO: Mock Audio library
#endif
59 changes: 41 additions & 18 deletions src/Display/MCU/LCDDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class LCDDisplay : public DisplayElement {
LCDDisplay(DisplayInterface &display, MCU::LCD<> &lcd,
const OutputBank &bank, uint8_t track, PixelLocation loc,
uint8_t textSize, uint16_t color)
: DisplayElement(display), lcd(lcd), bank(bank), offset(track - 1),
line(0), x(loc.x), y(loc.y), size(textSize), color(color) {}
: DisplayElement(display), lcd(lcd), bank(&bank), track(track - 1),
line(1), x(loc.x), y(loc.y), size(textSize), color(color) {}

/**
* @brief Constructor.
Expand All @@ -50,36 +50,59 @@ class LCDDisplay : public DisplayElement {
* @param lcd
* A reference to the MCU LCD MIDI input element that listens for
* incoming MIDI display data.
* @param bank
* The bank that determines the active track to be displayed.
* @param track
* The track number to display [1, 8].
* @param line
* The line of the MCU display to display [0, 1].
* @param loc
* The location on the display where to start drawing the text.
* @param textSize
* The font size to use for drawing the text.
* @param color
* The color of the text to draw.
*/
LCDDisplay(DisplayInterface &display, MCU::LCD<> &lcd,
const OutputBank &bank, uint8_t track, uint8_t line,
LCDDisplay(DisplayInterface &display, MCU::LCD<> &lcd, uint8_t track,
PixelLocation loc, uint8_t textSize, uint16_t color)
: DisplayElement(display), lcd(lcd), bank(bank), offset(track - 1),
line(line), x(loc.x), y(loc.y), size(textSize), color(color) {}
: DisplayElement(display), lcd(lcd), track(track - 1),
line(1), x(loc.x), y(loc.y), size(textSize), color(color) {}

/**
* @brief Constructor.
*
* @param display
* A reference to the display that this element will be drawn to.
* @param lcd
* A reference to the MCU LCD MIDI input element that listens for
* incoming MIDI display data.
* @param track
* The track number to display [1, 8].
* @param line
* The line of the MCU display to display [1, 2].
* @param loc
* The location on the display where to start drawing the text.
* @param textSize
* The font size to use for drawing the text.
* @param color
* The color of the text to draw.
*/
LCDDisplay(DisplayInterface &display, MCU::LCD<> &lcd, uint8_t track,
uint8_t line, PixelLocation loc, uint8_t textSize,
uint16_t color)
: DisplayElement(display), lcd(lcd), track(track - 1),
line(line - 1), x(loc.x), y(loc.y), size(textSize), color(color) {}

void draw() override {
// If it's a message across all tracks, don't display anything.
if (!separateTracks())
return;

// Determine the track and line to display
uint8_t offset = bank ? bank->getOffset() + track : track;
if (offset > 7)
ERROR(F("Track number out of bounds (") << offset << ')', 0xBA41);
if (line > 1)
ERROR(F("Line number out of bounds (") << line << ')', 0xBA42);

// Extract the six-character substring for this track.
uint8_t trackoffset = bank.getOffset() + offset;
if (trackoffset > 7) // TODO
trackoffset = 7;
if (line > 1) // TODO
line = 1;
const char *text = lcd.getText() + 7 * trackoffset + 56 * line;
const char *text = lcd.getText() + 7 * offset + 56 * line;
char buffer[7];
strncpy(buffer, text, 6);
buffer[6] = '\0';
Expand Down Expand Up @@ -123,8 +146,8 @@ class LCDDisplay : public DisplayElement {

private:
MCU::LCD<> &lcd;
const OutputBank &bank;
uint8_t offset;
const OutputBank *bank = nullptr;
uint8_t track;
uint8_t line;
int16_t x, y;
uint8_t size;
Expand Down
4 changes: 1 addition & 3 deletions src/Display/MCU/VPotDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ class VPotDisplay : public DisplayElement {

protected:
void drawVPotSegment(uint8_t segment) {
// segment 5 (i.e. the sixth segment) = 0° (i.e. 12 o'clock)
// Segment 5 (i.e. the sixth segment) = 0° (i.e. 12 o'clock, the middle)
float angle = angleSpacing * (segment - 5);

// TODO: use Bresenham directly

uint16_t x_start = x + round((float)innerRadius * sin(angle) / 2);
uint16_t y_start = y - round((float)innerRadius * cos(angle) / 2);

Expand Down

0 comments on commit 1a21d13

Please sign in to comment.