OttoDIY / blockly

Otto Blockly; a fully integrated graphical programming for any type of Arduino projects, including robots, ready to install in your computer, it works offline and also online
https://www.ottodiy.com/software
GNU General Public License v2.0
114 stars 80 forks source link

Blocks for Interrupts bad generated code #136

Open cparrapa opened 2 years ago

cparrapa commented 2 years ago

i think there is quite another problem. Blockly picks up the wrong C++ statement causing the interrupt not seen. \the statement for interrupt in blockly should translate int: attachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, CHANGE);

The statement should be of the form " attachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, CHANGE);" .

Issue is that the nano and uno interrupt handling is not that flexible.

to do some Realtime event handling with Otto (and nano) you must have good interrupt handling.

a. the setup should include digitalWrite (BUTTON, HIGH), this has to do with internal pullup resistor. I don't know exactly why, Arduino reference may have more info. However this is not relevant for the attach issue. b. the interrupt attach should definitely be of the form: attachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, CHANGE); the attach statement which currently is in the bloc does not work for some reason. This one does. I added a buzzer with two tones to check if it really works, it does. I forgot to save that one. I don't know WHY your original attach doesn't work, requires more study or testing. c. within the ISR you included a statement Read Digital state Pin (BUTTON) = 10 , THAT SHOULD BE 1 , OR HIGH. The 10 doesn't work. This is also not relevant to the attach issue as its inside the ISR which can be anything.

But of course the main thing is b. above, to change the attachInterrupt statement in your interrupt block. There is also info on that in the Arduino reference site.

Perhaps its possible to make two versions of your bloc, in case there is a dependency i am not aware off.

image

logix5 commented 2 years ago

Camilo ya lo reviso porque una parte sí que hay que cambiar, pero lo otro no estoy seguro. Esto no está probado

El mar, 11 ene 2022 a las 8:58, Camilo Parra Palacio (< @.***>) escribió:

Assigned #136 https://github.com/OttoDIY/blockly/issues/136 to @logix5 https://github.com/logix5.

— Reply to this email directly, view it on GitHub https://github.com/OttoDIY/blockly/issues/136#event-5871062517, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZ4AUFHYVWHQR4ZSMAVV53UVPPKPANCNFSM5IIARUHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were assigned.Message ID: @.***>

-- Óscar Ferruz Romero Socio fundador. Tel. 620.402.168

C/ Artajona, 17. 28039 - Madrid. www.logix5.com

www.twitter.com/Logix5_SS http://www.twitter.com/logix5_SS

www.facebook.com/logix5

www.instagram.com/logix5_smart_solutions

Conforme dispone el Reglamento (UE) 2016/679 del Parlamento Europeo y del Consejo, de 27 de abril de 2016, relativo a la protección de las personas físicas en lo referente al tratamiento de datos personales y a la libre circulación de estos, le informamos que los datos personales facilitados y recogidos en este e-mail y sus documentos adjuntos serán tratados e incluidos automatizadamente en los ficheros de datos personales bajo responsabilidad de LOGIX5 SMART SOLUTIONS, S.L. B-86129699, donde se recogen y almacenan los datos personales con la finalidad exclusiva de formar parte en los procesos de selección de personal, bolsa de trabajo, contratación o gestiones relacionadas con temas laborales que se lleven a cabo. El interesado otorga su consentimiento para el tratamiento de sus datos personales con la finalidad anteriormente mencionada. En el supuesto de producirse alguna modificación de sus datos personales, le solicitamos, nos lo comunique por escrito con la única finalidad de mantenerlos actualizados. LOGIX5 SMART SOLUTIONS, S.L. B-86129699 se compromete a respetar su confidencialidad en el tratamiento de sus datos personales, y le informa que tiene derecho a ejercitar los derechos ARCO (derecho de acceso, rectificación, cancelación y oposición) de sus datos personales mediante solicitud escrita a @.***, adjuntando fotocopia del D.N.I.

"En la vida hay tres cosas que no dan marcha atrás: la palabra pronunciada, la flecha lanzada y la oportunidad perdida, ¿vamos a dejarla escapar?"