Skip to content

Clock #3

@spywhere

Description

@spywhere

Bitmap

00000     1 22222 33333 4   4 55555 66666 77777 88888 99999
0   0     1     2     3 4   4 5     6         7 8   8 9   9   :
0   0     1 22222 33333 44444 55555 66666     7 88888 99999
0   0     1 2         3     4     5 6   6     7 8   8     9   :
00000     1 22222 33333     4 55555 66666     7 88888 99999

Bitmap encoded into numbers

[x, y]=0123456789:

[0, 0]=10111111110 1534
[1, 0]=10110111110 1470
[2, 0]=10110111110 1470
[3, 0]=10110111110 1470
[4, 0]=11111111110 2046

[0, 1]=10001110110 1142
[1, 1]=00000000000 0   
[2, 1]=00000000001 1   
[3, 1]=00000000000 0   
[4, 1]=11111001110 1998

[0, 2]=10111110110 1526
[1, 2]=00111110110 502 
[2, 2]=00111110110 502 
[3, 2]=00111110110 502 
[4, 2]=11111111110 2046

[0, 3]=10100010100 1300
[1, 3]=00000000000 0   
[2, 3]=00000000001 1   
[3, 3]=00000000000 0   
[4, 3]=11011111110 1790

[0, 4]=10110110110 1462
[1, 4]=10110110110 1462
[2, 4]=10110110110 1462
[3, 4]=10110110110 1462
[4, 4]=11111111110 2046

Code to generate encoded bitmap

function digit(x, y)
  local y_2 = y % 2
  local ey = y // 2
  local oy = (y - 1) // 2

  if x == 4 then
    if y_2 == 0 then
      return 2046
    else
      return 1998 - 208 * oy
    end
  elseif y == 4 then
    return 1462
  elseif x == 0 then
    if y_2 == 0 then
      return 1534 - 8 * ey
    else
      return 1142 + 158 * oy
    end
  elseif y_2 == 0 then
    return 1470 - 968 * ey
  elseif y_2 == 1 then
    return 1 - (x % 2)
  end
  return 0
end

local time = os.date('*t')
local hour = time.hour
local minute = time.min
-- local hour = time.min
-- local minute = time.sec

for y=0, 4 do
  local str = ''

  for c=0, 4 do
    local ch = '#'
    local n = 0
    if c == 0 then
      n = hour // 10
      -- ch = tostring(n)
    elseif c == 1 then
      n = hour % 10
      -- ch = tostring(n)
    elseif c == 2 then
      n = 10 + (time.sec % 2)
      -- ch = ':'
    elseif c == 3 then
      n = minute // 10
      -- ch = tostring(n)
    elseif c == 4 then
      n = minute % 10
      -- ch = tostring(n)
    end

    for x=0, 4 do
      local d = digit(x, y)
      if (d >> (10 - n)) & 1 == 1 then
        str = str .. ch
      else
        str = str .. ' '
      end
    end

    str = str .. ' | '
  end

  print(str)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions