V5.07.00 has major new functionality to make your programming easier including full mouse integration into the filemanager and editor.
First PS2 mice are now supported connected directly to the CMM2. Many current USB mice still support the PS2 protocol and the current Microsoft Basic Optical Mouse is fully tested and recommended.
To make the connection the mouse clock line is connected to pin 33 of the CMM2 and the mouse data to pin 32. Both lines MUST be pulled up to 5V with 4K7 resistors
You can use exactly the same commands and functions to access and use a PS2 mouse as the Hobbytronic mouse except that the channel number for the PS2 mouse is zero

CONTROLLER MOUSE OPEN 0 [,[leftclickinterrupt] [,rightclickinterrupt] [,sensitivity]

Note the new optional sensitivity parameter. This allows you to tune the sensitivity of the Hobbytronic mice I/F by specifying a number between 0 and 10. 
0 indicates that the default automaitic sensitivity should be used. Other values will explicitly set the sensitivity as per the Hobbytronic documentation.
For the PS2 mouse the sensitivity can be set between 0 and 8. 
Values of 1-4 set the resolution of the mouse to 1,2, 4 or 8 counts/mm. Values 5-8 do the same but in addition enable mouse scaling which gives a non-linear relationship between speed and count. 
See https://isdaman.com/alsos/hardware/mouse/ps2interface.htm for more details. NB: not all PS2 mice seem to implement these commands.
New sub-functions
MOUSE( T, 0) This tells you if a PS2 mouse has a scroll wheel (returns 3) or not (returns 0). Only works for PS2 mice (channel 0). 
For Hobbytronic mice will always return 0
MOUSE( D [,channel])
This allows you to detect a double click of the left mouse button and works for both the PS2 and Hobbytronic mice. 
The algorithm say the two clicks must occur between 100 and 500 milliseconds apart. 
The report via MOUSE(D) is then valid for 500mSec before it times out or until it is read.

In order to use a mouse in the filemanager and editor you need to tell the firmware to expect a mouse to be available:
OPTION MOUSE channel [,sensitivity]
This says that a mouse is connected to the specified channel (use channel 0 for a PS2 mouse) and the filemanager and editor will then expect and use the mouse. 
To disable the mouse in the editor and filemanager use:
OPTION MOUSE OFF

You can enquire the status of the mouse option using MM.INFO(OPTION MOUSE) - reports -1 if no mouse is specified.
The mouse works as you would expect in both applications:

In the filemanager you can:
Left click on a line to position the cursor.
You can use the wheel to scroll up and down the file list
Right click in the top half of the screen to page up
Right click in the bottom half of the screen to page down
Double click to open/run a file (same as typing CR)
If you open an image you can return to the filemanager by left clicking the mouse.


In the editor you can:
Left click to position the edit cursor.
Scroll wheel to move up and down
Left click and hold down then move cursor to a new position and release the left button. The enclosed area will be selected for cut and paste.
Within cut and paste mode you can use the cursor and wheel to change the selection
To exit cut and paste without doing anything right click
Right click in top area of screen to scroll up (except in select mode)
Right click in bottom of screen to scroll down (except in select mode)
Left click at far left to scroll horizontally one character if the screen is scrolled horizontally
Left click at far right to scroll horizontally one character if the line is too long for the display
Double left click at far left to scroll to beginning of line if the screen is scrolled horizontally
Double left click at far right scroll horizontally to the end of line if the line is too long for the display
GUI BITMAP command restored as per MM2/ArmmiteF4 
Fixes bug in CSUBs when used with OPTION RAM
Fixes bug in 12-bit colour modes missing last column
Fixes bug in edit when using large fonts with low resolution
Initialises the fast counter properly when using SETPIN 18,CIN
Increases the maximum files in a directory to 2000
CLS now only clears the serial console when the write page os 1

GUI CURSOR x,y no longer displays the cursor if it is hidden - it just remembers the new location for a subsequent SHOW command
GUI BITMAP added, same syntax as the MM2
New facility for the fast count. You can now specify a Basic interrupt that will fire when the count exceeds &HFFFFFFFF. 
This allows you to trigger an interrupt when a specific number of counts have happened. 

New edit font OPTION EDIT FONT VERY LARGE for use with high resolution modes 
Changed the horrible serif font 3 to a different one that is the same size

New Sub-Commands 
BOX xxx_PIXELS x, y, w, h, colour [,pageno]
This executes the requested logical operation between the pixels in the area defined on the page specified (defaults to the write page) with the colour specified

This release also supports a json parsing function. The json string to be parsed must be loaded into a LONGSTRING array
JSON$(array%(),string$) Returns a string representing a specific item out of the JSON input stored in the longstring array%()
e.g.
JSON$(a%(), "name")
JSON$(a%(), "coord.lat")
JSON$(a%(), "weather[0].description")
JSON$(a%(),"list[4].weather[0].description
Examples taken from api.openweathermap.org

New Sub-commands
SAVE DATA fname$, address, size 'saves "size" bytes to file "fname$" starting from "address"
LOAD DATA fname$, address 'loads the contents of file "fname$" and stores it in memory starting at "address"

Allow the user the ability to select which page(s) are displayed on the screen
Syntax is:
PAGE DISPLAY n [,page]
Normal example of use is:
PAGE DISPLAY 3. This says show on the screen the current contents of page 3. 
The command does not impact the current write page
In 12 bit mode you can also use:
PAGE DISPAY 4,1
This sets the page to display for the top layer
The command executes in the next screen blanking period. When a program ends for any reason the normal display page 0 is restored
Note for modes 3 or 5 or 6 or 7 or 12 or 13 you can only select pages 0 or 1 for display in 8 or 16 bit colour and pages 0, 1, or 2 in 12-bit colour

To turn the display off use PAGE DISPLAY -1. To turn it back on select a valid display page. This command is only valid in a program.

A new mode 14 is introduced which has the timings for 540P, same 960x540 as mode 12 but with no line duplication. If your monitor can handle it this is the best default mode for a widescreen monitor

New OPTION: OPTION SLEEP n
n is the number of minutes (0-255) before the monitor is turned off when at the command line. Set to 0 to disable. Any keypress will wake the monitor

Program profiling capability
To turn on or off the profiling use
OPTION PROFILING ON
OPTION PROFILING OFF
This is a permanent option but it defaults to OFF whenever new firmware is loaded. 
With profiling on you will see a performance impact of about 5% caused by the profiling data collection which happens at the MMBasic statement level. 
In addition you will see a reduction in available variable RAM of 512KB. Note that profiling and OPTION RAM are mutually incompatible.
With profiling enabled you can run your programs as usual and you should see no change in behaviour other than as mentioned above. You can see the way the program has run using the commands
LIST PROFILE
LIST PROFILE CSV
There are 5 comma-separated fields in the output
The first field is the number of times a given statement has been run
The second field is the average time in Microseconds taken to execute the statement
The third field is the crunched statement as stored in memory. This is quoted to make it easier to load into excel etc.
The fourth field is the filename in which the statement appears. This is blank if the statement is in the main program, otherwise it gives the filename of the include file in which the statement is to be found
The fifth and final field gives the line number of the statement in the source file.
When LIST PROFILE CSV is used a file is created in the same directory as the main program with the .BAS extension replaced with .CSV
LIST PROFILE can only be used at the command line
LIST PROFILE CSV can be used in a program allowing you to create and rename multiple files while a program is running if required

new operator for signed shift right
integervariable>>n' for unsigned shift right
integervariable>>>n' for signed shift right

A new fast settick mode is now available:

SETTICK FAST frequency, interruptroutine
This allows you to exceed the current maximum rate of 1 interrupt per millisecond (1000HZ) and has been tested up to 50KHz. 
Obviously if the interrupt routine overruns the time available then interrupts will be lost. 
If the program is executing a statement that takes longer than the time between interrupts the interrupts will be stacked.

Enhancement is to allow you to select the serial port to be used as the console.
OPTION CONSOLE PORT n
n can be 1, 2, or 3 (default). If this option is set all console output is directed to the specified com port. This allows easier remote operation using a wifi-uart or radio link. 
Previously you would have had to remove the MCP2221A chip and connect the external I/F to the USB-B connector. 
If the option is set to other than default then COM3 is available on the USB-B connector. 

New directive to allow multi-line comments. The command must be in capitals. Any lines between the two commands are completely ignored and not loaded into memory
#COMMENT START
#COMMENT END

MATH SENSORFUSION routine added for calculating yaw, pitch and roll from 9-DOF sensors such as the MCU-9250

The map function gives the RGB332 colour that is used internally to map to the CLUT. So map(255) always gives &He0e0c0 which the firmware then converts to 255. It is just a way of allowing you to select the normal colour that will find the place in the CLUT you want. It is not a window into the CLUT
BASE$( base, number [, chars])  
DAY$ and EPOCH functions now accept

"DD-MM-YY"
"DD-MM-YYYY"
and
"YYYY-MM-DD"
new mode 15 1280x1024 
new mode 16 1920x1080 G2 only
list pages
Improved accuracy of PAUSE command

Bugs fixed
Bug in getscanline when mode 1 is set at the beginning of a program and the default mode is also mode 1. 
Inconsistency in manual for PAGE COPY. Transparent mode is initiated with T not 1 as specified in the manual. 
Static variables with the same name in different subroutines conflict when used in an interrupt routine. 
Bug when returning to the filemanager from displaying images in some DEFAULT MODEs 
Typo in ARMCFunctions.h 
TRACE LIST only shows 63 lines and TRACE LIST n only shows half the number of lines requested
ON KEY key,interrupt operation does not match manual. 
SETPIN 18,CIN does not zero the counter. 
SPRITE HIDE SAFE does not give an error if an attempt is made to hide a non-active sprite. Doing this corrrupts the sprite structures and will then give an INTERNAL ERROR message. 
BUG in FRAMEBUFFER WINDOW when the write page is the framebuffer. 
Memory leak in SPITE LOAD. This will only be seen if you repeatedly load very large sprites. 

Known issues
Putting a call to the ERROR command on the same line as a CASE clause after a colon will not output the line information with the error string. Workround: put the ERROR statement on its own line.
