Tutorial: Change Flipper xBT to fahrenheit, add offset, or change text

Hey y’all (hope this is the right category, if not, feel free to fix pilgrim)

As you might have seen, the Flipper Zero currently only displays temp readouts for the xBT in Celsius. If you want to change that, or add a temp offset to correct for your body temp, here’s how:

First, make sure you have git installed for your respective platform. NOTE: This only supports macOS and linux. You can use a VM if you’d like, but I won’t cover that in this tutorial. LMK if you’d like me to make one covering that.

Open a terminal, and run (depending on the firmware you’d like to use)
git clone --recursive https://github.com/flipperdevices/flipperzero-firmware
or
git clone --recursive https://github.com/DarkFlippers/unleashed-firmware

This will take a while, they’re big repos.

Once done, you can do

cd flipperzero-firmware/lib/lfrfid/protocols
or
cd unleashed-firmware/lib/lfrfid/protocols
once again depending on which firmware you downloaded.

You’ll want to then open a text editor, and edit file protocol_fdx_b.c.

I use nano, so
nano protocol_fdx_b.c
Then, using your text editor, search for the function

void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result)

Then, if you’d like to change the “Animal: Yes” printout, now’s the time.

Find the line
furi_string_cat_printf(result, "Animal: %s, ", animal_flag ? "Yes" : "No");

NOTE: There will be two results, go to the second one, under function protocol_fdx_b_render_brief_data.

You can change this to whatever you want. An example is:
furi_string_cat_printf(result, "Cyborg: Yes, ");

From that example you can put whatever you’d line in the quotes, or delete that line entirely.
Make sure that if you also delete the line

bool animal_flag = bit_lib_get_bit(protocol->data, 63);

if you aren’t using it in your printout, or you’ll get an error later for unused variable.

Next, temperature. This is a little bit tricky if you aren’t a programmer.

Pay attention to this section:

    float temperature;
    if(protocol_fdx_b_get_temp(protocol->data, &temperature)) {
        float temperature_c = (temperature - 32) / 1.8;
        furi_string_cat_printf(result, "T: %.2fC", (double)temperature_c);
    } else {
        furi_string_cat_printf(result, "T: ---");
    }

Variable temperature here is already in fahrenheit, and is filled by the protocol_fdx_b_get_temp() function.

If all you want is an offset, and you still want your temperature in celsius, here’s the code block you need. Just replace the entire block above with this one.

Celsius w/ Offset (replace 4.2 with whatever your desired offset is in Celsius)
    float temperature;
    if(protocol_fdx_b_get_temp(protocol->data, &temperature)) {
        float offset = 4.2;
        float temperature_c = (temperature - 32) / 1.8;
        temperature_c += offset;
        furi_string_cat_printf(result, "T: %.2fC", (double)temperature_c);
    } else {
        furi_string_cat_printf(result, "T: ---");
    }

If you want to show both fahrenheit and celsius, and you want to give your offset in degrees fahrenheit, here’s an example for you:

Fahrenheit + celsius w/ offset (replace 4.2 with desired offset in Fahrenheit)
    float temperature;
    if(protocol_fdx_b_get_temp(protocol->data, &temperature)) {
        float offset = 4.2;
        temperature += offset;
        float temperature_c = (temperature - 32) / 1.8;
        furi_string_cat_printf(result, "T: %.1fF %.2fC", (double)temperature, (double)temperature_c);
    } else {
        furi_string_cat_printf(result, "T: ---");
    }

And for those who don’t care about temp offsets:

Fahrenheit + Celsius, no offset
float temperature;
    if(protocol_fdx_b_get_temp(protocol->data, &temperature)) {
        float temperature_c = (temperature - 32) / 1.8;
        furi_string_cat_printf(result, "T: %.1fF %.2fC", (double)temperature, (double)temperature_c);
    } else {
        furi_string_cat_printf(result, "T: ---");
    }

Lastly…

