Updates to demo to work on ChibiOS and to test orientation.
This commit is contained in:
parent
23bb9e659a
commit
200f7ecf6d
@ -48,6 +48,7 @@
|
||||
#define GDISP_NEED_CLIP TRUE
|
||||
#define GDISP_NEED_CIRCLE TRUE
|
||||
#define GDISP_NEED_TEXT TRUE
|
||||
#define GDISP_NEED_CONTROL TRUE
|
||||
|
||||
/* GDISP fonts to include */
|
||||
#define GDISP_INCLUDE_FONT_UI2 TRUE
|
||||
|
@ -54,10 +54,16 @@ static void createWidgets(void) {
|
||||
|
||||
int main(void) {
|
||||
GEvent* pe;
|
||||
static const orientation_t orients[] = { GDISP_ROTATE_0, GDISP_ROTATE_90, GDISP_ROTATE_180, GDISP_ROTATE_270 };
|
||||
unsigned which;
|
||||
|
||||
// Initialize the display
|
||||
gfxInit();
|
||||
|
||||
// We are currently at GDISP_ROTATE_0
|
||||
which = 0;
|
||||
gdispSetOrientation(orients[which]);
|
||||
|
||||
// Set the widget defaults
|
||||
gwinSetDefaultFont(gdispOpenFont("UI2"));
|
||||
gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
|
||||
@ -81,7 +87,15 @@ int main(void) {
|
||||
case GEVENT_GWIN_BUTTON:
|
||||
if (((GEventGWinButton*)pe)->button == ghButton1) {
|
||||
// Our button has been pressed
|
||||
printf("Button clicked\r\n");
|
||||
if (++which >= sizeof(orients)/sizeof(orients[0]))
|
||||
which = 0;
|
||||
|
||||
// Setting the orientation during run-time is a bit naughty particularly with
|
||||
// GWIN windows. In this case however we know that the button is in the top-left
|
||||
// corner which should translate safely into any orientation.
|
||||
gdispSetOrientation(orients[which]);
|
||||
gdispClear(White);
|
||||
gwinRedrawDisplay(GDISP, FALSE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user