V5.07.07RC8
Various bug fixes
New command SYNC
SPRITE SHOW (SAFE) can now optionally show BLACK by setting bit 2 in the option parameter

V5.07.07RC7
Various bug fixes

V5.07.07RC6
Bug fix to LOAD JPG
Error now generated by  CAT/INC command when arrays exceed 255
Optimisations for PLAY WAV and PLAY SOUND when left and right channels are the same or (SOUND only) inverted
WebMite can now overclock to 378MHz
Overhead of changing volume or type of sound for PLAY SOUND can now be removed using OPTION FAST AUDIO ON/OFF in a program - defaults to OFF
Interrupt frequency for Audio now reduced to max of 44100 or WAV/FLAC frequency irrespective of CPU speed

V5.07.07RC5
Various bug fixes to file handling edge cases
Improved performance of PLAY SOUND when left and right channels are the same
New parameter for OPTION SYSTEM I2C
OPTION SYSTEM I2C sdapin, sclpin [,SLOW/FAST]
By default the I2C port is opened at a speed of 400KHz and with a 100mSec timeout. The I2C frequency can be set using the optional third parameter which can take the values FAST = 400KHz or SLOW = 100KHz


V5.07.07RC4
Fixes bug in PIO functions when in-built functions are used as arguments
Fixes memory leak in FLAC player
Allows &H, &B, &O syntax in "side" parameter in PIO ASSEMBLE
Correctly executes the library when leaving the editor with F2

V5.07.07RC3
Fixes bug in editor in VGA version not showing cursor
Enhancements to WEB SCAN: 
  Duplicates no longer shown
  WEB SCAN [array%()]
  Optionally sends the output to a long string
TRACE command is now Library aware. The test for the Library is corrected when TRACE ON is applied, for TRACE LIST, [Lib] is shown for the line number in the library.
LIBRARY command can now be use in compound statements allowing better use in programmable functions

V5.07.07RC2
Fixes bug in DATA/READ statements in the library
Change to using a MCP48n2 DAC for audio output
OPTION AUDIO SPI CSpin, CLKpin, SDIpin
Tie LDAC to GND

V5.07.07RC1
Fixes bug in PLAY SOUND when switching from B to L or R
Implements PLAY FLAC - same as PLAY WAV but for FLAC files

V5.07.07b34/ Web version 5.07.07b4

LIBRARY LIST ALL implemented
Support for mono output in PLAY SOUND
PLAY SOUND chan, M, waveform, freq [,vol]
When M is set the right channel is set to to be the invert of the left
Support for user load sound profiles
Use PLAY SOUND LOAD array%() to load a sound
array%() must be a 1024 element array loaded with 4096 16-bit sound levels between 0 and 4095
Use PLAY SOUND chan, L/R/B, U, freq to output the loaded sound
Array%() is easily created from a normal 4096 element array using
MEMORY PACK inarray%(),array%(), 4096, 16

V5.07.07b33/ Web version 5.07.07b3

Support for MCP4822 DAC (8 pin version) for audio output
USE:
OPTION AUDIO SPI CSpin, LDACpin, SCKpin, SDIpin
to enable this. NB: SCKpin and SDIpin must be valid SPI TX and CLK pins as per the manual. The SPI channel is dedicated to the DAC and can't be shared. This mode will also use the PWM channel associated with the CLK pin chosen.
e.g OPTION AUDIO SPI GP0, GP1, GP2, GP3 uses SPI and PWM 1
USE standard syntax for PWM AUDIO output

b33/b3 also changes the frequency used for PWM and SPI output for audio as follows

CPU frequency 48-251MHz - 44100Hz
CPU frequency 252-377MHz - 88200Hz
CPU frequency 378MHz -132300Hz


V5.07.07b31/ Web version 5.07.07b1
Support for i2c keyboard https://shop.pimoroni.com/products/bbq20-keyboard-with-trackpad-usb-i2c-pmod
Set OPTION SYSTEM I2C if not already set
Connect the keyboard to the system I2C lines
Then set OPTION KEYBOARD I2C
Keys along the top are programmed as ESC, F1, F2, F3, CTRL
To use the editor see the manual for the control keys that are used for forward, backwards etc.

