Object Oriented Programming and MORE on Arduino!

preview_player
Показать описание
Learn OOP, clean project structure, abstraction, encapsulation and overloading, all on Arduino-Framework programmable devices! Become a PRO in no time! No more boring "cats and dogs" examples!

00:00 Intro
00:32 Object relationship diagram
01:40 Clean project structure
03:05 Snowflakes as objects
07:41 Applying constant data to objects
08:48 Instances with random parameters
10:04 Group objects
12:37 Including existing classes into own classes
19:43 Working example
20:00 Outro
Рекомендации по теме
Комментарии
Автор

I came across your channel by accident through your debugging video, was impressed and watched the rest. Congratulations on a refreshing approach, and I hope it goes well.

geoffdailey
Автор

Minor code suggestion, start using const in functions that don't modify the class, also for little jobs, I just put it the header. for example: int getX() const { return x; } I really like your style of video. I came to it trying to debug using platformio (On Linux so not quite the same but at least you pointed me in the right direction hopefully). Looking forward to more videos in the future.

chrisBruner
Автор

You shouldn't need to use a c to denote a class, just use an upper case first letter of each word and you know its a class. If its camelCase, you know its a variable and if its in all caps with underscore spaces, its a constant. Easy peezy

mattnsac
Автор

dude, you needed to make this vid like 3 years ago!! thanks. i have watched it 4 times now. this is like a crash coarse on oop in arduino for someone that had a bit of arduino experience. definitely subbed!!

reinokotze
Автор

Nice video. This is something that I was looking for some time ago. Also this video is good to follow. If you ever run out of topics then Unit testing tutorial using Platform io would be absolutely the thing that is missing in this world. Keep it going 😊

tanelkaus
Автор

Great video idea, since most Arduino code examples are pretty much spaghetti code. However I have a small suggestion for improvement in your code. In the video you say that dynamic memory allocation should be avoided if possible on microcontrollers like Arduino (which is correct). But in the constructor of e.g. the 'c_canvas' class you use the new keyword, which in fact does dynamic memory allocation. Also you don't have a destructor where you delete the object. It's worth noting that in this case dynamic memory allocation is abolutely unecessary. So it would be better to just stack allocate these objects.

samuellehnen
Автор

This is cool. I just started playing esp32 development and my brief search on OOP in C basically just resulted in multiple people saying don't. As a result, I instead opted to create a few psuedo-classes using structs with internal functions. I was still using the Arduino IDE, forcing me to have everything in a single file. Now I'm just curious about the pros/cons of structs vs classes.

brentmc
Автор

As I watch this I wondered why not use inheritance for different snowflakes, and snowstorm would have a list of the base class snowflake. To create random snowflakes use the concrete factory pattern to instantiate the snowflake and add them to the list. It is fun coding on the Arduino platform, I use the UNO or MEGA to do my controller projects for Halloween... BTW which C++ version are they using? And if memory serves, didn't C++11 add treads, and if so, could you make your Arduino sketch multithreaded? C++14 you can have functors and lambda functions... Anyway, YT recommended your video and it was fun to drop by and see what you were coding.

raymitchell
Автор

I'll be playing with this tomorrow. Thanks, and good luck with the channel 👍

philj
Автор

That is an interesting topic. OO is nice and clean but i got some unexpected error stuff i ran into. Like constructors with parameters that don't give an error but the thing won't run either, created a public init function for that. Anyways I wreck my way trough it. Thanks for the upload .

ronaldronald
Автор

Damn thats a nice introduction. Thanks!

wbrjr
Автор

@0:41 in which app you drawing the object diagram

Ravi-wsdg
Автор

Hi, I have an idea for another video: How to create a code where it will be easy to replace parts, and it itself has loose connections between itself (simple enable or disable module).
Take, for example, a thermometer. The sensor can be NTC, sensor, thermocouple... Showing can be on the display, Serial, several LEDs, or fan control. Or maybe several of them at once.

I couldn't find anywhere how to operate (such pseudo-)events in arduino. (many events)

wojciechbajon
Автор

Oh the infamous common and utils folders.

BinderTronics
Автор

This Channel is amazing, 195th sub for u

neon
Автор

WHY? OOP doesn't guarantee readability. You might break things into objects differently than someone else, depending on what you think is important at the time.

kayakMike
Автор

What resources would you recommend for learning how to do this?

skrame