FireFly library: variant kept in the 2014 GitLab archive
GPS include disabled, out-of-reach flag instead of the 7-segment error. Exact date unknown; dated at the archive's first commit (Feb 2014).
This commit is contained in:
1 parent
6e50819e01
commit
413f52c008
10 files changed
+1585
-1583
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -1,101 +1,101 @@
|
|||||||
/*
|
/*
|
||||||
* IRremote
|
* IRremote
|
||||||
* Version 0.1 July, 2009
|
* Version 0.1 July, 2009
|
||||||
* Copyright 2009 Ken Shirriff
|
* Copyright 2009 Ken Shirriff
|
||||||
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.htm http://arcfn.com
|
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.htm http://arcfn.com
|
||||||
*
|
*
|
||||||
* Interrupt code based on NECIRrcv by Joe Knapp
|
* Interrupt code based on NECIRrcv by Joe Knapp
|
||||||
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
|
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
|
||||||
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IRremote_h
|
#ifndef IRremote_h
|
||||||
#define IRremote_h
|
#define IRremote_h
|
||||||
|
|
||||||
// The following are compile-time library options.
|
// The following are compile-time library options.
|
||||||
// If you change them, recompile the library.
|
// If you change them, recompile the library.
|
||||||
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
|
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
|
||||||
// TEST must be defined for the IRtest unittests to work. It will make some
|
// TEST must be defined for the IRtest unittests to work. It will make some
|
||||||
// methods virtual, which will be slightly slower, which is why it is optional.
|
// methods virtual, which will be slightly slower, which is why it is optional.
|
||||||
// #define DEBUG
|
// #define DEBUG
|
||||||
// #define TEST
|
// #define TEST
|
||||||
|
|
||||||
// Results returned from the decoder
|
// Results returned from the decoder
|
||||||
class decode_results {
|
class decode_results {
|
||||||
public:
|
public:
|
||||||
int decode_type; // NEC, SONY, RC5, UNKNOWN
|
int decode_type; // NEC, SONY, RC5, UNKNOWN
|
||||||
unsigned long value; // Decoded value
|
unsigned long value; // Decoded value
|
||||||
int bits; // Number of bits in decoded value
|
int bits; // Number of bits in decoded value
|
||||||
volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks
|
volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks
|
||||||
int rawlen; // Number of records in rawbuf.
|
int rawlen; // Number of records in rawbuf.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Values for decode_type
|
// Values for decode_type
|
||||||
#define NEC 1
|
#define NEC 1
|
||||||
#define SONY 2
|
#define SONY 2
|
||||||
#define RC5 3
|
#define RC5 3
|
||||||
#define RC6 4
|
#define RC6 4
|
||||||
#define DISH 5
|
#define DISH 5
|
||||||
#define SHARP 6
|
#define SHARP 6
|
||||||
#define UNKNOWN -1
|
#define UNKNOWN -1
|
||||||
|
|
||||||
// Decoded value for NEC when a repeat code is received
|
// Decoded value for NEC when a repeat code is received
|
||||||
#define REPEAT 0xffffffff
|
#define REPEAT 0xffffffff
|
||||||
|
|
||||||
// main class for receiving IR
|
// main class for receiving IR
|
||||||
class IRrecv
|
class IRrecv
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IRrecv(int recvpin);
|
IRrecv(int recvpin);
|
||||||
void blink13(int blinkflag);
|
void blink13(int blinkflag);
|
||||||
int decode(decode_results *results);
|
int decode(decode_results *results);
|
||||||
void enableIRIn();
|
void enableIRIn();
|
||||||
void resume();
|
void resume();
|
||||||
private:
|
private:
|
||||||
// These are called by decode
|
// These are called by decode
|
||||||
int getRClevel(decode_results *results, int *offset, int *used, int t1);
|
int getRClevel(decode_results *results, int *offset, int *used, int t1);
|
||||||
long decodeNEC(decode_results *results);
|
long decodeNEC(decode_results *results);
|
||||||
long decodeSony(decode_results *results);
|
long decodeSony(decode_results *results);
|
||||||
long decodeRC5(decode_results *results);
|
long decodeRC5(decode_results *results);
|
||||||
long decodeRC6(decode_results *results);
|
long decodeRC6(decode_results *results);
|
||||||
long decodeHash(decode_results *results);
|
long decodeHash(decode_results *results);
|
||||||
int compare(unsigned int oldval, unsigned int newval);
|
int compare(unsigned int oldval, unsigned int newval);
|
||||||
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
// Only used for testing; can remove virtual for shorter code
|
// Only used for testing; can remove virtual for shorter code
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
#define VIRTUAL virtual
|
#define VIRTUAL virtual
|
||||||
#else
|
#else
|
||||||
#define VIRTUAL
|
#define VIRTUAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class IRsend
|
class IRsend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IRsend() {}
|
IRsend() {}
|
||||||
void sendNEC(unsigned long data, int nbits);
|
void sendNEC(unsigned long data, int nbits);
|
||||||
void sendSony(unsigned long data, int nbits);
|
void sendSony(unsigned long data, int nbits);
|
||||||
void sendRaw(unsigned int buf[], int len, int hz);
|
void sendRaw(unsigned int buf[], int len, int hz);
|
||||||
void sendRC5(unsigned long data, int nbits);
|
void sendRC5(unsigned long data, int nbits);
|
||||||
void sendRC6(unsigned long data, int nbits);
|
void sendRC6(unsigned long data, int nbits);
|
||||||
void sendDISH(unsigned long data, int nbits);
|
void sendDISH(unsigned long data, int nbits);
|
||||||
void sendSharp(unsigned long data, int nbits);
|
void sendSharp(unsigned long data, int nbits);
|
||||||
// private:
|
// private:
|
||||||
void enableIROut(int khz);
|
void enableIROut(int khz);
|
||||||
VIRTUAL void mark(int usec);
|
VIRTUAL void mark(int usec);
|
||||||
VIRTUAL void space(int usec);
|
VIRTUAL void space(int usec);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
// Some useful constants
|
// Some useful constants
|
||||||
|
|
||||||
#define USECPERTICK 50 // microseconds per clock interrupt tick
|
#define USECPERTICK 50 // microseconds per clock interrupt tick
|
||||||
#define RAWBUF 76 // Length of raw duration buffer
|
#define RAWBUF 76 // Length of raw duration buffer
|
||||||
|
|
||||||
// Marks tend to be 100us too long, and spaces 100us too short
|
// Marks tend to be 100us too long, and spaces 100us too short
|
||||||
// when received due to sensor lag.
|
// when received due to sensor lag.
|
||||||
#define MARK_EXCESS 100
|
#define MARK_EXCESS 100
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,398 +1,398 @@
|
|||||||
/*
|
/*
|
||||||
* IRremote
|
* IRremote
|
||||||
* Version 0.1 July, 2009
|
* Version 0.1 July, 2009
|
||||||
* Copyright 2009 Ken Shirriff
|
* Copyright 2009 Ken Shirriff
|
||||||
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
|
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
|
||||||
*
|
*
|
||||||
* Modified by Paul Stoffregen <paul@pjrc.com> to support other boards and timers
|
* Modified by Paul Stoffregen <paul@pjrc.com> to support other boards and timers
|
||||||
*
|
*
|
||||||
* Interrupt code based on NECIRrcv by Joe Knapp
|
* Interrupt code based on NECIRrcv by Joe Knapp
|
||||||
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
|
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
|
||||||
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IRremoteint_h
|
#ifndef IRremoteint_h
|
||||||
#define IRremoteint_h
|
#define IRremoteint_h
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
// define which timer to use
|
// define which timer to use
|
||||||
//
|
//
|
||||||
// Uncomment the timer you wish to use on your board. If you
|
// Uncomment the timer you wish to use on your board. If you
|
||||||
// are using another library which uses timer2, you have options
|
// are using another library which uses timer2, you have options
|
||||||
// to switch IRremote to use a different timer.
|
// to switch IRremote to use a different timer.
|
||||||
|
|
||||||
// Arduino Mega
|
// Arduino Mega
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__)
|
||||||
//#define IR_USE_TIMER1 // tx = pin 11
|
//#define IR_USE_TIMER1 // tx = pin 11
|
||||||
#define IR_USE_TIMER2 // tx = pin 9
|
#define IR_USE_TIMER2 // tx = pin 9
|
||||||
//#define IR_USE_TIMER3 // tx = pin 5
|
//#define IR_USE_TIMER3 // tx = pin 5
|
||||||
//#define IR_USE_TIMER4 // tx = pin 6
|
//#define IR_USE_TIMER4 // tx = pin 6
|
||||||
//#define IR_USE_TIMER5 // tx = pin 46
|
//#define IR_USE_TIMER5 // tx = pin 46
|
||||||
|
|
||||||
// Teensy 1.0
|
// Teensy 1.0
|
||||||
#elif defined(__AVR_AT90USB162__)
|
#elif defined(__AVR_AT90USB162__)
|
||||||
#define IR_USE_TIMER1 // tx = pin 17
|
#define IR_USE_TIMER1 // tx = pin 17
|
||||||
|
|
||||||
// Teensy 2.0
|
// Teensy 2.0
|
||||||
#elif defined(__AVR_ATmega32U4__)
|
#elif defined(__AVR_ATmega32U4__)
|
||||||
//#define IR_USE_TIMER1 // tx = pin 14
|
//#define IR_USE_TIMER1 // tx = pin 14
|
||||||
//#define IR_USE_TIMER3 // tx = pin 9
|
//#define IR_USE_TIMER3 // tx = pin 9
|
||||||
#define IR_USE_TIMER4_HS // tx = pin 10
|
#define IR_USE_TIMER4_HS // tx = pin 10
|
||||||
|
|
||||||
// Teensy++ 1.0 & 2.0
|
// Teensy++ 1.0 & 2.0
|
||||||
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
||||||
//#define IR_USE_TIMER1 // tx = pin 25
|
//#define IR_USE_TIMER1 // tx = pin 25
|
||||||
#define IR_USE_TIMER2 // tx = pin 1
|
#define IR_USE_TIMER2 // tx = pin 1
|
||||||
//#define IR_USE_TIMER3 // tx = pin 16
|
//#define IR_USE_TIMER3 // tx = pin 16
|
||||||
|
|
||||||
// Sanguino
|
// Sanguino
|
||||||
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
||||||
//#define IR_USE_TIMER1 // tx = pin 13
|
//#define IR_USE_TIMER1 // tx = pin 13
|
||||||
#define IR_USE_TIMER2 // tx = pin 14
|
#define IR_USE_TIMER2 // tx = pin 14
|
||||||
|
|
||||||
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc
|
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc
|
||||||
#else
|
#else
|
||||||
//#define IR_USE_TIMER1 // tx = pin 9
|
//#define IR_USE_TIMER1 // tx = pin 9
|
||||||
#define IR_USE_TIMER2 // tx = pin 3
|
#define IR_USE_TIMER2 // tx = pin 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef F_CPU
|
#ifdef F_CPU
|
||||||
#define SYSCLOCK F_CPU // main Arduino clock
|
#define SYSCLOCK F_CPU // main Arduino clock
|
||||||
#else
|
#else
|
||||||
#define SYSCLOCK 16000000 // main Arduino clock
|
#define SYSCLOCK 16000000 // main Arduino clock
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ERR 0
|
#define ERR 0
|
||||||
#define DECODED 1
|
#define DECODED 1
|
||||||
|
|
||||||
|
|
||||||
// defines for setting and clearing register bits
|
// defines for setting and clearing register bits
|
||||||
#ifndef cbi
|
#ifndef cbi
|
||||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||||
#endif
|
#endif
|
||||||
#ifndef sbi
|
#ifndef sbi
|
||||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// pulse parameters in usec
|
// pulse parameters in usec
|
||||||
#define NEC_HDR_MARK 9000
|
#define NEC_HDR_MARK 9000
|
||||||
#define NEC_HDR_SPACE 4500
|
#define NEC_HDR_SPACE 4500
|
||||||
#define NEC_BIT_MARK 560
|
#define NEC_BIT_MARK 560
|
||||||
#define NEC_ONE_SPACE 1600
|
#define NEC_ONE_SPACE 1600
|
||||||
#define NEC_ZERO_SPACE 560
|
#define NEC_ZERO_SPACE 560
|
||||||
#define NEC_RPT_SPACE 2250
|
#define NEC_RPT_SPACE 2250
|
||||||
|
|
||||||
#define SONY_HDR_MARK 2400
|
#define SONY_HDR_MARK 2400
|
||||||
#define SONY_HDR_SPACE 600
|
#define SONY_HDR_SPACE 600
|
||||||
#define SONY_ONE_MARK 1200
|
#define SONY_ONE_MARK 1200
|
||||||
#define SONY_ZERO_MARK 600
|
#define SONY_ZERO_MARK 600
|
||||||
#define SONY_RPT_LENGTH 45000
|
#define SONY_RPT_LENGTH 45000
|
||||||
|
|
||||||
#define RC5_T1 889
|
#define RC5_T1 889
|
||||||
#define RC5_RPT_LENGTH 46000
|
#define RC5_RPT_LENGTH 46000
|
||||||
|
|
||||||
#define RC6_HDR_MARK 2666
|
#define RC6_HDR_MARK 2666
|
||||||
#define RC6_HDR_SPACE 889
|
#define RC6_HDR_SPACE 889
|
||||||
#define RC6_T1 444
|
#define RC6_T1 444
|
||||||
#define RC6_RPT_LENGTH 46000
|
#define RC6_RPT_LENGTH 46000
|
||||||
|
|
||||||
#define SHARP_BIT_MARK 245
|
#define SHARP_BIT_MARK 245
|
||||||
#define SHARP_ONE_SPACE 1805
|
#define SHARP_ONE_SPACE 1805
|
||||||
#define SHARP_ZERO_SPACE 795
|
#define SHARP_ZERO_SPACE 795
|
||||||
#define SHARP_GAP 600000
|
#define SHARP_GAP 600000
|
||||||
#define SHARP_TOGGLE_MASK 0x3FF
|
#define SHARP_TOGGLE_MASK 0x3FF
|
||||||
#define SHARP_RPT_SPACE 3000
|
#define SHARP_RPT_SPACE 3000
|
||||||
|
|
||||||
#define DISH_HDR_MARK 400
|
#define DISH_HDR_MARK 400
|
||||||
#define DISH_HDR_SPACE 6100
|
#define DISH_HDR_SPACE 6100
|
||||||
#define DISH_BIT_MARK 400
|
#define DISH_BIT_MARK 400
|
||||||
#define DISH_ONE_SPACE 1700
|
#define DISH_ONE_SPACE 1700
|
||||||
#define DISH_ZERO_SPACE 2800
|
#define DISH_ZERO_SPACE 2800
|
||||||
#define DISH_RPT_SPACE 6200
|
#define DISH_RPT_SPACE 6200
|
||||||
#define DISH_TOP_BIT 0x8000
|
#define DISH_TOP_BIT 0x8000
|
||||||
|
|
||||||
#define SHARP_BITS 15
|
#define SHARP_BITS 15
|
||||||
#define DISH_BITS 16
|
#define DISH_BITS 16
|
||||||
|
|
||||||
#define TOLERANCE 25 // percent tolerance in measurements
|
#define TOLERANCE 25 // percent tolerance in measurements
|
||||||
#define LTOL (1.0 - TOLERANCE/100.)
|
#define LTOL (1.0 - TOLERANCE/100.)
|
||||||
#define UTOL (1.0 + TOLERANCE/100.)
|
#define UTOL (1.0 + TOLERANCE/100.)
|
||||||
|
|
||||||
#define _GAP 5000 // Minimum map between transmissions
|
#define _GAP 5000 // Minimum map between transmissions
|
||||||
#define GAP_TICKS (_GAP/USECPERTICK)
|
#define GAP_TICKS (_GAP/USECPERTICK)
|
||||||
|
|
||||||
#define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK))
|
#define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK))
|
||||||
#define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1))
|
#define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1))
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define MATCH(measured_ticks, desired_us) ((measured_ticks) >= TICKS_LOW(desired_us) && (measured_ticks) <= TICKS_HIGH(desired_us))
|
#define MATCH(measured_ticks, desired_us) ((measured_ticks) >= TICKS_LOW(desired_us) && (measured_ticks) <= TICKS_HIGH(desired_us))
|
||||||
#define MATCH_MARK(measured_ticks, desired_us) MATCH(measured_ticks, (desired_us) + MARK_EXCESS)
|
#define MATCH_MARK(measured_ticks, desired_us) MATCH(measured_ticks, (desired_us) + MARK_EXCESS)
|
||||||
#define MATCH_SPACE(measured_ticks, desired_us) MATCH((measured_ticks), (desired_us) - MARK_EXCESS)
|
#define MATCH_SPACE(measured_ticks, desired_us) MATCH((measured_ticks), (desired_us) - MARK_EXCESS)
|
||||||
// Debugging versions are in IRremote.cpp
|
// Debugging versions are in IRremote.cpp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// receiver states
|
// receiver states
|
||||||
#define STATE_IDLE 2
|
#define STATE_IDLE 2
|
||||||
#define STATE_MARK 3
|
#define STATE_MARK 3
|
||||||
#define STATE_SPACE 4
|
#define STATE_SPACE 4
|
||||||
#define STATE_STOP 5
|
#define STATE_STOP 5
|
||||||
|
|
||||||
// information for the interrupt handler
|
// information for the interrupt handler
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t recvpin; // pin for IR data from detector
|
uint8_t recvpin; // pin for IR data from detector
|
||||||
uint8_t rcvstate; // state machine
|
uint8_t rcvstate; // state machine
|
||||||
uint8_t blinkflag; // TRUE to enable blinking of pin 13 on IR processing
|
uint8_t blinkflag; // TRUE to enable blinking of pin 13 on IR processing
|
||||||
unsigned int timer; // state timer, counts 50uS ticks.
|
unsigned int timer; // state timer, counts 50uS ticks.
|
||||||
unsigned int rawbuf[RAWBUF]; // raw data
|
unsigned int rawbuf[RAWBUF]; // raw data
|
||||||
uint8_t rawlen; // counter of entries in rawbuf
|
uint8_t rawlen; // counter of entries in rawbuf
|
||||||
}
|
}
|
||||||
irparams_t;
|
irparams_t;
|
||||||
|
|
||||||
// Defined in IRremote.cpp
|
// Defined in IRremote.cpp
|
||||||
extern volatile irparams_t irparams;
|
extern volatile irparams_t irparams;
|
||||||
|
|
||||||
// IR detector output is active low
|
// IR detector output is active low
|
||||||
#define MARK 0
|
#define MARK 0
|
||||||
#define SPACE 1
|
#define SPACE 1
|
||||||
|
|
||||||
#define TOPBIT 0x80000000
|
#define TOPBIT 0x80000000
|
||||||
|
|
||||||
#define NEC_BITS 32
|
#define NEC_BITS 32
|
||||||
#define SONY_BITS 12
|
#define SONY_BITS 12
|
||||||
#define MIN_RC5_SAMPLES 11
|
#define MIN_RC5_SAMPLES 11
|
||||||
#define MIN_RC6_SAMPLES 1
|
#define MIN_RC6_SAMPLES 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// defines for timer2 (8 bits)
|
// defines for timer2 (8 bits)
|
||||||
#if defined(IR_USE_TIMER2)
|
#if defined(IR_USE_TIMER2)
|
||||||
#define TIMER_RESET
|
#define TIMER_RESET
|
||||||
#define TIMER_ENABLE_PWM (TCCR2A |= _BV(COM2B1))
|
#define TIMER_ENABLE_PWM (TCCR2A |= _BV(COM2B1))
|
||||||
#define TIMER_DISABLE_PWM (TCCR2A &= ~(_BV(COM2B1)))
|
#define TIMER_DISABLE_PWM (TCCR2A &= ~(_BV(COM2B1)))
|
||||||
#define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A))
|
#define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A))
|
||||||
#define TIMER_DISABLE_INTR (TIMSK2 - 0)
|
#define TIMER_DISABLE_INTR (TIMSK2 - 0)
|
||||||
#define TIMER_INTR_NAME TIMER2_COMPA_vect
|
#define TIMER_INTR_NAME TIMER2_COMPA_vect
|
||||||
#define TIMER_CONFIG_KHZ(val) ({ \
|
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||||
const uint8_t pwmval = SYSCLOCK / 2000 / (val); \
|
const uint8_t pwmval = SYSCLOCK / 2000 / (val); \
|
||||||
TCCR2A = _BV(WGM20); \
|
TCCR2A = _BV(WGM20); \
|
||||||
TCCR2B = _BV(WGM22) | _BV(CS20); \
|
TCCR2B = _BV(WGM22) | _BV(CS20); \
|
||||||
OCR2A = pwmval; \
|
OCR2A = pwmval; \
|
||||||
OCR2B = pwmval / 3; \
|
OCR2B = pwmval / 3; \
|
||||||
})
|
})
|
||||||
#define TIMER_COUNT_TOP (SYSCLOCK * USECPERTICK / 1000000)
|
#define TIMER_COUNT_TOP (SYSCLOCK * USECPERTICK / 1000000)
|
||||||
#if (TIMER_COUNT_TOP < 256)
|
#if (TIMER_COUNT_TOP < 256)
|
||||||
#define TIMER_CONFIG_NORMAL() ({ \
|
#define TIMER_CONFIG_NORMAL() ({ \
|
||||||
TCCR2A = _BV(WGM21); \
|
TCCR2A = _BV(WGM21); \
|
||||||
TCCR2B = _BV(CS20); \
|
TCCR2B = _BV(CS20); \
|
||||||
OCR2A = TIMER_COUNT_TOP; \
|
OCR2A = TIMER_COUNT_TOP; \
|
||||||
TCNT2 = 0; \
|
TCNT2 = 0; \
|
||||||
})
|
})
|
||||||
#else
|
#else
|
||||||
#define TIMER_CONFIG_NORMAL() ({ \
|
#define TIMER_CONFIG_NORMAL() ({ \
|
||||||
TCCR2A = _BV(WGM21); \
|
TCCR2A = _BV(WGM21); \
|
||||||
TCCR2B = _BV(CS21); \
|
TCCR2B = _BV(CS21); \
|
||||||
OCR2A = TIMER_COUNT_TOP / 8; \
|
OCR2A = TIMER_COUNT_TOP / 8; \
|
||||||
TCNT2 = 0; \
|
TCNT2 = 0; \
|
||||||
})
|
})
|
||||||
#endif
|
#endif
|
||||||
#if defined(CORE_OC2B_PIN)
|
#if defined(CORE_OC2B_PIN)
|
||||||
#define TIMER_PWM_PIN CORE_OC2B_PIN /* Teensy */
|
#define TIMER_PWM_PIN CORE_OC2B_PIN /* Teensy */
|
||||||
#elif defined(__AVR_ATmega1280__)
|
#elif defined(__AVR_ATmega1280__)
|
||||||
#define TIMER_PWM_PIN 9 /* Arduino Mega */
|
#define TIMER_PWM_PIN 9 /* Arduino Mega */
|
||||||
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
||||||
#define TIMER_PWM_PIN 14 /* Sanguino */
|
#define TIMER_PWM_PIN 14 /* Sanguino */
|
||||||
#else
|
#else
|
||||||
#define TIMER_PWM_PIN 3 /* Arduino Duemilanove, Diecimila, LilyPad, etc */
|
#define TIMER_PWM_PIN 3 /* Arduino Duemilanove, Diecimila, LilyPad, etc */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// defines for timer1 (16 bits)
|
// defines for timer1 (16 bits)
|
||||||
#elif defined(IR_USE_TIMER1)
|
#elif defined(IR_USE_TIMER1)
|
||||||
#define TIMER_RESET
|
#define TIMER_RESET
|
||||||
#define TIMER_ENABLE_PWM (TCCR1A |= _BV(COM1A1))
|
#define TIMER_ENABLE_PWM (TCCR1A |= _BV(COM1A1))
|
||||||
#define TIMER_DISABLE_PWM (TCCR1A &= ~(_BV(COM1A1)))
|
#define TIMER_DISABLE_PWM (TCCR1A &= ~(_BV(COM1A1)))
|
||||||
#define TIMER_ENABLE_INTR (TIMSK1 = _BV(OCIE1A))
|
#define TIMER_ENABLE_INTR (TIMSK1 = _BV(OCIE1A))
|
||||||
#define TIMER_DISABLE_INTR (TIMSK1 = 0)
|
#define TIMER_DISABLE_INTR (TIMSK1 = 0)
|
||||||
#define TIMER_INTR_NAME TIMER1_COMPA_vect
|
#define TIMER_INTR_NAME TIMER1_COMPA_vect
|
||||||
#define TIMER_CONFIG_KHZ(val) ({ \
|
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||||
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
||||||
TCCR1A = _BV(WGM11); \
|
TCCR1A = _BV(WGM11); \
|
||||||
TCCR1B = _BV(WGM13) | _BV(CS10); \
|
TCCR1B = _BV(WGM13) | _BV(CS10); \
|
||||||
ICR1 = pwmval; \
|
ICR1 = pwmval; \
|
||||||
OCR1A = pwmval / 3; \
|
OCR1A = pwmval / 3; \
|
||||||
})
|
})
|
||||||
#define TIMER_CONFIG_NORMAL() ({ \
|
#define TIMER_CONFIG_NORMAL() ({ \
|
||||||
TCCR1A = 0; \
|
TCCR1A = 0; \
|
||||||
TCCR1B = _BV(WGM12) | _BV(CS10); \
|
TCCR1B = _BV(WGM12) | _BV(CS10); \
|
||||||
OCR1A = SYSCLOCK * USECPERTICK / 1000000; \
|
OCR1A = SYSCLOCK * USECPERTICK / 1000000; \
|
||||||
TCNT1 = 0; \
|
TCNT1 = 0; \
|
||||||
})
|
})
|
||||||
#if defined(CORE_OC1A_PIN)
|
#if defined(CORE_OC1A_PIN)
|
||||||
#define TIMER_PWM_PIN CORE_OC1A_PIN /* Teensy */
|
#define TIMER_PWM_PIN CORE_OC1A_PIN /* Teensy */
|
||||||
#elif defined(__AVR_ATmega1280__)
|
#elif defined(__AVR_ATmega1280__)
|
||||||
#define TIMER_PWM_PIN 11 /* Arduino Mega */
|
#define TIMER_PWM_PIN 11 /* Arduino Mega */
|
||||||
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
||||||
#define TIMER_PWM_PIN 13 /* Sanguino */
|
#define TIMER_PWM_PIN 13 /* Sanguino */
|
||||||
#else
|
#else
|
||||||
#define TIMER_PWM_PIN 9 /* Arduino Duemilanove, Diecimila, LilyPad, etc */
|
#define TIMER_PWM_PIN 9 /* Arduino Duemilanove, Diecimila, LilyPad, etc */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// defines for timer3 (16 bits)
|
// defines for timer3 (16 bits)
|
||||||
#elif defined(IR_USE_TIMER3)
|
#elif defined(IR_USE_TIMER3)
|
||||||
#define TIMER_RESET
|
#define TIMER_RESET
|
||||||
#define TIMER_ENABLE_PWM (TCCR3A |= _BV(COM3A1))
|
#define TIMER_ENABLE_PWM (TCCR3A |= _BV(COM3A1))
|
||||||
#define TIMER_DISABLE_PWM (TCCR3A &= ~(_BV(COM3A1)))
|
#define TIMER_DISABLE_PWM (TCCR3A &= ~(_BV(COM3A1)))
|
||||||
#define TIMER_ENABLE_INTR (TIMSK3 = _BV(OCIE3A))
|
#define TIMER_ENABLE_INTR (TIMSK3 = _BV(OCIE3A))
|
||||||
#define TIMER_DISABLE_INTR (TIMSK3 = 0)
|
#define TIMER_DISABLE_INTR (TIMSK3 = 0)
|
||||||
#define TIMER_INTR_NAME TIMER3_COMPA_vect
|
#define TIMER_INTR_NAME TIMER3_COMPA_vect
|
||||||
#define TIMER_CONFIG_KHZ(val) ({ \
|
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||||
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
||||||
TCCR3A = _BV(WGM31); \
|
TCCR3A = _BV(WGM31); \
|
||||||
TCCR3B = _BV(WGM33) | _BV(CS30); \
|
TCCR3B = _BV(WGM33) | _BV(CS30); \
|
||||||
ICR3 = pwmval; \
|
ICR3 = pwmval; \
|
||||||
OCR3A = pwmval / 3; \
|
OCR3A = pwmval / 3; \
|
||||||
})
|
})
|
||||||
#define TIMER_CONFIG_NORMAL() ({ \
|
#define TIMER_CONFIG_NORMAL() ({ \
|
||||||
TCCR3A = 0; \
|
TCCR3A = 0; \
|
||||||
TCCR3B = _BV(WGM32) | _BV(CS30); \
|
TCCR3B = _BV(WGM32) | _BV(CS30); \
|
||||||
OCR3A = SYSCLOCK * USECPERTICK / 1000000; \
|
OCR3A = SYSCLOCK * USECPERTICK / 1000000; \
|
||||||
TCNT3 = 0; \
|
TCNT3 = 0; \
|
||||||
})
|
})
|
||||||
#if defined(CORE_OC3A_PIN)
|
#if defined(CORE_OC3A_PIN)
|
||||||
#define TIMER_PWM_PIN CORE_OC3A_PIN /* Teensy */
|
#define TIMER_PWM_PIN CORE_OC3A_PIN /* Teensy */
|
||||||
#elif defined(__AVR_ATmega1280__)
|
#elif defined(__AVR_ATmega1280__)
|
||||||
#define TIMER_PWM_PIN 5 /* Arduino Mega */
|
#define TIMER_PWM_PIN 5 /* Arduino Mega */
|
||||||
#else
|
#else
|
||||||
#error "Please add OC3A pin number here\n"
|
#error "Please add OC3A pin number here\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// defines for timer4 (10 bits, high speed option)
|
// defines for timer4 (10 bits, high speed option)
|
||||||
#elif defined(IR_USE_TIMER4_HS)
|
#elif defined(IR_USE_TIMER4_HS)
|
||||||
#define TIMER_RESET
|
#define TIMER_RESET
|
||||||
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
|
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
|
||||||
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
|
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
|
||||||
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4))
|
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4))
|
||||||
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
|
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
|
||||||
#define TIMER_INTR_NAME TIMER4_OVF_vect
|
#define TIMER_INTR_NAME TIMER4_OVF_vect
|
||||||
#define TIMER_CONFIG_KHZ(val) ({ \
|
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||||
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
||||||
TCCR4A = (1<<PWM4A); \
|
TCCR4A = (1<<PWM4A); \
|
||||||
TCCR4B = _BV(CS40); \
|
TCCR4B = _BV(CS40); \
|
||||||
TCCR4C = 0; \
|
TCCR4C = 0; \
|
||||||
TCCR4D = (1<<WGM40); \
|
TCCR4D = (1<<WGM40); \
|
||||||
TCCR4E = 0; \
|
TCCR4E = 0; \
|
||||||
TC4H = pwmval >> 8; \
|
TC4H = pwmval >> 8; \
|
||||||
OCR4C = pwmval; \
|
OCR4C = pwmval; \
|
||||||
TC4H = (pwmval / 3) >> 8; \
|
TC4H = (pwmval / 3) >> 8; \
|
||||||
OCR4A = (pwmval / 3) & 255; \
|
OCR4A = (pwmval / 3) & 255; \
|
||||||
})
|
})
|
||||||
#define TIMER_CONFIG_NORMAL() ({ \
|
#define TIMER_CONFIG_NORMAL() ({ \
|
||||||
TCCR4A = 0; \
|
TCCR4A = 0; \
|
||||||
TCCR4B = _BV(CS40); \
|
TCCR4B = _BV(CS40); \
|
||||||
TCCR4C = 0; \
|
TCCR4C = 0; \
|
||||||
TCCR4D = 0; \
|
TCCR4D = 0; \
|
||||||
TCCR4E = 0; \
|
TCCR4E = 0; \
|
||||||
TC4H = (SYSCLOCK * USECPERTICK / 1000000) >> 8; \
|
TC4H = (SYSCLOCK * USECPERTICK / 1000000) >> 8; \
|
||||||
OCR4C = (SYSCLOCK * USECPERTICK / 1000000) & 255; \
|
OCR4C = (SYSCLOCK * USECPERTICK / 1000000) & 255; \
|
||||||
TC4H = 0; \
|
TC4H = 0; \
|
||||||
TCNT4 = 0; \
|
TCNT4 = 0; \
|
||||||
})
|
})
|
||||||
#if defined(CORE_OC4A_PIN)
|
#if defined(CORE_OC4A_PIN)
|
||||||
#define TIMER_PWM_PIN CORE_OC4A_PIN /* Teensy */
|
#define TIMER_PWM_PIN CORE_OC4A_PIN /* Teensy */
|
||||||
#else
|
#else
|
||||||
#error "Please add OC4A pin number here\n"
|
#error "Please add OC4A pin number here\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// defines for timer4 (16 bits)
|
// defines for timer4 (16 bits)
|
||||||
#elif defined(IR_USE_TIMER4)
|
#elif defined(IR_USE_TIMER4)
|
||||||
#define TIMER_RESET
|
#define TIMER_RESET
|
||||||
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
|
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
|
||||||
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
|
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
|
||||||
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(OCIE4A))
|
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(OCIE4A))
|
||||||
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
|
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
|
||||||
#define TIMER_INTR_NAME TIMER4_COMPA_vect
|
#define TIMER_INTR_NAME TIMER4_COMPA_vect
|
||||||
#define TIMER_CONFIG_KHZ(val) ({ \
|
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||||
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
||||||
TCCR4A = _BV(WGM41); \
|
TCCR4A = _BV(WGM41); \
|
||||||
TCCR4B = _BV(WGM43) | _BV(CS40); \
|
TCCR4B = _BV(WGM43) | _BV(CS40); \
|
||||||
ICR4 = pwmval; \
|
ICR4 = pwmval; \
|
||||||
OCR4A = pwmval / 3; \
|
OCR4A = pwmval / 3; \
|
||||||
})
|
})
|
||||||
#define TIMER_CONFIG_NORMAL() ({ \
|
#define TIMER_CONFIG_NORMAL() ({ \
|
||||||
TCCR4A = 0; \
|
TCCR4A = 0; \
|
||||||
TCCR4B = _BV(WGM42) | _BV(CS40); \
|
TCCR4B = _BV(WGM42) | _BV(CS40); \
|
||||||
OCR4A = SYSCLOCK * USECPERTICK / 1000000; \
|
OCR4A = SYSCLOCK * USECPERTICK / 1000000; \
|
||||||
TCNT4 = 0; \
|
TCNT4 = 0; \
|
||||||
})
|
})
|
||||||
#if defined(CORE_OC4A_PIN)
|
#if defined(CORE_OC4A_PIN)
|
||||||
#define TIMER_PWM_PIN CORE_OC4A_PIN
|
#define TIMER_PWM_PIN CORE_OC4A_PIN
|
||||||
#elif defined(__AVR_ATmega1280__)
|
#elif defined(__AVR_ATmega1280__)
|
||||||
#define TIMER_PWM_PIN 6 /* Arduino Mega */
|
#define TIMER_PWM_PIN 6 /* Arduino Mega */
|
||||||
#else
|
#else
|
||||||
#error "Please add OC4A pin number here\n"
|
#error "Please add OC4A pin number here\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// defines for timer5 (16 bits)
|
// defines for timer5 (16 bits)
|
||||||
#elif defined(IR_USE_TIMER5)
|
#elif defined(IR_USE_TIMER5)
|
||||||
#define TIMER_RESET
|
#define TIMER_RESET
|
||||||
#define TIMER_ENABLE_PWM (TCCR5A |= _BV(COM5A1))
|
#define TIMER_ENABLE_PWM (TCCR5A |= _BV(COM5A1))
|
||||||
#define TIMER_DISABLE_PWM (TCCR5A &= ~(_BV(COM5A1)))
|
#define TIMER_DISABLE_PWM (TCCR5A &= ~(_BV(COM5A1)))
|
||||||
#define TIMER_ENABLE_INTR (TIMSK5 = _BV(OCIE5A))
|
#define TIMER_ENABLE_INTR (TIMSK5 = _BV(OCIE5A))
|
||||||
#define TIMER_DISABLE_INTR (TIMSK5 = 0)
|
#define TIMER_DISABLE_INTR (TIMSK5 = 0)
|
||||||
#define TIMER_INTR_NAME TIMER5_COMPA_vect
|
#define TIMER_INTR_NAME TIMER5_COMPA_vect
|
||||||
#define TIMER_CONFIG_KHZ(val) ({ \
|
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||||
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
|
||||||
TCCR5A = _BV(WGM51); \
|
TCCR5A = _BV(WGM51); \
|
||||||
TCCR5B = _BV(WGM53) | _BV(CS50); \
|
TCCR5B = _BV(WGM53) | _BV(CS50); \
|
||||||
ICR5 = pwmval; \
|
ICR5 = pwmval; \
|
||||||
OCR5A = pwmval / 3; \
|
OCR5A = pwmval / 3; \
|
||||||
})
|
})
|
||||||
#define TIMER_CONFIG_NORMAL() ({ \
|
#define TIMER_CONFIG_NORMAL() ({ \
|
||||||
TCCR5A = 0; \
|
TCCR5A = 0; \
|
||||||
TCCR5B = _BV(WGM52) | _BV(CS50); \
|
TCCR5B = _BV(WGM52) | _BV(CS50); \
|
||||||
OCR5A = SYSCLOCK * USECPERTICK / 1000000; \
|
OCR5A = SYSCLOCK * USECPERTICK / 1000000; \
|
||||||
TCNT5 = 0; \
|
TCNT5 = 0; \
|
||||||
})
|
})
|
||||||
#if defined(CORE_OC5A_PIN)
|
#if defined(CORE_OC5A_PIN)
|
||||||
#define TIMER_PWM_PIN CORE_OC5A_PIN
|
#define TIMER_PWM_PIN CORE_OC5A_PIN
|
||||||
#elif defined(__AVR_ATmega1280__)
|
#elif defined(__AVR_ATmega1280__)
|
||||||
#define TIMER_PWM_PIN 46 /* Arduino Mega */
|
#define TIMER_PWM_PIN 46 /* Arduino Mega */
|
||||||
#else
|
#else
|
||||||
#error "Please add OC5A pin number here\n"
|
#error "Please add OC5A pin number here\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#else // unknown timer
|
#else // unknown timer
|
||||||
#error "Internal code configuration error, no known IR_USE_TIMER# defined\n"
|
#error "Internal code configuration error, no known IR_USE_TIMER# defined\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// defines for blinking the LED
|
// defines for blinking the LED
|
||||||
#if defined(CORE_LED0_PIN)
|
#if defined(CORE_LED0_PIN)
|
||||||
#define BLINKLED CORE_LED0_PIN
|
#define BLINKLED CORE_LED0_PIN
|
||||||
#define BLINKLED_ON() (digitalWrite(CORE_LED0_PIN, HIGH))
|
#define BLINKLED_ON() (digitalWrite(CORE_LED0_PIN, HIGH))
|
||||||
#define BLINKLED_OFF() (digitalWrite(CORE_LED0_PIN, LOW))
|
#define BLINKLED_OFF() (digitalWrite(CORE_LED0_PIN, LOW))
|
||||||
#elif defined(__AVR_ATmega1280__)
|
#elif defined(__AVR_ATmega1280__)
|
||||||
#define BLINKLED 13
|
#define BLINKLED 13
|
||||||
#define BLINKLED_ON() (PORTB |= B10000000)
|
#define BLINKLED_ON() (PORTB |= B10000000)
|
||||||
#define BLINKLED_OFF() (PORTB &= B01111111)
|
#define BLINKLED_OFF() (PORTB &= B01111111)
|
||||||
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
||||||
#define BLINKLED 0
|
#define BLINKLED 0
|
||||||
#define BLINKLED_ON() (PORTD |= B00000001)
|
#define BLINKLED_ON() (PORTD |= B00000001)
|
||||||
#define BLINKLED_OFF() (PORTD &= B11111110)
|
#define BLINKLED_OFF() (PORTD &= B11111110)
|
||||||
#else
|
#else
|
||||||
#define BLINKLED 13
|
#define BLINKLED 13
|
||||||
#define BLINKLED_ON() (PORTB |= B00100000)
|
#define BLINKLED_ON() (PORTB |= B00100000)
|
||||||
#define BLINKLED_OFF() (PORTB &= B11011111)
|
#define BLINKLED_OFF() (PORTB &= B11011111)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
//Variables
|
//Variables
|
||||||
boolean error;
|
boolean error;
|
||||||
|
boolean OOF; // OutOfReach
|
||||||
|
|
||||||
void RL3 (int i, Data *DataLine)
|
void RL3 (int i, Data *DataLine)
|
||||||
{
|
{
|
||||||
@@ -72,7 +73,7 @@ float T3 (Data *DataLine)
|
|||||||
|
|
||||||
void setleg (int i, Data *DataLine)
|
void setleg (int i, Data *DataLine)
|
||||||
{
|
{
|
||||||
Segment Seg;
|
//Segment Seg;
|
||||||
|
|
||||||
if (i < 3)
|
if (i < 3)
|
||||||
{
|
{
|
||||||
@@ -90,8 +91,8 @@ void setleg (int i, Data *DataLine)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error = true;
|
OOF = true;
|
||||||
Seg.sevenSegWrite('e');
|
//Seg.sevenSegWrite('e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -110,18 +111,19 @@ void setleg (int i, Data *DataLine)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error = true;
|
OOF = true;
|
||||||
Seg.sevenSegWrite('e');
|
//Seg.sevenSegWrite('e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InverseKinemetics::IK(Data *DataLine)
|
void InverseKinemetics::IK(Data *DataLine)
|
||||||
{
|
{
|
||||||
Segment Seg;
|
//Segment Seg;
|
||||||
Seg.sevenSegWrite('o');
|
//Seg.sevenSegWrite('o');
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
|
OOF = false;
|
||||||
|
|
||||||
for (int i=0; i<6; i++)
|
for (int i=0; i<6; i++)
|
||||||
setleg(i, DataLine);
|
setleg(i, DataLine);
|
||||||
@@ -132,7 +134,7 @@ void InverseKinemetics::IK(Data *DataLine)
|
|||||||
if (i != 0)
|
if (i != 0)
|
||||||
Serial.print(", ");
|
Serial.print(", ");
|
||||||
else
|
else
|
||||||
Serial.print("### InverseKinemetics->ServosPosition's are: ");
|
Serial.print("### InverseKinemetics->ServoData[" + i + "]: ");
|
||||||
|
|
||||||
Serial.print(DataLine->ServoData[i].x);
|
Serial.print(DataLine->ServoData[i].x);
|
||||||
Serial.print(", ");
|
Serial.print(", ");
|
||||||
|
|||||||
@@ -1,84 +1,84 @@
|
|||||||
// 7Segment
|
// 7Segment
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Segment.h"
|
#include "Segment.h"
|
||||||
|
|
||||||
byte seven_seg_digits[][8] = {
|
byte seven_seg_digits[][8] = {
|
||||||
{ 0,1,1,1,1,1,0,1 }, // = 0
|
{ 0,1,1,1,1,1,0,1 }, // = 0
|
||||||
{ 0,1,1,0,0,0,0,0 }, // = 1
|
{ 0,1,1,0,0,0,0,0 }, // = 1
|
||||||
{ 0,0,1,1,1,1,1,0 }, // = 2
|
{ 0,0,1,1,1,1,1,0 }, // = 2
|
||||||
{ 0,1,1,1,1,0,1,0 }, // = 3
|
{ 0,1,1,1,1,0,1,0 }, // = 3
|
||||||
{ 0,1,1,0,0,0,1,1 }, // = 4
|
{ 0,1,1,0,0,0,1,1 }, // = 4
|
||||||
{ 0,1,0,1,1,0,1,1 }, // = 5
|
{ 0,1,0,1,1,0,1,1 }, // = 5
|
||||||
{ 0,1,0,1,1,1,1,1 }, // = 6
|
{ 0,1,0,1,1,1,1,1 }, // = 6
|
||||||
{ 0,1,1,1,0,0,0,0 }, // = 7
|
{ 0,1,1,1,0,0,0,0 }, // = 7
|
||||||
{ 0,1,1,1,1,1,1,1 }, // = 8
|
{ 0,1,1,1,1,1,1,1 }, // = 8
|
||||||
{ 0,1,1,1,1,0,1,1 }, // = 9
|
{ 0,1,1,1,1,0,1,1 }, // = 9
|
||||||
{ 1,1,1,1,0,1,1,1 }, // = A
|
{ 1,1,1,1,0,1,1,1 }, // = A
|
||||||
{ 1,1,0,0,1,1,1,1 }, // = B
|
{ 1,1,0,0,1,1,1,1 }, // = B
|
||||||
{ 1,0,0,1,1,1,0,1 }, // = C
|
{ 1,0,0,1,1,1,0,1 }, // = C
|
||||||
{ 1,1,0,0,1,1,1,1 }, // = D
|
{ 1,1,0,0,1,1,1,1 }, // = D
|
||||||
{ 1,0,0,1,1,1,1,1 }, // = E
|
{ 1,0,0,1,1,1,1,1 }, // = E
|
||||||
{ 1,0,0,1,0,1,1,1 }, // = F
|
{ 1,0,0,1,0,1,1,1 }, // = F
|
||||||
{ 1,1,0,1,1,0,1,1 }, // = S
|
{ 1,1,0,1,1,0,1,1 }, // = S
|
||||||
{ 0,0,0,0,0,0,0,0 }, // = NULL
|
{ 0,0,0,0,0,0,0,0 }, // = NULL
|
||||||
{ 1,0,0,1,0,1,0,1 } // = R
|
{ 1,0,0,1,0,1,0,1 } // = R
|
||||||
};
|
};
|
||||||
|
|
||||||
Segment::Segment() {
|
Segment::Segment() {
|
||||||
for (int i=0; i<8; i++)
|
for (int i=0; i<8; i++)
|
||||||
pinMode(6+i, OUTPUT);
|
pinMode(6+i, OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void Segment::sevenSegWrite(byte digit) {
|
/*void Segment::sevenSegWrite(byte digit) {
|
||||||
byte pin = 6;
|
byte pin = 6;
|
||||||
for (byte segCount = 0; segCount < 8; ++segCount) {
|
for (byte segCount = 0; segCount < 8; ++segCount) {
|
||||||
digitalWrite(pin, !seven_seg_digits[digit][segCount]);
|
digitalWrite(pin, !seven_seg_digits[digit][segCount]);
|
||||||
++pin;
|
++pin;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void Segment::sevenSegWrite(char chr) {
|
void Segment::sevenSegWrite(char chr) {
|
||||||
byte pin = 6;
|
byte pin = 6;
|
||||||
byte digit;
|
byte digit;
|
||||||
if(chr <= 9) digit = chr;
|
if(chr <= 9) digit = chr;
|
||||||
else if (chr <= 'f') digit = 10 + (chr -'a');
|
else if (chr <= 'f') digit = 10 + (chr -'a');
|
||||||
else if (chr == 's') digit = 16;
|
else if (chr == 's') digit = 16;
|
||||||
else if (chr == 'r') digit = 18;
|
else if (chr == 'r') digit = 18;
|
||||||
else digit = Cls;
|
else digit = Cls;
|
||||||
for (byte segCount = 0; segCount < 8; ++segCount) {
|
for (byte segCount = 0; segCount < 8; ++segCount) {
|
||||||
digitalWrite(pin, !seven_seg_digits[digit][segCount]);
|
digitalWrite(pin, !seven_seg_digits[digit][segCount]);
|
||||||
++pin;
|
++pin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void Segment::BlinksevenSegWrite(byte digit) {
|
/*void Segment::BlinksevenSegWrite(byte digit) {
|
||||||
byte pin = 6;
|
byte pin = 6;
|
||||||
for (byte segCount = 0; segCount < 8; ++segCount) {
|
for (byte segCount = 0; segCount < 8; ++segCount) {
|
||||||
digitalWrite(pin, !seven_seg_digits[digit][segCount]);
|
digitalWrite(pin, !seven_seg_digits[digit][segCount]);
|
||||||
++pin;
|
++pin;
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
sevenSegWrite((byte)17);
|
sevenSegWrite((byte)17);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void Segment::BlinksevenSegWrite(char chr) {
|
void Segment::BlinksevenSegWrite(char chr) {
|
||||||
byte pin = 6;
|
byte pin = 6;
|
||||||
byte digit;
|
byte digit;
|
||||||
if(chr <= 9) digit = chr;
|
if(chr <= 9) digit = chr;
|
||||||
else if (chr <= 'f') digit = 10 + (chr -'a');
|
else if (chr <= 'f') digit = 10 + (chr -'a');
|
||||||
else if (chr == 's') digit = 16;
|
else if (chr == 's') digit = 16;
|
||||||
else digit = Cls;
|
else digit = Cls;
|
||||||
for (byte segCount = 0; segCount < 8; ++segCount) {
|
for (byte segCount = 0; segCount < 8; ++segCount) {
|
||||||
digitalWrite(pin, !seven_seg_digits[digit][segCount]);
|
digitalWrite(pin, !seven_seg_digits[digit][segCount]);
|
||||||
++pin;
|
++pin;
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
sevenSegWrite(Cls);
|
sevenSegWrite(Cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
// 7 Segment driver.
|
// 7 Segment driver.
|
||||||
|
|
||||||
#ifndef SEGMENT_H
|
#ifndef SEGMENT_H
|
||||||
#define SEGMENT_H
|
#define SEGMENT_H
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#define Cls 17
|
#define Cls 17
|
||||||
|
|
||||||
class Segment
|
class Segment
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Segment();
|
Segment();
|
||||||
//void sevenSegWrite(byte digit);
|
//void sevenSegWrite(byte digit);
|
||||||
void sevenSegWrite(char chr);
|
void sevenSegWrite(char chr);
|
||||||
//void BlinksevenSegWrite(byte digit);
|
//void BlinksevenSegWrite(byte digit);
|
||||||
void BlinksevenSegWrite(char chr);
|
void BlinksevenSegWrite(char chr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||||||
#ifndef TinyGPS_h
|
#ifndef TinyGPS_h
|
||||||
#define TinyGPS_h
|
#define TinyGPS_h
|
||||||
|
|
||||||
#if defined(ARDUINO) && ARDUINO >= 100
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#else
|
#else
|
||||||
#include "WProgram.h"
|
#include "WProgram.h"
|
||||||
|
|||||||
@@ -1,190 +1,190 @@
|
|||||||
#ifndef WiiChuck_h
|
#ifndef WiiChuck_h
|
||||||
#define WiiChuck_h
|
#define WiiChuck_h
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
|
|
||||||
// these may need to be adjusted for each nunchuck for calibration
|
// these may need to be adjusted for each nunchuck for calibration
|
||||||
#define ZEROX 510
|
#define ZEROX 510
|
||||||
#define ZEROY 490
|
#define ZEROY 490
|
||||||
#define ZEROZ 460
|
#define ZEROZ 460
|
||||||
#define RADIUS 210 // probably pretty universal
|
#define RADIUS 210 // probably pretty universal
|
||||||
|
|
||||||
#define DEFAULT_ZERO_JOY_X 124
|
#define DEFAULT_ZERO_JOY_X 124
|
||||||
#define DEFAULT_ZERO_JOY_Y 132
|
#define DEFAULT_ZERO_JOY_Y 132
|
||||||
|
|
||||||
#define MAXANGLE 90
|
#define MAXANGLE 90
|
||||||
#define MINANGLE -90
|
#define MINANGLE -90
|
||||||
|
|
||||||
class WiiChuck {
|
class WiiChuck {
|
||||||
private:
|
private:
|
||||||
byte cnt;
|
byte cnt;
|
||||||
uint8_t status[6]; // array to store wiichuck output
|
uint8_t status[6]; // array to store wiichuck output
|
||||||
byte averageCounter;
|
byte averageCounter;
|
||||||
int i;
|
int i;
|
||||||
int total;
|
int total;
|
||||||
uint8_t zeroJoyX; // these are about where mine are
|
uint8_t zeroJoyX; // these are about where mine are
|
||||||
uint8_t zeroJoyY; // use calibrateJoy when the stick is at zero to correct
|
uint8_t zeroJoyY; // use calibrateJoy when the stick is at zero to correct
|
||||||
int lastJoyX;
|
int lastJoyX;
|
||||||
int lastJoyY;
|
int lastJoyY;
|
||||||
int angles[3];
|
int angles[3];
|
||||||
|
|
||||||
boolean lastZ, lastC;
|
boolean lastZ, lastC;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
byte joyX;
|
byte joyX;
|
||||||
byte joyY;
|
byte joyY;
|
||||||
boolean buttonZ;
|
boolean buttonZ;
|
||||||
boolean buttonC;
|
boolean buttonC;
|
||||||
boolean plugd;
|
boolean plugd;
|
||||||
void begin()
|
void begin()
|
||||||
{
|
{
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
averageCounter = 0;
|
averageCounter = 0;
|
||||||
Wire.beginTransmission (0x52); // transmit to device 0x52
|
Wire.beginTransmission (0x52); // transmit to device 0x52
|
||||||
Wire.write((byte)0x40); // sends memory address
|
Wire.write((byte)0x40); // sends memory address
|
||||||
Wire.write((byte)0x00); // sends memory address
|
Wire.write((byte)0x00); // sends memory address
|
||||||
Wire.endTransmission (); // stop transmitting
|
Wire.endTransmission (); // stop transmitting
|
||||||
update();
|
update();
|
||||||
for (i = 0; i<3;i++) {
|
for (i = 0; i<3;i++) {
|
||||||
angles[i] = 0;
|
angles[i] = 0;
|
||||||
}
|
}
|
||||||
zeroJoyX = DEFAULT_ZERO_JOY_X;
|
zeroJoyX = DEFAULT_ZERO_JOY_X;
|
||||||
zeroJoyY = DEFAULT_ZERO_JOY_Y;
|
zeroJoyY = DEFAULT_ZERO_JOY_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void calibrateJoy() {
|
void calibrateJoy() {
|
||||||
zeroJoyX = joyX;
|
zeroJoyX = joyX;
|
||||||
zeroJoyY = joyY;
|
zeroJoyY = joyY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckifPlugd()
|
void CheckifPlugd()
|
||||||
{
|
{
|
||||||
if (this->plugd == false){
|
if (this->plugd == false){
|
||||||
this->begin();
|
this->begin();
|
||||||
|
|
||||||
#ifdef GLCD
|
#ifdef GLCD
|
||||||
GLCD.CursorTo(1, 1);
|
GLCD.CursorTo(1, 1);
|
||||||
GLCD.print("No Chuck");
|
GLCD.print("No Chuck");
|
||||||
delay(100);
|
delay(100);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->begin();
|
this->begin();
|
||||||
if (this->plugd)
|
if (this->plugd)
|
||||||
this->calibrateJoy();
|
this->calibrateJoy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
|
|
||||||
Wire.requestFrom (0x52, 6); // request data from nunchuck
|
Wire.requestFrom (0x52, 6); // request data from nunchuck
|
||||||
while (Wire.available ()) {
|
while (Wire.available ()) {
|
||||||
// receive byte as an integer
|
// receive byte as an integer
|
||||||
status[cnt] = _nunchuk_decode_byte((byte)Wire.read()); //
|
status[cnt] = _nunchuk_decode_byte((byte)Wire.read()); //
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
if (cnt > 5) {
|
if (cnt > 5) {
|
||||||
lastZ = buttonZ;
|
lastZ = buttonZ;
|
||||||
lastC = buttonC;
|
lastC = buttonC;
|
||||||
lastJoyX = readJoyX();
|
lastJoyX = readJoyX();
|
||||||
lastJoyY = readJoyY();
|
lastJoyY = readJoyY();
|
||||||
|
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
joyX = (status[0]);
|
joyX = (status[0]);
|
||||||
joyY = (status[1]);
|
joyY = (status[1]);
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
angles[i] = (status[i+2] << 2) + ((status[5] & (B00000011 << ((i+1)*2) ) >> ((i+1)*2)));
|
angles[i] = (status[i+2] << 2) + ((status[5] & (B00000011 << ((i+1)*2) ) >> ((i+1)*2)));
|
||||||
|
|
||||||
buttonZ = !( status[5] & B00000001);
|
buttonZ = !( status[5] & B00000001);
|
||||||
buttonC = !((status[5] & B00000010) >> 1);
|
buttonC = !((status[5] & B00000010) >> 1);
|
||||||
_send_zero(); // send the request for next bytes
|
_send_zero(); // send the request for next bytes
|
||||||
plugd = true;
|
plugd = true;
|
||||||
}
|
}
|
||||||
else if (cnt == 0)
|
else if (cnt == 0)
|
||||||
plugd = false;
|
plugd = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float readAccelX() {
|
float readAccelX() {
|
||||||
return (float)angles[0] - ZEROX;
|
return (float)angles[0] - ZEROX;
|
||||||
}
|
}
|
||||||
float readAccelY() {
|
float readAccelY() {
|
||||||
return (float)angles[1] - ZEROY;
|
return (float)angles[1] - ZEROY;
|
||||||
}
|
}
|
||||||
float readAccelZ() {
|
float readAccelZ() {
|
||||||
return (float)angles[2] - ZEROZ;
|
return (float)angles[2] - ZEROZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean zPressed() {
|
boolean zPressed() {
|
||||||
return (buttonZ && ! lastZ);
|
return (buttonZ && ! lastZ);
|
||||||
}
|
}
|
||||||
boolean cPressed() {
|
boolean cPressed() {
|
||||||
return (buttonC && ! lastC);
|
return (buttonC && ! lastC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for using the joystick like a directional button
|
// for using the joystick like a directional button
|
||||||
boolean rightJoy(int thresh=60) {
|
boolean rightJoy(int thresh=60) {
|
||||||
return (readJoyX() > thresh and lastJoyX <= thresh);
|
return (readJoyX() > thresh and lastJoyX <= thresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for using the joystick like a directional button
|
// for using the joystick like a directional button
|
||||||
boolean leftJoy(int thresh=60) {
|
boolean leftJoy(int thresh=60) {
|
||||||
return (readJoyX() < -thresh and lastJoyX >= -thresh);
|
return (readJoyX() < -thresh and lastJoyX >= -thresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int readJoyX() {
|
int readJoyX() {
|
||||||
return (int) joyX - zeroJoyX;
|
return (int) joyX - zeroJoyX;
|
||||||
}
|
}
|
||||||
|
|
||||||
int readJoyY() {
|
int readJoyY() {
|
||||||
return (int)joyY - zeroJoyY;
|
return (int)joyY - zeroJoyY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// R, the radius, generally hovers around 210 (at least it does with mine)
|
// R, the radius, generally hovers around 210 (at least it does with mine)
|
||||||
int R() {
|
int R() {
|
||||||
return sqrt(readAccelX() * readAccelX() +readAccelY() * readAccelY() + readAccelZ() * readAccelZ());
|
return sqrt(readAccelX() * readAccelX() +readAccelY() * readAccelY() + readAccelZ() * readAccelZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns roll degrees
|
// returns roll degrees
|
||||||
int readRoll() {
|
int readRoll() {
|
||||||
return (int)(atan2(readAccelX(),readAccelZ())/ M_PI * 180.0);
|
return (int)(atan2(readAccelX(),readAccelZ())/ M_PI * 180.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns pitch in degrees
|
// returns pitch in degrees
|
||||||
int readPitch() {
|
int readPitch() {
|
||||||
return (int) (acos(readAccelY()/RADIUS)/ M_PI * 180.0); // optionally swap 'RADIUS' for 'R()'
|
return (int) (acos(readAccelY()/RADIUS)/ M_PI * 180.0); // optionally swap 'RADIUS' for 'R()'
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
byte _nunchuk_decode_byte (byte x)
|
byte _nunchuk_decode_byte (byte x)
|
||||||
{
|
{
|
||||||
x = (x ^ 0x17) + 0x17;
|
x = (x ^ 0x17) + 0x17;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _send_zero()
|
void _send_zero()
|
||||||
{
|
{
|
||||||
Wire.beginTransmission (0x52); // transmit to device 0x52
|
Wire.beginTransmission (0x52); // transmit to device 0x52
|
||||||
Wire.write ((byte)0x00); // sends one byte
|
Wire.write ((byte)0x00); // sends one byte
|
||||||
Wire.endTransmission (); // stop transmitting
|
Wire.endTransmission (); // stop transmitting
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,62 +1,62 @@
|
|||||||
class gedrag{
|
class gedrag{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
data_line PositieInformatie;
|
data_line PositieInformatie;
|
||||||
body_struct main_positie;
|
body_struct main_positie;
|
||||||
int HuidigePositieinProgramma;
|
int HuidigePositieinProgramma;
|
||||||
int matrix[..] MatrixmetdeGedragPatroonen;
|
int matrix[..] MatrixmetdeGedragPatroonen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
run()
|
run()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
run normaal gedrag patroon.
|
run normaal gedrag patroon.
|
||||||
|
|
||||||
[loop patroon dat niet word beinvloed door userinput]
|
[loop patroon dat niet word beinvloed door userinput]
|
||||||
vraag aankomende gedrag op uit matrix,
|
vraag aankomende gedrag op uit matrix,
|
||||||
-bereken de nieuwe posities
|
-bereken de nieuwe posities
|
||||||
--sla deze op in cache
|
--sla deze op in cache
|
||||||
---wacht tot de watchdog een timeout geeft
|
---wacht tot de watchdog een timeout geeft
|
||||||
----geef de cache door aan de servo controller.
|
----geef de cache door aan de servo controller.
|
||||||
|
|
||||||
[loop patroon dat WORD beinvloed door userinput]
|
[loop patroon dat WORD beinvloed door userinput]
|
||||||
vraag aankomende gedrag op uit matrix met userinput,
|
vraag aankomende gedrag op uit matrix met userinput,
|
||||||
-bereken de nieuwe posities
|
-bereken de nieuwe posities
|
||||||
--sla deze op in cache
|
--sla deze op in cache
|
||||||
---loop tot de watchdog een timeout geeft
|
---loop tot de watchdog een timeout geeft
|
||||||
----geef de cache door aan de servo controller.
|
----geef de cache door aan de servo controller.
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
quite()
|
quite()
|
||||||
{
|
{
|
||||||
while()
|
while()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
maak routine af om terug te gaan naar de main positie.
|
maak routine af om terug te gaan naar de main positie.
|
||||||
daarna return 0;
|
daarna return 0;
|
||||||
|
|
||||||
verplaats de body in een neutrale positie
|
verplaats de body in een neutrale positie
|
||||||
+als niet mogeleijk verplaats de poten die problemen geven
|
+als niet mogeleijk verplaats de poten die problemen geven
|
||||||
-mogelijk ga verder met de poten een voor een in de goode positie te zetten
|
-mogelijk ga verder met de poten een voor een in de goode positie te zetten
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exit()
|
exit()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
NOOD, stop nu en return positie;
|
NOOD, stop nu en return positie;
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
userinput()
|
userinput()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Mogelijkheid tot user input.
|
Mogelijkheid tot user input.
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
//Addons
|
//Addons
|
||||||
#include "Segment.h"
|
#include "Segment.h"
|
||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "TinyGPS.h"
|
//#include "TinyGPS.h"
|
||||||
//#include "WiiChuck.h"
|
//#include "WiiChuck.h"
|
||||||
//#include "Wire.h"
|
//#include "Wire.h"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user