V5.07.07b30
The LIBRARY commands, LIBRARY SAVE, LIBRARY DELETE and LIBRARY LIST are implemented with the same functionality as the Micromites.
The Library commands can only be run at the command prompt.
In the Micromites the Library inserts itself before the end of the main program area,reducing the available normal program area, but using what it takes more efficiently so resulting in better utilisation of the program area and also the library features.

In the Picomite implementation the Library uses the flash of the last Flash Slot (currently 4) so adds the library without reducing the program area. The use of the Library and the last Flash Slot are mutually exclusive. The first LIBRARY SAVE command will claim the Flash Slot if it is not in use. The FLASH command can claim slot 4 if it has not yet been used by the library.

When a program is run from the main program area any normal code in the library is run before the main program.The main program is then run and has access to any routines in the library.

Running a program stored in flash with FLASH RUN [1-3] will run any normal code stored in the Library before its main program, and the program will have access to any SUBs, FUNCTIONs,FONTs or CSUBs in the Library. The value returned by MM.Info(FLASH) will identify which slot the program is running from and can be used in the library to conditionally include or exclude Library code/routines.

Chaining a program stored in flash with FLASH CHAIN [1-3] will NOT run any normal code stored in the Library before its main program, however the program will have access to any SUBs, FUNCTIONs, FONTs or CSUBs in the Library. The value returned by MM.Info(FLASH) will identify which slot the program is chained from and can be used in the library to conditionally include or exclude Library code/routines.

FLASH LOAD [1-3] will load the program into the main program memory and will have access to any existing Library code.

FLASH [SAVE|ERASE|ERASE ALL|OVERWRITE|CHAIN|RUN] all respect the library if it has already claimed Flash Slot 4.

LIBRARY DELETE  will delete the library and return Flash Slot 4 for normal use.It also clears the program area.

OPTION RESET returns all Options to default, so will also delete the library and return Flash Slot 4 for normal use.

LIBRARY LIST will list the contents of the Library. The Library does not store comments or the HEX code for FONTs or CSUBs. A copy of the Library source should be kept externally or in one of the Flash Slots if you need to modify or recovered it.
e.g. Write your library code in the main program area. Back it up to a flash slot, FLASH SAVE 3. Your Library source is stored in Slot 3. Then do LIBRARY SAVE, the code in the normal program memory is now moved into the library (comments removed, HEX for Fonts and CSUBs removed) and the main program area cleared.
To modify the library, LIBRARY DELETE, FLASH LOAD 3 to get the source back, EDIT command to modify. FLASH OVERWRITE 3 to back it up, LIBRARY SAVE to put it into the Library or just keep it all in MMEdit.

LIBRARY SAVE is cumulative. i.e. Subsequent LIBRARY SAVEs will append whatever is currently in the main program area to the Library.

V5.07.07b28
Enhancements to PLAY SOUND to remove clicks and pops

Implements OPTION ESCAPE. 
This enables escape sequences in strings and must be used in any program where you want to use them. You will be able to also use it at the command prompt but like OPTION EXPLICIT it will be disabled again by the RUN command and so will need to be included in the program. This change will ensure that the new functionality won't break any existing programs.

Fixes bug introduced in an earlier beta in OPTION LCDPANEL SSD1963_n

PIO ASSEMBLE now accepts &B, &O, and &H for numeric values

V5.07.07b27
New "display" drivers
VIRTUAL_C and VIRTUAL_M

These are virtual drivers that allow you to use all the graphics routines without any display attached. In both cases a 38400 byte framebuffer is created when a graphics command is invoked for the first time. VIRTUAL_C is a 320x240 16 colour display and VIRTUAL_M is a 640x480 mono display.

Bug fixes for various numeric overflow conditions which now produce an error

New version of SAVE IMAGE for 1 and 4 bit/pixel displays. SAVE COMPRESSED IMAGE creates a BMP file but with run length encoding of the image data. This can result in a huge reduction in file size for graphics images (as compared to pictures). To work with this LOAD IMAGE has also been enhanced to support 16-colour BMP files with run length encoded data.

