|
1 | 1 | #include "VCF_Tasks.h" |
2 | 2 | #include "SharedFirmwareTypes.h" |
3 | | -#include "VCF_Globals.h" |
| 3 | +#include "EthernetAddressDefs.h" |
4 | 4 | #include "VCF_Constants.h" |
5 | 5 | #include <QNEthernet.h> |
6 | 6 | #include "ProtobufMsgInterface.h" |
@@ -37,7 +37,7 @@ HT_TASK::TaskResponse run_read_adc0_task(const unsigned long& sysMicros, const H |
37 | 37 | }); |
38 | 38 |
|
39 | 39 | // sample digital steering too TODO: move this to its own task maybe? |
40 | | - // OrbisBRInstance::instance().sample(); |
| 40 | + OrbisBRInstance::instance().sample(); |
41 | 41 | return HT_TASK::TaskResponse::YIELD; |
42 | 42 | } |
43 | 43 |
|
@@ -267,92 +267,9 @@ HT_TASK::TaskResponse run_dash_GPIOs_task(const unsigned long& sys_micros, const |
267 | 267 | NeopixelControllerInstance::instance().dim_neopixels(); |
268 | 268 | } |
269 | 269 |
|
270 | | - DashboardInterfaceInstance::instance().sync_dashboard_stored_state(); |
271 | | - |
272 | | - return HT_TASK::TaskResponse::YIELD; |
273 | | -} |
274 | | - |
275 | | -HT_TASK::TaskResponse create_ioexpander(const unsigned long& sys_micros, const HT_TASK::TaskInfo& task_info) |
276 | | -{ |
277 | | - Wire2.begin(); |
278 | | - IOExpanderInstance::create(0x20, Wire2); |
279 | | - IOExpanderInstance::instance().init(); |
280 | | - |
281 | | - IOExpanderInstance::instance().portMode(MCP23017Port::A, 0b00000000); |
282 | | - IOExpanderInstance::instance().portMode(MCP23017Port::B, 0b01111111); |
283 | | - |
284 | | - // IOExpanderInstance::instance().writeRegister(MCP23017Register::GPIO_A, 0x00); //Reset port A |
285 | | - // IOExpanderInstance::instance().writeRegister(MCP23017Register::GPIO_B, 0x00); //Reset port B |
286 | | - |
287 | | - IOExpanderInstance::instance().writeRegister(MCP23017Register::GPPU_B, 0xFF); //Internal pull-ups |
| 270 | + DashboardInterfaceInstance::instance().read_ioexpander(); |
288 | 271 |
|
289 | | - IOExpanderInstance::instance().writeRegister(MCP23017Register::IPOL_B, 0xFF); //Polarity (inverted) |
290 | | - |
291 | | - return HT_TASK::TaskResponse::YIELD; |
292 | | -} |
293 | | - |
294 | | -HT_TASK::TaskResponse read_ioexpander(const unsigned long& sys_micros, const HT_TASK::TaskInfo& task_info) |
295 | | -{ |
296 | | - uint16_t in = IOExpanderInstance::instance().read(); // NOLINT (linter thinks variable uninitialized) |
297 | | - // for (int i = 0; i < 8; ++i) { |
298 | | - // Serial.printf("%d ", in & 0x01); |
299 | | - // in = in >> 1; |
300 | | - // } |
301 | | - // Serial.println(""); |
302 | | - |
303 | | - //TODO: Double check the harnessing is not wrong this time |
304 | | - if (IOExpanderUtils::getBit(in, 1, 0)) { |
305 | | - DashboardInterfaceInstance::instance().set_dial_state(ControllerMode_e::MODE_0); |
306 | | - } else if (IOExpanderUtils::getBit(in, 1, 1)) { |
307 | | - DashboardInterfaceInstance::instance().set_dial_state(ControllerMode_e::MODE_1); |
308 | | - } else if (IOExpanderUtils::getBit(in, 1, 2)) { |
309 | | - DashboardInterfaceInstance::instance().set_dial_state(ControllerMode_e::MODE_2); |
310 | | - } else if (IOExpanderUtils::getBit(in, 1, 3)) { // NOLINT (pin is magic number) |
311 | | - DashboardInterfaceInstance::instance().set_dial_state(ControllerMode_e::MODE_3); |
312 | | - } else if (IOExpanderUtils::getBit(in, 1, 4)) { // NOLINT (pin is magic number) |
313 | | - DashboardInterfaceInstance::instance().set_dial_state(ControllerMode_e::MODE_4); |
314 | | - } else if (IOExpanderUtils::getBit(in, 1, 5)) { // NOLINT (pin is magic number) |
315 | | - DashboardInterfaceInstance::instance().set_dial_state(ControllerMode_e::MODE_5); |
316 | | - } |
317 | | - |
318 | | - ControllerMode_e state = DashboardInterfaceInstance::instance().get_dashboard_outputs().dial_state; // NOLINT (linter thinks state uninitialized) |
319 | | - switch (state) { |
320 | | - case ControllerMode_e::MODE_0: |
321 | | - { |
322 | | - IOExpanderInstance::instance().writePort(MCP23017Port::A, 0b00000010); |
323 | | - break; |
324 | | - } |
325 | | - case ControllerMode_e::MODE_1: |
326 | | - { |
327 | | - IOExpanderInstance::instance().writePort(MCP23017Port::A, 0b01010111); |
328 | | - break; |
329 | | - } |
330 | | - case ControllerMode_e::MODE_2: |
331 | | - { |
332 | | - IOExpanderInstance::instance().writePort(MCP23017Port::A, 0b00011000); |
333 | | - break; |
334 | | - } |
335 | | - case ControllerMode_e::MODE_3: |
336 | | - { |
337 | | - IOExpanderInstance::instance().writePort(MCP23017Port::A, 0b00010100); |
338 | | - break; |
339 | | - } |
340 | | - case ControllerMode_e::MODE_4: |
341 | | - { |
342 | | - IOExpanderInstance::instance().writePort(MCP23017Port::A, 0b01000101); |
343 | | - break; |
344 | | - } |
345 | | - case ControllerMode_e::MODE_5: |
346 | | - { |
347 | | - IOExpanderInstance::instance().writePort(MCP23017Port::A, 0b00100100); |
348 | | - break; |
349 | | - } |
350 | | - default: |
351 | | - { |
352 | | - IOExpanderInstance::instance().writePort(MCP23017Port::A, 0b11110000); |
353 | | - break; |
354 | | - } |
355 | | - } |
| 272 | + DashboardInterfaceInstance::instance().sync_dashboard_stored_state(); |
356 | 273 |
|
357 | 274 | return HT_TASK::TaskResponse::YIELD; |
358 | 275 | } |
@@ -616,7 +533,7 @@ void setup_all_interfaces() { |
616 | 533 | .DATA_BUTTON = VCFInterfaceConstants::BTN_DATA_READ, |
617 | 534 | .BUTTON_2 = VCFInterfaceConstants::BUTTON_2 |
618 | 535 | }; |
619 | | - DashboardInterfaceInstance::create(dashboard_gpios); //NOLINT |
| 536 | + DashboardInterfaceInstance::create(dashboard_gpios, VCFInterfaceConstants::IO_EXPANDER_ADDR, Wire2); //NOLINT |
620 | 537 | ACUInterfaceInstance::create(); |
621 | 538 | VCRInterfaceInstance::create(); |
622 | 539 |
|
|
0 commit comments