DevKitty-io / USB-Nugget

Run DuckyScript payloads on a USB Nugget!
https://usbnugget.com
MIT License
149 stars 16 forks source link

refactor build_web_ui.sh to speed build times #81

Closed brandonpaiz closed 1 year ago

brandonpaiz commented 1 year ago

build_web_ui.sh is responsible for converting our webpage from .html to a c-style array, stored in PROGMEM, which is imported and sent by the on-board webserver. build_web_ui.sh previously called file_to_progmem.sh which I wrote but was slow because it read two bytes at a time.

I've just found that xxd has a built-in option to convert a file into a C-style header. For example

>_ echo "hello there" > foo.txt
>_ xxd -i foo.txt
unsigned char foo_txt[] = {
  0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x72, 0x65, 0x0a
};
unsigned int foo_txt_len = 12;

This change removes file_to_progmem.sh and uses xxd instead. Faster build times with less code -- that's a win-win.