For normal string input and quoted DATA statements (but not unquoted DATA strings)

Implements

Escape sequence Hex value in ASCII Character represented
\a                           07                 Alert (Beep, Bell)
\b                           08                 Backspace
\e                           1B                 Escape character
\f                           0C                 Formfeed Page Break
\n                           0A                 Newline (Line Feed); see notes below
\r                           0D                 Carriage Return
\q                           22                 Quote symbol
\t                           09                 Horizontal Tab
\v                           0B                 Vertical Tab
\\                           5C                 Backslash
\nnn                       any                The byte whose numerical value is given by nnn interpreted as a decimal number
\xhh                       any                The byte whose numerical value is given by hh… interpreted as a hexadecimal number


V5.07.07b25Memory for PicoMite increased to 128Kb
Speed improvements for PicoMiteVGA
Fixed bug in using mono displays on PicoMite (introduced in previous beta)
Support for MM.CMDLINE$ in all versions (thanks Tom)


V5.07.07b24
Fixed bug in Triangle command not drawing border and fill in correct colours
Changes to flash access speeds to improve stability at cpu speeds > 200MHz
PicoMiteVGA changes:
BREAKING CHANGE
Tiles are now 8 pixels wide and not 16. The default tile height is 12 pixels to match font 1
new command
TILE HEIGHT n' n can be a number between 12 and 480.
in mode 1 colours can now be used with the text command. This will be applied if the character being 
written aligns with tile boundaries
e.g.
TILE HEIGHT 50
TEXT 8,50,"12:20:40",,,,rgb(red),rgb(green)
Colour editing is now available in Mode 1 with OPTION COLOURCODE ON set


V5.07.07b18
Update to SDK V1.5.
Number of flash slots reduced to 4
Fixes bug in previous beta when loaded over some other releases
ERASES ALL FLASH SLOTS AND THE FLASH DISK

V5.07.07b17
Wildcards for copy and kill
COPY fname$ to dirname$ ' the bulk copy is triggered if fname$ contains a '*' or a '?' character
dirname$ must be a valid directory name and should NOT end in a slash character

KILL fname$ [,all] ' the bulk erase is triggered if fname$ contains a '*' or a '?' character 
If the optional 'all' parameter is used then you will be prompted for a single confirmation
If 'all' is not specified you will be prompted on a file-by-file basis


V5.07.07b16
Added capability for inverted serial signals - use 'inv' in the OPEN command (same as MM2)
Improved memory allocation for PIO MAKE RING BUFFER
At the command prompt ONLY you can now use A: or B: to switch disk as well as DRIVE "A:" and DRIVE "B:" 
FILES command now deletes variable to avoid "Out of Memory" error
New command: AUTOSAVE APPEND ' appends the incoming serial data stream to the existing program. Perfect for adding library routines to new code


V5.07.07b15
Fixes bug in SETPIN
Adds support for 128x128 ST7735S display from Waveshare
use: OPTION LCDPANEL ST7735S_W, orientation, dcpin, resetpin, cspin [,backlightpin]

V5.07.07b14
Fixes bug introduced in I2C
Fixes instability introduced in B10

V5.07.07b11
New capabilities for PEEK function
peek(bp n%) ' returns the byte at address n% and increments n% to point to the next byte
peek(sp n%) ' returns the short at address n% and increments n% to point to the next short
peek(wp n%) ' returns the word at address n% and increments n% to point to the next word
PIO DMA TX and PIO DMA RX now allow up to &HFFFFFFFF transfers

V5.07.07b10
Change in timing for touch with SSD1963 displays to improve stability
New command
PIO assemble pio,linedata$
This command will assemble and load text based PIO assembler code including labels for jumps
Use: PIO assemble pio,".program anything" to initialise the assembler
Use: PIO assemble pio,".side_set n [opt] [pindirs]" if using side set. This is mandatory in order to correctly construct the op-codes is one or more side set pins are used.
It does not load the pinctrl register as this is specific to the state-machine.
Also note the "opt" parameter changes the op-code on instructions that have a side parameter
Use: PIO assemble pio,".line n" to assemble starting from a line other than 1 - this is optional
Use: PIO assemble pio,".end program [list]" to terminate the assembly and program the pio. The optional parameter LIST causes a hex dump of the op-codes to the terminal.
Use: PIO assemble pio,"label:" to define a label. This must appear as a separate command.
Use: PIO assemble pio "instruction [parameters]" to define the actual PIO instructions that will be converted to machine code

