From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: bbc:microbit and buttons and No_Implicit_Dynamic_Code Date: Wed, 25 Jul 2018 09:31:19 +0200 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 25 Jul 2018 07:32:21 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="7ab098c8268958480cc93e43d12997a5"; logging-data="11638"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jMAKe+RkHiVqqrLLAEMBG" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:OsGNqX+pXESFqez5BWw9IQLZU/M= Content-Language: en-US X-Mozilla-News-Host: news://news.eternal-september.org:119 Xref: reader02.eternal-september.org comp.lang.ada:53957 Date: 2018-07-25T09:31:19+02:00 List-Id: Hi! I got my microbot yesterday. I read about it here and decided to try it out. I also downloaded the cross-compiler and the gpl 2018 for linux and ran it all on a linux virtualBox guest on a win 10 system. I also cloned the Ada_Drivers_Library from github To my surprise - it just worked :-) And there was examples too. I did try avr-ada with an Arduino Nano with limited success a couple of years ago,but this was a very pleasant surprise. So I tried some code of my own, and there are 3 things I wonder. 1 - gpr and style. Why does the setting in the gpr file insist on a certain style, and treat everything else as error. Selecting all + tab does not pretty print in a way that the gpr file wants. Someone new to Ada would have a real hard time to get anything done. (Yes I did remove the gnaty but it should be so by default) 2 - Debugging. How do I do it? I've almost never used the debugger, not via GPS nor via GDB. Is there a guide somewhere how to use it via GPS? (Put_Lines have been my friend, thinking of taking advantage of the GPS) 3 - The microbit has 2 buttons. And the microbit.Button package has a way of subscribing callbacks to pressed/released events. But trying to use it I get main.adb:55:33: violation of restriction "No_Implicit_Dynamic_Code" at system.ads:45 code as below. with Microbit.Display; with Microbit.Buttons; with Microbit.Time; procedure Main is use Microbit.Buttons; procedure Button_Pressed(Button : Button_Id; State : Button_State) is begin case State is when Pressed => Microbit.Display.Set(2,2); when Released => Microbit.Display.Clear(2,2); end case; end Button_Pressed; Ok : Boolean := True; begin MicroBit.Display.Clear; Ok := Subscribe(Button_Pressed'Unrestricted_Access); if Ok then Microbit.Display.Set(0,0); end if; loop Microbit.Time.Delay_Ms (200); end loop; end Main; I did find an example using if State (Button_A) = Pressed then so problem is fixed, but I like the callback style here. Thanks for a good integration. (And I see that I can use my Adafruit Thermo printer too :-) ) -- -- Björn