aboutsummaryrefslogtreecommitdiff
path: root/Mussel/Mussel.h
blob: a50ccaa576cd3128960cc287f2c801fca6ab4b59 (plain)
  1. // SPDX-FileCopyrightText: 2025 Amal Mazrah <mazrah@ruc.dk>
  2. // SPDX-FileCopyrightText: 2025 Jonas Smedegaard <dr@jones.dk>
  3. // SPDX-FileCopyrightText: 2025 Mennatullah Hatim Kassim <stud-mennatulla@ruc.dk>
  4. // SPDX-FileCopyrightText: 2025 Noor Ahmad <noora@ruc.dk>
  5. // SPDX-FileCopyrightText: 2025 Tanishka Suwalka <tanishkas@ruc.dk>
  6. // SPDX-License-Identifier: GPL-3.0-or-later
  7. /// Mussel - a small library for Arduino to emulate a mussel biosensor
  8. ///
  9. /// @version 0.0.2
  10. /// @see <https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z2tFBF4gN7ziG9oXtUytVQNYe3VhQ/tree/Mussel/README.md>
  11. /// @see <https://moodle.ruc.dk/course/view.php?id=23504>
  12. #ifndef Mussel_h
  13. #define Mussel_h
  14. #include "Arduino.h"
  15. // seconds
  16. #define MUSSEL_NORMAL_PACE 50U
  17. #define MUSSEL_STRESS_PACE 10U
  18. // milliseconds
  19. #define MUSSEL_DEBOUNCE_DELAY 50U
  20. // Limited size NOW!! can be transformed into infinite array
  21. #define STACK_SIZE 1000
  22. class Mussel {
  23. public:
  24. // Default constructor
  25. Mussel(const int attitude);
  26. // Constructor for attitudes using an input pin
  27. Mussel(const int attitude, const uint8_t pin);
  28. // Constructor for attitudes using an input pin and a sensor type
  29. Mussel(
  30. const int attitude,
  31. const uint8_t pin,
  32. const uint8_t type);
  33. void begin();
  34. String desc();
  35. byte read();
  36. String debug();
  37. bool push(String id, unsigned long timestamp, int measure);
  38. void printStack();
  39. private:
  40. int _attitude;
  41. int _pin;
  42. bool _boolState;
  43. byte _count;
  44. unsigned long _time;
  45. #ifdef DHT_H
  46. DHT mussel_dht;
  47. #endif
  48. // Array to store ID strings
  49. String idStack[STACK_SIZE];
  50. unsigned long timeStack[STACK_SIZE];
  51. int measureStack[STACK_SIZE];
  52. // Index of the top element in the stack, -1 means stack is empty
  53. int top = -1;
  54. };
  55. #endif