-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
MMZHELP.TXT
2639 lines (2184 loc) · 106 KB
/
MMZHELP.TXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
``HELP
HELP topic
MMZ Module Help File
The help information resides in a single file MMZHELP.TXT which must be located
in the root folder of drive A:
One can bring up any file by simply typing 'help whatever' no (' or ") are
required but can be used and the file will come on the screen and not interrupt
the program in memory.
All file names are in lower case.
Example
\>help pause
Will show the "pause" command, then go back to the command prompt.
There are some help files where the name is a reserved keyword in MMBasic so if
one ends up with the main help screen after pressing enter try using a (")
Double Quote in front of the help word.
Below are a list of the major help pages and one just needs to type the word
into the help. T a minor spelling error is done the Help file system will
possibly find the relevant file aswell.
- Editor :- Explains the use of the online Editor
- Commands :- Lists all of the Commands used
- Functions:- Lists all of the Functions used.
- Revision Changes - for The Module :- This includes new commands
- Serial Communications
- I2C Communications
- SPI Communications
- One Wire
- Interrupts
- Loadable Fonts
- Operators and Precendence :- typing operator Will start this file
- Deprecated Commands
- ASCII-DEC-OCT-HEX table
- Defined Subroutines and Functions
- Multithreading and other specific to ELLO commands and functions
``1-Wire
ONEWIRE RESET pin - Reset the 1-Wire bus
ONEWIRE WRITE pin, flag, length, data [, data...] - Send a number of bytes
ONEWIRE READ pin, flag, length, data [, data...] - Get a number of bytes
Where:
pin - The Micromite I/O pin to use. It can be any pin capable of digital I/O.
flag - A combination of the following options:
1 - Send reset before command
2 - Send reset after command
4 - Only send/recv a bit instead of a byte of data
8 - Invoke a strong pullup after the command (the pin will be set high and open
drain disabled)
length - Length of data to send or receive
data - Data to send or variable to receive.
The number of data items must agree with the length parameter.
MM.ONEWIRE
Returns true if a device was found
``ABS
ABS( number )
Returns the absolute value of the argument 'number' (ie, any negative sign is
removed and the positive number is returned).
``ACOS
ACOS( number )
Returns the inverse cosine of the argument 'number' in radians.
``ASC
ASC( string$ )
Returns the ASCII code for the first letter in the argument ‘string$’.
``ASCII
The ASCII Code Table
Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex
------------------------------------------------------------------------------
(nul) 0 0000 0x00 | (sp) 32 0040 0x20 | @ 64 0100 0x40 | ` 96 0140 0x60
(soh) 1 0001 0x01 | ! 33 0041 0x21 | A 65 0101 0x41 | a 97 0141 0x61
(stx) 2 0002 0x02 | " 34 0042 0x22 | B 66 0102 0x42 | b 98 0142 0x62
(etx) 3 0003 0x03 | # 35 0043 0x23 | C 67 0103 0x43 | c 99 0143 0x63
(eot) 4 0004 0x04 | $ 36 0044 0x24 | D 68 0104 0x44 | d 100 0144 0x64
(enq) 5 0005 0x05 | % 37 0045 0x25 | E 69 0105 0x45 | e 101 0145 0x65
(ack) 6 0006 0x06 | & 38 0046 0x26 | F 70 0106 0x46 | f 102 0146 0x66
(bel) 7 0007 0x07 | ' 39 0047 0x27 | G 71 0107 0x47 | g 103 0147 0x67
(bs) 8 0010 0x08 | ( 40 0050 0x28 | H 72 0110 0x48 | h 104 0150 0x68
(ht) 9 0011 0x09 | ) 41 0051 0x29 | I 73 0111 0x49 | i 105 0151 0x69
(nl) 10 0012 0x0a | * 42 0052 0x2a | J 74 0112 0x4a | j 106 0152 0x6a
(vt) 11 0013 0x0b | + 43 0053 0x2b | K 75 0113 0x4b | k 107 0153 0x6b
(np) 12 0014 0x0c | , 44 0054 0x2c | L 76 0114 0x4c | l 108 0154 0x6c
(cr) 13 0015 0x0d | - 45 0055 0x2d | M 77 0115 0x4d | m 109 0155 0x6d
(so) 14 0016 0x0e | . 46 0056 0x2e | N 78 0116 0x4e | n 110 0156 0x6e
(si) 15 0017 0x0f | / 47 0057 0x2f | O 79 0117 0x4f | o 111 0157 0x6f
(dle) 16 0020 0x10 | 0 48 0060 0x30 | P 80 0120 0x50 | p 112 0160 0x70
(dc1) 17 0021 0x11 | 1 49 0061 0x31 | Q 81 0121 0x51 | q 113 0161 0x71
(dc2) 18 0022 0x12 | 2 50 0062 0x32 | R 82 0122 0x52 | r 114 0162 0x72
(dc3) 19 0023 0x13 | 3 51 0063 0x33 | S 83 0123 0x53 | s 115 0163 0x73
(dc4) 20 0024 0x14 | 4 52 0064 0x34 | T 84 0124 0x54 | t 116 0164 0x74
(nak) 21 0025 0x15 | 5 53 0065 0x35 | U 85 0125 0x55 | u 117 0165 0x75
(syn) 22 0026 0x16 | 6 54 0066 0x36 | V 86 0126 0x56 | v 118 0166 0x76
(etb) 23 0027 0x17 | 7 55 0067 0x37 | W 87 0127 0x57 | w 119 0167 0x77
(can) 24 0030 0x18 | 8 56 0070 0x38 | X 88 0130 0x58 | x 120 0170 0x78
(em) 25 0031 0x19 | 9 57 0071 0x39 | Y 89 0131 0x59 | y 121 0171 0x79
(sub) 26 0032 0x1a | : 58 0072 0x3a | Z 90 0132 0x5a | z 122 0172 0x7a
(esc) 27 0033 0x1b | ; 59 0073 0x3b | [ 91 0133 0x5b | { 123 0173 0x7b
(fs) 28 0034 0x1c | < 60 0074 0x3c | \ 92 0134 0x5c | | 124 0174 0x7c
(gs) 29 0035 0x1d | = 61 0075 0x3d | ] 93 0135 0x5d | } 125 0175 0x7d
(rs) 30 0036 0x1e | > 62 0076 0x3e | ^ 94 0136 0x5e | ~ 126 0176 0x7e
(us) 31 0037 0x1f | ? 63 0077 0x3f | _ 95 0137 0x5f |(del) 127 0177 0x7f
``ASIN
ASIN( number )
Returns the inverse sine value of the argument 'number' in radians.
``ATN
ATN( number )
Returns the arctangent of the argument 'number' in radians.
``AUTOSAVE
AUTOSAVE
Enter automatic program entry mode.
This command will take lines of text from the console serial input and
save them to memory. This mode is terminated by entering Control-Z which
will then cause the received data to be saved into program memory overwriting
the previous program.
At any time this command can be aborted by Control-C which will leave program
memory untouched.
This is one way of transferring a BASIC program into the Micromite. The program
to be transferred can be pasted into a terminal emulator and this command will
capture the text stream and store it into program memory.
It can also be used for entering a small program directly at the console input.
``BIN$
BIN$( number [, chars])
Returns a string giving the binary (base 2) value for the 'number'.
'chars' is optional and specifies the number of characters in the string with
zero as the leading padding character(s)
``BOX
BOX x1, y1, w, h [, lw] [,c][,fill]
Draws a box starting at x1 and y1 which is w pixels wide and h pixels high on
the attached LCD panel.
'lw' is the width of the sides of the box and can be zero. It defaults to 1.
'c' specifies the colour and defaults to the default foreground colour if not
specified.
'fill' is the fill colour. It can be omitted or set to -1 in which case the box
will not be filled.
``CFUNCTION
CFUNCTION name type [,type]
hex [[ hex[...]
hex [[ hex[...]
END CFUNCTION
Defines the binary code for an embedded machine code program module written in C
or MIPS assembler.
The module will appear in MMBasic as the command or function 'name' and can be
used in the same manner as a built- in command or function.
This command specifies the hex codes for the module.
This code is automatically programmed into MMBasic when the program is saved.
- Each 'hex' must be exactly eight hex digits representing the bits in a 32-bit
word.
- Each 'hex' word must be separated by one or more spaces and multiplelines of
'hex' words can be used.
The command must be terminated by a matching END CFUNCTION.
- The first 'hex' word must be the offset (in 32-bit words) to the entry point
of the embedded routine (usually the function main()).
- Multiple embedded routines can be used in a program with each defining a
different module with a different 'name'.
- During execution MMBasic will skip over any CSUB or CFUNCTION commands so they
can be placed anywhere in the program.
Any errors in the data format will be reported when the program is saved.
The type of each parameter can be specified in the definition. For example:
Csub MySub integer, integer, string
This specifies that there will be three parameters, the first two being integers
and the third a string.
As well as defining the types of the parameters a CFUNCTION can also specify the
type of the value returned.
For example, the following returns a string:
CFUNCTION MyFunct(integer, string) string
The 'name' created by these commands can be used as a normal command or function
within MMBasic with a few caveats:
- Up to ten values can be specified as parameters ('arg1', 'arg2', etc) and they
will be passed to the embedded C routine as pointers to the memory space
allocated to each value (ie, the result of the expression).
- If a variable or array is specified as an argument the C routine will receive
a pointer to the memory allocated to the variable or array and the C routine can
change this memory to return a value to the caller.
- In the case of arrays, they should be passed with empty brackets. Eg, arg().
In the C function the argument will be supplied as a pointer to the first
element of the array.
``CHR$
CHR$( number )
Returns a one-character string consisting of the character corresponding to the
ASCII code indicated by argument 'number'.
``CINT
CINT( number )
Round numbers with fractional portions up or down to the next whole number or
integer.
For example,
45.47 will round to 45
45.57 will round to 46
-34.45 will round to -34
-34.55 will round to -35
See also INT() and FIX()
``CIRCLE
CIRCLE x, y, r [,lw] [, a] [,c] [, fill]
Draw a circle on the video output centred at 'x' and 'y' with a radius of 'r' on
the attached LCD panel. 'c' is the optional colour and defaults to the current
foreground colour if not specified.
The optional 'a' is a floating point number which will define the aspect ratio.
If the aspect is not specified the default is 1.0 which gives a standard circle
'fill' is the fill colour. It can be omitted or set to -1 in which case the box
will not be filled.
``CLEAR
CLEAR
Delete all variables and recover the memory used by them.
See ERASE for deleting specific array variables.
``CLOSE
CLOSE [#]nbr [,[#]nbr] ...
Close the serial communications port(s) previously opened with the file number
‘nbr’. The # is optional. Also see the OPEN command.
``CLS
CLS [colour]
Clears the LCD panel's screen. Optionally 'colour' can be specified which will
be used for the background when clearing the screen.
``COLOUR
COLOUR fore [, back]
COLOR fore [, back]
Sets the default colour for commands (PRINT, etc) that display on the on the
attached LCD panel.
'fore' is the foreground colour
'back' is the background colour.
The background is optional and if not specified will default to black.
``COMMANDS
AUTOSAVE - BOX - CFUNCTION - CIRCLE - CLEAR - CLOSE - CLS - COLOUR - COMMENT -
CONTINUE - CPU - CPU RESTART - CPU SLEEP - CSUB - DATA - DATE$ - DEFINEFONT -
DIM - DO - DO LOOP - DO WHILE - EDIT - ELSE - ELSEIF - END - END FUNCTION - END
SUB - ENDIF - ERASE - ERROR - EXIT - FONT - FOR - FUNCTION - GOSUB - GOTO - GUI
BITMAP - GUI CALIBRATE - GUI RESET LCDPANEL - GUI TEST - HELP - HUMID - IF -
INPUT - IR - KEYPAD - LCD - LCD CMD - LET - LIBRARY - LINE - LINE INPUT - LIST -
LOCAL - LOOP - LOOP - MEMORY - NEW - NEXT - ON ERROR - ON GOTO - ON KEY - OPEN -
OPTION AUTORUN - OPTION BASE - OPTION BAUDRATE - OPTION BREAK - OPTION CASE -
OPTION CLOCKTRIM - OPTION COLOURCODE - OPTION CONSOLE - OPTION DEFAULT - OPTION
DISPLAY - OPTION EXPLICIT - OPTION LCDPANEL - OPTION LIST - OPTION PIN - OPTION
RESET - OPTION TAB - OPTION TOUCH - PAUSE - PIN - PIXEL - POKE - PORT - PRINT -
PULSE - PWM - RANDOMIZE - RBOX - READ - REM - RESTORE - RETURN - RTC - RUN -
SELECT CASE - SERVO - SETPIN - SETTICK - SUB - TEMPR START - TEXT - TIME$ -
TIMER - TRACE - VAR - WATCHDOG - XMODEM
``COMMENT
' (single quotation mark)
Starts a comment and any text following it will be ignored. Comments can be
placed anywhere on a line.
``CONTINUE
CONTINUE
CONTINUE DO
CONTINUE FOR
CONTINUE
Resume running a program that has been stopped by an END statement, an error, or
CTRL-C. The program will restart with the next statement following the previous
stopping point.
CONTINUE DO / CONTINUE FOR
Skip to the end of a DO/LOOP or a FOR/NEXT loop. The loop condition will then be
tested and if still valid the loop will continue with the next iteration.
``COS
COS( number )
Returns the cosine of the argument 'number' in radians.
``CPU
CPU speed
Set the clock speed of the processor.
'speed' is set in Mhz and on the 28/44 pin Micromite it can be either 48, 40,
30, 20, 10, or 5.
On the Micromite Plus it can be 120, 100, 80, 60, 48, 40, 30, 20, 10 or 5.
Current drawn by the chip is proportional to the clock speed, so by halving the
clock speed the current drain is roughly halved.
The default speed of the CPU when power is applied is 40 Mhz on the 28/44 pin
Micromite and 100Mhz on the Micromite Plus.
When the speed is changed all timing functions in MMBasic will be automatically
corrected to keep the correct time and the console baud rate will be unchanged.
The serial communications ports can remain open during the speed change and
their speed will be adjusted accordingly.
Note that there may be a glitch while changing speed and some characters may be
lost or corrupted.
The speed of any SPI, I 2 C and PWM functions open at the time will change with
the clock speed.
For this reason they should be closed before this command is used and reopened
after.
``CPU RESTART
CPU RESTART
Will force a restart of the processor.
This will clear all variables and reset everything (eg, timers, COM ports, I2C,
etc) similar to a power up situation but without the power up banner.
If OPTION AUTORUN has been set the program in memory will restart.
``CPU SLEEP
CPU SLEEP
CPU SLEEP seconds
Put the CPU to sleep. In this mode the running program will be halted and the
current drain reduced to less than 40 ?A.
In the first form (CPU SLEEP seconds) the command will put the CPU to sleep for
the specified number of 'seconds' (maximum of 10 days).
This command will update the TIMER function and internal calendar when it comes
out of sleep but note that the sleep time is not very accurate; it can vary by
up to ±20%.
In the second form the WAKEUP pin (see the pinout tables at the start of this
manual) will be automatically configured as a digital input and any change in
its state (ie, from high to low or low to high) will wakeup the CPU.
The IR command shares the WAKEUP pin and if it is running the CPU will be
awakened by the remote key press and MMBasic will immediately decode the signal
and execute the IR interrupt.
Notes:
- The CPU will go to sleep in the middle of the SLEEP command and when awakened
continue with normal program execution.
- All communications (serial, SPI, I2C and 1-Wire) and PWM will be frozen during
sleep. When the CPU comes out of sleep they will resume normal processing. It is
recommended that they be closed before entering sleep as they will add to the
current drawn by the chip in sleep.
- The time required to "wake up" is less than 1 mS.
- External circuitry and program features can cause extra current drain while in
sleep.
- All timing functions will freeze during the sleep, this includes the real time
clock and background pulse commands.
- CTRL-C on the console will not bring the chip out of sleep.
``CSUB
CSUB name(type [, type]) rtype
hex [[ hex[...]
hex [[ hex[...]
END CSUB
Defines the binary code for an embedded machine code program module written in C
or MIPS assembler.
The module will appear in MMBasic as the command or function 'name' and can be
used in the same manner as a built- in command or function.
This command specifies the hex codes for the module.
This code is automatically programmed into MMBasic when the program is saved.
- Each 'hex' must be exactly eight hex digits representing the bits in a 32-bit
word.
- Each 'hex' word must be separated by one or more spaces and multiplelines of
'hex' words can be used.
The command must be terminated by a matching END CSUB
- The first 'hex' word must be the offset (in 32-bit words) to the entry point
of the embedded routine (usually the function main()).
- Multiple embedded routines can be used in a program with each defining a
different module with a different 'name'.
- During execution MMBasic will skip over any CSUB or CFUNCTION commands so they
can be placed anywhere in the program.
Any errors in the data format will be reported when the program is saved.
The type of each parameter can be specified in the definition. For example:
Csub MySub integer, integer, string
This specifies that there will be three parameters, the first two being integers
and the third a string.
As well as defining the types of the parameters a Cfunction can also specify the
type of the value returned. For example, the following returns a string:
CFUNCTION MyFunct(integer, string) string
The 'name' created by these commands can be used as a normal command or function
within MMBasic with a few caveats:
- Up to ten values can be specified as parameters ('arg1', 'arg2', etc) and they
will be passed to the embedded C routine as pointers to the memory space
allocated to each value (ie, the result of the expression).
- If a variable or array is specified as an argument the C routine will receive
a pointer to the memory allocated to the variable or array and the C routine can
change this memory to return a value to the caller.
- In the case of arrays, they should be passed with empty brackets. Eg, arg().
In the C function the argument will be supplied as a pointer to the first
element of the array.
``DATA
DATA constant[,constant]…
Stores numerical and string constants to be accessed by READ.
In general string constants should be surrounded by double quotes (").
An exception is when the string consists of just alphanumeric characters
that do not represent MMBasic keywords (such as THEN, WHILE, etc).
In that case quotes are not needed.
Numerical constants can also be expressions such as 5 * 60.
``DATE$
DATE$ = "DD-MM-YY"
DATE$ = "DD/MM/YY"
Set the date of the internal clock/calendar.
DD, MM and YY are numbers, for example: DATE$ = "28-7-2014"
The date is set to "1-1-2000" on power up.
When used as function, DATE$ returns the current date based on MMBasic’s
internal clock as a string in the form "DD-MM-YYYY". For example, "28-07-2012".
The internal clock/calendar will keep track of the time and date including leap
years.
``DEFINEFONT
DEFINEFONT #Nbr
hex [[ hex[...]
hex [[ hex[...]
END DEFINEFONT
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.
These work exactly same as the built in fonts (ie, selected using the FONT
command or specified in the TEXT command).
'#Nbr' is the font's reference number (from 1 to 16). It can be the same
number as a built in font and in that case it will replace the built in
font.
Each 'hex' must be exactly eight hex digits and be separated by spaces
or new lines from the next.
- Multiple lines of 'hex' words can be used with the command terminated
by a matching END DEFINEFONT.
- Multiple embedded fonts can be used in a program with each defining a
different font with a different font number.
- During execution MMBasic will skip over any DEFINEFONT commands so they
can be placed anywhere in the program.
- Any errors in the data format will be reported when the program is saved.
``DEG
DEG( radians )
Converts 'radians' to degrees.
``DIM
DIM [type] decl [,decl]…
where 'decl' is:
var [length] [type] [init]
'var' is a variable name with optional dimensions
'length' is used to set the maximum size of the string to 'n' as in LENGTH
n
'type' is one of AS FLOAT or AS INTEGER or AS STRING
'init' is the value to initialise the variable and consists of:
= <expression>
For a simple variable one expression is used, for an array a list of comma
separated expressions surrounded by brackets is used.
Examples:
DIM nbr(50)
DIM INTEGER nbr(50)
DIM name AS STRING
DIM a, b$, nbr(100), strn$(20)
DIM a(5,5,5), b(1000)
DIM strn$(200) LENGTH 20
DIM STRING strn(200)
LENGTH 20
DIM a = 1234, b = 345
DIM STRING strn = "text"
DIM x%(3) = (11, 22, 33, 44)
Declares one or more variables (ie, makes the variable name and its
characteristics known to the interpreter).
When OPTION EXPLICIT is used (as recommended) the DIM or LOCAL
commands are the only way that a variable can be created. If this option
is not used then using the DIM command is optional and if not used the
variable will be created automatically when first referenced.
The type of the variable (ie, string, float or integer) can be specified
in one of three ways:
By using a type suffix (ie, !, % or $ for float, integer or string).
For example:
DIM nbr%, amount!, name$
By using one of the keywords FLOAT, INTEGER or STRING immediately
after the command DIM and before the variable(s) are listed. The specified
type then applies to all variables listed (ie, it does not have to be repeated).
For example:
DIM AS STRING first_name, last_name, city
By using the Microsoft convention of using the keyword "AS" and the type
keyword (ie, FLOAT, INTEGER or STRING) after each variable. If you
use this method the type must be specified for each variable and can be
changed from variable to variable.
For example:
DIM amount AS FLOAT, name AS STRING
Floating point or integer variables will be set to zero when created and
strings will be set to an empty string (ie, ""). You can initialise the
value of the variable with something different by using an equals symbol (=) and
an expression following the variable definition.
For example:
DIM AS STRING city = "Perth", house = "Brick"
The initialising value can be an expression (including other variables)
and will be evaluated when the DIM command is executed. See the chapter
"Defining and Using Variables" for more examples of the syntax.
As well as declaring simple variables the DIM command will also declare
arrayed variables (ie, an indexed variable with a number of dimensions).
Following the variable's name the dimensions are specified by a list of
numbers separated by commas and enclosed in brackets. For example:
DIM array(10, 20)
Each number specifies the number of elements in each dimension. Normally
the numbering of each dimension starts at 0 but the OPTION BASE
command can be used to change this to 1.
The above example specifies a two dimensional array with 11 elements (0
to 10) in the first dimension and 21 (0 to 20) in the second dimension. The
total number of elements is 231 and because each floating point number
requires 4 bytes a total of 924 bytes of memory will be allocated (integers
are different and require 8 bytes per element).
Strings will default to allocating 255 bytes (eg, characters) of memory
for each element and this can quickly use up memory. In that case the
LENGTH keyword can be used to specify the amount of memory to be
allocated to each element and therefore the maximum length of the string
that can be stored. This allocation ('n') can be from 1 to 255 characters.
For example: DIM str$(5, 10) will declare a string array with 66 elements
consuming 16,896 bytes of memory while:
DIM AS STRING str (5, 10) LENGTH 20
Will only consume 1,386 bytes of memory. Note that the amount of
memory allocated for each element is n + 1 as the extra byte is used to
track the actual length of the string stored in each element.
If a string longer than 'n' is assigned to an element of the array an error
will be produced. Other than this string arrays created with the LENGTH
keyword act exactly the same as other string arrays. Note that the LENGTH
keyword can also be used when defining non array string variables.
In the above example you can also use the Microsoft syntax of specifying
the type after the length specifier. For example:
DIM str (5, 10) LENGTH 20 AS STRING
Arrays can also be initialised when they are declared by adding an equals
symbol (=) followed by a bracketed list of values at the end of the
declaration. For example:
DIM INTEGER nbr(4) = (22, 44, 55, 66, 88)
or
DIM str$(3) = ("foo", "boo", "doo", "zoo")
Note that the number of initialising values must match the number of
elements in the array including the base value set by OPTION BASE. If a
multi dimensioned array is initialised then the first dimension will be
initialised first followed by the second, etc.
``DISTANCE
DISTANCE( trigger, echo )
or
DISTANCE( trig-echo )
Measure the distance to a target using the HC-SR04 ultrasonic distance sensor.
Four pin sensors have separate trigger and echo connections. 'trigger' is the
I/O pin connected to the "trig" input of the sensor and 'echo' is the pin
connected to the "echo" output of the sensor.
Three pin sensors have a combined trigger and echo connection and in that case
you only need to specify one I/O pin to interface to the sensor.
Note that any I/O pins used with the HC-SR04 should be 5V capable as the HC-SR04
is a 5V device. The I/O pins are automatically configured by this function and
multiple sensors can be used on different I/O pins.
The value returned is the distance in centimetres to the target or -1 if no
target was detected or -2 if there was an error (ie, sensor not connected).
The CPU speed must be 10 MHz or higher and the measurement can take up to 32 mS
to complete.
``DO
DO
<statements>
LOOP
This structure will loop forever; the EXIT DO command can be used to terminate
the loop or control must be explicitly transferred outside of the loop
by commands like GOTO or RETURN (if in a subroutine).
``DO LOOP
DO
<statements>
LOOP UNTIL expression
Loops until the expression following UNTIL is true. Because the test is
made at the end of the loop the statements inside the loop will be executed
at least once, even if the expression is true.
``DO WHILE
DO WHILE expression
<statements>
LOOP
Loops while "expression" is true (this is equivalent to the older WHILE-WEND
loop, also implemented in MMBasic). If, at the start, the expressionis
false the statements in the loop will not be executed, even once.
``EDIT
EDIT
Invoke the full screen editor.
All the editing keys work with a VT100 terminal emulator so editing can also be
accomplished over the console serial link. The editor has been tested with Tera
Term and PuTTY running on a Windows PC.
On entry the cursor will be automatically positioned at the last line edited or,
if there was an error when running the program, the line that caused the error.
The editing keys are:
Left/Right arrows - Moves the cursor within the line.
Up/Down arrows - Moves the cursor up or down a line.
Page Up/Down - Move up or down a page of the program.
Home/End - Moves the cursor to the start or end of the line. A second Home/End
will move to the start or end of the program.
Delete - Delete the character over the cursor. This can be the line separator
character and thus join two lines.
Backspace - Delete the character before the cursor.
Insert - Will switch between insert and overtype mode.
Escape - Key Will close the editor without saving (confirms first).
F1 - Save the edited text and exit.
F2 - Save, exit and run the program.
F3 Invoke the search function.
SHIFT F3 - Repeat the search using the text entered with F3.
F4 - Mark text for cut or copy (see below).
F5 – Paste text previously cut or copied.
When in the mark text mode (entered with F4) the editor will allow you to use
the arrow keys to highlight text which can be deleted, cut to the clipboard or
simply copied to the clipboard.
The status line will change to indicate the new functions of the function keys.
The editor will work with lines wider than the screen but characters beyond the
screen edge will not be visible. You can split such a line by inserting a new
line character and the two lines can be later rejoined by deleting the inserted
new line character.
``ELSE
ELSE
Introduces a default condition in a multiline IF statement. See the multiline
IF statement for more details.
``ELSEIF
ELSEIF expression THEN
ELSE IF expression THEN
Introduces a secondary condition in a multiline IF statement. See the multiline
IF statement for more details.
``END
END
End the running program and return to the command prompt.
``END FUNCTION
END FUNCTION
Marks the end of a user defined function. See the FUNCTION command.
Each function must have one and only one matching END FUNCTION statement.
Use EXIT FUNCTION if you need to return from a function from within its body.
``END SUB
END SUB
Marks the end of a user defined subroutine. See the SUB command.
Each sub must have one and only one matching END SUB statement.
Use EXIT SUB if you need to return from a subroutine from within its body.
``ENDIF
ENDIF
END IF
Terminates a multiline IF statement. See the multiline IF statement for more
details.
``EOF
EOF( [#]nbr )
For a serial communications port this function will return true if there are no
characters waiting in the receive buffer. #0 can be used which refers to the
console's input buffer.
The # is optional. Also see the OPEN, INPUT and LINE INPUT commands and the
INPUT$ function.
``ERASE
ERASE variable [,variable]…
Deletes arrayed variables and frees up the memory.
Use CLEAR to delete all variables including all arrayed variables.
``ERROR
ERROR [error_msg$]
Forces an error and terminates the program.
This is normally used in debugging or to trap events that should not occur.
``EXIT
EXIT DO
EXIT FOR
EXIT FUNCTION
EXIT SUB
EXIT DO provides an early exit from a DO...LOOP
EXIT FOR provides an early exit from a FOR...NEXT loop.
EXIT FUNCTION provides an early exit from a defined function.
EXIT SUB provides an early exit from a defined subroutine.
The old standard of EXIT on its own (exit a do loop) is also supported.
``EXP
EXP( number )
Returns the exponential value of 'number'.
``FIX
FIX( number )
Truncate a number to a whole number by eliminating the decimal point and all
characters to the right of the decimal point.
For example 9.89 will return 9 and -2.11 will return -2.
The major difference between FIX and INT is that FIX provides a true integer
function (ie, does not return the next lower number for negative numbers as
INT() does). This behaviour is for Microsoft compatibility.
See also CINT() .
``FONT
FONT [#]font-number, scaling
This will set the default font for displaying text on an LCD panel.
Fonts are specified as a number. For example, #2 (the # is optional)
'scaling' can range from 1 to 15 and will multiply the size of the pixels making
the displayed character correspondingly wider and higher. Eg, a scale of 2 will
double the height and width.
``FOR
FOR counter = start TO finish
[STEP increment]
Initiates a FOR-NEXT loop with the 'counter' initially set to 'start' and
incrementing in 'increment' steps (default is 1) until 'counter' equals
'finish'.
The ‘increment’ can be an integer or floating point number. Note that using a
floating point fractional number for 'increment' can accumulate rounding errors
in 'counter' which could cause the loop to terminate early or late.
'increment' can be negative in which case 'finish' should be less than 'start'
and the loop will count downwards.
See also the NEXT command.
``FUNCTION
FUNCTION xxx (arg1
[,arg2, ...]) [AS <type>}
<statements>
<statements>
xxx = <return value>
END FUNCTION
Defines a callable function.
This is the same as adding a new function to MMBasic while it is running your
program.
'xxx' is the function name and it must meet the specifications for naming a
variable.
The type of the function can be specified by using a type suffix (ie, xxx$) or
by specifying the type using AS <type> at the end of the functions definition.
For example:
FUNCTION xxx (arg1, arg2) AS STRING
'arg1', 'arg2', etc are the arguments or parameters to the function.
An array is specified by using empty brackets. ie, arg3().
The type of the argument can be specified by using a type suffix (ie, arg1$) or
by specifying the type using AS <type> (ie, arg1 AS STRING).
The argument can also be another defined function or the same function if
recursion is to be used (the recursion stack is limited to 50 nested calls).
To set the return value of the function you assign the value to the function's
name.
For example:
FUNCTION SQUARE(a)
SQUARE = a * a
END FUNCTION
Every definition must have one END FUNCTION statement.
When this is reached the function will return its value to the expression from
which it was called.
The command EXIT FUNCTION can be used for an early exit.
You use the function by using its name and arguments in a program just as you
would a normal MMBasic function.
For example:
PRINT SQUARE(56.8)
When the function is called each argument in the caller is matched to the
argument in the function definition.
These arguments are available only inside the function.
Functions can be called with a variable number of arguments.
Any omitted arguments in the function's list will be set to zero or a null
string.
Arguments in the caller's list that are a variable (ie, not an expression or
constant) will be passed by reference to the function.
This means that any changes to the corresponding argument in the function will
also be copied to the caller's variable.
Arrays are passed by specifying the array name with empty brackets (eg, arg())
and are always passed by reference.
You must not jump into or out of a function using commands like GOTO, GOSUB,
etc.
Doing so will have undefined side effects including the possibility of ruining
your day.
``FUNCTIONS
ABS - ACOS - ASC - ASIN - ATN - BIN$ - CHR$ - CINT - COS - DEG - DISTANCE - EOF
- EXP - FIX - HEX$ - INKEY$ - INPUT$ - INSTR - INT - LCASE$ - LEFT$ - LEN - LOC
- LOF - LOG - MID$ - OCT$ - PEEK - PI - POS - PULSIN - RAD - RGB - RIGHT$ - RND
- SGN - SIN - SPACE$ - SQR - STR$ - STRING$ - TAB - TAN - TEMPR - TOUCH - UCASE$
- VAL
``GOSUB
GOSUB target
Initiates a subroutine call to the target, which can be a line number or a
label.
The subroutine must end with RETURN.
``GOTO
GOTO target
Branches program execution to the target, which can be a line number or a label.
``GUI BITMAP
GUI BITMAP x, y, bits [,width] [, height] [, scale] [, c][, bc]
Displays the bits in a bitmap on an LCD panel starting at 'x' and 'y' on an
attached LCD panel.
'height' and 'width' are the dimensions of the bitmap as displayed on the LCD
panel and default to 8x8.
'scale' is optional and defaults to that set by the FONT command. 'c' is the
drawing colour and 'bc' is the background colour.
They are optional and default to the current foreground and background colours.
The bitmap can be an integer or a string variable or constant and is drawn using
the first byte as the first bits of the top line (bit 7 first, then bit 6, etc)
followed by the next byte, etc.
When the top line has been filled the next line of the displayed bitmap will
start with the next bit in the integer or String.
``GUI CALIBRATE
GUI CALIBRATE
This command is used to calibrate the touch feature on an LCD panel.
It will display a series of targets on the screen and wait for each one to be
precisely touched.
``GUI RESET LCDPANEL
GUI RESET LCDPANEL
Will reinitialise the configured LCD panel.
Initialisation is automatically done when the Micromite starts up but in some
circumstances it may be necessary to interrupt power to the LCD panel (eg, to
save battery power) and this command can then be used to reinitialise the
display.
``GUI TEST
GUI TEST TOUCH
GUI TEST LCDPANEL
Will test the display or touch feature on an LCD panel.
With GUI TEST LCDPANEL an animated display of colour circles will be rapidly
drawn on top of each other.
With GUI TEST TOUCH the screen will blank and wait for a touch which will cause
a white dot to be placed on the display marking the touch position on the
screen.
``HEX$
HEX$( number [, chars])
Returns a string giving the hexadecimal (base 16) value for the 'number'.
'chars' is optional and specifies the number of characters in the string with
zero as the leading padding character(s)
``HUMID
HUMID pin, tvar, hvar
Returns the temperature and humidity using the DHT22 sensor.
Alternative versions of the DHT22 are the AM2303 or the RHT03 (all are
compatible).
'pin' is the I/O pin connected to the sensor. Any I/O pin may be used.
'tvar' is the variable that will hold the measured temperature and 'hvar' is the
same for humidity.
Both must be present and both must be floating point variables.
For example: HUMID 2, TEMP!, HUMIDITY!
Temperature is measured in oC and the humidity is percent relative humidity.
Both will be measured with a resolution of 0.1. If an error occurs (sensor not
connected or corrupt signal) both values will be 1000.0.
The CPU speed must be 10MHz or higher and the measurement will take 6ms to
complete.
Normally the signal pin of the DHT22 should be pulled up by a 1K to 10K resistor
(4.7K recommended) to the supply voltage.
The Micromite will also enable an internal high value pullup resistor so when
the cable length is short (under 30cm) the external pullup resistor may be
omitted.
``I2C
I2C OPEN speed, timeout [, PU]
I2C WRITE addr, option, sendlen, senddata [,sendata ....]
I2C READ addr, option, rcvlen, rcvbuf
I2C CLOSE
I2C SLAVE OPEN addr, mask, option, send_int, rcv_int
I2C SLAVE WRITE sendlen, senddata [,sendata ....]
I2C SLAVE READ rcvlen, rcvbuf, rcvd
I2C SLAVE CLOSE
MM.I2C
``I2C CLOSE
I2C CLOSE
Disables the slave I 2 C module and returns the I/O pins to a "not configured"
state. Then can then be configured using SETPIN. This command will also send a
stop if the bus is still held.
``I2C OPEN
I2C OPEN speed, timeout [, PU]
Enables the I 2 C module in master mode.
‘speed’ is a value between 10 and 400 (for bus speeds 10 kHz to 400 kHz).
‘timeout’ is a value in milliseconds after which the master send and receive
commands will be interrupted if they have not completed. The minimum value is
100. A value of zero will disable the timeout (though this is not recommended).
'PU' (if specified) will enable weak pullups (about 100K) on both the clock and
data lines. I 2 C normally requires lower value resistors (typically 10K) but
for short signal lines at slow speed this may be all that is required.
``I2C READ
I2C READ addr, option, rcvlen, rcvbuf
Get data from the I 2 C slave device.
‘addr’ is the slave I 2 C address.
‘option’ is a number between 0 and 3 (normally this is set to 0)
1 = keep control of the bus after the command (a stop condition will not be sent
at the completion of the command)
2 = treat the address as a 10 bit address
3 = combine 1 and 2 (hold the bus and use 10 bit addresses).
‘rcvlen’ is the number of bytes to receive.
‘rcvbuf’ is the variable to receive the data - this can be a string variable
(eg, t$), or a one dimensional array of numbers specified without the dimensions
(eg, data()) or a normal numeric variable (in this case rcvlen must be 1).
``I2C SLAVE CLOSE
I2C SLAVE CLOSE