SODA Arudino library
SODA.h
Go to the documentation of this file.
1 
22 //The output filename can be changed by changing the character string below
23 #ifndef FILENAME
24 #define FILENAME "DATA.CSV"
25 #endif
26 //Note that the SD functions can be removed by uncommenting the line below:
27 //#define NO_SD
28 #ifndef __SODA__h
29 #define __SODA__h
30 #include <Arduino.h>
31 #include <Wire.h>
32 //clock values
33 #define CLOCK_I2C_ADDR 0x68
34 #define CLOCK_CONTROL_ADDR 0x0E
35 #define CLOCK_TEMPERATURE_ADDR 0x11
36 #define CLOCK_TIME_CAL_ADDR 0x00
37 #define CLOCK_SETUP 0x5 //allow interrupts on alarm1
38 #define CLOCK_ALARM1_ADDR 0x07
39 #define CLOCK_ALARM_STATUS 0x0F
40 //ADC values
41 #define ADC_I2C_ADDR 0x6E
42 #define ADC_CONTROL 0x00
43 #define ADC_BASE 0x80 //one shot conversion model
44 #define ADC_CH1 0x00
45 #define ADC_CH2 0x20
46 #define ADC_CH3 0x40
47 #define ADC_CH4 0x60
48 #define ADC_18BITS 0x0C
49 #define ADC_16BITS 0x08
50 #define ADC_14BITS 0x04
51 #define ADC_12BITS 0x00
52 #define ADC_GAIN1 0x00
53 #define ADC_GAIN2 0x01
54 #define ADC_GAIN4 0x02
55 #define ADC_GAIN8 0x03
56 //MISC Values
57 #define LEDPIN 13 // LED connected to digital pin 13
58 #endif
59 
63 class SODA
64 {
65  private:
66  void setAddress(uint8_t,uint8_t,uint8_t);
67  unsigned char getAddress(uint8_t,uint8_t);
68  int dectobcd(int val);
69  int bcdtodec(int val);
70  void runSD(int);
71  void parseCommand(char);
72  void testForConnection();
73  void incrementName(char* inChar, int newVal, int nameLength = 4);
74  unsigned char standby;
75  //variables
76  // static char buffer[];
77  // static int timeArray[];
78  public:
82  void begin();
84  //@I Clock Functions
92  void updateTime(int val,int place);
99  int checkTime(int place);
106  void setTime();
112  void getTime();
118  void bufferTime();
125  void serialSetTime();
130  float getClockTemp();
138  void setWake(int val,int valType);
143  void turnOff();
149  void setStandby(unsigned char val);
155  int getStandby();
157  //@I ADC Functions
166  long adcRead(int ch, int bit, int gain);
172  int tcReadK(int ch);
178  int smoothAnalogRead(int pin1);
180  //@I Data output functions
196  void dataLineBegin(boolean binary = false, boolean set_end_on_connect = false, boolean set_single_file = true, int sd_cs_pin = 17);
203  void dataLineAdd(int value);
210  void dataLineAdd(long value);
217  void dataLineAdd(float value);
224  void dataLineAddBytes(const void* buffer, int nbytes);
230  void dataLineEnd();
238  void dataDownload();
240  //@I communication functions
258  void communicate();
260  //@I misc function
265  void setID(long ID);
270  long getID();
274  void printBuffer();
279  bool usbConnected();
284  void blinks(int n);
285 };
286 
287 
void communicate()
Definition: SODA.cpp:549
void dataLineBegin(boolean binary=false, boolean set_end_on_connect=false, boolean set_single_file=true, int sd_cs_pin=17)
Definition: SODA.cpp:390
void getTime()
Definition: SODA.cpp:100
int getStandby()
Definition: SODA.cpp:286
void setTime()
Definition: SODA.cpp:70
long getID()
Definition: SODA.cpp:617
int checkTime(int place)
Definition: SODA.cpp:188
void begin()
Definition: SODA.cpp:19
void printBuffer()
Definition: SODA.cpp:61
void dataLineAddBytes(const void *buffer, int nbytes)
Definition: SODA.cpp:494
void dataLineAdd(int value)
Definition: SODA.cpp:452
void setWake(int val, int valType)
Definition: SODA.cpp:214
int tcReadK(int ch)
Definition: SODA.cpp:340
void setID(long ID)
Definition: SODA.cpp:610
char buffer[30]
Definition: SODA.cpp:10
Definition: SODA.h:63
void setStandby(unsigned char val)
Definition: SODA.cpp:267
void dataDownload()
Definition: SODA.cpp:521
void serialSetTime()
Definition: SODA.cpp:160
void turnOff()
Definition: SODA.cpp:257
int smoothAnalogRead(int pin1)
Definition: SODA.cpp:372
long adcRead(int ch, int bit, int gain)
Definition: SODA.cpp:297
bool usbConnected()
Definition: SODA.cpp:626
float getClockTemp()
Definition: SODA.cpp:194
void bufferTime()
Definition: SODA.cpp:133
void updateTime(int val, int place)
Definition: SODA.cpp:182
void blinks(int n)
Definition: SODA.cpp:631
void dataLineEnd()
Definition: SODA.cpp:506