#BB11

Sdílet
Vložit
  • čas přidán 10. 11. 2022
  • We use libraries all the time - even the Arduino framework is a library!
    ► PCBWay $5 for 10 pieces www.pcbway.com
    Writing a library is straightforward if you follow the simple pattern that I demo here. I show you a Real World library that controls a bit of hardware that I had on my workbench - but you can write one for ANY piece of hardware.
    We'll even talk about elephants (the one in the room) and why we should not be fearful about simple things like 'objects' - watch the video and judge for yourself. 😉
    Yes, a library can take the complexity of coding away from your sketch so that it (and future ones) "just work" by calling a library.
    ► The two-digit, common anode, 74HC595-driven display I used in the video (widely available):
    s.click.aliexpress.com/e/_DmJ...
    ► More information (including pictures, all links, sketches & PDFs in my GitHub):
    github.com/RalphBacon/BB11-Cr...
    ► List of all my videos
    (Special thanks to Michael Kurt Vogel for compiling this)
    bit.ly/CZcamsVideoList-RalphB...
    ► If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so and joining me on my Arduinite (and other μControllers) journey
    My channel, GitHub and blog are here:
    ------------------------------------------------------------------
    • / ralphbacon
    • ralphbacon.blog
    • github.com/RalphBacon
    • buymeacoffee.com/ralphbacon
    ------------------------------------------------------------------
    My ABOUT page with email address: / ralphbacon
  • Věda a technologie

