From 9aac27c40443111e0de8ae11d241678cb9e04334 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Wed, 12 Feb 2014 05:45:48 +0000 Subject: [PATCH] Move timer to main --- vis/device.py | 9 +++++++-- yue/main.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/vis/device.py b/vis/device.py index 093f380..7d47d77 100644 --- a/vis/device.py +++ b/vis/device.py @@ -87,6 +87,7 @@ class Frame: bits_typ = 0 # data type binary = "" # binary read-in values = [] # converted numeric data + total = 0 # total states read so far # Constructor def __init__(self): @@ -153,8 +154,12 @@ class Frame: fmt = Frame.fmtMap[self.bits_typ] * self.count sns = Frame.snsMap[self.bits_sns] self.values = unpack('<'+fmt, self.binary) - print('convert: %3s = \'%3s\'%%[%s] -> [%s]' % - (sns, fmt, hexDump(self.binary), fltDump(self.values))) + #print('convert: %3s = \'%3s\'%%[%s] -> [%s]' % + # (sns, fmt, hexDump(self.binary), fltDump(self.values))) + + if self.total % 100 == 0: + print('read %d samples' % self.total); + self.total += 1; # Create state state = State() diff --git a/yue/main.cpp b/yue/main.cpp index e580188..ce909d4 100644 --- a/yue/main.cpp +++ b/yue/main.cpp @@ -146,7 +146,7 @@ void printBin(uint8_t *frame, int len); int main(void) { // Initialization // Interruption Declarations - clock1.attach(&clock1_interrupt, TIME_ACCURACY); // maximun accuracy be 0.1s + //clock1.attach(&clock1_interrupt, TIME_ACCURACY); // maximun accuracy be 0.1s serial.attach(&serialRx_interrupt, Serial::RxIrq); // receive interrupt for serialS serial.baud(115200); magSensor.begin(); @@ -155,8 +155,13 @@ int main(void) { printStr("\r\n============= Start of the program ============\r\n"); + int ticks = 0, tocks = 0; while(1){ - wait(3); + ticks = us_ticker_read() * TIME_ACCURACY; + if (tocks < ticks) { + clock1_interrupt(); + tocks++; + } } } -- 2.43.2