A project to implement a console using the Mbed using VGA for video output and a PS/2 keyboard for the input. The eventual goal is to also include tools for managing SD cards, and a semi-self-hosting programming environment.

Dependencies:   PS2_MbedConsole fastlib SDFileSystem vga640x480g_mbedconsole lightvm mbed

MbedConsole is a cool little project to have a self-contained computer all on an Mbed. So far it has VGA and PS/2 support and can stand alone without a computer powering it. Next planned features are SD card support and a lightweight programmable VM complete with a file editor and self-hosted assembler.

You can view additional details about it at http://earlz.net/tags/mbedconsole

Committer:
earlz
Date:
Wed Sep 26 04:12:57 2012 +0000
Revision:
9:4211d638b2e9
Parent:
3:2bc2b0dce10e
Child:
10:bda85442b674
PS/2 keyboard now receives scan codes at least

Who changed what in which revision?

UserRevisionLine numberNew contents of line
earlz 3:2bc2b0dce10e 1 #include "mbedconsole.h"
earlz 3:2bc2b0dce10e 2 #include "plEarlz.h"
earlz 9:4211d638b2e9 3 #include "PS2Keyboard.h"
earlz 3:2bc2b0dce10e 4
earlz 3:2bc2b0dce10e 5
earlz 3:2bc2b0dce10e 6 LocalFileSystem local("local");
earlz 3:2bc2b0dce10e 7 void shell_begin(){
earlz 3:2bc2b0dce10e 8 vputs(">>Micro eMBEDded Shell v0.1<<\n");
earlz 3:2bc2b0dce10e 9 char *cmd=(char*)malloc(128);
earlz 3:2bc2b0dce10e 10 bool valid=false;
earlz 3:2bc2b0dce10e 11 while(1){
earlz 3:2bc2b0dce10e 12 vputs("> ");
earlz 3:2bc2b0dce10e 13 vgetsl(cmd, 128);
earlz 3:2bc2b0dce10e 14 vputc('\n');
earlz 3:2bc2b0dce10e 15 valid=false;
earlz 3:2bc2b0dce10e 16 if(strlcmp(cmd, "help", 5)==0){
earlz 3:2bc2b0dce10e 17 valid=true;
earlz 3:2bc2b0dce10e 18 vputs("Command list:\n");
earlz 3:2bc2b0dce10e 19 vputs("help -- this text \n");
earlz 3:2bc2b0dce10e 20 vputs("cls -- clear the screen\n");
earlz 3:2bc2b0dce10e 21 }else if(strlcmp(cmd,"cls",4)==0){
earlz 3:2bc2b0dce10e 22 valid=true;
earlz 3:2bc2b0dce10e 23 vga_cls();
earlz 3:2bc2b0dce10e 24 vsetcursor(0,0);
earlz 3:2bc2b0dce10e 25 }else if(strlcmp(cmd,"test", 5)==0){
earlz 3:2bc2b0dce10e 26 valid=true;
earlz 3:2bc2b0dce10e 27 vputs("Opening File...Screen may flicker!\n"); // Drive should be marked as removed
earlz 3:2bc2b0dce10e 28 wait(5);
earlz 3:2bc2b0dce10e 29 FILE *fp = fopen("/local/test.txt", "w");
earlz 3:2bc2b0dce10e 30 if(!fp) {
earlz 3:2bc2b0dce10e 31 vputs("File /local/test.txt could not be opened!\n");
earlz 3:2bc2b0dce10e 32 exit(1);
earlz 3:2bc2b0dce10e 33 }
earlz 3:2bc2b0dce10e 34
earlz 3:2bc2b0dce10e 35 wait(5.0);
earlz 3:2bc2b0dce10e 36
earlz 3:2bc2b0dce10e 37 vputs("Writing Data...\n");
earlz 3:2bc2b0dce10e 38 fprintf(fp, "Hello World!");
earlz 3:2bc2b0dce10e 39
earlz 3:2bc2b0dce10e 40 wait(5.0);
earlz 3:2bc2b0dce10e 41
earlz 3:2bc2b0dce10e 42 vputs("Closing File...\n");
earlz 3:2bc2b0dce10e 43 fclose(fp);
earlz 3:2bc2b0dce10e 44
earlz 3:2bc2b0dce10e 45 // Drive should be restored. this is the same as just returning from main
earlz 3:2bc2b0dce10e 46 wait(5);
earlz 9:4211d638b2e9 47 }else if(strlcmp(cmd, "test2", 6)==0){
earlz 9:4211d638b2e9 48 PS2Keyboard::keyboard_event_t evt_kb;
earlz 9:4211d638b2e9 49 while (1) {
earlz 9:4211d638b2e9 50 //serial.putc('.');
earlz 9:4211d638b2e9 51 if (ps2kb->processing(&evt_kb)) {
earlz 9:4211d638b2e9 52 console.printf("[%d]:", evt_kb.type);
earlz 9:4211d638b2e9 53 for (int i = 0; i < evt_kb.length; i++) {
earlz 9:4211d638b2e9 54 console.printf("%02x ", evt_kb.scancode[i]);
earlz 9:4211d638b2e9 55 }
earlz 9:4211d638b2e9 56 console.printf("\r\n");
earlz 9:4211d638b2e9 57 }
earlz 9:4211d638b2e9 58 }
earlz 3:2bc2b0dce10e 59 }else if(strlcmp(cmd, "plearlz", 8)==0){
earlz 3:2bc2b0dce10e 60 valid=1;
earlz 3:2bc2b0dce10e 61 pl_shell();
earlz 3:2bc2b0dce10e 62 }
earlz 3:2bc2b0dce10e 63 if(!valid){
earlz 3:2bc2b0dce10e 64 vputs("invalid command!\n");
earlz 3:2bc2b0dce10e 65 }
earlz 3:2bc2b0dce10e 66 }
earlz 3:2bc2b0dce10e 67 }
earlz 3:2bc2b0dce10e 68
earlz 3:2bc2b0dce10e 69
earlz 3:2bc2b0dce10e 70