forked from maaadc/singsang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes: * volume; bigger range, smaller steps, compact widget (displ…
…ay is button at same time) ! alternatively do not use boxes but shadows in a darker color with exact same dimension as bar itself * enhanced GUI; add playback position selction on progress bar ! may be later also add fast forward/reverse (seek), e.g. using more buttons or IMU ! may be for progress bar use M5.Lcd.progressBar instead of M5.Lcd.drawRoundRect and M5.Lcd.fillRoundRect * option to enable force mono playback during build
- Loading branch information
Showing
7 changed files
with
112 additions
and
17 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#ifndef SINGSANG_VOLUME_WIDGET_HPP | ||
#define SINGSANG_VOLUME_WIDGET_HPP | ||
|
||
#include "base_widget.hpp" | ||
|
||
#define sizeYMax 4 // height of bar, multiple of 2 | ||
#define volumeIdxMax 10 // number of bars, <= 20 = (height=80)/(sizeYMax=4) | ||
|
||
namespace singsang | ||
{ | ||
class CVolumeWidget : public CBaseWidget | ||
{ | ||
public: | ||
CVolumeWidget() : CBaseWidget(10, 0, 40, 80) {} | ||
|
||
void update(const int f_newAudioVolume) | ||
{ | ||
if (f_newAudioVolume != m_audioVolume) | ||
{ | ||
m_audioVolume = f_newAudioVolume; | ||
draw(true); | ||
} | ||
} | ||
|
||
int getButton(TouchPoint_t f_point) | ||
{ | ||
/* if (!isTouched(f_point)) | ||
{ | ||
return ...; | ||
}*/ | ||
return int(float(f_point.y - m_positionY) / m_sizeY * 2); | ||
} | ||
|
||
void draw(const bool updateOnly) | ||
{ | ||
const uint16_t color = M5.Lcd.color565(100, 100, 100); | ||
|
||
for (int volumeIdx = 0; volumeIdx < volumeIdxMax; volumeIdx++) | ||
{ | ||
const int pointX = m_positionX; | ||
const int pointY = m_positionY + m_sizeY - (m_sizeY/volumeIdxMax) * (volumeIdx + 1); | ||
const int sizeX = (m_sizeX/volumeIdxMax) * (volumeIdx + 1);// + 12; | ||
const int sizeY = sizeYMax; | ||
|
||
if (!updateOnly) | ||
{ | ||
M5.Lcd.fillRoundRect(pointX, pointY, sizeX, sizeY, sizeYMax/2, color); | ||
} | ||
|
||
const int barIsActive = (m_audioVolume > 2 * volumeIdx); | ||
const int pickColor = barIsActive ? color : TFT_BLACK; | ||
M5.Lcd.fillRoundRect(pointX+1, pointY+1, sizeX-2, sizeY-2, (sizeYMax/2)-1, pickColor); | ||
} | ||
} | ||
|
||
private: | ||
int m_audioVolume; | ||
}; | ||
|
||
} // namespace singsang | ||
|
||
#endif // SINGSANG_VOLUME_WIDGET_HPP |