Categories

Yield function, printable class and mapping arrays: Useful but unknown features from Arduino core

Posted on Thursday, January 18th, 2018 in Arduino, techniques by DP

test-printable-arduino-1

Yahya Tawil over at Atadiat wrote a new tip for Arduino developers about three hidden and useful features in Arduino core:

Arduino core, the source code of Arduino API functions and classes, has three useful features that can be used effectively. As the Arduino core documentation doesn’t mention them (at least until the time of publishing this micro-blog), these features are not well-known for arduino developers. Let’s discuss each feature of them one by one.

More details at Atadiat blog.

Via the contact form.

 

This entry was posted on Thursday, January 18th, 2018 at 10:51 pm and is filed under Arduino, techniques. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

9 Responses to “Yield function, printable class and mapping arrays: Useful but unknown features from Arduino core”

  1. KH says:

    yield() instead of proper interrupt-driven code? Ewwwwwww… somebody please teach these Arduino folks proper AVR microcontroller programming!

    • Max says:

      Well, there’s your problem. Or rather, the problem with Arduino in general: a) not using interrupts for anything that can’t wait, and b) using delay() at all, for anything that could wait but never, ever should unless you’re literally writing a single LED blink sketch. “We brake for nobody” should be the One Rule – if you have stuff to do, do it; if you don’t, pass execution to the next thing in line. And if you have ten nested “for” loops, maybe you should return and let everything else do some stuff between each iteration instead of lingering around for half an eternity at a time…

    • Yahya Tawil says:

      See the source files of Arduino core first before writing comments.

      yield is defined in Arduino core as a weak function and called in the delay function. Just as a simple as that! no one said it’s good for interrupt-driven code.

      And it’s not related to AVR MCU programming. It’s an embedded C topic.

      • KH says:

        Yes, I know how weak symbols work.

        Yes, I would still prefer interrupt-driven schemes when coding with embedded C.

        Boo.

      • Max says:

        Ayup. On _any_ hardware.

      • KH says:

        Yahya, relax. Some of us are just trained differently. Nobody is outright wrong.

        Massimo Banzi appears to be a software guy. He was at Interaction Design Institue Ivrea. IIRC, and started Ard there, likely not a hard engineering school. Artists always wants MCUs to sequence things, not too different from the more art-focused MIT Media Lab projects. He lists ‘Interaction Designer’ first in the second sentence in his About page. Look at his consultancy list, it screams interaction design or HCI, not embedded MCU or hard engineering. His wisdom will help you get things done quickly, but may not be appropriate among say, automotive or aviation electronics.

      • yahya tawil says:

        KY, I just hate how some engineers and experienced people thing about Arduino.

        And by the way I’m computer engineer and I worked in an RnD department.

        As a bare-metal c developer I learned alot from Arduino core and I try to make the reader aware about the source files and details behind Arduino platform. I just want the hobbyists understand the low level of Arduino which is very good to make them capable to move on to AVR programming later. I know exactly that Arduino style wastes the AVR resources while making programming easy. it’s not a win-win thing, but it is a very interested way to introduce abstraction to MCUs.

        Thanks

      • KH says:

        Max and I, we’re like, just shooting the breeze here. Relax, “hate” is a strong word. The embedded world has been overwhelmed by the Arduino culture, a simplified scheme made by folks who were once involved in the Processing language and was originally targeted towards artist types. Some people like me are always going to poke the Arduino bubble a bit, sorry if it irked you, you should get used to it. :-)

        Arduino is a sort of a champion from the software-centric side. An overwhelming voice from one side is bad if it drowns out other voices. One trend I see is that some software folks (I’m talking in general here) (or maybe the younger set) think they can solve big things, we should get on with them, move at express speed, some traditional hardware folks are just holding progress back. A case in point: Tesla’s confidence in autopilot tech and barrelling ahead with aggressive implementation. Others too, but Tesla’s stuff entails higher risk. One bad glitch every one million hours may still kill plenty of people. Sometimes ideas hit the jackpot, sometimes they don’t (e.g. internet balloons, and such). Don’t mind dinosaurs like me too much, because well, blog on stuff and people will always argue or nitpick, heh.

  2. Rohit de Sa says:

    ^^Amen. I like the ease of use and hardware-agnosticism that the Arduino has. Perfect for quick prototyping and slapping together quick. Instant gratification. But if I ever want to do something ‘serious’ I’ll turn to a PIC with C. Something even more serious like time-dependent code for software-PWM – I’ll go to assembly. Do I code in assembly everyday? Nope – too difficult and takes too long to make anything complicated.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Max: Thanks for the writeup, it's always interesting to read about a different culture. Other than that though I'm afraid I was spoiled by living neither...
  • Tepa: Heps keikkaa
  • Dan: Pick Me!!!
  • hli: Sunday++
  • Jack: May I have something to do with multiplexing various input signals, such as from different sensors, please? Thanx!