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
shell.cpp@13:442bd2fb4ea0, 2012-09-30 (annotated)
- Committer:
- earlz
- Date:
- Sun Sep 30 05:26:32 2012 +0000
- Revision:
- 13:442bd2fb4ea0
- Parent:
- 12:3ee3062cc11c
- Child:
- 16:370b9e559f92
finally a graphic
Who changed what in which revision?
User | Revision | Line number | New 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 | 10:bda85442b674 | 4 | char kbd_GetKey(); |
earlz | 3:2bc2b0dce10e | 5 | |
earlz | 3:2bc2b0dce10e | 6 | LocalFileSystem local("local"); |
earlz | 13:442bd2fb4ea0 | 7 | |
earlz | 13:442bd2fb4ea0 | 8 | |
earlz | 13:442bd2fb4ea0 | 9 | void do_hackaday() |
earlz | 13:442bd2fb4ea0 | 10 | { |
earlz | 13:442bd2fb4ea0 | 11 | // int y=150; |
earlz | 13:442bd2fb4ea0 | 12 | int tmp=0; |
earlz | 13:442bd2fb4ea0 | 13 | for(int y=0;y<HACKADAY_HEIGHT;y++) |
earlz | 13:442bd2fb4ea0 | 14 | { |
earlz | 13:442bd2fb4ea0 | 15 | for(int x=0;x<HACKADAY_WIDTH;x++) |
earlz | 13:442bd2fb4ea0 | 16 | { |
earlz | 13:442bd2fb4ea0 | 17 | int byte=tmp/8; |
earlz | 13:442bd2fb4ea0 | 18 | int bit=tmp%8; |
earlz | 13:442bd2fb4ea0 | 19 | bit=bit-7; //bits are reversed! Those bastards! |
earlz | 13:442bd2fb4ea0 | 20 | bit=-bit; |
earlz | 13:442bd2fb4ea0 | 21 | vga_plot(x,y, (hackadaylogo[byte]&(1<<bit))==0); |
earlz | 13:442bd2fb4ea0 | 22 | tmp++; |
earlz | 13:442bd2fb4ea0 | 23 | } |
earlz | 13:442bd2fb4ea0 | 24 | } |
earlz | 13:442bd2fb4ea0 | 25 | } |
earlz | 13:442bd2fb4ea0 | 26 | |
earlz | 3:2bc2b0dce10e | 27 | void shell_begin(){ |
earlz | 13:442bd2fb4ea0 | 28 | do_hackaday(); |
earlz | 3:2bc2b0dce10e | 29 | vputs(">>Micro eMBEDded Shell v0.1<<\n"); |
earlz | 3:2bc2b0dce10e | 30 | char *cmd=(char*)malloc(128); |
earlz | 3:2bc2b0dce10e | 31 | bool valid=false; |
earlz | 3:2bc2b0dce10e | 32 | while(1){ |
earlz | 3:2bc2b0dce10e | 33 | vputs("> "); |
earlz | 3:2bc2b0dce10e | 34 | vgetsl(cmd, 128); |
earlz | 3:2bc2b0dce10e | 35 | vputc('\n'); |
earlz | 3:2bc2b0dce10e | 36 | valid=false; |
earlz | 3:2bc2b0dce10e | 37 | if(strlcmp(cmd, "help", 5)==0){ |
earlz | 3:2bc2b0dce10e | 38 | valid=true; |
earlz | 3:2bc2b0dce10e | 39 | vputs("Command list:\n"); |
earlz | 12:3ee3062cc11c | 40 | vputs("help -- this text \n"); |
earlz | 12:3ee3062cc11c | 41 | vputs("cls -- clear the screen\n"); |
earlz | 12:3ee3062cc11c | 42 | vputs("testX -- test (where X is number) performs tests\n"); |
earlz | 12:3ee3062cc11c | 43 | vputs("reboot -- resets the processor\n"); |
earlz | 12:3ee3062cc11c | 44 | vputs("about -- prints text about how we got to here\n"); |
earlz | 12:3ee3062cc11c | 45 | vputs("plearlz -- enter the PLEarlz Forth shell\n"); |
earlz | 3:2bc2b0dce10e | 46 | }else if(strlcmp(cmd,"cls",4)==0){ |
earlz | 3:2bc2b0dce10e | 47 | valid=true; |
earlz | 3:2bc2b0dce10e | 48 | vga_cls(); |
earlz | 3:2bc2b0dce10e | 49 | vsetcursor(0,0); |
earlz | 3:2bc2b0dce10e | 50 | }else if(strlcmp(cmd,"test", 5)==0){ |
earlz | 3:2bc2b0dce10e | 51 | valid=true; |
earlz | 3:2bc2b0dce10e | 52 | vputs("Opening File...Screen may flicker!\n"); // Drive should be marked as removed |
earlz | 3:2bc2b0dce10e | 53 | wait(5); |
earlz | 3:2bc2b0dce10e | 54 | FILE *fp = fopen("/local/test.txt", "w"); |
earlz | 3:2bc2b0dce10e | 55 | if(!fp) { |
earlz | 3:2bc2b0dce10e | 56 | vputs("File /local/test.txt could not be opened!\n"); |
earlz | 3:2bc2b0dce10e | 57 | exit(1); |
earlz | 3:2bc2b0dce10e | 58 | } |
earlz | 3:2bc2b0dce10e | 59 | |
earlz | 3:2bc2b0dce10e | 60 | wait(5.0); |
earlz | 3:2bc2b0dce10e | 61 | |
earlz | 3:2bc2b0dce10e | 62 | vputs("Writing Data...\n"); |
earlz | 3:2bc2b0dce10e | 63 | fprintf(fp, "Hello World!"); |
earlz | 3:2bc2b0dce10e | 64 | |
earlz | 3:2bc2b0dce10e | 65 | wait(5.0); |
earlz | 3:2bc2b0dce10e | 66 | |
earlz | 3:2bc2b0dce10e | 67 | vputs("Closing File...\n"); |
earlz | 3:2bc2b0dce10e | 68 | fclose(fp); |
earlz | 3:2bc2b0dce10e | 69 | |
earlz | 3:2bc2b0dce10e | 70 | // Drive should be restored. this is the same as just returning from main |
earlz | 3:2bc2b0dce10e | 71 | wait(5); |
earlz | 9:4211d638b2e9 | 72 | }else if(strlcmp(cmd, "test2", 6)==0){ |
earlz | 10:bda85442b674 | 73 | while(1){ |
earlz | 10:bda85442b674 | 74 | vputc(kbd_GetKey()); |
earlz | 9:4211d638b2e9 | 75 | } |
earlz | 3:2bc2b0dce10e | 76 | }else if(strlcmp(cmd, "plearlz", 8)==0){ |
earlz | 3:2bc2b0dce10e | 77 | valid=1; |
earlz | 3:2bc2b0dce10e | 78 | pl_shell(); |
earlz | 12:3ee3062cc11c | 79 | }else if(strlcmp(cmd,"reboot", 7)==0){ |
earlz | 12:3ee3062cc11c | 80 | valid=1; |
earlz | 12:3ee3062cc11c | 81 | NVIC_SystemReset(); |
earlz | 12:3ee3062cc11c | 82 | }else if(strlcmp(cmd, "about", 6)==0){ |
earlz | 12:3ee3062cc11c | 83 | valid=1; |
earlz | 12:3ee3062cc11c | 84 | vputs("I am Jack's broken monolog\n"); |
earlz | 13:442bd2fb4ea0 | 85 | }else if(strlcmp(cmd, "scheme", 7)==0){ |
earlz | 13:442bd2fb4ea0 | 86 | valid=1; |
earlz | 13:442bd2fb4ea0 | 87 | //scheme_main(); |
earlz | 3:2bc2b0dce10e | 88 | } |
earlz | 3:2bc2b0dce10e | 89 | if(!valid){ |
earlz | 12:3ee3062cc11c | 90 | vputs("Invalid Command! Try `help` if you need it\n"); |
earlz | 3:2bc2b0dce10e | 91 | } |
earlz | 3:2bc2b0dce10e | 92 | } |
earlz | 3:2bc2b0dce10e | 93 | } |
earlz | 3:2bc2b0dce10e | 94 | |
earlz | 3:2bc2b0dce10e | 95 | |
earlz | 3:2bc2b0dce10e | 96 |