-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathSmartHandController.ino
More file actions
150 lines (126 loc) · 4.17 KB
/
SmartHandController.ino
File metadata and controls
150 lines (126 loc) · 4.17 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Title Smart Hand Controller (based on TeenAstro)
*
* Copyright (C) 2018 to 2025 Charles Lemaire, Howard Dutton, and Others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Revision History, see GitHub
*
* Author: Charles Lemaire, https://pixelstelescopes.wordpress.com/teenastro/
* Author: Howard Dutton, http://www.stellarjourney.com, hjd1964@gmail.com
*
* Description
*
* Smart Hand controller addon for OnStep
* for the actual hardware see: https://oshwlab.com/hdutton/smart-hand-controller2-plus
*/
#define Product "SHC"
#define FirmwareVersionMajor "4"
#define FirmwareVersionMinor "03"
#define FirmwareVersionPatch "b"
#include "src/Common.h"
#include "src/Validate.h"
#include "src/lib/nv/Nv.h"
#include "src/lib/tasks/OnTask.h"
#include "src/lib/convert/Convert.h"
#include "src/libApp/weather/Weather.h"
#include "src/userInterface/UserInterface.h"
#include "src/plugins/Plugins.config.h"
#if DEBUG == PROFILER
extern void profiler();
#endif
const char Version[] = "Version " FirmwareVersionMajor "." FirmwareVersionMinor FirmwareVersionPatch;
const KeyPad::Pin pins[7]= {
{B_PIN0, B_PIN0_ACTIVE_STATE, B_PIN0_INPUT_MODE},
{B_PIN1, B_PIN1_ACTIVE_STATE, B_PIN1_INPUT_MODE},
{B_PIN2, B_PIN2_ACTIVE_STATE, B_PIN2_INPUT_MODE},
{B_PIN3, B_PIN3_ACTIVE_STATE, B_PIN3_INPUT_MODE},
{B_PIN4, B_PIN4_ACTIVE_STATE, B_PIN4_INPUT_MODE},
{B_PIN5, B_PIN5_ACTIVE_STATE, B_PIN5_INPUT_MODE},
{B_PIN6, B_PIN6_ACTIVE_STATE, B_PIN6_INPUT_MODE},
};
#if WEATHER != OFF
void weatherServices() {
static int i = 0;
char command[80];
switch (i++ % 3) {
case 0: sprintF(command, ":SX9A,%0.1f#", weather.getTemperature()); onStepLx200.Set(command); break;
case 1: sprintF(command, ":SX9B,%0.1f#", weather.getPressure()); onStepLx200.Set(command); break;
case 2: sprintF(command, ":SX9C,%0.1f#", weather.getHumidity()); onStepLx200.Set(command); break;
}
}
#endif
void setup(void) {
// start debug serial port
if (DEBUG == ON || DEBUG == VERBOSE) SERIAL_DEBUG.begin(SERIAL_DEBUG_BAUD);
delay(2000);
VF("MSG: Smart Hand Controller "); V(FirmwareVersionMajor); V("."); V(FirmwareVersionMinor); VL(FirmwareVersionPatch);
VF("MSG: MCU = "); VLF(MCU_STR);
HAL_INIT();
WIRE_INIT();
// start the NV service task at priority level 5
if (!nv().init(5)) {
DLF("WRN: Setup, NV (EEPROM/FRAM/Flash/etc.) device not found!");
}
#if defined(NV_WIPE) && NV_WIPE == ON
nv().wipe();
#endif
// If necessary, power up the display
#ifdef DISPLAY_POWER_PIN
pinMode(DISPLAY_POWER_PIN, OUTPUT);
digitalWrite(DISPLAY_POWER_PIN, HIGH);
#endif
userInterface.init(Version, pins, SERIAL_ONSTEP_BAUD_DEFAULT, static_cast<OLED>(DISPLAY_OLED));
#if WEATHER != OFF
// get any BME280 or BMP280 ready
weather.init();
// add task to forward readings to OnStep
VF("MSG: Setup, starting weather services task (rate 3333ms priority 7)... ");
if (tasks.add(3333, 0, true, 7, weatherServices, "WeaFwd")) { VL("success"); } else { VL("FAILED!"); }
#endif
// start task manager debug events
#if DEBUG == PROFILER
tasks.add(142, 0, true, 7, profiler, "Profilr");
#endif
// start any plugins
#if PLUGIN1 != OFF
PLUGIN1.init();
#endif
#if PLUGIN2 != OFF
PLUGIN2.init();
#endif
#if PLUGIN3 != OFF
PLUGIN3.init();
#endif
#if PLUGIN4 != OFF
PLUGIN4.init();
#endif
#if PLUGIN5 != OFF
PLUGIN5.init();
#endif
#if PLUGIN6 != OFF
PLUGIN6.init();
#endif
#if PLUGIN7 != OFF
PLUGIN7.init();
#endif
#if PLUGIN8 != OFF
PLUGIN8.init();
#endif
VLF("MSG: Starting UI loop");
}
void loop() {
tasks.yield();
}