measurement in telegram
This commit is contained in:
parent
18d32c860e
commit
2b89c9736b
@ -9,6 +9,8 @@
|
||||
#include "stdint.h"
|
||||
#include "adc.h"
|
||||
|
||||
#include "time.h"
|
||||
|
||||
void MeterBusClient::aSB(unsigned char v) {
|
||||
m_sendBuffer[m_sendBufferLen] = v;
|
||||
m_sendBufferLen++;
|
||||
@ -106,8 +108,41 @@ void MeterBusClient::REQ_UD2() {
|
||||
aSB(getStatus()); // Status
|
||||
aSB((unsigned int)0); // Signatur
|
||||
|
||||
|
||||
// Uptime
|
||||
// DIF
|
||||
aSB((unsigned char)0x01);
|
||||
// VIF
|
||||
aSB((unsigned char)0x24);
|
||||
aSB(uptime.getSeconds());
|
||||
|
||||
// DIF
|
||||
aSB((unsigned char)0x01);
|
||||
// VIF
|
||||
aSB((unsigned char)0x25);
|
||||
aSB(uptime.getMinutes());
|
||||
|
||||
// DIF
|
||||
aSB((unsigned char)0x01);
|
||||
// VIF
|
||||
aSB((unsigned char)0x26);
|
||||
aSB(uptime.getHours());
|
||||
|
||||
// DIF
|
||||
aSB((unsigned char)0x02);
|
||||
// VIF
|
||||
aSB((unsigned char)0x27);
|
||||
aSB((unsigned int)uptime.getDays());
|
||||
|
||||
|
||||
// Measurement Value
|
||||
// DIF
|
||||
aSB((uint8_t)0x02);
|
||||
aSB((uint8_t)0x7f);
|
||||
|
||||
uint16_t measVal = adcGet();
|
||||
aSB(measVal);
|
||||
|
||||
//aSB((uint16_t) 0xaffe);
|
||||
|
||||
aSB(calcSendChecksum());
|
||||
|
24
src/time.cpp
24
src/time.cpp
@ -8,9 +8,11 @@
|
||||
#include <isr_compat.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "time.h"
|
||||
|
||||
|
||||
volatile unsigned long timestamp;
|
||||
Uptime uptime;
|
||||
|
||||
ISR(TIMER0_A0, TA0_ISR) {
|
||||
static uint8_t state = 0;
|
||||
@ -47,3 +49,25 @@ void timeInit() {
|
||||
unsigned long millis() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
|
||||
Uptime::Uptime() : m_seconds(0), m_minutes(0), m_hours(0), m_days(0) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Uptime::incOneSecond() {
|
||||
m_seconds++;
|
||||
if (m_seconds >= 60) {
|
||||
m_seconds -= 60;
|
||||
m_minutes++;
|
||||
if (m_minutes >= 60) {
|
||||
m_minutes -= 60;
|
||||
m_hours++;
|
||||
if (m_hours >= 24) {
|
||||
m_hours -= 24;
|
||||
m_days++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
src/time.h
21
src/time.h
@ -14,4 +14,25 @@ void timeInit();
|
||||
unsigned long millis();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Uptime {
|
||||
public:
|
||||
Uptime();
|
||||
uint8_t getSeconds() { return m_seconds; };
|
||||
uint8_t getMinutes() { return m_minutes; };
|
||||
uint8_t getHours() { return m_hours; };
|
||||
uint16_t getDays() { return m_days; };
|
||||
void incOneSecond();
|
||||
private:
|
||||
uint8_t m_seconds;
|
||||
uint8_t m_minutes;
|
||||
uint8_t m_hours;
|
||||
uint16_t m_days;
|
||||
};
|
||||
|
||||
|
||||
extern Uptime uptime;
|
||||
|
||||
#endif /* TIME_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user