WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
BaeUtilities.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 /* Constants */
11 #define LOG_DEBUG __FILE__, __FUNCTION__, __LINE__, DEBUG_TYPE
12 #define LOG_INFO __FILE__, __FUNCTION__, __LINE__, INFO_TYPE
13 #define LOG_ERROR __FILE__, __FUNCTION__, __LINE__, ERROR_TYPE
14 #define LOG_CRITICAL __FILE__, __FUNCTION__, __LINE__, CRITICAL_TYPE
15 #define LOG_FATAL __FILE__, __FUNCTION__, __LINE__, FATAL_TYPE
16 #define LOG_DEBUG __FILE__, __FUNCTION__, __LINE__, DEBUG_TYPE
17 
18 /* Enumerated Types */
19 
21 enum dprint_type {
22  DEBUG_TYPE,
23  INFO_TYPE,
24  ERROR_TYPE,
25  CRITICAL_TYPE,
26  FATAL_TYPE
27 };
28 
30 typedef enum DebugOutputType_enum {
31  DEBUG_OFF,
32  DEBUG_MOSTLY_OFF,
33  DEBUG_SCREEN_ONLY,
34  DEBUG_FILE_ONLY,
35  DEBUG_SCREEN_AND_FILE
36 } DebugOutputType;
37 
38 /* Enumerated Types */
39 
40 /* Utility functions */
41 
42 /* debug */
43 void SetDebugFlag(DebugOutputType flag);
44 void dprintf(const char *tempString, ...); /* Variable argument list */
45 
46 /* set FRC ranges for drive */
47 double RangeToNormalized(double pixel, int range);
48 /* change normalized value to any range - used for servo */
49 float NormalizeToRange(float normalizedValue, float minRange, float maxRange);
50 float NormalizeToRange(float normalizedValue);
51 
52 /* system utilities */
53 void ShowActivity(char *fmt, ...);
54 double ElapsedTime(double startTime);
55 
56 /* servo panning utilities */
57 class Servo;
58 double SinPosition(double *period, double sinStart);
59 void panInit();
60 void panInit(double period);
61 void panForTarget(Servo *panServo);
62 void panForTarget(Servo *panServo, double sinStart);
63 
64 /* config file read utilities */
65 int processFile(char *inputFile, char *outputString, int lineNumber);
66 int emptyString(char *string);
67 void stripString(char *string);
void dprintf(const char *tempString,...)
Debug print to a file and/or a terminal window.
Definition: BaeUtilities.cpp:46
int emptyString(char *string)
Ignore empty string.
Definition: BaeUtilities.cpp:338
double RangeToNormalized(double position, int range)
Normalizes a value in a range, used for drive input.
Definition: BaeUtilities.cpp:165
int processFile(char *inputFile, char *outputString, int lineNumber)
Read a file and return non-comment output string.
Definition: BaeUtilities.cpp:293
float NormalizeToRange(float normalizedValue, float minRange, float maxRange)
Convert a normalized value to the corresponding value in a range.
Definition: BaeUtilities.cpp:177
double ElapsedTime(double startTime)
Find the elapsed time since a specified time.
Definition: BaeUtilities.cpp:248
void stripString(char *string)
Remove special characters from string.
Definition: BaeUtilities.cpp:357
void ShowActivity(char *fmt,...)
Displays an activity indicator to console.
Definition: BaeUtilities.cpp:191
void panInit()
Initialize pan parameters.
Definition: BaeUtilities.cpp:257
double SinPosition(double *period, double sinStart)
Calculate sine wave increments (-1.0 to 1.0).
Definition: BaeUtilities.cpp:221
void panForTarget(Servo *panServo)
Move the horizontal servo back and forth.
Definition: BaeUtilities.cpp:272
void SetDebugFlag(DebugOutputType flag)
Set the debug flag to print to screen, file on cRIO, both or neither.
Definition: BaeUtilities.cpp:36
Standard hobby style servo.
Definition: Servo.h:22