Shop OBEX P1 Docs P2 Docs Learn Events
Mouse problems with the Propeller — Parallax Forums

Mouse problems with the Propeller

doverdover Posts: 9
edited 2011-03-09 00:15 in Propeller 1
I have been having no success with more than one mouse on the propeller proto board. The schematics say that the mouse pins are the same for both the demo and proto board, yet I have tried programs written for the demo board with no success. The program below was written in C using the Image Craft Propeller compiler. It loops, and scanning for a mouse each time, and displays the result of the search on the screen. According to the mouse.h header file, a 0 will be returned if no mouse is found, which is what I always get. I have tried the sample SPIN programs that come with the Propeller Tool spin compiler without success. Does anyone have any ideas, since I have tried several programs, and two different PS2 mice? I will not be able to answer any posts for about a week.


#include <stdio.h>
#include "mouse.h"
#include "vga_text.h"
#define VGA_TEXT_SCREENSIZE (900 * 1440)


int mouse = 0;
int buttons = 0;
int save = 0;
int xt;


void main(void)
{
vgaText_start(16);






while(1)

{
vgaText_setCurPosition(0, 10);
vgaText_dec(mouse);
printf("\b\b\b%d", mouse);
vgaText_setColors(6);

mouse_start(24, 25);

mouse = mouse_present();

}
}

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-02-25 04:46
    #include <stdio.h>
    #include "mouse.h"
    #include "vga_text.h"
    
    #define  VGA_TEXT_SCREENSIZE (900 * 1440)
    
    int mouse   = 0;
    int buttons = 0;
    int save    = 0;
    int xt;
    
    void main(void)
    {
        vgaText_start(16);
    
        while(1)
        {
            vgaText_setCurPosition(0, 10);   
            vgaText_dec(mouse);
            printf("\b\b\b%d", mouse);
            vgaText_setColors(6);
    
            [COLOR="red"]mouse_start(24, 25);
            mouse = mouse_present();[/COLOR]
        }   
    }
    
    If the C driver is anything like the SPIN version then this is getting you nowhere. The mouse driver is started inside an endless loop. Meaning it stops any running driver and (re)starts itself. Starting a cog takes about 8K cycles (in the background). You call mouse_present() while the driver isn't even up yet resulting in 0 being reported (repeatedly).

    If the initial assumption is true I'd suggest moving the mouse startup next to the vgaText startup call. What did your SPIN test code look like?
  • doverdover Posts: 9
    edited 2011-02-28 16:21
    That was a good idea that you had, and I can see how that could have been the problem, yet it didn’t solve the problem. I altered it like you recommend, as you will see below, and ran it with the same results as before. I even put a pause statement just before the While(1), so I could be sure the Propeller had enough time to load the mouse driver, but I still got the same results.


    The two programs that are attached are the sample SPIN programs that are included as examples for the Propeller Tool. When I run these programs, like the VGA_Tile_Driver_Demo2, the VGA text, etc, are displayed, and the yellow cursor even appears, but no matter how much you move the mouse, no action occurs. Note: The SPIN program VGA_Tile_Driver_Demo2 must have the .txt file, lincoln, in the same directory as SPIN program, when compiled.


    The mouse I am using, and tested on a PC, uses a laser, so you can easily tell if the mouse at least has power. The mouse always lights up as soon as the propeller receives power.






    [FONT=Courier New, monospace]
    #include <stdio.h>
    #include "mouse.h"
    #include "vga_text.h"
    #define VGA_TEXT_SCREENSIZE (900 * 1440)


    [/FONT][FONT=Courier New, monospace]int[/FONT][FONT=Courier New, monospace] mouse = 3;
    [/FONT][FONT=Courier New, monospace]int[/FONT][FONT=Courier New, monospace] buttons = 0;
    [/FONT][FONT=Courier New, monospace]int[/FONT][FONT=Courier New, monospace] save = 0;
    [/FONT][FONT=Courier New, monospace]int[/FONT][FONT=Courier New, monospace] xt;


    [/FONT][FONT=Courier New, monospace]void[/FONT][FONT=Courier New, monospace] main([/FONT][FONT=Courier New, monospace]void[/FONT][FONT=Courier New, monospace])
    {

    mouse_start(24, 25);

    vgaText_start(16);


    [/FONT][FONT=Courier New, monospace]while[/FONT][FONT=Courier New, monospace](1)

    {
    vgaText_setCurPosition(0, 10);
    vgaText_dec(mouse);
    printf(
    [/FONT][FONT=Courier New, monospace]"\b\b\b%d"[/FONT][FONT=Courier New, monospace], mouse);
    vgaText_setColors(6);

    mouse = mouse_present();




    }
    }
    [/FONT]
  • kuronekokuroneko Posts: 3,623
    edited 2011-02-28 16:58
    While initially written for the demoboard the listed program has been changed to send outa to the serial terminal. Can you run this and check whether there is any response at all from the mouse? The pattern should change for mouse type, movement and pressed buttons. Needless to say, this works for me (using a Parallax 3-Button mouse).
    CON
      _clkmode = XTAL1|PLL16X
      _xinfreq = 5_000_000
    
    OBJ
      serial: "FullDuplexSerial"
       mouse: "Mouse"
    
    PUB null | x, y, z, movement
    
      mouse.start(24, 25)
      serial.start(31, 30, %0000, 115200)
      waitcnt(clkfreq*2 + cnt)
      serial.tx(0)
      
    ' dira[16..23]~~                                        ' demoboard only
    
      repeat
        outa[16..17] := mouse.present                       ' type
        outa[19..23] := mouse.buttons                       ' buttons
    
        movement := x <> mouse.abs_x or y <> mouse.abs_y or z <> mouse.abs_z
        x := mouse.abs_x
        y := mouse.abs_y
        z := mouse.abs_z
    
        if movement
          !outa[18]
    
        serial.tx(1)
        serial.bin(outa[16..23], 8)                         ' display activity
    
    DAT
    
  • jazzedjazzed Posts: 11,803
    edited 2011-02-28 17:17
    If you can't get the SPIN demos to work, the C library won't work either.
    What type of mouse are you using? Only wheel mouse types are supported.
  • kuronekokuroneko Posts: 3,623
    edited 2011-02-28 18:27
    jazzed wrote: »
    Only wheel mouse types are supported.
    Can you elaborate? I just dug out an old Logitech 3-Button mouse which doesn't have wheels apart from the encoder and it works just fine (reported as type 1: 2 or 3 buttons).
  • jazzedjazzed Posts: 11,803
    edited 2011-02-28 19:01
    kuroneko wrote: »
    Can you elaborate? I just dug out an old Logitech 3-Button mouse which doesn't have wheels apart from the encoder and it works just fine (reported as type 1: 2 or 3 buttons).
    I could be confused with another project :-)
    I don't remember seeing any over-run handling in the PASM driver.
    The older 2/3 button mice make lots of bad packets.
  • doverdover Posts: 9
    edited 2011-03-08 15:16
    I got my problem solved. It was the proto board with the VGA and PS2 add-on module. I found that the needed pins on the PS2 connector in the module were never reaching the propeller! Thanks for everyone's time.
  • jazzedjazzed Posts: 11,803
    edited 2011-03-09 00:15
    dover wrote: »
    I got my problem solved. It was the proto board with the VGA and PS2 add-on module. I found that the needed pins on the PS2 connector in the module were never reaching the propeller! Thanks for everyone's time.
    Good to hear it works!
Sign In or Register to comment.