Giter VIP home page Giter VIP logo

lazybox's People

Contributors

fulf avatar

Stargazers

 avatar

Watchers

 avatar  avatar

lazybox's Issues

Add library files

For PlatformIO add library.json. Use PREi's as an example.

For Arduino add library.properties and keywords.txt. As above, use PREi's library and keywords files as an example.

Make core board agnostic

Allow the Core class to be used with any wifi module (ESP8266, ESP32, etc.)

Suggested implementations:

BoardClass implements CoreInterface

Have LazyBoxCore as an interface. All boards implement the interface, having to define their control logic.

Have a factory class that returns the right LazyBoxCore implementation board.

A downside to this would be the fact that all ESP8266 boards have to implement the control logic, meaning a lot of duplicated code.

BoardClass extends ModuleAbstractClass implements CoreInterface

Have LazyBoxCore as an interface. Each WiFi module represents an abstract class properly implementing the control logic. Each board extends the abstract class, specifying their properties (pins, memory, etc.)

Again, a factory class will return the correct BoardClass for the specific WiFi module.

A downside to this would be the need to create factories for all WiFi modules, and have the end user define the LazyBox variable type depending on the WiFi module he uses.


Apparently C++ doesn't support interfaces, but they can be mocked up via Virtual Classes.

The second implementation looks best, and we might go for something like:

class CoreInterface {
  public:
    LazyBoxPin* getPins() {
      // implementation
    }
    virtual void setPins(LazyBoxPin* p) = 0;
    virtual uint8_t connectWiFi(const char*, const char* = "") = 0;
    virtual void setPinMode(LazyBoxPin, const char*) = 0;
    // ...
}

class MyWiFiModule : CoreInterface {
  public:
    virtual uint8_t connectWiFi(const char*, const char* = "") {
      // implementation
    }
   virtual void setPinMode(LazyBoxPin, const char*) {
     // implementation
   };
  // ...
}

class MyBoardClass : public MyWiFiModule {
  public:
    MyBoardClass() {
      // set board pins, memory, etc.
    }
}

class MyWiFiModuleFactory {
  public:
    static MyWiFiModule getBoard(String board) {
      // return MyBoardClass
    }
}

// ---

class MyApp {
  public:
    MyApp() {
      MyWiFiModule module = MyWiFiModuleFactory::getBoard("MyBoard");
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.