-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
120 lines (100 loc) · 2.73 KB
/
Copy pathmain.cpp
File metadata and controls
120 lines (100 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#define PROD_BRD_V1
#include <Arduino.h>
#include <NuvIoT.h>
#define EXAMPLE_SKU "IO_VALUES"
#define FIRMWARE_VERSION "1.0.1"
bool running = true;
double testADCValues[8];
double testTemperatureValues[8];
void cmdCallback(String cmd)
{
console.println("Receive CMD: " + cmd);
cmd.trim();
if (cmd == "exit")
{
running = false;
}
else if (cmd == "restart")
{
running = true;
}
else if (cmd == "+")
{
running = true;
for (int idx = 0; idx < 8; ++idx)
{
testADCValues[idx] *= 1.2;
testTemperatureValues[idx] *= 1.2;
}
}
else if (cmd == "-")
{
running = true;
for (int idx = 0; idx < 8; ++idx)
{
testADCValues[idx] *= 0.8;
testTemperatureValues[idx] *= 0.8;
}
}
else{
console.println("Unknown Command [" + cmd + "]");
}
}
void setup()
{
initPins();
configureConsole();
console.registerCallback(cmdCallback);
sysConfig.setDefaults();
BT.begin("NuvIoT - IO Values", "422700856E40445687BE6B41D25CBFDE");
welcome(EXAMPLE_SKU, FIRMWARE_VERSION);
state.init(EXAMPLE_SKU, FIRMWARE_VERSION, "0.0.0", "cfg001", 010);
ioConfig.setDefaults();
ioConfig.ADC1Config = ADC_CONFIG_ADC;
ioConfig.ADC1Calibration = 1354.1;
ioConfig.ADC1Zero = 800;
ioConfig.ADC3Config = ADC_CONFIG_ADC;
ioConfig.ADC3Scaler = 15;
ioConfig.ADC4Config = ADC_CONFIG_ADC;
ioConfig.ADC4Zero = 1.2;
adc.configure(&ioConfig);
/* This values will simulate values
in volts out of 5 possible volts
coming from the ADC */
testADCValues[0] = 1.2;
testADCValues[2] = 1.5;
testADCValues[3] = 1.7;
ioConfig.GPIO3Config = GPIO_CONFIG_DBS18;
ioConfig.GPIO5Config = GPIO_CONFIG_DBS18;
ioConfig.GPIO7Config = GPIO_CONFIG_DBS18;
probes.configure(&ioConfig);
testTemperatureValues[2] = 89.9;
testTemperatureValues[4] = 54.3;
testTemperatureValues[6] = 100.3;
}
int nextPrint = 0;
void loop()
{
console.loop();
BT.update();
Serial.println("forever");
if (nextPrint < millis() && running)
{
/* We are passing in an array of
voltages to simulate what we
would normally read from the ADC */
adc.loop(testADCValues);
probes.loop(testTemperatureValues);
console.setVerboseLogging(true);
/* IO Values consists of an array of
16 values are that the outputs of
the configured sensor */
ioValues.debugPrint();
console.setVerboseLogging(false);
nextPrint = millis() + 1000;
if (!BT.getIsConnected())
{
console.println("ble:disconnected;");
}
}
}