0 Members and 2 Guests are viewing this topic.
I currently need more development workforce than testing. How about implementing the Touchpad keypad protocol from Goplat's spec?
#include <os.h>// returns 0 on failure, 1 on success// addresses are for 2.0.1 non-CAS#define touchpad_read ((int (*)(unsigned char start, unsigned char end, void *buf))0x10174A48)#define touchpad_write ((int (*)(unsigned char start, unsigned char end, const void *buf))0x10174B38)static inline void clearScreen() { memset(SCREEN_BASE_ADDRESS, 0xFF, SCREEN_BYTES_SIZE);}static inline void setPixel(int x, int y, int color) { unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS + ((x >> 1) + (y << 7) + (y << 5))); *p = (x & 1) ? ((*p & 0xF0) | color) : ((*p & 0x0F) | (color << 4));}int main() { int cpsr; struct { unsigned char width[2]; unsigned char height[2]; } size; int width, height; // be sure to turn interrupts off when accessing a different touchpad page // TI's interrupt handler expects it to be set to page 4 asm ("mrs %0, cpsr" : "=r" (cpsr)); asm ("msr cpsr_c, %0" : : "r" (cpsr | 0xC0)); touchpad_write(0xFF, 0xFF, "\x10"); touchpad_read(0x04, 0x07, &size); touchpad_write(0xFF, 0xFF, "\x04"); asm ("msr cpsr_c, %0" : : "r" (cpsr)); width = size.width[0] << 8 | size.width[1]; height = size.height[0] << 8 | size.height[1]; clearScreen(); while (*(int *)0x900E001C & 0x80) { // loop until ESC pressed struct { unsigned char contact; unsigned char proximity; unsigned char x[2]; unsigned char y[2]; } cur; int x, y; touchpad_read(0x00, 0x05, &cur); if (cur.contact) { x = cur.x[0] << 8 | cur.x[1]; y = cur.y[0] << 8 | cur.y[1]; x = x * 319 / width; y = 239 - (y * 239 / height); if (x >= 0 && y >= 0 && x < 320 && y < 240) setPixel(x, y, 0); } } return 0;}
I suppose Ndless should both make available the current isKeyPressed() function to detect left/right/... and a new touchpad-specific scanning function. Touchpad-based games may be fun to play!
Quote from: ExtendeD on February 25, 2011, 04:32:00 pmI currently need more development workforce than testing. How about implementing the Touchpad keypad protocol from Goplat's spec? Did you want to implement the I2C code? It might be easier to just make syscalls for the OS functions for read/write. Quick example of usage: (for OS 2.0.1 non-CAS)