Skip to content

Commit 47f8381

Browse files
committed
cleanup for release - more Arduino like
1 parent d451b2a commit 47f8381

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

examples/Example03_NavigationUART/Example03_NavigationUART.ino

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ SfeFPC2534UART mySensor;
4141
static void on_error(uint16_t error)
4242
{
4343
// hal_set_led_status(HAL_LED_STATUS_ERROR);
44-
Serial.printf("[ERROR]\t%d - 0x%X\n\r", error, error);
44+
Serial.print("[ERROR]\t");
45+
Serial.print(error);
46+
Serial.print(" - 0x");
47+
Serial.println(error, HEX);
4548
}
4649

4750
//----------------------------------------------------------------------------
@@ -68,11 +71,12 @@ static void on_is_ready_change(bool isReady)
6871
// error?
6972
if (rc != FPC_RESULT_OK)
7073
{
71-
Serial.printf("[ERROR]\tFailed to start navigation mode - error: %d\n\r", rc);
74+
Serial.print("[ERROR]\tFailed to start navigation mode - error: ");
75+
Serial.println(rc);
7276
return;
7377
}
7478

75-
Serial.printf("[SETUP]\tSensor In Navigation mode.\n\r");
79+
Serial.println("[SETUP]\tSensor In Navigation mode");
7680
Serial.println();
7781
Serial.println("\t- Swipe Up, Down, Left, Right to see events.");
7882
Serial.println("\t- Press to toggle LED on/off.");
@@ -92,7 +96,8 @@ static void on_is_ready_change(bool isReady)
9296
static void on_version(char *version)
9397
{
9498
// just print the version string
95-
Serial.printf("\t\t%s\n\r", version);
99+
Serial.print("\t\t");
100+
Serial.println(version);
96101
}
97102

98103
//----------------------------------------------------------------------------
@@ -122,7 +127,9 @@ static void on_navigation(uint16_t gesture)
122127
break;
123128
case CMD_NAV_EVENT_PRESS:
124129
// Toggle the on-board LED
125-
Serial.printf("PRESS -> {LED %s}\n\r", ledState ? "OFF" : "ON");
130+
Serial.print("PRESS -> {LED");
131+
Serial.print(ledState ? "OFF" : "ON");
132+
Serial.println("}");
126133
ledState = !ledState;
127134
mySensor.setLED(ledState);
128135
break;
@@ -182,8 +189,14 @@ void setup()
182189
// Initialize the UART/Serial communication
183190

184191
// The internal UART buffer can fill up quickly and overflow. As such, increase its size.
185-
// RP2350 call.
192+
// This example is supporting ESP32 and RP2040 based boards - adjust as needed for other platforms.
193+
#if defined(ARDUINO_ARCH_RP2040)
186194
Serial1.setFIFOSize(512);
195+
#elif defined(ESP32)
196+
Serial1.setBufferSize(512);
197+
#endif
198+
199+
// Setup Serial1 for communication with the FPC2534
187200
Serial1.begin(921600, SERIAL_8N1);
188201
delay(100);
189202
for (uint32_t startMS = millis(); !Serial1 && (millis() - startMS < 5000);) // Wait for the serial port to be ready
@@ -222,7 +235,8 @@ void loop()
222235
fpc_result_t rc = mySensor.processNextResponse();
223236
if (rc != FPC_RESULT_OK && rc != FPC_PENDING_OPERATION)
224237
{
225-
Serial.printf("[ERROR] Processing Error: %d\n\r", rc);
238+
Serial.print("[ERROR] Processing Error: ");
239+
Serial.println(rc);
226240
}
227241

228242
delay(200);

0 commit comments

Comments
 (0)