Browse Source

fix build for other platforms.

Thomas Buck 2 years ago
parent
commit
a14515c3ec
5 changed files with 30 additions and 7 deletions
  1. 1
    1
      include/config.h
  2. 8
    1
      include/config_pins.h
  3. 3
    2
      platformio.ini
  4. 14
    3
      src/GPIOBank.cpp
  5. 4
    0
      src/Statemachine.cpp

+ 1
- 1
include/config.h View File

30
 #define BACK_TO_IDLE_TIMEOUT (5UL * 60UL * 1000UL)
30
 #define BACK_TO_IDLE_TIMEOUT (5UL * 60UL * 1000UL)
31
 
31
 
32
 // in seconds
32
 // in seconds
33
-#define MAX_TANK_FILL_TIME (70)
33
+#define MAX_TANK_FILL_TIME (80)
34
 #define AUTO_PUMP_RUNTIME 4
34
 #define AUTO_PUMP_RUNTIME 4
35
 #define AUTO_STIRR_RUNTIME 60
35
 #define AUTO_STIRR_RUNTIME 60
36
 #define MAX_AUTO_PLANT_RUNTIME (35 * 60)
36
 #define MAX_AUTO_PLANT_RUNTIME (35 * 60)

+ 8
- 1
include/config_pins.h View File

52
  * AVR Controller
52
  * AVR Controller
53
  */
53
  */
54
 
54
 
55
+#define I2C_GPIO_EXPANDER_COUNT 0
56
+//#define I2C_GPIO_EXPANDER_ADDR 0x20, 0x21
57
+
55
 // out 1, out 2, out 3, out 4, in
58
 // out 1, out 2, out 3, out 4, in
56
 #define VALVE_COUNT 5
59
 #define VALVE_COUNT 5
57
 #define VALVE_PINS 10, 11, 12, 14, 15
60
 #define VALVE_PINS 10, 11, 12, 14, 15
58
 
61
 
62
+#define KICKSTART_PINS -1, -1, -1, -1
63
+
59
 // a, b, c
64
 // a, b, c
60
 #define PUMP_COUNT 3
65
 #define PUMP_COUNT 3
61
 #define PUMP_PINS 16, 17, 18
66
 #define PUMP_PINS 16, 17, 18
65
 #define SWITCH_PINS 19, 20
70
 #define SWITCH_PINS 19, 20
66
 
71
 
67
 // stirrer
72
 // stirrer
68
-#define AUX_COUNT 1
73
+#define STIRRER_COUNT 1
74
+#define LOCK_COUNT 0
75
+#define AUX_COUNT (STIRRER_COUNT + LOCK_COUNT)
69
 #define AUX_PINS 21
76
 #define AUX_PINS 21
70
 
77
 
71
 #endif // FUNCTION_CONTROL
78
 #endif // FUNCTION_CONTROL

+ 3
- 2
platformio.ini View File

15
 platform = espressif8266
15
 platform = espressif8266
16
 board = esp01_1m
16
 board = esp01_1m
17
 framework = arduino
17
 framework = arduino
18
-build_flags = -D PLATFORM_ESP -D FUNCTION_CONTROL
18
+build_flags = -D PLATFORM_ESP -D FUNCTION_CONTROL -D TWI_GPIO
19
 lib_deps =
19
 lib_deps =
20
     Wire
20
     Wire
21
     https://github.com/Links2004/arduinoWebSockets
21
     https://github.com/Links2004/arduinoWebSockets
22
     https://github.com/rlogiacco/CircularBuffer
22
     https://github.com/rlogiacco/CircularBuffer
23
     https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino.git
23
     https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino.git
24
+    https://github.com/RobTillaart/PCF8574
24
 
25
 
25
 [env:esp32_main]
26
 [env:esp32_main]
26
 platform = espressif32
27
 platform = espressif32
27
 board = esp32dev
28
 board = esp32dev
28
 framework = arduino
29
 framework = arduino
29
-build_flags = -D PLATFORM_ESP -D FUNCTION_CONTROL
30
+build_flags = -D PLATFORM_ESP -D FUNCTION_CONTROL -D TWI_GPIO
30
 upload_protocol = esptool
31
 upload_protocol = esptool
31
 upload_port = /dev/ttyUSB1
32
 upload_port = /dev/ttyUSB1
32
 lib_deps =
33
 lib_deps =

+ 14
- 3
src/GPIOBank.cpp View File

23
 #include "config.h"
23
 #include "config.h"
24
 #include "config_pins.h"
24
 #include "config_pins.h"
25
 
25
 
26
-#ifdef PLATFORM_ESP
26
+#ifdef TWI_GPIO
27
 #include <PCF8574.h>
27
 #include <PCF8574.h>
28
 #include <Wire.h>