e.g.
PIO assemble 1,".program myprog" 'start the assembly
PIO assemble 1,".line 0"
PIO assemble 1,".side_set 1 opt pindirs"
PIO assemble 1,"do_nack:"
PIO assemble 1,"jmp y--  12"
PIO assemble 1,"irq wait 0 rel"

PIO assemble 1,"do_byte:"
PIO assemble 1,"set x,7"

PIO assemble 1,"bitloop:"
PIO assemble 1,"out pindirs,1 [7]"
PIO assemble 1,"nop side 1 [2]"
PIO assemble 1,"wait 1 pin,1 [4]"
PIO assemble 1,"in pins,1 [7]"
PIO assemble 1,"jmp x-- bitloop side 0 [7]"
PIO assemble 1,"out pindirs, 1 [7]"
PIO assemble 1,"nop side 1 [7]"
PIO assemble 1,"wait 1 pin, 1 [7]"
PIO assemble 1,"jmp pin do_nack side 0 [2]"

PIO assemble 1,"entry_point:"
PIO assemble 1,"out x,6"
PIO assemble 1,"out y,1"
PIO assemble 1,"jmp !x do_byte"
PIO assemble 1,"out null,32"

PIO assemble 1,"do_exec:"
PIO assemble 1,"out exec,16"
PIO assemble 1,"jmp x-- do_exec"
PIO assemble 1,".end program list"



V5.07.07b8
Fixes bug in PWM SYNC for channel 4
Fixes bug in PIO MAKE RING BUFFER that allowed it to overlap arrays defined before it
Fixes bug in use of SETPIN PWM on pins 19 and 20.

V5.07.07b7
Fixed formatting bug in GUI output of floats
Command name changes:
DMA RX was DMA_IN
DMA TX was DMA_OUT
MEMORY PACK and UNPACK now accept array specifications as per the manual or a memory address as previously 

V5.07.07b5
Another optional parameter for PIO DMA
PIO DMA_IN pio, sm, nbr, data%() [,completioninterrupt] [,transfersize] [,loopbackcount]
PIO DMA_OUT pio, sm, nbr, data%() [,completioninterrupt] [,transfersize] [,loopbackcount]
The optional parameter loopbackcount specifies how many data items are to be read or written before the DMA starts again at the beginning of the buffer
The parameter must be a power of 2 between 2 and 32768
Due to a limitation in the RP2040 if loopbackcounter is used the MMBasic array must be aligned in memory to the number of bytes in the loop (transfer size in bytes * number of transfers)
Thus if the array is 64 integers long which is 512 bytes then the array must be aligned to a 512byte boundary in memory
All MMBasic arrays are aligned to a 256 byte boundary but to create an array which is guaranteed to be aligned to a 512 byte boundary or greater a new sub command is used

PIO MAKE RING BUFFER ivar%, size

To use this command create a simple integer variable then call the command and it will be converted into an array of the size specified and aligned to the number of bytes specified.

e.g.
dim packed%
PIO MAKE RING BUFFER packed%,4096

packed% will then be an integer array holding 4096/8=512 integers
This can then be used by the DMA for a loopbackcounter with DMA of 1024 32-bit words, 2048 16-bit shorts or 4096 8-bit bytes

If a DMA is running you can abort it with

PIO DMA_IN OFF
PIO DMA_OUT OFF

Use
PIO(DMA RX POINTER)
PIO(DMA TX POINTER)
to return the current data item being written or read by the PIO

V5.07.07b4

Bug fix to PIO INTERRUPT not accepting 0 for TX interrupt

