|
H753_CPP_SPI_BT817_EVE_02 1.0
STM32H753 draws its own touch screens on a Bridgetek BT817 (ME817EV + DP-0701-01A) over SPI with the STM32_Bridgetek_EVE_API library: a two-page widget tour
|
BT817 "widget tour" screen drawn in code (see widgetTour.h). More...
Go to the source code of this file.
Macros | |
| #define | SLIDER_RANGE 100U |
| #define | FRAME_DELAY_MS 15U |
| #define | TRACKER_FULL 65536UL |
| #define | TYPED_MAX 10U |
| #define | KEYPAD_KEYS "1234567890" |
Touch tags | |
Values written with EVE_TAG() and read back from REG_TOUCH_TAG / REG_TRACKER. | |
| #define | TAG_NONE 0U |
| #define | TAG_BUTTON 1U |
| #define | TAG_TOGGLE 2U |
| #define | TAG_SLIDER 3U |
| #define | TAG_NEXT 4U |
| #define | TAG_BACK 5U |
| #define | TAG_CLEAR 6U |
| #define | TAG_DIAL 7U |
| #define | TAG_DONE 8U |
Layout (pixels, 800 x 480 panel) | |
| #define | HEADER_HEIGHT 64 |
| #define | BUTTON_X 40 |
| #define | BUTTON_Y 100 |
| #define | BUTTON_W 200 |
| #define | BUTTON_H 70 |
| #define | COUNT_X 270 |
| #define | TOGGLE_X 520 |
| #define | TOGGLE_Y 122 |
| #define | TOGGLE_W 100 |
| #define | LED_X 710 |
| #define | LED_Y 135 |
| #define | LED_RADIUS 22 |
| #define | GAUGE_X 200 |
| #define | GAUGE_Y 330 |
| #define | GAUGE_RADIUS 115 |
| #define | SLIDER_X 420 |
| #define | SLIDER_Y 280 |
| #define | SLIDER_W 280 |
| #define | SLIDER_H 24 |
| #define | PROGRESS_Y 380 |
| #define | VALUE_X 730 |
| #define | NAV_W 150 |
| #define | NAV_H 44 |
| #define | NAV_X (EVE_DISP_WIDTH - NAV_W - 14) |
| #define | NAV_Y 10 |
| #define | TYPED_Y 110 |
| #define | CLEAR_X 600 |
| #define | CLEAR_W 150 |
| #define | KEYS_X 40 |
| #define | KEYS_Y 160 |
| #define | KEYS_W 720 |
| #define | KEYS_H 70 |
| #define | CLOCK_X 170 |
| #define | DIAL_X 470 |
| #define | ROUND_Y 355 |
| #define | ROUND_RADIUS 95 |
| #define | DIAL_TEXT_X 600 |
| #define | POPUP_W 500 |
| #define | POPUP_H 260 |
| #define | POPUP_X ((EVE_DISP_WIDTH - POPUP_W) / 2) |
| #define | POPUP_Y ((EVE_DISP_HEIGHT - POPUP_H) / 2) |
| #define | POPUP_RADIUS 16 |
Fonts (BT817 ROM fonts) | |
| #define | FONT_TITLE 30 |
| #define | FONT_WIDGET 29 |
| #define | FONT_SMALL 27 |
Enumerations | |
| enum | WidgetPage { PAGE_WIDGETS = 0 , PAGE_MORE } |
| Screen pages. More... | |
Functions | |
| static void | awaitCoPro (const char *step) |
| Waits for the co-processor to finish the current command list. | |
| static void | calibrateTouch (void) |
| Runs the BT817 touch calibration (tap the three dots). | |
| static void | registerTrackers (void) |
| Registers the slider and the dial with the touch tracker (CMD_TRACK). | |
| static void | readTouch (void) |
| Reads the touch registers and updates the screen state. | |
| static void | drawHeader (const char *title) |
| Draws the title bar across the top of the screen, with "Next >" on page 1, or "< Back" and "Done" on page 2. | |
| static void | drawButton (void) |
| Draws the "Press me" button and the press count. | |
| static void | drawToggle (void) |
| Draws the toggle and the LED it controls. | |
| static void | drawSliderGroup (void) |
| Draws the gauge, the slider with its value and the progress bar. | |
| static void | drawPageMore (void) |
| Draws page 2: typed digits with a Clear button, the keypad, an analog clock (time since reset) and a dial with its angle. | |
| static void | drawPopup (void) |
| Draws the final "Completed" pop-up. | |
| static void | drawScreen (void) |
| Builds and shows one complete frame of the widget tour. | |
| void | widgetTourInit (void) |
| Starts the BT817 and prepares the widget tour. | |
| void | widgetTourRun (void) |
| Runs the widget tour forever: read touch, redraw, short pause. | |
Variables | |
| static uint32_t | pressCount = 0U |
| Number of completed "Press me" presses. | |
| static bool | toggleOn = false |
| Toggle state; true = ON (LED lit). | |
| static uint16_t | sliderValue = 42U |
| Slider value, 0..SLIDER_RANGE; also shown by the gauge and progress bar. | |
| static uint8_t | previousTag = TAG_NONE |
| Tag touched in the previous frame, used to detect a new press. | |
| static WidgetPage | currentPage = PAGE_WIDGETS |
| Page currently shown. | |
| static char | typedDigits [TYPED_MAX+1U] = "" |
| Digits typed on the keypad (page 2), NUL-terminated. | |
| static uint8_t | typedLength = 0U |
| Number of digits in typedDigits. | |
| static uint16_t | dialValue = 0U |
| Dial position, 0..65535 (one full turn). | |
| static bool | popupShown = false |
| true once Done was tapped: the "Completed" pop-up stays until reset. | |
BT817 "widget tour" screen drawn in code (see widgetTour.h).
Definition in file widgetTour.c.
| #define BUTTON_H 70 |
| #define BUTTON_W 200 |
| #define BUTTON_X 40 |
| #define BUTTON_Y 100 |
| #define CLEAR_W 150 |
| #define CLEAR_X 600 |
| #define CLOCK_X 170 |
| #define COUNT_X 270 |
| #define DIAL_TEXT_X 600 |
| #define DIAL_X 470 |
Dial centre x
Definition at line 63 of file widgetTour.c.
Referenced by drawPageMore(), and registerTrackers().
| #define FONT_SMALL 27 |
Small labels and hints
Definition at line 78 of file widgetTour.c.
Referenced by drawPopup(), drawScreen(), and drawSliderGroup().
| #define FONT_TITLE 30 |
Title bar
Definition at line 76 of file widgetTour.c.
Referenced by drawHeader(), drawPageMore(), and drawPopup().
| #define FONT_WIDGET 29 |
Buttons and labels
Definition at line 77 of file widgetTour.c.
Referenced by calibrateTouch(), drawButton(), drawHeader(), drawPageMore(), drawPopup(), drawSliderGroup(), and drawToggle().
| #define FRAME_DELAY_MS 15U |
Pause between screen updates (about 60 frames/s)
Definition at line 82 of file widgetTour.c.
Referenced by widgetTourRun().
| #define GAUGE_RADIUS 115 |
| #define GAUGE_X 200 |
| #define GAUGE_Y 330 |
| #define HEADER_HEIGHT 64 |
| #define KEYPAD_KEYS "1234567890" |
Keys shown on the keypad (one tag each)
Definition at line 85 of file widgetTour.c.
Referenced by drawPageMore().
| #define KEYS_H 70 |
| #define KEYS_W 720 |
| #define KEYS_X 40 |
| #define KEYS_Y 160 |
| #define LED_RADIUS 22 |
| #define LED_X 710 |
| #define LED_Y 135 |
| #define NAV_H 44 |
Next/Back button height
Definition at line 52 of file widgetTour.c.
Referenced by drawHeader(), and drawPageMore().
| #define NAV_W 150 |
| #define NAV_X (EVE_DISP_WIDTH - NAV_W - 14) |
Next button left edge (page 1)
Definition at line 53 of file widgetTour.c.
Referenced by drawHeader().
| #define NAV_Y 10 |
| #define POPUP_H 260 |
| #define POPUP_RADIUS 16 |
| #define POPUP_W 500 |
| #define POPUP_X ((EVE_DISP_WIDTH - POPUP_W) / 2) |
| #define POPUP_Y ((EVE_DISP_HEIGHT - POPUP_H) / 2) |
| #define PROGRESS_Y 380 |
Progress bar top edge (same x and size as the slider)
Definition at line 49 of file widgetTour.c.
Referenced by drawSliderGroup().
| #define ROUND_RADIUS 95 |
| #define ROUND_Y 355 |
Clock and dial centre y
Definition at line 64 of file widgetTour.c.
Referenced by drawPageMore(), and registerTrackers().
| #define SLIDER_H 24 |
Slider height
Definition at line 48 of file widgetTour.c.
Referenced by drawSliderGroup(), and registerTrackers().
| #define SLIDER_RANGE 100U |
Slider, gauge and progress range (0..100)
Definition at line 81 of file widgetTour.c.
Referenced by drawSliderGroup(), and readTouch().
| #define SLIDER_W 280 |
Slider width
Definition at line 47 of file widgetTour.c.
Referenced by drawSliderGroup(), and registerTrackers().
| #define SLIDER_X 420 |
Slider left edge
Definition at line 45 of file widgetTour.c.
Referenced by drawSliderGroup(), and registerTrackers().
| #define SLIDER_Y 280 |
Slider top edge
Definition at line 46 of file widgetTour.c.
Referenced by drawSliderGroup(), and registerTrackers().
| #define TAG_BACK 5U |
"< Back" button (page 2 to page 1)
Definition at line 21 of file widgetTour.c.
Referenced by drawHeader(), and readTouch().
| #define TAG_BUTTON 1U |
"Press me" button
Definition at line 17 of file widgetTour.c.
Referenced by drawButton(), and readTouch().
| #define TAG_CLEAR 6U |
"Clear" button for the typed digits
Definition at line 22 of file widgetTour.c.
Referenced by drawPageMore(), and readTouch().
| #define TAG_DIAL 7U |
Dial (rotary tracked)
Definition at line 23 of file widgetTour.c.
Referenced by drawPageMore(), readTouch(), and registerTrackers().
| #define TAG_DONE 8U |
"Done" button (page 2), opens the pop-up
Definition at line 24 of file widgetTour.c.
Referenced by drawHeader(), and readTouch().
| #define TAG_NEXT 4U |
"Next >" button (page 1 to page 2)
Definition at line 20 of file widgetTour.c.
Referenced by drawHeader(), and readTouch().
| #define TAG_NONE 0U |
| #define TAG_SLIDER 3U |
Slider (tracked)
Definition at line 19 of file widgetTour.c.
Referenced by drawSliderGroup(), readTouch(), and registerTrackers().
| #define TAG_TOGGLE 2U |
On/off toggle
Definition at line 18 of file widgetTour.c.
Referenced by drawToggle(), and readTouch().
| #define TOGGLE_W 100 |
| #define TOGGLE_X 520 |
| #define TOGGLE_Y 122 |
| #define TRACKER_FULL 65536UL |
REG_TRACKER value range (linear and rotary tracks)
Definition at line 83 of file widgetTour.c.
Referenced by drawPageMore(), and readTouch().
| #define TYPED_MAX 10U |
Maximum number of typed digits
Definition at line 84 of file widgetTour.c.
Referenced by drawPageMore(), and readTouch().
| #define TYPED_Y 110 |
Typed-digits line centre y (page 2)
Definition at line 55 of file widgetTour.c.
Referenced by drawPageMore().
| #define VALUE_X 730 |
Percentage text left edge
Definition at line 50 of file widgetTour.c.
Referenced by drawSliderGroup().
| enum WidgetPage |
Screen pages.
| Enumerator | |
|---|---|
| PAGE_WIDGETS | Page 1: button, toggle, slider, gauge, progress |
| PAGE_MORE | Page 2: keypad, clock, dial |
Definition at line 88 of file widgetTour.c.
|
static |
Waits for the co-processor to finish the current command list.
| step | Short description of what was sent, printed if it fails. |
A co-processor exception means the BT817 could not run the list, so the program cannot continue: the reason is printed and Error_Handler() is called (coding rules 2 and 3).
Definition at line 121 of file widgetTour.c.
Referenced by calibrateTouch(), drawScreen(), and registerTrackers().
|
static |
Runs the BT817 touch calibration (tap the three dots).
The transform is not stored yet, so it runs after every reset.
Definition at line 135 of file widgetTour.c.
References awaitCoPro(), and FONT_WIDGET.
Referenced by widgetTourInit().
|
static |
Draws the "Press me" button and the press count.
Definition at line 280 of file widgetTour.c.
References BUTTON_H, BUTTON_W, BUTTON_X, BUTTON_Y, COUNT_X, FONT_WIDGET, pressCount, previousTag, and TAG_BUTTON.
Referenced by drawScreen().
|
static |
Draws the title bar across the top of the screen, with "Next >" on page 1, or "< Back" and "Done" on page 2.
| title | Text shown in the title bar. |
Definition at line 239 of file widgetTour.c.
References currentPage, FONT_TITLE, FONT_WIDGET, HEADER_HEIGHT, NAV_H, NAV_W, NAV_X, NAV_Y, PAGE_WIDGETS, previousTag, TAG_BACK, TAG_DONE, and TAG_NEXT.
Referenced by drawScreen().
|
static |
Draws page 2: typed digits with a Clear button, the keypad, an analog clock (time since reset) and a dial with its angle.
Definition at line 350 of file widgetTour.c.
References CLEAR_W, CLEAR_X, CLOCK_X, DIAL_TEXT_X, DIAL_X, dialValue, FONT_TITLE, FONT_WIDGET, KEYPAD_KEYS, KEYS_H, KEYS_W, KEYS_X, KEYS_Y, NAV_H, previousTag, ROUND_RADIUS, ROUND_Y, TAG_CLEAR, TAG_DIAL, TRACKER_FULL, TYPED_MAX, TYPED_Y, and typedDigits.
Referenced by drawScreen().
|
static |
Draws the final "Completed" pop-up.
Drawn on its own (no page behind it) on the plain background; the box has rounded corners (a rectangle drawn with a wide line width). It has no buttons: it stays until reset.
Definition at line 396 of file widgetTour.c.
References FONT_SMALL, FONT_TITLE, FONT_WIDGET, POPUP_H, POPUP_RADIUS, POPUP_W, POPUP_X, and POPUP_Y.
Referenced by drawScreen().
|
static |
Builds and shows one complete frame of the widget tour.
Definition at line 422 of file widgetTour.c.
References awaitCoPro(), currentPage, drawButton(), drawHeader(), drawPageMore(), drawPopup(), drawSliderGroup(), drawToggle(), FONT_SMALL, PAGE_WIDGETS, and popupShown.
Referenced by widgetTourRun().
|
static |
Draws the gauge, the slider with its value and the progress bar.
Definition at line 326 of file widgetTour.c.
References FONT_SMALL, FONT_WIDGET, GAUGE_RADIUS, GAUGE_X, GAUGE_Y, PROGRESS_Y, SLIDER_H, SLIDER_RANGE, SLIDER_W, SLIDER_X, SLIDER_Y, sliderValue, TAG_SLIDER, and VALUE_X.
Referenced by drawScreen().
|
static |
Draws the toggle and the LED it controls.
Definition at line 298 of file widgetTour.c.
References FONT_WIDGET, LED_RADIUS, LED_X, LED_Y, TAG_TOGGLE, TOGGLE_W, TOGGLE_X, TOGGLE_Y, and toggleOn.
Referenced by drawScreen().
|
static |
Reads the touch registers and updates the screen state.
A press of a button, the toggle or a key counts once, on the frame where the finger first touches it (nothing touched the frame before). The slider and the dial follow the finger while touched. Once Done was tapped, nothing reacts.
Definition at line 173 of file widgetTour.c.
References currentPage, dialValue, PAGE_MORE, PAGE_WIDGETS, popupShown, pressCount, previousTag, SLIDER_RANGE, sliderValue, TAG_BACK, TAG_BUTTON, TAG_CLEAR, TAG_DIAL, TAG_DONE, TAG_NEXT, TAG_NONE, TAG_SLIDER, TAG_TOGGLE, toggleOn, TRACKER_FULL, TYPED_MAX, typedDigits, and typedLength.
Referenced by widgetTourRun().
|
static |
Registers the slider and the dial with the touch tracker (CMD_TRACK).
While a tracked widget is touched, REG_TRACKER reports its tag in the low 16 bits and the position (0..65535) in the high 16 bits: along the slider, or the angle around the dial.
Definition at line 156 of file widgetTour.c.
References awaitCoPro(), DIAL_X, ROUND_Y, SLIDER_H, SLIDER_W, SLIDER_X, SLIDER_Y, TAG_DIAL, and TAG_SLIDER.
Referenced by widgetTourInit().
| void widgetTourInit | ( | void | ) |
Starts the BT817 and prepares the widget tour.
Initialises the EVE library (BT817 reset, clocks, panel timing), runs the touch calibration and registers the slider and dial trackers. Stops in Error_Handler() with a message if the BT817 is not found.
Definition at line 465 of file widgetTour.c.
References calibrateTouch(), and registerTrackers().
Referenced by main().
| void widgetTourRun | ( | void | ) |
Runs the widget tour forever: read touch, redraw, short pause.
Does not return.
Definition at line 482 of file widgetTour.c.
References drawScreen(), FRAME_DELAY_MS, and readTouch().
Referenced by main().
|
static |
Page currently shown.
Definition at line 103 of file widgetTour.c.
Referenced by drawHeader(), drawScreen(), and readTouch().
|
static |
Dial position, 0..65535 (one full turn).
Definition at line 109 of file widgetTour.c.
Referenced by drawPageMore(), and readTouch().
|
static |
true once Done was tapped: the "Completed" pop-up stays until reset.
Definition at line 111 of file widgetTour.c.
Referenced by drawScreen(), and readTouch().
|
static |
Number of completed "Press me" presses.
Definition at line 95 of file widgetTour.c.
Referenced by drawButton(), and readTouch().
|
static |
Tag touched in the previous frame, used to detect a new press.
Definition at line 101 of file widgetTour.c.
Referenced by drawButton(), drawHeader(), drawPageMore(), and readTouch().
|
static |
Slider value, 0..SLIDER_RANGE; also shown by the gauge and progress bar.
Definition at line 99 of file widgetTour.c.
Referenced by drawSliderGroup(), and readTouch().
|
static |
Toggle state; true = ON (LED lit).
Definition at line 97 of file widgetTour.c.
Referenced by drawToggle(), and readTouch().
|
static |
Digits typed on the keypad (page 2), NUL-terminated.
Definition at line 105 of file widgetTour.c.
Referenced by drawPageMore(), and readTouch().
|
static |
Number of digits in typedDigits.
Definition at line 107 of file widgetTour.c.
Referenced by readTouch().