28
 #include <Wire.h>
29
+#endif
30
+
31
+#ifdef PLATFORM_ESP
29
 #include "WifiStuff.h"
32
 #include "WifiStuff.h"
30
 #endif // PLATFORM_ESP
33
 #endif // PLATFORM_ESP
31
 
34
 
33
 
36
 
34
 // ----------------------------------------------------------------------------
37
 // ----------------------------------------------------------------------------
35
 
38
 
36
-#if (I2C_GPIO_EXPANDER_COUNT > 0)
39
+#if defined(TWI_GPIO) && (I2C_GPIO_EXPANDER_COUNT > 0)
37
 static uint8_t expand_addr[I2C_GPIO_EXPANDER_COUNT] = { I2C_GPIO_EXPANDER_ADDR };
40
 static uint8_t expand_addr[I2C_GPIO_EXPANDER_COUNT] = { I2C_GPIO_EXPANDER_ADDR };
38
 static PCF8574 expand[I2C_GPIO_EXPANDER_COUNT];
41
 static PCF8574 expand[I2C_GPIO_EXPANDER_COUNT];
39
 #endif
42
 #endif
40
 
43
 
41
 void gpio_i2c_init(void) {
44
 void gpio_i2c_init(void) {
42
-#if (I2C_GPIO_EXPANDER_COUNT > 0)
45
+#if defined(TWI_GPIO) && (I2C_GPIO_EXPANDER_COUNT > 0)
43
     for (int i = 0; i < I2C_GPIO_EXPANDER_COUNT; i++) {
46
     for (int i = 0; i < I2C_GPIO_EXPANDER_COUNT; i++) {
44
         expand[i].setAddress(expand_addr[i]);
47
         expand[i].setAddress(expand_addr[i]);
45
         expand[i].begin(0xFF);
48
         expand[i].begin(0xFF);
53
     } else if (pin < 0) {
56
     } else if (pin < 0) {
54
         // ignore negative pin numbers
57
         // ignore negative pin numbers
55
     } else {
58
     } else {
59
+#if defined(TWI_GPIO) && (I2C_GPIO_EXPANDER_COUNT > 0)
56
         pin -= 100;
60
         pin -= 100;
57
         int ex = pin / 8;
61
         int ex = pin / 8;
58
         pin = pin % 8;
62
         pin = pin % 8;
65
             }
69
             }
66
             expand[ex].setButtonMask(mask);
70
             expand[ex].setButtonMask(mask);
67
         }
71
         }
72
+#endif
68
     }
73
     }
69
 }
74
 }
70
 
75
 
74
     } else if (pin < 0) {
79
     } else if (pin < 0) {
75
         // ignore negative pin numbers
80
         // ignore negative pin numbers
76
     } else {
81
     } else {
82
+#if defined(TWI_GPIO) && (I2C_GPIO_EXPANDER_COUNT > 0)
77
         pin -= 100;
83
         pin -= 100;
78
         int ex = pin / 8;
84
         int ex = pin / 8;
79
         pin = pin % 8;
85
         pin = pin % 8;
80
         if (ex < I2C_GPIO_EXPANDER_COUNT) {
86
         if (ex < I2C_GPIO_EXPANDER_COUNT) {
81
             expand[ex].write(pin, value);
87
             expand[ex].write(pin, value);
82
         }
88
         }
89
+#endif
83
     }
90
     }
84
 }
91
 }
85
 
92
 
90
         // ignore negative pin numbers
97
         // ignore negative pin numbers
91
         return 0;
98
         return 0;
92
     } else {
99
     } else {
100
+#if defined(TWI_GPIO) && (I2C_GPIO_EXPANDER_COUNT > 0)
93
         pin -= 100;
101
         pin -= 100;
94
         int ex = pin / 8;
102
         int ex = pin / 8;
95
         pin = pin % 8;
103
         pin = pin % 8;
98
         } else {
106
         } else {
99
             return 0;
107
             return 0;
100
         }
108
         }
109
+#else
110
+        return 0;
111
+#endif
101
     }
112
     }
102
 }
113
 }
103
 
114
 

+ 4
- 0
src/Statemachine.cpp View File

24
 #include "config.h"
24
 #include "config.h"
25
 #include "config_pins.h"
25
 #include "config_pins.h"
26
 
26
 
27
+#ifdef FUNCTION_CONTROL
28
+
27
 Statemachine::DigitBuffer::DigitBuffer(int _size) {
29
 Statemachine::DigitBuffer::DigitBuffer(int _size) {
28
     size = _size;
30
     size = _size;
29
     pos = 0;
31
     pos = 0;
1521
         debug.println(s);
1523
         debug.println(s);
1522
     }
1524
     }
1523
 }
1525
 }
1526
+
1527
+#endif

Loading…
Cancel
Save