PrimerMouse 1.2
A CircleOS application that uses the Primer as a mouse device

Code size:6 KB Author:lionel
Source files included:yes Version:1.2
Use circleOS:yes (1.6) Creation date:2007-10-23 13:59:43
Hardware modification:no Modification date:2009-09-10 08:18:03
Based on the STM32 Primer:All
Downloads:2434 Views:22306
Average ratings:3.01/5 (880 rates)

Download: (695 KB)


Revision 1.2 by Raisonance : 

Project source(s) were modified to ensure compatability with ST Library 3.1.

Revision 1.1 by Raisonance :

 Project source(s) were modified to ensure compatability with Primer2. The archive is updated with a Ride project adapted to Primer2.


please use the following command line to add the application to your CircleOS, and not the add_to_circle.bat file:

circle_mgr.exe AMouseLib.lib L S


IMPORTANT NOTE: CircleOS version 1.6 -or later- is required!!

1. General description

1.1. - Information

This project is almost a copy of the ST example 'JoystickMouse' provided with the ST USBLib. The Joystick commands have been replaced by the orientation information from the MEMS. The project has been modified to work as a CircleOS application.

Only the movements are managed. The button-clicks are not handled by this application.

There is not any "software" way to connect/disconnect the USB cable (an external transistor is used for this purpose on the ST demo board for the original JoystickMouse example). Thus, you must disconnect-reconnect the USB cable (on the USB port near the orange button) once you have launched the application.

1.2. - Project architecture

The application itself is presented in the form of a library: MouseLib.lib, which is linked (transformed into an executable file) using different methods depending on what you intend to do.

When you open 'PrimerMouse.rprj', you will notice two main nodes in the project tree:

  • 'MouseLib', the application code itself whose output is wrapped into a single library file;
  • 'MouseExe', an application node to help you debug the application.

If you want to share the application with others, all you need to provide is the 'MouseLib.lib' and 'add_to_Circle.bat' files. In that case, circle_mgr.exe will link your application correctly, load it into your Primer and register it in the CircleOS FAT.

If you use the 'MouseExe' application, the CircleOS and a default FAT will be loaded at the same time as your application in the debugger memory, and the resulting image programmed in the STM32-Primer Flash memory. Because the STM32-Primer Flash has been erased before, your application will be alone in your CircleOS. 'MouseExe' is intended to debug the application, and can also be used to check that the application links correctly.

2. Usage

2.1. - Add the application to you current CircleOS...

Don't forget that CircleOS v1.6 or greater is mandatory. Please update your CircleOS if your version is older.

You can use the pre-compiled library in the same directory as the readme.txt file by double-clicking on the 'add_to_Circle.bat' file present here.

Alternatively, you can compile the library yourself then add it to your Circle :

  • Open the project 'PrimerMouse.rprj'
  • Select the 'MouseLib' node, right-click on it and select 'Properties'
  • Go to 'CGG Compiler'->'Compiler Output' section and select 'No Debug' information
  • Close the Properties windows, right-click on 'MouseLib' and select 'Build'
  • Navigate to the 'MouseLib' directory and double-click on 'add_to_Circle.bat'.

2.2. - ... Or debug the application

To debug the application:

  • Open the project 'PrimerMouse.rprj'
  • Connect your STM32-Primer "Debug" min-USB connector to your PC and power up the Primer by pressing the button once
  • Check that 'MouseLib' is configured to use debugging information (in 'GCC Compiler'->'Compiler Output' properties)
  • Select the menu 'Project'->'Build Project'
  • Double-click the 'MouseExe' application. Once it is loaded, press the 'Run' button (or select the menu 'Debug'->'Run')

3. Suggestions

It would be good to improve this project! Several ideas:

a. At the moment, the mouse pointer movement is driven by the Primer orientation. It would be better to use the Primer position (movement detection) instead of the orientation.

b. Click and double-click could be implemented. The button could be used. In this case, another command (for example reversing the Primer (OutZ < 0), or holding down the button for a certain period) must be used to exit the application.