- A fork of Damien's program.
Dependencies: WebSocketClient WiflyInterface mbed messages
Fork of BatteryModelTester by
headers/globals.h@10:e8b66718a103, 2016-11-29 (annotated)
- Committer:
- defrost
- Date:
- Tue Nov 29 15:02:01 2016 +0000
- Revision:
- 10:e8b66718a103
- Parent:
- 5:0c7d131e6089
- Child:
- 11:ce00133ab2f4
- Works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
defrost | 5:0c7d131e6089 | 1 | /** |
defrost | 5:0c7d131e6089 | 2 | * @author Damien Frost |
defrost | 5:0c7d131e6089 | 3 | * |
defrost | 5:0c7d131e6089 | 4 | * @section LICENSE |
defrost | 5:0c7d131e6089 | 5 | * |
defrost | 5:0c7d131e6089 | 6 | * Copyright (c) 2016 Damien Frost |
defrost | 5:0c7d131e6089 | 7 | * |
defrost | 5:0c7d131e6089 | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
defrost | 5:0c7d131e6089 | 9 | * of this software and associated documentation files (the "Software"), to deal |
defrost | 5:0c7d131e6089 | 10 | * in the Software without restriction, including without limitation the rights |
defrost | 5:0c7d131e6089 | 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
defrost | 5:0c7d131e6089 | 12 | * copies of the Software, and to permit persons to whom the Software is |
defrost | 5:0c7d131e6089 | 13 | * furnished to do so, subject to the following conditions: |
defrost | 5:0c7d131e6089 | 14 | * |
defrost | 5:0c7d131e6089 | 15 | * The above copyright notice and this permission notice shall be included in |
defrost | 5:0c7d131e6089 | 16 | * all copies or substantial portions of the Software. |
defrost | 5:0c7d131e6089 | 17 | * |
defrost | 5:0c7d131e6089 | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
defrost | 5:0c7d131e6089 | 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
defrost | 5:0c7d131e6089 | 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
defrost | 5:0c7d131e6089 | 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
defrost | 5:0c7d131e6089 | 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
defrost | 5:0c7d131e6089 | 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
defrost | 5:0c7d131e6089 | 24 | * THE SOFTWARE. |
defrost | 5:0c7d131e6089 | 25 | * |
defrost | 5:0c7d131e6089 | 26 | * @file "globals.h" |
defrost | 5:0c7d131e6089 | 27 | * |
defrost | 5:0c7d131e6089 | 28 | * @section DESCRIPTION |
defrost | 5:0c7d131e6089 | 29 | * Global definitions for the Internet of Things example. |
defrost | 5:0c7d131e6089 | 30 | * |
defrost | 5:0c7d131e6089 | 31 | */ |
defrost | 1:4403f2ed1c1f | 32 | |
defrost | 1:4403f2ed1c1f | 33 | #ifndef IQ_GLOBALS_H |
defrost | 1:4403f2ed1c1f | 34 | #define IQ_GLOBALS_H |
defrost | 1:4403f2ed1c1f | 35 | |
defrost | 1:4403f2ed1c1f | 36 | #include "mbed.h" |
defrost | 1:4403f2ed1c1f | 37 | #include "WiflyInterface.h" |
defrost | 1:4403f2ed1c1f | 38 | #include "Commands.h" |
defrost | 1:4403f2ed1c1f | 39 | #include "Websocket.h" |
defrost | 1:4403f2ed1c1f | 40 | |
defrost | 1:4403f2ed1c1f | 41 | |
defrost | 1:4403f2ed1c1f | 42 | // Wifi Interface defines: |
defrost | 1:4403f2ed1c1f | 43 | #define TCP_SERVER_PORT 4445 |
defrost | 1:4403f2ed1c1f | 44 | #define WIFIBAUDRATE 115200 |
defrost | 1:4403f2ed1c1f | 45 | #define WIFINETWORK 2 |
defrost | 1:4403f2ed1c1f | 46 | #define CHARMSGBUFF 1024 |
defrost | 1:4403f2ed1c1f | 47 | #define TIMEOUTRECEIVEATTEMPTS 5 |
defrost | 1:4403f2ed1c1f | 48 | #define WS_PORT 4444 |
defrost | 3:f20e114eb2ee | 49 | #define SERVER_IP "192.168.1.99" |
defrost | 1:4403f2ed1c1f | 50 | |
defrost | 10:e8b66718a103 | 51 | // Pin assignments |
defrost | 10:e8b66718a103 | 52 | #define VOLTAGE_SENSOR_PIN PA_0 |
defrost | 10:e8b66718a103 | 53 | #define CURRENT_SENSOR_PIN PA_1 |
defrost | 10:e8b66718a103 | 54 | |
defrost | 5:0c7d131e6089 | 55 | // Hardware: |
defrost | 1:4403f2ed1c1f | 56 | extern Serial pc; |
defrost | 1:4403f2ed1c1f | 57 | extern InterruptIn UIBut1; |
defrost | 1:4403f2ed1c1f | 58 | extern Timer DisplayTimer; |
defrost | 2:7abdaa5a9209 | 59 | extern DigitalOut Led; |
defrost | 1:4403f2ed1c1f | 60 | |
defrost | 5:0c7d131e6089 | 61 | // Variables: |
defrost | 1:4403f2ed1c1f | 62 | extern int ReconnectAttempts; |
defrost | 1:4403f2ed1c1f | 63 | extern int SendCounter; |
defrost | 1:4403f2ed1c1f | 64 | extern int IoT_ID; |
defrost | 1:4403f2ed1c1f | 65 | extern float TempSensor; |
defrost | 10:e8b66718a103 | 66 | extern float VoltageMeasurement; |
defrost | 10:e8b66718a103 | 67 | extern float CurrentMeasurement; |
defrost | 10:e8b66718a103 | 68 | extern float PwmPeriod_us; |
defrost | 10:e8b66718a103 | 69 | extern float Duty_us; |
defrost | 5:0c7d131e6089 | 70 | extern char* wifissid; |
defrost | 5:0c7d131e6089 | 71 | extern char* wifipassword; |
defrost | 10:e8b66718a103 | 72 | extern DigitalOut db; |
defrost | 10:e8b66718a103 | 73 | extern AnalogIn VoltageSensor; |
defrost | 10:e8b66718a103 | 74 | extern AnalogIn CurrentSensor; |
defrost | 1:4403f2ed1c1f | 75 | |
defrost | 5:0c7d131e6089 | 76 | // Communication: |
defrost | 5:0c7d131e6089 | 77 | extern WiflyInterface eth; |
defrost | 1:4403f2ed1c1f | 78 | extern Websocket ws; |
defrost | 1:4403f2ed1c1f | 79 | |
defrost | 1:4403f2ed1c1f | 80 | // Functions: |
defrost | 1:4403f2ed1c1f | 81 | void SensorToPu(float gain, float offset, int sensor, float* result); |
defrost | 1:4403f2ed1c1f | 82 | void InitializeStruct(struct tf_history_t* toClear); |
defrost | 1:4403f2ed1c1f | 83 | void SetupVar(void); |
defrost | 1:4403f2ed1c1f | 84 | void SetButtonEvent(void); |
defrost | 1:4403f2ed1c1f | 85 | void rt_OneStep(void); |
defrost | 1:4403f2ed1c1f | 86 | void DisplayInputs(float CPS); |
defrost | 1:4403f2ed1c1f | 87 | void SetSCKDCParams(bool enable, float gain); |
defrost | 1:4403f2ed1c1f | 88 | int SetupNetwork(int Tries); |
defrost | 1:4403f2ed1c1f | 89 | bool ConnectToServer(int Tries); |
defrost | 1:4403f2ed1c1f | 90 | void SendNetworkData(void); |
defrost | 5:0c7d131e6089 | 91 | void ReceiveNetworkData(unsigned int * wifi_cmd, float * value); |
defrost | 1:4403f2ed1c1f | 92 | void ModifyVariable(unsigned int wifi_var, float wifi_data); |
defrost | 1:4403f2ed1c1f | 93 | |
defrost | 1:4403f2ed1c1f | 94 | |
defrost | 1:4403f2ed1c1f | 95 | #endif /* IQ_GLOBALS_H */ |
defrost | 1:4403f2ed1c1f | 96 |