| View previous topic :: View next topic |
| Author |
Message |
bfr Junior

Joined: 28 Dec 2007 Posts: 10
|
Posted: Mon Jun 16, 2008 6:16 pm Post subject: String Input Routine |
|
|
Would any of you happen to have a TIGCC/C string input routine that lets you set the X and Y coordinates of the prompt (kind of like MoveTo(x,y) and then using getsn()) and works when interrupts 1, 5, and 6 are redirected? _________________ bfr's website - http://bfr.tifreakware.net |
|
| Back to top |
|
 |
pinhead Member

Joined: 03 Jun 2006 Posts: 31 Location: Diepoldsau, Switzerland
|
Posted: Wed Jun 18, 2008 1:07 pm Post subject: |
|
|
No, not really, but I adapted the TIGCC Docu example to fit most of your needs. However, my code requires AUTO_INT_1, but are you sure you can't enable this interrupt for a short time? Otherwise you would have to write a getKey replacement working without AUTO_INT_1.
| c: | // ----------------------------------------------------------------- // // checks for keypresses and turns the calc of if APD expired // originally taken from TICT sources // ----------------------------------------------------------------- // short getKey(void) { void *kbq = kbd_queue(); unsigned short key; // restart the APD timer now OSTimerRestart(APD_TIMER); // get an input while (OSdequeue(&key, kbq)) { // check if it is necessary to turn the calc off if (OSTimerExpired(APD_TIMER)) { off(); OSTimerRestart(APD_TIMER); } } // erase the status line ST_eraseHelp(); // allow key repetition return key & 0xF7FF; } // Custom String Input Function void InputStr(char *buffer, unsigned short maxlen, short x, short y) { SCR_STATE ss; short key; unsigned short i = 0; buffer[0] = 0; MoveTo(x,y); SaveScrState(&ss); do { MoveTo(ss.CurX, ss.CurY); // Note that two spaces are required only if the F_4x6 font is used printf("%s_ ", buffer); key = getKey(); if (key >= ' ' && key <= '~' && i < maxlen) buffer[i++] = key; else if (key == KEY_BACKSPACE && i) i--; buffer[i] = 0; } while (key != KEY_ENTER); } // Main Function void _main(void) { char s[21]; // NOTE: <s> must be 21 bytes long (zero byte at the end of the string! this is a bug in the tigcc docu! clrscr(); InputStr(s, 20, 10, 10); printf("\n%s", s); ngetchx(); }
|
// EDIT by saubue: fancy coloring _________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|