Show Menu
Cheatography

MMBasic Cheat Sheet (DRAFT) by

The BASIC commands for MMBasic. This does not include hardware specific commands and options. Get the manual for your specific hardware for those. This is just the BASIC keywords common across all platforms.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Keywords

'
Single line comment
/* ... */
Multi line comment
ADC FREQUENCY [freq]
This changes the sampling frequency of the ADC conversion without having to close and re-open
ADC CLOSE
Releases the pins to normal usage
ADC OPEN freq, n_chan­nels[, interrupt]
This allocates up to 4 ADC channels for use and sets them to be converted at the specified frequency
ADC START array1!() [,arra­y2!()] [,arra­y3!()] [,arra­y4!()] [,C1min] [,C1max] [,C2min] [,C2max] [,C3min] [,C3max] [,C4min] [,C4max]
This starts conversion into the specified arrays. The arrays must be floating point and the same size. ‘Cxmin’ and ‘Cxmax’ will scale the readings.
ADC RUN array1%(), array2%()
Runs the ADC contin­uously in double buffered mode.
ARRAY ADD in(), value, out()
This adds (or appends for strings) the value 'value' to every element of the matrix in() and puts the answer in out().
ARRAY INSERT target­arr­ay(), [d1] [,d2] [,d3] [,d4] [,d5], source­array()
This is the opposite of ARRAY SLICE
ARRAY SET value, array()
Sets all elements of array() to value
ARRAY SLICE source­arr­ay(), [d1] [,d2] [,d3] [,d4] [,d5] destin­ati­ona­rray()
This command copies a specified set of values from a multi-­dim­ens­ional array into a single dimens­ional array.
ARC x, y, r1, [r2], a1, a2 [, c]
Draws an arc of a circle with a given colour and width between two radials (defined in degrees)
AUTOSAVE [CRUNCH|APPEND]
Enter automatic program entry mode. CRUNCH removes all comments and whites­pace, APPEND appends to the end of the existing program
BIT(var%, bitno) = value
Sets the specified bit bitno in the 64-bit integer variable var% to value
BLIT READ [#]b, x, y, w, h
Will copy a portion of the display to the memory buffer '#b'. 32 buffers are available ranging from #1 to #32.
BLIT WRITE [#]b, x, y [,mode]
Will copy the memory buffer '#b' to the display. 32 buffers are available ranging from #1 to #32.
BLIT LOAD[BMP] [#]b, fname$ [,x] [,y] [,w] [,h]
Will load a blit buffer from a 24-bit bmp image file.
BLIT CLOSE [#]b
Will close the memory buffer '#b'
BLIT FRAMEB­UFFER from, to, xin, yin, xout, yout, width, height [,colour]
Copies an area of a specific ‘from’ frameb­uffer N, F, or L to another different ‘to’ frameb­uffer N, F, or L.
BLIT MEMORY address, x, y [,col]
Copies an area of memory treated as a packed array of colour nibbles to the current graphical output as specified by FRAMEB­UFFER WRITE
BLIT COMPRESSED address%, x, y [,col]
Acts the same as BLIT MEMORY but assumes the data is compressed and ignores the top bit in the width and height
BLIT x1, y1, x2, y2, w, h
Copy one section of the display screen to another part of the display
BOX x, y, w, h [, lw] [,c] [,fill]
Draws a box on the display with the top left hand corner at 'x' and 'y' with a width of 'w' pixels and a height of 'h' pixels
BYTE(var$, byteno­)=value
Sets byte byteno in string var$ to integer value value. value can be in the range 0- 255.
CALL usersu­bname$ [,user­sub­par­ame­ter­s,..]
Call subroutine usersu­bname$
CAT S$, N$
Appends N$ to S$
CHAIN fname$ [cmdline$]
Invokes program fname$ and keeps the variables intact
CHDIR dir$
Changes the current working directory to dir$
CIRCLE x, y, r [,lw] [, a] [, c] [, fill]
Draw a circle centered at x and y with a radius of r on the display
CLEAR
Delete all variables
CLOSE [#]fnbr [,[#]fnbr]
Closes the file(s) with the specified file number(s)
CLS [color]
Clears the screen
CMM2 LOAD|RUN
Loads and or runs a program from disk using the CMM2 program loading mechanism
COLOR fore [, back]
Sets the default color for commands that display on the screen
COLOUR MAP inarra­y%(), outarr­ay%() [,colo­urm­ap%()]
Generates RGB888 colors in outarray% from color codes (0- 15) in inarray%
CONFIGURE cfg
Configures a board as per the cfg specified equivalent of OPTION RESET
CONFIGURE LIST
Lists all the various config­ura­tions available for the firmware version
CONST id = expression [, id = expres­sion][, ...]
Creates constant identifier id and sets it to the value of expression. This value cannot be changed once set.
CONTINUE
Resume running a program that has been stopped by an END statement, an error, or CTRL-C
CONTINUE DO|FOR
Skip to the end of a DO/LOOP or a FOR/NEXT loop
COPY fname1$ TO fname2$
Copy file fname1$ to new file fnames2$
COPY fname$ TO dirname$
Wildcard copy. 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
CPU RESTART
Will force a restart of the CPUs. This will clear all variables and reset everything
CPU SLEEP n
Will cause the processors to sleep for n seconds
CSUB name [type][, type][, ...]
Defines the binary code for an embedded machine code program module written in C or ARM assembler.
END CSUB
Ends the CSUB definition
DATA constant[, consta­nt][, ...[
Stores numerical and string constants to be accessed by READ
DATE$ = "­DD-­MM-­YY[­YY]­" | "­DD/­MM/­YY[­YY]­" | ”YYYY-­MM-DD” | ”YYYY/­MM/DD”
Set the date of the internal clock/­cal­endar
DEFINEFONT #Nbr
This will define an embedded font which can be used alongside or to replace the built in font(s) used on an attached LCD panel.
END DEFINEFONT
Ends the font definition
DEVICE BITSTREAM pinno, n_tran­sit­ions, array%()
Generate an extremely accurate bit sequence on pin pinno
 

Predefined Read Only Variables

MM.VER
Returns the firmware version number
MM.CMD­LINE$
Returns any command line arguments passed to the current program
MM.DEVICE$
The device or platform that MMBasic is running on
MM.DISPLAY
Returns a 1 if a display is config­ured, else 0
MM.ERRNO
A non-zero value means an error occurred
MM.ERRMSG$
The error message
MM.FLAGS
Returns the system flags register
MM.FON­THEIGHT
Returns the height of the current font
MM.FON­TWIDTH
Returns the width of the current font
MM.HRES
Returns the horizontal resolution of the configured display
MM.VRES
Returns the vertical resolution of the configured display
MM.HEIGHT
Returns the number of characters high the configured display is with the current font
MM.WIDTH
Returns the number of characters wide the configured display is with the current font
MM.HPOS
Returns the current horizontal position
MM.VPOS
Returns the current vertical position
MM.INF­O$(­AUT­ORUN)
Returns the current setting of OPTION AUTORUN
MM.INF­O(ADC)
Returns the number of the buffer currently ready to read when using ADC RUN (1 or 2). Returns 0 if nothing ready.
MM.INF­O(ADC DMA)
Returns 1 if the ADC DMA is active
MM.INF­O(BOOT)
Tells you the reason of the last system restart
MM.INF­O(BOOT COUNT)
The number of restarts since the last flash ram format
MM.INF­O$(­CPU­SPEED)
Returns the current CPU speed
MM.INF­O$(­LCD­PANEL)
Returns the value of the configured LCD panel, or a blank string if none
MM.INF­O(L­CD320)
Returns 1 if the configured LCD panel can run OPTION LCD320
MM.INF­O$(­SDCARD)
Returns the status of the SD card
MM.INF­O$(­CUR­RENT)
Returns the name of the current program
MM.INF­O$(­PATH)
Returns the path of the current program
MM.INF­O(DISK SIZE)
Return the size of the active drive
MM.INF­O$(­DRIVE)
Returns active drive "­A:" or "­B:"
MM.INF­O(E­XISTS FILE fname$)
Returns 1 if the file specified exists, returns -1 if fname$ is a directory, otherwise returns 0.
MM.INF­O(E­XISTS DIR dirname$)
Returns 1 if the directory exists, else 0
MM.INF­O(FREE SPACE)
Returns the amount of free space available on the current drive
MM.INF­O(F­ILESIZE file$)
Returns the size of file file$ or 0 is not found
ALL variables start with MM., e.g. MM.VER, MM.FLAGS, etc.