{"id":48851262,"url":"https://github.com/ilcardella/lib_coffee_machine","last_synced_at":"2026-04-15T09:06:32.521Z","repository":{"id":43365466,"uuid":"336901216","full_name":"ilcardella/lib_coffee_machine","owner":"ilcardella","description":"C++ library to model a manual coffee machine","archived":false,"fork":false,"pushed_at":"2023-11-11T09:47:29.000Z","size":49,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-11-11T10:28:08.824Z","etag":null,"topics":["arduino","coffee-machine","manual-coffee-machine","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ilcardella.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-07T22:11:27.000Z","updated_at":"2023-11-11T10:28:08.824Z","dependencies_parsed_at":"2022-09-09T08:52:01.027Z","dependency_job_id":null,"html_url":"https://github.com/ilcardella/lib_coffee_machine","commit_stats":null,"previous_names":[],"tags_count":3,"template":null,"template_full_name":null,"purl":"pkg:github/ilcardella/lib_coffee_machine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilcardella%2Flib_coffee_machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilcardella%2Flib_coffee_machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilcardella%2Flib_coffee_machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilcardella%2Flib_coffee_machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ilcardella","download_url":"https://codeload.github.com/ilcardella/lib_coffee_machine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilcardella%2Flib_coffee_machine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31833864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T07:17:56.427Z","status":"ssl_error","status_checked_at":"2026-04-15T07:17:30.007Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","coffee-machine","manual-coffee-machine","raspberry-pi"],"created_at":"2026-04-15T09:06:31.621Z","updated_at":"2026-04-15T09:06:32.503Z","avatar_url":"https://github.com/ilcardella.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coffee Machine Library\n\nThe purpose of this library is to model a generic Coffee Machine creating a level of abstraction on the platform or hardware used for deployment.\nThe original application that led to its development was a PID controller for a Gaggia manual coffee machine, deployed on an Arduino Nano and then on a Raspberry PI Pico. The change of platform does not affect the functionalities of the library and speeded up the development for the new hardware.\n\nFurthermore, being hardware independent, the library allows automated testing in the CI pipeline.\n\nThe library uses C++17 features.\n\n## Getting started\n\nThe are different ways you can use this library in your project, depending on your setup\nyou might prefer to clone it, add as a git submodule or include it with CMake.\n\n### CMake\n\nIn this configuration the first step is to install the library in your development\nenvironment. The `Makefile` provide a target to do exactly that.\n\n```\nmake install\n```\n\nThen in your top-level `CMakelists.txt` you can find the library and then link your\ntargets against with, as in the example below:\n\n```CMake\nproject(my_project)\n...\nfind_package(lib_coffee_machine CONFIG REQUIRED)\n...\nadd_executable(${PROJECT_NAME} ...)\ntarget_link_libraries(${PROJECT_NAME}\n                        lib_coffee_machine::lib_coffee_machine\n                        ...\n)\n...\n```\n\n### Clone\n\nClone this repository into your project workspace and make sure the source code is\naccessible to your codebase.\nFor example if you are using `CMake`, you might need a `add_subdirectory(path/to/library)`\ninstruction.\nIf your project is Arduino based, then you need to clone this repository inside the\n`libraries` subfolder\n\n```bash\ngit clone https://github.com/ilcardella/lib_coffee_machine.git libraries/lib_coffee_machine\n```\n\n### As submodule\n\nCreate a submodule in your project with\n\n```bash\ngit submodule add https://github.com/ilcardella/lib_coffee_machine.git lib_coffee_machine\n```\n\nThen, as in the previous option, just integrate the library with your project.\n\n### Arduino library\n\nTBD\n\n## How to use\n\nThe library consists of 4 main components:\n- The `interfaces`\n- The `configuration`\n- The `adapter`\n- The `CoffeeMachine` class\n\n### Interfaces\n\nThe `interfaces.h` provides a list of base abstract classes that need to be implemented to support the deployment platform. They provide an interface and the level of abstraction required to make this library generic for any hardware.\n\n#### Example\n\nThe following example shows how you can implement a TSIC306 digital temperature sensor for your Arduino project\n\ncustom_temperture_sensor.h\n```c++\n#pragma once\n\n#include \"lib_coffee_machine/interfaces.h\"\n// Arduino library for TSIC sensor\n#include \u003cTSIC.h\u003e\n\nclass CustomTemperatureSensor : public BaseSensor\n{\n  public:\n    CustomTemperatureSensor(const unsigned char \u0026pin) : sensor(pin, NO_VCC_PIN, TSIC_30x)\n    {\n        pinMode(pin, INPUT);\n    }\n\n    bool read_sensor(float *value) override\n    {\n        unsigned short raw;\n        if (not sensor.getTemperature(\u0026raw))\n        {\n            return false;\n        }\n\n        auto temp = sensor.calc_Celsius(\u0026raw);\n\n        *value = temp;\n        return true;\n    }\n\n  private:\n    TSIC sensor;\n};\n\n```\n\n### Configuration\n\nThe library requires a template argument which should provide static constants of configurable parameters.\nThe `configuration.h` contains a sample `struct` with configuration parameters required by the `CoffeeMachine` class. You can use that struct as is or create a new derived instance replacing the parameters you need.\n\n#### Example\n\nThe following example shows how you can override the default configuration replacing some of the parameteres\n\nmy_configuration.h\n```c++\n#pragma once\n\n#include \u003clib_coffee_machine/default/configuration.h\u003e\n\nstruct MyConfiguration : public DefaultConfiguration\n{\n    // Replace the target water temperature\n    inline static constexpr double TARGET_WATER_TEMP = 92.0;\n    // Replace the target steam temperature\n    inline static constexpr double TARGET_STEAM_TEMP = 155.0;\n};\n```\n\n### Adapter\n\nThe second template parameter required by the library is the `Adapter`. A simple class with static methods that abstract functions that are platform specific. e.g. the Arduino `delay()`.\n\n#### Example\n\nThis example shows an adapter class for the Arduino MCU to abstract platform specific methods. You can find another example in the `test` folder of this repository.\n\n```c++\n#pragma once\n\n#include \u003cArduino.h\u003e\n\nclass ArduinoAdapter\n{\n  public:\n    inline static void delay(unsigned long ms)\n    {\n        ::delay(ms);\n    }\n\n    inline static unsigned long millis()\n    {\n        return ::millis();\n    }\n\n    inline static char *dtostrf(double val, signed char width, unsigned char prec,\n                                char *s)\n    {\n        return ::dtostrf(val, width, prec, s);\n    }\n};\n\n```\n\n### CoffeeMachine\n\nThe `coffee_machine.h` provides the main library class and interface that needs to be instantiatd and spinned in your main function.\n\n#### Example\n\n```c++\n\n#include \u003clib_coffee_machine/coffee_machine.h\u003e\n\n// Implementation of the interfaces for your platform\n#include \u003cmy_interfaces.h\u003e\n// Implementation of the Adapter\n#include \u003cmy_adapter.h\u003e\n// Implementation of the Configuration\n#include \u003cmy_configuration.h\u003e\n\nusing Adapter = MyAdapter;\nusing Configuration = MyConfiguration;\n\nvoid main()\n{\n    // Create the custom interfaces\n    CustomTemperatureSensor* temp_sensor = new CustomTemperatureSensor();\n    ...\n\n    // Create the coffee machine instance\n    CoffeeMachine\u003cAdapter, Configuration\u003e machine(temp_sensor, ...);\n\n    while (true)\n    {\n        machine.spin();\n    }\n}\n\n```\n\n## Default PID Controller\n\nThe library provides a default PID controller. This PID controller requires the following\nconfiguration parameters to be defined in the Configuration struct:\n- P_GAIN\n- I_GAIN\n- D_GAIN\n\nThe easiest way to use the default PID controller is by creating the CoffeeMachine\ninstance with the contructor that does not require a Controller in the argument list.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filcardella%2Flib_coffee_machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filcardella%2Flib_coffee_machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filcardella%2Flib_coffee_machine/lists"}