Thank you very much for PropBasic and PE-Basic.
I've tried the version 0.16 and I get an error message: INVALID PARAMETER __param1 and ....__ param2
for these subroutines :
SUB I2C_Start ' SDApin, SCLpin
I2CSTART __param1, __param2
ENDSUB
SUB I2C_Stop ' SDApin, SCLpin
I2CSTOP __param1, __param2
ENDSUB
SUB I2C_Write ' SDApin, SCLpin, value
I2CWRITE __param1, __param2, __param3
ENDSUB
I compiled the modified program and load it into the propeller. With the speed-measuring program I've tried saving and loading the program into the EEPROM. It runs without any problems.
I think it should be possible to pass the PIN numbers (SDA and SCL = 29 and 28) only in the four subroutines?
development environment : Linux, BST, PropBasic-00.01.12-78
Thank you Bean. PEBasic is now compiled with the new PropBASIC 00.01.14-79 without error and works fine.
But a PropBasic test program for my Gam_Bo_Prop now needs a couple of minutes to compile but without any error message. I'll try to find the error otherwise I post in the PropBasic thread.
I took the High/Low game in the manual and extracted the input section into a general purpose input routine.
This subroutine does not take any inputs and uses only INPZ as a temporary variable. It returns the numeric input in the variable INP
If you need more than one input, call the subroutine with a GOSUB 32000, and then save it to another variable before calling the subroutine again.
10 PRINT "Please enter your age: ";
20 GOSUB 32000:PRINT
30 PRINT "You are currently ";inp;" years old."40 PRINT "Next year, you will turn ";inp + 1;" years old."50 END
32000 ' Input INP
32001 ' Uses: INPZ for temporary storage
32010 inp=032020 inpz=INKEY:IF inpz=0 THEN 3202032030 IF inpz=13 THEN 3208032040 IF inpz=8 THEN DISPLAY 8:DISPLAY 32:DISPLAY 8:inp=inp/10:GOTO 3202032050 inpz=inpz-48:IF inpz<0 OR inpz>9 THEN 3202032055 PRINT inpz;
32060 inp=inp*10+inpz
32070 GOTO 3202032080 RETURN
Lines 10-50 are just a simple program to demonstrate usage of the subroutine. The routine takes into consideration the backspace key, and ignores non-numeric characters.
HyperTerminal actually made for a nice development environment. I had to add about 20 ms of line delay in the ASCII Setup in the Settings tab of the Properties. That allowed me to use the full-screen editing capability of Notepad, and when I was ready to test my code, I selected the code in Notepad and copied it to the clipboard, clicked on HyperTerminal and typed new, then right-clicked and selected Paste to Host. That entered the code and I was able to list it and run it on the Prop. (Normally I use Linux, but I am at work, and we only have Windows here. Does anyone have a nice terminal emulator for Linux that can do that - the BST terminal does not accept pasted text as far as I can tell.)
I most-love the autoexecute capabilities of PE_BASIC. That actually works better than any other on-chip language, because microcontrollers are supposed to automatically run at power up.
I am new to this Forum and looking for a tiny embedded interpreter, that can run programs like BASIC or scripting language, that are provided as text to it.
AND it should be able to access functions provided in SPIN or PASM whick build the drivers and system level.
I want to use it to allow users of our test systems to write test-scripts - calling predef. test steps, setting parameters and manipulating results, loops and conditionals, Vars and ideally arrays ...
just a very simple language -
PEBasic seems to come quite close -
but:-
can you call PASM or SPIN?
PEBasic in one COG and the others doing realtime stuff ?
any other ideas / existing code or ... you long time propeller users ??
Thanks
MJB,
Using the standard PE-BASIC language you cannot call PASM or SPIN code.
You would have to modify the PE-BASIC source code (written in PropBASIC) to add commands to do whatever you need.
The source code for PE-BASIC is "open-source".
Let me know if you want to do this.
MJB,
Using the standard PE-BASIC language you cannot call PASM or SPIN code.
You would have to modify the PE-BASIC source code (written in PropBASIC) to add commands to do whatever you need.
The source code for PE-BASIC is "open-source".
Let me know if you want to do this.
MJB,
Using the standard PE-BASIC language you cannot call PASM or SPIN code.
You would have to modify the PE-BASIC source code (written in PropBASIC) to add commands to do whatever you need.
The source code for PE-BASIC is "open-source".
Let me know if you want to do this.
Another alternative solution could be PropForth, a Forth development system that runs on one or more Propellers. It doesn't directly run SPIN or PASM routines but it does have an assembler for time critical code. You would develop your entire application in Forth and due to its interactive nature, you could test/change/monitor variables from one cog while application routines run in another cog.
Due the the limited memory in the Propeller, it would be very difficult to have an embedded BASIC which you could add to an existing like you can add VBA for example to a PC application. the best you could do with SPIN/PASM would be to write a simple monitor routine to give you some of the variable inspection and testing you require. The other alternative is to see what pieces of PE-BASIC could be used with you code as an embedded monitor.
Welcome and keep us informed on where you end up, it sounds like an interesting and useful tool!
Thanks Bean & mindrobots
my first propeller is scheduled to arrive today
unfortunately I have to focus on my bread&butter project for a while now.
While slowly discovering all the Prop developments - like ViewPort, PropBsasic, PropForth, Spinnernet,... I habe quite s.th. to digest at the moment ...
Any propeller users here in Germany near Stuttgart ?? please contact me.
I assume you mean the pin reads LOW until it is pressed. If that is the case, you would do something like:
100 IF PIN(7) = 0 THEN GOTO 100
If the pin is HIGH until it is pressed, just change the zero to a one.
Bean
That did the trick - Thanks.
Not sure what happened, I thought that I had tried that, but must have messed up something ...
Anyway thanks. This is being used in that intro book that I told you about at UPENE '12.
Also, I seem to be missing something here. According to the QuickStart schematic, the Prop pin is connected through a 100K resistor (part of R8) and then to the switch S2 (touchpad) and then on to ground. It seems to me that this should be reading a high (via the internal pull-up resistor on the Prop pin) until you touch the switch, when the switch shorts the pin to ground.
My program sits at the IF line, like you describe in line 100 above, until the person pushes the button (touchpad) and then continues on with the rest of the program. That part works as advertised, but it seems to me that I should be waiting while the pin is showing a high (by doing an IF PIN(7) = 1 THEN ...) and then continuing on with the rest of the program when the pin goes to low - grounded through the touchpad S2 (I.E. the IF statement fails in looking for a 1.)
Is this touchpad acting like a normally-closed switch? Is the schematic wrong? Is there an inverter on the input pins? Any ideas on how I can explain this?
The quickstart buttons don't work like that. They are kind of hard to read accurately.
If I remember correctly I would make the button pin high, then make it an input. Then wait a short time and see if the pin had changed to low (if it was touched). But it didn't work real well.
I have two touch pad drivers that I've been using.
This one is pure Spin. Straight forward and fairly simple.
But slower than the PASM version.
Both do the same thing, pretty much the same way.
They run is a different cog so that they run constantly.
They return a byte that has the touch pad pins encoded into it.
bit zero = pin zero, etc,
So all we have to do to read a touch pad is to examine the corresponding bit in the returned byte.
Examples below...
'CON { QS_ButtonScan.spin }' { returns buttons packed bitwide is a byte}VARLONG ButtonAdr, ButtonCog, delay
LONG Stack[ 16 ] ' define my stackPUBstart( BAdr )' start this in a new cog
ButtonAdr := BAdr ' save address of return byteif ButtonCog ' did the new cog start?cogstop(ButtonCog-1) ' OOPS! no cog available
ButtonCog := cognew(ButtonScan, @Stack) + 1
delay := 4*(clkfreq/1000)
PUBButtonScan | B, B1' local variablesdira [0..7] := %11111111' all pad pins outputs outa [0..7] := %11111111' all pad pins high 'main loop - scan the buttons Repeat' loop foreverRepeat B from0to7' QS LEDS are pins 0-7dira [B] := 1' make pin an output dira [B] := 0' make pin an inputwaitcnt(delay+cnt) ' short delay for some decay
B1 := ina[B] ' read the padif B1 == 0' 0 here means pressedBYTE[ButtonAdr] |= |< B ' set bit if pressed elseBYTE[ButtonAdr] &= !|< B ' clear bit if not
Demo program:
CON{ QS_POPO - press on press off demo }_CLKMODE=XTAL2_xinfreq = 5_000_000VARbyte Buttons, State[8]
OBJ button: "QS_Buttons"' touchpad driverPUBDemo | B' local variable B
button.start( @Buttons ) ' send address of Buttonsouta[ 16..23 ] := $00' all LED pins off 'dira[ 16..23 ] := $FF' all LED pins outputs RepeatRepeat B from0to7' chack all 8 buttons if Buttons & |< B ' is bit set?if state[b] == 1
state[b] := 0else
state[b] := 1Repeat B from0to7' check all 8 buttons if state[b] == 1
TurnOn(b+16) ' cooresponding LED onelse
TurnOff(b+16) ' else off PUBTurnON(pin)outa[pin] := 1PUBTurnOFF(pin)outa[pin] := 0
10 btn=720 led=2330 LOW led
40 HIGH btn
50 INPUT btn
60 PAUSE 1070 b=PIN(btn)
80IF b=1 THEN 11090 HIGH led
100 GOTO 120110 LOW led
120 GOTO 40
jwaldha,
Still a heavy Spin influence doesn't it, but yeah baby.
The other interpretation of BASIC : Business And Scientific Instruction Code
nit-picking, of course.
If I may?
INP/OUT reserved words
30 OUT led, low
and/or
50 inputbit = INP(btn)
Please lest we open ancient GOTO fueds!
Looping structures!
For/Next/iNC
While/Wend
"Well that would be just great".... Office Space
As for intrinsic I/O, BASIC flavor.
BASIC should provide the user with I/O device control for any built in circuitry.
Open(port) for (R/W/RO/WO/DCTL/Stream?) as Name
Print Name (formatting), data
Write Name, buf
INPUT Name (formatting), buf
OUT port, buf USING (Formatting)
So the QSdemo might then go...
Open 23 for OUTPUT as led
Open 7 for INPUT as btn
WHILE 1
OUT led, high
Button = INP(btn)
...
WEND
END
Any chance of a VGA version of this? I'd sure love to run this on the VGAplus board. I got rid of my composite monitor a month ago when I installed my new system and monitor.
Any chance of a VGA version of this? I'd sure love to run this on the VGAplus board. I got rid of my composite monitor a month ago when I installed my new system and monitor.
Jeff
Ha, funny you should ask. I've been working on it lately just for the PMC. It's not finished yet. I need to implement LINE (easy) and SD card routines (hard). But here it is...
tokGOTO CON131' GOTO GOTO lineNumber
tokLET CON132' LET LET var=value
tokPAUSE CON133' PAUSE PAUSE value
tokHIGH CON134' HIGH HIGH value
tokLOW CON135' LOW LOW value
tokCLS CON136' CLS CLS
tokLIST CON137' LIST LIST {value}
tokRUN CON138' RUN RUN
tokPRINT CON139' PRINT PRINT value
tokCONT CON140' CONT CONT
tokINPUT CON141' INPUT INPUT value
tokOUTPUT CON142' OUTPUT OUTPUT value
tokDUMP CON143' DUMP DUMP
tokCNT CON144' CNT LET A=CNT
tokREM CON145' REM REM COMMENT
tokIF CON146' IF IF A = B THEN commands
tokTHEN CON147' THEN
tokELSE CON148' IF...THEN...ELSE
tokNotEqual CON149' IF a <> b
tokLessEqual CON150' IF a <= b
tokGreaterEqual CON151' IF a >= b
tokSHL CON152' LET a=b SHL 4
tokSHR CON153' LET a=b SHR 5
tokINKEY CON154' LET A = INKEY
tokCHR CON155' PRINT CHR$(65) ' Prints ascii character "A"
tokPEEK CON156' LET A = PEEK(B)
tokPEEKW CON157' LET A = PEEKW(B)
tokPEEKL CON158' LET A = PEEKL(B)
tokPOKE CON159' POKE A,B
tokPOKEW CON160' POKEW A,B
tokPOKEL CON161' POKEL A,B
tokVARS CON162' LET A = VARS ' Gets address of vars (program - 104)
tokCHARS CON163' LET A = CHARS ' Gets address of character bitmaps
tokFREE CON164' PRINT FREE ' Print number of program bytes available
tokSCREEN CON165' POKE SCREEN,a ' Put data directly into screen memory
tokDEBUG CON166' DEBUG ' Shows line #'s as it runs
tokNODEBUG CON167' NODEBUG ' Does NOT show line #'s as it runs
tokNEW CON168' NEW ' clears program
tokINA CON169' INA LET A=INA
tokOUTA CON170' OUTA LET OUTA=value
tokDIRA CON171' DIRA LET DIRA=value
tokCTRA CON172' CTRA = value
tokCTRB CON173' CTRB = value
tokFRQA CON174' FRQA = value
tokFRQB CON175' FRQB = value
tokPHSA CON176' PHSA = value
tokPHSB CON177' PHSB = value
tokVCFG CON178' VCFG = value
tokVSCL CON179' VSCL = value
tokSAVE CON180' SAVE if you have 64K EEPROM you can specify 1-4 as a program slot
tokFOR CON181' FOR A = 1 TO 10 STEP 1
tokTO CON182
tokSTEP CON183
tokNEXT CON184
tokGOSUB CON185' GOSUB 1000
tokRETURN CON186' RETURN ' Returns from subroutine
tokEND CON187' END ' Stops program and returns to command prompt
tokLOAD CON188' LOAD if you have 64K EEPROM you can specify 1-4 as a program slot
tokPAUSEUS CON189' PAUSEUS value ' Pauses for "value" microseconds
tokPIN CON190' PIN pin#,state or PIN pin#..pin#,value (does NOT set pin to an output)
tokPINF CON191' var=PIN pin# or var=PIN pin#..pin#
tokREAD CON192' READ var{,var,etc}
tokDATA CON193' DATA value, value, value
tokRESTORE CON194' RESTORE line#
tokLOCATE CON195' LOCATE x,y
tokRND CON196' a=RND(expr) ' Returns random value from 0 to expr-1
tokPLOT CON197' PLOT x,y,color
tokLINE CON198' LINE x,y,color (not implemented yet)
tokDotDot CON199' .. as in "a=pin 0..7"
tokABS CON200' var=ABS(expr)
tokNOT CON201' var=NOT expr or IF NOT a=b (NOT 0 gives -1; NOT "non-zero" gives 0)
tokAND CON202' IF (a=b) AND (c=d) THEN
tokOR CON203' IF (a=b) OR (c=d) THEN
tokSHIFTOUT CON204' SHIFTOUT Dpin, Cpin, Mode, expression, bits
tokSHIFTIN CON205' var=SHIFTIN(Dpin, Cpin, Mode, variable, bits)
tokI2CSTART CON206' I2CSTART SDApin, SCLpin
tokI2CSTOP CON207' I2CSTOP SDApin, SCLpin
tokI2CWRITE CON208' I2CWRITE SDApin, SCLpin, expression
tokI2CREAD CON209' var=I2CREAD(SDApin, SCLpin)
tokFCOLOR CON210' FCOLOR foregroundcolor(0 to 63)
tokBCOLOR CON211' BCOLOR backgroundcolor(0 to 63)
tokCOLOR CON212' COLOR colorvalue (colorvalue = foreground + background * 64)
tokApos CON213' Apostrophe (for remark)
tokREV CON214' var=expr1 REV expr2 ' Reverses expr2 bits of value expr1
tokSAR CON215' var=expr1 SAR expr2 ' Shift arithmetic right expr1 by expr2 bits
tokROL CON216' var=expr1 ROL expr2 ' Rotate left expr1 by expr2 bits
tokROR CON217' var=expr1 ROR expr2 ' Rotate right expr1 by expr2 bits
tokMOD CON218' var=expr1 // expr2 ' Modulus
tokHELP CON219' Shows list of commands (needs updated)
tokUNPLOT CON220' UNPLOT x,y{,bcolor} (not implemented)
tokSOUND CON221' SOUND tone{,length} (not implemented)
I tried to load to RAM and EEPROM the PBASIC 2 code you posted for the first time to my Quickstart with either Human Interface Board or PMC256 (64 color mode) and got this error. See JPG attachment. It doesn't like the @@@ statements in ASM.
It's probably something simple that I'm not aware of using this for the first time.
Comments
10 a=CNT 20 FOR b=1 TO 1000 30 NEXT b 40 a=CNT-a 50 PRINT a/80000;" milliseconds."
PE-Basic gives 33 milliseconds for a 1 to 1000 for...next loop.
Bean
Thank you very much for PropBasic and PE-Basic.
I've tried the version 0.16 and I get an error message: INVALID PARAMETER __param1 and ....__ param2
for these subroutines : At first I have all pin numbers for pin 29 and pin 28 changed to SDA and SCL but the error message appear again. Then I changed the subroutine: I compiled the modified program and load it into the propeller. With the speed-measuring program I've tried saving and loading the program into the EEPROM. It runs without any problems.
I think it should be possible to pass the PIN numbers (SDA and SCL = 29 and 28) only in the four subroutines?
development environment : Linux, BST, PropBasic-00.01.12-78
With best regards
--G
You need to get the latest version of the PropBasic compiler.
The latest is version 00.01.14 and you may download it from BradC website here http://www.fnarfbargle.com/PropBasic/
It is at the bottom of the list. Make sure to get the correct version Mac, Linux or Windows.
Bean
But a PropBasic test program for my Gam_Bo_Prop now needs a couple of minutes to compile but without any error message. I'll try to find the error otherwise I post in the PropBasic thread.
With best regards
G
This subroutine does not take any inputs and uses only INPZ as a temporary variable. It returns the numeric input in the variable INP
If you need more than one input, call the subroutine with a GOSUB 32000, and then save it to another variable before calling the subroutine again.
10 PRINT "Please enter your age: "; 20 GOSUB 32000:PRINT 30 PRINT "You are currently ";inp;" years old." 40 PRINT "Next year, you will turn ";inp + 1;" years old." 50 END 32000 ' Input INP 32001 ' Uses: INPZ for temporary storage 32010 inp=0 32020 inpz=INKEY:IF inpz=0 THEN 32020 32030 IF inpz=13 THEN 32080 32040 IF inpz=8 THEN DISPLAY 8:DISPLAY 32:DISPLAY 8:inp=inp/10:GOTO 32020 32050 inpz=inpz-48:IF inpz<0 OR inpz>9 THEN 32020 32055 PRINT inpz; 32060 inp=inp*10+inpz 32070 GOTO 32020 32080 RETURN
Lines 10-50 are just a simple program to demonstrate usage of the subroutine. The routine takes into consideration the backspace key, and ignores non-numeric characters.
HyperTerminal actually made for a nice development environment. I had to add about 20 ms of line delay in the ASCII Setup in the Settings tab of the Properties. That allowed me to use the full-screen editing capability of Notepad, and when I was ready to test my code, I selected the code in Notepad and copied it to the clipboard, clicked on HyperTerminal and typed new, then right-clicked and selected Paste to Host. That entered the code and I was able to list it and run it on the Prop. (Normally I use Linux, but I am at work, and we only have Windows here. Does anyone have a nice terminal emulator for Linux that can do that - the BST terminal does not accept pasted text as far as I can tell.)
I most-love the autoexecute capabilities of PE_BASIC. That actually works better than any other on-chip language, because microcontrollers are supposed to automatically run at power up.
Great job Bean!
I am new to this Forum and looking for a tiny embedded interpreter, that can run programs like BASIC or scripting language, that are provided as text to it.
AND it should be able to access functions provided in SPIN or PASM whick build the drivers and system level.
I want to use it to allow users of our test systems to write test-scripts - calling predef. test steps, setting parameters and manipulating results, loops and conditionals, Vars and ideally arrays ...
just a very simple language -
PEBasic seems to come quite close -
but:-
can you call PASM or SPIN?
PEBasic in one COG and the others doing realtime stuff ?
any other ideas / existing code or ... you long time propeller users ??
Thanks
Using the standard PE-BASIC language you cannot call PASM or SPIN code.
You would have to modify the PE-BASIC source code (written in PropBASIC) to add commands to do whatever you need.
The source code for PE-BASIC is "open-source".
Let me know if you want to do this.
Bean (Creator of PE-BASIC and PropBasic)
Using the standard PE-BASIC language you cannot call PASM or SPIN code.
You would have to modify the PE-BASIC source code (written in PropBASIC) to add commands to do whatever you need.
The source code for PE-BASIC is "open-source".
Let me know if you want to do this.
Bean (Creator of PE-BASIC and PropBasic)
Using the standard PE-BASIC language you cannot call PASM or SPIN code.
You would have to modify the PE-BASIC source code (written in PropBASIC) to add commands to do whatever you need.
The source code for PE-BASIC is "open-source".
Let me know if you want to do this.
Bean (Creator of PE-BASIC and PropBasic)
Another alternative solution could be PropForth, a Forth development system that runs on one or more Propellers. It doesn't directly run SPIN or PASM routines but it does have an assembler for time critical code. You would develop your entire application in Forth and due to its interactive nature, you could test/change/monitor variables from one cog while application routines run in another cog.
Due the the limited memory in the Propeller, it would be very difficult to have an embedded BASIC which you could add to an existing like you can add VBA for example to a PC application. the best you could do with SPIN/PASM would be to write a simple monitor routine to give you some of the variable inspection and testing you require. The other alternative is to see what pieces of PE-BASIC could be used with you code as an embedded monitor.
Welcome and keep us informed on where you end up, it sounds like an interesting and useful tool!
my first propeller is scheduled to arrive today
unfortunately I have to focus on my bread&butter project for a while now.
While slowly discovering all the Prop developments - like ViewPort, PropBsasic, PropForth, Spinnernet,... I habe quite s.th. to digest at the moment ...
Any propeller users here in Germany near Stuttgart ?? please contact me.
How would I check the level of a pin? I am trying to pause a program until the user pushes a button on P7.
The button is tied through a resistor to ground - as in the QuickStart board.
100 IF PIN(7) = 0 THEN GOTO 100
If the pin is HIGH until it is pressed, just change the zero to a one.
Bean
That did the trick - Thanks.
Not sure what happened, I thought that I had tried that, but must have messed up something ...
Anyway thanks. This is being used in that intro book that I told you about at UPENE '12.
Also, I seem to be missing something here. According to the QuickStart schematic, the Prop pin is connected through a 100K resistor (part of R8) and then to the switch S2 (touchpad) and then on to ground. It seems to me that this should be reading a high (via the internal pull-up resistor on the Prop pin) until you touch the switch, when the switch shorts the pin to ground.
My program sits at the IF line, like you describe in line 100 above, until the person pushes the button (touchpad) and then continues on with the rest of the program. That part works as advertised, but it seems to me that I should be waiting while the pin is showing a high (by doing an IF PIN(7) = 1 THEN ...) and then continuing on with the rest of the program when the pin goes to low - grounded through the touchpad S2 (I.E. the IF statement fails in looking for a 1.)
Is this touchpad acting like a normally-closed switch? Is the schematic wrong? Is there an inverter on the input pins? Any ideas on how I can explain this?
If I remember correctly I would make the button pin high, then make it an input. Then wait a short time and see if the pin had changed to low (if it was touched). But it didn't work real well.
Bean
See if this will help?
I have two touch pad drivers that I've been using.
This one is pure Spin. Straight forward and fairly simple.
But slower than the PASM version.
Both do the same thing, pretty much the same way.
They run is a different cog so that they run constantly.
They return a byte that has the touch pad pins encoded into it.
bit zero = pin zero, etc,
So all we have to do to read a touch pad is to examine the corresponding bit in the returned byte.
Examples below...
'CON { QS_ButtonScan.spin } ' { returns buttons packed bitwide is a byte} VAR LONG ButtonAdr, ButtonCog, delay LONG Stack[ 16 ] ' define my stack PUB start( BAdr ) ' start this in a new cog ButtonAdr := BAdr ' save address of return byte if ButtonCog ' did the new cog start? cogstop(ButtonCog-1) ' OOPS! no cog available ButtonCog := cognew(ButtonScan, @Stack) + 1 delay := 4*(clkfreq/1000) PUB ButtonScan | B, B1 ' local variables dira [0..7] := %11111111 ' all pad pins outputs outa [0..7] := %11111111 ' all pad pins high 'main loop - scan the buttons Repeat ' loop forever Repeat B from 0 to 7 ' QS LEDS are pins 0-7 dira [B] := 1 ' make pin an output dira [B] := 0 ' make pin an input waitcnt(delay+cnt) ' short delay for some decay B1 := ina[B] ' read the pad if B1 == 0 ' 0 here means pressed BYTE[ButtonAdr] |= |< B ' set bit if pressed else BYTE[ButtonAdr] &= !|< B ' clear bit if not
Demo program:
CON { QS_POPO - press on press off demo } _CLKMODE=XTAL2 _xinfreq = 5_000_000 VAR byte Buttons, State[8] OBJ button: "QS_Buttons" ' touchpad driver PUB Demo | B ' local variable B button.start( @Buttons ) ' send address of Buttons outa[ 16..23 ] := $00 ' all LED pins off ' dira[ 16..23 ] := $FF ' all LED pins outputs Repeat Repeat B from 0 to 7 ' chack all 8 buttons if Buttons & |< B ' is bit set? if state[b] == 1 state[b] := 0 else state[b] := 1 Repeat B from 0 to 7 ' check all 8 buttons if state[b] == 1 TurnOn(b+16) ' cooresponding LED on else TurnOff(b+16) ' else off PUB TurnON(pin) outa[pin] := 1 PUB TurnOFF(pin) outa[pin] := 0
10 btn=7 20 led=23 30 LOW led 40 HIGH btn 50 INPUT btn 60 PAUSE 10 70 b=PIN(btn) 80 IF b=1 THEN 110 90 HIGH led 100 GOTO 120 110 LOW led 120 GOTO 40
jwaldha,
Still a heavy Spin influence doesn't it, but yeah baby.
The other interpretation of BASIC : Business And Scientific Instruction Code
nit-picking, of course.
If I may?
INP/OUT reserved words
30 OUT led, low
and/or
50 inputbit = INP(btn)
Please lest we open ancient GOTO fueds!
Looping structures!
For/Next/iNC
While/Wend
"Well that would be just great".... Office Space
As for intrinsic I/O, BASIC flavor.
BASIC should provide the user with I/O device control for any built in circuitry.
Open(port) for (R/W/RO/WO/DCTL/Stream?) as Name
Print Name (formatting), data
Write Name, buf
INPUT Name (formatting), buf
OUT port, buf USING (Formatting)
So the QSdemo might then go...
Open 23 for OUTPUT as led
Open 7 for INPUT as btn
WHILE 1
OUT led, high
Button = INP(btn)
...
WEND
END
just two cents
Any chance of a VGA version of this? I'd sure love to run this on the VGAplus board. I got rid of my composite monitor a month ago when I installed my new system and monitor.
Jeff
Ha, funny you should ask. I've been working on it lately just for the PMC. It's not finished yet. I need to implement LINE (easy) and SD card routines (hard). But here it is...
Try this demo program to see how fast it is
10 CLS 20 x=RND(50) 30 y=RND(37) 40 c=RND(64) 100 PLOT x,y,c 110 PLOT 99-x,y,c 120 PLOT x,73-y,c 130 PLOT 99-x,73-y,c 200 GOTO 20
Bean
tokGOTO CON 131 ' GOTO GOTO lineNumber tokLET CON 132 ' LET LET var=value tokPAUSE CON 133 ' PAUSE PAUSE value tokHIGH CON 134 ' HIGH HIGH value tokLOW CON 135 ' LOW LOW value tokCLS CON 136 ' CLS CLS tokLIST CON 137 ' LIST LIST {value} tokRUN CON 138 ' RUN RUN tokPRINT CON 139 ' PRINT PRINT value tokCONT CON 140 ' CONT CONT tokINPUT CON 141 ' INPUT INPUT value tokOUTPUT CON 142 ' OUTPUT OUTPUT value tokDUMP CON 143 ' DUMP DUMP tokCNT CON 144 ' CNT LET A=CNT tokREM CON 145 ' REM REM COMMENT tokIF CON 146 ' IF IF A = B THEN commands tokTHEN CON 147 ' THEN tokELSE CON 148 ' IF...THEN...ELSE tokNotEqual CON 149 ' IF a <> b tokLessEqual CON 150 ' IF a <= b tokGreaterEqual CON 151 ' IF a >= b tokSHL CON 152 ' LET a=b SHL 4 tokSHR CON 153 ' LET a=b SHR 5 tokINKEY CON 154 ' LET A = INKEY tokCHR CON 155 ' PRINT CHR$(65) ' Prints ascii character "A" tokPEEK CON 156 ' LET A = PEEK(B) tokPEEKW CON 157 ' LET A = PEEKW(B) tokPEEKL CON 158 ' LET A = PEEKL(B) tokPOKE CON 159 ' POKE A,B tokPOKEW CON 160 ' POKEW A,B tokPOKEL CON 161 ' POKEL A,B tokVARS CON 162 ' LET A = VARS ' Gets address of vars (program - 104) tokCHARS CON 163 ' LET A = CHARS ' Gets address of character bitmaps tokFREE CON 164 ' PRINT FREE ' Print number of program bytes available tokSCREEN CON 165 ' POKE SCREEN,a ' Put data directly into screen memory tokDEBUG CON 166 ' DEBUG ' Shows line #'s as it runs tokNODEBUG CON 167 ' NODEBUG ' Does NOT show line #'s as it runs tokNEW CON 168 ' NEW ' clears program tokINA CON 169 ' INA LET A=INA tokOUTA CON 170 ' OUTA LET OUTA=value tokDIRA CON 171 ' DIRA LET DIRA=value tokCTRA CON 172 ' CTRA = value tokCTRB CON 173 ' CTRB = value tokFRQA CON 174 ' FRQA = value tokFRQB CON 175 ' FRQB = value tokPHSA CON 176 ' PHSA = value tokPHSB CON 177 ' PHSB = value tokVCFG CON 178 ' VCFG = value tokVSCL CON 179 ' VSCL = value tokSAVE CON 180 ' SAVE if you have 64K EEPROM you can specify 1-4 as a program slot tokFOR CON 181 ' FOR A = 1 TO 10 STEP 1 tokTO CON 182 tokSTEP CON 183 tokNEXT CON 184 tokGOSUB CON 185 ' GOSUB 1000 tokRETURN CON 186 ' RETURN ' Returns from subroutine tokEND CON 187 ' END ' Stops program and returns to command prompt tokLOAD CON 188 ' LOAD if you have 64K EEPROM you can specify 1-4 as a program slot tokPAUSEUS CON 189 ' PAUSEUS value ' Pauses for "value" microseconds tokPIN CON 190 ' PIN pin#,state or PIN pin#..pin#,value (does NOT set pin to an output) tokPINF CON 191 ' var=PIN pin# or var=PIN pin#..pin# tokREAD CON 192 ' READ var{,var,etc} tokDATA CON 193 ' DATA value, value, value tokRESTORE CON 194 ' RESTORE line# tokLOCATE CON 195 ' LOCATE x,y tokRND CON 196 ' a=RND(expr) ' Returns random value from 0 to expr-1 tokPLOT CON 197 ' PLOT x,y,color tokLINE CON 198 ' LINE x,y,color (not implemented yet) tokDotDot CON 199 ' .. as in "a=pin 0..7" tokABS CON 200 ' var=ABS(expr) tokNOT CON 201 ' var=NOT expr or IF NOT a=b (NOT 0 gives -1; NOT "non-zero" gives 0) tokAND CON 202 ' IF (a=b) AND (c=d) THEN tokOR CON 203 ' IF (a=b) OR (c=d) THEN tokSHIFTOUT CON 204 ' SHIFTOUT Dpin, Cpin, Mode, expression, bits tokSHIFTIN CON 205 ' var=SHIFTIN(Dpin, Cpin, Mode, variable, bits) tokI2CSTART CON 206 ' I2CSTART SDApin, SCLpin tokI2CSTOP CON 207 ' I2CSTOP SDApin, SCLpin tokI2CWRITE CON 208 ' I2CWRITE SDApin, SCLpin, expression tokI2CREAD CON 209 ' var=I2CREAD(SDApin, SCLpin) tokFCOLOR CON 210 ' FCOLOR foregroundcolor(0 to 63) tokBCOLOR CON 211 ' BCOLOR backgroundcolor(0 to 63) tokCOLOR CON 212 ' COLOR colorvalue (colorvalue = foreground + background * 64) tokApos CON 213 ' Apostrophe (for remark) tokREV CON 214 ' var=expr1 REV expr2 ' Reverses expr2 bits of value expr1 tokSAR CON 215 ' var=expr1 SAR expr2 ' Shift arithmetic right expr1 by expr2 bits tokROL CON 216 ' var=expr1 ROL expr2 ' Rotate left expr1 by expr2 bits tokROR CON 217 ' var=expr1 ROR expr2 ' Rotate right expr1 by expr2 bits tokMOD CON 218 ' var=expr1 // expr2 ' Modulus tokHELP CON 219 ' Shows list of commands (needs updated) tokUNPLOT CON 220 ' UNPLOT x,y{,bcolor} (not implemented) tokSOUND CON 221 ' SOUND tone{,length} (not implemented)
At risk of being thought of of offering a bribe, Would you like a VGAplus256 board?
Jeff
I tried to load to RAM and EEPROM the PBASIC 2 code you posted for the first time to my Quickstart with either Human Interface Board or PMC256 (64 color mode) and got this error. See JPG attachment. It doesn't like the @@@ statements in ASM.
It's probably something simple that I'm not aware of using this for the first time.
Thanks,
Tim
Bean