Skip to content

Commit c0519e0

Browse files
authored
Zero-pad hex addr values on displays
1 parent b16ec37 commit c0519e0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libraries/Bluefruit52Lib/examples/Projects/rssi_proximity/rssi_proximity_central/rssi_proximity_central.ino

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,22 @@ void renderResultsToTFT(void)
371371

372372
for (uint8_t i=0; i<ARRAY_SIZE; i++)
373373
{
374+
if (records[i].addr[0] <= 0xF) tft.print("0");
374375
tft.print(records[i].addr[0], HEX);
375376
tft.print(":");
377+
if (records[i].addr[1] <= 0xF) tft.print("0");
376378
tft.print(records[i].addr[1], HEX);
377379
tft.print(":");
380+
if (records[i].addr[2] <= 0xF) tft.print("0");
378381
tft.print(records[i].addr[2], HEX);
379382
tft.print(":");
383+
if (records[i].addr[3] <= 0xF) tft.print("0");
380384
tft.print(records[i].addr[3], HEX);
381385
tft.print(":");
386+
if (records[i].addr[4] <= 0xF) tft.print("0");
382387
tft.print(records[i].addr[4], HEX);
383388
tft.print(":");
389+
if (records[i].addr[5] <= 0xF) tft.print("0");
384390
tft.print(records[i].addr[5], HEX);
385391
tft.print(" ");
386392
tft.print(records[i].rssi);
@@ -409,16 +415,22 @@ void renderResultsToOLED(void)
409415
if (records[i].rssi != -128)
410416
{
411417
oled.setCursor(0, i*8);
418+
if (records[i].addr[0] <= 0xF) oled.print("0");
412419
oled.print(records[i].addr[0], HEX);
413420
oled.print(":");
421+
if (records[i].addr[1] <= 0xF) oled.print("0");
414422
oled.print(records[i].addr[1], HEX);
415423
oled.print(":");
424+
if (records[i].addr[2] <= 0xF) oled.print("0");
416425
oled.print(records[i].addr[2], HEX);
417426
oled.print(":");
427+
if (records[i].addr[3] <= 0xF) oled.print("0");
418428
oled.print(records[i].addr[3], HEX);
419429
oled.print(":");
430+
if (records[i].addr[4] <= 0xF) oled.print("0");
420431
oled.print(records[i].addr[4], HEX);
421432
oled.print(":");
433+
if (records[i].addr[5] <= 0xF) oled.print("0");
422434
oled.print(records[i].addr[5], HEX);
423435
oled.print(" ");
424436
oled.println(records[i].rssi);

0 commit comments

Comments
 (0)