[136] | 1 | /******************************************************************
|
---|
| 2 | * EasyTransfer Arduino Library
|
---|
| 3 | * details and example sketch:
|
---|
| 4 | * http://www.billporter.info/easytransfer-arduino-library/
|
---|
| 5 | *
|
---|
| 6 | * Brought to you by:
|
---|
| 7 | * Bill Porter
|
---|
| 8 | * www.billporter.info
|
---|
| 9 | *
|
---|
| 10 | * See Readme for other info and version history
|
---|
| 11 | *
|
---|
| 12 | *
|
---|
| 13 | *This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
|
---|
| 14 | This program is distributed in the hope that it will be useful,
|
---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 17 | GNU General Public License for more details.
|
---|
| 18 | <http://www.gnu.org/licenses/>
|
---|
| 19 | *
|
---|
| 20 | *This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
---|
| 21 | *To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or
|
---|
| 22 | *send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
|
---|
| 23 | ******************************************************************/
|
---|
| 24 | #ifndef EasyTransfer2_h
|
---|
| 25 | #define EasyTransfer2_h
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | //make it a little prettier on the front end.
|
---|
| 29 | #define details(name) (byte*)&name,sizeof(name)
|
---|
| 30 |
|
---|
| 31 | //Not neccessary, but just in case.
|
---|
| 32 | #if ARDUINO > 22
|
---|
| 33 | #include "Arduino.h"
|
---|
| 34 | #else
|
---|
| 35 | #include "WProgram.h"
|
---|
| 36 | #endif
|
---|
| 37 | #include "HardwareSerial.h"
|
---|
| 38 | //#include <NewSoftSerial.h>
|
---|
| 39 | #include <math.h>
|
---|
| 40 | #include <stdio.h>
|
---|
| 41 | #include <stdint.h>
|
---|
| 42 | #include <avr/io.h>
|
---|
| 43 |
|
---|
| 44 | class EasyTransfer2 {
|
---|
| 45 | public:
|
---|
| 46 | void begin(HardwareSerial *theSerial);
|
---|
| 47 | //void begin(uint8_t *, uint8_t, NewSoftSerial *theSerial);
|
---|
| 48 | void sendData();
|
---|
| 49 | boolean receiveData();
|
---|
| 50 |
|
---|
| 51 | void writeByte(uint8_t dat);
|
---|
| 52 | void writeInt(int dat);
|
---|
| 53 | uint8_t readByte();
|
---|
| 54 | int readInt();
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | private:
|
---|
| 58 | HardwareSerial *_serial;
|
---|
| 59 |
|
---|
| 60 | void resetData();
|
---|
| 61 |
|
---|
| 62 | uint8_t data[20]; //data storage, for both read and send
|
---|
| 63 | uint8_t position;
|
---|
| 64 | uint8_t size; //size of data in bytes. Both for read and send
|
---|
| 65 | //uint8_t * address; //address of struct
|
---|
| 66 | //uint8_t size; //size of struct
|
---|
| 67 | //uint8_t * rx_buffer; //address for temporary storage and parsing buffer
|
---|
| 68 | //uint8_t rx_buffer[20];
|
---|
| 69 | uint8_t rx_array_inx; //index for RX parsing buffer
|
---|
| 70 | uint8_t rx_len; //RX packet length according to the packet
|
---|
| 71 | uint8_t calc_CS; //calculated Chacksum
|
---|
| 72 | };
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | #endif
|
---|