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@18:83579e7dd1bc, 2013-04-05 (annotated)
- Committer:
- earlz
- Date:
- Fri Apr 05 01:01:22 2013 +0000
- Revision:
- 18:83579e7dd1bc
- Parent:
- 16:370b9e559f92
- Child:
- 20:13556e5bac04
Commented out Hack a day code. Probably will have my own little logo in there eventually
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
earlz | 16:370b9e559f92 | 1 | /* |
earlz | 16:370b9e559f92 | 2 | <Copyright Header> |
earlz | 16:370b9e559f92 | 3 | Copyright (c) 2012 Jordan "Earlz" Earls <http://lastyearswishes.com> |
earlz | 16:370b9e559f92 | 4 | All rights reserved. |
earlz | 16:370b9e559f92 | 5 | |
earlz | 16:370b9e559f92 | 6 | Redistribution and use in source and binary forms, with or without |
earlz | 16:370b9e559f92 | 7 | modification, are permitted provided that the following conditions |
earlz | 16:370b9e559f92 | 8 | are met: |
earlz | 16:370b9e559f92 | 9 | |
earlz | 16:370b9e559f92 | 10 | 1. Redistributions of source code must retain the above copyright |
earlz | 16:370b9e559f92 | 11 | notice, this list of conditions and the following disclaimer. |
earlz | 16:370b9e559f92 | 12 | 2. Redistributions in binary form must reproduce the above copyright |
earlz | 16:370b9e559f92 | 13 | notice, this list of conditions and the following disclaimer in the |
earlz | 16:370b9e559f92 | 14 | documentation and/or other materials provided with the distribution. |
earlz | 16:370b9e559f92 | 15 | 3. The name of the author may not be used to endorse or promote products |
earlz | 16:370b9e559f92 | 16 | derived from this software without specific prior written permission. |
earlz | 16:370b9e559f92 | 17 | |
earlz | 16:370b9e559f92 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
earlz | 16:370b9e559f92 | 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
earlz | 16:370b9e559f92 | 20 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
earlz | 16:370b9e559f92 | 21 | THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
earlz | 16:370b9e559f92 | 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
earlz | 16:370b9e559f92 | 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
earlz | 16:370b9e559f92 | 24 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
earlz | 16:370b9e559f92 | 25 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
earlz | 16:370b9e559f92 | 26 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
earlz | 16:370b9e559f92 | 27 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
earlz | 16:370b9e559f92 | 28 | |
earlz | 16:370b9e559f92 | 29 | This file is part of the MbedConsole project |
earlz | 16:370b9e559f92 | 30 | */ |
earlz | 16:370b9e559f92 | 31 | |
earlz | 3:2bc2b0dce10e | 32 | #include "mbedconsole.h" |
earlz | 3:2bc2b0dce10e | 33 | #include "plEarlz.h" |
earlz | 9:4211d638b2e9 | 34 | #include "PS2Keyboard.h" |
earlz | 10:bda85442b674 | 35 | char kbd_GetKey(); |
earlz | 3:2bc2b0dce10e | 36 | |
earlz | 3:2bc2b0dce10e | 37 | LocalFileSystem local("local"); |
earlz | 13:442bd2fb4ea0 | 38 | |
earlz | 18:83579e7dd1bc | 39 | /* |
earlz | 13:442bd2fb4ea0 | 40 | void do_hackaday() |
earlz | 13:442bd2fb4ea0 | 41 | { |
earlz | 13:442bd2fb4ea0 | 42 | // int y=150; |
earlz | 13:442bd2fb4ea0 | 43 | int tmp=0; |
earlz | 13:442bd2fb4ea0 | 44 | for(int y=0;y<HACKADAY_HEIGHT;y++) |
earlz | 13:442bd2fb4ea0 | 45 | { |
earlz | 13:442bd2fb4ea0 | 46 | for(int x=0;x<HACKADAY_WIDTH;x++) |
earlz | 13:442bd2fb4ea0 | 47 | { |
earlz | 13:442bd2fb4ea0 | 48 | int byte=tmp/8; |
earlz | 13:442bd2fb4ea0 | 49 | int bit=tmp%8; |
earlz | 13:442bd2fb4ea0 | 50 | bit=bit-7; //bits are reversed! Those bastards! |
earlz | 13:442bd2fb4ea0 | 51 | bit=-bit; |
earlz | 13:442bd2fb4ea0 | 52 | vga_plot(x,y, (hackadaylogo[byte]&(1<<bit))==0); |
earlz | 13:442bd2fb4ea0 | 53 | tmp++; |
earlz | 13:442bd2fb4ea0 | 54 | } |
earlz | 13:442bd2fb4ea0 | 55 | } |
earlz | 13:442bd2fb4ea0 | 56 | } |
earlz | 18:83579e7dd1bc | 57 | */ |
earlz | 3:2bc2b0dce10e | 58 | void shell_begin(){ |
earlz | 18:83579e7dd1bc | 59 | //do_hackaday(); |
earlz | 3:2bc2b0dce10e | 60 | vputs(">>Micro eMBEDded Shell v0.1<<\n"); |
earlz | 3:2bc2b0dce10e | 61 | char *cmd=(char*)malloc(128); |
earlz | 3:2bc2b0dce10e | 62 | bool valid=false; |
earlz | 3:2bc2b0dce10e | 63 | while(1){ |
earlz | 3:2bc2b0dce10e | 64 | vputs("> "); |
earlz | 3:2bc2b0dce10e | 65 | vgetsl(cmd, 128); |
earlz | 3:2bc2b0dce10e | 66 | vputc('\n'); |
earlz | 3:2bc2b0dce10e | 67 | valid=false; |
earlz | 3:2bc2b0dce10e | 68 | if(strlcmp(cmd, "help", 5)==0){ |
earlz | 3:2bc2b0dce10e | 69 | valid=true; |
earlz | 3:2bc2b0dce10e | 70 | vputs("Command list:\n"); |
earlz | 12:3ee3062cc11c | 71 | vputs("help -- this text \n"); |
earlz | 12:3ee3062cc11c | 72 | vputs("cls -- clear the screen\n"); |
earlz | 12:3ee3062cc11c | 73 | vputs("testX -- test (where X is number) performs tests\n"); |
earlz | 12:3ee3062cc11c | 74 | vputs("reboot -- resets the processor\n"); |
earlz | 12:3ee3062cc11c | 75 | vputs("about -- prints text about how we got to here\n"); |
earlz | 12:3ee3062cc11c | 76 | vputs("plearlz -- enter the PLEarlz Forth shell\n"); |
earlz | 3:2bc2b0dce10e | 77 | }else if(strlcmp(cmd,"cls",4)==0){ |
earlz | 3:2bc2b0dce10e | 78 | valid=true; |
earlz | 3:2bc2b0dce10e | 79 | vga_cls(); |
earlz | 3:2bc2b0dce10e | 80 | vsetcursor(0,0); |
earlz | 3:2bc2b0dce10e | 81 | }else if(strlcmp(cmd,"test", 5)==0){ |
earlz | 3:2bc2b0dce10e | 82 | valid=true; |
earlz | 3:2bc2b0dce10e | 83 | vputs("Opening File...Screen may flicker!\n"); // Drive should be marked as removed |
earlz | 3:2bc2b0dce10e | 84 | wait(5); |
earlz | 3:2bc2b0dce10e | 85 | FILE *fp = fopen("/local/test.txt", "w"); |
earlz | 3:2bc2b0dce10e | 86 | if(!fp) { |
earlz | 3:2bc2b0dce10e | 87 | vputs("File /local/test.txt could not be opened!\n"); |
earlz | 3:2bc2b0dce10e | 88 | exit(1); |
earlz | 3:2bc2b0dce10e | 89 | } |
earlz | 3:2bc2b0dce10e | 90 | |
earlz | 3:2bc2b0dce10e | 91 | wait(5.0); |
earlz | 3:2bc2b0dce10e | 92 | |
earlz | 3:2bc2b0dce10e | 93 | vputs("Writing Data...\n"); |
earlz | 3:2bc2b0dce10e | 94 | fprintf(fp, "Hello World!"); |
earlz | 3:2bc2b0dce10e | 95 | |
earlz | 3:2bc2b0dce10e | 96 | wait(5.0); |
earlz | 3:2bc2b0dce10e | 97 | |
earlz | 3:2bc2b0dce10e | 98 | vputs("Closing File...\n"); |
earlz | 3:2bc2b0dce10e | 99 | fclose(fp); |
earlz | 3:2bc2b0dce10e | 100 | |
earlz | 3:2bc2b0dce10e | 101 | // Drive should be restored. this is the same as just returning from main |
earlz | 3:2bc2b0dce10e | 102 | wait(5); |
earlz | 9:4211d638b2e9 | 103 | }else if(strlcmp(cmd, "test2", 6)==0){ |
earlz | 10:bda85442b674 | 104 | while(1){ |
earlz | 10:bda85442b674 | 105 | vputc(kbd_GetKey()); |
earlz | 9:4211d638b2e9 | 106 | } |
earlz | 3:2bc2b0dce10e | 107 | }else if(strlcmp(cmd, "plearlz", 8)==0){ |
earlz | 3:2bc2b0dce10e | 108 | valid=1; |
earlz | 3:2bc2b0dce10e | 109 | pl_shell(); |
earlz | 12:3ee3062cc11c | 110 | }else if(strlcmp(cmd,"reboot", 7)==0){ |
earlz | 12:3ee3062cc11c | 111 | valid=1; |
earlz | 12:3ee3062cc11c | 112 | NVIC_SystemReset(); |
earlz | 12:3ee3062cc11c | 113 | }else if(strlcmp(cmd, "about", 6)==0){ |
earlz | 12:3ee3062cc11c | 114 | valid=1; |
earlz | 12:3ee3062cc11c | 115 | vputs("I am Jack's broken monolog\n"); |
earlz | 13:442bd2fb4ea0 | 116 | }else if(strlcmp(cmd, "scheme", 7)==0){ |
earlz | 13:442bd2fb4ea0 | 117 | valid=1; |
earlz | 13:442bd2fb4ea0 | 118 | //scheme_main(); |
earlz | 3:2bc2b0dce10e | 119 | } |
earlz | 3:2bc2b0dce10e | 120 | if(!valid){ |
earlz | 12:3ee3062cc11c | 121 | vputs("Invalid Command! Try `help` if you need it\n"); |
earlz | 3:2bc2b0dce10e | 122 | } |
earlz | 3:2bc2b0dce10e | 123 | } |
earlz | 3:2bc2b0dce10e | 124 | } |
earlz | 3:2bc2b0dce10e | 125 | |
earlz | 3:2bc2b0dce10e | 126 | |
earlz | 3:2bc2b0dce10e | 127 |