The new commands in this release are:
PIO DMA_IN pio, sm, nbr, data%() [,completioninterrupt] [,transfersize] [,loopbackcount]
PIO DMA_OUT pio, sm, nbr, data%() [,completioninterrupt] [,transfersize] [,loopbackcount]
In both cases:
pio specifies which of the two pio instances to use (0 or 1) NB: 1 only for the VGA version
sm specifies which of the state machine to use (0-3)
nbr specifies how many 32-bit words to transfer
data%() is the array that will either supply or receive the PIO data
The optional parameter completioninterrupt is the name of a MMBasic subroutine rthat will be called when the DMA completes and in the case of DMA_OUT the FIFO has been emptied.
If the optional interrupt is not used then the status of the DMA can be checked using the functions
MM.INFO(PIO RX DMA)
MM.INFO(PIO TX DMA)

The optional parameter transfersize allows the user to override the normal 32-bit transfers and select 8, 16, or 32.
The optional parameter loopbackcount specifies how many data items are to be read or written before the DMA starts again at the beginning of the buffer
The parameter must be a power of 2 between 2 and 32768
Due to a limitation in the RP2040 if loopbackcounter is used the MMBasic array must be aligned in memory to the number of bytes in the loop
Thus if the array is 64 integers long which is 512 bytes then the array must be aligned to a 512byte boundary in memory
All MMBasic arrays are aligned to a 256 byte boundary but to create an array which is guaranteed to be aligned to a 512 byte boundary or greater a new sub command is used

PIO MAKE RING BUFFER ivar%, size

To use this command create a simple integer variable then call the command and it will be converted into an array of the size specified and aligned to the number of bytes specified.

e.g.
dim packed%
PIO MAKE RING BUFFER packed%,4096

packed% will then be an integer array holding 4096/8=512 integers
This can then be used by the DMA for a loopbackcounter with 1024 32-bit words, 2048 16-bit shorts or 4096 8-bit bytes



V5.07.07b3

Bug fix to CHDIR for flash file system

V5.07.07b2

Fix bug in pixel drawing in PicoMite

V5.07.07b1

Bug fix to ON ERROR SKIP (thanks Tom)

New functions
MM.INFO(EXISTS FILE fname$) ' see CMM2 manual for details
MM.INFO(EXISTS DIR dname$) ' see CMM2 manual for details
PIN(FLEVEL pio [,sm, DIR]) ' dir can be RX or TX. If specified gives the level of the specific fifo
PIO (SHIFTCTRL push_threshold [,pull_threshold] [,autopush] [,autopull] [,in_shiftdir] [,out_shiftdir] [,FJOIN_RX] [,FJOIN_TX])
PIO CLEAR now clears all the FIFOs for the pio specified
PIO INIT and PIO START clear the specific FIFOs for the pio and sm specified

New Commands
NB: RX and TX are from the Basic code perspective
PIO INTERRUPT pio, sm [,RXinterrupt] [,TXinterrupt]
Use the value 0 for RXinterrupt or TXinterrupt to disable an interrupt
Omit values not needed
The RX interrupt triggers whenever a word has been "pushed" by the PIO code into the specified FIFO. The data MUST be read in the interrupt to clear it.
The TX interrupt triggers whenever the specified FIFO has been FULL and the PIO code has now "pulled" it
PIO interrupts have priority have keyboard interrupts but before anything else. As with all interrupts interrupt conditions are processed one at a time.
The PWM command is modified as follows:
PWM channel, frequency, [dutyA] [,dutyB] [,phase] [,deferredstart]
Phase is a new parameter that causes the waveforms to be centred such that a wave form with a shorter duty cycle starts and ends equal times from a longer one. Use 1 to enable this mode and 0 (or omit) to run as normal
The new parameter "deferredstart" when set to 1 prepares the PWM channels as before but does not start the output running. This is to avoid any undesirable startup artefacts
PWM SYNC [channel0offset] [,channel1offset] .......[channel7offset]
This initiates the PWM on channels where a deferred start was defined or just syncs exisitng running channels. However, the power comes in the ability to offset the channels one to another (defined as a percentage of the time period as per the duty cycle - can be a float)
You can use an offset of -1 to omit a channel from the synch