hx711.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*********************************************************************
  2. *
  3. * Load Cell Amplifier HX711 library for Fraise pic18f device.
  4. * thanks to https://github.com/bogde/HX711 arduino library.
  5. *
  6. *********************************************************************
  7. * Author Date Comment
  8. *********************************************************************
  9. * Antoine Rousseau sept 2016 Original.
  10. ********************************************************************/
  11. /*
  12. # This program is free software; you can redistribute it and/or
  13. # modify it under the terms of the GNU General Public License
  14. # as published by the Free Software Foundation; either version 2
  15. # of the License, or (at your option) any later version.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. # You should have received a copy of the GNU General Public License
  22. # along with this program; if not, write to the Free Software
  23. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  24. # MA 02110-1301, USA.
  25. */
  26. #ifndef _HX711_H_
  27. #define _HX711_H_
  28. /** @file */
  29. /** @defgroup hx711 Load Cell Amplifier HX711 module
  30. *
  31. * Example :
  32. * **config.h** :
  33. * \include hx711/examples/example1/config.h
  34. * **main.c** :
  35. * \include hx711/examples/example1/main.c
  36. * @{
  37. */
  38. #include <fruit.h>
  39. #ifndef HX711_SCK_PIN
  40. #error you must define HX711_SCK_PIN before calling hx711.h
  41. #endif
  42. #ifndef HX711_DATA_PIN
  43. #error you must define HX711_DATA_PIN before calling hx711.h
  44. #endif
  45. /** \name Settings to put in config.h
  46. You must define the serial port :
  47. ~~~~
  48. #define HX711_SCK_PIN [pin]
  49. #define HX711_DATA_PIN [pin]
  50. ~~~~
  51. */
  52. // The following parameters can be overloaded:
  53. //@{
  54. //@}
  55. /** \name Initialization
  56. */
  57. //@{
  58. /** @brief Init the module in **setup()**
  59. @gainA channel A gain selection : 0=128 1=64
  60. */
  61. void hx711Init(unsigned char gainA);
  62. //@}
  63. /** \name Main loop functions
  64. */
  65. //@{
  66. void hx711Service(); ///< @brief Module service routine, to be called by the main **loop()**.
  67. //@}
  68. /** \name Utilities
  69. */
  70. //@{
  71. /** @brief Read last measure of a channel
  72. @param channel channel selection : 0=A 1=B
  73. @return current measure
  74. */
  75. long hx711Read(unsigned char channel);
  76. //@}
  77. /** @}
  78. */
  79. #endif // _HX711_H_