The work by others to port Arduino BASIC to the Smart Response-XE device was of interest, but I wanted a few enhancements to extend battery life (auto shutdown) and I wanted an easier way to do math on the console rather than typing "PRINT" everytime I wanted to do something simple.
Thus, I did some hacking and implemented auto-shutdown after 3 minutes which can be easily redefined in host.cpp with line:
#define AutoSleep 180000
Note: AutoSleep only works when the device is idle; that is, not running a BASIC program. Thus, with the simple menu system I show later, the device will not shutdown automatically.
A really nice feature of BASIC is that quick calculations can be made directly on the console. Unfortunately, typing "PRINT" before every operation is a P.I.T.A. and totally lame. Remember when one could simply type "?" at the start and get the answer - so much faster.
On the SmartResponse-XE a "shift" key is required to generate the "?" thus 2 keystrokes. In considering this, I remembered an old compiled program I had written back in the mid-1980's for the IBM-PC ... it was compiled as "q.exe" and to add 3 and 5 one only needed to type:
q 3 + 5
and press ENTER. Of course, my program at that time handled a large number of math functions, much as are already implemented the the -XE's run-time interpreter. Thus, to minimize the keystorkes, I did an alias operation to PRINT as Q. To add 3 and 5, the
q 3 + 5
will be successful. One of the images shows a more complex operation:
Additionally, while not a hack, I wanted a way to really make use of the F1 - F10 function keys. I wrote a very basic BASIC program which others may wish (or not) to use a a template. I implemented a subroutine for calculating the hypotenuse or a right-triangle and a subroutine for converting angular degrees into the more useful radians.
The program listing is:
1 CLS
2 GOSUB 1100
5 PAUSE (50)
10 a=0; a=INKEY
20 IF a=0 THEN GOTO 5
25 a=a+17
30 IF a=1 THEN GOTO 100
35 IF a=2 THEN GOTO 200
40 IF a=3 THEN GOTO 300
45 IF a=4 THEN GOTO 400
50 IF a=5 THEN GOTO 500
55 IF a=6 THEN GOTO 600
60 IF a=7 THEN GOTO 700
65 IF a=8 THEN GOTO 800
70 IF a=9 THEN GOTO 900
75 IF a=10 THEN GOTO 1000
80 GOTO 1
100 GOSUB 190
105 PRINT "side a +": INPUT a
110 GOSUB 190
115 PRINT "a= " a " b=";:INPUT b
120 GOSUB 190
125 PRINT "a= " a " b=" b " c= "SQR(a*a+b*b)
126 PRINT ">>>>> Press any key <<<<<";
130 GOTO 1020
190 CLS
192 PRINT " /! Rt Triangle"
193 PRINT " / !"
194 PRINT " c / ! a"
195 PRINT " / !"
196 PRINT " ----!"
197 PRINT " b"
198 RETURN
199 GOTO 1
200 REM
299 GOTO 1
300 REM
399 GOTO 1
400 REM
499 GOTO 1
500 REM
599 GOTO 1
600 REM
699 GOTO 1
700 REM
799 GOTO 1
800 REM
899 GOTO 1
900 REM
999 GOTO 1
1000 CLS: PRINT " Degree to Radians calculator": PRINT
1005 PRINT "Enter Degrees ";: INPUT a
1010 PRINT a "Degrees = " (a/360*2*355/113) "Radians"
1015 PRINT "": PRINT "": PRINT "Press any key for Main Menu"
1025 a=INKEY: IF (a=0) THEN GOTO 1025
1030 goto 1
1100 PRINT "F1 Rt triangle F6" : PRINT
1120 PRINT "F2 F7" : PRINT
1130 PRINT "F3 F8" : PRINT
1140 PRINT "F4 F9" : PRINT
1150 PRINT "F5 Deg-Rad F10"
1160 RETURN
Of note, F1 - F10 map to subroutines as follows:
30 IF a=1 THEN GOTO 100
35 IF a=2 THEN GOTO 200
40 IF a=3 THEN GOTO 300
45 IF a=4 THEN GOTO 400
50 IF a=5 THEN GOTO 500
55 IF a=6 THEN GOTO 600
60 IF a=7 THEN GOTO 700
65 IF a=8 THEN GOTO 800
70 IF a=9 THEN GOTO 900
75 IF a=10 THEN GOTO 1000
It is a simplistic template for creating one's own everyday needed operations. Nice thing about the Dan Geiger / fdufnews / robinhedwards / Larry Banks / Michael Field port of Arduino BASIC to the Smart Response-XE is that the current implementation makes use of SAVE/LOAD for the internal EEPROM and MSAVE 0 - MSAVE 9 for the external FLASH inside the -XE. This then provides 11 separate templates that you can easily carry around with you....
Read more »