Pārlūkot izejas kodu

fix build for other platforms.

Thomas Buck 2 gadus atpakaļ
vecāks
revīzija
a14515c3ec
5 mainītis faili ar 30 papildinājumiem un 7 dzēšanām
  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 Parādīt failu

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

+ 8
- 1
include/config_pins.h Parādīt failu

@@ -52,10 +52,15 @@
52 52
  * AVR Controller
53 53
  */
54 54
 
55
+#define I2C_GPIO_EXPANDER_COUNT 0
56
+//#define I2C_GPIO_EXPANDER_ADDR 0x20, 0x21
57
+
55 58
 // out 1, out 2, out 3, out 4, in
56 59
 #define VALVE_COUNT 5
57 60
 #define VALVE_PINS 10, 11, 12, 14, 15
58 61
 
62
+#define KICKSTART_PINS -1, -1, -1, -1
63
+
59 64
 // a, b, c
60 65
 #define PUMP_COUNT 3
61 66
 #define PUMP_PINS 16, 17, 18
@@ -65,7 +70,9 @@
65 70
 #define SWITCH_PINS 19, 20
66 71
 
67 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 76
 #define AUX_PINS 21
70 77
 
71 78
 #endif // FUNCTION_CONTROL

+ 3
- 2
platformio.ini Parādīt failu

@@ -15,18 +15,19 @@ default_envs = esp8266_main, esp32_main, arduino_ui, arduino_test, leonardo_main
15 15
 platform = espressif8266
16 16
 board = esp01_1m
17 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 19
 lib_deps =
20 20
     Wire
21 21
     https://github.com/Links2004/arduinoWebSockets
22 22
     https://github.com/rlogiacco/CircularBuffer
23 23
     https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino.git
24
+    https://github.com/RobTillaart/PCF8574
24 25
 
25 26
 [env:esp32_main]
26 27
 platform = espressif32
27 28
 board = esp32dev
28 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 31
 upload_protocol = esptool
31 32
 upload_port = /dev/ttyUSB1
32 33
 lib_deps =

+ 14
- 3
src/GPIOBank.cpp Parādīt failu

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

+ 4
- 0
src/Statemachine.cpp Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt