This is the image you will want to download if you wish to generate the
header file yourself with the code provided.
<?php
$im = imagecreatefrompng('1602.png');
$image_width = imagesx($im);
$image_height = imagesy($im);
$tile_x_offset = 103;
$tile_y_offset = 46;
$tile_boundary_width = 35;
$tile_boundary_height = 50;
$tile_columns = 16;
$tile_rows = 16;
$tile_width = 5;
$tile_height = 8;
$pixel_width = 5;
$pixel_height = 5;
$pixel_width_midpoint = floor($pixel_width / 2);
$pixel_height_midpoint = floor($pixel_height / 2);
$binary = [];
$positions = [
0 // 0
, 0 // 1
, 1 // 2
, 2 // 3
, 3 // 4
, 4 // 5
, 5 // 6
, 6 // 7
, 0 // 8
, 0 // 9
, 7 // 10
, 8 // 11
, 9 // 12
, 10 // 13
, 11 // 14
, 12 // 15
];
for ($column = 0; $column < $tile_columns; $column++) {
for ($row = 0; $row < $tile_rows; $row++) {
for ($tile_x = 0; $tile_x < $tile_width; $tile_x++) {
for ($tile_y = 0; $tile_y < $tile_height; $tile_y++) {
$image_x = $tile_x_offset + $positions[$column] * $tile_boundary_width + ($tile_x + 1) * $pixel_width + $pixel_width_midpoint;
$image_y = $tile_y_offset + $row * $tile_boundary_height + (7 - $tile_y) * $pixel_height + $pixel_height_midpoint;
if ($image_x >= $image_width) {
exit('Invalid Tile Width Measurements');
}
if ($image_y >= $image_height) {
exit('Invalid Tile Height Measurements');
}
$pixel_color = imagecolorat($im, $image_x, $image_y);
$tile_number = $tile_rows * $column + $row;
if (!isset($binary[$tile_number][$tile_x])) {
$binary[$tile_number][$tile_x] = '0b';
}
$binary[$tile_number][$tile_x] .= $pixel_color ? '0' : '1';
}
}
}
}
print_r($binary);
foreach ($binary as $n => $vals) {
$binary[$n] = implode(", //" . ($n + 1) . "\r\n ", $vals);
}
$code = '
PROGMEM const byte LCD1602[] = {
' . implode(",\r\n ", $binary) . '
};
';
$fp = fopen('LCD1602.h', 'w');
fwrite($fp, $code);
fclose($fp);