aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorTectu <joel@unormal.org>2012-06-26 15:14:34 +0200
committerTectu <joel@unormal.org>2012-06-26 15:14:34 +0200
commit4fee89285eea5fa9af69ce1aed250ffc459f1b69 (patch)
tree355472440400430d295bd15396554cb1d93ff29b /demos
parent9782c3edbcaf45f4ce3b82e9155f4d9cca17ed6e (diff)
downloaduGFX-4fee89285eea5fa9af69ce1aed250ffc459f1b69.tar.gz
uGFX-4fee89285eea5fa9af69ce1aed250ffc459f1b69.tar.bz2
uGFX-4fee89285eea5fa9af69ce1aed250ffc459f1b69.zip
added GUI usage demo
Diffstat (limited to 'demos')
-rwxr-xr-xdemos/gui/main.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/demos/gui/main.c b/demos/gui/main.c
new file mode 100755
index 00000000..d37c993c
--- /dev/null
+++ b/demos/gui/main.c
@@ -0,0 +1,74 @@
+#include "ch.h"
+#include "hal.h"
+#include "gui.h"
+#include "glcd.h"
+#include "touchpad.h"
+
+__inline void lld_lcdWriteGPIO(uint16_t data) {
+ palWritePort(LCD_DATA_PORT, data);
+}
+
+__inline uint16_t lld_lcdReadGPIO(void) {
+ uint16_t value;
+
+ // change pin mode to digital input
+ LCD_DATA_PORT->CRH = 0x44444444;
+ LCD_DATA_PORT->CRL = 0x44444444;
+
+ value = palReadPort(LCD_DATA_PORT); // dummy
+ value = palReadPort(LCD_DATA_PORT);
+
+ // change pin mode back to digital output
+ LCD_DATA_PORT->CRH = 0x33333333;
+ LCD_DATA_PORT->CRL = 0x33333333;
+
+ return value;
+}
+
+// GLCD driver object
+static GLCDDriver GLCDD1;
+
+int main(void) {
+ uint8_t setActive, setState, clearActive, clearState;
+
+ halInit();
+ chSysInit();
+
+ // Initializes the LCD
+ lcdInit(&GLCDD1);
+
+ // Initializes the touchpad
+ tpInit(&SPID1);
+
+ // clear the entire LCD screen
+ lcdClear(Black);
+
+ // Initializes the GUI thread
+ // 10ms interval
+ // HIGHPRIO-2 thread priority level
+ guiInit(10, HIGHPRIO-2);
+
+ // set the following buttons to active
+ // buttons wouldn't have any effect if you set these variables to 'inactive'
+ setActive = active;
+ clearActive = active;
+
+ // draw a button to set, and one to clear the LED
+ guiDrawButton(10, 10, 60, 60, "Set", Black, Yellow, &setActive, &setState);
+ guiDrawButton(70, 10, 120, 60, "Clear", Black, Red, &clearActive, &clearState);
+
+ while (TRUE) {
+
+ // check if button 'set' is pressed
+ if(setState)
+ palSetPad(GPIOD, GPIOD_LED3);
+
+ // check if button 'clear' is pressed
+ if(clearState)
+ palClearPad(GPIOD, GPIOD_LED3);
+
+ chThdSleepMilliseconds(200);
+ }
+
+ return 0;
+}