Shop OBEX P1 Docs P2 Docs Learn Events
Convert Fuzzy Library for Arduino to the Propeller - Page 3 — Parallax Forums

Convert Fuzzy Library for Arduino to the Propeller

13»

Comments

  • Wow! Thanks for typing that up! That will make it much easier to add to the documentation.

    Unfortunately, I'm not seeing any errors that you mentioned. Did you forget to upload another document with the errors?
  • ASAS Posts: 149
    I already try some different CMakeLists.txt.
    I´m asking if I should add other CMakeLists.txt inside the directory (for example) general_simple_sample (where is already the file general_simple_sample.cpp), make a directory bin and do the same procedure like the examples of PropWare?
    I need to make other CMakeLists.txt? What I write inside?
    I need you tell me how I should to do the CMakeLists.txt, this is very obvious for you but I´m not doing some detail.
    I´m not understand how the files of CMakeLists.txt work with each other.

    Give me a sugestion how you think is the best procedure.
    Thanks
  • Ah, okay.

    The "bin" directory should exist once for every project, no matter how folders and CMakeLists.txt files are in that project.

    When you create a CMakeLists.txt file, it will not automatically search for other CMakeLists.txt files in neighboring directories (such as "examples"). Instead, you must forcibly tell it "find another file named CMakeLists.txt file in ___ directory". The way you can do that is with add_subdirectory(___).

    With that being said, you rarely need to create multiple CMakeListst.txt files. Most of the time, it is possible (though not recommended) to do everything in a single folder with a single CMakeLists.txt file - even though your project might have many subdirectories.

    For instance, if I have a project named Foo with the following source code:
    Foo/
      library/
        foo.cpp
      example/
        example_foo.cpp
    

    Then I can imagine two ways I might create my CMake project. The first way does everything with a single CMakeLists.txt file, which is great for a small project like this. The second will split it up into multiple.
    Foo/
      CMakeLists.txt
      library/
        foo.cpp
      example/
        example_foo.cpp
    
    And the CMake file will read something like:
    cmake_minimum_required(VERSION 3.3)
    find_package(PropWare REQUIRED)
    
    project(foo)
    
    set_compile_flags()
    add_library(foo library/foo.cpp)
    
    create_executable(example_foo example/example_foo.cpp)
    target_link_libraries(example_foo foo)
    

    Pretty easy! :)
    But as your project grows, this one file can quickly grow out of hand. At which point it makes sense to split up your project.
    Foo/
      CMakeLists.txt
      library/
        CMakeLists.txt
        foo.cpp
      example/
        CMakeLists.txt
        example_foo.cpp
    

    Now, in the order listed above, here is the content of each of those three CMakeLists.txt files
    # Foo/CMakeLists.txt
    cmake_minimum_required(VERSION 3.3)
    find_package(PropWare REQUIRED)
    
    project(foo)
    
    add_subdirectory(library)
    add_subdirectory(example)
    
    # Foo/library/CMakeLists.txt
    
    set_compile_flags()
    add_library(foo foo.cpp)
    
    # Foo/example/CMakeLists.txt
    
    create_executable(example_foo example_foo.cpp)
    target_link_libraries(example_foo foo)
    

    In both of these cases, you would create a single bin directory and run "cmake .." and "make" once.

    Okay, so back at the beginning of this post, I said most of the time the first option is possible. It fails when you want to build multiple instances of a library, each with different compilation flags. This is the case for PropWare's libraries: I want to build one instance of each library for every different memory model. PropWare does not support changing memory models in a single CMakeLists.txt file. Therefore, you must create a subdirectory for each different memory model. This is why I created 6 subfolders in eFFL: one for each memory model.

    But I don't want multiple versions of the example code. Just a single instance of each example will do, and I'm willing to have all examples use the memory model. So I use a single CMakeLists.txt file in the eFFL/examples folder (much easier than creating four files, each with two lines in them).

    I think (hope) I answered your question. Let me know if anything is unclear.
  • ASAS Posts: 149
    ok! you already help me to understand a little more.
    I will make some tests and I will have certainly a few more questions.

    thank you
  • ASAS Posts: 149
    ok!
    I think you help me to understand how CMake works.

    I was trying to create CMakeLists.txt inside the examples and make the "bin" directories inside :D, I don´t understand that is everything done!!

    At this moment I creat a "bin" directory at the "root" directory of the project, in this case "eFLL-master", I wrote as you said:
    mkdir bin
    cd bin
    cmake ..
    make
    
    everything works great! :D

    In the examples of PropWare I can write "make debug" because is only one example for each project. Right?
    But now a have 3 examples and I only want debug one example each time to the propeller, off course.
    My question is: How I should now "make debug" of only one of the examples inside the bin directory?

    thanks a lot

  • Ah! That's understandable :) in fact... I'm not sure I documented this anywhere.... I'll have to fix that.

    PropWare adds two functions to cmake which are very similar to CMake's standard add_executable function: create_simple_executable and create_executable. The first creates targets debug, run, gdb, etc. It's helpful when your project contains only a single executable, and you don't like to type very much at the command line. The second option adds the name of the executable to the target name, so you end up with targets like debug-simple_sample_generic and run-simple_sample_generic. Otherwise, if you had two different executables in a project and typed "make debug" which one would it use???
  • ASAS Posts: 149
    Thanks a lot! is everything working great. :thumb:
  • AS wrote: »
    Thanks a lot! is everything working great. :thumb:

    Excellent! I'm happy to hear it!
  • ASAS Posts: 149
    edited 2016-02-19 02:34
    Thanks a lot David Zemon and David Betz.

    At this moment I have Propeller doing the same than Arduino with the same libraries, but better.

    Propeller is much better than Arduino Leonardo (it was the one tested), I can give a lot examples with my short experience. Is very stable, the Cogs are really great and in the [cmm] mode memory it´s very fast too. With the Propeller is like to work with few Arduinos but more faster. And very versatil with the memories, I can upgrade to 64kb or more with the SPI flash chip.

    The work I done was simulating with LabView and controlling with the Propeller with Fuzzy Logic embeded, in this case I have two independent loops, a no linear system.

    Next step learn with Genetic algorithm to make the Fuzzy Sets!! :D
    When I writing this I was thinking that should be already this libraries in C (http://lancet.mit.edu/ga/) there are more, but it´s necessary see the better work, if is too much to Propeller 1 maybe Propeller 2 can deal with that, I´m not sure, I need to learn a lot to that!!

    These chips can be smart! :P
Sign In or Register to comment.