/* * Snap.hpp * * Created: 10.05.2014 13:28:04 * Author: netz */ #ifndef SNAP_H_ #define SNAP_H_ class Snap { public: static const uint8_t DEVICE = 30; static const uint8_t ALL = 0; static const uint8_t GROUP = 240; static const uint8_t MASTER = 1; static const uint8_t PING = 1; static const uint8_t SLEEP = 2; static const uint8_t ACTIVE = 3; static const uint8_t SETSLEEP = 4; static const uint8_t SETACTIVE = 5; static const uint8_t RUN = 6; static const uint8_t SETRUN = 7; static const uint8_t DEDECT = 8; static const uint8_t SETDEDECT = 9; protected: virtual void hook_turn() = 0; virtual void hook_poll() = 0; virtual void funk_begin() = 0; virtual void funk_end() = 0; virtual uint8_t funk_has_data() = 0; virtual uint8_t funk_get_byte() = 0; virtual void funk_send_packet(uint8_t addr, uint8_t from, uint8_t data) = 0; void wait() { _delay_ms(10); for(uint8_t i=0;iDEVICE;i++) { _delay_ms(5); } } void get_packet(uint8_t data[], uint8_t len){ this->funk_begin(); for (uint8_t i = 0; i < len; i++) { while(this->funk_has_data()) { this->hook_poll(); } data[i] = this->funk_get_byte(); } this->funk_end(); } void send_packet(uint8_t data) { this->funk_send_packet(this->MASTER, this->DEVICE, data); } }; #endif /* SNAP_H_ */