From ed17033c789f771c3ba7defef3b1ecb24b51a981 Mon Sep 17 00:00:00 2001 From: hg Date: Wed, 5 Nov 2014 19:19:20 +0100 Subject: [PATCH] some fixes, strange zeros in between --- ModbusThermometer.cpp | 4 ++-- ads1210.cpp | 16 ++-------------- ads1210.h | 12 ++++++------ led.h | 8 ++++---- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/ModbusThermometer.cpp b/ModbusThermometer.cpp index aa12ab3..9b13373 100644 --- a/ModbusThermometer.cpp +++ b/ModbusThermometer.cpp @@ -21,7 +21,7 @@ void setup() { Serial.begin(9600); delay(1000); - led(LED_PIN); + led.begin(LED_PIN); ads1210.begin(ADC_CS_PIN, ADC_RDY_PIN); } @@ -31,6 +31,6 @@ void loop() { if (secondTick.check() == 1) { led.toggle(); - Serial << "AdcValue: " << adc1210.value << endl; + Serial << "AdcValue: " << _HEX(ads1210.value) << endl; } } diff --git a/ads1210.cpp b/ads1210.cpp index 22c705e..68cf1be 100644 --- a/ads1210.cpp +++ b/ads1210.cpp @@ -69,26 +69,14 @@ void ADS1210::exec() { res.in[3] = 0; disableCS(); - Serial << "DOR4x8: " << _HEX(res.in[3]) << " " << _HEX(res.in[2]) << " " << _HEX(res.in[1]) << " " << _HEX(res.in[0]) << endl; - Serial << "DOR1x32: " << _HEX(res.out) << endl; + // Serial << "DOR4x8: " << _HEX(res.in[3]) << " " << _HEX(res.in[2]) << " " << _HEX(res.in[1]) << " " << _HEX(res.in[0]) << endl; + // Serial << "DOR1x32: " << _HEX(res.out) << endl; value = res.out; } } -void ADS1210::disableRefO() const { - uint8_t cmr = readRegister(ADDR_CMR3); - cmr &= ~CMR_REFO; - writeRegister(ADDR_CMR3, cmr); -} - -void ADS1210::enableRefO() const { - uint8_t cmr = readRegister(ADDR_CMR3); - cmr |= CMR_REFO; - writeRegister(ADDR_CMR3, cmr); -} - void ADS1210::setMode(uint8_t mode) const { uint8_t cmr = readRegister(ADDR_CMR2); cmr &= ~CMR_MD_Mask; diff --git a/ads1210.h b/ads1210.h index f3b4da1..e2f648c 100644 --- a/ads1210.h +++ b/ads1210.h @@ -10,7 +10,7 @@ class ADS1210 { public: - ADS1210() : value(0); + ADS1210() : value(0) {}; void begin(uint8_t csPin, uint8_t drdyPin); void exec(); @@ -55,11 +55,11 @@ private: const uint8_t CMD_MD_Sleep = 0xc0; const uint8_t CMR_Gain_Mask = (0x07 << 2); - const uint8_t CMD_Gain_1 = 0; - const uint8_t CMD_Gain_2 = (0x01 << 2); - const uint8_t CMD_Gain_4 = (0x02 << 2); - const uint8_t CMD_Gain_8 = (0x03 << 2); - const uint8_t CMD_Gain_16 = (0x04 << 2); + const uint8_t CMR_Gain_1 = 0; + const uint8_t CMR_Gain_2 = (0x01 << 2); + const uint8_t CMR_Gain_4 = (0x02 << 2); + const uint8_t CMR_Gain_8 = (0x03 << 2); + const uint8_t CMR_Gain_16 = (0x04 << 2); // bit values // INSR diff --git a/led.h b/led.h index 1e42a52..cb87fa2 100644 --- a/led.h +++ b/led.h @@ -15,18 +15,18 @@ public: void on() { m_state = 1; digitalWrite(m_pin, m_state); - } + }; void off() { m_state = 0; digitalWrite(m_pin, m_state); - } + }; void toggle() { m_state ^= 1; digitalWrite(m_pin, m_state); - } + }; private: uint8_t m_state; uint8_t m_pin; -} +}; #endif // _LED_H_