Skip to content

Commit fe63fff

Browse files
committed
Feat: Change color of graph with sliders on touch screen
1 parent 217e1b8 commit fe63fff

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

TouchGFX/gui/src/screen_screen/screenView.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern USBD_HandleTypeDef hUsbDeviceFS; // forwarded from usb_device.c
1414
extern SAI_HandleTypeDef haudio_out_sai; // forwarded from stm32746g_discovery.c
1515

1616
static int volume = 0; // from slider_volume to to BSP_Out_SetVolume. 0~100
17+
static colortype color_graph_t; // Store the previous color of graph_tHistogram1
1718

1819
screenView::screenView()
1920
{
@@ -24,6 +25,7 @@ screenView::screenView()
2425
slider_R.setValue( LCD16bpp::getRedFromColor( graph_tHistogram1.getColor()) );
2526
slider_G.setValue( LCD16bpp::getGreenFromColor( graph_tHistogram1.getColor()) );
2627
slider_B.setValue( LCD16bpp::getBlueFromColor( graph_tHistogram1.getColor()) );
28+
color_graph_t.color = graph_tHistogram1.getColor().color;
2729
}
2830

2931
void screenView::setupScreen()
@@ -51,6 +53,7 @@ void screenView::handleTickEvent(){
5153
static uint32_t tk_graph = 0; // ticks to update graph_t
5254
static uint32_t tk_vol_ctrl = 0; // ticks to update volume from slider_volume
5355
static uint32_t tk_vu = 0; // ticks to update vu_L and vu_R
56+
static uint32_t tk_color = 0; // ticks to update color to graph_tHistogram1
5457

5558
if(uwTick - tk_graph > 50){
5659
tk_graph = uwTick;
@@ -122,4 +125,15 @@ void screenView::handleTickEvent(){
122125
vu_R.invalidate();
123126
}
124127

128+
if(uwTick - tk_color > 50){
129+
tk_color = uwTick;
130+
color_graph_t.color = touchgfx::Color::getColorFrom24BitRGB(
131+
slider_R.getValue(),
132+
slider_G.getValue(),
133+
slider_B.getValue() ).color;
134+
135+
// Only update color if color changed for graphics performance
136+
if(graph_tHistogram1.getColor().color != color_graph_t.color)
137+
graph_tHistogram1.setColor(color_graph_t);
138+
}
125139
}

0 commit comments

Comments
 (0)