Komentáře • 147

  • @YoutubeBorkedMyOldHandle_why

    A long time ago I was playing around with 7-seg displays and 595 chips to drive them. I came across something that Nick Gammon had done, which seemed rather brilliant. Nick had a (multiplexed) design for driving a 3-digit display. I extended this to 8-digit displays. Basically:
    There are (up to) 16 pins on the 7-seg displays; 8 for the digits and 8 for the segments. And on 2x595s there are 16 parallel output pins. So, what Nick did in his schematic, was to use what I refer to as 'anatomically correct' device symbols, (where the symbol pin positions match the physical device.) He placed these in his schematic and basically drew the shortest connections between pins. Brilliant. Most people would designate one of the 595s for 'digits' and the other for 'segments', (and probably also map them in order, e.g. data pin 0-7 to seg A-G+DP etc.) But it really doesn't make any difference to the circuit. Nick's way vastly simplifies the pcb layout, because you don't have a tangled mess of traces to sort out. Then in software, he simply 'mapped' the 16 595 pins to the corresponding 16 7-seg pins.
    This is actually a pretty powerful principle which can be employed for other things beyond 7-seg displays. It can be a bit confusing, but you only need to do it once.
    I have some of my own code if you're interested.

    • @RalphBacon
      @RalphBacon  Před rokem

      Nick Gammon (no relation) is indeed a guru for all things Arduino so I'm not surprised he came up with a novel solution. Great that you extended his idea.
      The best way of sharing such code / info is via GitHub (like I do), then everyone can see your endeavours.

  • @hiddevandijk143
    @hiddevandijk143 Před měsícem

    Just wrote my first library after seeing this video a few times. Never understood it before, but now it starts to make sense. Thank Mr Bacon.

    • @RalphBacon
      @RalphBacon  Před měsícem

      I'm delighted you did this! Congrats! Start small and then you can increase the complexity of your library (class). 👍

  • @gerardstrik2555
    @gerardstrik2555 Před rokem +1

    This is very helpful. Just what I was looking for. Thanks for the clear explanation Ralph.

  • @electronics.unmessed
    @electronics.unmessed Před rokem

    Thank you very much for that video about libraries. Since I am a somebody who is just applying them, it helps me a lot to better understand how they work. 👍👍👍

  • @veedonfleece3694
    @veedonfleece3694 Před rokem

    Thankyou once again for a clear explanation.
    As a non programmer, who knows bits about all parts of this stuff, it really ties it together in an ordered and efficient way. Well done!

  • @gpTeacher
    @gpTeacher Před rokem +1

    Instructive as always Ralph! Thank you kindly!

  • @JamesFraley
    @JamesFraley Před rokem

    Your lessons are always the best!

  • @dougbarber600
    @dougbarber600 Před rokem

    Always had trouble understanding C++ objects they now make a lot more sense. Many Thanks Ralph

    • @RalphBacon
      @RalphBacon  Před rokem +1

      Objects are shrouded in mystery but for no good reason.

  • @noweare1
    @noweare1 Před měsícem +1

    Excellent Ralph, I have been wanting to get more familiar with libraries but do not know C++. This is a very good starting point though.

  • @andymouse
    @andymouse Před rokem

    Great explanation Ralph, I will need to run through this a few times !...cheers.

  • @roberto660
    @roberto660 Před rokem

    Hey mr. Bacon, thank you so much for this video and for explaining how to build a library, much appreciated

  • @OtusAsio
    @OtusAsio Před rokem

    Friday is my "neardy!" day...always look for your video... Thank you!

    • @RalphBacon
      @RalphBacon  Před rokem

      Yay! Thank you! Hang on, you saying I'm a nerd, Pierre?

    • @OtusAsio
      @OtusAsio Před rokem

      @@RalphBacon I would not say something to offend you of course that is why I said "my nerdy day"😀

  • @williammiller7543
    @williammiller7543 Před rokem

    Another Great video, I've wanted to look into to libraries and this was a great starter. Thanks.

  • @greg4367
    @greg4367 Před rokem +1

    Totally productive and useful video. Thank you.

  • @Telectronics
    @Telectronics Před rokem +1

    You explain it really well thank you very much ! 👍

  • @ReflectingMe2024
    @ReflectingMe2024 Před rokem

    Morning Ralph. You may (or probably may not) remember I sub'd to your channel many years ago, and a few years after that I contacted you after a clear out of my overwhelming volume of YT sub'd channels, kept yours in my list. (In case you're curious, I contacted you regarding a central heating control question). Anyway, you are still very much in my list and I just watched this one and must say, very nicely explained sir. Classes are a topic that confuse many people, myself included, and you make the process very clear. Keep up the great work.. PS: I am currently working with M5Stack and LilyGo T-Display devices - both of which you may find extremely useful in your line of work. Currently connecting a T-Embed device with built in rotary encoder via WiFi to my SunSDR2DX Amateur Radio transceiver to control it via the manufacturers TCT Protocol. All super stuff! John (GW3JVB)

    • @RalphBacon
      @RalphBacon  Před rokem +1

      Sounds very interesting (not to mention, complex) stuff you're working on, John. And, yes, I do remember you, I'm very happy you're still here on my Arduinite journey! 👍

  • @PeteTheProps
    @PeteTheProps Před rokem +1

    A very useful demo thank you for that.

  • @ForwardGuidance
    @ForwardGuidance Před rokem +1

    Do you know how elephants hide in a cherry tree, Ralph? They paint their toes nails red! Have you ever seen an elephant in a cherry tree? No? It works. Great video Ralph. You're on the top of the leaderboard.

    • @RalphBacon
      @RalphBacon  Před rokem

      And on the topic of OOP code, how do you eat an OOP elephant? One byte at a time, of course. 😁

  • @SpinStar1956
    @SpinStar1956 Před rokem

    Thanks Ralph!
    Nice explanation...

  • @keitholiver3981
    @keitholiver3981 Před rokem

    Thanks for the interesting topic on libraries, got me thinking how to change my project.

    • @RalphBacon
      @RalphBacon  Před rokem

      Glad it was helpful! Deffo worth experimenting with a simple library first and see how you get on (spoiler: brilliantly).

  • @ronycaballero4409
    @ronycaballero4409 Před rokem

    Very useful !!. Thanks a lot!

  • @maxpenfold8699
    @maxpenfold8699 Před rokem

    Very nice explanation thank you.

    • @RalphBacon
      @RalphBacon  Před rokem

      Hey, Max, Merry Christmas! 🧑‍🎄Thanks for your kind words!

  • @doverivermedia3937
    @doverivermedia3937 Před rokem

    Must admit Ralph, this one I'm struggling with and over my head as a newbie to micro electronics. Bookmarked until I'm further along with my 'vertical' learning curve, hehe .... Constructing your own library really makes sense though, and you've produced a uniquely comprehensive, excellent video as always .. 🇬🇧

    • @RalphBacon
      @RalphBacon  Před rokem +2

      You can do it! Even if your "library" contained just one function to print "Hello World" then you would have a library. But I can understand that it might be somewhat overwhelming for a self-confessed newbie... all in your own time!

  • @grahamnichols1416
    @grahamnichols1416 Před 2 měsíci

    REALLY helpful. Liked and subscribed.

  • @tseckwr3783
    @tseckwr3783 Před 11 měsíci

    Thanks Ralph.

  • @grahamheath3799
    @grahamheath3799 Před 4 měsíci +1

    Classes and arduino libraries are beginning to make sense

    • @RalphBacon
      @RalphBacon  Před 4 měsíci

      I'm glad, because the power of object oriented programming cannot be underestimated. But start with baby steps first!

  • @igrewold
    @igrewold Před rokem

    Good work, thanks man.

  • @pekkagronfors7304
    @pekkagronfors7304 Před rokem

    Yes! Today I watched your movie for the first time in the highest resolution, before the playback was hacking and lagging all the time. I got an old written off ThinkPad X1 Carbon 7th i7/16GB from work.

    • @RalphBacon
      @RalphBacon  Před rokem

      It's "only" HD not 4K! What were you using before, a Sinclair Spectrum? 😲😁🤣 But I'm happy you can now see it in full definition.

    • @pekkagronfors7304
      @pekkagronfors7304 Před rokem

      @@RalphBacon I used the Swedish Luxor ABC 80. Ha, ha not. I used an old iMac running Win 7 in Bootcamp. I have used it for many years, 10+, but now it had to retire. The difference is staggering in performance.

  • @basiljackson3829
    @basiljackson3829 Před rokem

    I have now watched a good number of your videos. Initially, I found your presentation to be a bit distracting (lots of hand motion). However, I eventually came to appreciate the professionalism and quality of the information enough to ignore the hands. 🙂
    This one was the icing on the cake and made the decision easy. New Subscriber!

    • @RalphBacon
      @RalphBacon  Před rokem

      Thanks for the sub, Basil. 👍I'll try and watch (and control) the hand waving in future (I just get carried away 😁).

  • @steverileyretired
    @steverileyretired Před rokem

    Very good, thanks

  • @user-jj4cb7vn2s
    @user-jj4cb7vn2s Před 5 měsíci +1

    Wow, I've just read the comments sections from a couple of your videos and I'm absolutely gobsmacked at how some people are arrogant and disrespectful of your work, if they want to view videos for super experts as they claim they are, why make such terrible comments, just say this channel is not for me and move on. Personally although I have been "hobby" coding for over 50 years, Fortran77, Cobol, Basic on the Sinclair Spectrum, MS Basic, Visual Basic etc, but never cpp, I like the level you are aiming at, so please keep doing what you are doing. Now to the issue that made me write this. For me the video stopped one minute early, or perhaps could be the subject of another video. How do I install MY library?, I've done searches of my folders and find arduino and platformio libraries all over the place. I want MY libraries to be global for me so if I update them the new version will be used everywhere. I see the need for version control for third party libraries but not mine. The more I look into it, the more a don't understand, so perhaps a video on libraries how they differ from Arduino ide and platformio (I've converted to platformio) how to use "project" libraries and how to use global libraries (as in Ardunio). Sorry for the long post, get well and stay well. Sev.

    • @RalphBacon
      @RalphBacon  Před 5 měsíci +1

      Yes, Sev, some comments can be less than constructive, for sure!
      Onto your question. In your 'sketches' folder is another folder called 'libraries'. In _that_ folder are all your library folders. Create a new library folder there and pop in your library files (.h and .cpp files) and they will be global and found by the Arduino IDE/compiler.
      So there's no "installation" as such, just a copy process. Ensure you only have the library accessible to the Arduino IDE in ONE place or it will possibly pick up the wrong version.

  • @TheOleHermit
    @TheOleHermit Před 7 měsíci

    Very hoopie-cool, Ralph!
    An Arduino that's millennia faster than Deep Thought! 😎

  • @ElieWar
    @ElieWar Před rokem

    Thank you

  • @joelmelan6394
    @joelmelan6394 Před rokem

    Thank you for this very good tuto !
    I have a question : just suppose you have 2 models of arduino (mega and esp32 for instance) and 2 types of displays (LCD and OLED for instance). Please, how will you dispatch code between libraries and main file in order to manage all the 4 cases of configuration ?

    • @RalphBacon
      @RalphBacon  Před rokem +1

      You would need definitions that determine which part of the library you need. This is done all the time by those that create libraries for 20 different screen for example.
      So the developer (you & me) would edit one of the files to uncomment the correct screen type definition (eg ILI9341) and within the library header there would be #ifdef statements that only spring into life when a particular variable has been declared.
      This ensures that you your sketch does not contain all the code for 19 different screen types that you will never use. All the code that does not get exposed as part of the #ifdef statement will never get compiled.
      Here's a Real World extract from one the libraries I use:
      // Only define one driver, the other ones must be commented out
      #define ILI9341_DRIVER
      //#define ST7735_DRIVER // Define additional parameters below for this display
      //#define ILI9163_DRIVER // Define additional parameters below for this display
      //#define S6D02A1_DRIVER
      //#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
      //#define HX8357D_DRIVER
      //#define ILI9481_DRIVER
      //#define ILI9486_DRIVER
      //#define ILI9488_DRIVER

  • @WagonLoads
    @WagonLoads Před rokem

    I want to thank you for all of your help. I still don't grasp everything yet, but you have explained everything very well. I will just have to watch this a few more times.
    I just recently bought a esp32-S3 T-Display. I can access it, but it can't find my libraries DIR.
    I made one major mistake when pasting the git json url in the preferences window.
    When I pasted the url into the window, I accidentally deleted the previous json urls.
    Did that make the Arduino forget where my libraries DIR is.. or worse, did it delete the original libraries DIR? it was originally in a path starting with a dot followed by arduino15
    Is there a master list of json urls for the arduino IDE preferences window?
    (board definitions)??

    • @RalphBacon
      @RalphBacon  Před rokem

      Your Arduino _libraries_ folder usually resides in the same folder as all your sketches. Eg C: > Document > Arduino Sketches > libraries
      Have a look to see whether you can find it in the trash otherwise, from where you can restore it.
      The "master list" of json URLs doesn't really exist but mine looks like this:
      ```
      arduino.esp8266.com/stable/package_esp8266com_index.json
      dan.drown.org/stm32duino/package_STM32duino_index.json
      digistump.com/package_digistump_index.json
      drazzy.com/package_drazzy.com_index.json
      adafruit.github.io/arduino-board-index/package_adafruit_index.json
      dl.espressif.com/dl/package_esp32_index.json
      github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
      mcudude.github.io/MicroCore/package_MCUdude_MicroCore_index.json
      mcudude.github.io/MightyCore/package_MCUdude_MightyCore_index.json
      mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
      raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
      raw.githubusercontent.com/dbuezas/lgt8fx/master/package_lgt8fx_index.json
      raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
      raw.githubusercontent.com/mikaelpatel/Cosa/master/package_cosa_index.json
      raw.githubusercontent.com/sleemanj/optiboot/master/dists/package_gogo_diy_attiny_index.json
      raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json
      ```
      There could be some duplicates and experimental devices in that list, so you should be selective!

  • @HelmutFischer-thehefi

    Very well done!
    But: where is the decimal point when running the sketch?

    • @RalphBacon
      @RalphBacon  Před rokem

      Did the sketch output a DP, I can't remember? All the DP bit does is add an additional "1" bit at the end (LSB) for the 8th segment. I'll check that it's working when I next use it.

  • @joaquingutierrez3072
    @joaquingutierrez3072 Před měsícem

    Amazing

  • @josephchamness9915
    @josephchamness9915 Před rokem

    I found this video interesting, thanks.
    I realize this is kind of off-topic but if I was trying to save every byte of memory possible, then for example would you get 8 copies of "_digits" if you had 8 copies of the class or would the linker optimize it? (For say a DRO for CNC where you might need 1 for each of 7 axis + more for other stuff.)

    • @RalphBacon
      @RalphBacon  Před rokem

      Not off topic at all, actually, Joseph.
      Yes, in that use case you would repeat everything in the "private" section. However, there are ways round that to ensure each instance uses a "static" version of the "_digits" (known as a singleton) but that's not beginner-friendly stuff.
      Better for beginners to use a few more bytes and get it working.

  • @kevingpearce
    @kevingpearce Před rokem

    Thanks Ralph, I'm an avid follower of all your videos, great work. However, I'm a bit confused about how you arrived at the screen showing 3 tabs open at the top (minute 5:09).
    How do you actually begin to write your library ? I assume it's not from within the Arduino IDE, as that saves any sketches automatically with .ino extensions ? Confused is me.

    • @RalphBacon
      @RalphBacon  Před rokem

      Dear confused 😲 Yes, you can indeed use the Arduino IDE.
      On the top row with the single .ino tab, there is (on the right hand side) a drop down three dots (using Arduino 2.0.2) from which you can select "New Tab".
      Give it (the new file) a name, such as "MyLibrary.cpp" and it will place it in the same folder as your .ino file. It will also open it when you next open the .ino file too, so helpful!
      Does this answer your query, Kevin?

    • @kevingpearce
      @kevingpearce Před rokem +1

      @@RalphBacon Thanks Ralph. A brilliant and concise answer providing immediate clarity. I never looked behind those 3 dots before.

  • @danny12345
    @danny12345 Před rokem

    Thank you very much for the beautiful explanation. I have a question Can you show a video on the difference between accessing a class through dynamic memory and static memory when we address the class as you wrote and when do we address the class through the word new in arduino And when we write the destructor when we opened dynamic memory in the Arduino program .

    • @RalphBacon
      @RalphBacon  Před rokem +1

      A tricky subject at the best of times, Danny. The question I would ask is Why on earth are you worried about Heap vs Stack memory allocation?
      Using the "new" keyword puts the object on the (larger) heap memory but then you must explicitly delete the object to free up the memory (or you get a memory leak). Using smart pointers goes a long way to prevent this but even so...
      Not using "new" keyword (the default way, I guess) means the item goes on the stack (limited memory, agreed) but you don't have to manually manage it; it will be automatically removed (the memory freed) when the object or variable goes out of scope (eg a function finishes).
      Unless you have a _a very good reason_ to use "new", don't. Some good reasons might be:
      * you have a large object or array that would cause a stack overflow (or otherwise impair the operation of the rest of the code because there is insufficient stack memory
      * you want a pointer to the object returned (but note my comment about smart pointers)
      * you need to resize a variable (eg array) and therefore it can't really go on the stack which only allows fixed sized variables (apart from vectors which does all the hard work behind the scenes)
      Unless you want memory leaks, don't directly call "new" and "delete" from your sketch. Wrap such objects in a class so that the "delete" function is automatically called when it goes out of scope.
      As I say, a tricky subject at best of times.

    • @danny12345
      @danny12345 Před rokem

      @@RalphBacon Thank you very much for your answer, I really appreciate the demonstrations that teach Arduino programming through the programming language C++

    • @Henry-sv3wv
      @Henry-sv3wv Před rokem

      On Microcontroller: Dynamic memory bad. Avoid if you don't know what you do. Danger of Memory Fragmentation.
      (of couse use new and delete if you want to try stuff out but know why stuff can go bad and should be avoided)
      (at least dynamic memory bad on these small ATmega with only 2KB RAM) but i guess some arduino libraries use dynamic memory to like allocate a buffer and never free the space in the runtime ...

  • @jenniferw8963
    @jenniferw8963 Před rokem

    Great video :) I've been learning C++, coming from Java. Something that is weird is when you have classes as members of another class, you are forced to create a parameterless constructor. When the class is declared as member it instantiaties. Then the constructor of the class it is in, will have to again call the proper parameterized constructor. Actually had to modify several existing classes adding empty constructors. A bit annoying.

    • @RalphBacon
      @RalphBacon  Před rokem

      You mean Java is no longer the blue-eyed boy on the block? 😲😁 You'll be coding in Python next 🤮

    • @jenniferw8963
      @jenniferw8963 Před rokem

      @@RalphBacon Yuck @ Python. Actually Java is really good; very clean code and typed unlike Python. I do like C++ but it's weird having to call empty constructor which leaves class in an unusable state until it is called again with the proper parameterized constructor.

  • @jstro-hobbytech
    @jstro-hobbytech Před rokem

    Think function overloading using a template or literals for each port to speed up the code a little would work?

    • @RalphBacon
      @RalphBacon  Před rokem

      Function overloading won't _speed up_ the code, but it would make it easier for a developer (me & you) to just pick a named function and use it.

    • @jstro-hobbytech
      @jstro-hobbytech Před rokem

      @@RalphBacon haha I'm but a grasshopper my friend. I've never written production code. I just read alot of books and make silly apps haha

  • @joymakerRC
    @joymakerRC Před rokem

    thank you again Mr. Bacon, luv your face.

    • @RalphBacon
      @RalphBacon  Před rokem

      My old face, I think you mean, Bill. 👴

  • @Roy_Tellason
    @Roy_Tellason Před rokem

    I got into c some years back, never got into c++. Perhaps it's time to give it a go...

    • @RalphBacon
      @RalphBacon  Před rokem

      If you know C you can migrate to C++ because it still allows a lot of C constructs and methods.

  • @danman32
    @danman32 Před 6 měsíci +1

    You appear to have a bug in your value checking in updateValue method.
    When inputting a value to display in hex, you're checking if the value is greater than 256. Should be 255 since 256 is not valid for only 2 hex digits.

    • @RalphBacon
      @RalphBacon  Před 5 měsíci +1

      Really?!? Obvs a typo and I hope I haven't confused anyone! Well spotted!

  • @bob-ny6kn
    @bob-ny6kn Před rokem

    In your other "create library" video you added a keywords.txt file. Is a created keyword in danger of conflicting with the same keyword created by a #include (another abstraction) or will compilers identify and warn about the conflict?

    • @RalphBacon
      @RalphBacon  Před rokem

      The keywords file doesn't warn you of anything, not even spelling mistakes. 😲
      It's just eye-candy for the IDE you are using (but useful eye candy, nonetheless). Compiler ignores it completely.
      I don't think one list of keywords will conflict with other libraries because the keywords.txt file is in the library folder to which it pertains.

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist Před rokem +1

    I would have written the library as a generic library to drive a 47HC595.
    In the set up routine I would have data for pins used, display type, non-display just I/O, number of attached devices- so you can link more than one. etc, etc
    But the important point that should be made is when you update the library the new one should be backwards compatible.
    I've given up using Arduino libraries due to this. Having to find a version of the library that works with the code you're looking at, as the latest one just does not work. and the author does not reference the version of the library used.

    • @RalphBacon
      @RalphBacon  Před rokem +2

      I hear you about backward compatibility (or lack of it). Many of my Arduino sketches failed on recompile after a few years due to this.
      That's why I use VSC (PlatformIO) so I can use specific versions of a library, if required. Or even keep a snapshot of the actual library with the project. Makes life a lot easier.

    • @grunto666
      @grunto666 Před rokem

      @@RalphBacon How do you add a library that you have created to VSC / PlatformIO?

  • @hugbearsx4
    @hugbearsx4 Před rokem

    Is the use of classes in Arduino libraries mandatory? Is it possible to use #include files as collections of standalone functions, just like normal beginners? Is this video a trick to lure unsuspecting Arduiners into the wonderful world of OOP? 😁
    Excellent presentation, btw. Thanks!

    • @RalphBacon
      @RalphBacon  Před rokem +1

      Dang, you discovered my subterfuge! But seriously...
      The #include file can contain anything that syntactically fits into the place in your sketch (as though you had typed the contents of the #include file right there).
      So it can include functions that are logically grouped, perhaps. I showed how to organise code better in videos #BB9 and #BB10 which includes this technique.
      czcams.com/video/PWMOb85OGY0/video.html
      czcams.com/video/P0PYqu83ScY/video.html
      So, long answer to a short question: you don't need to include a class in an #include file!

  • @ChrisBalmforth
    @ChrisBalmforth Před rokem

    This made me consider re-writing large chunks of my line follower robot code as a robot library. Hmmm!

    • @RalphBacon
      @RalphBacon  Před rokem

      Yes, do it. Perhaps more than one library (separation of concerns). 👍

  • @b3nd0v3r28
    @b3nd0v3r28 Před rokem

    Yoo, b-word!
    Glad to see Mr White moved on from methamphetamine production to embedded programming

    • @RalphBacon
      @RalphBacon  Před rokem

      Well, [re-reads post for umpteenth time trying to understand it], yes, absolutely! 😁😉😲

  • @mariusscheepers9003
    @mariusscheepers9003 Před rokem +1

    Can you please consider doing a few Rust on Arduino videos.

    • @RalphBacon
      @RalphBacon  Před rokem

      The question I have to ask is, " How many of my viewers program in Rust? On an Arduino? Or want to?" I'm pretty sure it must be very low.

    • @mariusscheepers9003
      @mariusscheepers9003 Před rokem

      @@RalphBacon I agree. Its very interesting but not that popular under Arduino users.

  • @danman32
    @danman32 Před 6 měsíci

    I find it funny when at the end of your sponsorship you say "try them out now." Well then if they do that, they'll have to stop watching the video!

    • @RalphBacon
      @RalphBacon  Před 5 měsíci

      I will have to change that to say "Try them out soon!" 😁

  • @yogeshitaliya473
    @yogeshitaliya473 Před rokem

    🥰🥰🥰

    • @RalphBacon
      @RalphBacon  Před rokem +1

      First again, like a coiled spring, Yogesh!

  • @fredflintstone1
    @fredflintstone1 Před rokem

    I was with you when you said "yes Indeed" after that it all went OOP's 😟

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist Před rokem

      That's because you're just an old Woofer Fred. ;-)

    • @fredflintstone1
      @fredflintstone1 Před rokem

      @@TheEmbeddedHobbyist Meow!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    • @RalphBacon
      @RalphBacon  Před rokem +2

      So you got past "Welcome Back" and "Yes, indeed". 🎉🎊🎈 I suppose the "instantiation of a blueprint class into an object" was just one step too far? 😟

    • @fredflintstone1
      @fredflintstone1 Před rokem

      @@RalphBacon damn big words as well very Perspicacious of you 🙂

    • @jyvben1520
      @jyvben1520 Před rokem

      maybe Bambam can explain it to you ...

  • @__--JY-Moe--__
    @__--JY-Moe--__ Před rokem

    that Bacon, he's a ''slick'' one!! that Bacon, U can use his Technics on about anything! that Bacon, add L&T. & u've got a meal!
    that Bacon,🖖. cause I'm not genius!🤣

    • @RalphBacon
      @RalphBacon  Před rokem

      You got that right! Mmm, BLT (especially when the Bacon is sizzling) 🥓😋

  • @rfdave3980
    @rfdave3980 Před rokem

    I like Bacon.... Thanks Ralph

  • @reoproedros
    @reoproedros Před rokem

    after unbearable thinking , i found a name to propose for the device , "the debugun" (the debugging has began )

    • @RalphBacon
      @RalphBacon  Před rokem +1

      Wow! You should definitely patent that name, quickly!

  • @DrexProjects
    @DrexProjects Před rokem

    My brain hurts.

    • @RalphBacon
      @RalphBacon  Před rokem +1

      Funnily enough so does mine. I blame that bottle of Scotch from last night, what's your excuse? 😁

    • @DrexProjects
      @DrexProjects Před rokem

      @@RalphBacon My lack of neurons to remember things of importance. And Ballantine's.

  • @thepvporg
    @thepvporg Před rokem

    I am still trying to wrap my head around the lack of alternative coding languages and compilers for Arduino thats been out for 10 years now.
    I hated C and hate C++ as there is a lot of unnecessary fidgeting to write a simple program. There are far better languages out there that would make Arduino accessible, there is no reason why people can't use languages that they are used to, example, I left Delphi C behind in 1995, just like C++ it is cumbersome and pedantic, you have to do a lot of work for such a simple task that it makes Arduino and it's ilk fail the rapid development test.
    I have been campaigning in the Arduion forums for years, had 7 or 8 accounts deleted by them as they just don't want to listen to good reasoning to make Arduion more accessible, they instead want people to spend hours upon hours of writing redundant elements that should be automatic like an array...
    JavaScript :
    jsArray = [1,2,3,4,5,6];
    C++ :
    int cppArray [6] = {1,2,3,4,5,6};
    If you suggest that there is a JavaScript (the easiest language to learn) then you get all sorts of comments about how it is not suitable or "Powerful enough"£ when these muppets fail to understand that the front end is only as powerful as the compiler.
    It is my considered opinion that a JavaScript (not Java) front end and compiler would make Arduino more accessible as more people know JavaScript than C++
    I have given up on C++ and I await a more user friendly front end that has a compiler that does all the housekeeping and compiles in to something that the Atmel chip can use. Maybe when Arduino wake up to this fact that they will be making their product more accessible, they will soon see a huge surge in demand for it, they don't seem to see that many people trying to learn C++ struggle because its not an easy language to use and you have to take care of memory allocations, pointers and flushing buffers and mopping up after you're done.
    Atmel would also do themselves a big favour by putting the whole memory space available for use rather than having to specifically and write special code to access the higher memory spaces, why make things hard?

    • @RalphBacon
      @RalphBacon  Před rokem

      In which case you'll be pleasantly surprised that the Arduino IDE now supports microPython, albeit in the early stages yet. See bit.ly/3VzTRu5

    • @Henry-sv3wv
      @Henry-sv3wv Před rokem

      Arduino with ATMega328p: 2KB RAM ... but you're welcome to write a python interpeter for it. cause i like python, too ...

    • @Henry-sv3wv
      @Henry-sv3wv Před rokem

      And everybody agrees with me that if i say: "javascript sucks" that it is not a number.
      czcams.com/video/qvFG8J7SUDE/video.html

    • @user-mt1hg6lr1z
      @user-mt1hg6lr1z Před rokem

      @@RalphBacon It's kinda limited (as opposed to CPython in Linux or Windows).

  • @joaoarriagaecunha8583

    Hi, thanks for your video but you didn't explain the most important part of the process. I am not very interested in the internals of your class. What I am interested in is learning things like these:
    1. Where do you get and put the arduino.h file to include in your class code? And the corresponding library?
    2. Once complete, how do you install your library in the Arduino environment so we can use it in our sketches?
    3. What really do you install in the Arduino environment? Is it the source code of your class? Is it the compiled version of your code?
    4. I see you were using Visual Studio to make your class. Is the compiled code of Visual Studio C++ compiler compatible with Arduino compiler?
    5. Why do you code your library in Visual Studio and not in the Arduino editor? Does it have to be like that? You cannot write libraries in the Arduino editor and environment?

    • @RalphBacon
      @RalphBacon  Před rokem

      Oh no! You must have been sleeping, João! I explained all this in the video. Look:
      1. The .h file (and the associated .cpp) are created as new files by using the 3-dots button in the IDE. They are all placed in the same folder automatically as your sketch, whilst you work on them.
      2. Once you have it (the library) ready for wider consumption, create a new library folder (ideally of the same name, as I mentioned in the video) in the _libraries_ folder which you will find in your Arduino sketches folder.
      Arduino Sketches -> libraries -> MyLibrary -> myLibrary.h & myLibrary.cpp
      3. Nothing is _installed_ as such. Just the .h and .cpp files in their folder in the libraries folder. Then you just #include in whatever sketch you want! The library is compiled for each sketch that needs it and is included in the final code for the target device.
      4. Visual Studio Code (PlatformIO) uses the same gcc-avr compiler as the Arduino IDE (and now both IDEs look more similar, too, since Arduino IDE 2.0.2).
      Did I miss anything? Let me know! And good luck!

    • @joaoarriagaecunha8583
      @joaoarriagaecunha8583 Před rokem

      @@RalphBacon Sorry for being asleep......
      Meanwhile I discovered another video of yours where you explain all that.
      Thanks a lot for the help!

    • @Henry-sv3wv
      @Henry-sv3wv Před rokem +1

      The c++ compiler would call a library something that is compiled into a library and stuff but arduino says: a library is a source code that is programmed in a way that you can put it in the arduino library folder so you can use it as an arduino library.

  • @qzorn4440
    @qzorn4440 Před rokem

    This is amazing as about 10 days ago I was curious about making an Arduino library for a Modbus esp32 project board with so - so how to information to find and get working. "For Me?" For the learning curve this video will help: $23 LILYGO T-CAN485 ESP32 Development Board CAN Modbus RTU RS485 IoT Engineer Control Module with cellphone free RemoteXY. 😎 Thanks a lot.

    • @RalphBacon
      @RalphBacon  Před rokem +1

      I'm glad it arrived at the right time for you!

    • @qzorn4440
      @qzorn4440 Před rokem

      @@RalphBacon Thanks.

  • @YoutubeBorkedMyOldHandle_why

    Of course you are correct Ralph, and I mean to do this some time, but I've just not quite wrapped my head around github yet. In the meantime, here's a googledrive link to some stuff:
    drive.google.com/drive/folders/1Ba3jRfbYRE5geXDQd1XrxaZvgdlixG03?usp=share_link
    I've included KiCad files, so everyone can see what I mean about the anatomically correct symbols, and also some demo Arduino code. This is pretty old stuff, but I've just tested it to make sure everything still works. It does.
    Cheers, Richard

    • @RalphBacon
      @RalphBacon  Před rokem

      "Anatomically correct", you say?
      Ha ha! Yes, I see the design goal here but if I might suggest that you could shrink the PCB to less than half its size if you put the chips either _under_ each display or on the other side of this _double-sided_ board? Just a suggestion.
      And if you use the SMD version of the PCB pin headers I showed then you could put the pins on the "other side" two too, and thus have a very clean board with little more than the display visible on one side.
      Thanks for sharing this, I like the code style, very clean, well documented too.

    • @YoutubeBorkedMyOldHandle_why
      @YoutubeBorkedMyOldHandle_why Před rokem +1

      @@RalphBacon Thanks and yes, of course. This was a long time ago and was just a proof of concept even then. The reason for using DIP components btw, was to place sockets on the board and swap out common anode for cathode, to prove that this worked. But today I'd use SMD and probably place the ICs on the other side of the board. I'd also add transistors and not drive the displays directly from the mcu.