Just fahrenheit w/ no offset (freedom edition)
    float temperature;
    if(protocol_fdx_b_get_temp(protocol->data, &temperature)) {
        furi_string_cat_printf(result, "T: %.1fF", (double)temperature);
    } else {
        furi_string_cat_printf(result, "T: ---");
    }

Hopefully from those examples, it’s easy to figure out how to modify it to your needs. LMK if any of them have issues, I just threw those together, but they all should be valid (I’ve used several of the combinations)

Okay, now that that’s done, run
cd ../../.. to get back to the main folder.

You can now run

./fbt, and it should automagically download the toolchain, and begin compilation. It may error out on your first try or two (missing header images or something IIRC?), just run it again.

When done, your firmware file will be in either
flipperzero-firmware/dist/f7-D
or
unleashed-firmware/dist/f7-D

It’ll be the flipper-z-f7-full-local.dfu file.

Then, open qFlipper, connect your flipper, and do Install from file. Pick your new dfu file.

(You also might be able to do ./fbt flash instead of using qFlipper, but that seems a bit more finicky)

Voila!

10 Likes

Thank you very much for the write up!
I’m doing this now, will report back when done.

1 Like

Feel free to lmk if you have any problems during the guide. I wrote it in a bit of a hurry, in about an hour I’m driving back to college (visiting home rn), but I wanted to get it posted before I left.

1 Like

There are two strings in protocol_fdx_b.c that I had to change. Line 291 and 322 show furi_string_cat_printf(result, "Animal: %s, ", animal_flag ? "Yes" : "No");

When I first compiled with only changing one, I didn’t notice the second line at the time, it still showed “Animal” when scanned. After changing both everything worked!

Screenshot-20221029-201044

1 Like

Line 291 shouldn’t have to be changed (if I’m getting the order of things right, don’t have my laptop open rn).

There’s two different functions:
protocol_fdx_b_render_brief_data
protocol_fdx_b_render_data

Only the stuff under render_brief_data has to be changed, since that’s what’s used for the display output.

The first result that you changed was likely the render_data function, which won’t affect display output. That’s why nothing changed until you edited the other line under brief_data.

I’ll edit the guide to clarify that, thanks. My mistake.

Glad you got yours working!

1 Like

Oh you’re right! I didn’t notice that.

Screenshot-20221029-203532
Ok, now I’m just having fun

3 Likes

:rofl:
I actually laughed out loud…well more like
multiple audible exhales in quick succession out of my nostrils

but still funny

d704d425-93fb-4c31-9490-59237d2ad106_text

2 Likes

This is awesome!

Or…you could just use Celsius

3 Likes

image

4 Likes

Thank you for putting this together! I assume it would have to be redone with each firmware update?

Yes. You could also run a git pull every so often, and it would pull the latest commits to the git repo, ensuring you’re always at the bleeding edge of updates.

2 Likes

Makes sense! I’m honestly both a little bit lazy and a PC user, so I’d probably just update less frequently in order to not have to do that as much. I do think I have an Ubuntu system lying around somewhere though…

Hopefully these kind of edits will be more easily and permanently changeable at some point.

If you wanted to just update occasionally, you could also clone a specific release:
(this page shows all of the release tags)

For example, 0.69.1 is the latest full release, you can clone just that release.
git clone --recursive --depth 1 --branch 0.69.1 https://github.com/flipperdevices/flipperzero-firmware

Just replace 0.69.1 with each new release. That way you have a firm checkpoint of sorts for each release, and aren’t doing random incremental upgrades.

Something else that I’m working on, as a stopgap until I can get the commits done (need to really look into their proper procedures and everything, always intimidating to commit to a big repo), I’ll start hosting prebuilt .dfu files on my site. I’ll just make 2 versions probably (F only, C+F) for both main repos, and automatically build them for a new release. Won’t have offsets, but that doesn’t really matter a ton anyways. Precision matters way more than accuracy for these implants, the offsets just make it a little more comforting.

I’ll post here when I get that done.

1 Like

@darthdomo Any chance this could be officially included in something like Unleashed or RogueMaster?

I think he is working on that

1 Like

Ah, gotcha! Thanks for the hard work @darthdomo!

2 Likes