Skip to content

Instantly share code, notes, and snippets.

@ffoxin
ffoxin / bin2hex.py
Last active January 3, 2016 20:59
Replace binary numbers (ex. 0b00110101) with its hex representation (ex. 0x35). Useful for adopting arduino Sketch project sources for common IDE.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import listdir
from os.path import isfile, join
import re
def bin2hex(dir_path, extensions):
bin_match = re.compile('0b[01]{8}')