PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
reflow_debug.c
Go to the documentation of this file.
1 /*
2  * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
3  * All rights reserved.
4  * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
5  * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
6  * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation for any purpose, without fee, and without written agreement is
10  * hereby granted, provided that the above copyright notice, the following
11  * two paragraphs and the authors appear in all copies of this software.
12  *
13  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
15  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
16  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17  *
18  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
23  *
24  * Please maintain this header in its entirety when copying/modifying
25  * these files.
26  *
27  *
28  */
29 #include "pic24_all.h"
30 #include <stdio.h>
31 #include "reflow_oven.h"
32 
33 /** \file
34  Utilities for debugging reflow
35 */
36 
37 void debugPower(void) {
38  uint8_t u8_c;
39  u8_c = 0;
40  outString("\n");
41  do {
42  printf("Power: %d\n",u8_currPowerSetting);
43  u8_c = inChar();
44  if (u8_c == '-') decrementPower();
45  if (u8_c == '+') incrementPower();
46  } while ((u8_c == '-') || (u8_c == '+'));
47 }
48 
49 
50 void debugZeroCross(void) {
51  uint8_t u8_x;
52  u8_x = ZEROCROSS;
53  do {
54  while ((u8_x == ZEROCROSS) && !isCharReady()) doHeartbeat();
55  u8_x = !u8_x;
56  DELAY_MS(2);
57  if (u8_x) outChar('0');
58  else outChar('1');
59  } while (!isCharReady());
60  inChar();
61 }
62 
63 void debugThermocouple(void) {
64  float f_tempC,f_tempF;
65  do {
66  f_tempC = getCelsiusFloatTemp();
67  f_tempF = f_tempC*9/5 + 32;
68  printf("Temp is: %4.4f (C), %4.4f (F)\n", (double) f_tempC, (double) f_tempF);
69  DELAY_MS(400);
70  } while (!isCharReady());
71  inChar();
72 }
73 
74 void doDebugMenu(void) {
75  uint8_t u8_c;
76  printf("Debug menu:\n");
77  printf(" 't' - read thermocouple, hit any key to exit\n");
78  printf(" 'z' - read zerocross, hit any key to exit \n");
79  printf(" 'p' - control power setting, '+' increments,'-' decrements, other exits.\n");
80  printf(" 'x' - exit to main menu\n");
81  printf("Enter character: ");
82  u8_c = inCharEcho();
83  if (u8_c == 't') debugThermocouple();
84  else if (u8_c == 'z') debugZeroCross();
85  else if (u8_c == 'p') debugPower();
86  printf("\n");
87 }
88 
89