Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

3 місяці тому
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include <Arduino.h>
  2. #include <EEPROMex.h>
  3. #include "lcd.h"
  4. #include "serial.h"
  5. #include "scale.h"
  6. #include "buttons.h"
  7. #include "weight_controller.h"
  8. #define shift_element 3
  9. // =====================
  10. // ======= SETUP =======
  11. // =====================
  12. LCD lcd;
  13. SerialIO serial;
  14. Scale scale;
  15. Buttons buttons;
  16. WeightControllerPool pool;
  17. void setup()
  18. {
  19. //
  20. // INIT
  21. //
  22. lcd.init();
  23. serial.init();
  24. scale.init();
  25. buttons.init();
  26. pool.init();
  27. //
  28. // DISPLAY INIT MESSAGES
  29. //
  30. serial.print_init_message();
  31. lcd.print_init_message(scale.get_calibration_weight());
  32. lcd.clear();
  33. //
  34. // DISPLAY INIT MESSAGES
  35. //
  36. }
  37. void loop()
  38. {
  39. //
  40. // ON BUTTON PRESSED ACTION
  41. //
  42. if (buttons.is_any_pressed())
  43. {
  44. buttons.on_button_pressed(scale, pool, lcd);
  45. }
  46. //
  47. // READ WEIGHT
  48. //
  49. scale.read();
  50. if (pool.is_controller_displayed()) {
  51. //
  52. // SHOW CONTROL RESULT
  53. //
  54. WeightController &controller = pool.get();
  55. int result = controller.compare(scale.get_average_grain());
  56. lcd.print_control_result(controller.get_name(), controller.get_val_min(), controller.get_val_max(), result);
  57. //
  58. // SHOW CONTROL RESULT
  59. //
  60. } else {
  61. //
  62. // PRINT WEIGHT
  63. //
  64. lcd.print_weights(scale.get_average_gram(), scale.get_average_grain());
  65. //
  66. // PRINT WEIGHT
  67. //
  68. }
  69. //
  70. // PROCESS REQUESTS FROM SERIAL
  71. //
  72. if (serial.is_available())
  73. {
  74. serial.on_command(scale, pool, lcd);
  75. if (serial.is_debug_info_allowed())
  76. {
  77. serial.print_debug_info(scale.get_raw(), scale.get_average_raw(), scale.get_offset(), scale.get_weight(), scale.get_actual_gram(), scale.get_average_gram(), scale.get_average_grain());
  78. }
  79. }
  80. //
  81. // PROCESS REQUESTS FROM SERIAL
  82. //
  83. }