Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1638
Posted: 05:32am 19 Mar 2019
Copy link to clipboard
Print this post
Below is a program for the Colour Maximite to demonstrate the use of a mouse to operate on screen “buttons” and the use of “LEDs” to indicate status. The cursor is a sprite. I am using the Silicon Chip USB Keyboard & mouse adaptor with a USB mouse using the default settings but an old serial mouse will work.
The mouse part of the program was adapted from Raros’ program. Raros’ program did not make use of the 6th bit for the X and Y movement, I thought that could cause erratic movement of the cursor (by turning a large movement into a small one) but that did not seem to be a problem in practice. Instead, I have used a lookup table for the mouse movement using all 7 bits. Calculation of the lookup table incorporates a scaling factor (div) to slow the mouse down a bit if necessary. This can be changed in the program to suit the mouse. The mouse movement calculation has been moved out of the interrupt routine so that less time is spent in the interrupt.
The button part of the program was adapted for the Maximite from Geoff’s “Drawing Buttons” section of his “Getting Started with the Micromite” tutorial.
A right-click will display the cursor coordinates under the heading. Clicking on the ON button will turn the power LED on while the OFF button will turn it off. The ALM button will toggle the alarm condition from off to on, when on the alarm LED will flash. The CSR button will change the cursor, there are only two. The EXIT button will exit the program.
Mouse movement is disabled while a mouse button is clicked. This prevents artefacts appearing on a button due to the Maximite restoring the previous background colour behind the button if the cursor is moved.
The program will run without a mouse but of course you cannot move the cursor.
BillKeep safe. Live long and prosper.
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1638
Posted: 06:45am 19 Mar 2019
Copy link to clipboard
Print this post
It just occurred to me that someone might want to try this but doesn't want to bother with a mouse. I could make another version that uses the keyboard cursor keys to move the mouse. Say move 5 pixels with a cursor key press and 1 pixel with CTRL+key press. Enter to select and (say) the R key to right click.
Bill
Keep safe. Live long and prosper.
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 946
Posted: 10:16am 21 Mar 2019
Copy link to clipboard
Print this post
Very cool code! Thanks for sharing!!!
Frank
Raros Regular Member Joined: 06/02/2012 Location: ItalyPosts: 55
Posted: 02:27pm 21 Mar 2019
Copy link to clipboard
Print this post
Great. A good job.
Raros Edited by Raros 2019-03-23
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1638
Posted: 01:53am 22 Mar 2019
Copy link to clipboard
Print this post
Thanks for the kind comments and thank you again Raros for your original program.