1

Fork of coniolib by Anders Hörnfeldt

Files at this revision

API Documentation at this revision

Comitter:
alex1403
Date:
Fri Sep 14 09:13:08 2018 +0000
Parent:
0:6c1bc9b3a347
Commit message:
Version 1;

Changed in this revision

aa.c Show diff for this revision Revisions of this file
hw_mbed.c Show diff for this revision Revisions of this file
lib/conio.c Show diff for this revision Revisions of this file
lib/ui.c Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
diff -r 6c1bc9b3a347 -r e0c613cee738 aa.c
--- a/aa.c	Mon Apr 19 20:20:10 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
-    aa.c
-    Demo ASCII art picture.
-    Part of MicroVGA CONIO library / demo project
-    Copyright (c) 2008-9 SECONS s.r.o., http://www.MicroVGA.com
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "conio.h"
-
-static const ROMDEF unsigned char ascii_art_str[] = "";
-
-
-/* */
\ No newline at end of file
diff -r 6c1bc9b3a347 -r e0c613cee738 hw_mbed.c
--- a/hw_mbed.c	Mon Apr 19 20:20:10 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-#include "mbed.h"
-#include "conio.h"
-
-Serial pc(USBTX, USBRX);
-
-int get_esc_sec () {
-    int ch;
-    if (pc.scanf("\x1b\x5b%c",ch) == 0)
-        return 0;
-    else
-        return ch;
-}
-
-int _kbhit (void) {
-    return pc.readable();
-}
-
-
-void _putch (char ch) {
-    pc.putc(ch);
-}
-
-int _getch (void) {
-    int ret;
-
-    while (!_kbhit()); //wait and read new char
-    ret = pc.getc();
-    if (ret==0) {
-        while (!_kbhit()); //wait and read new char
-        ret = pc.getc();
-        ret = ret | 0x100;
-    }
-
-    return ret;
-}
-
-
-void MCU_Init(void) {
-    pc.baud(19200);
-}
\ No newline at end of file
diff -r 6c1bc9b3a347 -r e0c613cee738 lib/conio.c
--- a/lib/conio.c	Mon Apr 19 20:20:10 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/*
-    conio.c
-    Standard conio routines.
-    Part of MicroVGA CONIO library / demo project
-    Copyright (c) 2008-9 SECONS s.r.o., http://www.MicroVGA.com
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "../h/conio.h"
-#include "../h/ui.h"
-#include "../h/kbd.h"
-
-
-
-void clrscr(void)
-{
-  _putch('\033');
-  _putch('[');
-  _putch('2');
-  _putch('J');
-}
-
-void clreol(void)
-{
-  _putch('\033');
-  _putch('[');
-  _putch('K');
-}
-
-
-void cursoron(void)
-{
-  _putch('\033');
-  _putch('[');
-  _putch('2');
-  _putch('5');
-  _putch('h');
-}
-
-void cursoroff(void)
-{
-  _putch('\033');
-  _putch('[');
-  _putch('2');
-  _putch('5');
-  _putch('l');
-}
-
-void textcolor(int color)
-{
-  _putch('\033');
-  _putch('[');
-  if (color & 0x8) 
-      _putch('1');
-  else _putch('2');
-  _putch('m');
-
-  _putch('\033');
-  _putch('[');
-  _putch('3');
-  _putch(((color&0x7)%10)+'0');
-  _putch('m');
-}
-
-void textbackground(int color)
-{
-  _putch('\033');
-  _putch('[');
-  if (color & 0x8) 
-      _putch('5');
-  else _putch('6');
-  _putch('m');
-
-  _putch('\033');
-  _putch('[');
-  _putch('4');
-  _putch((color&0x7)+'0');
-  _putch('m');
-}
-
-void textattr(int attr)
-{
-  textcolor(attr&0xF);
-  textbackground(attr>>4);
-}
-
-void gotoxy(char x, char y)
-{
-  if (x>MAX_X || y>MAX_Y)
-    return;
-  
-  x--;
-  y--;
-
-  _putch(0x1B);
-  _putch('[');
-  _putch((y/10)+'0');
-  _putch((y%10)+'0');
-  _putch(';');
-  _putch((x/10)+'0');
-  _putch((x%10)+'0');
-  _putch('f');
-}
-
-
-void _cputs(ROMDEF char *s)
-{
-   while (*s != 0) 
-    _putch(*s++);
-}
-
-char * _cgets(char *s)
-{
-  char len;
-  int ch;
-  
-  len=0;
-
-  while (s[0]>len)
-  {
-    ch=_getch();
-    
-    if (ch==KB_ENTER)
-      break; //enter hit, end of input
-
-    if (ch==KB_ESC) {
-      s[1]=0;
-      s[2]=0;
-      return &s[2]; 
-    }
-
-    
-    if (ch==KB_BACK)
-    {
-      
-        if (len>0) 
-        {
-            len--;
-            //delete char and go back (if some chars left)
-            _putch(KB_BACK);
-            _putch(' '); 
-            _putch(KB_BACK);
-           
-        }
-         
-         continue;
-    }
-
-    if (ch>0x80 || ch <' ') //skip functions keys
-        continue;
-  
-    _putch((char)0xff&ch); //print back to screen
-    s[len+2]=(char)0xff&ch;
-    len++;
-  }
-  
-  s[1]=len;
-  s[len+2]=0;
-
-  return &s[2]; 
-}
\ No newline at end of file
diff -r 6c1bc9b3a347 -r e0c613cee738 lib/ui.c
--- a/lib/ui.c	Mon Apr 19 20:20:10 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-/*
-    ui.c
-    User interface functions.
-    Part of MicroVGA CONIO library / demo project
-    Copyright (c) 2008-9 SECONS s.r.o., http://www.MicroVGA.com
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "conio.h"
-#include "ui.h"
-#include "kbd.h"
-
-
-int runmenu(char x, char y, ROMDEF char *menu[], int defaultitem)
-{
-  int keys[3], i,j, itemno;
-  int nitems, width;
-  ROMDEF char *s;
-
-  itemno = defaultitem-1;
-  width = 20;
-
-  width = 10;
-  nitems = 0;
-  while (menu[nitems] != 0) {
-    for (j=0;menu[nitems][j];j++);
-    if (j>width)
-     width = j;
-    nitems++;
-  }
-  width+=2;
-
-  if (itemno < 0 || itemno > nitems)
-    itemno = 0;
-
-  while (1) {
-
-
-  cursoroff();
-  textattr(CYAN<<4 | BLACK);
-  gotoxy(x,y);
-  _putch(ACS_ULCORNER);
-  for (i=0;i<width+2;i++) 
-    _putch(ACS_HLINE);
-  _putch(ACS_URCORNER);
-
-  for (i = 0;i<nitems;i++) {
-      gotoxy(x,y+i+1);
-      _putch(ACS_VLINE);
-      _putch(' ');
-      if (i == itemno)
-        textattr(YELLOW);
-      s = 0;
-      for (j=0;j<width;j++) {
-        if (s && *s)
-          _putch(*s++);
-        else _putch(' ');
-        if (s == 0)
-          s = (ROMDEF char *)menu[i];
-      }
-       textattr(CYAN<<4 | BLACK);
-      _putch(' ');
-      _putch(ACS_VLINE);
-  }
-
-  gotoxy(x,y+nitems+1);
-  _putch(ACS_LLCORNER);
-  for (i=0;i<width+2;i++) 
-    _putch(ACS_HLINE);
-  _putch(ACS_LRCORNER);
-
-  
-  while (!_kbhit()) ;
-  
-   if (_kbhit()) {
-     keys[0] = keys[1];
-     keys[1] = keys[2];
-     keys[2] = _getch();
-     if (keys[0] == 0x1b && keys[1] == 0x5b)
-     {
-        switch (keys[2]) {
-          case 'A': if (itemno>0) itemno--;  else itemno = nitems-1; break;
-          case 'B': itemno++; itemno %= nitems; break;
-        }
-     }
-     else
-         switch(keys[0]) {
-          case KB_ENTER : cursoron(); return itemno+1;
-          case KB_ESC: cursoron(); return 0;
-         } 
-   } 
-  }
-}
-
-
-
-void drawfkeys(ROMDEF char *fkeys[])
-{
- ROMDEF char *s;
- int i, j;
-
- gotoxy(1,25);
- for (i=0;i<10;i++) {
-   textcolor(WHITE);
-   textbackground(BLACK);
-   if (i!= 0)
-    _putch(' ');
-   if (i== 9) {
-    _putch('1');
-    _putch('0');
-   } else
-   _putch((i%10)+'1');
-   textcolor(BLACK);
-   textbackground(CYAN);
-
-  s = fkeys[i] ? fkeys[i] : 0;
-  for (j=0;j<6;j++) {
-   if (s && *s)
-    _putch(*s++);
-   else _putch(' ');
-  }
- }
-}
-
-void drawframe(int x, int y, int width, int height, int color)
-{
-  int i,j;
-  
-  textattr(color);
-  gotoxy(x,y);
-  
-  _putch(ACS_ULCORNER);
-  for (i=0;i<width+2;i++) 
-    _putch(ACS_HLINE);
-  _putch(ACS_URCORNER);
-  
-  for (i = 0;i<height;i++) {
-      gotoxy(x,y+i+1);
-      _putch(ACS_VLINE);
-      _putch(' ');
-   
-   for (j=0;j<width;j++) {
-        _putch(' ');
-      }
-          _putch(' ');
-      _putch(ACS_VLINE);
-  }
- 
-  gotoxy(x,y+height+1);
-  _putch(ACS_LLCORNER);
-  for (i=0;i<width+2;i++) 
-    _putch(ACS_HLINE);
-  _putch(ACS_LRCORNER);
-}
\ No newline at end of file
diff -r 6c1bc9b3a347 -r e0c613cee738 main.cpp
--- a/main.cpp	Mon Apr 19 20:20:10 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,378 +0,0 @@
-/*
-    main.c
-    Main demo file. Using conio functions to display demo userinterface.
-    Part of MicroVGA CONIO library / demo project
-    Copyright (c) 2008-9 SECONS s.r.o., http://www.MicroVGA.com
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "conio.h"
-#include "kbd.h"
-#include "ui.h"
-
-#ifdef AVR_MCU  //WinAvr - AVR MCU - has to be defined in project settings
-#define LOWMEM 1
-#endif
-
-#ifdef __ICC78K__
-#define LOWMEM 1
-#endif
-
-#if RENESAS_C //Renessa High performance Emb. Workshop- has to be defined in project settings
-#define LOWMEM 1
-#endif
-
-#ifndef LOWMEM
-#include "aa.c" //ascii art
-#endif
-
-extern void MCU_Init(void);
-
-
-/*const static char *nc_fkeys[10] = 
-{"Help","Menu","View","Edit","Copy","RenMov","Mkdir","Delete","Setup","Quit"};
-*/
-
-ROMDEF static char *memview_fkeys[10] = 
-{"Help",0,0,0,"DynMem",0,0,0,0,"Quit"};
-
-ROMDEF static char *mainmenu[] = 
-{ 
-  "Memory viewer",
-  "Console debug demo",
-  "Speed test",
-  "Test sub menu",
-  "Command line interface",
-  "ASCII-Art test",
-  "Input dialog test",
-  0
-};
-
-ROMDEF static char *submenu1[] = 
-//far const rom char *submenu1[] = 
-{ 
-  "Menu item number 1",
-  "Menu item number 2",
-  "Some other menu",
-  "And finally last menu item",
-  0
-};
-
-const static char hexchars[] = "0123456789ABCDEF";
-
-void drawmem(const unsigned char *mem)
-{
-  const unsigned char *mptr;
-  int i,j;
-
-
- textbackground(BLUE);
- for (i=0;i<23 && !_kbhit();i++) {
-   mptr = &mem[i*16];
-   gotoxy(1,i+2);
-   textcolor(YELLOW);
-   j = 8;
-   do {
-     j--;
-     _putch(hexchars[  (((int)mptr)>>(j*4)) &0xF] );
-   } while (j>0);
-   _cputs(":  ");
-   textcolor(WHITE);
-
-   for (j=0;j<16;j++) {
-     _putch(hexchars[*mptr>>4]);
-     _putch(hexchars[*mptr&0xF]);
-     mptr++;
-     _putch(' ');
-     if (j == 7) {
-       _putch('-');
-       _putch(' ');
-     }
-   } 
-
-   _putch(179);
-   _putch(' ');
-
-   mptr = &mem[i*16];
-   for (j=0;j<16;j++) {
-     if (*mptr >= ' ')
-     _putch(*mptr);
-      else _putch('.');
-     mptr++;
-   } 
-
-   clreol();   
- }
-}
-
-
-void memviewer(void *start)
-{
-#ifndef LOWMEM
- int key;
- const unsigned char *mem;
-
- textattr(LIGHTGRAY  | BLUE <<4);
- clrscr();
- textcolor(BLACK);
- textbackground(CYAN);
- _cputs("Memory viewer");
- clreol();
-
- cursoroff();
- drawfkeys(memview_fkeys);
-
- mem=(const unsigned char *)start;
- for (;;) {
-   drawmem(mem);
-
-   if (_kbhit()) {
-     key = _getch();
-     switch(key) {
-      case KB_LEFT: if ((int)mem > 0 ) (int)mem--; break;
-      case KB_RIGHT: mem++; break;
-      case KB_UP: if (mem >= (unsigned char const *)16) mem-=16; break;
-      case KB_DOWN: mem+=16; break;
-      case KB_PGUP: if (mem >= (unsigned char const *)(16*23))  mem-=16*23; break;
-      case KB_PGDN: mem+=16*23; break;
-      case KB_F10: cursoron(); return ;
-     } 
-   }
-
- }
- #else
-  textattr(LIGHTGRAY);
-  clrscr();
-  _cputs("Not enought memory for this feature");
-    
-   while (_getch() != KB_ESC);
- #endif
-}
-
-void debugdemo()
-{
- int key;
-
- textattr(LIGHTGRAY);
- clrscr();
-
- while (1) {
-    _cputs("Debug line 1\r\n");
-   if (_kbhit()) {
-      key = _getch();
-      _cputs("You have pressed key");
-      _putch(key);
-      _cputs("\r\n");
-      if (key == KB_ESC)
-       return ;
-   }
- }
-}
-
-
-void cli()
-{
-    char buffer[40];
-    char * out;
-
-    textattr(LIGHTGRAY);
-    
-    clrscr();
-    
-    while (1) {
-      //read data
-      buffer[0]=40;
-       
-      textattr(YELLOW);
-      _cputs("uVGA> ");
-      textattr(LIGHTGRAY);
-      out=_cgets(buffer);
-      
-      if (out != 0 && out[0] == 'q' && out[1] == 0)
-        return ;
-      
-      textattr(WHITE);
-      _cputs("\r\nUnsupported command. Only ");
-      textattr(LIGHTRED);
-      _cputs("q");
-      textattr(WHITE);
-      _cputs(" (exit) is supported.\r\n");
-    }
-}
-
-
-void speedtest(void)
-{
-  unsigned int i;
-
-  gotoxy(1,1);
-  textattr(GREEN<<4 | YELLOW);
-
-  for (i=0;i<50000;i++) {
-    _cputs("TEST50=>");
-    _putch(((i/10000)%10) + '0');
-    _putch(((i/1000)%10) + '0');
-    _cputs("\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08");
-  }
-}
-
-
-void submenutest()
-{
-int item;
-
- item = 0;
-
- while (1) {
-
-    item = runmenu(8,10, submenu1, item);
-    switch (item) {
-        case 0: return ;
-    }
- }
-}
-
-
-void ascii_art()
-{
- #ifndef LOWMEM
-     textattr(LIGHTGRAY);
-     clrscr();
-   
-//    _cputs((const char *)ascii_art_str);
-    
-     while (_getch() != KB_ESC);
- #else
-         textattr(LIGHTGRAY);
-     clrscr();
-    _cputs("Not enought memory for this feature");
-    
-     while (_getch() != KB_ESC);
- #endif
-}
-
-void testCGetS()
-{
-        char buffer[40];
-        char * out;
-        int i;
-             
-        //draw input dialog (frame)
-        drawframe(10, 10, 40, 9, WHITE  | RED <<4);
-        gotoxy(12,12);
-        _cputs("Enter your name:");       
-        gotoxy(12,14);
-        textattr(WHITE  | BLACK <<4);
-        for (i=0;i<40;i++)
-          _putch(' ');
-        
-        //read data
-        gotoxy(12,14);
-        buffer[0]=40;
-         
-        out=_cgets(buffer);
-        
-        //write read data
-        gotoxy(12,16);
-        if (buffer[1]==0)
-        {
-             textattr((WHITE | RED <<4)|BLINK);
-            _cputs("You didn't enter your name!");
-        }
-        else
-        {
-             textattr((WHITE | RED <<4));
-            _cputs("Your name is:\n");
-            gotoxy(12,17);
-            _cputs(out);
-        }
-        cursoroff();
-
-        gotoxy(23,19);
-        textattr((WHITE | RED <<4)|BLINK);
-        _cputs("PRESS ESC TO EXIT");
-        
-        //wait for ESC press
-        while (_getch() != KB_ESC);
-}
-
-#ifndef LOWMEM
-static ROMDEF char *uvga_logo=
-"        ##    ##   ####     #   "
-"        ##    ##  ##  ##   ###  "
-"        ##    ## ##    #  ## ## "
-" ##  ## ##    ## ##      ##   ##"
-" ##  ## ##    ## ##      ##   ##"
-" ##  ## ##    ## ## #### #######"
-" ##  ## ##    ## ##   ## ##   ##"
-" ##  ##  ##  ##  ##   ## ##   ##"
-" #####    ####    ##  ## ##   ##"
-" ##        ##      ### # ##   ##"
-" ##    MicroVGA demo application"
-"##                              "
-"www.MicroVGA.com, www.secons.com";
-#endif
-
-void main()
-{
- int i,j;
- int item;
-
-//////////// Main routine
-
- MCU_Init();
-
-
- item = 0;
-
- while (1) {
-    
-     textbackground(BLUE);
-     clrscr();
-     textcolor(BLACK);
-     textbackground(CYAN);
-     _cputs("MicroVGA demo app");
-
-     clreol();
-     textbackground(BLUE);
-     textcolor(GREEN);
-
-
-#ifndef LOWMEM
-     // draw "logo"
-     for (i=0;i<13;i++) {
-        gotoxy(46,12+i);
-         for (j=0;j<32;j++) {
-            if (uvga_logo[i*32+ j] == '#')
-               _putch(219); 
-            else _putch(uvga_logo[i*32+ j]);
-         }
-     }
-#endif
-
-
-    item = runmenu(5,5, mainmenu, item);
-    switch (item) {
-      case 1:  memviewer(0); break;
-      case 2:  debugdemo(); break;
-      case 3:  speedtest(); break;
-      case 4:  submenutest(); break;
-      case 5:  cli(); break;
-      case 6:  ascii_art(); break;
-          case 7:  testCGetS(); break;
-          
-    }
- }
-}
diff -r 6c1bc9b3a347 -r e0c613cee738 mbed.bld
--- a/mbed.bld	Mon Apr 19 20:20:10 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0