Skip to content

Commit

Permalink
Feat: Implemet btn_color: Toggle slidebars vissible
Browse files Browse the repository at this point in the history
  • Loading branch information
qqq89513 committed Jan 10, 2021
1 parent 9a16921 commit 217e1b8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
6 changes: 3 additions & 3 deletions TouchGFX/equalizer.touchgfx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"ValueMax": 255,
"ValueMin": 0,
"InitValue": 5,
"Name": "sliderB",
"Name": "slider_B",
"X": 64,
"Y": 255,
"Width": 355,
Expand All @@ -276,7 +276,7 @@
"ValueMax": 255,
"ValueMin": 0,
"InitValue": 5,
"Name": "sliderG",
"Name": "slider_G",
"X": 64,
"Y": 238,
"Width": 355,
Expand All @@ -302,7 +302,7 @@
"ValueMax": 255,
"ValueMin": 0,
"InitValue": 255,
"Name": "sliderR",
"Name": "slider_R",
"X": 64,
"Y": 221,
"Width": 355,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class screenViewBase : public touchgfx::View<screenPresenter>
touchgfx::PainterRGB565Bitmap vu_LPainter;
touchgfx::LineProgress vu_R;
touchgfx::PainterRGB565Bitmap vu_RPainter;
touchgfx::Slider sliderB;
touchgfx::Slider sliderG;
touchgfx::Slider sliderR;
touchgfx::Slider slider_B;
touchgfx::Slider slider_G;
touchgfx::Slider slider_R;
touchgfx::Slider slider_volume;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,26 +466,26 @@ screenViewBase::screenViewBase() :
vu_R.setLineEndingStyle(touchgfx::Line::SQUARE_CAP_ENDING);
vu_R.setValue(100);

sliderB.setXY(64, 255);
sliderB.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_SLIDER_INDICATOR_BLUE_ID));
sliderB.setVisible(false);
sliderB.setupHorizontalSlider(3, 7, 0, 36, 306);
sliderB.setValueRange(0, 255);
sliderB.setValue(5);
slider_B.setXY(64, 255);
slider_B.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_SLIDER_INDICATOR_BLUE_ID));
slider_B.setVisible(false);
slider_B.setupHorizontalSlider(3, 7, 0, 36, 306);
slider_B.setValueRange(0, 255);
slider_B.setValue(5);

sliderG.setXY(64, 238);
sliderG.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_SLIDER_INDICATOR_GREEN_ID));
sliderG.setVisible(false);
sliderG.setupHorizontalSlider(3, 7, 0, 36, 306);
sliderG.setValueRange(0, 255);
sliderG.setValue(5);
slider_G.setXY(64, 238);
slider_G.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_SLIDER_INDICATOR_GREEN_ID));
slider_G.setVisible(false);
slider_G.setupHorizontalSlider(3, 7, 0, 36, 306);
slider_G.setValueRange(0, 255);
slider_G.setValue(5);

sliderR.setXY(64, 221);
sliderR.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_SLIDER_INDICATOR_RED_ID));
sliderR.setVisible(false);
sliderR.setupHorizontalSlider(3, 7, 0, 36, 306);
sliderR.setValueRange(0, 255);
sliderR.setValue(255);
slider_R.setXY(64, 221);
slider_R.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_BLUE_DIVIDERS_DIVIDER_SHORT_ID), touchgfx::Bitmap(BITMAP_SLIDER_INDICATOR_RED_ID));
slider_R.setVisible(false);
slider_R.setupHorizontalSlider(3, 7, 0, 36, 306);
slider_R.setValueRange(0, 255);
slider_R.setValue(255);

slider_volume.setXY(144, 232);
slider_volume.setBitmaps(touchgfx::Bitmap(BITMAP_DARK_SLIDER_HORIZONTAL_SMALL_SLIDER_HORIZONTAL_SMALL_ROUND_FILL_ID), touchgfx::Bitmap(BITMAP_DARK_SLIDER_HORIZONTAL_SMALL_SLIDER_HORIZONTAL_SMALL_ROUND_BACK_ID), touchgfx::Bitmap(BITMAP_DARK_ICONS_SOUND_32_ID));
Expand All @@ -499,9 +499,9 @@ screenViewBase::screenViewBase() :
add(graph_t);
add(vu_L);
add(vu_R);
add(sliderB);
add(sliderG);
add(sliderR);
add(slider_B);
add(slider_G);
add(slider_R);
add(slider_volume);
}

Expand Down
2 changes: 2 additions & 0 deletions TouchGFX/gui/include/gui/screen_screen/screenView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class screenView : public screenViewBase
virtual void setupScreen();
virtual void tearDownScreen();
void handleTickEvent();
void btn_color_onclick();
void SliderHandler(const Slider& sli, const ClickEvent& Event);

protected:
int tick_cnt;
Expand Down
20 changes: 19 additions & 1 deletion TouchGFX/gui/src/screen_screen/screenView.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <gui/screen_screen/screenView.hpp>

// User include
#include <../../Middlewares/ST/touchgfx/framework/include/platform/driver/lcd/LCD16bpp.hpp>
#include <stdio.h>
#include <math.h>
#include "stm32746g_discovery_audio.h"
Expand All @@ -17,6 +20,10 @@ screenView::screenView()
tick_cnt = 0;
graph_t.clear();
slider_volume.setValue(volume+1);

slider_R.setValue( LCD16bpp::getRedFromColor( graph_tHistogram1.getColor()) );
slider_G.setValue( LCD16bpp::getGreenFromColor( graph_tHistogram1.getColor()) );
slider_B.setValue( LCD16bpp::getBlueFromColor( graph_tHistogram1.getColor()) );
}

void screenView::setupScreen()
Expand All @@ -29,6 +36,17 @@ void screenView::tearDownScreen()
screenViewBase::tearDownScreen();
}

// This toggles the visibiilty of slider_volume and slider_RGB
void screenView::btn_color_onclick(){
slider_volume.setVisible( !slider_volume.isVisible() ); slider_volume.invalidate();
slider_R.setVisible( !slider_R.isVisible() ); slider_R.invalidate();
slider_G.setVisible( !slider_G.isVisible() ); slider_G.invalidate();
slider_B.setVisible( !slider_B.isVisible() ); slider_B.invalidate();
printf("btn clicked \r\n");
}



void screenView::handleTickEvent(){
static uint32_t tk_graph = 0; // ticks to update graph_t
static uint32_t tk_vol_ctrl = 0; // ticks to update volume from slider_volume
Expand All @@ -52,7 +70,7 @@ void screenView::handleTickEvent(){

// Update volume if USB connected
int usb_conn_state = hUsbDeviceFS.dev_state;
printf("[Debug] usb_conn_state:%d\r\n", usb_conn_state);
// printf("[Debug] usb_conn_state:%d\r\n", usb_conn_state);
switch(usb_conn_state){
case USBD_STATE_DEFAULT:
break;
Expand Down

0 comments on commit 217e1b8

Please sign in to comment.