thotro / arduino-dw1000

A library that offers functionality to use Decawave's DW1000 chips/modules with Arduino.
Apache License 2.0
527 stars 288 forks source link

Strange programming of library #74

Closed Rotzbua closed 7 years ago

Rotzbua commented 8 years ago
  1. Why is everything in DW1000.h static? Is there a reason for programming it as a singleton?
  2. Why is short and int used? Both are 16bit for atmegas.
MarioRuz commented 8 years ago

I also thought about that @Rotzbua , especially point 1. Maybe @thotro can tell us about that :).

Thanks!

thotro commented 8 years ago

Hi there, both very good questions, indeed: neither the use of static nor the explicit use of short relates to a particular design decision ;-)

So, you're right, the static declarations should better go and see the garbage bin.

The shorts are not really bad of course, but here their actual purpose is questionable. I'm indifferent regarding them.

Thanks and cheers, Thomas

MikeS159 commented 8 years ago

Although I agree there should be justification for making something static, static functions do save a small amount of memory. The trade off isn't normally worth it, but in the case of a micro-controller it might be. The Ranging Anchor/Tab takes about 70% of program memory on a Uno, and adding my code on top I was getting to 97% before I started making some optimizations and design changes.

Rotzbua commented 7 years ago

Solved.