1
0
mirror of https://gitlab.com/lander-team/lander-cpp.git synced 2025-08-02 11:31:34 +00:00

Moved init_loadCells() to teensy.h

This commit is contained in:
bpmcgeeney
2021-11-14 20:31:17 -07:00
parent f7acf25479
commit 503bf40c5b
2 changed files with 52 additions and 51 deletions

View File

@@ -27,19 +27,6 @@ unsigned long last, initTime;
#include <HX711.h>
#include <PWMServo.h>
const int lc_clock = 23;
const int pin_lc0 = 14;
const int pin_lc1 = 15;
const int pin_lc2 = 19;
const int pin_lc3 = 20;
void init_loadCells();
void read_lc0();
void read_lc1();
void read_lc2();
void read_lc3();
HX711 lc0;
HX711 lc1;
HX711 lc2;
@@ -63,7 +50,7 @@ void setup() {
delay(1000);
}
init_loadCells();
init_loadCells(lc0, lc1, lc2, lc3);
init_Vehicle(State);
State.lc0 = lc0.get_value();
State.lc1 = lc1.get_value();
@@ -119,46 +106,12 @@ void loop() {
delay(State.stepSize - ((micros() - last) / 1000.0));
}
void init_loadCells() {
// Configure clock pin with high impedance to protect
// pin (if this doesn't work, change to OUTPUT)
pinMode(lc_clock, INPUT);
// Configure load cell data pins as inputs
pinMode(pin_lc0, INPUT);
pinMode(pin_lc1, INPUT);
pinMode(pin_lc2, INPUT);
pinMode(pin_lc3, INPUT);
lc0.begin(pin_lc0, lc_clock);
lc1.begin(pin_lc1, lc_clock);
lc2.begin(pin_lc2, lc_clock);
lc3.begin(pin_lc3, lc_clock);
// Attach ISRs to load cell data pins to read data when available
attachInterrupt(digitalPinToInterrupt(pin_lc0), read_lc0, LOW);
attachInterrupt(digitalPinToInterrupt(pin_lc1), read_lc1, LOW);
attachInterrupt(digitalPinToInterrupt(pin_lc2), read_lc2, LOW);
attachInterrupt(digitalPinToInterrupt(pin_lc3), read_lc3, LOW);
Serial.println("Load Cells Initialized");
Serial.print("Calibrating");
lc0.tare();
Serial.print(".");
lc1.tare();
Serial.print(".");
lc2.tare();
Serial.print(".");
lc3.tare();
Serial.println(".");
Serial.println("Load Cells Calibrated");
}
// ISRs to print data to serial monitor
// ISRs to print data to serial monitor - These unfortunately can't move
void read_lc0() { State.lc0 = lc0.get_value(); }
void read_lc1() { State.lc1 = lc1.get_value(); }
void read_lc2() { State.lc2 = lc2.get_value(); }
void read_lc3() { State.lc3 = lc3.get_value(); }
#endif
#if defined(_WIN32) || defined(NATIVE)