diff --git a/examples/osd/lgb-train/arduino-merkurbaord.geany b/examples/osd/lgb-train/arduino-merkurbaord.geany index bd3a46c5a..b90ea9056 100644 --- a/examples/osd/lgb-train/arduino-merkurbaord.geany +++ b/examples/osd/lgb-train/arduino-merkurbaord.geany @@ -23,7 +23,7 @@ long_line_behaviour=1 long_line_column=72 [files] -current_page=-1 +current_page=0 [VTE] last_dir=/home/harald diff --git a/examples/osd/lgb-train/project-conf.h b/examples/osd/lgb-train/project-conf.h index 6c8ede3e4..4ac91c697 100644 --- a/examples/osd/lgb-train/project-conf.h +++ b/examples/osd/lgb-train/project-conf.h @@ -37,14 +37,14 @@ #define PLATFORM_HAS_BATTERY 1 -#define LOOP_INTERVAL (1 * CLOCK_SECOND) +#define LOOP_INTERVAL (CLOCK_SECOND/10) /* Save energy */ //#define RDC_CONF_PT_YIELD_OFF /* For Debug: Dont allow MCU sleeping between channel checks */ -//#undef RDC_CONF_MCU_SLEEP -//#define RDC_CONF_MCU_SLEEP 0 +#undef RDC_CONF_MCU_SLEEP +#define RDC_CONF_MCU_SLEEP 0 /* Disabling RDC for demo purposes. Core updates often require more memory. */ /* For projects, optimize memory and enable RDC again. */ diff --git a/examples/osd/lgb-train/sketch.pde b/examples/osd/lgb-train/sketch.pde index 62184224b..63ea6db82 100644 --- a/examples/osd/lgb-train/sketch.pde +++ b/examples/osd/lgb-train/sketch.pde @@ -19,14 +19,45 @@ extern resource_t res_led, res_battery, res_cputemp; uint8_t led_pin=4; uint8_t led_status; + } +// Merkurboard and BB-L298 connected to it. +// |---------------------------------------------------------------------------| +// | The connections were as follows: | +// |--------------------------------|------------------------------------------| +// |Connector at Merkurboard Grove 4| Connector at BB-L298 | +// |--------------------------------|------------------------------------------| +// | Power<3>, 3V | CTRL<1>, +5V | +// | Power<4>, GND | CTRL<8>, GND | +// | Power<5>, GND | PWR<2>, GND | +// | Power<6>, VIN(@12VDC) | PWR<1>, VIN | +// | DIGITAL<3>, D3 | CTRL<5>, Enable_B | +// | DIGITAL<17>, D17 | CTRL<6>, IN3 | +// | DIGITAL<18>, D18 | CTRL<7>, IN4 | +// |--------------------------------|------------------------------------------| + +#define BB_Enable_B 3 +#define BB_IN3 17 +#define BB_IN4 18 + +#define IN3_L digitalWrite(BB_IN3, LOW); +#define IN3_H digitalWrite(BB_IN3, HIGH); +#define IN4_L digitalWrite(BB_IN4, LOW); +#define IN4_H digitalWrite(BB_IN4, HIGH); + #include Grove_LED_Bar bar(9, 8, 1); // Clock pin, Data pin, Orientation void setup (void) { + // BB-L298 + pinMode(BB_IN3, OUTPUT); + pinMode(BB_IN4, OUTPUT); + IN3_L; + IN4_L; + analogWrite(BB_Enable_B, 0); // switch off the led pinMode(led_pin, OUTPUT); digitalWrite(led_pin, HIGH); @@ -47,12 +78,17 @@ void setup (void) void loop (void) { - static int i = 0; + static int vbar = 0; + int sensorValue1 = analogRead(A4); + int sensorValue2 = analogRead(A5); + vbar = sensorValue2/100; // Walk through the levels - bar.setLevel(i++); - if (i >= 10){ - i=0; + bar.setLevel(10-vbar); + if (vbar >= 10){ + vbar=0; } + printf("x: %d , y: %d \n",sensorValue1,sensorValue2); + }