Port of Conio.h

Dependencies:   mbed

Dependents:   KNN_coba5

Committer:
hornfeldt
Date:
Mon Apr 19 20:20:10 2010 +0000
Revision:
0:6c1bc9b3a347

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hornfeldt 0:6c1bc9b3a347 1 /*
hornfeldt 0:6c1bc9b3a347 2 main.c
hornfeldt 0:6c1bc9b3a347 3 Main demo file. Using conio functions to display demo userinterface.
hornfeldt 0:6c1bc9b3a347 4 Part of MicroVGA CONIO library / demo project
hornfeldt 0:6c1bc9b3a347 5 Copyright (c) 2008-9 SECONS s.r.o., http://www.MicroVGA.com
hornfeldt 0:6c1bc9b3a347 6
hornfeldt 0:6c1bc9b3a347 7 This program is free software: you can redistribute it and/or modify
hornfeldt 0:6c1bc9b3a347 8 it under the terms of the GNU General Public License as published by
hornfeldt 0:6c1bc9b3a347 9 the Free Software Foundation, either version 3 of the License, or
hornfeldt 0:6c1bc9b3a347 10 (at your option) any later version.
hornfeldt 0:6c1bc9b3a347 11
hornfeldt 0:6c1bc9b3a347 12 This program is distributed in the hope that it will be useful,
hornfeldt 0:6c1bc9b3a347 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
hornfeldt 0:6c1bc9b3a347 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
hornfeldt 0:6c1bc9b3a347 15 GNU General Public License for more details.
hornfeldt 0:6c1bc9b3a347 16
hornfeldt 0:6c1bc9b3a347 17 You should have received a copy of the GNU General Public License
hornfeldt 0:6c1bc9b3a347 18 along with this program. If not, see <http://www.gnu.org/licenses/>.
hornfeldt 0:6c1bc9b3a347 19 */
hornfeldt 0:6c1bc9b3a347 20
hornfeldt 0:6c1bc9b3a347 21 #include "conio.h"
hornfeldt 0:6c1bc9b3a347 22 #include "kbd.h"
hornfeldt 0:6c1bc9b3a347 23 #include "ui.h"
hornfeldt 0:6c1bc9b3a347 24
hornfeldt 0:6c1bc9b3a347 25 #ifdef AVR_MCU //WinAvr - AVR MCU - has to be defined in project settings
hornfeldt 0:6c1bc9b3a347 26 #define LOWMEM 1
hornfeldt 0:6c1bc9b3a347 27 #endif
hornfeldt 0:6c1bc9b3a347 28
hornfeldt 0:6c1bc9b3a347 29 #ifdef __ICC78K__
hornfeldt 0:6c1bc9b3a347 30 #define LOWMEM 1
hornfeldt 0:6c1bc9b3a347 31 #endif
hornfeldt 0:6c1bc9b3a347 32
hornfeldt 0:6c1bc9b3a347 33 #if RENESAS_C //Renessa High performance Emb. Workshop- has to be defined in project settings
hornfeldt 0:6c1bc9b3a347 34 #define LOWMEM 1
hornfeldt 0:6c1bc9b3a347 35 #endif
hornfeldt 0:6c1bc9b3a347 36
hornfeldt 0:6c1bc9b3a347 37 #ifndef LOWMEM
hornfeldt 0:6c1bc9b3a347 38 #include "aa.c" //ascii art
hornfeldt 0:6c1bc9b3a347 39 #endif
hornfeldt 0:6c1bc9b3a347 40
hornfeldt 0:6c1bc9b3a347 41 extern void MCU_Init(void);
hornfeldt 0:6c1bc9b3a347 42
hornfeldt 0:6c1bc9b3a347 43
hornfeldt 0:6c1bc9b3a347 44 /*const static char *nc_fkeys[10] =
hornfeldt 0:6c1bc9b3a347 45 {"Help","Menu","View","Edit","Copy","RenMov","Mkdir","Delete","Setup","Quit"};
hornfeldt 0:6c1bc9b3a347 46 */
hornfeldt 0:6c1bc9b3a347 47
hornfeldt 0:6c1bc9b3a347 48 ROMDEF static char *memview_fkeys[10] =
hornfeldt 0:6c1bc9b3a347 49 {"Help",0,0,0,"DynMem",0,0,0,0,"Quit"};
hornfeldt 0:6c1bc9b3a347 50
hornfeldt 0:6c1bc9b3a347 51 ROMDEF static char *mainmenu[] =
hornfeldt 0:6c1bc9b3a347 52 {
hornfeldt 0:6c1bc9b3a347 53 "Memory viewer",
hornfeldt 0:6c1bc9b3a347 54 "Console debug demo",
hornfeldt 0:6c1bc9b3a347 55 "Speed test",
hornfeldt 0:6c1bc9b3a347 56 "Test sub menu",
hornfeldt 0:6c1bc9b3a347 57 "Command line interface",
hornfeldt 0:6c1bc9b3a347 58 "ASCII-Art test",
hornfeldt 0:6c1bc9b3a347 59 "Input dialog test",
hornfeldt 0:6c1bc9b3a347 60 0
hornfeldt 0:6c1bc9b3a347 61 };
hornfeldt 0:6c1bc9b3a347 62
hornfeldt 0:6c1bc9b3a347 63 ROMDEF static char *submenu1[] =
hornfeldt 0:6c1bc9b3a347 64 //far const rom char *submenu1[] =
hornfeldt 0:6c1bc9b3a347 65 {
hornfeldt 0:6c1bc9b3a347 66 "Menu item number 1",
hornfeldt 0:6c1bc9b3a347 67 "Menu item number 2",
hornfeldt 0:6c1bc9b3a347 68 "Some other menu",
hornfeldt 0:6c1bc9b3a347 69 "And finally last menu item",
hornfeldt 0:6c1bc9b3a347 70 0
hornfeldt 0:6c1bc9b3a347 71 };
hornfeldt 0:6c1bc9b3a347 72
hornfeldt 0:6c1bc9b3a347 73 const static char hexchars[] = "0123456789ABCDEF";
hornfeldt 0:6c1bc9b3a347 74
hornfeldt 0:6c1bc9b3a347 75 void drawmem(const unsigned char *mem)
hornfeldt 0:6c1bc9b3a347 76 {
hornfeldt 0:6c1bc9b3a347 77 const unsigned char *mptr;
hornfeldt 0:6c1bc9b3a347 78 int i,j;
hornfeldt 0:6c1bc9b3a347 79
hornfeldt 0:6c1bc9b3a347 80
hornfeldt 0:6c1bc9b3a347 81 textbackground(BLUE);
hornfeldt 0:6c1bc9b3a347 82 for (i=0;i<23 && !_kbhit();i++) {
hornfeldt 0:6c1bc9b3a347 83 mptr = &mem[i*16];
hornfeldt 0:6c1bc9b3a347 84 gotoxy(1,i+2);
hornfeldt 0:6c1bc9b3a347 85 textcolor(YELLOW);
hornfeldt 0:6c1bc9b3a347 86 j = 8;
hornfeldt 0:6c1bc9b3a347 87 do {
hornfeldt 0:6c1bc9b3a347 88 j--;
hornfeldt 0:6c1bc9b3a347 89 _putch(hexchars[ (((int)mptr)>>(j*4)) &0xF] );
hornfeldt 0:6c1bc9b3a347 90 } while (j>0);
hornfeldt 0:6c1bc9b3a347 91 _cputs(": ");
hornfeldt 0:6c1bc9b3a347 92 textcolor(WHITE);
hornfeldt 0:6c1bc9b3a347 93
hornfeldt 0:6c1bc9b3a347 94 for (j=0;j<16;j++) {
hornfeldt 0:6c1bc9b3a347 95 _putch(hexchars[*mptr>>4]);
hornfeldt 0:6c1bc9b3a347 96 _putch(hexchars[*mptr&0xF]);
hornfeldt 0:6c1bc9b3a347 97 mptr++;
hornfeldt 0:6c1bc9b3a347 98 _putch(' ');
hornfeldt 0:6c1bc9b3a347 99 if (j == 7) {
hornfeldt 0:6c1bc9b3a347 100 _putch('-');
hornfeldt 0:6c1bc9b3a347 101 _putch(' ');
hornfeldt 0:6c1bc9b3a347 102 }
hornfeldt 0:6c1bc9b3a347 103 }
hornfeldt 0:6c1bc9b3a347 104
hornfeldt 0:6c1bc9b3a347 105 _putch(179);
hornfeldt 0:6c1bc9b3a347 106 _putch(' ');
hornfeldt 0:6c1bc9b3a347 107
hornfeldt 0:6c1bc9b3a347 108 mptr = &mem[i*16];
hornfeldt 0:6c1bc9b3a347 109 for (j=0;j<16;j++) {
hornfeldt 0:6c1bc9b3a347 110 if (*mptr >= ' ')
hornfeldt 0:6c1bc9b3a347 111 _putch(*mptr);
hornfeldt 0:6c1bc9b3a347 112 else _putch('.');
hornfeldt 0:6c1bc9b3a347 113 mptr++;
hornfeldt 0:6c1bc9b3a347 114 }
hornfeldt 0:6c1bc9b3a347 115
hornfeldt 0:6c1bc9b3a347 116 clreol();
hornfeldt 0:6c1bc9b3a347 117 }
hornfeldt 0:6c1bc9b3a347 118 }
hornfeldt 0:6c1bc9b3a347 119
hornfeldt 0:6c1bc9b3a347 120
hornfeldt 0:6c1bc9b3a347 121 void memviewer(void *start)
hornfeldt 0:6c1bc9b3a347 122 {
hornfeldt 0:6c1bc9b3a347 123 #ifndef LOWMEM
hornfeldt 0:6c1bc9b3a347 124 int key;
hornfeldt 0:6c1bc9b3a347 125 const unsigned char *mem;
hornfeldt 0:6c1bc9b3a347 126
hornfeldt 0:6c1bc9b3a347 127 textattr(LIGHTGRAY | BLUE <<4);
hornfeldt 0:6c1bc9b3a347 128 clrscr();
hornfeldt 0:6c1bc9b3a347 129 textcolor(BLACK);
hornfeldt 0:6c1bc9b3a347 130 textbackground(CYAN);
hornfeldt 0:6c1bc9b3a347 131 _cputs("Memory viewer");
hornfeldt 0:6c1bc9b3a347 132 clreol();
hornfeldt 0:6c1bc9b3a347 133
hornfeldt 0:6c1bc9b3a347 134 cursoroff();
hornfeldt 0:6c1bc9b3a347 135 drawfkeys(memview_fkeys);
hornfeldt 0:6c1bc9b3a347 136
hornfeldt 0:6c1bc9b3a347 137 mem=(const unsigned char *)start;
hornfeldt 0:6c1bc9b3a347 138 for (;;) {
hornfeldt 0:6c1bc9b3a347 139 drawmem(mem);
hornfeldt 0:6c1bc9b3a347 140
hornfeldt 0:6c1bc9b3a347 141 if (_kbhit()) {
hornfeldt 0:6c1bc9b3a347 142 key = _getch();
hornfeldt 0:6c1bc9b3a347 143 switch(key) {
hornfeldt 0:6c1bc9b3a347 144 case KB_LEFT: if ((int)mem > 0 ) (int)mem--; break;
hornfeldt 0:6c1bc9b3a347 145 case KB_RIGHT: mem++; break;
hornfeldt 0:6c1bc9b3a347 146 case KB_UP: if (mem >= (unsigned char const *)16) mem-=16; break;
hornfeldt 0:6c1bc9b3a347 147 case KB_DOWN: mem+=16; break;
hornfeldt 0:6c1bc9b3a347 148 case KB_PGUP: if (mem >= (unsigned char const *)(16*23)) mem-=16*23; break;
hornfeldt 0:6c1bc9b3a347 149 case KB_PGDN: mem+=16*23; break;
hornfeldt 0:6c1bc9b3a347 150 case KB_F10: cursoron(); return ;
hornfeldt 0:6c1bc9b3a347 151 }
hornfeldt 0:6c1bc9b3a347 152 }
hornfeldt 0:6c1bc9b3a347 153
hornfeldt 0:6c1bc9b3a347 154 }
hornfeldt 0:6c1bc9b3a347 155 #else
hornfeldt 0:6c1bc9b3a347 156 textattr(LIGHTGRAY);
hornfeldt 0:6c1bc9b3a347 157 clrscr();
hornfeldt 0:6c1bc9b3a347 158 _cputs("Not enought memory for this feature");
hornfeldt 0:6c1bc9b3a347 159
hornfeldt 0:6c1bc9b3a347 160 while (_getch() != KB_ESC);
hornfeldt 0:6c1bc9b3a347 161 #endif
hornfeldt 0:6c1bc9b3a347 162 }
hornfeldt 0:6c1bc9b3a347 163
hornfeldt 0:6c1bc9b3a347 164 void debugdemo()
hornfeldt 0:6c1bc9b3a347 165 {
hornfeldt 0:6c1bc9b3a347 166 int key;
hornfeldt 0:6c1bc9b3a347 167
hornfeldt 0:6c1bc9b3a347 168 textattr(LIGHTGRAY);
hornfeldt 0:6c1bc9b3a347 169 clrscr();
hornfeldt 0:6c1bc9b3a347 170
hornfeldt 0:6c1bc9b3a347 171 while (1) {
hornfeldt 0:6c1bc9b3a347 172 _cputs("Debug line 1\r\n");
hornfeldt 0:6c1bc9b3a347 173 if (_kbhit()) {
hornfeldt 0:6c1bc9b3a347 174 key = _getch();
hornfeldt 0:6c1bc9b3a347 175 _cputs("You have pressed key");
hornfeldt 0:6c1bc9b3a347 176 _putch(key);
hornfeldt 0:6c1bc9b3a347 177 _cputs("\r\n");
hornfeldt 0:6c1bc9b3a347 178 if (key == KB_ESC)
hornfeldt 0:6c1bc9b3a347 179 return ;
hornfeldt 0:6c1bc9b3a347 180 }
hornfeldt 0:6c1bc9b3a347 181 }
hornfeldt 0:6c1bc9b3a347 182 }
hornfeldt 0:6c1bc9b3a347 183
hornfeldt 0:6c1bc9b3a347 184
hornfeldt 0:6c1bc9b3a347 185 void cli()
hornfeldt 0:6c1bc9b3a347 186 {
hornfeldt 0:6c1bc9b3a347 187 char buffer[40];
hornfeldt 0:6c1bc9b3a347 188 char * out;
hornfeldt 0:6c1bc9b3a347 189
hornfeldt 0:6c1bc9b3a347 190 textattr(LIGHTGRAY);
hornfeldt 0:6c1bc9b3a347 191
hornfeldt 0:6c1bc9b3a347 192 clrscr();
hornfeldt 0:6c1bc9b3a347 193
hornfeldt 0:6c1bc9b3a347 194 while (1) {
hornfeldt 0:6c1bc9b3a347 195 //read data
hornfeldt 0:6c1bc9b3a347 196 buffer[0]=40;
hornfeldt 0:6c1bc9b3a347 197
hornfeldt 0:6c1bc9b3a347 198 textattr(YELLOW);
hornfeldt 0:6c1bc9b3a347 199 _cputs("uVGA> ");
hornfeldt 0:6c1bc9b3a347 200 textattr(LIGHTGRAY);
hornfeldt 0:6c1bc9b3a347 201 out=_cgets(buffer);
hornfeldt 0:6c1bc9b3a347 202
hornfeldt 0:6c1bc9b3a347 203 if (out != 0 && out[0] == 'q' && out[1] == 0)
hornfeldt 0:6c1bc9b3a347 204 return ;
hornfeldt 0:6c1bc9b3a347 205
hornfeldt 0:6c1bc9b3a347 206 textattr(WHITE);
hornfeldt 0:6c1bc9b3a347 207 _cputs("\r\nUnsupported command. Only ");
hornfeldt 0:6c1bc9b3a347 208 textattr(LIGHTRED);
hornfeldt 0:6c1bc9b3a347 209 _cputs("q");
hornfeldt 0:6c1bc9b3a347 210 textattr(WHITE);
hornfeldt 0:6c1bc9b3a347 211 _cputs(" (exit) is supported.\r\n");
hornfeldt 0:6c1bc9b3a347 212 }
hornfeldt 0:6c1bc9b3a347 213 }
hornfeldt 0:6c1bc9b3a347 214
hornfeldt 0:6c1bc9b3a347 215
hornfeldt 0:6c1bc9b3a347 216 void speedtest(void)
hornfeldt 0:6c1bc9b3a347 217 {
hornfeldt 0:6c1bc9b3a347 218 unsigned int i;
hornfeldt 0:6c1bc9b3a347 219
hornfeldt 0:6c1bc9b3a347 220 gotoxy(1,1);
hornfeldt 0:6c1bc9b3a347 221 textattr(GREEN<<4 | YELLOW);
hornfeldt 0:6c1bc9b3a347 222
hornfeldt 0:6c1bc9b3a347 223 for (i=0;i<50000;i++) {
hornfeldt 0:6c1bc9b3a347 224 _cputs("TEST50=>");
hornfeldt 0:6c1bc9b3a347 225 _putch(((i/10000)%10) + '0');
hornfeldt 0:6c1bc9b3a347 226 _putch(((i/1000)%10) + '0');
hornfeldt 0:6c1bc9b3a347 227 _cputs("\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08");
hornfeldt 0:6c1bc9b3a347 228 }
hornfeldt 0:6c1bc9b3a347 229 }
hornfeldt 0:6c1bc9b3a347 230
hornfeldt 0:6c1bc9b3a347 231
hornfeldt 0:6c1bc9b3a347 232 void submenutest()
hornfeldt 0:6c1bc9b3a347 233 {
hornfeldt 0:6c1bc9b3a347 234 int item;
hornfeldt 0:6c1bc9b3a347 235
hornfeldt 0:6c1bc9b3a347 236 item = 0;
hornfeldt 0:6c1bc9b3a347 237
hornfeldt 0:6c1bc9b3a347 238 while (1) {
hornfeldt 0:6c1bc9b3a347 239
hornfeldt 0:6c1bc9b3a347 240 item = runmenu(8,10, submenu1, item);
hornfeldt 0:6c1bc9b3a347 241 switch (item) {
hornfeldt 0:6c1bc9b3a347 242 case 0: return ;
hornfeldt 0:6c1bc9b3a347 243 }
hornfeldt 0:6c1bc9b3a347 244 }
hornfeldt 0:6c1bc9b3a347 245 }
hornfeldt 0:6c1bc9b3a347 246
hornfeldt 0:6c1bc9b3a347 247
hornfeldt 0:6c1bc9b3a347 248 void ascii_art()
hornfeldt 0:6c1bc9b3a347 249 {
hornfeldt 0:6c1bc9b3a347 250 #ifndef LOWMEM
hornfeldt 0:6c1bc9b3a347 251 textattr(LIGHTGRAY);
hornfeldt 0:6c1bc9b3a347 252 clrscr();
hornfeldt 0:6c1bc9b3a347 253
hornfeldt 0:6c1bc9b3a347 254 // _cputs((const char *)ascii_art_str);
hornfeldt 0:6c1bc9b3a347 255
hornfeldt 0:6c1bc9b3a347 256 while (_getch() != KB_ESC);
hornfeldt 0:6c1bc9b3a347 257 #else
hornfeldt 0:6c1bc9b3a347 258 textattr(LIGHTGRAY);
hornfeldt 0:6c1bc9b3a347 259 clrscr();
hornfeldt 0:6c1bc9b3a347 260 _cputs("Not enought memory for this feature");
hornfeldt 0:6c1bc9b3a347 261
hornfeldt 0:6c1bc9b3a347 262 while (_getch() != KB_ESC);
hornfeldt 0:6c1bc9b3a347 263 #endif
hornfeldt 0:6c1bc9b3a347 264 }
hornfeldt 0:6c1bc9b3a347 265
hornfeldt 0:6c1bc9b3a347 266 void testCGetS()
hornfeldt 0:6c1bc9b3a347 267 {
hornfeldt 0:6c1bc9b3a347 268 char buffer[40];
hornfeldt 0:6c1bc9b3a347 269 char * out;
hornfeldt 0:6c1bc9b3a347 270 int i;
hornfeldt 0:6c1bc9b3a347 271
hornfeldt 0:6c1bc9b3a347 272 //draw input dialog (frame)
hornfeldt 0:6c1bc9b3a347 273 drawframe(10, 10, 40, 9, WHITE | RED <<4);
hornfeldt 0:6c1bc9b3a347 274 gotoxy(12,12);
hornfeldt 0:6c1bc9b3a347 275 _cputs("Enter your name:");
hornfeldt 0:6c1bc9b3a347 276 gotoxy(12,14);
hornfeldt 0:6c1bc9b3a347 277 textattr(WHITE | BLACK <<4);
hornfeldt 0:6c1bc9b3a347 278 for (i=0;i<40;i++)
hornfeldt 0:6c1bc9b3a347 279 _putch(' ');
hornfeldt 0:6c1bc9b3a347 280
hornfeldt 0:6c1bc9b3a347 281 //read data
hornfeldt 0:6c1bc9b3a347 282 gotoxy(12,14);
hornfeldt 0:6c1bc9b3a347 283 buffer[0]=40;
hornfeldt 0:6c1bc9b3a347 284
hornfeldt 0:6c1bc9b3a347 285 out=_cgets(buffer);
hornfeldt 0:6c1bc9b3a347 286
hornfeldt 0:6c1bc9b3a347 287 //write read data
hornfeldt 0:6c1bc9b3a347 288 gotoxy(12,16);
hornfeldt 0:6c1bc9b3a347 289 if (buffer[1]==0)
hornfeldt 0:6c1bc9b3a347 290 {
hornfeldt 0:6c1bc9b3a347 291 textattr((WHITE | RED <<4)|BLINK);
hornfeldt 0:6c1bc9b3a347 292 _cputs("You didn't enter your name!");
hornfeldt 0:6c1bc9b3a347 293 }
hornfeldt 0:6c1bc9b3a347 294 else
hornfeldt 0:6c1bc9b3a347 295 {
hornfeldt 0:6c1bc9b3a347 296 textattr((WHITE | RED <<4));
hornfeldt 0:6c1bc9b3a347 297 _cputs("Your name is:\n");
hornfeldt 0:6c1bc9b3a347 298 gotoxy(12,17);
hornfeldt 0:6c1bc9b3a347 299 _cputs(out);
hornfeldt 0:6c1bc9b3a347 300 }
hornfeldt 0:6c1bc9b3a347 301 cursoroff();
hornfeldt 0:6c1bc9b3a347 302
hornfeldt 0:6c1bc9b3a347 303 gotoxy(23,19);
hornfeldt 0:6c1bc9b3a347 304 textattr((WHITE | RED <<4)|BLINK);
hornfeldt 0:6c1bc9b3a347 305 _cputs("PRESS ESC TO EXIT");
hornfeldt 0:6c1bc9b3a347 306
hornfeldt 0:6c1bc9b3a347 307 //wait for ESC press
hornfeldt 0:6c1bc9b3a347 308 while (_getch() != KB_ESC);
hornfeldt 0:6c1bc9b3a347 309 }
hornfeldt 0:6c1bc9b3a347 310
hornfeldt 0:6c1bc9b3a347 311 #ifndef LOWMEM
hornfeldt 0:6c1bc9b3a347 312 static ROMDEF char *uvga_logo=
hornfeldt 0:6c1bc9b3a347 313 " ## ## #### # "
hornfeldt 0:6c1bc9b3a347 314 " ## ## ## ## ### "
hornfeldt 0:6c1bc9b3a347 315 " ## ## ## # ## ## "
hornfeldt 0:6c1bc9b3a347 316 " ## ## ## ## ## ## ##"
hornfeldt 0:6c1bc9b3a347 317 " ## ## ## ## ## ## ##"
hornfeldt 0:6c1bc9b3a347 318 " ## ## ## ## ## #### #######"
hornfeldt 0:6c1bc9b3a347 319 " ## ## ## ## ## ## ## ##"
hornfeldt 0:6c1bc9b3a347 320 " ## ## ## ## ## ## ## ##"
hornfeldt 0:6c1bc9b3a347 321 " ##### #### ## ## ## ##"
hornfeldt 0:6c1bc9b3a347 322 " ## ## ### # ## ##"
hornfeldt 0:6c1bc9b3a347 323 " ## MicroVGA demo application"
hornfeldt 0:6c1bc9b3a347 324 "## "
hornfeldt 0:6c1bc9b3a347 325 "www.MicroVGA.com, www.secons.com";
hornfeldt 0:6c1bc9b3a347 326 #endif
hornfeldt 0:6c1bc9b3a347 327
hornfeldt 0:6c1bc9b3a347 328 void main()
hornfeldt 0:6c1bc9b3a347 329 {
hornfeldt 0:6c1bc9b3a347 330 int i,j;
hornfeldt 0:6c1bc9b3a347 331 int item;
hornfeldt 0:6c1bc9b3a347 332
hornfeldt 0:6c1bc9b3a347 333 //////////// Main routine
hornfeldt 0:6c1bc9b3a347 334
hornfeldt 0:6c1bc9b3a347 335 MCU_Init();
hornfeldt 0:6c1bc9b3a347 336
hornfeldt 0:6c1bc9b3a347 337
hornfeldt 0:6c1bc9b3a347 338 item = 0;
hornfeldt 0:6c1bc9b3a347 339
hornfeldt 0:6c1bc9b3a347 340 while (1) {
hornfeldt 0:6c1bc9b3a347 341
hornfeldt 0:6c1bc9b3a347 342 textbackground(BLUE);
hornfeldt 0:6c1bc9b3a347 343 clrscr();
hornfeldt 0:6c1bc9b3a347 344 textcolor(BLACK);
hornfeldt 0:6c1bc9b3a347 345 textbackground(CYAN);
hornfeldt 0:6c1bc9b3a347 346 _cputs("MicroVGA demo app");
hornfeldt 0:6c1bc9b3a347 347
hornfeldt 0:6c1bc9b3a347 348 clreol();
hornfeldt 0:6c1bc9b3a347 349 textbackground(BLUE);
hornfeldt 0:6c1bc9b3a347 350 textcolor(GREEN);
hornfeldt 0:6c1bc9b3a347 351
hornfeldt 0:6c1bc9b3a347 352
hornfeldt 0:6c1bc9b3a347 353 #ifndef LOWMEM
hornfeldt 0:6c1bc9b3a347 354 // draw "logo"
hornfeldt 0:6c1bc9b3a347 355 for (i=0;i<13;i++) {
hornfeldt 0:6c1bc9b3a347 356 gotoxy(46,12+i);
hornfeldt 0:6c1bc9b3a347 357 for (j=0;j<32;j++) {
hornfeldt 0:6c1bc9b3a347 358 if (uvga_logo[i*32+ j] == '#')
hornfeldt 0:6c1bc9b3a347 359 _putch(219);
hornfeldt 0:6c1bc9b3a347 360 else _putch(uvga_logo[i*32+ j]);
hornfeldt 0:6c1bc9b3a347 361 }
hornfeldt 0:6c1bc9b3a347 362 }
hornfeldt 0:6c1bc9b3a347 363 #endif
hornfeldt 0:6c1bc9b3a347 364
hornfeldt 0:6c1bc9b3a347 365
hornfeldt 0:6c1bc9b3a347 366 item = runmenu(5,5, mainmenu, item);
hornfeldt 0:6c1bc9b3a347 367 switch (item) {
hornfeldt 0:6c1bc9b3a347 368 case 1: memviewer(0); break;
hornfeldt 0:6c1bc9b3a347 369 case 2: debugdemo(); break;
hornfeldt 0:6c1bc9b3a347 370 case 3: speedtest(); break;
hornfeldt 0:6c1bc9b3a347 371 case 4: submenutest(); break;
hornfeldt 0:6c1bc9b3a347 372 case 5: cli(); break;
hornfeldt 0:6c1bc9b3a347 373 case 6: ascii_art(); break;
hornfeldt 0:6c1bc9b3a347 374 case 7: testCGetS(); break;
hornfeldt 0:6c1bc9b3a347 375
hornfeldt 0:6c1bc9b3a347 376 }
hornfeldt 0:6c1bc9b3a347 377 }
hornfeldt 0:6c1bc9b3a347 378 }