ugfx_release_2.6
Tectu 2012-06-07 14:37:29 +02:00
parent 8cafee2c32
commit 9ccab0c207
4 changed files with 55 additions and 6 deletions

11
glcd.c
View File

@ -11,7 +11,7 @@ static __inline void lcdWriteIndex(uint16_t index) {
Clr_RS;
Set_RD;
LCD_DATA_PORT->ODR = index;
palWritePort(LCD_DATA_PORT, index);
Clr_WR;
Set_WR;
@ -20,7 +20,7 @@ static __inline void lcdWriteIndex(uint16_t index) {
static __inline void lcdWriteData(uint16_t data) {
Set_RS;
LCD_DATA_PORT->ODR = data;
palWritePort(LCD_DATA_PORT, data);
Clr_WR;
Set_WR;
@ -36,9 +36,10 @@ static __inline uint16_t lcdReadData(void) {
// change pin mode to digital input
LCD_DATA_PORT->CRH = 0x44444444;
LCD_DATA_PORT->CRL = 0x44444444;
value = LCD_DATA_PORT->IDR; // dummy
value = LCD_DATA_PORT->IDR;
value = palReadPort(LCD_DATA_PORT); // dummy
value = palReadPort(LCD_DATA_PORT);
// change pin mode back to digital output
LCD_DATA_PORT->CRH = 0x33333333;

40
gui.c 100644
View File

@ -0,0 +1,40 @@
#include "ch.h"
#include "hal.h"
#include "gui.h"
#include "glcd.h"
#include "touchpad.h"
volatile uint16_t x, y;
static WORKING_AREA(waTouchPadThread, 512);
static msg_t TouchPadThread(void *arg) {
(void)arg;
unsigned char buffer[10];
chRegSetThreadName("GUI");
while(TRUE) {
if(tpIRQ()) {
x = tpReadX();
y = tpReadY();
lcdFillArea(10, 10, 80, 80, Black);
sprintf(buffer, "X: %d", x);
lcdDrawString(10, 10, buffer, White, Black);
sprintf(buffer, "Y: %d", y);
lcdDrawString(10, 25, buffer, White, Black);
}
chThdSleepMilliseconds(10);
}
}
void guiInit(void) {
chThdCreateStatic(TouchPadThread, sizeof(TouchPadThread), HIGHPRIO, TouchPadThread, NULL);
}
void guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsigned char *str, uint16_t fontColor, uint16_t buttonColor, uint8_t *state) {
lcdDrawRectString(x0, y0, x1, y1, str, fontColor, buttonColor);
}

7
gui.h 100644
View File

@ -0,0 +1,7 @@
#ifndef GUI_H
#define GUI_H
void guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsigned char *str, uint16_t fontColor, uint16_t buttonColor, uint8_t *state);
#endif

3
lcd.mk
View File

@ -2,6 +2,7 @@
LCDSRC = ${CHIBIOS}/ext/lcd/glcd.c \
${CHIBIOS}/ext/fonts.c \
${CHIBIOS}/ext/touchpad.c \
${CHIBIOS}/ext/graph.c
${CHIBIOS}/ext/graph.c \
${CHIBIOS}/ext/gui.c
LCDINC = ${CHIBIOS}/ext/lcd