Simple demo for exercising the board
Dependencies: MAX11300 MAX4822 OneWire Terminal ds3231 mbed
main.cpp@6:18a831a757b5, 2016-08-12 (annotated)
- Committer:
- j3
- Date:
- Fri Aug 12 18:44:14 2016 +0000
- Revision:
- 6:18a831a757b5
- Parent:
- 5:2fe6dd435618
- Child:
- 8:8e36fe48b351
updated OW lib
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 0:24b8a6f0a563 | 1 | /********************************************************************** |
j3 | 0:24b8a6f0a563 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
j3 | 0:24b8a6f0a563 | 3 | * |
j3 | 0:24b8a6f0a563 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
j3 | 0:24b8a6f0a563 | 5 | * copy of this software and associated documentation files (the "Software"), |
j3 | 0:24b8a6f0a563 | 6 | * to deal in the Software without restriction, including without limitation |
j3 | 0:24b8a6f0a563 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
j3 | 0:24b8a6f0a563 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
j3 | 0:24b8a6f0a563 | 9 | * Software is furnished to do so, subject to the following conditions: |
j3 | 0:24b8a6f0a563 | 10 | * |
j3 | 0:24b8a6f0a563 | 11 | * The above copyright notice and this permission notice shall be included |
j3 | 0:24b8a6f0a563 | 12 | * in all copies or substantial portions of the Software. |
j3 | 0:24b8a6f0a563 | 13 | * |
j3 | 0:24b8a6f0a563 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
j3 | 0:24b8a6f0a563 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
j3 | 0:24b8a6f0a563 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
j3 | 0:24b8a6f0a563 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
j3 | 0:24b8a6f0a563 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
j3 | 0:24b8a6f0a563 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
j3 | 0:24b8a6f0a563 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
j3 | 0:24b8a6f0a563 | 21 | * |
j3 | 0:24b8a6f0a563 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
j3 | 0:24b8a6f0a563 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
j3 | 0:24b8a6f0a563 | 24 | * Products, Inc. Branding Policy. |
j3 | 0:24b8a6f0a563 | 25 | * |
j3 | 0:24b8a6f0a563 | 26 | * The mere transfer of this software does not imply any licenses |
j3 | 0:24b8a6f0a563 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
j3 | 0:24b8a6f0a563 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
j3 | 0:24b8a6f0a563 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
j3 | 0:24b8a6f0a563 | 30 | * ownership rights. |
j3 | 0:24b8a6f0a563 | 31 | **********************************************************************/ |
j3 | 0:24b8a6f0a563 | 32 | |
j3 | 0:24b8a6f0a563 | 33 | #include "mbed.h" |
j3 | 0:24b8a6f0a563 | 34 | #include "ds3231.h" |
j3 | 0:24b8a6f0a563 | 35 | #include "MAX4822.h" |
j3 | 0:24b8a6f0a563 | 36 | #include "MAX11300.h" |
j3 | 0:24b8a6f0a563 | 37 | #include "Terminal.h" |
j3 | 0:24b8a6f0a563 | 38 | #include "OneWire.h" |
j3 | 0:24b8a6f0a563 | 39 | |
j3 | 0:24b8a6f0a563 | 40 | using namespace OneWire; |
j3 | 0:24b8a6f0a563 | 41 | using namespace RomCommands; |
j3 | 0:24b8a6f0a563 | 42 | |
j3 | 0:24b8a6f0a563 | 43 | void set_rtc(Terminal & term, Ds3231 & rtc); |
j3 | 0:24b8a6f0a563 | 44 | void get_time_date(Terminal & term, Ds3231 & rtc); |
j3 | 0:24b8a6f0a563 | 45 | void search_ow_bus(Terminal & term, DS2484 & owm); |
j3 | 0:24b8a6f0a563 | 46 | void print_rom_id(Terminal & term, RomId & romId); |
j3 | 2:0c0994f70fd2 | 47 | void calibrate_420_io(Terminal & term, MAX11300 & pixi, |
j3 | 2:0c0994f70fd2 | 48 | float & slope_out, float & offset_out, |
j3 | 2:0c0994f70fd2 | 49 | float & slope_in, float & offset_in); |
j3 | 5:2fe6dd435618 | 50 | void DS1920Menu(Terminal & term, const RomId & romId, MultidropRomIterator & selector); |
j3 | 0:24b8a6f0a563 | 51 | |
j3 | 0:24b8a6f0a563 | 52 | int main(void) |
j3 | 0:24b8a6f0a563 | 53 | { |
j3 | 0:24b8a6f0a563 | 54 | Terminal term(USBTX, USBRX); |
j3 | 0:24b8a6f0a563 | 55 | term.baud(57600); |
j3 | 0:24b8a6f0a563 | 56 | term.cls(); |
j3 | 0:24b8a6f0a563 | 57 | term.home(); |
j3 | 0:24b8a6f0a563 | 58 | term.printf("Starting Demo\n"); |
j3 | 0:24b8a6f0a563 | 59 | |
j3 | 0:24b8a6f0a563 | 60 | SPI spi_bus(D11, D12, D13); |
j3 | 0:24b8a6f0a563 | 61 | MAX4822 rly_drvr(spi_bus, D10); |
j3 | 0:24b8a6f0a563 | 62 | DigitalOut rly_drvr_set(D7, 1); |
j3 | 0:24b8a6f0a563 | 63 | DigitalOut rly_drvr_reset(D6, 1); |
j3 | 0:24b8a6f0a563 | 64 | |
j3 | 0:24b8a6f0a563 | 65 | rly_drvr.reset_all_relays(rly_drvr_reset); |
j3 | 0:24b8a6f0a563 | 66 | |
j3 | 1:03c04017a728 | 67 | MAX11300 pixi(spi_bus, D8, NC, D9); |
j3 | 0:24b8a6f0a563 | 68 | |
j3 | 0:24b8a6f0a563 | 69 | //set all analog outs to 0 |
j3 | 0:24b8a6f0a563 | 70 | for(uint8_t idx = 0; idx < 9; idx++) |
j3 | 0:24b8a6f0a563 | 71 | { |
j3 | 0:24b8a6f0a563 | 72 | pixi.single_ended_dac_write(static_cast<MAX11300::MAX11300_Ports>(idx), 0); |
j3 | 0:24b8a6f0a563 | 73 | } |
j3 | 0:24b8a6f0a563 | 74 | |
j3 | 0:24b8a6f0a563 | 75 | //ensure latching relays are reset |
j3 | 0:24b8a6f0a563 | 76 | for(uint8_t idx = 0; idx < 3; idx++) |
j3 | 0:24b8a6f0a563 | 77 | { |
j3 | 0:24b8a6f0a563 | 78 | pixi.gpio_write(static_cast<MAX11300::MAX11300_Ports>(idx + 9), 1); |
j3 | 0:24b8a6f0a563 | 79 | wait_ms(100); |
j3 | 0:24b8a6f0a563 | 80 | pixi.gpio_write(static_cast<MAX11300::MAX11300_Ports>(idx + 9), 0); |
j3 | 0:24b8a6f0a563 | 81 | } |
j3 | 0:24b8a6f0a563 | 82 | |
j3 | 0:24b8a6f0a563 | 83 | I2C i2c_bus(D14, D15); |
j3 | 0:24b8a6f0a563 | 84 | i2c_bus.frequency(400000); |
j3 | 0:24b8a6f0a563 | 85 | |
j3 | 0:24b8a6f0a563 | 86 | Ds3231 rtc(i2c_bus); |
j3 | 0:24b8a6f0a563 | 87 | |
j3 | 0:24b8a6f0a563 | 88 | DS2484 owm(i2c_bus); |
j3 | 0:24b8a6f0a563 | 89 | OneWireMaster::CmdResult owm_result = owm.OWInitMaster(); |
j3 | 0:24b8a6f0a563 | 90 | while(owm_result != OneWireMaster::Success) |
j3 | 0:24b8a6f0a563 | 91 | { |
j3 | 0:24b8a6f0a563 | 92 | wait_ms(100); |
j3 | 0:24b8a6f0a563 | 93 | term.printf("Failed to initialize OneWire master\n"); |
j3 | 0:24b8a6f0a563 | 94 | owm_result = owm.OWInitMaster(); |
j3 | 0:24b8a6f0a563 | 95 | } |
j3 | 0:24b8a6f0a563 | 96 | term.printf("OneWire master initialized\n\n"); |
j3 | 0:24b8a6f0a563 | 97 | |
j3 | 0:24b8a6f0a563 | 98 | int32_t user_entry = 0; |
j3 | 0:24b8a6f0a563 | 99 | int32_t relay = 0; |
j3 | 0:24b8a6f0a563 | 100 | |
j3 | 2:0c0994f70fd2 | 101 | uint16_t analog_out_ch, analog_val; |
j3 | 2:0c0994f70fd2 | 102 | float avo_volts, aio_mA, aii_mA; |
j3 | 0:24b8a6f0a563 | 103 | |
j3 | 2:0c0994f70fd2 | 104 | float aio_slope = 130.0; |
j3 | 2:0c0994f70fd2 | 105 | float aio_offset = -2.0; |
j3 | 2:0c0994f70fd2 | 106 | float aii_slope = 7.71e-3; |
j3 | 2:0c0994f70fd2 | 107 | float aii_offset = 3.86e-3; |
j3 | 2:0c0994f70fd2 | 108 | |
j3 | 2:0c0994f70fd2 | 109 | const int32_t QUIT = 15; |
j3 | 0:24b8a6f0a563 | 110 | |
j3 | 1:03c04017a728 | 111 | MAX11300::CmdResult pixi_result; |
j3 | 1:03c04017a728 | 112 | MAX4822::CmdResult rly_drvr_result; |
j3 | 1:03c04017a728 | 113 | |
j3 | 0:24b8a6f0a563 | 114 | while(user_entry != QUIT) |
j3 | 0:24b8a6f0a563 | 115 | { |
j3 | 2:0c0994f70fd2 | 116 | term.printf("1. Set RTC\n"); |
j3 | 2:0c0994f70fd2 | 117 | term.printf("2. Get Time/Date\n"); |
j3 | 2:0c0994f70fd2 | 118 | term.printf("3. Search OneWire bus\n"); |
j3 | 2:0c0994f70fd2 | 119 | term.printf("4. Set non-latching relay\n"); |
j3 | 2:0c0994f70fd2 | 120 | term.printf("5. Reset non-latching relay\n"); |
j3 | 2:0c0994f70fd2 | 121 | term.printf("6. Set all non-latching relays\n"); |
j3 | 2:0c0994f70fd2 | 122 | term.printf("7. Reset all non-latching relays\n"); |
j3 | 2:0c0994f70fd2 | 123 | term.printf("8. Set latching relay\n"); |
j3 | 2:0c0994f70fd2 | 124 | term.printf("9. Reset latching relay\n"); |
j3 | 0:24b8a6f0a563 | 125 | term.printf("10. Set 0-10 analog out\n"); |
j3 | 0:24b8a6f0a563 | 126 | term.printf("11. Set 4-20 out\n"); |
j3 | 0:24b8a6f0a563 | 127 | term.printf("12. Get 4-20 in\n"); |
j3 | 2:0c0994f70fd2 | 128 | term.printf("13. Calibrate 4-20 io\n"); |
j3 | 0:24b8a6f0a563 | 129 | term.printf("%d. Clear Screen\n", (QUIT - 1)); |
j3 | 0:24b8a6f0a563 | 130 | term.printf("%d. Quit\n\n", QUIT); |
j3 | 0:24b8a6f0a563 | 131 | |
j3 | 0:24b8a6f0a563 | 132 | user_entry = term.get_int32("Please select an option above: ", 1, QUIT); |
j3 | 0:24b8a6f0a563 | 133 | |
j3 | 0:24b8a6f0a563 | 134 | //get non-latching relay |
j3 | 0:24b8a6f0a563 | 135 | if((user_entry == 4) || (user_entry == 5)) |
j3 | 0:24b8a6f0a563 | 136 | { |
j3 | 0:24b8a6f0a563 | 137 | relay = term.get_int32("Select a relay from 1 to 8: ", 1, 8); |
j3 | 0:24b8a6f0a563 | 138 | } |
j3 | 0:24b8a6f0a563 | 139 | |
j3 | 0:24b8a6f0a563 | 140 | //get latching relay |
j3 | 0:24b8a6f0a563 | 141 | if((user_entry == 8) || (user_entry == 9)) |
j3 | 0:24b8a6f0a563 | 142 | { |
j3 | 0:24b8a6f0a563 | 143 | relay = (8 + term.get_int32("Select a relay from 1 to 3: ", 1, 3)); |
j3 | 0:24b8a6f0a563 | 144 | } |
j3 | 0:24b8a6f0a563 | 145 | |
j3 | 0:24b8a6f0a563 | 146 | switch(user_entry) |
j3 | 0:24b8a6f0a563 | 147 | { |
j3 | 0:24b8a6f0a563 | 148 | case 1: |
j3 | 0:24b8a6f0a563 | 149 | set_rtc(term, rtc); |
j3 | 0:24b8a6f0a563 | 150 | break; |
j3 | 0:24b8a6f0a563 | 151 | |
j3 | 0:24b8a6f0a563 | 152 | case 2: |
j3 | 0:24b8a6f0a563 | 153 | get_time_date(term, rtc); |
j3 | 0:24b8a6f0a563 | 154 | break; |
j3 | 0:24b8a6f0a563 | 155 | |
j3 | 0:24b8a6f0a563 | 156 | case 3: |
j3 | 0:24b8a6f0a563 | 157 | search_ow_bus(term, owm); |
j3 | 0:24b8a6f0a563 | 158 | break; |
j3 | 0:24b8a6f0a563 | 159 | |
j3 | 0:24b8a6f0a563 | 160 | case 4: |
j3 | 1:03c04017a728 | 161 | rly_drvr_result = rly_drvr.set_relay(static_cast<MAX4822::RelayChannel>(relay)); |
j3 | 1:03c04017a728 | 162 | if(rly_drvr_result != MAX4822::Success) |
j3 | 1:03c04017a728 | 163 | { |
j3 | 1:03c04017a728 | 164 | term.printf("Failed to set relay\n"); |
j3 | 1:03c04017a728 | 165 | } |
j3 | 0:24b8a6f0a563 | 166 | break; |
j3 | 0:24b8a6f0a563 | 167 | |
j3 | 0:24b8a6f0a563 | 168 | case 5: |
j3 | 1:03c04017a728 | 169 | rly_drvr_result = rly_drvr.reset_relay(static_cast<MAX4822::RelayChannel>(relay)); |
j3 | 1:03c04017a728 | 170 | if(rly_drvr_result != MAX4822::Success) |
j3 | 1:03c04017a728 | 171 | { |
j3 | 1:03c04017a728 | 172 | term.printf("Failed to reset relay\n"); |
j3 | 1:03c04017a728 | 173 | } |
j3 | 0:24b8a6f0a563 | 174 | break; |
j3 | 0:24b8a6f0a563 | 175 | |
j3 | 0:24b8a6f0a563 | 176 | case 6: |
j3 | 0:24b8a6f0a563 | 177 | rly_drvr.set_all_relays(rly_drvr_set); |
j3 | 0:24b8a6f0a563 | 178 | term.printf("\n"); |
j3 | 0:24b8a6f0a563 | 179 | break; |
j3 | 0:24b8a6f0a563 | 180 | |
j3 | 0:24b8a6f0a563 | 181 | case 7: |
j3 | 0:24b8a6f0a563 | 182 | rly_drvr.reset_all_relays(rly_drvr_reset); |
j3 | 0:24b8a6f0a563 | 183 | term.printf("\n"); |
j3 | 0:24b8a6f0a563 | 184 | break; |
j3 | 0:24b8a6f0a563 | 185 | |
j3 | 0:24b8a6f0a563 | 186 | case 8: |
j3 | 1:03c04017a728 | 187 | pixi_result = pixi.gpio_write(static_cast<MAX11300::MAX11300_Ports>(relay), 1); |
j3 | 1:03c04017a728 | 188 | if(pixi_result != MAX11300::Success) |
j3 | 1:03c04017a728 | 189 | { |
j3 | 1:03c04017a728 | 190 | term.printf("Failed to set relay\n"); |
j3 | 1:03c04017a728 | 191 | } |
j3 | 0:24b8a6f0a563 | 192 | break; |
j3 | 0:24b8a6f0a563 | 193 | |
j3 | 0:24b8a6f0a563 | 194 | case 9: |
j3 | 1:03c04017a728 | 195 | pixi_result = pixi.gpio_write(static_cast<MAX11300::MAX11300_Ports>(relay), 0); |
j3 | 1:03c04017a728 | 196 | if(pixi_result != MAX11300::Success) |
j3 | 1:03c04017a728 | 197 | { |
j3 | 1:03c04017a728 | 198 | term.printf("Failed to reset relay\n"); |
j3 | 1:03c04017a728 | 199 | } |
j3 | 0:24b8a6f0a563 | 200 | break; |
j3 | 0:24b8a6f0a563 | 201 | |
j3 | 0:24b8a6f0a563 | 202 | case 10: |
j3 | 2:0c0994f70fd2 | 203 | analog_out_ch = (term.get_int32("Please select a 0-10V output; 1-8: ", 1, 8) - 1); |
j3 | 2:0c0994f70fd2 | 204 | avo_volts = term.get_float("Please enter a voltage from 0.0 to 10.0 volts: ", -0.1, 10.1); |
j3 | 2:0c0994f70fd2 | 205 | analog_val = static_cast<uint16_t>((avo_volts/10.0) * 4095); |
j3 | 1:03c04017a728 | 206 | |
j3 | 5:2fe6dd435618 | 207 | term.printf("DAC Code = %d\n", analog_val); |
j3 | 5:2fe6dd435618 | 208 | |
j3 | 2:0c0994f70fd2 | 209 | pixi_result = pixi.single_ended_dac_write(static_cast<MAX11300::MAX11300_Ports>(analog_out_ch), analog_val); |
j3 | 1:03c04017a728 | 210 | if(pixi_result != MAX11300::Success) |
j3 | 1:03c04017a728 | 211 | { |
j3 | 1:03c04017a728 | 212 | term.printf("Failed to set 0-10 out\n"); |
j3 | 1:03c04017a728 | 213 | } |
j3 | 0:24b8a6f0a563 | 214 | break; |
j3 | 0:24b8a6f0a563 | 215 | |
j3 | 0:24b8a6f0a563 | 216 | case 11: |
j3 | 2:0c0994f70fd2 | 217 | aio_mA = term.get_float("Please enter a current from 4.0 to 20.0 mA: ", 3.9, 20.1); |
j3 | 2:0c0994f70fd2 | 218 | analog_val = static_cast<uint16_t>((aio_slope * aio_mA) + aio_offset); |
j3 | 1:03c04017a728 | 219 | |
j3 | 1:03c04017a728 | 220 | pixi_result = pixi.single_ended_dac_write(MAX11300::PORT8, analog_val); |
j3 | 1:03c04017a728 | 221 | if(pixi_result != MAX11300::Success) |
j3 | 1:03c04017a728 | 222 | { |
j3 | 1:03c04017a728 | 223 | term.printf("Failed to set 4-20 out\n"); |
j3 | 1:03c04017a728 | 224 | } |
j3 | 0:24b8a6f0a563 | 225 | break; |
j3 | 0:24b8a6f0a563 | 226 | |
j3 | 0:24b8a6f0a563 | 227 | case 12: |
j3 | 1:03c04017a728 | 228 | pixi_result = pixi.single_ended_adc_read(MAX11300::PORT12, analog_val); |
j3 | 2:0c0994f70fd2 | 229 | aii_mA = ((aii_slope*analog_val) + aii_offset); |
j3 | 1:03c04017a728 | 230 | if(pixi_result == MAX11300::Success) |
j3 | 1:03c04017a728 | 231 | { |
j3 | 2:0c0994f70fd2 | 232 | term.printf("4-20 in = %.2fmA\n", aii_mA); |
j3 | 1:03c04017a728 | 233 | } |
j3 | 1:03c04017a728 | 234 | else |
j3 | 1:03c04017a728 | 235 | { |
j3 | 1:03c04017a728 | 236 | term.printf("Failed to read 4-20 in\n"); |
j3 | 1:03c04017a728 | 237 | } |
j3 | 0:24b8a6f0a563 | 238 | break; |
j3 | 0:24b8a6f0a563 | 239 | |
j3 | 2:0c0994f70fd2 | 240 | case 13: |
j3 | 2:0c0994f70fd2 | 241 | calibrate_420_io(term, pixi, aio_slope, aio_offset, aii_slope, aii_offset); |
j3 | 2:0c0994f70fd2 | 242 | break; |
j3 | 2:0c0994f70fd2 | 243 | |
j3 | 0:24b8a6f0a563 | 244 | case (QUIT - 1): |
j3 | 0:24b8a6f0a563 | 245 | term.cls(); |
j3 | 0:24b8a6f0a563 | 246 | term.home(); |
j3 | 0:24b8a6f0a563 | 247 | break; |
j3 | 0:24b8a6f0a563 | 248 | |
j3 | 0:24b8a6f0a563 | 249 | case QUIT: |
j3 | 0:24b8a6f0a563 | 250 | term.printf("\nEnding Program\n"); |
j3 | 0:24b8a6f0a563 | 251 | break; |
j3 | 0:24b8a6f0a563 | 252 | |
j3 | 0:24b8a6f0a563 | 253 | default: |
j3 | 0:24b8a6f0a563 | 254 | mbed_die(); |
j3 | 0:24b8a6f0a563 | 255 | break; |
j3 | 0:24b8a6f0a563 | 256 | } |
j3 | 0:24b8a6f0a563 | 257 | } |
j3 | 0:24b8a6f0a563 | 258 | } |
j3 | 0:24b8a6f0a563 | 259 | |
j3 | 0:24b8a6f0a563 | 260 | //********************************************************************* |
j3 | 0:24b8a6f0a563 | 261 | void set_rtc(Terminal & term, Ds3231 & rtc) |
j3 | 0:24b8a6f0a563 | 262 | { |
j3 | 0:24b8a6f0a563 | 263 | //default, use bit masks in ds3231.h for desired operation |
j3 | 0:24b8a6f0a563 | 264 | ds3231_cntl_stat_t rtc_control_status = {0,0}; |
j3 | 0:24b8a6f0a563 | 265 | ds3231_time_t rtc_time; |
j3 | 0:24b8a6f0a563 | 266 | ds3231_calendar_t rtc_calendar; |
j3 | 0:24b8a6f0a563 | 267 | |
j3 | 0:24b8a6f0a563 | 268 | rtc.set_cntl_stat_reg(rtc_control_status); |
j3 | 0:24b8a6f0a563 | 269 | |
j3 | 0:24b8a6f0a563 | 270 | //get day from user |
j3 | 0:24b8a6f0a563 | 271 | rtc_calendar.day = term.get_int32("\nPlease enter day of week, 1 for Sunday (1-7): ", 1, 7); |
j3 | 0:24b8a6f0a563 | 272 | |
j3 | 0:24b8a6f0a563 | 273 | //get day of month from user |
j3 | 0:24b8a6f0a563 | 274 | rtc_calendar.date = term.get_int32("\nPlease enter day of month (1-31): ", 1, 31); |
j3 | 0:24b8a6f0a563 | 275 | |
j3 | 0:24b8a6f0a563 | 276 | //get month from user |
j3 | 0:24b8a6f0a563 | 277 | rtc_calendar.month = term.get_int32("\nPlease enter the month, 1 for January (1-12): ", 1, 12); |
j3 | 0:24b8a6f0a563 | 278 | |
j3 | 0:24b8a6f0a563 | 279 | //get year from user |
j3 | 0:24b8a6f0a563 | 280 | rtc_calendar.year = term.get_int32("\nPlease enter the year (0-99): ", 0, 99); |
j3 | 0:24b8a6f0a563 | 281 | |
j3 | 0:24b8a6f0a563 | 282 | //Get time mode |
j3 | 0:24b8a6f0a563 | 283 | rtc_time.mode = term.get_int32("\nWhat time mode? 1 for 12hr 0 for 24hr: ", 0, 1); |
j3 | 0:24b8a6f0a563 | 284 | |
j3 | 0:24b8a6f0a563 | 285 | if(rtc_time.mode) |
j3 | 0:24b8a6f0a563 | 286 | { |
j3 | 0:24b8a6f0a563 | 287 | //Get AM/PM status |
j3 | 0:24b8a6f0a563 | 288 | rtc_time.am_pm = term.get_int32("\nIs it AM or PM? 0 for AM 1 for PM: ", 0, 1); |
j3 | 0:24b8a6f0a563 | 289 | //Get hour from user |
j3 | 0:24b8a6f0a563 | 290 | rtc_time.hours = term.get_int32("\nPlease enter the hour (1-12): ", 1, 12); |
j3 | 0:24b8a6f0a563 | 291 | } |
j3 | 0:24b8a6f0a563 | 292 | else |
j3 | 0:24b8a6f0a563 | 293 | { |
j3 | 0:24b8a6f0a563 | 294 | //Get hour from user |
j3 | 0:24b8a6f0a563 | 295 | rtc_time.hours = term.get_int32("\nPlease enter the hour (0-23): ", 0, 23); |
j3 | 0:24b8a6f0a563 | 296 | } |
j3 | 0:24b8a6f0a563 | 297 | |
j3 | 0:24b8a6f0a563 | 298 | //Get minutes from user |
j3 | 0:24b8a6f0a563 | 299 | rtc_time.minutes = term.get_int32("\nPlease enter the minute (0-59): ", 0, 59); |
j3 | 0:24b8a6f0a563 | 300 | |
j3 | 0:24b8a6f0a563 | 301 | |
j3 | 0:24b8a6f0a563 | 302 | //Get seconds from user |
j3 | 0:24b8a6f0a563 | 303 | rtc_time.seconds = term.get_int32("\nPlease enter the second (0-59): ", 0, 59); |
j3 | 0:24b8a6f0a563 | 304 | |
j3 | 0:24b8a6f0a563 | 305 | term.printf("\n"); |
j3 | 0:24b8a6f0a563 | 306 | |
j3 | 0:24b8a6f0a563 | 307 | rtc.set_time(rtc_time); |
j3 | 0:24b8a6f0a563 | 308 | rtc.set_calendar(rtc_calendar); |
j3 | 0:24b8a6f0a563 | 309 | } |
j3 | 0:24b8a6f0a563 | 310 | |
j3 | 0:24b8a6f0a563 | 311 | //********************************************************************* |
j3 | 0:24b8a6f0a563 | 312 | void get_time_date(Terminal & term, Ds3231 & rtc) |
j3 | 0:24b8a6f0a563 | 313 | { |
j3 | 0:24b8a6f0a563 | 314 | time_t epoch_time; |
j3 | 0:24b8a6f0a563 | 315 | |
j3 | 0:24b8a6f0a563 | 316 | epoch_time = rtc.get_epoch(); |
j3 | 0:24b8a6f0a563 | 317 | term.printf("\n%s\n", ctime(&epoch_time)); |
j3 | 0:24b8a6f0a563 | 318 | } |
j3 | 0:24b8a6f0a563 | 319 | |
j3 | 0:24b8a6f0a563 | 320 | //********************************************************************* |
j3 | 0:24b8a6f0a563 | 321 | void search_ow_bus(Terminal & term, DS2484 & owm) |
j3 | 0:24b8a6f0a563 | 322 | { |
j3 | 0:24b8a6f0a563 | 323 | OneWireMaster::CmdResult result = owm.OWReset(); |
j3 | 5:2fe6dd435618 | 324 | MultidropRomIterator selector(owm); |
j3 | 0:24b8a6f0a563 | 325 | SearchState search_state; |
j3 | 0:24b8a6f0a563 | 326 | |
j3 | 0:24b8a6f0a563 | 327 | if(result == OneWireMaster::Success) |
j3 | 0:24b8a6f0a563 | 328 | { |
j3 | 0:24b8a6f0a563 | 329 | term.printf("\nOWReset success, starting search\n"); |
j3 | 0:24b8a6f0a563 | 330 | |
j3 | 0:24b8a6f0a563 | 331 | result = OWFirst(owm, search_state); |
j3 | 0:24b8a6f0a563 | 332 | if(result == OneWireMaster::Success) |
j3 | 0:24b8a6f0a563 | 333 | { |
j3 | 0:24b8a6f0a563 | 334 | while(result == OneWireMaster::Success) |
j3 | 0:24b8a6f0a563 | 335 | { |
j3 | 0:24b8a6f0a563 | 336 | //print current devices rom id |
j3 | 0:24b8a6f0a563 | 337 | print_rom_id(term, search_state.romId); |
j3 | 0:24b8a6f0a563 | 338 | |
j3 | 5:2fe6dd435618 | 339 | if(search_state.romId.familyCode() == 0x10) |
j3 | 6:18a831a757b5 | 340 | { |
j3 | 6:18a831a757b5 | 341 | DS1920Menu(term, search_state.romId, selector); |
j3 | 6:18a831a757b5 | 342 | } |
j3 | 5:2fe6dd435618 | 343 | |
j3 | 0:24b8a6f0a563 | 344 | //find the next device if any |
j3 | 0:24b8a6f0a563 | 345 | result = OWNext(owm, search_state); |
j3 | 0:24b8a6f0a563 | 346 | } |
j3 | 0:24b8a6f0a563 | 347 | term.printf("\n"); |
j3 | 0:24b8a6f0a563 | 348 | } |
j3 | 0:24b8a6f0a563 | 349 | else |
j3 | 0:24b8a6f0a563 | 350 | { |
j3 | 0:24b8a6f0a563 | 351 | term.printf("\nSearch failed\n"); |
j3 | 0:24b8a6f0a563 | 352 | term.printf("\nError code = %d\n", result); |
j3 | 0:24b8a6f0a563 | 353 | } |
j3 | 0:24b8a6f0a563 | 354 | } |
j3 | 0:24b8a6f0a563 | 355 | else |
j3 | 0:24b8a6f0a563 | 356 | { |
j3 | 0:24b8a6f0a563 | 357 | term.printf("\nFailed to find any 1-wire devices on bus\n"); |
j3 | 0:24b8a6f0a563 | 358 | term.printf("\nError code = %d\n", result); |
j3 | 0:24b8a6f0a563 | 359 | } |
j3 | 0:24b8a6f0a563 | 360 | } |
j3 | 0:24b8a6f0a563 | 361 | |
j3 | 0:24b8a6f0a563 | 362 | //********************************************************************* |
j3 | 0:24b8a6f0a563 | 363 | void print_rom_id(Terminal & term, RomId & romId) |
j3 | 0:24b8a6f0a563 | 364 | { |
j3 | 0:24b8a6f0a563 | 365 | //print the rom number |
j3 | 0:24b8a6f0a563 | 366 | term.printf("\n"); |
j3 | 0:24b8a6f0a563 | 367 | int8_t idx = (RomId::byteLen - 1); |
j3 | 0:24b8a6f0a563 | 368 | do |
j3 | 0:24b8a6f0a563 | 369 | { |
j3 | 0:24b8a6f0a563 | 370 | if(romId[idx] < 16) |
j3 | 0:24b8a6f0a563 | 371 | { |
j3 | 0:24b8a6f0a563 | 372 | term.printf("0x0%x ", romId[idx--]); |
j3 | 0:24b8a6f0a563 | 373 | } |
j3 | 0:24b8a6f0a563 | 374 | else |
j3 | 0:24b8a6f0a563 | 375 | { |
j3 | 0:24b8a6f0a563 | 376 | term.printf("0x%2x ", romId[idx--]); |
j3 | 0:24b8a6f0a563 | 377 | } |
j3 | 0:24b8a6f0a563 | 378 | } |
j3 | 0:24b8a6f0a563 | 379 | while(idx >= 0); |
j3 | 0:24b8a6f0a563 | 380 | term.printf("\n"); |
j3 | 0:24b8a6f0a563 | 381 | } |
j3 | 2:0c0994f70fd2 | 382 | |
j3 | 2:0c0994f70fd2 | 383 | //********************************************************************* |
j3 | 2:0c0994f70fd2 | 384 | void calibrate_420_io(Terminal & term, MAX11300 & pixi, |
j3 | 2:0c0994f70fd2 | 385 | float & slope_out, float & offset_out, |
j3 | 2:0c0994f70fd2 | 386 | float & slope_in, float & offset_in) |
j3 | 2:0c0994f70fd2 | 387 | { |
j3 | 2:0c0994f70fd2 | 388 | char user_entry; |
j3 | 2:0c0994f70fd2 | 389 | //initial vals for aio determined imperically on one pcb |
j3 | 2:0c0994f70fd2 | 390 | static uint16_t aio_4mA = 518; |
j3 | 2:0c0994f70fd2 | 391 | static uint16_t aio_20mA = 2592; |
j3 | 2:0c0994f70fd2 | 392 | uint16_t aii_4mA, aii_20mA; |
j3 | 2:0c0994f70fd2 | 393 | |
j3 | 4:2a25a4e00541 | 394 | term.cls(); |
j3 | 4:2a25a4e00541 | 395 | term.home(); |
j3 | 4:2a25a4e00541 | 396 | |
j3 | 2:0c0994f70fd2 | 397 | //cal aio |
j3 | 2:0c0994f70fd2 | 398 | term.printf("\nConnect DMM in series with AIO and AII.\n"); |
j3 | 4:2a25a4e00541 | 399 | term.printf("AIO----(DMMM)----AII\n\n"); |
j3 | 4:2a25a4e00541 | 400 | term.printf("Use 'i' and 'd' keys to increase/decrease measurement to calibration value.\n\n"); |
j3 | 4:2a25a4e00541 | 401 | term.printf("Setting AIO calibration val to 4mA, enter 'q' when DMM measurement = 4mA.\n\n"); |
j3 | 2:0c0994f70fd2 | 402 | |
j3 | 2:0c0994f70fd2 | 403 | do |
j3 | 2:0c0994f70fd2 | 404 | { |
j3 | 2:0c0994f70fd2 | 405 | pixi.single_ended_dac_write(MAX11300::PORT8, aio_4mA); |
j3 | 4:2a25a4e00541 | 406 | user_entry = term.get_char("increase (i), decrease (d), quit (q) when DMM = 4mA: ", 'd', 'q'); |
j3 | 2:0c0994f70fd2 | 407 | |
j3 | 2:0c0994f70fd2 | 408 | if(user_entry == 'i') |
j3 | 2:0c0994f70fd2 | 409 | { |
j3 | 2:0c0994f70fd2 | 410 | aio_4mA++; |
j3 | 2:0c0994f70fd2 | 411 | } |
j3 | 2:0c0994f70fd2 | 412 | else if(user_entry == 'd') |
j3 | 2:0c0994f70fd2 | 413 | { |
j3 | 2:0c0994f70fd2 | 414 | aio_4mA--; |
j3 | 2:0c0994f70fd2 | 415 | } |
j3 | 2:0c0994f70fd2 | 416 | else if(user_entry == 'q') |
j3 | 2:0c0994f70fd2 | 417 | { |
j3 | 4:2a25a4e00541 | 418 | term.printf("\nSetting AIO calibration val to 20mA, enter 'q' when DMM measurement = 20mA.\n\n"); |
j3 | 2:0c0994f70fd2 | 419 | } |
j3 | 2:0c0994f70fd2 | 420 | else |
j3 | 2:0c0994f70fd2 | 421 | { |
j3 | 2:0c0994f70fd2 | 422 | term.printf("Not an option, please read the instructions.\n"); |
j3 | 2:0c0994f70fd2 | 423 | } |
j3 | 2:0c0994f70fd2 | 424 | } |
j3 | 2:0c0994f70fd2 | 425 | while(user_entry != 'q'); |
j3 | 2:0c0994f70fd2 | 426 | |
j3 | 2:0c0994f70fd2 | 427 | do |
j3 | 2:0c0994f70fd2 | 428 | { |
j3 | 2:0c0994f70fd2 | 429 | pixi.single_ended_dac_write(MAX11300::PORT8, aio_20mA); |
j3 | 4:2a25a4e00541 | 430 | user_entry = term.get_char("increase (i), decrease (d), quit (q) when DMM = 20mA: ", 'd', 'q'); |
j3 | 2:0c0994f70fd2 | 431 | |
j3 | 2:0c0994f70fd2 | 432 | if(user_entry == 'i') |
j3 | 2:0c0994f70fd2 | 433 | { |
j3 | 2:0c0994f70fd2 | 434 | aio_20mA++; |
j3 | 2:0c0994f70fd2 | 435 | } |
j3 | 2:0c0994f70fd2 | 436 | else if(user_entry == 'd') |
j3 | 2:0c0994f70fd2 | 437 | { |
j3 | 2:0c0994f70fd2 | 438 | aio_20mA--; |
j3 | 2:0c0994f70fd2 | 439 | } |
j3 | 2:0c0994f70fd2 | 440 | else if(user_entry == 'q') |
j3 | 2:0c0994f70fd2 | 441 | { |
j3 | 4:2a25a4e00541 | 442 | term.printf("\nExecuting AII Cal\n\n"); |
j3 | 2:0c0994f70fd2 | 443 | } |
j3 | 2:0c0994f70fd2 | 444 | else |
j3 | 2:0c0994f70fd2 | 445 | { |
j3 | 2:0c0994f70fd2 | 446 | term.printf("Not an option, please read the instructions.\n"); |
j3 | 2:0c0994f70fd2 | 447 | } |
j3 | 2:0c0994f70fd2 | 448 | } |
j3 | 2:0c0994f70fd2 | 449 | while(user_entry != 'q'); |
j3 | 2:0c0994f70fd2 | 450 | |
j3 | 2:0c0994f70fd2 | 451 | slope_out = (((aio_20mA*1.0) - (aio_4mA*1.0))/16.0); |
j3 | 2:0c0994f70fd2 | 452 | offset_out = ((-1.0*slope_out*4.0) + aio_4mA); |
j3 | 2:0c0994f70fd2 | 453 | |
j3 | 4:2a25a4e00541 | 454 | uint8_t idx; |
j3 | 2:0c0994f70fd2 | 455 | //cal aii |
j3 | 2:0c0994f70fd2 | 456 | pixi.single_ended_dac_write(MAX11300::PORT8, aio_4mA); |
j3 | 4:2a25a4e00541 | 457 | for(idx = 0; idx < 10; idx++) |
j3 | 4:2a25a4e00541 | 458 | { |
j3 | 4:2a25a4e00541 | 459 | term.printf("AII 4mA input cal...\n"); |
j3 | 4:2a25a4e00541 | 460 | wait(1.0); |
j3 | 4:2a25a4e00541 | 461 | } |
j3 | 2:0c0994f70fd2 | 462 | pixi.single_ended_adc_read(MAX11300::PORT12, aii_4mA); |
j3 | 4:2a25a4e00541 | 463 | |
j3 | 2:0c0994f70fd2 | 464 | pixi.single_ended_dac_write(MAX11300::PORT8, aio_20mA); |
j3 | 4:2a25a4e00541 | 465 | for(idx = 0; idx < 10; idx++) |
j3 | 4:2a25a4e00541 | 466 | { |
j3 | 4:2a25a4e00541 | 467 | term.printf("AII 20mA input cal...\n"); |
j3 | 4:2a25a4e00541 | 468 | wait(1.0); |
j3 | 4:2a25a4e00541 | 469 | } |
j3 | 2:0c0994f70fd2 | 470 | pixi.single_ended_adc_read(MAX11300::PORT12, aii_20mA); |
j3 | 2:0c0994f70fd2 | 471 | |
j3 | 2:0c0994f70fd2 | 472 | |
j3 | 2:0c0994f70fd2 | 473 | slope_in = (16.0/((aii_20mA*1.0) - (aii_4mA*1.0))); |
j3 | 2:0c0994f70fd2 | 474 | offset_in = ((-1.0*slope_in*aii_4mA) + 4.0); |
j3 | 4:2a25a4e00541 | 475 | |
j3 | 4:2a25a4e00541 | 476 | term.printf("\nCal done.\n\n"); |
j3 | 4:2a25a4e00541 | 477 | wait(1.0); |
j3 | 2:0c0994f70fd2 | 478 | } |
j3 | 2:0c0994f70fd2 | 479 | |
j3 | 5:2fe6dd435618 | 480 | //********************************************************************* |
j3 | 5:2fe6dd435618 | 481 | void DS1920Menu(Terminal & term, const RomId & romId, MultidropRomIterator & selector) |
j3 | 5:2fe6dd435618 | 482 | { |
j3 | 5:2fe6dd435618 | 483 | char userEntry = '0'; |
j3 | 5:2fe6dd435618 | 484 | uint8_t th, tl, idx; |
j3 | 5:2fe6dd435618 | 485 | uint8_t scratchPadBuff[8]; |
j3 | 5:2fe6dd435618 | 486 | float temperature; |
j3 | 5:2fe6dd435618 | 487 | |
j3 | 5:2fe6dd435618 | 488 | DS1920 tempIbutton(selector); |
j3 | 5:2fe6dd435618 | 489 | DS1920::CmdResult result = DS1920::OpFailure; |
j3 | 5:2fe6dd435618 | 490 | tempIbutton.setRomId(romId); |
j3 | 5:2fe6dd435618 | 491 | |
j3 | 5:2fe6dd435618 | 492 | while(userEntry != '7') |
j3 | 5:2fe6dd435618 | 493 | { |
j3 | 5:2fe6dd435618 | 494 | term.printf("\nDS1920 Menu Options\n"); |
j3 | 5:2fe6dd435618 | 495 | term.printf("\n%t1. Write ScratchPad"); |
j3 | 5:2fe6dd435618 | 496 | term.printf("\n%t2. Read Scratchpad"); |
j3 | 5:2fe6dd435618 | 497 | term.printf("\n%t3. Copy Scratchpad"); |
j3 | 5:2fe6dd435618 | 498 | term.printf("\n%t4. Convert Temperature"); |
j3 | 5:2fe6dd435618 | 499 | term.printf("\n%t5. Recall EEPROM"); |
j3 | 5:2fe6dd435618 | 500 | term.printf("\n%t6. Clear Screen"); |
j3 | 5:2fe6dd435618 | 501 | term.printf("\n%t7. Quit"); |
j3 | 5:2fe6dd435618 | 502 | |
j3 | 5:2fe6dd435618 | 503 | userEntry = term.get_char("\nPlease select an option above: ", '1', '7'); |
j3 | 5:2fe6dd435618 | 504 | |
j3 | 5:2fe6dd435618 | 505 | switch(userEntry) |
j3 | 5:2fe6dd435618 | 506 | { |
j3 | 5:2fe6dd435618 | 507 | case '1': |
j3 | 5:2fe6dd435618 | 508 | th = term.get_int32("\nPlease enter upper temperature threshold, integer values only: ", 0, 100); |
j3 | 5:2fe6dd435618 | 509 | tl = term.get_int32("\nPlease enter lower temperature threshold, integer values only: ", -55, 0); |
j3 | 5:2fe6dd435618 | 510 | |
j3 | 5:2fe6dd435618 | 511 | result = tempIbutton.writeScratchPad(th, tl); |
j3 | 5:2fe6dd435618 | 512 | if(result == DS1920::Success) |
j3 | 5:2fe6dd435618 | 513 | { |
j3 | 5:2fe6dd435618 | 514 | term.printf("\nWrite Scratchpad Success\n"); |
j3 | 5:2fe6dd435618 | 515 | } |
j3 | 5:2fe6dd435618 | 516 | else |
j3 | 5:2fe6dd435618 | 517 | { |
j3 | 5:2fe6dd435618 | 518 | term.printf("\nWrite Scratchpad Fail\n"); |
j3 | 5:2fe6dd435618 | 519 | } |
j3 | 5:2fe6dd435618 | 520 | |
j3 | 5:2fe6dd435618 | 521 | break; |
j3 | 5:2fe6dd435618 | 522 | |
j3 | 5:2fe6dd435618 | 523 | case '2': |
j3 | 5:2fe6dd435618 | 524 | |
j3 | 5:2fe6dd435618 | 525 | result = tempIbutton.readScratchPad(scratchPadBuff); |
j3 | 5:2fe6dd435618 | 526 | if(result == DS1920::Success) |
j3 | 5:2fe6dd435618 | 527 | { |
j3 | 5:2fe6dd435618 | 528 | term.printf("\nRead Scratchpad Success\n"); |
j3 | 5:2fe6dd435618 | 529 | term.printf("\nScratchpad = "); |
j3 | 5:2fe6dd435618 | 530 | for(idx = 0; idx < 8; idx++) |
j3 | 5:2fe6dd435618 | 531 | { |
j3 | 5:2fe6dd435618 | 532 | if(scratchPadBuff[idx] < 16) |
j3 | 5:2fe6dd435618 | 533 | { |
j3 | 5:2fe6dd435618 | 534 | term.printf("0x0%x ", scratchPadBuff[idx]); |
j3 | 5:2fe6dd435618 | 535 | } |
j3 | 5:2fe6dd435618 | 536 | else |
j3 | 5:2fe6dd435618 | 537 | { |
j3 | 5:2fe6dd435618 | 538 | term.printf("0x%2x ", scratchPadBuff[idx]); |
j3 | 5:2fe6dd435618 | 539 | } |
j3 | 5:2fe6dd435618 | 540 | } |
j3 | 5:2fe6dd435618 | 541 | term.printf("\n"); |
j3 | 5:2fe6dd435618 | 542 | |
j3 | 5:2fe6dd435618 | 543 | } |
j3 | 5:2fe6dd435618 | 544 | else |
j3 | 5:2fe6dd435618 | 545 | { |
j3 | 5:2fe6dd435618 | 546 | term.printf("\nRead Scratchpad Fail\n"); |
j3 | 5:2fe6dd435618 | 547 | } |
j3 | 5:2fe6dd435618 | 548 | |
j3 | 5:2fe6dd435618 | 549 | break; |
j3 | 5:2fe6dd435618 | 550 | |
j3 | 5:2fe6dd435618 | 551 | case '3': |
j3 | 5:2fe6dd435618 | 552 | |
j3 | 5:2fe6dd435618 | 553 | result = tempIbutton.copyScratchPad(); |
j3 | 5:2fe6dd435618 | 554 | if(result == DS1920::Success) |
j3 | 5:2fe6dd435618 | 555 | { |
j3 | 5:2fe6dd435618 | 556 | term.printf("\nCopy Scratchpad Success\n"); |
j3 | 5:2fe6dd435618 | 557 | } |
j3 | 5:2fe6dd435618 | 558 | else |
j3 | 5:2fe6dd435618 | 559 | { |
j3 | 5:2fe6dd435618 | 560 | term.printf("\nCopy Scratchpad Fail\n"); |
j3 | 5:2fe6dd435618 | 561 | } |
j3 | 5:2fe6dd435618 | 562 | |
j3 | 5:2fe6dd435618 | 563 | break; |
j3 | 5:2fe6dd435618 | 564 | |
j3 | 5:2fe6dd435618 | 565 | case '4': |
j3 | 5:2fe6dd435618 | 566 | |
j3 | 5:2fe6dd435618 | 567 | result = tempIbutton.convertTemperature(temperature); |
j3 | 5:2fe6dd435618 | 568 | if(result == DS1920::Success) |
j3 | 5:2fe6dd435618 | 569 | { |
j3 | 5:2fe6dd435618 | 570 | term.printf("\nConvert Temperature Success\n"); |
j3 | 5:2fe6dd435618 | 571 | term.printf("\nTemperature = %.1f", temperature); |
j3 | 5:2fe6dd435618 | 572 | } |
j3 | 5:2fe6dd435618 | 573 | else |
j3 | 5:2fe6dd435618 | 574 | { |
j3 | 5:2fe6dd435618 | 575 | term.printf("\nConvert Temperature Fail\n"); |
j3 | 5:2fe6dd435618 | 576 | } |
j3 | 5:2fe6dd435618 | 577 | |
j3 | 5:2fe6dd435618 | 578 | break; |
j3 | 5:2fe6dd435618 | 579 | |
j3 | 5:2fe6dd435618 | 580 | case '5': |
j3 | 5:2fe6dd435618 | 581 | |
j3 | 5:2fe6dd435618 | 582 | result = tempIbutton.recallEEPROM(); |
j3 | 5:2fe6dd435618 | 583 | if(result == DS1920::Success) |
j3 | 5:2fe6dd435618 | 584 | { |
j3 | 5:2fe6dd435618 | 585 | term.printf("\nRecall EEPROM Success\n"); |
j3 | 5:2fe6dd435618 | 586 | } |
j3 | 5:2fe6dd435618 | 587 | else |
j3 | 5:2fe6dd435618 | 588 | { |
j3 | 5:2fe6dd435618 | 589 | term.printf("\nRecall EEPROM Fail\n"); |
j3 | 5:2fe6dd435618 | 590 | } |
j3 | 5:2fe6dd435618 | 591 | |
j3 | 5:2fe6dd435618 | 592 | break; |
j3 | 5:2fe6dd435618 | 593 | |
j3 | 5:2fe6dd435618 | 594 | case '6': |
j3 | 5:2fe6dd435618 | 595 | term.cls(); |
j3 | 5:2fe6dd435618 | 596 | term.home(); |
j3 | 5:2fe6dd435618 | 597 | break; |
j3 | 5:2fe6dd435618 | 598 | |
j3 | 5:2fe6dd435618 | 599 | case '7': |
j3 | 5:2fe6dd435618 | 600 | term.printf("\nLeaving DS1920 Menu Options\n"); |
j3 | 5:2fe6dd435618 | 601 | break; |
j3 | 5:2fe6dd435618 | 602 | |
j3 | 5:2fe6dd435618 | 603 | default: |
j3 | 5:2fe6dd435618 | 604 | mbed_die(); |
j3 | 5:2fe6dd435618 | 605 | break; |
j3 | 5:2fe6dd435618 | 606 | } |
j3 | 5:2fe6dd435618 | 607 | } |
j3 | 5:2fe6dd435618 | 608 | } |