80 Serial.println(
"Connection to device failed :(");
84 Serial.println(
"Connection to device succeeded!");
100 Serial.println(user_command);
103 switch (user_command)
130 Serial.println(F(
"Invalid option"));
137 Serial.println(F(
"*****************************************************************"));
138 Serial.println(F(
"* EVAL-7420SDZ Demonstration Program *"));
139 Serial.println(F(
"* *"));
140 Serial.println(F(
"* This program demonstrates communication with the ADT7420 *"));
141 Serial.println(F(
"* high accuracy digital temperature sensor *"));
142 Serial.println(F(
"* *"));
143 Serial.println(F(
"* Set the baud rate to 115200 select the newline terminator. *"));
144 Serial.println(F(
"*****************************************************************"));
149 Serial.println(F(
"\nCommand Summary:"));
151 Serial.println(F(
" 1- Read temperature"));
152 Serial.println(F(
" 2- Set resolution"));
153 Serial.println(F(
" 3- Set operation mode"));
154 Serial.println(F(
" 4- Poll for a bunch of temperatures"));
155 Serial.println(F(
" X- Get critical temperature setting"));
156 Serial.println(F(
" X- Test & clear Linduino EEPROM"));
159 Serial.print(F(
"Enter a command: "));
164 float temp = adt7420_get_temperature(
device);
166 Serial.print(
"Current temperature: ");
168 Serial.println(F(
" C"));
173 Serial.println(F(
" Available resolutions:"));
174 Serial.println(F(
" 1- 13-bit"));
175 Serial.println(F(
" 2- 16-bit"));
176 Serial.print(F(
" Select an option: "));
179 Serial.println(new_res);
181 new_res = (new_res == 1) ? 0 : 1;
183 adt7420_set_resolution(
device, new_res);
185 Serial.print(F(
"Set resolution to "));
186 Serial.print((13 + 3 * new_res));
187 Serial.println(F(
"-bit"));
197 Serial.println(F(
" Available operation modes:"));
198 Serial.println(F(
" 1- Continuous conversion mode (default)"));
199 Serial.println(F(
" 2- One-shot mode"));
200 Serial.println(F(
" 3- 1 SPS mode"));
201 Serial.println(F(
" 4- Shutdown"));
202 Serial.print(F(
" Select a mode: "));
205 Serial.println(new_mode);
210 adt7420_set_operation_mode(
device, ADT7420_OP_MODE_CONT_CONV);
214 adt7420_set_operation_mode(
device, ADT7420_OP_MODE_ONE_SHOT);
218 adt7420_set_operation_mode(
device, ADT7420_OP_MODE_1_SPS);
222 adt7420_set_operation_mode(
device, ADT7420_OP_MODE_SHUTDOWN);
226 Serial.println(F(
"Invalid option"));
235 Serial.print(F(
" Enter number of desired samples: "));
237 Serial.println(num_samples);
239 Serial.print(F(
" Enter a desired frequency in samples/sec (max 10): "));
241 sample_freq = constrain(sample_freq, 1, 10);
242 Serial.println(sample_freq);
244 uint16_t delay_sec = 1000 / sample_freq;
246 Serial.print(F(
" Gathering "));
247 Serial.print(num_samples / sample_freq);
248 Serial.println(F(
" seconds of samples, press enter to continue"));
254 Serial.print(F(
" #"));
256 Serial.print(F(
":\t"));
258 float temp = adt7420_get_temperature(
device);
259 Serial.println(temp);
268 void temp_to_code(
float temp, uint8_t *msb, uint8_t *lsb, uint8_t resolution)
276 code = (uint16_t)((temp * 128) + 65536);
280 code = (uint16_t)(temp * 128);
287 code = (uint16_t) (temp * 16) + 8192;
291 code = (uint16_t) (temp * 16) + 8192;
297 *msb = (uint8_t)(code >> 8);
298 *lsb = (uint8_t)(code & 255);
unsigned char user_command
Header File for Linduino Libraries and Demo Code.
i2c_init_param i2c_params
static void print_prompt()
volatile int num_samples
Total number of samples that the user desires.
static void temp_to_code(float temp, uint8_t *msb, uint8_t *lsb, uint8_t resolution)
Convert a temperature to the code the sensor understands.
static uint8_t menu_1_read_temperature()
static uint8_t menu_3_set_op_mode()
static void print_title()
adt7420_init_param init_params
static uint8_t menu_4_bunchoftemps()
static uint8_t menu_2_set_resolution()