slviajero / tinybasic

A BASIC interpreter for Arduino, ESP, RP2040, STM32, Infineon XMC and POSIX with IoT and microcontroller features.
GNU General Public License v3.0
203 stars 31 forks source link

Allow the user to assign an autorun pin #44

Closed twoporylyj closed 1 year ago

twoporylyj commented 1 year ago

Greetings. For now, we have the following in the manual:

"SET 1,1 activates the autorun mode of the EEPROM. SET 1,0 resets the autorun mode. SET 1,255 marks the EEPROM as not to contain a program. SET 1,1 should only be used if a program was stored with SAVE "!" to the EEPROM. There is no safety net here"

This problem can be solved by allowing the user to assign an autorun pin, so that program from EEPROM starts automatically only if that pin is grounded at startup or reset, otherwise the user gets a Basic interpreter prompt in the terminal and can edit and run the program manually. Thanks.

slviajero commented 1 year ago

Thank you! Actually, this mechanism already exists in a slightly different form.
In hardware-arduino.h there is the macro BREAKPIN. If you set that to any pin, then setting the pin to LOW will interrupt the program. The pin is set to INPUT_PULLUP at startup, no external additional circuitry is needed. I forgot to put that into the manual. Will do this asap.

Am 28.12.2022 um 17:30 schrieb twoporylyj @.***>:

Greetings. For now, we have the following in the manual:

"SET 1,1 activates the autorun mode of the EEPROM. SET 1,0 resets the autorun mode. SET 1,255 marks the EEPROM as not to contain a program. SET 1,1 should only be used if a program was stored with SAVE "!" to the EEPROM. There is no safety net here"

This problem can be solved by allowing the user to assign an autorun pin, so that program from EEPROM starts automatically only if that pin is grounded at startup or reset, otherwise the user gets a Basic interpreter prompt in the terminal and can edit and run the program manually. Thanks.

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/44, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56G3MEO6B5KNSJVBTNLWPRTLTANCNFSM6AAAAAATLMUE5E. You are receiving this because you are subscribed to this thread.

twoporylyj commented 1 year ago

Thanks, will try this.

slviajero commented 1 year ago

Great, by the way, you can always interrupt a program by sending the BREAKCHAR. This is # by default. Can be changed to any character.

Am 28.12.2022 um 17:53 schrieb twoporylyj @.***>:

Thanks, will try this.

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/44#issuecomment-1366788780, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56F7APYX5JRGOPXEZEDWPRV7DANCNFSM6AAAAAATLMUE5E. You are receiving this because you commented.

twoporylyj commented 1 year ago

Cool! 10 print &2,"abcd" 20 goto 10 run It began printing "abcd" on HD44780 in endless loop. Then i pressed # without even pressing enter, and program stopped. Thanks. So there actually exists a safety net?

slviajero commented 1 year ago

That’s how it is supposed to work. One remark: the break character has to be the first character send. If you type anything else and then # it won’t work. This is why I added the BREAKPIN. It works always.

Am 28.12.2022 um 18:04 schrieb twoporylyj @.***>:

Cool! 10 print &2,"abcd" 20 goto 10 run It began printing "abcd" on HD44780 in endless loop. Then i pressed # without even pressing enter, and program stopped. Thanks.

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/44#issuecomment-1366796994, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56DQATHXSDBBEJXLVDDWPRXKVANCNFSM6AAAAAATLMUE5E. You are receiving this because you commented.

twoporylyj commented 1 year ago

But is case of error i can push restart button and send # again?

slviajero commented 1 year ago

Yes! It is the statement loop that looks into the input stream. It checks the character in the buffer but does not read it. That’s why it has to be the first character. After reset, the buffer is empty. You can go again.

Am 28.12.2022 um 18:14 schrieb twoporylyj @.***>:

But is case of error i can push restart button and send # again?

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/44#issuecomment-1366803146, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56E236N4EXZMWWSDDO3WPRYPTANCNFSM6AAAAAATLMUE5E. You are receiving this because you commented.

slviajero commented 1 year ago

Closed