comp.lang.ada
 help / color / mirror / Atom feed
* bbc:microbit and buttons and No_Implicit_Dynamic_Code
@ 2018-07-25  7:31 Björn Lundin
  2018-07-25  9:03 ` fabien.chouteau
  0 siblings, 1 reply; 5+ messages in thread
From: Björn Lundin @ 2018-07-25  7:31 UTC (permalink / raw)



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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: bbc:microbit and buttons and No_Implicit_Dynamic_Code
  2018-07-25  7:31 bbc:microbit and buttons and No_Implicit_Dynamic_Code Björn Lundin
@ 2018-07-25  9:03 ` fabien.chouteau
  2018-07-25  9:29   ` Björn Lundin
  0 siblings, 1 reply; 5+ messages in thread
From: fabien.chouteau @ 2018-07-25  9:03 UTC (permalink / raw)


Hi Björn,

I'm Fabien and I work for AdaCore, in particular I was involved in the support of the micro:bit.

On Wednesday, July 25, 2018 at 9:32:22 AM UTC+2, björn lundin wrote:
> To my surprise - it just worked :-)

Thanks for the feedback, that was our goal :)

> 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)
> 

This is to enforce the coding style of the library. I agree that this is not very friendly for beginners. I will try to find a solution. 
I opened a issue on github for this: https://github.com/AdaCore/Ada_Drivers_Library/issues/271

> 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)

We could have a debugging example.

> 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

I was not aware of this problem, can you please open an issue on GitHub for this? https://github.com/AdaCore/Ada_Drivers_Library/issues

Regards,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: bbc:microbit and buttons and No_Implicit_Dynamic_Code
  2018-07-25  9:03 ` fabien.chouteau
@ 2018-07-25  9:29   ` Björn Lundin
  2018-09-05 16:38     ` fabien.chouteau
  0 siblings, 1 reply; 5+ messages in thread
From: Björn Lundin @ 2018-07-25  9:29 UTC (permalink / raw)


On 2018-07-25 11:03, fabien.chouteau@gmail.com wrote:
> 
> This is to enforce the coding style of the library. 
I understand that. But it is annoying to get a compilation error
for writing 'Microbit' instead of 'MicroBit', especially in a case
insensitive language.

>I agree that this is not very friendly for beginners. I will try to find a solution. 
> I opened a issue on github for this: https://github.com/AdaCore/Ada_Drivers_Library/issues/271

Great

> 
> We could have a debugging example.
Yes, please consider it.
My wife works as a science teacher grades 7-9.
They now have to teach programming.
The MicroBit is essentially what they need.
It would be a pity if they write Javascript then...
But perhaps they will use the block language instead.
But it would be nice if Ada was an easy and well documented option.
This is going the right way, I think.


>> main.adb:55:33: violation of restriction "No_Implicit_Dynamic_Code" at
>> system.ads:45
> 
> I was not aware of this problem, can you please open an issue on GitHub for this? https://github.com/AdaCore/Ada_Drivers_Library/issues

I'll do that.


-- 
--
Björn

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: bbc:microbit and buttons and No_Implicit_Dynamic_Code
  2018-07-25  9:29   ` Björn Lundin
@ 2018-09-05 16:38     ` fabien.chouteau
  2018-09-07  9:07       ` Björn Lundin
  0 siblings, 1 reply; 5+ messages in thread
From: fabien.chouteau @ 2018-09-05 16:38 UTC (permalink / raw)


Hi Björn,

On Wednesday, July 25, 2018 at 11:30:36 AM UTC+2, björn lundin wrote:
> On 2018-07-25 11:03, fabien.chouteau wrote:
> > 
> > This is to enforce the coding style of the library. 
> I understand that. But it is annoying to get a compilation error
> for writing 'Microbit' instead of 'MicroBit', especially in a case
> insensitive language.
> 
> >I agree that this is not very friendly for beginners. I will try to find a solution. 
> > I opened a issue on github for this: https://github.com/AdaCore/Ada_Drivers_Library/issues/271
> 

The style checks are now optional and disabled by default. You can enable them with a scenario variable.

> 
> >> main.adb:55:33: violation of restriction "No_Implicit_Dynamic_Code" at
> >> system.ads:45
> > 
> > I was not aware of this problem, can you please open an issue on GitHub for this? https://github.com/AdaCore/Ada_Drivers_Library/issues
> 

I answered here: https://github.com/AdaCore/Ada_Drivers_Library/issues/272

Regards,


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: bbc:microbit and buttons and No_Implicit_Dynamic_Code
  2018-09-05 16:38     ` fabien.chouteau
@ 2018-09-07  9:07       ` Björn Lundin
  0 siblings, 0 replies; 5+ messages in thread
From: Björn Lundin @ 2018-09-07  9:07 UTC (permalink / raw)


On 2018-09-05 18:38, fabien.chouteau@gmail.com wrote:
> 
> The style checks are now optional and disabled by default. You can enable them with a scenario variable.

Good - thanks

> 
> I answered here: https://github.com/AdaCore/Ada_Drivers_Library/issues/272

Perfect - I'll try it out this weekend.

-- 
--
Björn


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-07  9:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25  7:31 bbc:microbit and buttons and No_Implicit_Dynamic_Code Björn Lundin
2018-07-25  9:03 ` fabien.chouteau
2018-07-25  9:29   ` Björn Lundin
2018-09-05 16:38     ` fabien.chouteau
2018-09-07  9:07       ` Björn Lundin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox