main.c 875 B

12345678910111213141516171819202122232425262728293031
  1. /*********************************************************************
  2. * hx711 example for Versa1.0
  3. *********************************************************************/
  4. #define BOARD Versa1
  5. #include <fruit.h>
  6. #include <hx711.h>
  7. //----------- Setup ----------------
  8. void setup(void) {
  9. fruitInit();
  10. hx711Init(0); // init hx711 module, gainA=128
  11. }
  12. // ---------- Main loop ------------
  13. void loop() {
  14. fraiseService();// listen to Fraise events
  15. hx711Service(); // hx711 service routine
  16. }
  17. // ---------- Receiving ------------
  18. void fraiseReceive() // receive raw bytes
  19. {
  20. int i;
  21. unsigned char c=fraiseGetChar(); // get first byte
  22. if(c == 50) { // if first byte is 50
  23. c=fraiseGetChar(); // read channel byte
  24. printf("C 50 %d %ld\n", c, hx711Read(c)); // return selected channel current value
  25. }
  26. }