From d015c05c7a141f183647fe0cd64c332b7af23800 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 2 Dec 2014 20:06:26 +0100 Subject: o Splitting out the app code into its own file. o Understanding how pipes work, getting a TX part of a pipe to work. --- app.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app.cpp (limited to 'app.cpp') diff --git a/app.cpp b/app.cpp new file mode 100644 index 0000000..8163ad8 --- /dev/null +++ b/app.cpp @@ -0,0 +1,41 @@ +#include "app.h" + +#include + +// http://bleaklow.com/2010/09/05/progmem_and_gcc_bug_34734.html +#undef PROGMEM +#define PROGMEM __attribute__((section(".progmem.data"))) + +#define GAUGE_COUNT 4 + +// See http://redbearlab.com/blendmicro/ +int gauge_pins[GAUGE_COUNT] = { + 9, 10, 11, 13 +}; + +void on_gauge_data(uint8_t *data, uint8_t len) { + Serial.print(F("on_gauge_data, channel=")); + Serial.print(data[0], HEX); + Serial.print(F(", data[1]=")); + Serial.println(data[1], HEX); +} + +void on_gauge_ctrl(uint8_t *data, uint8_t len) { + Serial.print(F("on_gauge_data, data[0]=")); + Serial.print(data[0], HEX); + Serial.print(F(", data[1]=")); + Serial.println(data[1], HEX); + + uint8_t res[2]; + + switch(data[0]) { + case FSP_CMD_GAUGE_COUNT: + res[0] = FSP_CMD_GAUGE_COUNT; + res[1] = GAUGE_COUNT; + send_ctrl(res, 2); + break; + default: + break; + } +} + -- cgit v1.2.3