Shop OBEX P1 Docs P2 Docs Learn Events
C3+MikronautsVGA80+keyboard test program - Page 2 — Parallax Forums

C3+MikronautsVGA80+keyboard test program

2»

Comments

  • AribaAriba Posts: 2,690
    edited 2011-04-22 08:59
    if ( help  == buffer ) is the same as:
    if help[0] == buffer[0]
    
    so you compare the first character of the "strings" (they are not valid strings without an ending zero). As long as each command has a different first letter this works accidentally.

    You really need to follow the suggestions of Kuroneko. A string library from the OBEX may also help.

    Andy
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-04-22 11:14
    I set this up to use the strcomp, but it is not working for me, and I do not see what the problem is. When I type in 'help', 'dir', or 'cls' the program does not respond to the command. The key is, that when I hit enter, I want it to check the buffer, and respond accordingly. I would like somebody else to look at this, and tell me what I am missing.


    Thanks

    Ray
    '' PropOS_C3.spin
    
    '' Version 0.0.1
    
    
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    
    
    STATUS_LED_BUS_MUX = 15
    
    PS2_DATA  = 26
    PS2_CLK   = 27
    
    ccnt = 32      '' Size of buffer[]
    
    VAR
    
    byte buffer[ccnt]
    long index
    
    OBJ
    
    
      vga        : "MikronautsVGA64.spin"   '' Program by William Henning
      kbd        : "keyboard_010.spin"
    
    
    PUB Main
    
    '' This is needed for the C3 init '''''
                                          '
      DIRA[STATUS_LED_BUS_MUX]:=1         '
      vga.start(16)                       '
    '''''''''''''''''''''''''''''''''''''''
    
      
      vga.cls    '' Clear the screen
    
      vga.str(string("This is the PropOS_C3 program!"))
      vga.out($0D)
      vga.str(string("Type 'help' for help!"))
      
      
    
      kbd.start(PS2_DATA, PS2_CLK)
    
      kbd.clearkeys
      vga.out($0D)            '' Newline
      vga.out(">")            '' Special char
      
      repeat
        get_keystring        '' The command line interface
               
        vga.blink(100)
        
    
    PUB get_keystring | c
    
      if (kbd.gotkey == TRUE)
         c:=kbd.key
         vga.out(c)
    
         if index < constant(ccnt-1)     '' This controls placement of char 
           buffer[index++]:=c            '' in the buffer array
    
      if c == $0D            '' Newline
    
        if strcomp(@help,@buffer{0})     
          vga.str(string("          Help"))
          vga.out($0D)
          vga.str(string("dir - Directory Listing"))
          vga.out($0D)
          vga.str(string("cls - Clear the screen"))
          vga.out($0D)
          
        if strcomp(@dir, @buffer{0})      '' dir
          vga.str(string("Future 'DIR' listing."))
          vga.out($0D)
          
        if strcomp( @cls, @buffer{0} )      '' cls
          vga.cls
          vga.gotoxy(0,0)
            
        ''vga.str(string("Local Buffer: "))
        ''vga.str(@buffer{0})                '' This prints the buffer contents
        index~                             '' Reset the index
        bytefill(@buffer{0}, 0, ccnt)      '' This zeros out @buffer
        
       vga.str(string("No such command"))
       vga.out($0D)
       vga.out(">")
      
    
    DAT
    help byte "help",0
    dir byte "dir",0
    cls byte "cls",0  
    
  • AribaAriba Posts: 2,690
    edited 2011-04-22 12:10
    your string buffer also contains the $0D as a character, so the compare can not be succesfull.
    Either you add the $0D also at he end of the keywords:
    DAT
    help byte "help",$D,0
    dir byte "dir",$D,0
    cls byte "cls",$D,0
    
    or you delete the $0D character before comparing starts:
    if c == $0D            '' Newline
         buffer[index-1] := 0
         ...
    
    And you need to indent the whole "if c == $0D " block, so that the test is only done when you got a key.

    Andy

    Edit: You know that all these {0} statements are only comments?
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-04-22 13:11
    Thanks Ariba for the good tips.

    The zip file below contains, what I am referring to as version 0.0.1. It responds to three commands: help, dir, and cls. I just added the dir command for the heck of it, I am not sure if I am ready to tackle the SD stuff, just yet. I could not get "No such command" to work correctly, so I will have to give it some more thought. Maybe I should try adding some color to CLI, not sure if color is implemented in the VGA64 driver. I am open for reasonable suggestions as to what PropOS_C3 should contain.

    Thanks

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-04-24 08:04
    Back to version 0.0.1, this time using the new VGA80 driver(s). In the VGA80 driver I have tested out the new functions that are in there, so far they work. The program is just a test of keyboard/VGA screen functionality, so it's just a simple program. So far the VGA80 driver(s) are holding up, no problems.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-04-24 09:52
    Attached is version 0.0.2, added some more functions to VGA80 driver(s). Added a few "commands" to the program, it all seems to behave as expected. This is using a 6.25MHz crystal, so it probably will not work on a different setup.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-04-25 05:09
    I can't seem to find a good source for the keyboard key codes, especially the function keys (F1 - F12), Ctrl, and Alt. I found some key codes, but they do not seem to work. In the C3 source I found the code for the Esc key, and some others, but none of the function keys. I have a chart that lists, for example, the F1 as $3B, but that does not work. So I am at loss here.

    Thanks

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-04-25 06:40
    Attached below is version 0.0.3. This version I have implemented a concept of a very crude version of an editor. Basically you type some stuff in, and then you use the '@' to display the contents of the buffer. The next step is to create a name for the file, and store the file. For this concept I will be using the upper part of the EEPROM. Has anybody created an EEPROM disk? I will be referring to this as dira, and the SD will be referred to as dirc. Now comes the hard part, getting the name of the file to EEPROM, storing the file to EEPROM, and then being able to access the file, by name, off of the EEPROM.

    As for the keyboard key codes, I think the keyboard driver sets the keyboard up as an XT model, meaning no function keys, keypad, or other special keys. I guess I need a keyboard expert to figure this one out.

    Ray
  • AribaAriba Posts: 2,690
    edited 2011-04-25 16:56
    Rsadeika

    You find all keycodes described at the end of the Keyboard object source code.
    Generally the documentation of an object is integrated in the source with special comments. If you click on "Documentation" in the PropellerTool under the Tabs, you get this description comments extracted as an own file.

    Andy
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-04-26 05:00
    I created a quick and dirty utility program for obtaining the keycodes. The program below, you just press a key on the keyboard, and the program will display the decimal and hex codes. This resolves my issue with finding the keycodes. Of course this is for a C3 setup.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-04-27 05:36
    I decided to create the editor as a stand alone object, which is pedit.spin. Hopefully I will be able to call it from within the PropOS program, and have it function the way I want to.

    Pedit .spin is a concept program, so it lacks a lot of stuff. I have not provided a way of naming and storing the file, so for the time being, all it does is capture the input, and at quit time displays what is in the buffer before it quits.

    The program is still not complicated, code wise, so I think the beginners can still pretty much follow as to what is going on. That is why I am posting it.

    Some prelim concerns:
    I still cannot get the backspace to work correctly, as it concerns the buffer, some guidance would be appreciated.
    When the buffer gets dumped, it is not displaying within pedit framework.

    Next I will be implementing the SD portion , so I can start working on naming and storing the file.

    Ray
Sign In or Register to comment.